@undefineds.co/xpod 0.4.3 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. package/config/cloud.json +1 -1
  2. package/config/main.json +36 -2
  3. package/dist/api/ai-gateway/auth/GatewayApiKeyAuthenticator.d.ts +3 -0
  4. package/dist/api/ai-gateway/auth/GatewayApiKeyAuthenticator.js +1 -1
  5. package/dist/api/ai-gateway/auth/PodGatewayAccessKeyRepository.d.ts +2 -1
  6. package/dist/api/ai-gateway/auth/PodGatewayAccessKeyRepository.js +101 -32
  7. package/dist/api/ai-gateway/connect/DeviceCodeProtocol.d.ts +80 -0
  8. package/dist/api/ai-gateway/connect/DeviceCodeProtocol.js +3 -0
  9. package/dist/api/ai-gateway/connect/FileSessionImportAdapter.d.ts +38 -0
  10. package/dist/api/ai-gateway/connect/FileSessionImportAdapter.js +63 -0
  11. package/dist/api/ai-gateway/connect/LoopbackAuthorizationCallbackReceiver.d.ts +24 -0
  12. package/dist/api/ai-gateway/connect/LoopbackAuthorizationCallbackReceiver.js +136 -0
  13. package/dist/api/ai-gateway/connect/OAuthConnectAdapter.d.ts +2 -0
  14. package/dist/api/ai-gateway/connect/OAuthConnectAdapter.js +2 -1
  15. package/dist/api/ai-gateway/connect/OAuthIntegrationRegistry.d.ts +17 -13
  16. package/dist/api/ai-gateway/connect/OAuthIntegrationRegistry.js +52 -19
  17. package/dist/api/ai-gateway/connect/OpenAiSubscriptionSessionImportAdapter.d.ts +4 -28
  18. package/dist/api/ai-gateway/connect/OpenAiSubscriptionSessionImportAdapter.js +7 -58
  19. package/dist/api/ai-gateway/connect/ProviderAuthorizationProfiles.d.ts +4 -0
  20. package/dist/api/ai-gateway/connect/ProviderAuthorizationProfiles.js +116 -0
  21. package/dist/api/ai-gateway/connect/SessionImportProfiles.d.ts +10 -0
  22. package/dist/api/ai-gateway/connect/SessionImportProfiles.js +112 -0
  23. package/dist/api/ai-gateway/connect/index.d.ts +125 -23
  24. package/dist/api/ai-gateway/connect/index.js +1277 -260
  25. package/dist/api/ai-gateway/models/PodModelSelectionRepository.d.ts +4 -1
  26. package/dist/api/ai-gateway/models/PodModelSelectionRepository.js +154 -19
  27. package/dist/api/ai-gateway/providers/DeepSeekRuntimeAdapter.js +10 -6
  28. package/dist/api/ai-gateway/providers/ModelsDevCatalog.d.ts +7 -0
  29. package/dist/api/ai-gateway/providers/ModelsDevCatalog.js +25 -1
  30. package/dist/api/ai-gateway/providers/OfferingAuthorization.d.ts +24 -0
  31. package/dist/api/ai-gateway/providers/OfferingAuthorization.js +37 -0
  32. package/dist/api/ai-gateway/providers/OpenAiRuntimeAdapter.d.ts +1 -1
  33. package/dist/api/ai-gateway/providers/OpenAiRuntimeAdapter.js +5 -3
  34. package/dist/api/ai-gateway/providers/ProviderRegistry.d.ts +6 -3
  35. package/dist/api/ai-gateway/providers/ProviderRegistry.js +55 -16
  36. package/dist/api/ai-gateway/providers/ProviderRuntimeAdapter.d.ts +2 -0
  37. package/dist/api/ai-gateway/providers/ProviderRuntimeAdapter.js +37 -4
  38. package/dist/api/ai-gateway/providers/ProviderRuntimeRegistry.js +7 -0
  39. package/dist/api/ai-gateway/quota/SubscriptionQuotaAdapters.js +2 -1
  40. package/dist/api/ai-gateway/routing/ModelRouter.js +3 -1
  41. package/dist/api/container/common.js +30 -40
  42. package/dist/api/container/index.js +6 -2
  43. package/dist/api/container/routes.js +5 -22
  44. package/dist/api/handlers/AiClientConfigurationHandler.js +39 -1
  45. package/dist/api/handlers/AiGatewayManagementHandler.d.ts +3 -0
  46. package/dist/api/handlers/AiGatewayManagementHandler.js +173 -58
  47. package/dist/api/service/AiClientConfigurationService.d.ts +4 -15
  48. package/dist/api/service/AiClientConfigurationService.js +17 -64
  49. package/dist/cli/commands/start.js +2 -0
  50. package/dist/components/components.jsonld +1 -0
  51. package/dist/components/context.jsonld +80 -0
  52. package/dist/http/InternalPodDataHttpHandler.d.ts +3 -0
  53. package/dist/http/InternalPodDataHttpHandler.js +13 -2
  54. package/dist/http/InternalPodDataHttpHandler.jsonld +12 -0
  55. package/dist/identity/oidc/RememberedClientPromptFactory.d.ts +1 -1
  56. package/dist/identity/oidc/RememberedClientPromptFactory.js +5 -2
  57. package/dist/identity/oidc/RememberedConsentHandler.js +1 -1
  58. package/dist/identity/oidc/ScopedPickWebIdHandler.d.ts +1 -0
  59. package/dist/identity/oidc/ScopedPickWebIdHandler.js +26 -0
  60. package/dist/identity/oidc/ScopedPickWebIdHandler.jsonld +4 -0
  61. package/dist/identity/oidc/SessionBoundIdentityProviderFactory.d.ts +10 -0
  62. package/dist/identity/oidc/SessionBoundIdentityProviderFactory.js +21 -0
  63. package/dist/identity/oidc/SessionBoundIdentityProviderFactory.jsonld +172 -0
  64. package/dist/index.d.ts +2 -1
  65. package/dist/index.js +4 -2
  66. package/dist/runtime/component-parameter-keys.js +18 -2
  67. package/dist/storage/accessors/MixDataAccessor.js +6 -2
  68. package/dist/storage/rdf/PostgresRdfEngine.js +10 -2
  69. package/dist/storage/rdf/RdfContentTypes.js +4 -0
  70. package/node_modules/@undefineds.co/ai-connections/dist/AiClientConfigurationSection.d.ts +3 -0
  71. package/node_modules/@undefineds.co/ai-connections/dist/AiClientConfigurationSection.js +13 -16
  72. package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsList.js +1 -3
  73. package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsMain.d.ts +2 -1
  74. package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsMain.js +2 -2
  75. package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsPanel.d.ts +4 -1
  76. package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsPanel.js +127 -57
  77. package/node_modules/@undefineds.co/ai-connections/dist/AiCredentialPoolSection.d.ts +6 -4
  78. package/node_modules/@undefineds.co/ai-connections/dist/AiCredentialPoolSection.js +436 -83
  79. package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayKeysSection.d.ts +3 -2
  80. package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayKeysSection.js +212 -76
  81. package/node_modules/@undefineds.co/ai-connections/dist/AiProviderCard.d.ts +6 -4
  82. package/node_modules/@undefineds.co/ai-connections/dist/AiProviderCard.js +58 -41
  83. package/node_modules/@undefineds.co/ai-connections/dist/AiQuotaCard.d.ts +4 -1
  84. package/node_modules/@undefineds.co/ai-connections/dist/AiQuotaCard.js +63 -4
  85. package/node_modules/@undefineds.co/ai-connections/dist/ai-connections-client.d.ts +46 -6
  86. package/node_modules/@undefineds.co/ai-connections/dist/ai-connections-client.js +143 -14
  87. package/node_modules/@undefineds.co/ai-connections/dist/client-config/base-adapter.d.ts +19 -3
  88. package/node_modules/@undefineds.co/ai-connections/dist/client-config/base-adapter.js +45 -7
  89. package/node_modules/@undefineds.co/ai-connections/dist/client-config/codex.d.ts +7 -1
  90. package/node_modules/@undefineds.co/ai-connections/dist/client-config/codex.js +305 -40
  91. package/node_modules/@undefineds.co/ai-connections/dist/client-config/index.cjs +383 -50
  92. package/node_modules/@undefineds.co/ai-connections/dist/client-config/json-env-adapter.js +3 -2
  93. package/node_modules/@undefineds.co/ai-connections/dist/client-config/pi.js +12 -3
  94. package/node_modules/@undefineds.co/ai-connections/dist/client-config/transaction.d.ts +2 -0
  95. package/node_modules/@undefineds.co/ai-connections/dist/client-config/transaction.js +39 -4
  96. package/node_modules/@undefineds.co/ai-connections/dist/client-config/types.d.ts +8 -1
  97. package/node_modules/@undefineds.co/ai-connections/dist/client-visuals.d.ts +2 -0
  98. package/node_modules/@undefineds.co/ai-connections/dist/client-visuals.js +14 -0
  99. package/node_modules/@undefineds.co/ai-connections/dist/controller.d.ts +2 -2
  100. package/node_modules/@undefineds.co/ai-connections/dist/controller.js +216 -57
  101. package/node_modules/@undefineds.co/ai-connections/dist/index.d.ts +3 -1
  102. package/node_modules/@undefineds.co/ai-connections/dist/index.js +16 -2
  103. package/node_modules/@undefineds.co/ai-connections/dist/provider-visuals.js +6 -1
  104. package/node_modules/@undefineds.co/drizzle-solid/dist/core/execution/ldp-executor.js +27 -6
  105. package/node_modules/@undefineds.co/drizzle-solid/dist/core/pod-database.js +1 -1
  106. package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-builders/select-query-builder.js +2 -2
  107. package/node_modules/@undefineds.co/drizzle-solid/dist/core/sparql/builder/update-builder.js +12 -1
  108. package/node_modules/@undefineds.co/drizzle-solid/dist/core/triple/builder.js +1 -1
  109. package/node_modules/@undefineds.co/drizzle-solid/dist/core/triple/handlers/array.js +8 -0
  110. package/node_modules/@undefineds.co/drizzle-solid/dist/core/triple/handlers/default.js +9 -1
  111. package/node_modules/@undefineds.co/drizzle-solid/dist/core/triple/handlers/inline.js +3 -3
  112. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/execution/ldp-executor.js +27 -6
  113. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/pod-database.js +1 -1
  114. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-builders/select-query-builder.js +2 -2
  115. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/sparql/builder/update-builder.js +12 -1
  116. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/triple/builder.js +1 -1
  117. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/triple/handlers/array.js +8 -0
  118. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/triple/handlers/default.js +9 -1
  119. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/triple/handlers/inline.js +3 -3
  120. package/node_modules/@undefineds.co/extension-sdk/dist/web.d.ts +31 -0
  121. package/package.json +2 -2
  122. package/static/app/assets/{index-BikOyGPu.js → index-BCZVzMpj.js} +44 -44
  123. package/static/app/assets/inrupt-smoke.js +2 -2
  124. package/static/app/assets/main.css +1 -1
  125. package/static/app/assets/main.js +10 -10
  126. package/static/auth-callback/assets/{AiConfigContext-DrCH6ckh.js → AiConfigContext-DVkh8Kg2.js} +1 -1
  127. package/static/auth-callback/assets/{AiConfigPage-DVrlSSdA.js → AiConfigPage-HWVWpe-P.js} +1 -1
  128. package/static/auth-callback/assets/{DocumentProcessingPanel-_Md-v2R2.js → DocumentProcessingPanel-DDq-mH17.js} +1 -1
  129. package/static/auth-callback/assets/{IndexLifecyclePanel-BbWwe23H.js → IndexLifecyclePanel-Cx4cjrdP.js} +1 -1
  130. package/static/auth-callback/assets/{IndexSubjectPanel-upH9MjU-.js → IndexSubjectPanel-DzSw8M9j.js} +1 -1
  131. package/static/auth-callback/assets/{ModelAssignmentsPanel-CVGH4t4g.js → ModelAssignmentsPanel-BsRxGc2p.js} +1 -1
  132. package/static/auth-callback/assets/ModelsPage-DEe1lo6Q.js +10 -0
  133. package/static/auth-callback/assets/{NetworkPage-Dcbrb1fd.js → NetworkPage-DBiEh1Oz.js} +1 -1
  134. package/static/auth-callback/assets/{PaneListHeader-DrY-1wBq.js → PaneListHeader-lEEgjyN9.js} +1 -1
  135. package/static/auth-callback/assets/{SearchIndexingPanel-Dw25y53v.js → SearchIndexingPanel-CZCUUGt6.js} +1 -1
  136. package/static/auth-callback/assets/{StatusSubjectPanel-BHlz9rNF.js → StatusSubjectPanel-21qdueMr.js} +1 -1
  137. package/static/auth-callback/assets/{StatusWorkspace-BH7exQP5.js → StatusWorkspace-R8RKsqVz.js} +1 -1
  138. package/static/auth-callback/assets/{SystemSettingsPage-BYLKnM9f.js → SystemSettingsPage-BQ4e-4Wy.js} +1 -1
  139. package/static/auth-callback/assets/{SystemSettingsSubjectPanel-DT34LKku.js → SystemSettingsSubjectPanel-BopXD7SE.js} +1 -1
  140. package/static/auth-callback/assets/{activity-DdULRcSI.js → activity-DSfmTGfY.js} +1 -1
  141. package/static/auth-callback/assets/ai-connections-C03UWyPh.js +1 -0
  142. package/static/auth-callback/assets/{auth-callback-D7l2P25I.js → auth-callback-DleaitAS.js} +91 -91
  143. package/static/auth-callback/assets/auth-callback-vPSC2d2F.css +1 -0
  144. package/static/auth-callback/assets/{badge-j4zjFnmg.js → badge-B0aLu1sl.js} +1 -1
  145. package/static/auth-callback/assets/{download-DGXoks01.js → download-D_bFwdYJ.js} +1 -1
  146. package/static/auth-callback/assets/{external-link-CvbgXXaI.js → external-link-DRfjTaQu.js} +1 -1
  147. package/static/auth-callback/assets/{index-LRWvKJ2i.js → index-CG23cLYQ.js} +1 -1
  148. package/static/auth-callback/assets/{index-BOK3j1dz.js → index-CyV9ejwx.js} +1 -1
  149. package/static/auth-callback/assets/{index-browser-C1Qpe0g4.js → index-browser-D70paxIg.js} +1 -1
  150. package/static/auth-callback/assets/{key-round-CmgS5UdQ.js → key-round-BjV_mVYH.js} +1 -1
  151. package/static/auth-callback/assets/{rotate-ccw-c4CSG6Rq.js → rotate-ccw-CKoOAfse.js} +1 -1
  152. package/static/auth-callback/assets/{skeleton-ZPMTiRSM.js → skeleton-BZNjZaHx.js} +1 -1
  153. package/static/auth-callback/assets/{waypoints-xjyBflU5.js → waypoints-DoaJVzZv.js} +1 -1
  154. package/static/auth-callback/assets/{workspace-layout-B9nj6F5J.js → workspace-layout-CaP46_ZR.js} +1 -1
  155. package/static/auth-callback/auth-callback.html +2 -2
  156. package/static/dashboard/assets/{AiConfigContext-BWOOSYNr.js → AiConfigContext-BSrR27yD.js} +1 -1
  157. package/static/dashboard/assets/{AiConfigPage-CG2kQ9Wy.js → AiConfigPage-D65Z2LET.js} +1 -1
  158. package/static/dashboard/assets/{DocumentProcessingPanel-B4VXajfj.js → DocumentProcessingPanel-DyTe7Nei.js} +1 -1
  159. package/static/dashboard/assets/{IndexLifecyclePanel-CWCy0CC8.js → IndexLifecyclePanel-fK8ZGlrL.js} +1 -1
  160. package/static/dashboard/assets/{IndexSubjectPanel-CSgyQnG_.js → IndexSubjectPanel-CZPGor7v.js} +1 -1
  161. package/static/dashboard/assets/{ModelAssignmentsPanel-CdGIGidT.js → ModelAssignmentsPanel-CfYn5LMQ.js} +1 -1
  162. package/static/dashboard/assets/ModelsPage-djlJsghe.js +25 -0
  163. package/static/dashboard/assets/{NetworkPage-COia9NCH.js → NetworkPage-Coj6GnPl.js} +1 -1
  164. package/static/dashboard/assets/{PaneListHeader-SZWyr602.js → PaneListHeader-CUuFNSsZ.js} +1 -1
  165. package/static/dashboard/assets/{SearchIndexingPanel-D6PZtG6k.js → SearchIndexingPanel-CyJLioXS.js} +1 -1
  166. package/static/dashboard/assets/{StatusSubjectPanel-CxRD4kv0.js → StatusSubjectPanel-Cv26GSVC.js} +1 -1
  167. package/static/dashboard/assets/{StatusWorkspace-D3PfmY9-.js → StatusWorkspace-CDjFrsmB.js} +1 -1
  168. package/static/dashboard/assets/{SystemSettingsPage-COg1MmMj.js → SystemSettingsPage-BuNOyNoa.js} +1 -1
  169. package/static/dashboard/assets/{SystemSettingsSubjectPanel-BSVVB9Ol.js → SystemSettingsSubjectPanel-B2dasdez.js} +1 -1
  170. package/static/dashboard/assets/{activity-BJJx5cN-.js → activity-D1d2j_4Z.js} +1 -1
  171. package/static/dashboard/assets/ai-connections-C03UWyPh.js +1 -0
  172. package/static/dashboard/assets/{badge-elmrFSCj.js → badge-BeAAv6sp.js} +1 -1
  173. package/static/dashboard/assets/{dashboard-IvQrNmru.js → dashboard-BnGrUGv8.js} +68 -68
  174. package/static/dashboard/assets/dashboard-vPSC2d2F.css +1 -0
  175. package/static/dashboard/assets/{download-C3FH2KzG.js → download-DfFGiZRn.js} +1 -1
  176. package/static/dashboard/assets/{external-link-Bx7F0uKb.js → external-link-IsjU_LC9.js} +1 -1
  177. package/static/dashboard/assets/{index-liRoRIP1.js → index-BWQTucPe.js} +1 -1
  178. package/static/dashboard/assets/{index-M4-kWiGz.js → index-Dj75OjnW.js} +1 -1
  179. package/static/dashboard/assets/{key-round-CXg0bKAj.js → key-round-BJ_9wmQ_.js} +1 -1
  180. package/static/dashboard/assets/{rotate-ccw-yxJKOBrX.js → rotate-ccw-D3JGiFbR.js} +1 -1
  181. package/static/dashboard/assets/{skeleton-x9jNGrQT.js → skeleton-CC4nc-z-.js} +1 -1
  182. package/static/dashboard/assets/{waypoints-CTKeRsGp.js → waypoints-h7sqFqiG.js} +1 -1
  183. package/static/dashboard/assets/{workspace-layout--YkgkS38.js → workspace-layout-ZAPTOHhs.js} +1 -1
  184. package/static/dashboard/dashboard.html +2 -2
  185. package/static/settings/assets/{AiConfigContext-CelxXFcQ.js → AiConfigContext-lGkWpvKP.js} +1 -1
  186. package/static/settings/assets/{AiConfigPage-BaP-EovM.js → AiConfigPage-BbZWIBZq.js} +1 -1
  187. package/static/settings/assets/{DocumentProcessingPanel-DzLZluFv.js → DocumentProcessingPanel-DvYdjT-V.js} +1 -1
  188. package/static/settings/assets/{IndexLifecyclePanel-Bzj1-_oI.js → IndexLifecyclePanel-W5OGQZj7.js} +1 -1
  189. package/static/settings/assets/{IndexSubjectPanel-B263QLUh.js → IndexSubjectPanel-g_Aa5soq.js} +1 -1
  190. package/static/settings/assets/{ModelAssignmentsPanel-BAdT4UR0.js → ModelAssignmentsPanel-COlMBKXj.js} +1 -1
  191. package/static/settings/assets/ModelsPage-mApKi-aw.js +10 -0
  192. package/static/settings/assets/{NetworkPage-BK6a7l4g.js → NetworkPage-BDT05JUq.js} +1 -1
  193. package/static/settings/assets/{PaneListHeader-BAS2ICPq.js → PaneListHeader-CByhNpMG.js} +1 -1
  194. package/static/settings/assets/{SearchIndexingPanel-Cb_p-NgW.js → SearchIndexingPanel-BFAyzXls.js} +1 -1
  195. package/static/settings/assets/{StatusSubjectPanel-CcjqUua6.js → StatusSubjectPanel-Bz_XZ3VU.js} +1 -1
  196. package/static/settings/assets/{StatusWorkspace-7Ibty3_k.js → StatusWorkspace-CeVypHcW.js} +1 -1
  197. package/static/settings/assets/{SystemSettingsPage-DPSz4dg4.js → SystemSettingsPage-Dh7cQIfx.js} +1 -1
  198. package/static/settings/assets/{SystemSettingsSubjectPanel-Cb4HkKT5.js → SystemSettingsSubjectPanel-CSnpciO0.js} +1 -1
  199. package/static/settings/assets/{activity-Qhsr5Pxu.js → activity-DXz3EfFN.js} +1 -1
  200. package/static/settings/assets/ai-connections-C03UWyPh.js +1 -0
  201. package/static/settings/assets/{badge-B1vf2qCl.js → badge-1ZA144i4.js} +1 -1
  202. package/static/settings/assets/{download-CYNt0aZ-.js → download-CUHimlYa.js} +1 -1
  203. package/static/settings/assets/{external-link-ClKb39NT.js → external-link-BYHSVj2Z.js} +1 -1
  204. package/static/settings/assets/{index-y8ew3MLM.js → index-DKPDMdW5.js} +1 -1
  205. package/static/settings/assets/{index-browser-DJhvgpNI.js → index-browser-BaEFz0e0.js} +1 -1
  206. package/static/settings/assets/{index-BgiIDSch.js → index-viSgSvbO.js} +1 -1
  207. package/static/settings/assets/{key-round-5d-DrJz-.js → key-round-COByPOg8.js} +1 -1
  208. package/static/settings/assets/{rotate-ccw-CHZY7kS5.js → rotate-ccw-BC2EN6cE.js} +1 -1
  209. package/static/settings/assets/{settings-D5VRWyx6.js → settings-DLH9XUoT.js} +86 -86
  210. package/static/settings/assets/settings-vPSC2d2F.css +1 -0
  211. package/static/settings/assets/{skeleton-FNabNxNE.js → skeleton-B0-FOhKL.js} +1 -1
  212. package/static/settings/assets/{waypoints-BnL_8ljo.js → waypoints-DGMsvqWo.js} +1 -1
  213. package/static/settings/assets/{workspace-layout-D5q3F59S.js → workspace-layout-B0SVrJIu.js} +1 -1
  214. package/static/settings/settings.html +2 -2
  215. package/static/auth-callback/assets/ModelsPage-BpkVFKbf.js +0 -10
  216. package/static/auth-callback/assets/ai-connections-Bm52UO7Y.js +0 -1
  217. package/static/auth-callback/assets/auth-callback-01yz-UDU.css +0 -1
  218. package/static/dashboard/assets/ModelsPage-Chd5UK0D.js +0 -25
  219. package/static/dashboard/assets/ai-connections-Bm52UO7Y.js +0 -1
  220. package/static/dashboard/assets/dashboard-01yz-UDU.css +0 -1
  221. package/static/settings/assets/ModelsPage-C0NFa1zq.js +0 -10
  222. package/static/settings/assets/ai-connections-Bm52UO7Y.js +0 -1
  223. package/static/settings/assets/settings-01yz-UDU.css +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BikOyGPu.js","assets/_commonjsHelpers-B-UnjaXt.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BCZVzMpj.js","assets/_commonjsHelpers-B-UnjaXt.js"])))=>i.map(i=>d[i]);
2
2
  import{g as Bi}from"./_commonjsHelpers-B-UnjaXt.js";const Wt=crypto,zr=o=>o instanceof CryptoKey,bt=new TextEncoder,jt=new TextDecoder;function Vn(...o){const i=o.reduce((p,{length:v})=>p+v,0),c=new Uint8Array(i);let s=0;for(const p of o)c.set(p,s),s+=p.length;return c}const Mi=o=>{let i=o;typeof i=="string"&&(i=bt.encode(i));const c=32768,s=[];for(let p=0;p<i.length;p+=c)s.push(String.fromCharCode.apply(null,i.subarray(p,p+c)));return btoa(s.join(""))},yr=o=>Mi(o).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),ji=o=>{const i=atob(o),c=new Uint8Array(i.length);for(let s=0;s<i.length;s++)c[s]=i.charCodeAt(s);return c},Ut=o=>{let i=o;i instanceof Uint8Array&&(i=jt.decode(i)),i=i.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return ji(i)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}};class ze extends Error{constructor(i,c){super(i,c),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}ze.code="ERR_JOSE_GENERIC";class vt extends ze{constructor(i,c,s="unspecified",p="unspecified"){super(i,{cause:{claim:s,reason:p,payload:c}}),this.code="ERR_JWT_CLAIM_VALIDATION_FAILED",this.claim=s,this.reason=p,this.payload=c}}vt.code="ERR_JWT_CLAIM_VALIDATION_FAILED";class Hr extends ze{constructor(i,c,s="unspecified",p="unspecified"){super(i,{cause:{claim:s,reason:p,payload:c}}),this.code="ERR_JWT_EXPIRED",this.claim=s,this.reason=p,this.payload=c}}Hr.code="ERR_JWT_EXPIRED";class Wn extends ze{constructor(){super(...arguments),this.code="ERR_JOSE_ALG_NOT_ALLOWED"}}Wn.code="ERR_JOSE_ALG_NOT_ALLOWED";class ut extends ze{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}}ut.code="ERR_JOSE_NOT_SUPPORTED";class Ki extends ze{constructor(i="decryption operation failed",c){super(i,c),this.code="ERR_JWE_DECRYPTION_FAILED"}}Ki.code="ERR_JWE_DECRYPTION_FAILED";class Vi extends ze{constructor(){super(...arguments),this.code="ERR_JWE_INVALID"}}Vi.code="ERR_JWE_INVALID";class Te extends ze{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}}Te.code="ERR_JWS_INVALID";class br extends ze{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}}br.code="ERR_JWT_INVALID";class Wi extends ze{constructor(){super(...arguments),this.code="ERR_JWK_INVALID"}}Wi.code="ERR_JWK_INVALID";class Gr extends ze{constructor(){super(...arguments),this.code="ERR_JWKS_INVALID"}}Gr.code="ERR_JWKS_INVALID";class Yr extends ze{constructor(i="no applicable key found in the JSON Web Key Set",c){super(i,c),this.code="ERR_JWKS_NO_MATCHING_KEY"}}Yr.code="ERR_JWKS_NO_MATCHING_KEY";class Jn extends ze{constructor(i="multiple matching keys found in the JSON Web Key Set",c){super(i,c),this.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS"}}Jn.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";class qn extends ze{constructor(i="request timed out",c){super(i,c),this.code="ERR_JWKS_TIMEOUT"}}qn.code="ERR_JWKS_TIMEOUT";class $n extends ze{constructor(i="signature verification failed",c){super(i,c),this.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED"}}$n.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";function St(o,i="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${i} must be ${o}`)}function tr(o,i){return o.name===i}function Rr(o){return parseInt(o.name.slice(4),10)}function Ji(o){switch(o){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}function qi(o,i){if(i.length&&!i.some(c=>o.usages.includes(c))){let c="CryptoKey does not support this operation, its usages must include ";if(i.length>2){const s=i.pop();c+=`one of ${i.join(", ")}, or ${s}.`}else i.length===2?c+=`one of ${i[0]} or ${i[1]}.`:c+=`${i[0]}.`;throw new TypeError(c)}}function $i(o,i,...c){switch(i){case"HS256":case"HS384":case"HS512":{if(!tr(o.algorithm,"HMAC"))throw St("HMAC");const s=parseInt(i.slice(2),10);if(Rr(o.algorithm.hash)!==s)throw St(`SHA-${s}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!tr(o.algorithm,"RSASSA-PKCS1-v1_5"))throw St("RSASSA-PKCS1-v1_5");const s=parseInt(i.slice(2),10);if(Rr(o.algorithm.hash)!==s)throw St(`SHA-${s}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!tr(o.algorithm,"RSA-PSS"))throw St("RSA-PSS");const s=parseInt(i.slice(2),10);if(Rr(o.algorithm.hash)!==s)throw St(`SHA-${s}`,"algorithm.hash");break}case"EdDSA":{if(o.algorithm.name!=="Ed25519"&&o.algorithm.name!=="Ed448")throw St("Ed25519 or Ed448");break}case"Ed25519":{if(!tr(o.algorithm,"Ed25519"))throw St("Ed25519");break}case"ES256":case"ES384":case"ES512":{if(!tr(o.algorithm,"ECDSA"))throw St("ECDSA");const s=Ji(i);if(o.algorithm.namedCurve!==s)throw St(s,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}qi(o,c)}function zn(o,i,...c){if(c=c.filter(Boolean),c.length>2){const s=c.pop();o+=`one of type ${c.join(", ")}, or ${s}.`}else c.length===2?o+=`one of type ${c[0]} or ${c[1]}.`:o+=`of type ${c[0]}.`;return i==null?o+=` Received ${i}`:typeof i=="function"&&i.name?o+=` Received function ${i.name}`:typeof i=="object"&&i!=null&&i.constructor?.name&&(o+=` Received an instance of ${i.constructor.name}`),o}const Br=(o,...i)=>zn("Key must be ",o,...i);function Gn(o,i,...c){return zn(`Key for the ${o} algorithm must be `,i,...c)}const Yn=o=>zr(o)?!0:o?.[Symbol.toStringTag]==="KeyObject",ir=["CryptoKey"],Xn=(...o)=>{const i=o.filter(Boolean);if(i.length===0||i.length===1)return!0;let c;for(const s of i){const p=Object.keys(s);if(!c||c.size===0){c=new Set(p);continue}for(const v of p){if(c.has(v))return!1;c.add(v)}}return!0};function zi(o){return typeof o=="object"&&o!==null}function kt(o){if(!zi(o)||Object.prototype.toString.call(o)!=="[object Object]")return!1;if(Object.getPrototypeOf(o)===null)return!0;let i=o;for(;Object.getPrototypeOf(i)!==null;)i=Object.getPrototypeOf(i);return Object.getPrototypeOf(o)===i}const Qn=(o,i)=>{if(o.startsWith("RS")||o.startsWith("PS")){const{modulusLength:c}=i.algorithm;if(typeof c!="number"||c<2048)throw new TypeError(`${o} requires key modulusLength to be 2048 bits or larger`)}};function Jt(o){return kt(o)&&typeof o.kty=="string"}function Gi(o){return o.kty!=="oct"&&typeof o.d=="string"}function Yi(o){return o.kty!=="oct"&&typeof o.d>"u"}function Xi(o){return Jt(o)&&o.kty==="oct"&&typeof o.k=="string"}function Qi(o){let i,c;switch(o.kty){case"RSA":{switch(o.alg){case"PS256":case"PS384":case"PS512":i={name:"RSA-PSS",hash:`SHA-${o.alg.slice(-3)}`},c=o.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":i={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${o.alg.slice(-3)}`},c=o.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":i={name:"RSA-OAEP",hash:`SHA-${parseInt(o.alg.slice(-3),10)||1}`},c=o.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new ut('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"EC":{switch(o.alg){case"ES256":i={name:"ECDSA",namedCurve:"P-256"},c=o.d?["sign"]:["verify"];break;case"ES384":i={name:"ECDSA",namedCurve:"P-384"},c=o.d?["sign"]:["verify"];break;case"ES512":i={name:"ECDSA",namedCurve:"P-521"},c=o.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":i={name:"ECDH",namedCurve:o.crv},c=o.d?["deriveBits"]:[];break;default:throw new ut('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"OKP":{switch(o.alg){case"Ed25519":i={name:"Ed25519"},c=o.d?["sign"]:["verify"];break;case"EdDSA":i={name:o.crv},c=o.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":i={name:o.crv},c=o.d?["deriveBits"]:[];break;default:throw new ut('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}default:throw new ut('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:i,keyUsages:c}}const Zn=async o=>{if(!o.alg)throw new TypeError('"alg" argument is required when "jwk.alg" is not present');const{algorithm:i,keyUsages:c}=Qi(o),s=[i,o.ext??!1,o.key_ops??c],p={...o};return delete p.alg,delete p.use,Wt.subtle.importKey("jwk",p,...s)},ei=o=>Ut(o);let Ht,Bt;const ti=o=>o?.[Symbol.toStringTag]==="KeyObject",wr=async(o,i,c,s,p=!1)=>{let v=o.get(i);if(v?.[s])return v[s];const d=await Zn({...c,alg:s});return p&&Object.freeze(i),v?v[s]=d:o.set(i,{[s]:d}),d},Zi=(o,i)=>{if(ti(o)){let c=o.export({format:"jwk"});return delete c.d,delete c.dp,delete c.dq,delete c.p,delete c.q,delete c.qi,c.k?ei(c.k):(Bt||(Bt=new WeakMap),wr(Bt,o,c,i))}return Jt(o)?o.k?Ut(o.k):(Bt||(Bt=new WeakMap),wr(Bt,o,o,i,!0)):o},eo=(o,i)=>{if(ti(o)){let c=o.export({format:"jwk"});return c.k?ei(c.k):(Ht||(Ht=new WeakMap),wr(Ht,o,c,i))}return Jt(o)?o.k?Ut(o.k):(Ht||(Ht=new WeakMap),wr(Ht,o,o,i,!0)):o},An={normalizePublicKey:Zi,normalizePrivateKey:eo};async function ri(o,i){if(!kt(o))throw new TypeError("JWK must be an object");switch(i||(i=o.alg),o.kty){case"oct":if(typeof o.k!="string"||!o.k)throw new TypeError('missing "k" (Key Value) Parameter value');return Ut(o.k);case"RSA":if("oth"in o&&o.oth!==void 0)throw new ut('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');case"EC":case"OKP":return Zn({...o,alg:i});default:throw new ut('Unsupported "kty" (Key Type) Parameter value')}}const Mt=o=>o?.[Symbol.toStringTag],Mr=(o,i,c)=>{if(i.use!==void 0&&i.use!=="sig")throw new TypeError("Invalid key for this operation, when present its use must be sig");if(i.key_ops!==void 0&&i.key_ops.includes?.(c)!==!0)throw new TypeError(`Invalid key for this operation, when present its key_ops must include ${c}`);if(i.alg!==void 0&&i.alg!==o)throw new TypeError(`Invalid key for this operation, when present its alg must be ${o}`);return!0},to=(o,i,c,s)=>{if(!(i instanceof Uint8Array)){if(s&&Jt(i)){if(Xi(i)&&Mr(o,i,c))return;throw new TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present')}if(!Yn(i))throw new TypeError(Gn(o,i,...ir,"Uint8Array",s?"JSON Web Key":null));if(i.type!=="secret")throw new TypeError(`${Mt(i)} instances for symmetric algorithms must be of type "secret"`)}},ro=(o,i,c,s)=>{if(s&&Jt(i))switch(c){case"sign":if(Gi(i)&&Mr(o,i,c))return;throw new TypeError("JSON Web Key for this operation be a private JWK");case"verify":if(Yi(i)&&Mr(o,i,c))return;throw new TypeError("JSON Web Key for this operation be a public JWK")}if(!Yn(i))throw new TypeError(Gn(o,i,...ir,s?"JSON Web Key":null));if(i.type==="secret")throw new TypeError(`${Mt(i)} instances for asymmetric algorithms must not be of type "secret"`);if(c==="sign"&&i.type==="public")throw new TypeError(`${Mt(i)} instances for asymmetric algorithm signing must be of type "private"`);if(c==="decrypt"&&i.type==="public")throw new TypeError(`${Mt(i)} instances for asymmetric algorithm decryption must be of type "private"`);if(i.algorithm&&c==="verify"&&i.type==="private")throw new TypeError(`${Mt(i)} instances for asymmetric algorithm verifying must be of type "public"`);if(i.algorithm&&c==="encrypt"&&i.type==="private")throw new TypeError(`${Mt(i)} instances for asymmetric algorithm encryption must be of type "public"`)};function ni(o,i,c,s){i.startsWith("HS")||i==="dir"||i.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(i)?to(i,c,s,o):ro(i,c,s,o)}ni.bind(void 0,!1);const jr=ni.bind(void 0,!0);function ii(o,i,c,s,p){if(p.crit!==void 0&&s?.crit===void 0)throw new o('"crit" (Critical) Header Parameter MUST be integrity protected');if(!s||s.crit===void 0)return new Set;if(!Array.isArray(s.crit)||s.crit.length===0||s.crit.some(d=>typeof d!="string"||d.length===0))throw new o('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let v;c!==void 0?v=new Map([...Object.entries(c),...i.entries()]):v=i;for(const d of s.crit){if(!v.has(d))throw new ut(`Extension Header Parameter "${d}" is not recognized`);if(p[d]===void 0)throw new o(`Extension Header Parameter "${d}" is missing`);if(v.get(d)&&s[d]===void 0)throw new o(`Extension Header Parameter "${d}" MUST be integrity protected`)}return new Set(s.crit)}const no=(o,i)=>{if(i!==void 0&&(!Array.isArray(i)||i.some(c=>typeof c!="string")))throw new TypeError(`"${o}" option must be an array of strings`);if(i)return new Set(i)},io=async o=>{if(o instanceof Uint8Array)return{kty:"oct",k:yr(o)};if(!zr(o))throw new TypeError(Br(o,...ir,"Uint8Array"));if(!o.extractable)throw new TypeError("non-extractable CryptoKey cannot be exported as a JWK");const{ext:i,key_ops:c,alg:s,use:p,...v}=await Wt.subtle.exportKey("jwk",o);return v};async function oo(o){return io(o)}function oi(o,i){const c=`SHA-${o.slice(-3)}`;switch(o){case"HS256":case"HS384":case"HS512":return{hash:c,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:c,name:"RSA-PSS",saltLength:o.slice(-3)>>3};case"RS256":case"RS384":case"RS512":return{hash:c,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:c,name:"ECDSA",namedCurve:i.namedCurve};case"Ed25519":return{name:"Ed25519"};case"EdDSA":return{name:i.name};default:throw new ut(`alg ${o} is not supported either by JOSE or your javascript runtime`)}}async function si(o,i,c){if(c==="sign"&&(i=await An.normalizePrivateKey(i,o)),c==="verify"&&(i=await An.normalizePublicKey(i,o)),zr(i))return $i(i,o,c),i;if(i instanceof Uint8Array){if(!o.startsWith("HS"))throw new TypeError(Br(i,...ir));return Wt.subtle.importKey("raw",i,{hash:`SHA-${o.slice(-3)}`,name:"HMAC"},!1,[c])}throw new TypeError(Br(i,...ir,"Uint8Array","JSON Web Key"))}const so=async(o,i,c,s)=>{const p=await si(o,i,"verify");Qn(o,p);const v=oi(o,p.algorithm);try{return await Wt.subtle.verify(v,p,c,s)}catch{return!1}};async function ao(o,i,c){if(!kt(o))throw new Te("Flattened JWS must be an object");if(o.protected===void 0&&o.header===void 0)throw new Te('Flattened JWS must have either of the "protected" or "header" members');if(o.protected!==void 0&&typeof o.protected!="string")throw new Te("JWS Protected Header incorrect type");if(o.payload===void 0)throw new Te("JWS Payload missing");if(typeof o.signature!="string")throw new Te("JWS Signature missing or incorrect type");if(o.header!==void 0&&!kt(o.header))throw new Te("JWS Unprotected Header incorrect type");let s={};if(o.protected)try{const J=Ut(o.protected);s=JSON.parse(jt.decode(J))}catch{throw new Te("JWS Protected Header is invalid")}if(!Xn(s,o.header))throw new Te("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const p={...s,...o.header},v=ii(Te,new Map([["b64",!0]]),c?.crit,s,p);let d=!0;if(v.has("b64")&&(d=s.b64,typeof d!="boolean"))throw new Te('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const{alg:b}=p;if(typeof b!="string"||!b)throw new Te('JWS "alg" (Algorithm) Header Parameter missing or invalid');const w=c&&no("algorithms",c.algorithms);if(w&&!w.has(b))throw new Wn('"alg" (Algorithm) Header Parameter value not allowed');if(d){if(typeof o.payload!="string")throw new Te("JWS Payload must be a string")}else if(typeof o.payload!="string"&&!(o.payload instanceof Uint8Array))throw new Te("JWS Payload must be a string or an Uint8Array instance");let l=!1;typeof i=="function"?(i=await i(s,o),l=!0,jr(b,i,"verify"),Jt(i)&&(i=await ri(i,b))):jr(b,i,"verify");const h=Vn(bt.encode(o.protected??""),bt.encode("."),typeof o.payload=="string"?bt.encode(o.payload):o.payload);let u;try{u=Ut(o.signature)}catch{throw new Te("Failed to base64url decode the signature")}if(!await so(b,i,u,h))throw new $n;let R;if(d)try{R=Ut(o.payload)}catch{throw new Te("Failed to base64url decode the payload")}else typeof o.payload=="string"?R=bt.encode(o.payload):R=o.payload;const A={payload:R};return o.protected!==void 0&&(A.protectedHeader=s),o.header!==void 0&&(A.unprotectedHeader=o.header),l?{...A,key:i}:A}async function uo(o,i,c){if(o instanceof Uint8Array&&(o=jt.decode(o)),typeof o!="string")throw new Te("Compact JWS must be a string or Uint8Array");const{0:s,1:p,2:v,length:d}=o.split(".");if(d!==3)throw new Te("Invalid Compact JWS");const b=await ao({payload:p,protected:s,signature:v},i,c),w={payload:b.payload,protectedHeader:b.protectedHeader};return typeof i=="function"?{...w,key:b.key}:w}const Pt=o=>Math.floor(o.getTime()/1e3),ai=60,ui=ai*60,Xr=ui*24,co=Xr*7,lo=Xr*365.25,ho=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,nr=o=>{const i=ho.exec(o);if(!i||i[4]&&i[1])throw new TypeError("Invalid time period format");const c=parseFloat(i[2]),s=i[3].toLowerCase();let p;switch(s){case"sec":case"secs":case"second":case"seconds":case"s":p=Math.round(c);break;case"minute":case"minutes":case"min":case"mins":case"m":p=Math.round(c*ai);break;case"hour":case"hours":case"hr":case"hrs":case"h":p=Math.round(c*ui);break;case"day":case"days":case"d":p=Math.round(c*Xr);break;case"week":case"weeks":case"w":p=Math.round(c*co);break;default:p=Math.round(c*lo);break}return i[1]==="-"||i[4]==="ago"?-p:p},kn=o=>o.toLowerCase().replace(/^application\//,""),fo=(o,i)=>typeof o=="string"?i.includes(o):Array.isArray(o)?i.some(Set.prototype.has.bind(new Set(o))):!1,go=(o,i,c={})=>{let s;try{s=JSON.parse(jt.decode(i))}catch{}if(!kt(s))throw new br("JWT Claims Set must be a top-level JSON object");const{typ:p}=c;if(p&&(typeof o.typ!="string"||kn(o.typ)!==kn(p)))throw new vt('unexpected "typ" JWT header value',s,"typ","check_failed");const{requiredClaims:v=[],issuer:d,subject:b,audience:w,maxTokenAge:l}=c,h=[...v];l!==void 0&&h.push("iat"),w!==void 0&&h.push("aud"),b!==void 0&&h.push("sub"),d!==void 0&&h.push("iss");for(const A of new Set(h.reverse()))if(!(A in s))throw new vt(`missing required "${A}" claim`,s,A,"missing");if(d&&!(Array.isArray(d)?d:[d]).includes(s.iss))throw new vt('unexpected "iss" claim value',s,"iss","check_failed");if(b&&s.sub!==b)throw new vt('unexpected "sub" claim value',s,"sub","check_failed");if(w&&!fo(s.aud,typeof w=="string"?[w]:w))throw new vt('unexpected "aud" claim value',s,"aud","check_failed");let u;switch(typeof c.clockTolerance){case"string":u=nr(c.clockTolerance);break;case"number":u=c.clockTolerance;break;case"undefined":u=0;break;default:throw new TypeError("Invalid clockTolerance option type")}const{currentDate:S}=c,R=Pt(S||new Date);if((s.iat!==void 0||l)&&typeof s.iat!="number")throw new vt('"iat" claim must be a number',s,"iat","invalid");if(s.nbf!==void 0){if(typeof s.nbf!="number")throw new vt('"nbf" claim must be a number',s,"nbf","invalid");if(s.nbf>R+u)throw new vt('"nbf" claim timestamp check failed',s,"nbf","check_failed")}if(s.exp!==void 0){if(typeof s.exp!="number")throw new vt('"exp" claim must be a number',s,"exp","invalid");if(s.exp<=R-u)throw new Hr('"exp" claim timestamp check failed',s,"exp","check_failed")}if(l){const A=R-s.iat,J=typeof l=="number"?l:nr(l);if(A-u>J)throw new Hr('"iat" claim timestamp check failed (too far in the past)',s,"iat","check_failed");if(A<0-u)throw new vt('"iat" claim timestamp check failed (it should be in the past)',s,"iat","check_failed")}return s};async function po(o,i,c){const s=await uo(o,i,c);if(s.protectedHeader.crit?.includes("b64")&&s.protectedHeader.b64===!1)throw new br("JWTs MUST NOT use unencoded payload");const v={payload:go(s.protectedHeader,s.payload,c),protectedHeader:s.protectedHeader};return typeof i=="function"?{...v,key:s.key}:v}const yo=async(o,i,c)=>{const s=await si(o,i,"sign");Qn(o,s);const p=await Wt.subtle.sign(oi(o,s.algorithm),s,c);return new Uint8Array(p)};class vo{constructor(i){if(!(i instanceof Uint8Array))throw new TypeError("payload must be an instance of Uint8Array");this._payload=i}setProtectedHeader(i){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=i,this}setUnprotectedHeader(i){if(this._unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this._unprotectedHeader=i,this}async sign(i,c){if(!this._protectedHeader&&!this._unprotectedHeader)throw new Te("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!Xn(this._protectedHeader,this._unprotectedHeader))throw new Te("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const s={...this._protectedHeader,...this._unprotectedHeader},p=ii(Te,new Map([["b64",!0]]),c?.crit,this._protectedHeader,s);let v=!0;if(p.has("b64")&&(v=this._protectedHeader.b64,typeof v!="boolean"))throw new Te('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const{alg:d}=s;if(typeof d!="string"||!d)throw new Te('JWS "alg" (Algorithm) Header Parameter missing or invalid');jr(d,i,"sign");let b=this._payload;v&&(b=bt.encode(yr(b)));let w;this._protectedHeader?w=bt.encode(yr(JSON.stringify(this._protectedHeader))):w=bt.encode("");const l=Vn(w,bt.encode("."),b),h=await yo(d,i,l),u={signature:yr(h),payload:""};return v&&(u.payload=jt.decode(b)),this._unprotectedHeader&&(u.header=this._unprotectedHeader),this._protectedHeader&&(u.protected=jt.decode(w)),u}}class mo{constructor(i){this._flattened=new vo(i)}setProtectedHeader(i){return this._flattened.setProtectedHeader(i),this}async sign(i,c){const s=await this._flattened.sign(i,c);if(s.payload===void 0)throw new TypeError("use the flattened module for creating JWS with b64: false");return`${s.protected}.${s.payload}.${s.signature}`}}function Ct(o,i){if(!Number.isFinite(i))throw new TypeError(`Invalid ${o} input`);return i}class _o{constructor(i={}){if(!kt(i))throw new TypeError("JWT Claims Set MUST be an object");this._payload=i}setIssuer(i){return this._payload={...this._payload,iss:i},this}setSubject(i){return this._payload={...this._payload,sub:i},this}setAudience(i){return this._payload={...this._payload,aud:i},this}setJti(i){return this._payload={...this._payload,jti:i},this}setNotBefore(i){return typeof i=="number"?this._payload={...this._payload,nbf:Ct("setNotBefore",i)}:i instanceof Date?this._payload={...this._payload,nbf:Ct("setNotBefore",Pt(i))}:this._payload={...this._payload,nbf:Pt(new Date)+nr(i)},this}setExpirationTime(i){return typeof i=="number"?this._payload={...this._payload,exp:Ct("setExpirationTime",i)}:i instanceof Date?this._payload={...this._payload,exp:Ct("setExpirationTime",Pt(i))}:this._payload={...this._payload,exp:Pt(new Date)+nr(i)},this}setIssuedAt(i){return typeof i>"u"?this._payload={...this._payload,iat:Pt(new Date)}:i instanceof Date?this._payload={...this._payload,iat:Ct("setIssuedAt",Pt(i))}:typeof i=="string"?this._payload={...this._payload,iat:Ct("setIssuedAt",Pt(new Date)+nr(i))}:this._payload={...this._payload,iat:Ct("setIssuedAt",i)},this}}class wo extends _o{setProtectedHeader(i){return this._protectedHeader=i,this}async sign(i,c){const s=new mo(bt.encode(JSON.stringify(this._payload)));if(s.setProtectedHeader(this._protectedHeader),Array.isArray(this._protectedHeader?.crit)&&this._protectedHeader.crit.includes("b64")&&this._protectedHeader.b64===!1)throw new br("JWTs MUST NOT use unencoded payload");return s.sign(i,c)}}function So(o){switch(typeof o=="string"&&o.slice(0,2)){case"RS":case"PS":return"RSA";case"ES":return"EC";case"Ed":return"OKP";default:throw new ut('Unsupported "alg" value for a JSON Web Key Set')}}function bo(o){return o&&typeof o=="object"&&Array.isArray(o.keys)&&o.keys.every(Eo)}function Eo(o){return kt(o)}function ci(o){return typeof structuredClone=="function"?structuredClone(o):JSON.parse(JSON.stringify(o))}class Fo{constructor(i){if(this._cached=new WeakMap,!bo(i))throw new Gr("JSON Web Key Set malformed");this._jwks=ci(i)}async getKey(i,c){const{alg:s,kid:p}={...i,...c?.header},v=So(s),d=this._jwks.keys.filter(l=>{let h=v===l.kty;if(h&&typeof p=="string"&&(h=p===l.kid),h&&typeof l.alg=="string"&&(h=s===l.alg),h&&typeof l.use=="string"&&(h=l.use==="sig"),h&&Array.isArray(l.key_ops)&&(h=l.key_ops.includes("verify")),h)switch(s){case"ES256":h=l.crv==="P-256";break;case"ES256K":h=l.crv==="secp256k1";break;case"ES384":h=l.crv==="P-384";break;case"ES512":h=l.crv==="P-521";break;case"Ed25519":h=l.crv==="Ed25519";break;case"EdDSA":h=l.crv==="Ed25519"||l.crv==="Ed448";break}return h}),{0:b,length:w}=d;if(w===0)throw new Yr;if(w!==1){const l=new Jn,{_cached:h}=this;throw l[Symbol.asyncIterator]=async function*(){for(const u of d)try{yield await Pn(h,u,s)}catch{}},l}return Pn(this._cached,b,s)}}async function Pn(o,i,c){const s=o.get(i)||o.set(i,{}).get(i);if(s[c]===void 0){const p=await ri({...i,ext:!0},c);if(p instanceof Uint8Array||p.type!=="public")throw new Gr("JSON Web Key Set members must be public keys");s[c]=p}return s[c]}function Tn(o){const i=new Fo(o),c=async(s,p)=>i.getKey(s,p);return Object.defineProperties(c,{jwks:{value:()=>ci(i._jwks),enumerable:!0,configurable:!1,writable:!1}}),c}const xo=async(o,i,c)=>{let s,p,v=!1;typeof AbortController=="function"&&(s=new AbortController,p=setTimeout(()=>{v=!0,s.abort()},i));const d=await fetch(o.href,{signal:s?s.signal:void 0,redirect:"manual",headers:c.headers}).catch(b=>{throw v?new qn:b});if(p!==void 0&&clearTimeout(p),d.status!==200)throw new ze("Expected 200 OK from the JSON Web Key Set HTTP response");try{return await d.json()}catch{throw new ze("Failed to parse the JSON Web Key Set HTTP response as JSON")}};function Ao(){return typeof WebSocketPair<"u"||typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"||typeof EdgeRuntime<"u"&&EdgeRuntime==="vercel"}let Kr;(typeof navigator>"u"||!navigator.userAgent?.startsWith?.("Mozilla/5.0 "))&&(Kr="jose/v5.10.0");const Cr=Symbol();function ko(o,i){return!(typeof o!="object"||o===null||!("uat"in o)||typeof o.uat!="number"||Date.now()-o.uat>=i||!("jwks"in o)||!kt(o.jwks)||!Array.isArray(o.jwks.keys)||!Array.prototype.every.call(o.jwks.keys,kt))}class Po{constructor(i,c){if(!(i instanceof URL))throw new TypeError("url must be an instance of URL");this._url=new URL(i.href),this._options={agent:c?.agent,headers:c?.headers},this._timeoutDuration=typeof c?.timeoutDuration=="number"?c?.timeoutDuration:5e3,this._cooldownDuration=typeof c?.cooldownDuration=="number"?c?.cooldownDuration:3e4,this._cacheMaxAge=typeof c?.cacheMaxAge=="number"?c?.cacheMaxAge:6e5,c?.[Cr]!==void 0&&(this._cache=c?.[Cr],ko(c?.[Cr],this._cacheMaxAge)&&(this._jwksTimestamp=this._cache.uat,this._local=Tn(this._cache.jwks)))}coolingDown(){return typeof this._jwksTimestamp=="number"?Date.now()<this._jwksTimestamp+this._cooldownDuration:!1}fresh(){return typeof this._jwksTimestamp=="number"?Date.now()<this._jwksTimestamp+this._cacheMaxAge:!1}async getKey(i,c){(!this._local||!this.fresh())&&await this.reload();try{return await this._local(i,c)}catch(s){if(s instanceof Yr&&this.coolingDown()===!1)return await this.reload(),this._local(i,c);throw s}}async reload(){this._pendingFetch&&Ao()&&(this._pendingFetch=void 0);const i=new Headers(this._options.headers);Kr&&!i.has("User-Agent")&&(i.set("User-Agent",Kr),this._options.headers=Object.fromEntries(i.entries())),this._pendingFetch||(this._pendingFetch=xo(this._url,this._timeoutDuration,this._options).then(c=>{this._local=Tn(c),this._cache&&(this._cache.uat=Date.now(),this._cache.jwks=c),this._jwksTimestamp=Date.now(),this._pendingFetch=void 0}).catch(c=>{throw this._pendingFetch=void 0,c})),await this._pendingFetch}}function To(o,i){const c=new Po(o,i),s=async(p,v)=>c.getKey(p,v);return Object.defineProperties(s,{coolingDown:{get:()=>c.coolingDown(),enumerable:!0,configurable:!1},fresh:{get:()=>c.fresh(),enumerable:!0,configurable:!1},reload:{value:()=>c.reload(),enumerable:!0,configurable:!1,writable:!1},reloading:{get:()=>!!c._pendingFetch,enumerable:!0,configurable:!1},jwks:{value:()=>c._local?.jwks(),enumerable:!0,configurable:!1,writable:!1}}),s}function Ur(o){const i=o?.modulusLength??2048;if(typeof i!="number"||i<2048)throw new ut("Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used");return i}async function Io(o,i){let c,s;switch(o){case"PS256":case"PS384":case"PS512":c={name:"RSA-PSS",hash:`SHA-${o.slice(-3)}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:Ur(i)},s=["sign","verify"];break;case"RS256":case"RS384":case"RS512":c={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${o.slice(-3)}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:Ur(i)},s=["sign","verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":c={name:"RSA-OAEP",hash:`SHA-${parseInt(o.slice(-3),10)||1}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:Ur(i)},s=["decrypt","unwrapKey","encrypt","wrapKey"];break;case"ES256":c={name:"ECDSA",namedCurve:"P-256"},s=["sign","verify"];break;case"ES384":c={name:"ECDSA",namedCurve:"P-384"},s=["sign","verify"];break;case"ES512":c={name:"ECDSA",namedCurve:"P-521"},s=["sign","verify"];break;case"Ed25519":c={name:"Ed25519"},s=["sign","verify"];break;case"EdDSA":{s=["sign","verify"];const p="Ed25519";switch(p){case"Ed25519":case"Ed448":c={name:p};break;default:throw new ut("Invalid or unsupported crv option provided")}break}case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{s=["deriveKey","deriveBits"];const p="P-256";switch(p){case"P-256":case"P-384":case"P-521":{c={name:"ECDH",namedCurve:p};break}case"X25519":case"X448":c={name:p};break;default:throw new ut("Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, X25519, and X448")}break}default:throw new ut('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return Wt.subtle.generateKey(c,!1,s)}async function Ro(o,i){return Io(o,i)}const $e=[];for(let o=0;o<256;++o)$e.push((o+256).toString(16).slice(1));function Co(o,i=0){return($e[o[i+0]]+$e[o[i+1]]+$e[o[i+2]]+$e[o[i+3]]+"-"+$e[o[i+4]]+$e[o[i+5]]+"-"+$e[o[i+6]]+$e[o[i+7]]+"-"+$e[o[i+8]]+$e[o[i+9]]+"-"+$e[o[i+10]]+$e[o[i+11]]+$e[o[i+12]]+$e[o[i+13]]+$e[o[i+14]]+$e[o[i+15]]).toLowerCase()}let Dr;const Uo=new Uint8Array(16);function Do(){if(!Dr){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Dr=crypto.getRandomValues.bind(crypto)}return Dr(Uo)}const Lo=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),In={randomUUID:Lo};function Qr(o,i,c){if(In.randomUUID&&!o)return In.randomUUID();o=o||{};const s=o.random??o.rng?.()??Do();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,Co(s)}const li="solidClientAuthn:",Sr=["ES256","RS256"],je={ERROR:"error",LOGIN:"login",LOGOUT:"logout",NEW_REFRESH_TOKEN:"newRefreshToken",NEW_TOKENS:"newTokens",AUTHORIZATION_REQUEST:"authorizationRequest",SESSION_EXPIRED:"sessionExpired",SESSION_EXTENDED:"sessionExtended",SESSION_RESTORED:"sessionRestore",TIMEOUT_SET:"timeoutSet"},Rn=5,No="openid",Oo="offline_access",Ho="webid",Cn=[No,Oo,Ho];class Bo{handleables;constructor(i){this.handleables=i,this.handleables=i}async getProperHandler(i){const c=await Promise.all(this.handleables.map(s=>s.canHandle(...i)));for(let s=0;s<c.length;s+=1)if(c[s])return this.handleables[s];return null}async canHandle(...i){return await this.getProperHandler(i)!==null}async handle(...i){const c=await this.getProperHandler(i);if(c)return c.handle(...i);throw new Error(`[${this.constructor.name}] cannot find a suitable handler for: ${i.map(s=>{try{return JSON.stringify(s)}catch{return s.toString()}}).join(", ")}`)}}async function hi(o,i,c,s){let p,v;try{const{payload:d}=await po(o,To(new URL(i)),{issuer:c,audience:s});p=d}catch(d){throw new Error(`Token verification failed: ${d.stack}`)}if(typeof p.azp=="string"&&(v=p.azp),typeof p.webid=="string")return{webId:p.webid,clientId:v};if(typeof p.sub!="string")throw new Error(`The token ${JSON.stringify(p)} is invalid: it has no 'webid' claim and no 'sub' claim.`);try{return new URL(p.sub),{webId:p.sub,clientId:v}}catch(d){throw new Error(`The token has no 'webid' claim, and its 'sub' claim of [${p.sub}] is invalid as a URL - error [${d}].`)}}function Mo(o){return Array.isArray(o)?Array.from(new Set([...Cn,...o.filter(i=>typeof i=="string"&&!i.includes(" "))])):Cn}function di(o){try{const i=new URL(o),c=!i.searchParams.has("code")&&!i.searchParams.has("state"),s=i.hash==="";return c&&s}catch{return!1}}function fi(o){const i=new URL(o);return i.searchParams.delete("state"),i.searchParams.delete("code"),i.searchParams.delete("error"),i.searchParams.delete("error_description"),i.searchParams.delete("iss"),i}function jo(o,i){return typeof o=="boolean"?!!o:!!i}class Ko{storageUtility;redirector;constructor(i,c){this.storageUtility=i,this.redirector=c,this.storageUtility=i,this.redirector=c}parametersGuard=i=>i.issuerConfiguration.grantTypesSupported!==void 0&&i.issuerConfiguration.grantTypesSupported.indexOf("authorization_code")>-1&&i.redirectUrl!==void 0;async canHandle(i){return this.parametersGuard(i)}async setupRedirectHandler({oidcLoginOptions:i,state:c,codeVerifier:s,targetUrl:p}){if(!this.parametersGuard(i))throw new Error("The authorization code grant requires a redirectUrl.");await Promise.all([this.storageUtility.setForUser(c,{sessionId:i.sessionId}),this.storageUtility.setForUser(i.sessionId,{codeVerifier:s,issuer:i.issuer.toString(),redirectUrl:i.redirectUrl,dpop:(!!i.dpop).toString(),keepAlive:jo(i.keepAlive,!0).toString()})]),this.redirector.redirect(p,{handleRedirect:i.handleRedirect})}}class Vo{sessionInfoManager;constructor(i){this.sessionInfoManager=i,this.sessionInfoManager=i}async canHandle(){return!0}async handle(i){await this.sessionInfoManager.clear(i)}}class Wo{redirector;constructor(i){this.redirector=i,this.redirector=i}async canHandle(i,c){return c?.logoutType==="idp"}async handle(i,c){if(c?.logoutType!=="idp")throw new Error("Attempting to call idp logout handler to perform app logout");if(c.toLogoutUrl===void 0)throw new Error("Cannot perform IDP logout. Did you log in using the OIDC authentication flow?");this.redirector.redirect(c.toLogoutUrl(c),{handleRedirect:c.handleRedirect})}}class Jo{handlers;constructor(i,c){this.handlers=[new Vo(i),new Wo(c)]}async canHandle(){return!0}async handle(i,c){for(const s of this.handlers)await s.canHandle(i,c)&&await s.handle(i,c)}}function gi(){return{isLoggedIn:!1,sessionId:Qr(),fetch:(...o)=>fetch(...o)}}async function pi(o,i){await Promise.all([i.deleteAllUserData(o,{secure:!1}),i.deleteAllUserData(o,{secure:!0})])}class qo{storageUtility;constructor(i){this.storageUtility=i,this.storageUtility=i}update(i,c){throw new Error("Not Implemented")}set(i,c){throw new Error("Not Implemented")}get(i){throw new Error("Not implemented")}async getAll(){throw new Error("Not implemented")}async clear(i){return pi(i,this.storageUtility)}async register(i){throw new Error("Not implemented")}async getRegisteredSessionIdAll(){throw new Error("Not implemented")}async clearAll(){throw new Error("Not implemented")}async setOidcContext(i,c){throw new Error("Not implemented")}}function $o({endSessionEndpoint:o,idTokenHint:i,postLogoutRedirectUri:c,state:s}){const p=new URL(o);return i!==void 0&&p.searchParams.append("id_token_hint",i),c!==void 0&&(p.searchParams.append("post_logout_redirect_uri",c),s!==void 0&&p.searchParams.append("state",s)),p.toString()}function zo({endSessionEndpoint:o,idTokenHint:i}){if(o!==void 0)return function({state:s,postLogoutUrl:p}){return $o({endSessionEndpoint:o,idTokenHint:i,state:s,postLogoutRedirectUri:p})}}function Go(o){return typeof o=="string"&&["DPoP","Bearer"].includes(o)}function yi(o){try{return new URL(o),!0}catch{return!1}}function Yo(o,i){return i.find(c=>o.includes(c))??null}function Xo(o){return o.clientId!==void 0&&!yi(o.clientId)}function Qo(o,i){return i.scopesSupported.includes("webid")&&o.clientId!==void 0&&yi(o.clientId)}function Zo(o){return typeof o=="string"&&["dynamic","static","solid-oidc"].includes(o)}async function es(o,i,c,s){let p;if(Qo(o,i))p={clientId:o.clientId,clientName:o.clientName,clientType:"solid-oidc"};else if(Xo(o))p={clientId:o.clientId,clientSecret:o.clientSecret,clientName:o.clientName,clientType:"static"};else return s.getClient({sessionId:o.sessionId,clientName:o.clientName,redirectUrl:o.redirectUrl},i);const v={clientId:p.clientId,clientType:p.clientType};return p.clientType==="static"&&(v.clientSecret=p.clientSecret),p.clientName&&(v.clientName=p.clientName),await c.setForUser(o.sessionId,v),p}const Un=(o,i)=>fetch(o,i);let ts=class{loginHandler;redirectHandler;logoutHandler;sessionInfoManager;issuerConfigFetcher;boundLogout;constructor(i,c,s,p,v){this.loginHandler=i,this.redirectHandler=c,this.logoutHandler=s,this.sessionInfoManager=p,this.issuerConfigFetcher=v,this.loginHandler=i,this.redirectHandler=c,this.logoutHandler=s,this.sessionInfoManager=p,this.issuerConfigFetcher=v}fetch=Un;logout=async(i,c)=>{await this.logoutHandler.handle(i,c?.logoutType==="idp"?{...c,toLogoutUrl:this.boundLogout}:c),this.fetch=Un,delete this.boundLogout};getSessionInfo=async i=>this.sessionInfoManager.get(i);getAllSessionInfo=async()=>this.sessionInfoManager.getAll()};async function vi(o,i,c){try{const[s,p,v,d,b]=await Promise.all([i.getForUser(o,"issuer",{errorIfNull:!0}),i.getForUser(o,"codeVerifier"),i.getForUser(o,"redirectUrl"),i.getForUser(o,"dpop",{errorIfNull:!0}),i.getForUser(o,"keepAlive")]);await i.deleteForUser(o,"codeVerifier");const w=await c.fetchConfig(s);return{codeVerifier:p,redirectUrl:v,issuerConfig:w,dpop:d==="true",keepAlive:typeof b=="string"?b==="true":!0}}catch(s){throw new Error(`Failed to retrieve OIDC context from storage associated with session [${o}]: ${s}`)}}async function rs(o,i,c,s,p,v,d,b){c!==void 0&&await o.setForUser(i,{webId:c},{secure:d}),s!==void 0&&await o.setForUser(i,{clientId:s},{secure:d}),await o.setForUser(i,{isLoggedIn:p},{secure:d})}class ns{secureStorage;insecureStorage;constructor(i,c){this.secureStorage=i,this.insecureStorage=c,this.secureStorage=i,this.insecureStorage=c}getKey(i){return`solidClientAuthenticationUser:${i}`}async getUserData(i,c){const s=await(c?this.secureStorage:this.insecureStorage).get(this.getKey(i));if(s===void 0)return{};try{return JSON.parse(s)}catch{throw new Error(`Data for user [${i}] in [${c?"secure":"unsecure"}] storage is corrupted - expected valid JSON, but got: ${s}`)}}async setUserData(i,c,s){await(s?this.secureStorage:this.insecureStorage).set(this.getKey(i),JSON.stringify(c))}async get(i,c){const s=await(c?.secure?this.secureStorage:this.insecureStorage).get(i);if(s===void 0&&c?.errorIfNull)throw new Error(`[${i}] is not stored`);return s}async set(i,c,s){return(s?.secure?this.secureStorage:this.insecureStorage).set(i,c)}async delete(i,c){return(c?.secure?this.secureStorage:this.insecureStorage).delete(i)}async getForUser(i,c,s){const p=await this.getUserData(i,s?.secure);let v;if((!p||!p[c])&&(v=void 0),v=p[c],v===void 0&&s?.errorIfNull)throw new Error(`Field [${c}] for user [${i}] is not stored`);return v||void 0}async setForUser(i,c,s){let p;try{p=await this.getUserData(i,s?.secure)}catch{p={}}await this.setUserData(i,{...p,...c},s?.secure)}async deleteForUser(i,c,s){const p=await this.getUserData(i,s?.secure);delete p[c],await this.setUserData(i,p,s?.secure)}async deleteAllUserData(i,c){await(c?.secure?this.secureStorage:this.insecureStorage).delete(this.getKey(i))}}class is{map={};async get(i){return this.map[i]||void 0}async set(i,c){this.map[i]=c}async delete(i){delete this.map[i]}}class Vr extends Error{constructor(i){super(i)}}class rr extends Error{missingFields;constructor(i){super(`Invalid response from OIDC provider: missing fields ${i}`),this.missingFields=i}}class mi extends Error{error;errorDescription;constructor(i,c,s){super(i),this.error=c,this.errorDescription=s}}function os(o){const i=new URL(o);return new URL(i.pathname,i.origin).toString()}async function Zr(o,i,c){return new wo({htu:os(o),htm:i.toUpperCase(),jti:Qr()}).setProtectedHeader({alg:Sr[0],jwk:c.publicKey,typ:"dpop+jwt"}).setIssuedAt().sign(c.privateKey,{})}async function ss(){const{privateKey:o,publicKey:i}=await Ro(Sr[0]),c={privateKey:o,publicKey:await oo(i)};return[c.publicKey.alg]=Sr,c}const _i=600;function as(o){return[401,403].includes(o)}async function us(o,i,c,s){const p=new Headers(s?.headers);return p.set("Authorization",`DPoP ${i}`),p.set("DPoP",await Zr(o,s?.method??"get",c)),{...s,headers:p}}async function cs(o,i,c,s){if(c!==void 0)return us(o,i,c,s);const p=new Headers(s?.headers);return p.set("Authorization",`Bearer ${i}`),{...s,headers:p}}async function Dn(o,i,c,s,p=fetch){return p(i,await cs(i.toString(),o,s,c))}async function ls(o,i,c){const s=await o.tokenRefresher.refresh(o.sessionId,o.refreshToken,i);return c?.emit(je.SESSION_EXTENDED,s.expiresIn??_i),{accessToken:s.accessToken,refreshToken:s.refreshToken,expiresIn:s.expiresIn}}const Lr=o=>o!==void 0?o-Rn>0?o-Rn:o:_i;function hs(o,i){let c=o,s,p=0;const v=6e4,d=i?.refreshOptions;if(d!==void 0){const b=async()=>{try{const{accessToken:w,refreshToken:l,expiresIn:h}=await ls(d,i.dpopKey,i.eventEmitter);c=w,p=0,l!==void 0&&(d.refreshToken=l),clearTimeout(s),s=setTimeout(b,Lr(h)*1e3),i.eventEmitter?.emit(je.TIMEOUT_SET,s)}catch(w){const l=w instanceof mi&&w.error!=="server_error"&&w.error!=="temporarily_unavailable";l&&(i?.eventEmitter?.emit(je.ERROR,w.error,w.errorDescription),i?.eventEmitter?.emit(je.SESSION_EXPIRED));const h=w instanceof rr&&w.missingFields.includes("access_token");if(h&&i?.eventEmitter?.emit(je.SESSION_EXPIRED),!l&&!h){const u=Math.min(1e3*2**p,v);p+=1,clearTimeout(s),s=setTimeout(b,u),i?.eventEmitter?.emit(je.TIMEOUT_SET,s)}}};s=setTimeout(b,Lr(i.expiresIn)*1e3),i.eventEmitter?.emit(je.TIMEOUT_SET,s)}else if(i!==void 0&&i.eventEmitter!==void 0){const b=setTimeout(()=>{i.eventEmitter.emit(je.SESSION_EXPIRED)},Lr(i.expiresIn)*1e3);i.eventEmitter.emit(je.TIMEOUT_SET,b)}return async(b,w)=>{let l=await Dn(c,b,w,i?.dpopKey,i?.fetch);const h=!l.ok&&!as(l.status);return l.ok||h||l.url!==b&&i?.dpopKey!==void 0&&(l=await Dn(c,l.url,w,i.dpopKey,i.fetch)),l}}var gr={exports:{}},Ln;function ds(){if(Ln)return gr.exports;Ln=1;var o=typeof Reflect=="object"?Reflect:null,i=o&&typeof o.apply=="function"?o.apply:function(B,T,I){return Function.prototype.apply.call(B,T,I)},c;o&&typeof o.ownKeys=="function"?c=o.ownKeys:Object.getOwnPropertySymbols?c=function(B){return Object.getOwnPropertyNames(B).concat(Object.getOwnPropertySymbols(B))}:c=function(B){return Object.getOwnPropertyNames(B)};function s(x){console&&console.warn&&console.warn(x)}var p=Number.isNaN||function(B){return B!==B};function v(){v.init.call(this)}gr.exports=v,gr.exports.once=C,v.EventEmitter=v,v.prototype._events=void 0,v.prototype._eventsCount=0,v.prototype._maxListeners=void 0;var d=10;function b(x){if(typeof x!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof x)}Object.defineProperty(v,"defaultMaxListeners",{enumerable:!0,get:function(){return d},set:function(x){if(typeof x!="number"||x<0||p(x))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+x+".");d=x}}),v.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},v.prototype.setMaxListeners=function(B){if(typeof B!="number"||B<0||p(B))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+B+".");return this._maxListeners=B,this};function w(x){return x._maxListeners===void 0?v.defaultMaxListeners:x._maxListeners}v.prototype.getMaxListeners=function(){return w(this)},v.prototype.emit=function(B){for(var T=[],I=1;I<arguments.length;I++)T.push(arguments[I]);var Q=B==="error",ne=this._events;if(ne!==void 0)Q=Q&&ne.error===void 0;else if(!Q)return!1;if(Q){var N;if(T.length>0&&(N=T[0]),N instanceof Error)throw N;var ie=new Error("Unhandled error."+(N?" ("+N.message+")":""));throw ie.context=N,ie}var ye=ne[B];if(ye===void 0)return!1;if(typeof ye=="function")i(ye,this,T);else for(var me=ye.length,Ve=A(ye,me),I=0;I<me;++I)i(Ve[I],this,T);return!0};function l(x,B,T,I){var Q,ne,N;if(b(T),ne=x._events,ne===void 0?(ne=x._events=Object.create(null),x._eventsCount=0):(ne.newListener!==void 0&&(x.emit("newListener",B,T.listener?T.listener:T),ne=x._events),N=ne[B]),N===void 0)N=ne[B]=T,++x._eventsCount;else if(typeof N=="function"?N=ne[B]=I?[T,N]:[N,T]:I?N.unshift(T):N.push(T),Q=w(x),Q>0&&N.length>Q&&!N.warned){N.warned=!0;var ie=new Error("Possible EventEmitter memory leak detected. "+N.length+" "+String(B)+" listeners added. Use emitter.setMaxListeners() to increase limit");ie.name="MaxListenersExceededWarning",ie.emitter=x,ie.type=B,ie.count=N.length,s(ie)}return x}v.prototype.addListener=function(B,T){return l(this,B,T,!1)},v.prototype.on=v.prototype.addListener,v.prototype.prependListener=function(B,T){return l(this,B,T,!0)};function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function u(x,B,T){var I={fired:!1,wrapFn:void 0,target:x,type:B,listener:T},Q=h.bind(I);return Q.listener=T,I.wrapFn=Q,Q}v.prototype.once=function(B,T){return b(T),this.on(B,u(this,B,T)),this},v.prototype.prependOnceListener=function(B,T){return b(T),this.prependListener(B,u(this,B,T)),this},v.prototype.removeListener=function(B,T){var I,Q,ne,N,ie;if(b(T),Q=this._events,Q===void 0)return this;if(I=Q[B],I===void 0)return this;if(I===T||I.listener===T)--this._eventsCount===0?this._events=Object.create(null):(delete Q[B],Q.removeListener&&this.emit("removeListener",B,I.listener||T));else if(typeof I!="function"){for(ne=-1,N=I.length-1;N>=0;N--)if(I[N]===T||I[N].listener===T){ie=I[N].listener,ne=N;break}if(ne<0)return this;ne===0?I.shift():J(I,ne),I.length===1&&(Q[B]=I[0]),Q.removeListener!==void 0&&this.emit("removeListener",B,ie||T)}return this},v.prototype.off=v.prototype.removeListener,v.prototype.removeAllListeners=function(B){var T,I,Q;if(I=this._events,I===void 0)return this;if(I.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):I[B]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete I[B]),this;if(arguments.length===0){var ne=Object.keys(I),N;for(Q=0;Q<ne.length;++Q)N=ne[Q],N!=="removeListener"&&this.removeAllListeners(N);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(T=I[B],typeof T=="function")this.removeListener(B,T);else if(T!==void 0)for(Q=T.length-1;Q>=0;Q--)this.removeListener(B,T[Q]);return this};function S(x,B,T){var I=x._events;if(I===void 0)return[];var Q=I[B];return Q===void 0?[]:typeof Q=="function"?T?[Q.listener||Q]:[Q]:T?H(Q):A(Q,Q.length)}v.prototype.listeners=function(B){return S(this,B,!0)},v.prototype.rawListeners=function(B){return S(this,B,!1)},v.listenerCount=function(x,B){return typeof x.listenerCount=="function"?x.listenerCount(B):R.call(x,B)},v.prototype.listenerCount=R;function R(x){var B=this._events;if(B!==void 0){var T=B[x];if(typeof T=="function")return 1;if(T!==void 0)return T.length}return 0}v.prototype.eventNames=function(){return this._eventsCount>0?c(this._events):[]};function A(x,B){for(var T=new Array(B),I=0;I<B;++I)T[I]=x[I];return T}function J(x,B){for(;B+1<x.length;B++)x[B]=x[B+1];x.pop()}function H(x){for(var B=new Array(x.length),T=0;T<B.length;++T)B[T]=x[T].listener||x[T];return B}function C(x,B){return new Promise(function(T,I){function Q(N){x.removeListener(B,ne),I(N)}function ne(){typeof x.removeListener=="function"&&x.removeListener("error",Q),T([].slice.call(arguments))}W(x,B,ne,{once:!0}),B!=="error"&&U(x,Q,{once:!0})})}function U(x,B,T){typeof x.on=="function"&&W(x,"error",B,T)}function W(x,B,T,I){if(typeof x.on=="function")I.once?x.once(B,T):x.on(B,T);else if(typeof x.addEventListener=="function")x.addEventListener(B,function Q(ne){I.once&&x.removeEventListener(B,Q),T(ne)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof x)}return gr.exports}var fs=ds();const gs=Bi(fs);var vr={exports:{}},ps=vr.exports,Nn;function ys(){return Nn||(Nn=1,(function(o,i){(function(s,p){o.exports=p()})(ps,(function(){return(function(c){var s={};function p(v){if(s[v])return s[v].exports;var d=s[v]={i:v,l:!1,exports:{}};return c[v].call(d.exports,d,d.exports,p),d.l=!0,d.exports}return p.m=c,p.c=s,p.d=function(v,d,b){p.o(v,d)||Object.defineProperty(v,d,{enumerable:!0,get:b})},p.r=function(v){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(v,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(v,"__esModule",{value:!0})},p.t=function(v,d){if(1&d&&(v=p(v)),8&d||4&d&&typeof v=="object"&&v&&v.__esModule)return v;var b=Object.create(null);if(p.r(b),Object.defineProperty(b,"default",{enumerable:!0,value:v}),2&d&&typeof v!="string")for(var w in v)p.d(b,w,(function(l){return v[l]}).bind(null,w));return b},p.n=function(v){var d=v&&v.__esModule?function(){return v.default}:function(){return v};return p.d(d,"a",d),d},p.o=function(v,d){return Object.prototype.hasOwnProperty.call(v,d)},p.p="",p(p.s=22)})([function(c,s,p){Object.defineProperty(s,"__esModule",{value:!0});var v=(function(){function l(h,u){for(var S=0;S<u.length;S++){var R=u[S];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(h,R.key,R)}}return function(h,u,S){return u&&l(h.prototype,u),S&&l(h,S),h}})(),d={debug:function(){},info:function(){},warn:function(){},error:function(){}},b=void 0,w=void 0;(s.Log=(function(){function l(){(function(u,S){if(!(u instanceof S))throw new TypeError("Cannot call a class as a function")})(this,l)}return l.reset=function(){w=3,b=d},l.debug=function(){if(w>=4){for(var u=arguments.length,S=Array(u),R=0;R<u;R++)S[R]=arguments[R];b.debug.apply(b,Array.from(S))}},l.info=function(){if(w>=3){for(var u=arguments.length,S=Array(u),R=0;R<u;R++)S[R]=arguments[R];b.info.apply(b,Array.from(S))}},l.warn=function(){if(w>=2){for(var u=arguments.length,S=Array(u),R=0;R<u;R++)S[R]=arguments[R];b.warn.apply(b,Array.from(S))}},l.error=function(){if(w>=1){for(var u=arguments.length,S=Array(u),R=0;R<u;R++)S[R]=arguments[R];b.error.apply(b,Array.from(S))}},v(l,null,[{key:"NONE",get:function(){return 0}},{key:"ERROR",get:function(){return 1}},{key:"WARN",get:function(){return 2}},{key:"INFO",get:function(){return 3}},{key:"DEBUG",get:function(){return 4}},{key:"level",get:function(){return w},set:function(u){if(!(0<=u&&u<=4))throw new Error("Invalid log level");w=u}},{key:"logger",get:function(){return b},set:function(u){if(!u.debug&&u.info&&(u.debug=u.info),!(u.debug&&u.info&&u.warn&&u.error))throw new Error("Invalid logger");b=u}}]),l})()).reset()},function(c,s,p){Object.defineProperty(s,"__esModule",{value:!0});var v=(function(){function l(h,u){for(var S=0;S<u.length;S++){var R=u[S];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(h,R.key,R)}}return function(h,u,S){return u&&l(h.prototype,u),S&&l(h,S),h}})(),d={setInterval:(function(l){function h(u,S){return l.apply(this,arguments)}return h.toString=function(){return l.toString()},h})((function(l,h){return setInterval(l,h)})),clearInterval:(function(l){function h(u){return l.apply(this,arguments)}return h.toString=function(){return l.toString()},h})((function(l){return clearInterval(l)}))},b=!1,w=null;s.Global=(function(){function l(){(function(u,S){if(!(u instanceof S))throw new TypeError("Cannot call a class as a function")})(this,l)}return l._testing=function(){b=!0},l.setXMLHttpRequest=function(u){w=u},v(l,null,[{key:"location",get:function(){if(!b)return location}},{key:"localStorage",get:function(){if(!b&&typeof window<"u")return localStorage}},{key:"sessionStorage",get:function(){if(!b&&typeof window<"u")return sessionStorage}},{key:"XMLHttpRequest",get:function(){if(!b&&typeof window<"u")return w||XMLHttpRequest}},{key:"timer",get:function(){if(!b)return d}}]),l})()},function(c,s,p){Object.defineProperty(s,"__esModule",{value:!0}),s.MetadataService=void 0;var v=(function(){function h(u,S){for(var R=0;R<S.length;R++){var A=S[R];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(u,A.key,A)}}return function(u,S,R){return S&&h(u.prototype,S),R&&h(u,R),u}})(),d=p(0),b=p(7);function w(h,u){if(!(h instanceof u))throw new TypeError("Cannot call a class as a function")}var l=".well-known/openid-configuration";s.MetadataService=(function(){function h(u){var S=arguments.length>1&&arguments[1]!==void 0?arguments[1]:b.JsonService;if(w(this,h),!u)throw d.Log.error("MetadataService: No settings passed to MetadataService"),new Error("settings");this._settings=u,this._jsonService=new S(["application/jwk-set+json"])}return h.prototype.resetSigningKeys=function(){this._settings=this._settings||{},this._settings.signingKeys=void 0},h.prototype.getMetadata=function(){var S=this;return this._settings.metadata?(d.Log.debug("MetadataService.getMetadata: Returning metadata from settings"),Promise.resolve(this._settings.metadata)):this.metadataUrl?(d.Log.debug("MetadataService.getMetadata: getting metadata from",this.metadataUrl),this._jsonService.getJson(this.metadataUrl).then((function(R){d.Log.debug("MetadataService.getMetadata: json received");var A=S._settings.metadataSeed||{};return S._settings.metadata=Object.assign({},A,R),S._settings.metadata}))):(d.Log.error("MetadataService.getMetadata: No authority or metadataUrl configured on settings"),Promise.reject(new Error("No authority or metadataUrl configured on settings")))},h.prototype.getIssuer=function(){return this._getMetadataProperty("issuer")},h.prototype.getAuthorizationEndpoint=function(){return this._getMetadataProperty("authorization_endpoint")},h.prototype.getUserInfoEndpoint=function(){return this._getMetadataProperty("userinfo_endpoint")},h.prototype.getTokenEndpoint=function(){var S=!(arguments.length>0&&arguments[0]!==void 0)||arguments[0];return this._getMetadataProperty("token_endpoint",S)},h.prototype.getCheckSessionIframe=function(){return this._getMetadataProperty("check_session_iframe",!0)},h.prototype.getEndSessionEndpoint=function(){return this._getMetadataProperty("end_session_endpoint",!0)},h.prototype.getRevocationEndpoint=function(){return this._getMetadataProperty("revocation_endpoint",!0)},h.prototype.getKeysEndpoint=function(){return this._getMetadataProperty("jwks_uri",!0)},h.prototype._getMetadataProperty=function(S){var R=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return d.Log.debug("MetadataService.getMetadataProperty for: "+S),this.getMetadata().then((function(A){if(d.Log.debug("MetadataService.getMetadataProperty: metadata recieved"),A[S]===void 0){if(R===!0)return void d.Log.warn("MetadataService.getMetadataProperty: Metadata does not contain optional property "+S);throw d.Log.error("MetadataService.getMetadataProperty: Metadata does not contain property "+S),new Error("Metadata does not contain property "+S)}return A[S]}))},h.prototype.getSigningKeys=function(){var S=this;return this._settings.signingKeys?(d.Log.debug("MetadataService.getSigningKeys: Returning signingKeys from settings"),Promise.resolve(this._settings.signingKeys)):this._getMetadataProperty("jwks_uri").then((function(R){return d.Log.debug("MetadataService.getSigningKeys: jwks_uri received",R),S._jsonService.getJson(R).then((function(A){if(d.Log.debug("MetadataService.getSigningKeys: key set received",A),!A.keys)throw d.Log.error("MetadataService.getSigningKeys: Missing keys on keyset"),new Error("Missing keys on keyset");return S._settings.signingKeys=A.keys,S._settings.signingKeys}))}))},v(h,[{key:"metadataUrl",get:function(){return this._metadataUrl||(this._settings.metadataUrl?this._metadataUrl=this._settings.metadataUrl:(this._metadataUrl=this._settings.authority,this._metadataUrl&&this._metadataUrl.indexOf(l)<0&&(this._metadataUrl[this._metadataUrl.length-1]!=="/"&&(this._metadataUrl+="/"),this._metadataUrl+=l))),this._metadataUrl}}]),h})()},function(c,s,p){Object.defineProperty(s,"__esModule",{value:!0}),s.UrlUtility=void 0;var v=p(0),d=p(1);s.UrlUtility=(function(){function b(){(function(l,h){if(!(l instanceof h))throw new TypeError("Cannot call a class as a function")})(this,b)}return b.addQueryParam=function(l,h,u){return l.indexOf("?")<0&&(l+="?"),l[l.length-1]!=="?"&&(l+="&"),l+=encodeURIComponent(h),l+="=",l+=encodeURIComponent(u)},b.parseUrlFragment=function(l){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"#",u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:d.Global;typeof l!="string"&&(l=u.location.href);var S=l.lastIndexOf(h);S>=0&&(l=l.substr(S+1)),h==="?"&&(S=l.indexOf("#"))>=0&&(l=l.substr(0,S));for(var R,A={},J=/([^&=]+)=([^&]*)/g,H=0;R=J.exec(l);)if(A[decodeURIComponent(R[1])]=decodeURIComponent(R[2].replace(/\+/g," ")),H++>50)return v.Log.error("UrlUtility.parseUrlFragment: response exceeded expected number of parameters",l),{error:"Response exceeded expected number of parameters"};for(var C in A)return A;return{}},b})()},function(c,s,p){Object.defineProperty(s,"__esModule",{value:!0}),s.JoseUtil=void 0;var v=p(26),d=(function(w){return w&&w.__esModule?w:{default:w}})(p(33));s.JoseUtil=(0,d.default)({jws:v.jws,KeyUtil:v.KeyUtil,X509:v.X509,crypto:v.crypto,hextob64u:v.hextob64u,b64tohex:v.b64tohex,AllowedSigningAlgs:v.AllowedSigningAlgs})},function(c,s,p){Object.defineProperty(s,"__esModule",{value:!0}),s.OidcClientSettings=void 0;var v=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(C){return typeof C}:function(C){return C&&typeof Symbol=="function"&&C.constructor===Symbol&&C!==Symbol.prototype?"symbol":typeof C},d=(function(){function C(U,W){for(var x=0;x<W.length;x++){var B=W[x];B.enumerable=B.enumerable||!1,B.configurable=!0,"value"in B&&(B.writable=!0),Object.defineProperty(U,B.key,B)}}return function(U,W,x){return W&&C(U.prototype,W),x&&C(U,x),U}})(),b=p(0),w=p(23),l=p(6),h=p(24),u=p(2);function S(C,U){if(!(C instanceof U))throw new TypeError("Cannot call a class as a function")}var R=".well-known/openid-configuration",A="id_token",J="openid",H="client_secret_post";s.OidcClientSettings=(function(){function C(){var U=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},W=U.authority,x=U.metadataUrl,B=U.metadata,T=U.signingKeys,I=U.metadataSeed,Q=U.client_id,ne=U.client_secret,N=U.response_type,ie=N===void 0?A:N,ye=U.scope,me=ye===void 0?J:ye,Ve=U.redirect_uri,Re=U.post_logout_redirect_uri,Ge=U.client_authentication,Le=Ge===void 0?H:Ge,Ye=U.prompt,fe=U.display,ve=U.max_age,Je=U.ui_locales,Xe=U.acr_values,rt=U.resource,nt=U.response_mode,ct=U.filterProtocolClaims,Et=ct===void 0||ct,Qe=U.loadUserInfo,it=Qe===void 0||Qe,We=U.staleStateAge,xe=We===void 0?900:We,q=U.clockSkew,g=q===void 0?300:q,y=U.clockService,j=y===void 0?new w.ClockService:y,$=U.userInfoJwtIssuer,X=$===void 0?"OP":$,re=U.mergeClaims,ce=re!==void 0&&re,de=U.stateStore,we=de===void 0?new l.WebStorageStateStore:de,_e=U.ResponseValidatorCtor,Se=_e===void 0?h.ResponseValidator:_e,ot=U.MetadataServiceCtor,ft=ot===void 0?u.MetadataService:ot,le=U.extraQueryParams,Pe=le===void 0?{}:le,pe=U.extraTokenParams,lt=pe===void 0?{}:pe;S(this,C),this._authority=W,this._metadataUrl=x,this._metadata=B,this._metadataSeed=I,this._signingKeys=T,this._client_id=Q,this._client_secret=ne,this._response_type=ie,this._scope=me,this._redirect_uri=Ve,this._post_logout_redirect_uri=Re,this._client_authentication=Le,this._prompt=Ye,this._display=fe,this._max_age=ve,this._ui_locales=Je,this._acr_values=Xe,this._resource=rt,this._response_mode=nt,this._filterProtocolClaims=!!Et,this._loadUserInfo=!!it,this._staleStateAge=xe,this._clockSkew=g,this._clockService=j,this._userInfoJwtIssuer=X,this._mergeClaims=!!ce,this._stateStore=we,this._validator=new Se(this),this._metadataService=new ft(this),this._extraQueryParams=(Pe===void 0?"undefined":v(Pe))==="object"?Pe:{},this._extraTokenParams=(lt===void 0?"undefined":v(lt))==="object"?lt:{}}return C.prototype.getEpochTime=function(){return this._clockService.getEpochTime()},d(C,[{key:"client_id",get:function(){return this._client_id},set:function(W){if(this._client_id)throw b.Log.error("OidcClientSettings.set_client_id: client_id has already been assigned."),new Error("client_id has already been assigned.");this._client_id=W}},{key:"client_secret",get:function(){return this._client_secret}},{key:"response_type",get:function(){return this._response_type}},{key:"scope",get:function(){return this._scope}},{key:"redirect_uri",get:function(){return this._redirect_uri}},{key:"post_logout_redirect_uri",get:function(){return this._post_logout_redirect_uri}},{key:"client_authentication",get:function(){return this._client_authentication}},{key:"prompt",get:function(){return this._prompt}},{key:"display",get:function(){return this._display}},{key:"max_age",get:function(){return this._max_age}},{key:"ui_locales",get:function(){return this._ui_locales}},{key:"acr_values",get:function(){return this._acr_values}},{key:"resource",get:function(){return this._resource}},{key:"response_mode",get:function(){return this._response_mode}},{key:"authority",get:function(){return this._authority},set:function(W){if(this._authority)throw b.Log.error("OidcClientSettings.set_authority: authority has already been assigned."),new Error("authority has already been assigned.");this._authority=W}},{key:"metadataUrl",get:function(){return this._metadataUrl||(this._metadataUrl=this.authority,this._metadataUrl&&this._metadataUrl.indexOf(R)<0&&(this._metadataUrl[this._metadataUrl.length-1]!=="/"&&(this._metadataUrl+="/"),this._metadataUrl+=R)),this._metadataUrl}},{key:"metadata",get:function(){return this._metadata},set:function(W){this._metadata=W}},{key:"metadataSeed",get:function(){return this._metadataSeed},set:function(W){this._metadataSeed=W}},{key:"signingKeys",get:function(){return this._signingKeys},set:function(W){this._signingKeys=W}},{key:"filterProtocolClaims",get:function(){return this._filterProtocolClaims}},{key:"loadUserInfo",get:function(){return this._loadUserInfo}},{key:"staleStateAge",get:function(){return this._staleStateAge}},{key:"clockSkew",get:function(){return this._clockSkew}},{key:"userInfoJwtIssuer",get:function(){return this._userInfoJwtIssuer}},{key:"mergeClaims",get:function(){return this._mergeClaims}},{key:"stateStore",get:function(){return this._stateStore}},{key:"validator",get:function(){return this._validator}},{key:"metadataService",get:function(){return this._metadataService}},{key:"extraQueryParams",get:function(){return this._extraQueryParams},set:function(W){(W===void 0?"undefined":v(W))==="object"?this._extraQueryParams=W:this._extraQueryParams={}}},{key:"extraTokenParams",get:function(){return this._extraTokenParams},set:function(W){(W===void 0?"undefined":v(W))==="object"?this._extraTokenParams=W:this._extraTokenParams={}}}]),C})()},function(c,s,p){Object.defineProperty(s,"__esModule",{value:!0}),s.WebStorageStateStore=void 0;var v=p(0),d=p(1);function b(w,l){if(!(w instanceof l))throw new TypeError("Cannot call a class as a function")}s.WebStorageStateStore=(function(){function w(){var l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},h=l.prefix,u=h===void 0?"oidc.":h,S=l.store,R=S===void 0?d.Global.localStorage:S;b(this,w),this._store=R,this._prefix=u}return w.prototype.set=function(h,u){return v.Log.debug("WebStorageStateStore.set",h),h=this._prefix+h,this._store.setItem(h,u),Promise.resolve()},w.prototype.get=function(h){v.Log.debug("WebStorageStateStore.get",h),h=this._prefix+h;var u=this._store.getItem(h);return Promise.resolve(u)},w.prototype.remove=function(h){v.Log.debug("WebStorageStateStore.remove",h),h=this._prefix+h;var u=this._store.getItem(h);return this._store.removeItem(h),Promise.resolve(u)},w.prototype.getAllKeys=function(){v.Log.debug("WebStorageStateStore.getAllKeys");for(var h=[],u=0;u<this._store.length;u++){var S=this._store.key(u);S.indexOf(this._prefix)===0&&h.push(S.substr(this._prefix.length))}return Promise.resolve(h)},w})()},function(c,s,p){Object.defineProperty(s,"__esModule",{value:!0}),s.JsonService=void 0;var v=p(0),d=p(1);function b(w,l){if(!(w instanceof l))throw new TypeError("Cannot call a class as a function")}s.JsonService=(function(){function w(){var l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:d.Global.XMLHttpRequest,u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null;b(this,w),l&&Array.isArray(l)?this._contentTypes=l.slice():this._contentTypes=[],this._contentTypes.push("application/json"),u&&this._contentTypes.push("application/jwt"),this._XMLHttpRequest=h,this._jwtHandler=u}return w.prototype.getJson=function(h,u){var S=this;if(!h)throw v.Log.error("JsonService.getJson: No url passed"),new Error("url");return v.Log.debug("JsonService.getJson, url: ",h),new Promise((function(R,A){var J=new S._XMLHttpRequest;J.open("GET",h);var H=S._contentTypes,C=S._jwtHandler;J.onload=function(){if(v.Log.debug("JsonService.getJson: HTTP response received, status",J.status),J.status===200){var U=J.getResponseHeader("Content-Type");if(U){var W=H.find((function(x){if(U.startsWith(x))return!0}));if(W=="application/jwt")return void C(J).then(R,A);if(W)try{return void R(JSON.parse(J.responseText))}catch(x){return v.Log.error("JsonService.getJson: Error parsing JSON response",x.message),void A(x)}}A(Error("Invalid response Content-Type: "+U+", from URL: "+h))}else A(Error(J.statusText+" ("+J.status+")"))},J.onerror=function(){v.Log.error("JsonService.getJson: network error"),A(Error("Network Error"))},u&&(v.Log.debug("JsonService.getJson: token passed, setting Authorization header"),J.setRequestHeader("Authorization","Bearer "+u)),J.send()}))},w.prototype.postForm=function(h,u,S){var R=this;if(!h)throw v.Log.error("JsonService.postForm: No url passed"),new Error("url");return v.Log.debug("JsonService.postForm, url: ",h),new Promise((function(A,J){var H=new R._XMLHttpRequest;H.open("POST",h);var C=R._contentTypes;H.onload=function(){if(v.Log.debug("JsonService.postForm: HTTP response received, status",H.status),H.status!==200){if(H.status===400&&(T=H.getResponseHeader("Content-Type"))&&C.find((function(I){if(T.startsWith(I))return!0})))try{var B=JSON.parse(H.responseText);if(B&&B.error)return v.Log.error("JsonService.postForm: Error from server: ",B.error),void J(new Error(B.error))}catch(I){return v.Log.error("JsonService.postForm: Error parsing JSON response",I.message),void J(I)}J(Error(H.statusText+" ("+H.status+")"))}else{var T;if((T=H.getResponseHeader("Content-Type"))&&C.find((function(I){if(T.startsWith(I))return!0})))try{return void A(JSON.parse(H.responseText))}catch(I){return v.Log.error("JsonService.postForm: Error parsing JSON response",I.message),void J(I)}J(Error("Invalid response Content-Type: "+T+", from URL: "+h))}},H.onerror=function(){v.Log.error("JsonService.postForm: network error"),J(Error("Network Error"))};var U="";for(var W in u){var x=u[W];x&&(U.length>0&&(U+="&"),U+=encodeURIComponent(W),U+="=",U+=encodeURIComponent(x))}H.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),S!==void 0&&H.setRequestHeader("Authorization","Basic "+btoa(S)),H.send(U)}))},w})()},function(c,s,p){Object.defineProperty(s,"__esModule",{value:!0}),s.SigninRequest=void 0;var v=p(0),d=p(3),b=p(13);s.SigninRequest=(function(){function w(l){var h=l.url,u=l.client_id,S=l.redirect_uri,R=l.response_type,A=l.scope,J=l.authority,H=l.data,C=l.prompt,U=l.display,W=l.max_age,x=l.ui_locales,B=l.id_token_hint,T=l.login_hint,I=l.acr_values,Q=l.resource,ne=l.response_mode,N=l.request,ie=l.request_uri,ye=l.extraQueryParams,me=l.request_type,Ve=l.client_secret,Re=l.extraTokenParams,Ge=l.skipUserInfo;if((function(rt,nt){if(!(rt instanceof nt))throw new TypeError("Cannot call a class as a function")})(this,w),!h)throw v.Log.error("SigninRequest.ctor: No url passed"),new Error("url");if(!u)throw v.Log.error("SigninRequest.ctor: No client_id passed"),new Error("client_id");if(!S)throw v.Log.error("SigninRequest.ctor: No redirect_uri passed"),new Error("redirect_uri");if(!R)throw v.Log.error("SigninRequest.ctor: No response_type passed"),new Error("response_type");if(!A)throw v.Log.error("SigninRequest.ctor: No scope passed"),new Error("scope");if(!J)throw v.Log.error("SigninRequest.ctor: No authority passed"),new Error("authority");var Le=w.isOidc(R),Ye=w.isCode(R);ne||(ne=w.isCode(R)?"query":null),this.state=new b.SigninState({nonce:Le,data:H,client_id:u,authority:J,redirect_uri:S,code_verifier:Ye,request_type:me,response_mode:ne,client_secret:Ve,scope:A,extraTokenParams:Re,skipUserInfo:Ge}),h=d.UrlUtility.addQueryParam(h,"client_id",u),h=d.UrlUtility.addQueryParam(h,"redirect_uri",S),h=d.UrlUtility.addQueryParam(h,"response_type",R),h=d.UrlUtility.addQueryParam(h,"scope",A),h=d.UrlUtility.addQueryParam(h,"state",this.state.id),Le&&(h=d.UrlUtility.addQueryParam(h,"nonce",this.state.nonce)),Ye&&(h=d.UrlUtility.addQueryParam(h,"code_challenge",this.state.code_challenge),h=d.UrlUtility.addQueryParam(h,"code_challenge_method","S256"));var fe={prompt:C,display:U,max_age:W,ui_locales:x,id_token_hint:B,login_hint:T,acr_values:I,resource:Q,request:N,request_uri:ie,response_mode:ne};for(var ve in fe)fe[ve]&&(h=d.UrlUtility.addQueryParam(h,ve,fe[ve]));for(var Je in ye)h=d.UrlUtility.addQueryParam(h,Je,ye[Je]);this.url=h}return w.isOidc=function(h){return!!h.split(/\s+/g).filter((function(u){return u==="id_token"}))[0]},w.isOAuth=function(h){return!!h.split(/\s+/g).filter((function(u){return u==="token"}))[0]},w.isCode=function(h){return!!h.split(/\s+/g).filter((function(u){return u==="code"}))[0]},w})()},function(c,s,p){Object.defineProperty(s,"__esModule",{value:!0}),s.State=void 0;var v=(function(){function l(h,u){for(var S=0;S<u.length;S++){var R=u[S];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(h,R.key,R)}}return function(h,u,S){return u&&l(h.prototype,u),S&&l(h,S),h}})(),d=p(0),b=(function(h){return h&&h.__esModule?h:{default:h}})(p(14));function w(l,h){if(!(l instanceof h))throw new TypeError("Cannot call a class as a function")}s.State=(function(){function l(){var h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},u=h.id,S=h.data,R=h.created,A=h.request_type;w(this,l),this._id=u||(0,b.default)(),this._data=S,this._created=typeof R=="number"&&R>0?R:parseInt(Date.now()/1e3),this._request_type=A}return l.prototype.toStorageString=function(){return d.Log.debug("State.toStorageString"),JSON.stringify({id:this.id,data:this.data,created:this.created,request_type:this.request_type})},l.fromStorageString=function(u){return d.Log.debug("State.fromStorageString"),new l(JSON.parse(u))},l.clearStaleState=function(u,S){var R=Date.now()/1e3-S;return u.getAllKeys().then((function(A){d.Log.debug("State.clearStaleState: got keys",A);for(var J=[],H=function(x){var B=A[x];U=u.get(B).then((function(T){var I=!1;if(T)try{var Q=l.fromStorageString(T);d.Log.debug("State.clearStaleState: got item from key: ",B,Q.created),Q.created<=R&&(I=!0)}catch(ne){d.Log.error("State.clearStaleState: Error parsing state for key",B,ne.message),I=!0}else d.Log.debug("State.clearStaleState: no item in storage for key: ",B),I=!0;if(I)return d.Log.debug("State.clearStaleState: removed item for key: ",B),u.remove(B)})),J.push(U)},C=0;C<A.length;C++){var U;H(C)}return d.Log.debug("State.clearStaleState: waiting on promise count:",J.length),Promise.all(J)}))},v(l,[{key:"id",get:function(){return this._id}},{key:"data",get:function(){return this._data}},{key:"created",get:function(){return this._created}},{key:"request_type",get:function(){return this._request_type}}]),l})()},function(c,s,p){Object.defineProperty(s,"__esModule",{value:!0}),s.OidcClient=void 0;var v=(function(){function H(C,U){for(var W=0;W<U.length;W++){var x=U[W];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(C,x.key,x)}}return function(C,U,W){return U&&H(C.prototype,U),W&&H(C,W),C}})(),d=p(0),b=p(5),w=p(12),l=p(8),h=p(34),u=p(35),S=p(36),R=p(13),A=p(9);function J(H,C){if(!(H instanceof C))throw new TypeError("Cannot call a class as a function")}s.OidcClient=(function(){function H(){var C=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};J(this,H),C instanceof b.OidcClientSettings?this._settings=C:this._settings=new b.OidcClientSettings(C)}return H.prototype.createSigninRequest=function(){var U=this,W=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},x=W.response_type,B=W.scope,T=W.redirect_uri,I=W.data,Q=W.state,ne=W.prompt,N=W.display,ie=W.max_age,ye=W.ui_locales,me=W.id_token_hint,Ve=W.login_hint,Re=W.acr_values,Ge=W.resource,Le=W.request,Ye=W.request_uri,fe=W.response_mode,ve=W.extraQueryParams,Je=W.extraTokenParams,Xe=W.request_type,rt=W.skipUserInfo,nt=arguments[1];d.Log.debug("OidcClient.createSigninRequest");var ct=this._settings.client_id;x=x||this._settings.response_type,B=B||this._settings.scope,T=T||this._settings.redirect_uri,ne=ne||this._settings.prompt,N=N||this._settings.display,ie=ie||this._settings.max_age,ye=ye||this._settings.ui_locales,Re=Re||this._settings.acr_values,Ge=Ge||this._settings.resource,fe=fe||this._settings.response_mode,ve=ve||this._settings.extraQueryParams,Je=Je||this._settings.extraTokenParams;var Et=this._settings.authority;return l.SigninRequest.isCode(x)&&x!=="code"?Promise.reject(new Error("OpenID Connect hybrid flow is not supported")):this._metadataService.getAuthorizationEndpoint().then((function(Qe){d.Log.debug("OidcClient.createSigninRequest: Received authorization endpoint",Qe);var it=new l.SigninRequest({url:Qe,client_id:ct,redirect_uri:T,response_type:x,scope:B,data:I||Q,authority:Et,prompt:ne,display:N,max_age:ie,ui_locales:ye,id_token_hint:me,login_hint:Ve,acr_values:Re,resource:Ge,request:Le,request_uri:Ye,extraQueryParams:ve,extraTokenParams:Je,request_type:Xe,response_mode:fe,client_secret:U._settings.client_secret,skipUserInfo:rt}),We=it.state;return(nt=nt||U._stateStore).set(We.id,We.toStorageString()).then((function(){return it}))}))},H.prototype.readSigninResponseState=function(U,W){var x=arguments.length>2&&arguments[2]!==void 0&&arguments[2];d.Log.debug("OidcClient.readSigninResponseState");var B=this._settings.response_mode==="query"||!this._settings.response_mode&&l.SigninRequest.isCode(this._settings.response_type),T=B?"?":"#",I=new h.SigninResponse(U,T);if(!I.state)return d.Log.error("OidcClient.readSigninResponseState: No state in response"),Promise.reject(new Error("No state in response"));W=W||this._stateStore;var Q=x?W.remove.bind(W):W.get.bind(W);return Q(I.state).then((function(ne){if(!ne)throw d.Log.error("OidcClient.readSigninResponseState: No matching state found in storage"),new Error("No matching state found in storage");return{state:R.SigninState.fromStorageString(ne),response:I}}))},H.prototype.processSigninResponse=function(U,W){var x=this;return d.Log.debug("OidcClient.processSigninResponse"),this.readSigninResponseState(U,W,!0).then((function(B){var T=B.state,I=B.response;return d.Log.debug("OidcClient.processSigninResponse: Received state from storage; validating response"),x._validator.validateSigninResponse(T,I)}))},H.prototype.createSignoutRequest=function(){var U=this,W=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},x=W.id_token_hint,B=W.data,T=W.state,I=W.post_logout_redirect_uri,Q=W.extraQueryParams,ne=W.request_type,N=arguments[1];return d.Log.debug("OidcClient.createSignoutRequest"),I=I||this._settings.post_logout_redirect_uri,Q=Q||this._settings.extraQueryParams,this._metadataService.getEndSessionEndpoint().then((function(ie){if(!ie)throw d.Log.error("OidcClient.createSignoutRequest: No end session endpoint url returned"),new Error("no end session endpoint");d.Log.debug("OidcClient.createSignoutRequest: Received end session endpoint",ie);var ye=new u.SignoutRequest({url:ie,id_token_hint:x,post_logout_redirect_uri:I,data:B||T,extraQueryParams:Q,request_type:ne}),me=ye.state;return me&&(d.Log.debug("OidcClient.createSignoutRequest: Signout request has state to persist"),(N=N||U._stateStore).set(me.id,me.toStorageString())),ye}))},H.prototype.readSignoutResponseState=function(U,W){var x=arguments.length>2&&arguments[2]!==void 0&&arguments[2];d.Log.debug("OidcClient.readSignoutResponseState");var B=new S.SignoutResponse(U);if(!B.state)return d.Log.debug("OidcClient.readSignoutResponseState: No state in response"),B.error?(d.Log.warn("OidcClient.readSignoutResponseState: Response was error: ",B.error),Promise.reject(new w.ErrorResponse(B))):Promise.resolve({state:void 0,response:B});var T=B.state;W=W||this._stateStore;var I=x?W.remove.bind(W):W.get.bind(W);return I(T).then((function(Q){if(!Q)throw d.Log.error("OidcClient.readSignoutResponseState: No matching state found in storage"),new Error("No matching state found in storage");return{state:A.State.fromStorageString(Q),response:B}}))},H.prototype.processSignoutResponse=function(U,W){var x=this;return d.Log.debug("OidcClient.processSignoutResponse"),this.readSignoutResponseState(U,W,!0).then((function(B){var T=B.state,I=B.response;return T?(d.Log.debug("OidcClient.processSignoutResponse: Received state from storage; validating response"),x._validator.validateSignoutResponse(T,I)):(d.Log.debug("OidcClient.processSignoutResponse: No state from storage; skipping validating response"),I)}))},H.prototype.clearStaleState=function(U){return d.Log.debug("OidcClient.clearStaleState"),U=U||this._stateStore,A.State.clearStaleState(U,this.settings.staleStateAge)},v(H,[{key:"_stateStore",get:function(){return this.settings.stateStore}},{key:"_validator",get:function(){return this.settings.validator}},{key:"_metadataService",get:function(){return this.settings.metadataService}},{key:"settings",get:function(){return this._settings}},{key:"metadataService",get:function(){return this._metadataService}}]),H})()},function(c,s,p){Object.defineProperty(s,"__esModule",{value:!0}),s.TokenClient=void 0;var v=p(7),d=p(2),b=p(0);function w(l,h){if(!(l instanceof h))throw new TypeError("Cannot call a class as a function")}s.TokenClient=(function(){function l(h){var u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:v.JsonService,S=arguments.length>2&&arguments[2]!==void 0?arguments[2]:d.MetadataService;if(w(this,l),!h)throw b.Log.error("TokenClient.ctor: No settings passed"),new Error("settings");this._settings=h,this._jsonService=new u,this._metadataService=new S(this._settings)}return l.prototype.exchangeCode=function(){var u=this,S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};(S=Object.assign({},S)).grant_type=S.grant_type||"authorization_code",S.client_id=S.client_id||this._settings.client_id,S.client_secret=S.client_secret||this._settings.client_secret,S.redirect_uri=S.redirect_uri||this._settings.redirect_uri;var R=void 0,A=S._client_authentication||this._settings._client_authentication;return delete S._client_authentication,S.code?S.redirect_uri?S.code_verifier?S.client_id?S.client_secret||A!="client_secret_basic"?(A=="client_secret_basic"&&(R=S.client_id+":"+S.client_secret,delete S.client_id,delete S.client_secret),this._metadataService.getTokenEndpoint(!1).then((function(J){return b.Log.debug("TokenClient.exchangeCode: Received token endpoint"),u._jsonService.postForm(J,S,R).then((function(H){return b.Log.debug("TokenClient.exchangeCode: response received"),H}))}))):(b.Log.error("TokenClient.exchangeCode: No client_secret passed"),Promise.reject(new Error("A client_secret is required"))):(b.Log.error("TokenClient.exchangeCode: No client_id passed"),Promise.reject(new Error("A client_id is required"))):(b.Log.error("TokenClient.exchangeCode: No code_verifier passed"),Promise.reject(new Error("A code_verifier is required"))):(b.Log.error("TokenClient.exchangeCode: No redirect_uri passed"),Promise.reject(new Error("A redirect_uri is required"))):(b.Log.error("TokenClient.exchangeCode: No code passed"),Promise.reject(new Error("A code is required")))},l.prototype.exchangeRefreshToken=function(){var u=this,S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};(S=Object.assign({},S)).grant_type=S.grant_type||"refresh_token",S.client_id=S.client_id||this._settings.client_id,S.client_secret=S.client_secret||this._settings.client_secret;var R=void 0,A=S._client_authentication||this._settings._client_authentication;return delete S._client_authentication,S.refresh_token?S.client_id?(A=="client_secret_basic"&&(R=S.client_id+":"+S.client_secret,delete S.client_id,delete S.client_secret),this._metadataService.getTokenEndpoint(!1).then((function(J){return b.Log.debug("TokenClient.exchangeRefreshToken: Received token endpoint"),u._jsonService.postForm(J,S,R).then((function(H){return b.Log.debug("TokenClient.exchangeRefreshToken: response received"),H}))}))):(b.Log.error("TokenClient.exchangeRefreshToken: No client_id passed"),Promise.reject(new Error("A client_id is required"))):(b.Log.error("TokenClient.exchangeRefreshToken: No refresh_token passed"),Promise.reject(new Error("A refresh_token is required")))},l})()},function(c,s,p){Object.defineProperty(s,"__esModule",{value:!0}),s.ErrorResponse=void 0;var v=p(0);function d(w,l){if(!(w instanceof l))throw new TypeError("Cannot call a class as a function")}function b(w,l){if(!w)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!l||typeof l!="object"&&typeof l!="function"?w:l}s.ErrorResponse=(function(w){function l(){var h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},u=h.error,S=h.error_description,R=h.error_uri,A=h.state,J=h.session_state;if(d(this,l),!u)throw v.Log.error("No error passed to ErrorResponse"),new Error("error");var H=b(this,w.call(this,S||u));return H.name="ErrorResponse",H.error=u,H.error_description=S,H.error_uri=R,H.state=A,H.session_state=J,H}return(function(u,S){if(typeof S!="function"&&S!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof S);u.prototype=Object.create(S&&S.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),S&&(Object.setPrototypeOf?Object.setPrototypeOf(u,S):u.__proto__=S)})(l,w),l})(Error)},function(c,s,p){Object.defineProperty(s,"__esModule",{value:!0}),s.SigninState=void 0;var v=(function(){function S(R,A){for(var J=0;J<A.length;J++){var H=A[J];H.enumerable=H.enumerable||!1,H.configurable=!0,"value"in H&&(H.writable=!0),Object.defineProperty(R,H.key,H)}}return function(R,A,J){return A&&S(R.prototype,A),J&&S(R,J),R}})(),d=p(0),b=p(9),w=p(4),l=(function(R){return R&&R.__esModule?R:{default:R}})(p(14));function h(S,R){if(!(S instanceof R))throw new TypeError("Cannot call a class as a function")}function u(S,R){if(!S)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!R||typeof R!="object"&&typeof R!="function"?S:R}s.SigninState=(function(S){function R(){var A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},J=A.nonce,H=A.authority,C=A.client_id,U=A.redirect_uri,W=A.code_verifier,x=A.response_mode,B=A.client_secret,T=A.scope,I=A.extraTokenParams,Q=A.skipUserInfo;h(this,R);var ne=u(this,S.call(this,arguments[0]));if(J===!0?ne._nonce=(0,l.default)():J&&(ne._nonce=J),W===!0?ne._code_verifier=(0,l.default)()+(0,l.default)()+(0,l.default)():W&&(ne._code_verifier=W),ne.code_verifier){var N=w.JoseUtil.hashString(ne.code_verifier,"SHA256");ne._code_challenge=w.JoseUtil.hexToBase64Url(N)}return ne._redirect_uri=U,ne._authority=H,ne._client_id=C,ne._response_mode=x,ne._client_secret=B,ne._scope=T,ne._extraTokenParams=I,ne._skipUserInfo=Q,ne}return(function(J,H){if(typeof H!="function"&&H!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof H);J.prototype=Object.create(H&&H.prototype,{constructor:{value:J,enumerable:!1,writable:!0,configurable:!0}}),H&&(Object.setPrototypeOf?Object.setPrototypeOf(J,H):J.__proto__=H)})(R,S),R.prototype.toStorageString=function(){return d.Log.debug("SigninState.toStorageString"),JSON.stringify({id:this.id,data:this.data,created:this.created,request_type:this.request_type,nonce:this.nonce,code_verifier:this.code_verifier,redirect_uri:this.redirect_uri,authority:this.authority,client_id:this.client_id,response_mode:this.response_mode,client_secret:this.client_secret,scope:this.scope,extraTokenParams:this.extraTokenParams,skipUserInfo:this.skipUserInfo})},R.fromStorageString=function(J){return d.Log.debug("SigninState.fromStorageString"),new R(JSON.parse(J))},v(R,[{key:"nonce",get:function(){return this._nonce}},{key:"authority",get:function(){return this._authority}},{key:"client_id",get:function(){return this._client_id}},{key:"redirect_uri",get:function(){return this._redirect_uri}},{key:"code_verifier",get:function(){return this._code_verifier}},{key:"code_challenge",get:function(){return this._code_challenge}},{key:"response_mode",get:function(){return this._response_mode}},{key:"client_secret",get:function(){return this._client_secret}},{key:"scope",get:function(){return this._scope}},{key:"extraTokenParams",get:function(){return this._extraTokenParams}},{key:"skipUserInfo",get:function(){return this._skipUserInfo}}]),R})(b.State)},function(c,s,p){Object.defineProperty(s,"__esModule",{value:!0}),s.default=function(){return(v!="undefined"&&v!==null&&v.getRandomValues!==void 0?d:b)().replace(/-/g,"")};var v=typeof window<"u"?window.crypto||window.msCrypto:null;function d(){return("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,(function(w){return(w^v.getRandomValues(new Uint8Array(1))[0]&15>>w/4).toString(16)}))}function b(){return("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,(function(w){return(w^16*Math.random()>>w/4).toString(16)}))}c.exports=s.default},function(c,s,p){Object.defineProperty(s,"__esModule",{value:!0}),s.User=void 0;var v=(function(){function b(w,l){for(var h=0;h<l.length;h++){var u=l[h];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(w,u.key,u)}}return function(w,l,h){return l&&b(w.prototype,l),h&&b(w,h),w}})(),d=p(0);s.User=(function(){function b(w){var l=w.id_token,h=w.session_state,u=w.access_token,S=w.refresh_token,R=w.token_type,A=w.scope,J=w.profile,H=w.expires_at,C=w.state;(function(W,x){if(!(W instanceof x))throw new TypeError("Cannot call a class as a function")})(this,b),this.id_token=l,this.session_state=h,this.access_token=u,this.refresh_token=S,this.token_type=R,this.scope=A,this.profile=J,this.expires_at=H,this.state=C}return b.prototype.toStorageString=function(){return d.Log.debug("User.toStorageString"),JSON.stringify({id_token:this.id_token,session_state:this.session_state,access_token:this.access_token,refresh_token:this.refresh_token,token_type:this.token_type,scope:this.scope,profile:this.profile,expires_at:this.expires_at})},b.fromStorageString=function(l){return d.Log.debug("User.fromStorageString"),new b(JSON.parse(l))},v(b,[{key:"expires_in",get:function(){if(this.expires_at){var l=parseInt(Date.now()/1e3);return this.expires_at-l}},set:function(l){var h=parseInt(l);if(typeof h=="number"&&h>0){var u=parseInt(Date.now()/1e3);this.expires_at=u+h}}},{key:"expired",get:function(){var l=this.expires_in;if(l!==void 0)return l<=0}},{key:"scopes",get:function(){return(this.scope||"").split(" ")}}]),b})()},function(c,s,p){Object.defineProperty(s,"__esModule",{value:!0}),s.AccessTokenEvents=void 0;var v=p(0),d=p(46);function b(w,l){if(!(w instanceof l))throw new TypeError("Cannot call a class as a function")}s.AccessTokenEvents=(function(){function w(){var l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},h=l.accessTokenExpiringNotificationTime,u=h===void 0?60:h,S=l.accessTokenExpiringTimer,R=S===void 0?new d.Timer("Access token expiring"):S,A=l.accessTokenExpiredTimer,J=A===void 0?new d.Timer("Access token expired"):A;b(this,w),this._accessTokenExpiringNotificationTime=u,this._accessTokenExpiring=R,this._accessTokenExpired=J}return w.prototype.load=function(h){if(h.access_token&&h.expires_in!==void 0){var u=h.expires_in;if(v.Log.debug("AccessTokenEvents.load: access token present, remaining duration:",u),u>0){var S=u-this._accessTokenExpiringNotificationTime;S<=0&&(S=1),v.Log.debug("AccessTokenEvents.load: registering expiring timer in:",S),this._accessTokenExpiring.init(S)}else v.Log.debug("AccessTokenEvents.load: canceling existing expiring timer becase we're past expiration."),this._accessTokenExpiring.cancel();var R=u+1;v.Log.debug("AccessTokenEvents.load: registering expired timer in:",R),this._accessTokenExpired.init(R)}else this._accessTokenExpiring.cancel(),this._accessTokenExpired.cancel()},w.prototype.unload=function(){v.Log.debug("AccessTokenEvents.unload: canceling existing access token timers"),this._accessTokenExpiring.cancel(),this._accessTokenExpired.cancel()},w.prototype.addAccessTokenExpiring=function(h){this._accessTokenExpiring.addHandler(h)},w.prototype.removeAccessTokenExpiring=function(h){this._accessTokenExpiring.removeHandler(h)},w.prototype.addAccessTokenExpired=function(h){this._accessTokenExpired.addHandler(h)},w.prototype.removeAccessTokenExpired=function(h){this._accessTokenExpired.removeHandler(h)},w})()},function(c,s,p){Object.defineProperty(s,"__esModule",{value:!0}),s.Event=void 0;var v=p(0);s.Event=(function(){function d(b){(function(l,h){if(!(l instanceof h))throw new TypeError("Cannot call a class as a function")})(this,d),this._name=b,this._callbacks=[]}return d.prototype.addHandler=function(w){this._callbacks.push(w)},d.prototype.removeHandler=function(w){var l=this._callbacks.findIndex((function(h){return h===w}));l>=0&&this._callbacks.splice(l,1)},d.prototype.raise=function(){v.Log.debug("Event: Raising event: "+this._name);for(var w=0;w<this._callbacks.length;w++){var l;(l=this._callbacks)[w].apply(l,arguments)}},d})()},function(c,s,p){Object.defineProperty(s,"__esModule",{value:!0}),s.SessionMonitor=void 0;var v=(function(){function h(u,S){for(var R=0;R<S.length;R++){var A=S[R];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(u,A.key,A)}}return function(u,S,R){return S&&h(u.prototype,S),R&&h(u,R),u}})(),d=p(0),b=p(19),w=p(1);function l(h,u){if(!(h instanceof u))throw new TypeError("Cannot call a class as a function")}s.SessionMonitor=(function(){function h(u){var S=this,R=arguments.length>1&&arguments[1]!==void 0?arguments[1]:b.CheckSessionIFrame,A=arguments.length>2&&arguments[2]!==void 0?arguments[2]:w.Global.timer;if(l(this,h),!u)throw d.Log.error("SessionMonitor.ctor: No user manager passed to SessionMonitor"),new Error("userManager");this._userManager=u,this._CheckSessionIFrameCtor=R,this._timer=A,this._userManager.events.addUserLoaded(this._start.bind(this)),this._userManager.events.addUserUnloaded(this._stop.bind(this)),Promise.resolve(this._userManager.getUser().then((function(J){J?S._start(J):S._settings.monitorAnonymousSession&&S._userManager.querySessionStatus().then((function(H){var C={session_state:H.session_state};H.sub&&H.sid&&(C.profile={sub:H.sub,sid:H.sid}),S._start(C)})).catch((function(H){d.Log.error("SessionMonitor ctor: error from querySessionStatus:",H.message)}))})).catch((function(J){d.Log.error("SessionMonitor ctor: error from getUser:",J.message)})))}return h.prototype._start=function(S){var R=this,A=S.session_state;A&&(S.profile?(this._sub=S.profile.sub,this._sid=S.profile.sid,d.Log.debug("SessionMonitor._start: session_state:",A,", sub:",this._sub)):(this._sub=void 0,this._sid=void 0,d.Log.debug("SessionMonitor._start: session_state:",A,", anonymous user")),this._checkSessionIFrame?this._checkSessionIFrame.start(A):this._metadataService.getCheckSessionIframe().then((function(J){if(J){d.Log.debug("SessionMonitor._start: Initializing check session iframe");var H=R._client_id,C=R._checkSessionInterval,U=R._stopCheckSessionOnError;R._checkSessionIFrame=new R._CheckSessionIFrameCtor(R._callback.bind(R),H,J,C,U),R._checkSessionIFrame.load().then((function(){R._checkSessionIFrame.start(A)}))}else d.Log.warn("SessionMonitor._start: No check session iframe found in the metadata")})).catch((function(J){d.Log.error("SessionMonitor._start: Error from getCheckSessionIframe:",J.message)})))},h.prototype._stop=function(){var S=this;if(this._sub=void 0,this._sid=void 0,this._checkSessionIFrame&&(d.Log.debug("SessionMonitor._stop"),this._checkSessionIFrame.stop()),this._settings.monitorAnonymousSession)var R=this._timer.setInterval((function(){S._timer.clearInterval(R),S._userManager.querySessionStatus().then((function(A){var J={session_state:A.session_state};A.sub&&A.sid&&(J.profile={sub:A.sub,sid:A.sid}),S._start(J)})).catch((function(A){d.Log.error("SessionMonitor: error from querySessionStatus:",A.message)}))}),1e3)},h.prototype._callback=function(){var S=this;this._userManager.querySessionStatus().then((function(R){var A=!0;R?R.sub===S._sub?(A=!1,S._checkSessionIFrame.start(R.session_state),R.sid===S._sid?d.Log.debug("SessionMonitor._callback: Same sub still logged in at OP, restarting check session iframe; session_state:",R.session_state):(d.Log.debug("SessionMonitor._callback: Same sub still logged in at OP, session state has changed, restarting check session iframe; session_state:",R.session_state),S._userManager.events._raiseUserSessionChanged())):d.Log.debug("SessionMonitor._callback: Different subject signed into OP:",R.sub):d.Log.debug("SessionMonitor._callback: Subject no longer signed into OP"),A&&(S._sub?(d.Log.debug("SessionMonitor._callback: SessionMonitor._callback; raising signed out event"),S._userManager.events._raiseUserSignedOut()):(d.Log.debug("SessionMonitor._callback: SessionMonitor._callback; raising signed in event"),S._userManager.events._raiseUserSignedIn()))})).catch((function(R){S._sub&&(d.Log.debug("SessionMonitor._callback: Error calling queryCurrentSigninSession; raising signed out event",R.message),S._userManager.events._raiseUserSignedOut())}))},v(h,[{key:"_settings",get:function(){return this._userManager.settings}},{key:"_metadataService",get:function(){return this._userManager.metadataService}},{key:"_client_id",get:function(){return this._settings.client_id}},{key:"_checkSessionInterval",get:function(){return this._settings.checkSessionInterval}},{key:"_stopCheckSessionOnError",get:function(){return this._settings.stopCheckSessionOnError}}]),h})()},function(c,s,p){Object.defineProperty(s,"__esModule",{value:!0}),s.CheckSessionIFrame=void 0;var v=p(0);function d(b,w){if(!(b instanceof w))throw new TypeError("Cannot call a class as a function")}s.CheckSessionIFrame=(function(){function b(w,l,h,u){var S=!(arguments.length>4&&arguments[4]!==void 0)||arguments[4];d(this,b),this._callback=w,this._client_id=l,this._url=h,this._interval=u||2e3,this._stopOnError=S;var R=h.indexOf("/",h.indexOf("//")+2);this._frame_origin=h.substr(0,R),this._frame=window.document.createElement("iframe"),this._frame.style.visibility="hidden",this._frame.style.position="absolute",this._frame.style.display="none",this._frame.width=0,this._frame.height=0,this._frame.src=h}return b.prototype.load=function(){var l=this;return new Promise((function(h){l._frame.onload=function(){h()},window.document.body.appendChild(l._frame),l._boundMessageEvent=l._message.bind(l),window.addEventListener("message",l._boundMessageEvent,!1)}))},b.prototype._message=function(l){l.origin===this._frame_origin&&l.source===this._frame.contentWindow&&(l.data==="error"?(v.Log.error("CheckSessionIFrame: error message from check session op iframe"),this._stopOnError&&this.stop()):l.data==="changed"?(v.Log.debug("CheckSessionIFrame: changed message from check session op iframe"),this.stop(),this._callback()):v.Log.debug("CheckSessionIFrame: "+l.data+" message from check session op iframe"))},b.prototype.start=function(l){var h=this;if(this._session_state!==l){v.Log.debug("CheckSessionIFrame.start"),this.stop(),this._session_state=l;var u=function(){h._frame.contentWindow.postMessage(h._client_id+" "+h._session_state,h._frame_origin)};u(),this._timer=window.setInterval(u,this._interval)}},b.prototype.stop=function(){this._session_state=null,this._timer&&(v.Log.debug("CheckSessionIFrame.stop"),window.clearInterval(this._timer),this._timer=null)},b})()},function(c,s,p){Object.defineProperty(s,"__esModule",{value:!0}),s.TokenRevocationClient=void 0;var v=p(0),d=p(2),b=p(1);function w(u,S){if(!(u instanceof S))throw new TypeError("Cannot call a class as a function")}var l="access_token",h="refresh_token";s.TokenRevocationClient=(function(){function u(S){var R=arguments.length>1&&arguments[1]!==void 0?arguments[1]:b.Global.XMLHttpRequest,A=arguments.length>2&&arguments[2]!==void 0?arguments[2]:d.MetadataService;if(w(this,u),!S)throw v.Log.error("TokenRevocationClient.ctor: No settings provided"),new Error("No settings provided.");this._settings=S,this._XMLHttpRequestCtor=R,this._metadataService=new A(this._settings)}return u.prototype.revoke=function(R,A){var J=this,H=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"access_token";if(!R)throw v.Log.error("TokenRevocationClient.revoke: No token provided"),new Error("No token provided.");if(H!==l&&H!=h)throw v.Log.error("TokenRevocationClient.revoke: Invalid token type"),new Error("Invalid token type.");return this._metadataService.getRevocationEndpoint().then((function(C){if(C){v.Log.debug("TokenRevocationClient.revoke: Revoking "+H);var U=J._settings.client_id,W=J._settings.client_secret;return J._revoke(C,U,W,R,H)}if(A)throw v.Log.error("TokenRevocationClient.revoke: Revocation not supported"),new Error("Revocation not supported")}))},u.prototype._revoke=function(R,A,J,H,C){var U=this;return new Promise((function(W,x){var B=new U._XMLHttpRequestCtor;B.open("POST",R),B.onload=function(){v.Log.debug("TokenRevocationClient.revoke: HTTP response received, status",B.status),B.status===200?W():x(Error(B.statusText+" ("+B.status+")"))},B.onerror=function(){v.Log.debug("TokenRevocationClient.revoke: Network Error."),x("Network Error")};var T="client_id="+encodeURIComponent(A);J&&(T+="&client_secret="+encodeURIComponent(J)),T+="&token_type_hint="+encodeURIComponent(C),T+="&token="+encodeURIComponent(H),B.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),B.send(T)}))},u})()},function(c,s,p){Object.defineProperty(s,"__esModule",{value:!0}),s.CordovaPopupWindow=void 0;var v=(function(){function b(w,l){for(var h=0;h<l.length;h++){var u=l[h];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(w,u.key,u)}}return function(w,l,h){return l&&b(w.prototype,l),h&&b(w,h),w}})(),d=p(0);s.CordovaPopupWindow=(function(){function b(w){var l=this;(function(u,S){if(!(u instanceof S))throw new TypeError("Cannot call a class as a function")})(this,b),this._promise=new Promise((function(h,u){l._resolve=h,l._reject=u})),this.features=w.popupWindowFeatures||"location=no,toolbar=no,zoom=no",this.target=w.popupWindowTarget||"_blank",this.redirect_uri=w.startUrl,d.Log.debug("CordovaPopupWindow.ctor: redirect_uri: "+this.redirect_uri)}return b.prototype._isInAppBrowserInstalled=function(l){return["cordova-plugin-inappbrowser","cordova-plugin-inappbrowser.inappbrowser","org.apache.cordova.inappbrowser"].some((function(h){return l.hasOwnProperty(h)}))},b.prototype.navigate=function(l){if(l&&l.url){if(!window.cordova)return this._error("cordova is undefined");var h=window.cordova.require("cordova/plugin_list").metadata;if(this._isInAppBrowserInstalled(h)===!1)return this._error("InAppBrowser plugin not found");this._popup=cordova.InAppBrowser.open(l.url,this.target,this.features),this._popup?(d.Log.debug("CordovaPopupWindow.navigate: popup successfully created"),this._exitCallbackEvent=this._exitCallback.bind(this),this._loadStartCallbackEvent=this._loadStartCallback.bind(this),this._popup.addEventListener("exit",this._exitCallbackEvent,!1),this._popup.addEventListener("loadstart",this._loadStartCallbackEvent,!1)):this._error("Error opening popup window")}else this._error("No url provided");return this.promise},b.prototype._loadStartCallback=function(l){l.url.indexOf(this.redirect_uri)===0&&this._success({url:l.url})},b.prototype._exitCallback=function(l){this._error(l)},b.prototype._success=function(l){this._cleanup(),d.Log.debug("CordovaPopupWindow: Successful response from cordova popup window"),this._resolve(l)},b.prototype._error=function(l){this._cleanup(),d.Log.error(l),this._reject(new Error(l))},b.prototype.close=function(){this._cleanup()},b.prototype._cleanup=function(){this._popup&&(d.Log.debug("CordovaPopupWindow: cleaning up popup"),this._popup.removeEventListener("exit",this._exitCallbackEvent,!1),this._popup.removeEventListener("loadstart",this._loadStartCallbackEvent,!1),this._popup.close()),this._popup=null},v(b,[{key:"promise",get:function(){return this._promise}}]),b})()},function(c,s,p){Object.defineProperty(s,"__esModule",{value:!0});var v=p(0),d=p(10),b=p(5),w=p(6),l=p(37),h=p(38),u=p(16),S=p(2),R=p(48),A=p(49),J=p(19),H=p(20),C=p(18),U=p(1),W=p(15),x=p(50);s.default={Version:x.Version,Log:v.Log,OidcClient:d.OidcClient,OidcClientSettings:b.OidcClientSettings,WebStorageStateStore:w.WebStorageStateStore,InMemoryWebStorage:l.InMemoryWebStorage,UserManager:h.UserManager,AccessTokenEvents:u.AccessTokenEvents,MetadataService:S.MetadataService,CordovaPopupNavigator:R.CordovaPopupNavigator,CordovaIFrameNavigator:A.CordovaIFrameNavigator,CheckSessionIFrame:J.CheckSessionIFrame,TokenRevocationClient:H.TokenRevocationClient,SessionMonitor:C.SessionMonitor,Global:U.Global,User:W.User},c.exports=s.default},function(c,s,p){Object.defineProperty(s,"__esModule",{value:!0}),s.ClockService=(function(){function v(){(function(b,w){if(!(b instanceof w))throw new TypeError("Cannot call a class as a function")})(this,v)}return v.prototype.getEpochTime=function(){return Promise.resolve(Date.now()/1e3|0)},v})()},function(c,s,p){Object.defineProperty(s,"__esModule",{value:!0}),s.ResponseValidator=void 0;var v=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(A){return typeof A}:function(A){return A&&typeof Symbol=="function"&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A},d=p(0),b=p(2),w=p(25),l=p(11),h=p(12),u=p(4);function S(A,J){if(!(A instanceof J))throw new TypeError("Cannot call a class as a function")}var R=["nonce","at_hash","iat","nbf","exp","aud","iss","c_hash"];s.ResponseValidator=(function(){function A(J){var H=arguments.length>1&&arguments[1]!==void 0?arguments[1]:b.MetadataService,C=arguments.length>2&&arguments[2]!==void 0?arguments[2]:w.UserInfoService,U=arguments.length>3&&arguments[3]!==void 0?arguments[3]:u.JoseUtil,W=arguments.length>4&&arguments[4]!==void 0?arguments[4]:l.TokenClient;if(S(this,A),!J)throw d.Log.error("ResponseValidator.ctor: No settings passed to ResponseValidator"),new Error("settings");this._settings=J,this._metadataService=new H(this._settings),this._userInfoService=new C(this._settings),this._joseUtil=U,this._tokenClient=new W(this._settings)}return A.prototype.validateSigninResponse=function(H,C){var U=this;return d.Log.debug("ResponseValidator.validateSigninResponse"),this._processSigninParams(H,C).then((function(W){return d.Log.debug("ResponseValidator.validateSigninResponse: state processed"),U._validateTokens(H,W).then((function(x){return d.Log.debug("ResponseValidator.validateSigninResponse: tokens validated"),U._processClaims(H,x).then((function(B){return d.Log.debug("ResponseValidator.validateSigninResponse: claims processed"),B}))}))}))},A.prototype.validateSignoutResponse=function(H,C){return H.id!==C.state?(d.Log.error("ResponseValidator.validateSignoutResponse: State does not match"),Promise.reject(new Error("State does not match"))):(d.Log.debug("ResponseValidator.validateSignoutResponse: state validated"),C.state=H.data,C.error?(d.Log.warn("ResponseValidator.validateSignoutResponse: Response was error",C.error),Promise.reject(new h.ErrorResponse(C))):Promise.resolve(C))},A.prototype._processSigninParams=function(H,C){if(H.id!==C.state)return d.Log.error("ResponseValidator._processSigninParams: State does not match"),Promise.reject(new Error("State does not match"));if(!H.client_id)return d.Log.error("ResponseValidator._processSigninParams: No client_id on state"),Promise.reject(new Error("No client_id on state"));if(!H.authority)return d.Log.error("ResponseValidator._processSigninParams: No authority on state"),Promise.reject(new Error("No authority on state"));if(this._settings.authority){if(this._settings.authority&&this._settings.authority!==H.authority)return d.Log.error("ResponseValidator._processSigninParams: authority mismatch on settings vs. signin state"),Promise.reject(new Error("authority mismatch on settings vs. signin state"))}else this._settings.authority=H.authority;if(this._settings.client_id){if(this._settings.client_id&&this._settings.client_id!==H.client_id)return d.Log.error("ResponseValidator._processSigninParams: client_id mismatch on settings vs. signin state"),Promise.reject(new Error("client_id mismatch on settings vs. signin state"))}else this._settings.client_id=H.client_id;return d.Log.debug("ResponseValidator._processSigninParams: state validated"),C.state=H.data,C.error?(d.Log.warn("ResponseValidator._processSigninParams: Response was error",C.error),Promise.reject(new h.ErrorResponse(C))):H.nonce&&!C.id_token?(d.Log.error("ResponseValidator._processSigninParams: Expecting id_token in response"),Promise.reject(new Error("No id_token in response"))):!H.nonce&&C.id_token?(d.Log.error("ResponseValidator._processSigninParams: Not expecting id_token in response"),Promise.reject(new Error("Unexpected id_token in response"))):H.code_verifier&&!C.code?(d.Log.error("ResponseValidator._processSigninParams: Expecting code in response"),Promise.reject(new Error("No code in response"))):!H.code_verifier&&C.code?(d.Log.error("ResponseValidator._processSigninParams: Not expecting code in response"),Promise.reject(new Error("Unexpected code in response"))):(C.scope||(C.scope=H.scope),Promise.resolve(C))},A.prototype._processClaims=function(H,C){var U=this;if(C.isOpenIdConnect){if(d.Log.debug("ResponseValidator._processClaims: response is OIDC, processing claims"),C.profile=this._filterProtocolClaims(C.profile),H.skipUserInfo!==!0&&this._settings.loadUserInfo&&C.access_token)return d.Log.debug("ResponseValidator._processClaims: loading user info"),this._userInfoService.getClaims(C.access_token).then((function(W){return d.Log.debug("ResponseValidator._processClaims: user info claims received from user info endpoint"),W.sub!==C.profile.sub?(d.Log.error("ResponseValidator._processClaims: sub from user info endpoint does not match sub in id_token"),Promise.reject(new Error("sub from user info endpoint does not match sub in id_token"))):(C.profile=U._mergeClaims(C.profile,W),d.Log.debug("ResponseValidator._processClaims: user info claims received, updated profile:",C.profile),C)}));d.Log.debug("ResponseValidator._processClaims: not loading user info")}else d.Log.debug("ResponseValidator._processClaims: response is not OIDC, not processing claims");return Promise.resolve(C)},A.prototype._mergeClaims=function(H,C){var U=Object.assign({},H);for(var W in C){var x=C[W];Array.isArray(x)||(x=[x]);for(var B=0;B<x.length;B++){var T=x[B];U[W]?Array.isArray(U[W])?U[W].indexOf(T)<0&&U[W].push(T):U[W]!==T&&((T===void 0?"undefined":v(T))==="object"&&this._settings.mergeClaims?U[W]=this._mergeClaims(U[W],T):U[W]=[U[W],T]):U[W]=T}}return U},A.prototype._filterProtocolClaims=function(H){d.Log.debug("ResponseValidator._filterProtocolClaims, incoming claims:",H);var C=Object.assign({},H);return this._settings._filterProtocolClaims?(R.forEach((function(U){delete C[U]})),d.Log.debug("ResponseValidator._filterProtocolClaims: protocol claims filtered",C)):d.Log.debug("ResponseValidator._filterProtocolClaims: protocol claims not filtered"),C},A.prototype._validateTokens=function(H,C){return C.code?(d.Log.debug("ResponseValidator._validateTokens: Validating code"),this._processCode(H,C)):C.id_token?C.access_token?(d.Log.debug("ResponseValidator._validateTokens: Validating id_token and access_token"),this._validateIdTokenAndAccessToken(H,C)):(d.Log.debug("ResponseValidator._validateTokens: Validating id_token"),this._validateIdToken(H,C)):(d.Log.debug("ResponseValidator._validateTokens: No code to process or id_token to validate"),Promise.resolve(C))},A.prototype._processCode=function(H,C){var U=this,W={client_id:H.client_id,client_secret:H.client_secret,code:C.code,redirect_uri:H.redirect_uri,code_verifier:H.code_verifier};return H.extraTokenParams&&v(H.extraTokenParams)==="object"&&Object.assign(W,H.extraTokenParams),this._tokenClient.exchangeCode(W).then((function(x){for(var B in x)C[B]=x[B];return C.id_token?(d.Log.debug("ResponseValidator._processCode: token response successful, processing id_token"),U._validateIdTokenAttributes(H,C)):(d.Log.debug("ResponseValidator._processCode: token response successful, returning response"),C)}))},A.prototype._validateIdTokenAttributes=function(H,C){var U=this;return this._metadataService.getIssuer().then((function(W){var x=H.client_id,B=U._settings.clockSkew;return d.Log.debug("ResponseValidator._validateIdTokenAttributes: Validaing JWT attributes; using clock skew (in seconds) of: ",B),U._settings.getEpochTime().then((function(T){return U._joseUtil.validateJwtAttributes(C.id_token,W,x,B,T).then((function(I){return H.nonce&&H.nonce!==I.nonce?(d.Log.error("ResponseValidator._validateIdTokenAttributes: Invalid nonce in id_token"),Promise.reject(new Error("Invalid nonce in id_token"))):I.sub?(C.profile=I,C):(d.Log.error("ResponseValidator._validateIdTokenAttributes: No sub present in id_token"),Promise.reject(new Error("No sub present in id_token")))}))}))}))},A.prototype._validateIdTokenAndAccessToken=function(H,C){var U=this;return this._validateIdToken(H,C).then((function(W){return U._validateAccessToken(W)}))},A.prototype._getSigningKeyForJwt=function(H){var C=this;return this._metadataService.getSigningKeys().then((function(U){var W=H.header.kid;if(!U)return d.Log.error("ResponseValidator._validateIdToken: No signing keys from metadata"),Promise.reject(new Error("No signing keys from metadata"));d.Log.debug("ResponseValidator._validateIdToken: Received signing keys");var x=void 0;if(W)x=U.filter((function(B){return B.kid===W}))[0];else{if((U=C._filterByAlg(U,H.header.alg)).length>1)return d.Log.error("ResponseValidator._validateIdToken: No kid found in id_token and more than one key found in metadata"),Promise.reject(new Error("No kid found in id_token and more than one key found in metadata"));x=U[0]}return Promise.resolve(x)}))},A.prototype._getSigningKeyForJwtWithSingleRetry=function(H){var C=this;return this._getSigningKeyForJwt(H).then((function(U){return U?Promise.resolve(U):(C._metadataService.resetSigningKeys(),C._getSigningKeyForJwt(H))}))},A.prototype._validateIdToken=function(H,C){var U=this;if(!H.nonce)return d.Log.error("ResponseValidator._validateIdToken: No nonce on state"),Promise.reject(new Error("No nonce on state"));var W=this._joseUtil.parseJwt(C.id_token);return W&&W.header&&W.payload?H.nonce!==W.payload.nonce?(d.Log.error("ResponseValidator._validateIdToken: Invalid nonce in id_token"),Promise.reject(new Error("Invalid nonce in id_token"))):this._metadataService.getIssuer().then((function(x){return d.Log.debug("ResponseValidator._validateIdToken: Received issuer"),U._getSigningKeyForJwtWithSingleRetry(W).then((function(B){if(!B)return d.Log.error("ResponseValidator._validateIdToken: No key matching kid or alg found in signing keys"),Promise.reject(new Error("No key matching kid or alg found in signing keys"));var T=H.client_id,I=U._settings.clockSkew;return d.Log.debug("ResponseValidator._validateIdToken: Validaing JWT; using clock skew (in seconds) of: ",I),U._joseUtil.validateJwt(C.id_token,B,x,T,I).then((function(){return d.Log.debug("ResponseValidator._validateIdToken: JWT validation successful"),W.payload.sub?(C.profile=W.payload,C):(d.Log.error("ResponseValidator._validateIdToken: No sub present in id_token"),Promise.reject(new Error("No sub present in id_token")))}))}))})):(d.Log.error("ResponseValidator._validateIdToken: Failed to parse id_token",W),Promise.reject(new Error("Failed to parse id_token")))},A.prototype._filterByAlg=function(H,C){var U=null;if(C.startsWith("RS"))U="RSA";else if(C.startsWith("PS"))U="PS";else{if(!C.startsWith("ES"))return d.Log.debug("ResponseValidator._filterByAlg: alg not supported: ",C),[];U="EC"}return d.Log.debug("ResponseValidator._filterByAlg: Looking for keys that match kty: ",U),H=H.filter((function(W){return W.kty===U})),d.Log.debug("ResponseValidator._filterByAlg: Number of keys that match kty: ",U,H.length),H},A.prototype._validateAccessToken=function(H){if(!H.profile)return d.Log.error("ResponseValidator._validateAccessToken: No profile loaded from id_token"),Promise.reject(new Error("No profile loaded from id_token"));if(!H.profile.at_hash)return d.Log.error("ResponseValidator._validateAccessToken: No at_hash in id_token"),Promise.reject(new Error("No at_hash in id_token"));if(!H.id_token)return d.Log.error("ResponseValidator._validateAccessToken: No id_token"),Promise.reject(new Error("No id_token"));var C=this._joseUtil.parseJwt(H.id_token);if(!C||!C.header)return d.Log.error("ResponseValidator._validateAccessToken: Failed to parse id_token",C),Promise.reject(new Error("Failed to parse id_token"));var U=C.header.alg;if(!U||U.length!==5)return d.Log.error("ResponseValidator._validateAccessToken: Unsupported alg:",U),Promise.reject(new Error("Unsupported alg: "+U));var W=U.substr(2,3);if(!W)return d.Log.error("ResponseValidator._validateAccessToken: Unsupported alg:",U,W),Promise.reject(new Error("Unsupported alg: "+U));if((W=parseInt(W))!==256&&W!==384&&W!==512)return d.Log.error("ResponseValidator._validateAccessToken: Unsupported alg:",U,W),Promise.reject(new Error("Unsupported alg: "+U));var x="sha"+W,B=this._joseUtil.hashString(H.access_token,x);if(!B)return d.Log.error("ResponseValidator._validateAccessToken: access_token hash failed:",x),Promise.reject(new Error("Failed to validate at_hash"));var T=B.substr(0,B.length/2),I=this._joseUtil.hexToBase64Url(T);return I!==H.profile.at_hash?(d.Log.error("ResponseValidator._validateAccessToken: Failed to validate at_hash",I,H.profile.at_hash),Promise.reject(new Error("Failed to validate at_hash"))):(d.Log.debug("ResponseValidator._validateAccessToken: success"),Promise.resolve(H))},A})()},function(c,s,p){Object.defineProperty(s,"__esModule",{value:!0}),s.UserInfoService=void 0;var v=p(7),d=p(2),b=p(0),w=p(4);function l(h,u){if(!(h instanceof u))throw new TypeError("Cannot call a class as a function")}s.UserInfoService=(function(){function h(u){var S=arguments.length>1&&arguments[1]!==void 0?arguments[1]:v.JsonService,R=arguments.length>2&&arguments[2]!==void 0?arguments[2]:d.MetadataService,A=arguments.length>3&&arguments[3]!==void 0?arguments[3]:w.JoseUtil;if(l(this,h),!u)throw b.Log.error("UserInfoService.ctor: No settings passed"),new Error("settings");this._settings=u,this._jsonService=new S(void 0,void 0,this._getClaimsFromJwt.bind(this)),this._metadataService=new R(this._settings),this._joseUtil=A}return h.prototype.getClaims=function(S){var R=this;return S?this._metadataService.getUserInfoEndpoint().then((function(A){return b.Log.debug("UserInfoService.getClaims: received userinfo url",A),R._jsonService.getJson(A,S).then((function(J){return b.Log.debug("UserInfoService.getClaims: claims received",J),J}))})):(b.Log.error("UserInfoService.getClaims: No token passed"),Promise.reject(new Error("A token is required")))},h.prototype._getClaimsFromJwt=function(S){var R=this;try{var A=this._joseUtil.parseJwt(S.responseText);if(!A||!A.header||!A.payload)return b.Log.error("UserInfoService._getClaimsFromJwt: Failed to parse JWT",A),Promise.reject(new Error("Failed to parse id_token"));var J=A.header.kid,H=void 0;switch(this._settings.userInfoJwtIssuer){case"OP":H=this._metadataService.getIssuer();break;case"ANY":H=Promise.resolve(A.payload.iss);break;default:H=Promise.resolve(this._settings.userInfoJwtIssuer)}return H.then((function(C){return b.Log.debug("UserInfoService._getClaimsFromJwt: Received issuer:"+C),R._metadataService.getSigningKeys().then((function(U){if(!U)return b.Log.error("UserInfoService._getClaimsFromJwt: No signing keys from metadata"),Promise.reject(new Error("No signing keys from metadata"));b.Log.debug("UserInfoService._getClaimsFromJwt: Received signing keys");var W=void 0;if(J)W=U.filter((function(T){return T.kid===J}))[0];else{if((U=R._filterByAlg(U,A.header.alg)).length>1)return b.Log.error("UserInfoService._getClaimsFromJwt: No kid found in id_token and more than one key found in metadata"),Promise.reject(new Error("No kid found in id_token and more than one key found in metadata"));W=U[0]}if(!W)return b.Log.error("UserInfoService._getClaimsFromJwt: No key matching kid or alg found in signing keys"),Promise.reject(new Error("No key matching kid or alg found in signing keys"));var x=R._settings.client_id,B=R._settings.clockSkew;return b.Log.debug("UserInfoService._getClaimsFromJwt: Validaing JWT; using clock skew (in seconds) of: ",B),R._joseUtil.validateJwt(S.responseText,W,C,x,B,void 0,!0).then((function(){return b.Log.debug("UserInfoService._getClaimsFromJwt: JWT validation successful"),A.payload}))}))}))}catch(C){return b.Log.error("UserInfoService._getClaimsFromJwt: Error parsing JWT response",C.message),void reject(C)}},h.prototype._filterByAlg=function(S,R){var A=null;if(R.startsWith("RS"))A="RSA";else if(R.startsWith("PS"))A="PS";else{if(!R.startsWith("ES"))return b.Log.debug("UserInfoService._filterByAlg: alg not supported: ",R),[];A="EC"}return b.Log.debug("UserInfoService._filterByAlg: Looking for keys that match kty: ",A),S=S.filter((function(J){return J.kty===A})),b.Log.debug("UserInfoService._filterByAlg: Number of keys that match kty: ",A,S.length),S},h})()},function(c,s,p){Object.defineProperty(s,"__esModule",{value:!0}),s.AllowedSigningAlgs=s.b64tohex=s.hextob64u=s.crypto=s.X509=s.KeyUtil=s.jws=void 0;var v=p(27);s.jws=v.jws,s.KeyUtil=v.KEYUTIL,s.X509=v.X509,s.crypto=v.crypto,s.hextob64u=v.hextob64u,s.b64tohex=v.b64tohex,s.AllowedSigningAlgs=["RS256","RS384","RS512","PS256","PS384","PS512","ES256","ES384","ES512"]},function(c,s,p){(function(v){Object.defineProperty(s,"__esModule",{value:!0});var d,b,w,l,h,u,S,R,A,J,H,C=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},U={},W={},x=x||(d=Math,w=(b={}).lib={},l=w.Base=(function(){function t(){}return{extend:function(r){t.prototype=this;var n=new t;return r&&n.mixIn(r),n.hasOwnProperty("init")||(n.init=function(){n.$super.init.apply(this,arguments)}),n.init.prototype=n,n.$super=this,n},create:function(){var r=this.extend();return r.init.apply(r,arguments),r},init:function(){},mixIn:function(r){for(var n in r)r.hasOwnProperty(n)&&(this[n]=r[n]);r.hasOwnProperty("toString")&&(this.toString=r.toString)},clone:function(){return this.init.prototype.extend(this)}}})(),h=w.WordArray=l.extend({init:function(e,r){e=this.words=e||[],this.sigBytes=r??4*e.length},toString:function(e){return(e||S).stringify(this)},concat:function(e){var r=this.words,n=e.words,a=this.sigBytes,f=e.sigBytes;if(this.clamp(),a%4)for(var _=0;_<f;_++){var P=n[_>>>2]>>>24-_%4*8&255;r[a+_>>>2]|=P<<24-(a+_)%4*8}else for(_=0;_<f;_+=4)r[a+_>>>2]=n[_>>>2];return this.sigBytes+=f,this},clamp:function(){var e=this.words,r=this.sigBytes;e[r>>>2]&=4294967295<<32-r%4*8,e.length=d.ceil(r/4)},clone:function(){var e=l.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var r=[],n=0;n<e;n+=4)r.push(4294967296*d.random()|0);return new h.init(r,e)}}),u=b.enc={},S=u.Hex={stringify:function(e){for(var r=e.words,n=e.sigBytes,a=[],f=0;f<n;f++){var _=r[f>>>2]>>>24-f%4*8&255;a.push((_>>>4).toString(16)),a.push((15&_).toString(16))}return a.join("")},parse:function(e){for(var r=e.length,n=[],a=0;a<r;a+=2)n[a>>>3]|=parseInt(e.substr(a,2),16)<<24-a%8*4;return new h.init(n,r/2)}},R=u.Latin1={stringify:function(e){for(var r=e.words,n=e.sigBytes,a=[],f=0;f<n;f++){var _=r[f>>>2]>>>24-f%4*8&255;a.push(String.fromCharCode(_))}return a.join("")},parse:function(e){for(var r=e.length,n=[],a=0;a<r;a++)n[a>>>2]|=(255&e.charCodeAt(a))<<24-a%4*8;return new h.init(n,r)}},A=u.Utf8={stringify:function(e){try{return decodeURIComponent(escape(R.stringify(e)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(e){return R.parse(unescape(encodeURIComponent(e)))}},J=w.BufferedBlockAlgorithm=l.extend({reset:function(){this._data=new h.init,this._nDataBytes=0},_append:function(e){typeof e=="string"&&(e=A.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(e){var r=this._data,n=r.words,a=r.sigBytes,f=this.blockSize,_=a/(4*f),P=(_=e?d.ceil(_):d.max((0|_)-this._minBufferSize,0))*f,F=d.min(4*P,a);if(P){for(var k=0;k<P;k+=f)this._doProcessBlock(n,k);var D=n.splice(0,P);r.sigBytes-=F}return new h.init(D,F)},clone:function(){var e=l.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),w.Hasher=J.extend({cfg:l.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){J.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(r,n){return new e.init(n).finalize(r)}},_createHmacHelper:function(e){return function(r,n){return new H.HMAC.init(e,n).finalize(r)}}}),H=b.algo={},b);(function(t){var e,r=(e=x).lib,n=r.Base,a=r.WordArray;(e=e.x64={}).Word=n.extend({init:function(_,P){this.high=_,this.low=P}}),e.WordArray=n.extend({init:function(_,P){_=this.words=_||[],this.sigBytes=P??8*_.length},toX32:function(){for(var _=this.words,P=_.length,F=[],k=0;k<P;k++){var D=_[k];F.push(D.high),F.push(D.low)}return a.create(F,this.sigBytes)},clone:function(){for(var _=n.clone.call(this),P=_.words=this.words.slice(0),F=P.length,k=0;k<F;k++)P[k]=P[k].clone();return _}})})(),(function(){var t=x,e=t.lib.WordArray;t.enc.Base64={stringify:function(n){var a=n.words,f=n.sigBytes,_=this._map;n.clamp(),n=[];for(var P=0;P<f;P+=3)for(var F=(a[P>>>2]>>>24-P%4*8&255)<<16|(a[P+1>>>2]>>>24-(P+1)%4*8&255)<<8|a[P+2>>>2]>>>24-(P+2)%4*8&255,k=0;4>k&&P+.75*k<f;k++)n.push(_.charAt(F>>>6*(3-k)&63));if(a=_.charAt(64))for(;n.length%4;)n.push(a);return n.join("")},parse:function(n){var a=n.length,f=this._map;(_=f.charAt(64))&&(_=n.indexOf(_))!=-1&&(a=_);for(var _=[],P=0,F=0;F<a;F++)if(F%4){var k=f.indexOf(n.charAt(F-1))<<F%4*2,D=f.indexOf(n.charAt(F))>>>6-F%4*2;_[P>>>2]|=(k|D)<<24-P%4*8,P++}return e.create(_,P)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}})(),(function(t){for(var e=x,r=(a=e.lib).WordArray,n=a.Hasher,a=e.algo,f=[],_=[],P=function(Z){return 4294967296*(Z-(0|Z))|0},F=2,k=0;64>k;){var D;e:{D=F;for(var O=t.sqrt(D),V=2;V<=O;V++)if(!(D%V)){D=!1;break e}D=!0}D&&(8>k&&(f[k]=P(t.pow(F,.5))),_[k]=P(t.pow(F,1/3)),k++),F++}var z=[];a=a.SHA256=n.extend({_doReset:function(){this._hash=new r.init(f.slice(0))},_doProcessBlock:function(Z,ee){for(var m=this._hash.words,L=m[0],M=m[1],K=m[2],Y=m[3],te=m[4],ue=m[5],oe=m[6],ge=m[7],ae=0;64>ae;ae++){if(16>ae)z[ae]=0|Z[ee+ae];else{var he=z[ae-15],be=z[ae-2];z[ae]=((he<<25|he>>>7)^(he<<14|he>>>18)^he>>>3)+z[ae-7]+((be<<15|be>>>17)^(be<<13|be>>>19)^be>>>10)+z[ae-16]}he=ge+((te<<26|te>>>6)^(te<<21|te>>>11)^(te<<7|te>>>25))+(te&ue^~te&oe)+_[ae]+z[ae],be=((L<<30|L>>>2)^(L<<19|L>>>13)^(L<<10|L>>>22))+(L&M^L&K^M&K),ge=oe,oe=ue,ue=te,te=Y+he|0,Y=K,K=M,M=L,L=he+be|0}m[0]=m[0]+L|0,m[1]=m[1]+M|0,m[2]=m[2]+K|0,m[3]=m[3]+Y|0,m[4]=m[4]+te|0,m[5]=m[5]+ue|0,m[6]=m[6]+oe|0,m[7]=m[7]+ge|0},_doFinalize:function(){var Z=this._data,ee=Z.words,m=8*this._nDataBytes,L=8*Z.sigBytes;return ee[L>>>5]|=128<<24-L%32,ee[14+(L+64>>>9<<4)]=t.floor(m/4294967296),ee[15+(L+64>>>9<<4)]=m,Z.sigBytes=4*ee.length,this._process(),this._hash},clone:function(){var Z=n.clone.call(this);return Z._hash=this._hash.clone(),Z}}),e.SHA256=n._createHelper(a),e.HmacSHA256=n._createHmacHelper(a)})(Math),(function(){function t(){return n.create.apply(n,arguments)}for(var e=x,r=e.lib.Hasher,n=(f=e.x64).Word,a=f.WordArray,f=e.algo,_=[t(1116352408,3609767458),t(1899447441,602891725),t(3049323471,3964484399),t(3921009573,2173295548),t(961987163,4081628472),t(1508970993,3053834265),t(2453635748,2937671579),t(2870763221,3664609560),t(3624381080,2734883394),t(310598401,1164996542),t(607225278,1323610764),t(1426881987,3590304994),t(1925078388,4068182383),t(2162078206,991336113),t(2614888103,633803317),t(3248222580,3479774868),t(3835390401,2666613458),t(4022224774,944711139),t(264347078,2341262773),t(604807628,2007800933),t(770255983,1495990901),t(1249150122,1856431235),t(1555081692,3175218132),t(1996064986,2198950837),t(2554220882,3999719339),t(2821834349,766784016),t(2952996808,2566594879),t(3210313671,3203337956),t(3336571891,1034457026),t(3584528711,2466948901),t(113926993,3758326383),t(338241895,168717936),t(666307205,1188179964),t(773529912,1546045734),t(1294757372,1522805485),t(1396182291,2643833823),t(1695183700,2343527390),t(1986661051,1014477480),t(2177026350,1206759142),t(2456956037,344077627),t(2730485921,1290863460),t(2820302411,3158454273),t(3259730800,3505952657),t(3345764771,106217008),t(3516065817,3606008344),t(3600352804,1432725776),t(4094571909,1467031594),t(275423344,851169720),t(430227734,3100823752),t(506948616,1363258195),t(659060556,3750685593),t(883997877,3785050280),t(958139571,3318307427),t(1322822218,3812723403),t(1537002063,2003034995),t(1747873779,3602036899),t(1955562222,1575990012),t(2024104815,1125592928),t(2227730452,2716904306),t(2361852424,442776044),t(2428436474,593698344),t(2756734187,3733110249),t(3204031479,2999351573),t(3329325298,3815920427),t(3391569614,3928383900),t(3515267271,566280711),t(3940187606,3454069534),t(4118630271,4000239992),t(116418474,1914138554),t(174292421,2731055270),t(289380356,3203993006),t(460393269,320620315),t(685471733,587496836),t(852142971,1086792851),t(1017036298,365543100),t(1126000580,2618297676),t(1288033470,3409855158),t(1501505948,4234509866),t(1607167915,987167468),t(1816402316,1246189591)],P=[],F=0;80>F;F++)P[F]=t();f=f.SHA512=r.extend({_doReset:function(){this._hash=new a.init([new n.init(1779033703,4089235720),new n.init(3144134277,2227873595),new n.init(1013904242,4271175723),new n.init(2773480762,1595750129),new n.init(1359893119,2917565137),new n.init(2600822924,725511199),new n.init(528734635,4215389547),new n.init(1541459225,327033209)])},_doProcessBlock:function(D,O){for(var V=(M=this._hash.words)[0],z=M[1],G=M[2],Z=M[3],ee=M[4],m=M[5],L=M[6],M=M[7],K=V.high,Y=V.low,te=z.high,ue=z.low,oe=G.high,ge=G.low,ae=Z.high,he=Z.low,be=ee.high,Ae=ee.low,Fe=m.high,at=m.low,Ze=L.high,et=L.low,Ce=M.high,Be=M.low,qe=K,tt=Y,Gt=te,Lt=ue,Yt=oe,Nt=ge,Pr=ae,Xt=he,pt=be,dt=Ae,dr=Fe,Qt=at,fr=Ze,Zt=et,Tr=Ce,er=Be,yt=0;80>yt;yt++){var Tt=P[yt];if(16>yt)var xt=Tt.high=0|D[O+2*yt],ke=Tt.low=0|D[O+2*yt+1];else{xt=((ke=(xt=P[yt-15]).high)>>>1|(At=xt.low)<<31)^(ke>>>8|At<<24)^ke>>>7;var At=(At>>>1|ke<<31)^(At>>>8|ke<<24)^(At>>>7|ke<<25),Ot=((ke=(Ot=P[yt-2]).high)>>>19|(Me=Ot.low)<<13)^(ke<<3|Me>>>29)^ke>>>6,Me=(Me>>>19|ke<<13)^(Me<<3|ke>>>29)^(Me>>>6|ke<<26),Ir=(ke=P[yt-7]).high,It=(Rt=P[yt-16]).high,Rt=Rt.low;xt=(xt=(xt=xt+Ir+((ke=At+ke.low)>>>0<At>>>0?1:0))+Ot+((ke=ke+Me)>>>0<Me>>>0?1:0))+It+((ke=ke+Rt)>>>0<Rt>>>0?1:0),Tt.high=xt,Tt.low=ke}Ir=pt&dr^~pt&fr,Rt=dt&Qt^~dt&Zt,Tt=qe&Gt^qe&Yt^Gt&Yt;var Oi=tt&Lt^tt&Nt^Lt&Nt,Hi=(At=(qe>>>28|tt<<4)^(qe<<30|tt>>>2)^(qe<<25|tt>>>7),Ot=(tt>>>28|qe<<4)^(tt<<30|qe>>>2)^(tt<<25|qe>>>7),(Me=_[yt]).high),xn=Me.low;It=Tr+((pt>>>14|dt<<18)^(pt>>>18|dt<<14)^(pt<<23|dt>>>9))+((Me=er+((dt>>>14|pt<<18)^(dt>>>18|pt<<14)^(dt<<23|pt>>>9)))>>>0<er>>>0?1:0),Tr=fr,er=Zt,fr=dr,Zt=Qt,dr=pt,Qt=dt,pt=Pr+(It=(It=(It=It+Ir+((Me=Me+Rt)>>>0<Rt>>>0?1:0))+Hi+((Me=Me+xn)>>>0<xn>>>0?1:0))+xt+((Me=Me+ke)>>>0<ke>>>0?1:0))+((dt=Xt+Me|0)>>>0<Xt>>>0?1:0)|0,Pr=Yt,Xt=Nt,Yt=Gt,Nt=Lt,Gt=qe,Lt=tt,qe=It+(Tt=At+Tt+((ke=Ot+Oi)>>>0<Ot>>>0?1:0))+((tt=Me+ke|0)>>>0<Me>>>0?1:0)|0}Y=V.low=Y+tt,V.high=K+qe+(Y>>>0<tt>>>0?1:0),ue=z.low=ue+Lt,z.high=te+Gt+(ue>>>0<Lt>>>0?1:0),ge=G.low=ge+Nt,G.high=oe+Yt+(ge>>>0<Nt>>>0?1:0),he=Z.low=he+Xt,Z.high=ae+Pr+(he>>>0<Xt>>>0?1:0),Ae=ee.low=Ae+dt,ee.high=be+pt+(Ae>>>0<dt>>>0?1:0),at=m.low=at+Qt,m.high=Fe+dr+(at>>>0<Qt>>>0?1:0),et=L.low=et+Zt,L.high=Ze+fr+(et>>>0<Zt>>>0?1:0),Be=M.low=Be+er,M.high=Ce+Tr+(Be>>>0<er>>>0?1:0)},_doFinalize:function(){var D=this._data,O=D.words,V=8*this._nDataBytes,z=8*D.sigBytes;return O[z>>>5]|=128<<24-z%32,O[30+(z+128>>>10<<5)]=Math.floor(V/4294967296),O[31+(z+128>>>10<<5)]=V,D.sigBytes=4*O.length,this._process(),this._hash.toX32()},clone:function(){var D=r.clone.call(this);return D._hash=this._hash.clone(),D},blockSize:32}),e.SHA512=r._createHelper(f),e.HmacSHA512=r._createHmacHelper(f)})(),(function(){var t=x,e=(a=t.x64).Word,r=a.WordArray,n=(a=t.algo).SHA512,a=a.SHA384=n.extend({_doReset:function(){this._hash=new r.init([new e.init(3418070365,3238371032),new e.init(1654270250,914150663),new e.init(2438529370,812702999),new e.init(355462360,4144912697),new e.init(1731405415,4290775857),new e.init(2394180231,1750603025),new e.init(3675008525,1694076839),new e.init(1203062813,3204075428)])},_doFinalize:function(){var _=n._doFinalize.call(this);return _.sigBytes-=16,_}});t.SHA384=n._createHelper(a),t.HmacSHA384=n._createHmacHelper(a)})();var B,T="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function I(t){var e,r,n="";for(e=0;e+3<=t.length;e+=3)r=parseInt(t.substring(e,e+3),16),n+=T.charAt(r>>6)+T.charAt(63&r);for(e+1==t.length?(r=parseInt(t.substring(e,e+1),16),n+=T.charAt(r<<2)):e+2==t.length&&(r=parseInt(t.substring(e,e+2),16),n+=T.charAt(r>>2)+T.charAt((3&r)<<4)),"=";(3&n.length)>0;)n+="=";return n}function Q(t){var e,r,n,a="",f=0;for(e=0;e<t.length&&t.charAt(e)!="=";++e)(n=T.indexOf(t.charAt(e)))<0||(f==0?(a+=Re(n>>2),r=3&n,f=1):f==1?(a+=Re(r<<2|n>>4),r=15&n,f=2):f==2?(a+=Re(r),a+=Re(n>>2),r=3&n,f=3):(a+=Re(r<<2|n>>4),a+=Re(15&n),f=0));return f==1&&(a+=Re(r<<2)),a}function ne(t){var e,r=Q(t),n=new Array;for(e=0;2*e<r.length;++e)n[e]=parseInt(r.substring(2*e,2*e+2),16);return n}function N(t,e,r){t!=null&&(typeof t=="number"?this.fromNumber(t,e,r):e==null&&typeof t!="string"?this.fromString(t,256):this.fromString(t,e))}function ie(){return new N(null)}U.appName=="Microsoft Internet Explorer"?(N.prototype.am=function(e,r,n,a,f,_){for(var P=32767&r,F=r>>15;--_>=0;){var k=32767&this[e],D=this[e++]>>15,O=F*k+D*P;f=((k=P*k+((32767&O)<<15)+n[a]+(1073741823&f))>>>30)+(O>>>15)+F*D+(f>>>30),n[a++]=1073741823&k}return f},B=30):U.appName!="Netscape"?(N.prototype.am=function(e,r,n,a,f,_){for(;--_>=0;){var P=r*this[e++]+n[a]+f;f=Math.floor(P/67108864),n[a++]=67108863&P}return f},B=26):(N.prototype.am=function(e,r,n,a,f,_){for(var P=16383&r,F=r>>14;--_>=0;){var k=16383&this[e],D=this[e++]>>14,O=F*k+D*P;f=((k=P*k+((16383&O)<<14)+n[a]+f)>>28)+(O>>14)+F*D,n[a++]=268435455&k}return f},B=28),N.prototype.DB=B,N.prototype.DM=(1<<B)-1,N.prototype.DV=1<<B,N.prototype.FV=Math.pow(2,52),N.prototype.F1=52-B,N.prototype.F2=2*B-52;var ye,me,Ve=new Array;for(ye=48,me=0;me<=9;++me)Ve[ye++]=me;for(ye=97,me=10;me<36;++me)Ve[ye++]=me;for(ye=65,me=10;me<36;++me)Ve[ye++]=me;function Re(t){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t)}function Ge(t,e){var r=Ve[t.charCodeAt(e)];return r??-1}function Le(t){var e=ie();return e.fromInt(t),e}function Ye(t){var e,r=1;return(e=t>>>16)!=0&&(t=e,r+=16),(e=t>>8)!=0&&(t=e,r+=8),(e=t>>4)!=0&&(t=e,r+=4),(e=t>>2)!=0&&(t=e,r+=2),(e=t>>1)!=0&&(t=e,r+=1),r}function fe(t){this.m=t}function ve(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function Je(t,e){return t&e}function Xe(t,e){return t|e}function rt(t,e){return t^e}function nt(t,e){return t&~e}function ct(t){if(t==0)return-1;var e=0;return(65535&t)==0&&(t>>=16,e+=16),(255&t)==0&&(t>>=8,e+=8),(15&t)==0&&(t>>=4,e+=4),(3&t)==0&&(t>>=2,e+=2),(1&t)==0&&++e,e}function Et(t){for(var e=0;t!=0;)t&=t-1,++e;return e}function Qe(){}function it(t){return t}function We(t){this.r2=ie(),this.q3=ie(),N.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}fe.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},fe.prototype.revert=function(e){return e},fe.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},fe.prototype.mulTo=function(e,r,n){e.multiplyTo(r,n),this.reduce(n)},fe.prototype.sqrTo=function(e,r){e.squareTo(r),this.reduce(r)},ve.prototype.convert=function(e){var r=ie();return e.abs().dlShiftTo(this.m.t,r),r.divRemTo(this.m,null,r),e.s<0&&r.compareTo(N.ZERO)>0&&this.m.subTo(r,r),r},ve.prototype.revert=function(e){var r=ie();return e.copyTo(r),this.reduce(r),r},ve.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var r=0;r<this.m.t;++r){var n=32767&e[r],a=n*this.mpl+((n*this.mph+(e[r]>>15)*this.mpl&this.um)<<15)&e.DM;for(e[n=r+this.m.t]+=this.m.am(0,a,e,r,0,this.m.t);e[n]>=e.DV;)e[n]-=e.DV,e[++n]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},ve.prototype.mulTo=function(e,r,n){e.multiplyTo(r,n),this.reduce(n)},ve.prototype.sqrTo=function(e,r){e.squareTo(r),this.reduce(r)},N.prototype.copyTo=function(e){for(var r=this.t-1;r>=0;--r)e[r]=this[r];e.t=this.t,e.s=this.s},N.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0},N.prototype.fromString=function(e,r){var n;if(r==16)n=4;else if(r==8)n=3;else if(r==256)n=8;else if(r==2)n=1;else if(r==32)n=5;else{if(r!=4)return void this.fromRadix(e,r);n=2}this.t=0,this.s=0;for(var a=e.length,f=!1,_=0;--a>=0;){var P=n==8?255&e[a]:Ge(e,a);P<0?e.charAt(a)=="-"&&(f=!0):(f=!1,_==0?this[this.t++]=P:_+n>this.DB?(this[this.t-1]|=(P&(1<<this.DB-_)-1)<<_,this[this.t++]=P>>this.DB-_):this[this.t-1]|=P<<_,(_+=n)>=this.DB&&(_-=this.DB))}n==8&&(128&e[0])!=0&&(this.s=-1,_>0&&(this[this.t-1]|=(1<<this.DB-_)-1<<_)),this.clamp(),f&&N.ZERO.subTo(this,this)},N.prototype.clamp=function(){for(var e=this.s&this.DM;this.t>0&&this[this.t-1]==e;)--this.t},N.prototype.dlShiftTo=function(e,r){var n;for(n=this.t-1;n>=0;--n)r[n+e]=this[n];for(n=e-1;n>=0;--n)r[n]=0;r.t=this.t+e,r.s=this.s},N.prototype.drShiftTo=function(e,r){for(var n=e;n<this.t;++n)r[n-e]=this[n];r.t=Math.max(this.t-e,0),r.s=this.s},N.prototype.lShiftTo=function(e,r){var n,a=e%this.DB,f=this.DB-a,_=(1<<f)-1,P=Math.floor(e/this.DB),F=this.s<<a&this.DM;for(n=this.t-1;n>=0;--n)r[n+P+1]=this[n]>>f|F,F=(this[n]&_)<<a;for(n=P-1;n>=0;--n)r[n]=0;r[P]=F,r.t=this.t+P+1,r.s=this.s,r.clamp()},N.prototype.rShiftTo=function(e,r){r.s=this.s;var n=Math.floor(e/this.DB);if(n>=this.t)r.t=0;else{var a=e%this.DB,f=this.DB-a,_=(1<<a)-1;r[0]=this[n]>>a;for(var P=n+1;P<this.t;++P)r[P-n-1]|=(this[P]&_)<<f,r[P-n]=this[P]>>a;a>0&&(r[this.t-n-1]|=(this.s&_)<<f),r.t=this.t-n,r.clamp()}},N.prototype.subTo=function(e,r){for(var n=0,a=0,f=Math.min(e.t,this.t);n<f;)a+=this[n]-e[n],r[n++]=a&this.DM,a>>=this.DB;if(e.t<this.t){for(a-=e.s;n<this.t;)a+=this[n],r[n++]=a&this.DM,a>>=this.DB;a+=this.s}else{for(a+=this.s;n<e.t;)a-=e[n],r[n++]=a&this.DM,a>>=this.DB;a-=e.s}r.s=a<0?-1:0,a<-1?r[n++]=this.DV+a:a>0&&(r[n++]=a),r.t=n,r.clamp()},N.prototype.multiplyTo=function(e,r){var n=this.abs(),a=e.abs(),f=n.t;for(r.t=f+a.t;--f>=0;)r[f]=0;for(f=0;f<a.t;++f)r[f+n.t]=n.am(0,a[f],r,f,0,n.t);r.s=0,r.clamp(),this.s!=e.s&&N.ZERO.subTo(r,r)},N.prototype.squareTo=function(e){for(var r=this.abs(),n=e.t=2*r.t;--n>=0;)e[n]=0;for(n=0;n<r.t-1;++n){var a=r.am(n,r[n],e,2*n,0,1);(e[n+r.t]+=r.am(n+1,2*r[n],e,2*n+1,a,r.t-n-1))>=r.DV&&(e[n+r.t]-=r.DV,e[n+r.t+1]=1)}e.t>0&&(e[e.t-1]+=r.am(n,r[n],e,2*n,0,1)),e.s=0,e.clamp()},N.prototype.divRemTo=function(e,r,n){var a=e.abs();if(!(a.t<=0)){var f=this.abs();if(f.t<a.t)return r?.fromInt(0),void(n!=null&&this.copyTo(n));n==null&&(n=ie());var _=ie(),P=this.s,F=e.s,k=this.DB-Ye(a[a.t-1]);k>0?(a.lShiftTo(k,_),f.lShiftTo(k,n)):(a.copyTo(_),f.copyTo(n));var D=_.t,O=_[D-1];if(O!=0){var V=O*(1<<this.F1)+(D>1?_[D-2]>>this.F2:0),z=this.FV/V,G=(1<<this.F1)/V,Z=1<<this.F2,ee=n.t,m=ee-D,L=r??ie();for(_.dlShiftTo(m,L),n.compareTo(L)>=0&&(n[n.t++]=1,n.subTo(L,n)),N.ONE.dlShiftTo(D,L),L.subTo(_,_);_.t<D;)_[_.t++]=0;for(;--m>=0;){var M=n[--ee]==O?this.DM:Math.floor(n[ee]*z+(n[ee-1]+Z)*G);if((n[ee]+=_.am(0,M,n,m,0,D))<M)for(_.dlShiftTo(m,L),n.subTo(L,n);n[ee]<--M;)n.subTo(L,n)}r!=null&&(n.drShiftTo(D,r),P!=F&&N.ZERO.subTo(r,r)),n.t=D,n.clamp(),k>0&&n.rShiftTo(k,n),P<0&&N.ZERO.subTo(n,n)}}},N.prototype.invDigit=function(){if(this.t<1)return 0;var e=this[0];if((1&e)==0)return 0;var r=3&e;return(r=(r=(r=(r=r*(2-(15&e)*r)&15)*(2-(255&e)*r)&255)*(2-((65535&e)*r&65535))&65535)*(2-e*r%this.DV)%this.DV)>0?this.DV-r:-r},N.prototype.isEven=function(){return(this.t>0?1&this[0]:this.s)==0},N.prototype.exp=function(e,r){if(e>4294967295||e<1)return N.ONE;var n=ie(),a=ie(),f=r.convert(this),_=Ye(e)-1;for(f.copyTo(n);--_>=0;)if(r.sqrTo(n,a),(e&1<<_)>0)r.mulTo(a,f,n);else{var P=n;n=a,a=P}return r.revert(n)},N.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var r;if(e==16)r=4;else if(e==8)r=3;else if(e==2)r=1;else if(e==32)r=5;else{if(e!=4)return this.toRadix(e);r=2}var n,a=(1<<r)-1,f=!1,_="",P=this.t,F=this.DB-P*this.DB%r;if(P-- >0)for(F<this.DB&&(n=this[P]>>F)>0&&(f=!0,_=Re(n));P>=0;)F<r?(n=(this[P]&(1<<F)-1)<<r-F,n|=this[--P]>>(F+=this.DB-r)):(n=this[P]>>(F-=r)&a,F<=0&&(F+=this.DB,--P)),n>0&&(f=!0),f&&(_+=Re(n));return f?_:"0"},N.prototype.negate=function(){var e=ie();return N.ZERO.subTo(this,e),e},N.prototype.abs=function(){return this.s<0?this.negate():this},N.prototype.compareTo=function(e){var r=this.s-e.s;if(r!=0)return r;var n=this.t;if((r=n-e.t)!=0)return this.s<0?-r:r;for(;--n>=0;)if((r=this[n]-e[n])!=0)return r;return 0},N.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+Ye(this[this.t-1]^this.s&this.DM)},N.prototype.mod=function(e){var r=ie();return this.abs().divRemTo(e,null,r),this.s<0&&r.compareTo(N.ZERO)>0&&e.subTo(r,r),r},N.prototype.modPowInt=function(e,r){var n;return n=e<256||r.isEven()?new fe(r):new ve(r),this.exp(e,n)},N.ZERO=Le(0),N.ONE=Le(1),Qe.prototype.convert=it,Qe.prototype.revert=it,Qe.prototype.mulTo=function(e,r,n){e.multiplyTo(r,n)},Qe.prototype.sqrTo=function(e,r){e.squareTo(r)},We.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var r=ie();return e.copyTo(r),this.reduce(r),r},We.prototype.revert=function(e){return e},We.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},We.prototype.mulTo=function(e,r,n){e.multiplyTo(r,n),this.reduce(n)},We.prototype.sqrTo=function(e,r){e.squareTo(r),this.reduce(r)};var xe=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],q=(1<<26)/xe[xe.length-1];function g(){this.i=0,this.j=0,this.S=new Array}N.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},N.prototype.toRadix=function(e){if(e==null&&(e=10),this.signum()==0||e<2||e>36)return"0";var r=this.chunkSize(e),n=Math.pow(e,r),a=Le(n),f=ie(),_=ie(),P="";for(this.divRemTo(a,f,_);f.signum()>0;)P=(n+_.intValue()).toString(e).substr(1)+P,f.divRemTo(a,f,_);return _.intValue().toString(e)+P},N.prototype.fromRadix=function(e,r){this.fromInt(0),r==null&&(r=10);for(var n=this.chunkSize(r),a=Math.pow(r,n),f=!1,_=0,P=0,F=0;F<e.length;++F){var k=Ge(e,F);k<0?e.charAt(F)=="-"&&this.signum()==0&&(f=!0):(P=r*P+k,++_>=n&&(this.dMultiply(a),this.dAddOffset(P,0),_=0,P=0))}_>0&&(this.dMultiply(Math.pow(r,_)),this.dAddOffset(P,0)),f&&N.ZERO.subTo(this,this)},N.prototype.fromNumber=function(e,r,n){if(typeof r=="number")if(e<2)this.fromInt(1);else for(this.fromNumber(e,n),this.testBit(e-1)||this.bitwiseTo(N.ONE.shiftLeft(e-1),Xe,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(r);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(N.ONE.shiftLeft(e-1),this);else{var a=new Array,f=7&e;a.length=1+(e>>3),r.nextBytes(a),f>0?a[0]&=(1<<f)-1:a[0]=0,this.fromString(a,256)}},N.prototype.bitwiseTo=function(e,r,n){var a,f,_=Math.min(e.t,this.t);for(a=0;a<_;++a)n[a]=r(this[a],e[a]);if(e.t<this.t){for(f=e.s&this.DM,a=_;a<this.t;++a)n[a]=r(this[a],f);n.t=this.t}else{for(f=this.s&this.DM,a=_;a<e.t;++a)n[a]=r(f,e[a]);n.t=e.t}n.s=r(this.s,e.s),n.clamp()},N.prototype.changeBit=function(e,r){var n=N.ONE.shiftLeft(e);return this.bitwiseTo(n,r,n),n},N.prototype.addTo=function(e,r){for(var n=0,a=0,f=Math.min(e.t,this.t);n<f;)a+=this[n]+e[n],r[n++]=a&this.DM,a>>=this.DB;if(e.t<this.t){for(a+=e.s;n<this.t;)a+=this[n],r[n++]=a&this.DM,a>>=this.DB;a+=this.s}else{for(a+=this.s;n<e.t;)a+=e[n],r[n++]=a&this.DM,a>>=this.DB;a+=e.s}r.s=a<0?-1:0,a>0?r[n++]=a:a<-1&&(r[n++]=this.DV+a),r.t=n,r.clamp()},N.prototype.dMultiply=function(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},N.prototype.dAddOffset=function(e,r){if(e!=0){for(;this.t<=r;)this[this.t++]=0;for(this[r]+=e;this[r]>=this.DV;)this[r]-=this.DV,++r>=this.t&&(this[this.t++]=0),++this[r]}},N.prototype.multiplyLowerTo=function(e,r,n){var a,f=Math.min(this.t+e.t,r);for(n.s=0,n.t=f;f>0;)n[--f]=0;for(a=n.t-this.t;f<a;++f)n[f+this.t]=this.am(0,e[f],n,f,0,this.t);for(a=Math.min(e.t,r);f<a;++f)this.am(0,e[f],n,f,0,r-f);n.clamp()},N.prototype.multiplyUpperTo=function(e,r,n){--r;var a=n.t=this.t+e.t-r;for(n.s=0;--a>=0;)n[a]=0;for(a=Math.max(r-this.t,0);a<e.t;++a)n[this.t+a-r]=this.am(r-a,e[a],n,0,0,this.t+a-r);n.clamp(),n.drShiftTo(1,n)},N.prototype.modInt=function(e){if(e<=0)return 0;var r=this.DV%e,n=this.s<0?e-1:0;if(this.t>0)if(r==0)n=this[0]%e;else for(var a=this.t-1;a>=0;--a)n=(r*n+this[a])%e;return n},N.prototype.millerRabin=function(e){var r=this.subtract(N.ONE),n=r.getLowestSetBit();if(n<=0)return!1;var a=r.shiftRight(n);(e=e+1>>1)>xe.length&&(e=xe.length);for(var f=ie(),_=0;_<e;++_){f.fromInt(xe[Math.floor(Math.random()*xe.length)]);var P=f.modPow(a,this);if(P.compareTo(N.ONE)!=0&&P.compareTo(r)!=0){for(var F=1;F++<n&&P.compareTo(r)!=0;)if((P=P.modPowInt(2,this)).compareTo(N.ONE)==0)return!1;if(P.compareTo(r)!=0)return!1}}return!0},N.prototype.clone=function(){var e=ie();return this.copyTo(e),e},N.prototype.intValue=function(){if(this.s<0){if(this.t==1)return this[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this[0];if(this.t==0)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},N.prototype.byteValue=function(){return this.t==0?this.s:this[0]<<24>>24},N.prototype.shortValue=function(){return this.t==0?this.s:this[0]<<16>>16},N.prototype.signum=function(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1},N.prototype.toByteArray=function(){var e=this.t,r=new Array;r[0]=this.s;var n,a=this.DB-e*this.DB%8,f=0;if(e-- >0)for(a<this.DB&&(n=this[e]>>a)!=(this.s&this.DM)>>a&&(r[f++]=n|this.s<<this.DB-a);e>=0;)a<8?(n=(this[e]&(1<<a)-1)<<8-a,n|=this[--e]>>(a+=this.DB-8)):(n=this[e]>>(a-=8)&255,a<=0&&(a+=this.DB,--e)),(128&n)!=0&&(n|=-256),f==0&&(128&this.s)!=(128&n)&&++f,(f>0||n!=this.s)&&(r[f++]=n);return r},N.prototype.equals=function(e){return this.compareTo(e)==0},N.prototype.min=function(e){return this.compareTo(e)<0?this:e},N.prototype.max=function(e){return this.compareTo(e)>0?this:e},N.prototype.and=function(e){var r=ie();return this.bitwiseTo(e,Je,r),r},N.prototype.or=function(e){var r=ie();return this.bitwiseTo(e,Xe,r),r},N.prototype.xor=function(e){var r=ie();return this.bitwiseTo(e,rt,r),r},N.prototype.andNot=function(e){var r=ie();return this.bitwiseTo(e,nt,r),r},N.prototype.not=function(){for(var e=ie(),r=0;r<this.t;++r)e[r]=this.DM&~this[r];return e.t=this.t,e.s=~this.s,e},N.prototype.shiftLeft=function(e){var r=ie();return e<0?this.rShiftTo(-e,r):this.lShiftTo(e,r),r},N.prototype.shiftRight=function(e){var r=ie();return e<0?this.lShiftTo(-e,r):this.rShiftTo(e,r),r},N.prototype.getLowestSetBit=function(){for(var e=0;e<this.t;++e)if(this[e]!=0)return e*this.DB+ct(this[e]);return this.s<0?this.t*this.DB:-1},N.prototype.bitCount=function(){for(var e=0,r=this.s&this.DM,n=0;n<this.t;++n)e+=Et(this[n]^r);return e},N.prototype.testBit=function(e){var r=Math.floor(e/this.DB);return r>=this.t?this.s!=0:(this[r]&1<<e%this.DB)!=0},N.prototype.setBit=function(e){return this.changeBit(e,Xe)},N.prototype.clearBit=function(e){return this.changeBit(e,nt)},N.prototype.flipBit=function(e){return this.changeBit(e,rt)},N.prototype.add=function(e){var r=ie();return this.addTo(e,r),r},N.prototype.subtract=function(e){var r=ie();return this.subTo(e,r),r},N.prototype.multiply=function(e){var r=ie();return this.multiplyTo(e,r),r},N.prototype.divide=function(e){var r=ie();return this.divRemTo(e,r,null),r},N.prototype.remainder=function(e){var r=ie();return this.divRemTo(e,null,r),r},N.prototype.divideAndRemainder=function(e){var r=ie(),n=ie();return this.divRemTo(e,r,n),new Array(r,n)},N.prototype.modPow=function(e,r){var n,a,f=e.bitLength(),_=Le(1);if(f<=0)return _;n=f<18?1:f<48?3:f<144?4:f<768?5:6,a=f<8?new fe(r):r.isEven()?new We(r):new ve(r);var P=new Array,F=3,k=n-1,D=(1<<n)-1;if(P[1]=a.convert(this),n>1){var O=ie();for(a.sqrTo(P[1],O);F<=D;)P[F]=ie(),a.mulTo(O,P[F-2],P[F]),F+=2}var V,z,G=e.t-1,Z=!0,ee=ie();for(f=Ye(e[G])-1;G>=0;){for(f>=k?V=e[G]>>f-k&D:(V=(e[G]&(1<<f+1)-1)<<k-f,G>0&&(V|=e[G-1]>>this.DB+f-k)),F=n;(1&V)==0;)V>>=1,--F;if((f-=F)<0&&(f+=this.DB,--G),Z)P[V].copyTo(_),Z=!1;else{for(;F>1;)a.sqrTo(_,ee),a.sqrTo(ee,_),F-=2;F>0?a.sqrTo(_,ee):(z=_,_=ee,ee=z),a.mulTo(ee,P[V],_)}for(;G>=0&&(e[G]&1<<f)==0;)a.sqrTo(_,ee),z=_,_=ee,ee=z,--f<0&&(f=this.DB-1,--G)}return a.revert(_)},N.prototype.modInverse=function(e){var r=e.isEven();if(this.isEven()&&r||e.signum()==0)return N.ZERO;for(var n=e.clone(),a=this.clone(),f=Le(1),_=Le(0),P=Le(0),F=Le(1);n.signum()!=0;){for(;n.isEven();)n.rShiftTo(1,n),r?(f.isEven()&&_.isEven()||(f.addTo(this,f),_.subTo(e,_)),f.rShiftTo(1,f)):_.isEven()||_.subTo(e,_),_.rShiftTo(1,_);for(;a.isEven();)a.rShiftTo(1,a),r?(P.isEven()&&F.isEven()||(P.addTo(this,P),F.subTo(e,F)),P.rShiftTo(1,P)):F.isEven()||F.subTo(e,F),F.rShiftTo(1,F);n.compareTo(a)>=0?(n.subTo(a,n),r&&f.subTo(P,f),_.subTo(F,_)):(a.subTo(n,a),r&&P.subTo(f,P),F.subTo(_,F))}return a.compareTo(N.ONE)!=0?N.ZERO:F.compareTo(e)>=0?F.subtract(e):F.signum()<0?(F.addTo(e,F),F.signum()<0?F.add(e):F):F},N.prototype.pow=function(e){return this.exp(e,new Qe)},N.prototype.gcd=function(e){var r=this.s<0?this.negate():this.clone(),n=e.s<0?e.negate():e.clone();if(r.compareTo(n)<0){var a=r;r=n,n=a}var f=r.getLowestSetBit(),_=n.getLowestSetBit();if(_<0)return r;for(f<_&&(_=f),_>0&&(r.rShiftTo(_,r),n.rShiftTo(_,n));r.signum()>0;)(f=r.getLowestSetBit())>0&&r.rShiftTo(f,r),(f=n.getLowestSetBit())>0&&n.rShiftTo(f,n),r.compareTo(n)>=0?(r.subTo(n,r),r.rShiftTo(1,r)):(n.subTo(r,n),n.rShiftTo(1,n));return _>0&&n.lShiftTo(_,n),n},N.prototype.isProbablePrime=function(e){var r,n=this.abs();if(n.t==1&&n[0]<=xe[xe.length-1]){for(r=0;r<xe.length;++r)if(n[0]==xe[r])return!0;return!1}if(n.isEven())return!1;for(r=1;r<xe.length;){for(var a=xe[r],f=r+1;f<xe.length&&a<q;)a*=xe[f++];for(a=n.modInt(a);r<f;)if(a%xe[r++]==0)return!1}return n.millerRabin(e)},N.prototype.square=function(){var e=ie();return this.squareTo(e),e},g.prototype.init=function(e){var r,n,a;for(r=0;r<256;++r)this.S[r]=r;for(n=0,r=0;r<256;++r)n=n+this.S[r]+e[r%e.length]&255,a=this.S[r],this.S[r]=this.S[n],this.S[n]=a;this.i=0,this.j=0},g.prototype.next=function(){var e;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,e=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=e,this.S[e+this.S[this.i]&255]};var y,j,$;function X(){(function(e){j[$++]^=255&e,j[$++]^=e>>8&255,j[$++]^=e>>16&255,j[$++]^=e>>24&255,$>=256&&($-=256)})(new Date().getTime())}if(j==null){var re;if(j=new Array,$=0,W!==void 0&&(W.crypto!==void 0||W.msCrypto!==void 0)){var ce=W.crypto||W.msCrypto;if(ce.getRandomValues){var de=new Uint8Array(32);for(ce.getRandomValues(de),re=0;re<32;++re)j[$++]=de[re]}else if(U.appName=="Netscape"&&U.appVersion<"5"){var we=W.crypto.random(32);for(re=0;re<we.length;++re)j[$++]=255&we.charCodeAt(re)}}for(;$<256;)re=Math.floor(65536*Math.random()),j[$++]=re>>>8,j[$++]=255&re;$=0,X()}function _e(){if(y==null){for(X(),(y=(function(){return new g})()).init(j),$=0;$<j.length;++$)j[$]=0;$=0}return y.next()}function Se(){}function ot(t,e){return new N(t,e)}function ft(t,e,r){for(var n="",a=0;n.length<e;)n+=r(String.fromCharCode.apply(String,t.concat([(4278190080&a)>>24,(16711680&a)>>16,(65280&a)>>8,255&a]))),a+=1;return n}function le(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function Pe(t,e){this.x=e,this.q=t}function pe(t,e,r,n){this.curve=t,this.x=e,this.y=r,this.z=n??N.ONE,this.zinv=null}function lt(t,e,r){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(r),this.infinity=new pe(this,null,null)}Se.prototype.nextBytes=function(e){var r;for(r=0;r<e.length;++r)e[r]=_e()},le.prototype.doPublic=function(e){return e.modPowInt(this.e,this.n)},le.prototype.setPublic=function(e,r){if(this.isPublic=!0,this.isPrivate=!1,typeof e!="string")this.n=e,this.e=r;else{if(!(e!=null&&r!=null&&e.length>0&&r.length>0))throw"Invalid RSA public key";this.n=ot(e,16),this.e=parseInt(r,16)}},le.prototype.encrypt=function(e){var r=(function(_,P){if(P<_.length+11)throw"Message too long for RSA";for(var F=new Array,k=_.length-1;k>=0&&P>0;){var D=_.charCodeAt(k--);D<128?F[--P]=D:D>127&&D<2048?(F[--P]=63&D|128,F[--P]=D>>6|192):(F[--P]=63&D|128,F[--P]=D>>6&63|128,F[--P]=D>>12|224)}F[--P]=0;for(var O=new Se,V=new Array;P>2;){for(V[0]=0;V[0]==0;)O.nextBytes(V);F[--P]=V[0]}return F[--P]=2,F[--P]=0,new N(F)})(e,this.n.bitLength()+7>>3);if(r==null)return null;var n=this.doPublic(r);if(n==null)return null;var a=n.toString(16);return(1&a.length)==0?a:"0"+a},le.prototype.encryptOAEP=function(e,r,n){var a=(function(F,k,D,O){var V=E.crypto.MessageDigest,z=E.crypto.Util,G=null;if(D||(D="sha1"),typeof D=="string"&&(G=V.getCanonicalAlgName(D),O=V.getHashLength(G),D=function(oe){return ht(z.hashHex(_t(oe),G))}),F.length+2*O+2>k)throw"Message too long for RSA";var Z,ee="";for(Z=0;Z<k-F.length-2*O-2;Z+=1)ee+="\0";var m=D("")+ee+""+F,L=new Array(O);new Se().nextBytes(L);var M=ft(L,m.length,D),K=[];for(Z=0;Z<m.length;Z+=1)K[Z]=m.charCodeAt(Z)^M.charCodeAt(Z);var Y=ft(K,L.length,D),te=[0];for(Z=0;Z<L.length;Z+=1)te[Z+1]=L[Z]^Y.charCodeAt(Z);return new N(te.concat(K))})(e,this.n.bitLength()+7>>3,r,n);if(a==null)return null;var f=this.doPublic(a);if(f==null)return null;var _=f.toString(16);return(1&_.length)==0?_:"0"+_},le.prototype.type="RSA",Pe.prototype.equals=function(e){return e==this||this.q.equals(e.q)&&this.x.equals(e.x)},Pe.prototype.toBigInteger=function(){return this.x},Pe.prototype.negate=function(){return new Pe(this.q,this.x.negate().mod(this.q))},Pe.prototype.add=function(e){return new Pe(this.q,this.x.add(e.toBigInteger()).mod(this.q))},Pe.prototype.subtract=function(e){return new Pe(this.q,this.x.subtract(e.toBigInteger()).mod(this.q))},Pe.prototype.multiply=function(e){return new Pe(this.q,this.x.multiply(e.toBigInteger()).mod(this.q))},Pe.prototype.square=function(){return new Pe(this.q,this.x.square().mod(this.q))},Pe.prototype.divide=function(e){return new Pe(this.q,this.x.multiply(e.toBigInteger().modInverse(this.q)).mod(this.q))},pe.prototype.getX=function(){return this.zinv==null&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))},pe.prototype.getY=function(){return this.zinv==null&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))},pe.prototype.equals=function(e){return e==this||(this.isInfinity()?e.isInfinity():e.isInfinity()?this.isInfinity():!!e.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(e.z)).mod(this.curve.q).equals(N.ZERO)&&e.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(e.z)).mod(this.curve.q).equals(N.ZERO))},pe.prototype.isInfinity=function(){return this.x==null&&this.y==null||this.z.equals(N.ZERO)&&!this.y.toBigInteger().equals(N.ZERO)},pe.prototype.negate=function(){return new pe(this.curve,this.x,this.y.negate(),this.z)},pe.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var r=e.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(e.z)).mod(this.curve.q),n=e.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(e.z)).mod(this.curve.q);if(N.ZERO.equals(n))return N.ZERO.equals(r)?this.twice():this.curve.getInfinity();var a=new N("3"),f=this.x.toBigInteger(),_=this.y.toBigInteger(),P=(e.x.toBigInteger(),e.y.toBigInteger(),n.square()),F=P.multiply(n),k=f.multiply(P),D=r.square().multiply(this.z),O=D.subtract(k.shiftLeft(1)).multiply(e.z).subtract(F).multiply(n).mod(this.curve.q),V=k.multiply(a).multiply(r).subtract(_.multiply(F)).subtract(D.multiply(r)).multiply(e.z).add(r.multiply(F)).mod(this.curve.q),z=F.multiply(this.z).multiply(e.z).mod(this.curve.q);return new pe(this.curve,this.curve.fromBigInteger(O),this.curve.fromBigInteger(V),z)},pe.prototype.twice=function(){if(this.isInfinity())return this;if(this.y.toBigInteger().signum()==0)return this.curve.getInfinity();var e=new N("3"),r=this.x.toBigInteger(),n=this.y.toBigInteger(),a=n.multiply(this.z),f=a.multiply(n).mod(this.curve.q),_=this.curve.a.toBigInteger(),P=r.square().multiply(e);N.ZERO.equals(_)||(P=P.add(this.z.square().multiply(_)));var F=(P=P.mod(this.curve.q)).square().subtract(r.shiftLeft(3).multiply(f)).shiftLeft(1).multiply(a).mod(this.curve.q),k=P.multiply(e).multiply(r).subtract(f.shiftLeft(1)).shiftLeft(2).multiply(f).subtract(P.square().multiply(P)).mod(this.curve.q),D=a.square().multiply(a).shiftLeft(3).mod(this.curve.q);return new pe(this.curve,this.curve.fromBigInteger(F),this.curve.fromBigInteger(k),D)},pe.prototype.multiply=function(e){if(this.isInfinity())return this;if(e.signum()==0)return this.curve.getInfinity();var r,n=e,a=n.multiply(new N("3")),f=this.negate(),_=this,P=this.curve.q.subtract(e),F=P.multiply(new N("3")),k=new pe(this.curve,this.x,this.y),D=k.negate();for(r=a.bitLength()-2;r>0;--r){_=_.twice();var O=a.testBit(r);O!=n.testBit(r)&&(_=_.add(O?this:f))}for(r=F.bitLength()-2;r>0;--r){k=k.twice();var V=F.testBit(r);V!=P.testBit(r)&&(k=k.add(V?k:D))}return _},pe.prototype.multiplyTwo=function(e,r,n){var a;a=e.bitLength()>n.bitLength()?e.bitLength()-1:n.bitLength()-1;for(var f=this.curve.getInfinity(),_=this.add(r);a>=0;)f=f.twice(),e.testBit(a)?f=n.testBit(a)?f.add(_):f.add(this):n.testBit(a)&&(f=f.add(r)),--a;return f},lt.prototype.getQ=function(){return this.q},lt.prototype.getA=function(){return this.a},lt.prototype.getB=function(){return this.b},lt.prototype.equals=function(e){return e==this||this.q.equals(e.q)&&this.a.equals(e.a)&&this.b.equals(e.b)},lt.prototype.getInfinity=function(){return this.infinity},lt.prototype.fromBigInteger=function(e){return new Pe(this.q,e)},lt.prototype.decodePointHex=function(e){switch(parseInt(e.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var r=(e.length-2)/2,n=e.substr(2,r),a=e.substr(r+2,r);return new pe(this,this.fromBigInteger(new N(n,16)),this.fromBigInteger(new N(a,16)));default:return null}},Pe.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},pe.prototype.getEncoded=function(t){var e=function(_,P){var F=_.toByteArrayUnsigned();if(P<F.length)F=F.slice(F.length-P);else for(;P>F.length;)F.unshift(0);return F},r=this.getX().toBigInteger(),n=this.getY().toBigInteger(),a=e(r,32);return t?n.isEven()?a.unshift(2):a.unshift(3):(a.unshift(4),a=a.concat(e(n,32))),a},pe.decodeFrom=function(t,e){e[0];var r=e.length-1,n=e.slice(1,1+r/2),a=e.slice(1+r/2,1+r);n.unshift(0),a.unshift(0);var f=new N(n),_=new N(a);return new pe(t,t.fromBigInteger(f),t.fromBigInteger(_))},pe.decodeFromHex=function(t,e){e.substr(0,2);var r=e.length-2,n=e.substr(2,r/2),a=e.substr(2+r/2,r/2),f=new N(n,16),_=new N(a,16);return new pe(t,t.fromBigInteger(f),t.fromBigInteger(_))},pe.prototype.add2D=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;if(this.x.equals(t.x))return this.y.equals(t.y)?this.twice():this.curve.getInfinity();var e=t.x.subtract(this.x),r=t.y.subtract(this.y).divide(e),n=r.square().subtract(this.x).subtract(t.x),a=r.multiply(this.x.subtract(n)).subtract(this.y);return new pe(this.curve,n,a)},pe.prototype.twice2D=function(){if(this.isInfinity())return this;if(this.y.toBigInteger().signum()==0)return this.curve.getInfinity();var t=this.curve.fromBigInteger(N.valueOf(2)),e=this.curve.fromBigInteger(N.valueOf(3)),r=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(t)),n=r.square().subtract(this.x.multiply(t)),a=r.multiply(this.x.subtract(n)).subtract(this.y);return new pe(this.curve,n,a)},pe.prototype.multiply2D=function(t){if(this.isInfinity())return this;if(t.signum()==0)return this.curve.getInfinity();var e,r=t,n=r.multiply(new N("3")),a=this.negate(),f=this;for(e=n.bitLength()-2;e>0;--e){f=f.twice();var _=n.testBit(e);_!=r.testBit(e)&&(f=f.add2D(_?this:a))}return f},pe.prototype.isOnCurve=function(){var t=this.getX().toBigInteger(),e=this.getY().toBigInteger(),r=this.curve.getA().toBigInteger(),n=this.curve.getB().toBigInteger(),a=this.curve.getQ(),f=e.multiply(e).mod(a),_=t.multiply(t).multiply(t).add(r.multiply(t)).add(n).mod(a);return f.equals(_)},pe.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"},pe.prototype.validate=function(){var t=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var e=this.getX().toBigInteger(),r=this.getY().toBigInteger();if(e.compareTo(N.ONE)<0||e.compareTo(t.subtract(N.ONE))>0)throw new Error("x coordinate out of bounds");if(r.compareTo(N.ONE)<0||r.compareTo(t.subtract(N.ONE))>0)throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(t).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0};var ln=(function(){var t=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)|(?:"(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))*"))',"g"),e=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),r={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:`
3
3
  `,r:"\r",t:" "};function n(_,P,F){return P?r[P]:String.fromCharCode(parseInt(F,16))}var a=new String(""),f=Object.hasOwnProperty;return function(_,P){var F,k,D=_.match(t),O=D[0],V=!1;O==="{"?F={}:O==="["?F=[]:(F=[],V=!0);for(var z=[F],G=1-V,Z=D.length;G<Z;++G){var ee;switch((O=D[G]).charCodeAt(0)){default:(ee=z[0])[k||ee.length]=+O,k=void 0;break;case 34:if((O=O.substring(1,O.length-1)).indexOf("\\")!==-1&&(O=O.replace(e,n)),ee=z[0],!k){if(!(ee instanceof Array)){k=O||a;break}k=ee.length}ee[k]=O,k=void 0;break;case 91:ee=z[0],z.unshift(ee[k||ee.length]=[]),k=void 0;break;case 93:z.shift();break;case 102:(ee=z[0])[k||ee.length]=!1,k=void 0;break;case 110:(ee=z[0])[k||ee.length]=null,k=void 0;break;case 116:(ee=z[0])[k||ee.length]=!0,k=void 0;break;case 123:ee=z[0],z.unshift(ee[k||ee.length]={}),k=void 0;break;case 125:z.shift()}}if(V){if(z.length!==1)throw new Error;F=F[0]}else if(z.length)throw new Error;return P&&(F=(function m(L,M){var K=L[M];if(K&&(K===void 0?"undefined":C(K))==="object"){var Y=null;for(var te in K)if(f.call(K,te)&&K!==L){var ue=m(K,te);ue!==void 0?K[te]=ue:(Y||(Y=[]),Y.push(te))}if(Y)for(var oe=Y.length;--oe>=0;)delete K[Y[oe]]}return P.call(L,M,K)})({"":F},"")),F}})();E!==void 0&&E||(s.KJUR=E={}),E.asn1!==void 0&&E.asn1||(E.asn1={}),E.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if(e.substr(0,1)!="-")e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var r=e.substr(1).length;r%2==1?r+=1:e.match(/^[0-7]/)||(r+=2);for(var n="",a=0;a<r;a++)n+="f";e=new N(n,16).xor(t).add(N.ONE).toString(16).replace(/^-/,"")}return e},this.getPEMStringFromHex=function(t,e){return st(t,e)},this.newObject=function(t){var e=E.asn1,r=e.ASN1Object,n=e.DERBoolean,a=e.DERInteger,f=e.DERBitString,_=e.DEROctetString,P=e.DERNull,F=e.DERObjectIdentifier,k=e.DEREnumerated,D=e.DERUTF8String,O=e.DERNumericString,V=e.DERPrintableString,z=e.DERTeletexString,G=e.DERIA5String,Z=e.DERUTCTime,ee=e.DERGeneralizedTime,m=e.DERVisibleString,L=e.DERBMPString,M=e.DERSequence,K=e.DERSet,Y=e.DERTaggedObject,te=e.ASN1Util.newObject;if(t instanceof e.ASN1Object)return t;var ue=Object.keys(t);if(ue.length!=1)throw new Error("key of param shall be only one.");var oe=ue[0];if(":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+oe+":")==-1)throw new Error("undefined key: "+oe);if(oe=="bool")return new n(t[oe]);if(oe=="int")return new a(t[oe]);if(oe=="bitstr")return new f(t[oe]);if(oe=="octstr")return new _(t[oe]);if(oe=="null")return new P(t[oe]);if(oe=="oid")return new F(t[oe]);if(oe=="enum")return new k(t[oe]);if(oe=="utf8str")return new D(t[oe]);if(oe=="numstr")return new O(t[oe]);if(oe=="prnstr")return new V(t[oe]);if(oe=="telstr")return new z(t[oe]);if(oe=="ia5str")return new G(t[oe]);if(oe=="utctime")return new Z(t[oe]);if(oe=="gentime")return new ee(t[oe]);if(oe=="visstr")return new m(t[oe]);if(oe=="bmpstr")return new L(t[oe]);if(oe=="asn1")return new r(t[oe]);if(oe=="seq"){for(var ge=t[oe],ae=[],he=0;he<ge.length;he++){var be=te(ge[he]);ae.push(be)}return new M({array:ae})}if(oe=="set"){for(ge=t[oe],ae=[],he=0;he<ge.length;he++)be=te(ge[he]),ae.push(be);return new K({array:ae})}if(oe=="tag"){var Ae=t[oe];if(Object.prototype.toString.call(Ae)==="[object Array]"&&Ae.length==3){var Fe=te(Ae[2]);return new Y({tag:Ae[0],explicit:Ae[1],obj:Fe})}return new Y(Ae)}},this.jsonToASN1HEX=function(t){return this.newObject(t).getEncodedHex()}},E.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",r=parseInt(t.substr(0,2),16),n=(e=Math.floor(r/40)+"."+r%40,""),a=2;a<t.length;a+=2){var f=("00000000"+parseInt(t.substr(a,2),16).toString(2)).slice(-8);n+=f.substr(1,7),f.substr(0,1)=="0"&&(e=e+"."+new N(n,2).toString(10),n="")}return e},E.asn1.ASN1Util.oidIntToHex=function(t){var e=function(F){var k=F.toString(16);return k.length==1&&(k="0"+k),k},r=function(F){var k="",D=new N(F,10).toString(2),O=7-D.length%7;O==7&&(O=0);for(var V="",z=0;z<O;z++)V+="0";for(D=V+D,z=0;z<D.length-1;z+=7){var G=D.substr(z,7);z!=D.length-7&&(G="1"+G),k+=e(parseInt(G,2))}return k};if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var n="",a=t.split("."),f=40*parseInt(a[0])+parseInt(a[1]);n+=e(f),a.splice(0,2);for(var _=0;_<a.length;_++)n+=r(a[_]);return n},E.asn1.ASN1Object=function(t){this.params=null,this.getLengthHexFromValue=function(){if(this.hV===void 0||this.hV==null)throw new Error("this.hV is null or undefined");if(this.hV.length%2==1)throw new Error("value hex must be even length: n=0,v="+this.hV);var e=this.hV.length/2,r=e.toString(16);if(r.length%2==1&&(r="0"+r),e<128)return r;var n=r.length/2;if(n>15)throw"ASN.1 length too long to represent by 8x: n = "+e.toString(16);return(128+n).toString(16)+r},this.getEncodedHex=function(){return(this.hTLV==null||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""},this.setByParam=function(e){this.params=e},t!=null&&t.tlv!=null&&(this.hTLV=t.tlv,this.isModified=!1)},E.asn1.DERAbstractString=function(t){E.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(e){this.hTLV=null,this.isModified=!0,this.s=e,this.hV=Fr(this.s).toLowerCase()},this.setStringHex=function(e){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.getFreshValueHex=function(){return this.hV},t!==void 0&&(typeof t=="string"?this.setString(t):t.str!==void 0?this.setString(t.str):t.hex!==void 0&&this.setStringHex(t.hex))},Ie(E.asn1.DERAbstractString,E.asn1.ASN1Object),E.asn1.DERAbstractTime=function(t){E.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(e){var r=e.getTime()+6e4*e.getTimezoneOffset();return new Date(r)},this.formatDate=function(e,r,n){var a=this.zeroPadding,f=this.localDateToUTC(e),_=String(f.getFullYear());r=="utc"&&(_=_.substr(2,2));var P=_+a(String(f.getMonth()+1),2)+a(String(f.getDate()),2)+a(String(f.getHours()),2)+a(String(f.getMinutes()),2)+a(String(f.getSeconds()),2);if(n===!0){var F=f.getMilliseconds();if(F!=0){var k=a(String(F),3);P=P+"."+(k=k.replace(/[0]+$/,""))}}return P+"Z"},this.zeroPadding=function(e,r){return e.length>=r?e:new Array(r-e.length+1).join("0")+e},this.getString=function(){return this.s},this.setString=function(e){this.hTLV=null,this.isModified=!0,this.s=e,this.hV=Ft(e)},this.setByDateValue=function(e,r,n,a,f,_){var P=new Date(Date.UTC(e,r-1,n,a,f,_,0));this.setByDate(P)},this.getFreshValueHex=function(){return this.hV}},Ie(E.asn1.DERAbstractTime,E.asn1.ASN1Object),E.asn1.DERAbstractStructured=function(t){E.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(e){this.hTLV=null,this.isModified=!0,this.asn1Array=e},this.appendASN1Object=function(e){this.hTLV=null,this.isModified=!0,this.asn1Array.push(e)},this.asn1Array=new Array,t!==void 0&&t.array!==void 0&&(this.asn1Array=t.array)},Ie(E.asn1.DERAbstractStructured,E.asn1.ASN1Object),E.asn1.DERBoolean=function(t){E.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV=t==0?"010100":"0101ff"},Ie(E.asn1.DERBoolean,E.asn1.ASN1Object),E.asn1.DERInteger=function(t){E.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(e){this.hTLV=null,this.isModified=!0,this.hV=E.asn1.ASN1Util.bigIntToMinTwosComplementsHex(e)},this.setByInteger=function(e){var r=new N(String(e),10);this.setByBigInteger(r)},this.setValueHex=function(e){this.hV=e},this.getFreshValueHex=function(){return this.hV},t!==void 0&&(t.bigint!==void 0?this.setByBigInteger(t.bigint):t.int!==void 0?this.setByInteger(t.int):typeof t=="number"?this.setByInteger(t):t.hex!==void 0&&this.setValueHex(t.hex))},Ie(E.asn1.DERInteger,E.asn1.ASN1Object),E.asn1.DERBitString=function(t){if(t!==void 0&&t.obj!==void 0){var e=E.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}E.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(r){this.hTLV=null,this.isModified=!0,this.hV=r},this.setUnusedBitsAndHexValue=function(r,n){if(r<0||7<r)throw"unused bits shall be from 0 to 7: u = "+r;var a="0"+r;this.hTLV=null,this.isModified=!0,this.hV=a+n},this.setByBinaryString=function(r){var n=8-(r=r.replace(/0+$/,"")).length%8;n==8&&(n=0);for(var a=0;a<=n;a++)r+="0";var f="";for(a=0;a<r.length-1;a+=8){var _=r.substr(a,8),P=parseInt(_,2).toString(16);P.length==1&&(P="0"+P),f+=P}this.hTLV=null,this.isModified=!0,this.hV="0"+n+f},this.setByBooleanArray=function(r){for(var n="",a=0;a<r.length;a++)r[a]==1?n+="1":n+="0";this.setByBinaryString(n)},this.newFalseArray=function(r){for(var n=new Array(r),a=0;a<r;a++)n[a]=!1;return n},this.getFreshValueHex=function(){return this.hV},t!==void 0&&(typeof t=="string"&&t.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(t):t.hex!==void 0?this.setHexValueIncludingUnusedBits(t.hex):t.bin!==void 0?this.setByBinaryString(t.bin):t.array!==void 0&&this.setByBooleanArray(t.array))},Ie(E.asn1.DERBitString,E.asn1.ASN1Object),E.asn1.DEROctetString=function(t){if(t!==void 0&&t.obj!==void 0){var e=E.asn1.ASN1Util.newObject(t.obj);t.hex=e.getEncodedHex()}E.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},Ie(E.asn1.DEROctetString,E.asn1.DERAbstractString),E.asn1.DERNull=function(){E.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},Ie(E.asn1.DERNull,E.asn1.ASN1Object),E.asn1.DERObjectIdentifier=function(t){E.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(e){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueOidString=function(e){var r=(function(a){var f=function(V){var z=V.toString(16);return z.length==1&&(z="0"+z),z},_=function(V){var z="",G=parseInt(V,10).toString(2),Z=7-G.length%7;Z==7&&(Z=0);for(var ee="",m=0;m<Z;m++)ee+="0";for(G=ee+G,m=0;m<G.length-1;m+=7){var L=G.substr(m,7);m!=G.length-7&&(L="1"+L),z+=f(parseInt(L,2))}return z};try{if(!a.match(/^[0-9.]+$/))return null;var P="",F=a.split("."),k=40*parseInt(F[0],10)+parseInt(F[1],10);P+=f(k),F.splice(0,2);for(var D=0;D<F.length;D++)P+=_(F[D]);return P}catch{return null}})(e);if(r==null)throw new Error("malformed oid string: "+e);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=r},this.setValueName=function(e){var r=E.asn1.x509.OID.name2oid(e);if(r==="")throw new Error("DERObjectIdentifier oidName undefined: "+e);this.setValueOidString(r)},this.setValueNameOrOid=function(e){e.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(e):this.setValueName(e)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(e){typeof e=="string"?this.setValueNameOrOid(e):e.oid!==void 0?this.setValueNameOrOid(e.oid):e.name!==void 0?this.setValueNameOrOid(e.name):e.hex!==void 0&&this.setValueHex(e.hex)},t!==void 0&&this.setByParam(t)},Ie(E.asn1.DERObjectIdentifier,E.asn1.ASN1Object),E.asn1.DEREnumerated=function(t){E.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(e){this.hTLV=null,this.isModified=!0,this.hV=E.asn1.ASN1Util.bigIntToMinTwosComplementsHex(e)},this.setByInteger=function(e){var r=new N(String(e),10);this.setByBigInteger(r)},this.setValueHex=function(e){this.hV=e},this.getFreshValueHex=function(){return this.hV},t!==void 0&&(t.int!==void 0?this.setByInteger(t.int):typeof t=="number"?this.setByInteger(t):t.hex!==void 0&&this.setValueHex(t.hex))},Ie(E.asn1.DEREnumerated,E.asn1.ASN1Object),E.asn1.DERUTF8String=function(t){E.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},Ie(E.asn1.DERUTF8String,E.asn1.DERAbstractString),E.asn1.DERNumericString=function(t){E.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},Ie(E.asn1.DERNumericString,E.asn1.DERAbstractString),E.asn1.DERPrintableString=function(t){E.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},Ie(E.asn1.DERPrintableString,E.asn1.DERAbstractString),E.asn1.DERTeletexString=function(t){E.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},Ie(E.asn1.DERTeletexString,E.asn1.DERAbstractString),E.asn1.DERIA5String=function(t){E.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},Ie(E.asn1.DERIA5String,E.asn1.DERAbstractString),E.asn1.DERVisibleString=function(t){E.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="1a"},Ie(E.asn1.DERVisibleString,E.asn1.DERAbstractString),E.asn1.DERBMPString=function(t){E.asn1.DERBMPString.superclass.constructor.call(this,t),this.hT="1e"},Ie(E.asn1.DERBMPString,E.asn1.DERAbstractString),E.asn1.DERUTCTime=function(t){E.asn1.DERUTCTime.superclass.constructor.call(this,t),this.hT="17",this.setByDate=function(e){this.hTLV=null,this.isModified=!0,this.date=e,this.s=this.formatDate(this.date,"utc"),this.hV=Ft(this.s)},this.getFreshValueHex=function(){return this.date===void 0&&this.s===void 0&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=Ft(this.s)),this.hV},t!==void 0&&(t.str!==void 0?this.setString(t.str):typeof t=="string"&&t.match(/^[0-9]{12}Z$/)?this.setString(t):t.hex!==void 0?this.setStringHex(t.hex):t.date!==void 0&&this.setByDate(t.date))},Ie(E.asn1.DERUTCTime,E.asn1.DERAbstractTime),E.asn1.DERGeneralizedTime=function(t){E.asn1.DERGeneralizedTime.superclass.constructor.call(this,t),this.hT="18",this.withMillis=!1,this.setByDate=function(e){this.hTLV=null,this.isModified=!0,this.date=e,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=Ft(this.s)},this.getFreshValueHex=function(){return this.date===void 0&&this.s===void 0&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=Ft(this.s)),this.hV},t!==void 0&&(t.str!==void 0?this.setString(t.str):typeof t=="string"&&t.match(/^[0-9]{14}Z$/)?this.setString(t):t.hex!==void 0?this.setStringHex(t.hex):t.date!==void 0&&this.setByDate(t.date),t.millis===!0&&(this.withMillis=!0))},Ie(E.asn1.DERGeneralizedTime,E.asn1.DERAbstractTime),E.asn1.DERSequence=function(t){E.asn1.DERSequence.superclass.constructor.call(this,t),this.hT="30",this.getFreshValueHex=function(){for(var e="",r=0;r<this.asn1Array.length;r++)e+=this.asn1Array[r].getEncodedHex();return this.hV=e,this.hV}},Ie(E.asn1.DERSequence,E.asn1.DERAbstractStructured),E.asn1.DERSet=function(t){E.asn1.DERSet.superclass.constructor.call(this,t),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var e=new Array,r=0;r<this.asn1Array.length;r++){var n=this.asn1Array[r];e.push(n.getEncodedHex())}return this.sortFlag==1&&e.sort(),this.hV=e.join(""),this.hV},t!==void 0&&t.sortflag!==void 0&&t.sortflag==0&&(this.sortFlag=!1)},Ie(E.asn1.DERSet,E.asn1.DERAbstractStructured),E.asn1.DERTaggedObject=function(t){E.asn1.DERTaggedObject.superclass.constructor.call(this);var e=E.asn1;this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(r,n,a){this.hT=n,this.isExplicit=r,this.asn1Object=a,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=a.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,n),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(r){r.tag!=null&&(this.hT=r.tag),r.explicit!=null&&(this.isExplicit=r.explicit),r.tage!=null&&(this.hT=r.tage,this.isExplicit=!0),r.tagi!=null&&(this.hT=r.tagi,this.isExplicit=!1),r.obj!=null&&(r.obj instanceof e.ASN1Object?(this.asn1Object=r.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)):C(r.obj)=="object"&&(this.asn1Object=e.ASN1Util.newObject(r.obj),this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},t!=null&&this.setByParam(t)},Ie(E.asn1.DERTaggedObject,E.asn1.ASN1Object);var E,$t,gt,se=new function(){};function hn(t){for(var e=new Array,r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}function dn(t){for(var e="",r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e}function ar(t){for(var e="",r=0;r<t.length;r++){var n=t[r].toString(16);n.length==1&&(n="0"+n),e+=n}return e}function Ft(t){return ar(hn(t))}function ur(t){return t=(t=(t=t.replace(/\=/g,"")).replace(/\+/g,"-")).replace(/\//g,"_")}function zt(t){return t.length%4==2?t+="==":t.length%4==3&&(t+="="),t=(t=t.replace(/-/g,"+")).replace(/_/g,"/")}function Ne(t){return t.length%2==1&&(t="0"+t),ur(I(t))}function Ee(t){return Q(zt(t))}function Fr(t){return cr(hr(t))}function Oe(t){return decodeURIComponent(lr(t))}function ht(t){for(var e="",r=0;r<t.length-1;r+=2)e+=String.fromCharCode(parseInt(t.substr(r,2),16));return e}function _t(t){for(var e="",r=0;r<t.length;r++)e+=("0"+t.charCodeAt(r).toString(16)).slice(-2);return e}function fn(t){return I(t)}function gn(t){var e=fn(t).replace(/(.{64})/g,`$1\r
4
4
  `);return e=e.replace(/\r\n$/,"")}function pn(t){return Q(t.replace(/[^0-9A-Za-z\/+=]*/g,""))}function st(t,e){return"-----BEGIN "+e+`-----\r
@@ -128,4 +128,4 @@ import{g as Bi}from"./_commonjsHelpers-B-UnjaXt.js";const Wt=crypto,zr=o=>o inst
128
128
  <h2>Report</h2>
129
129
  <textarea id="report" readonly></textarea>
130
130
  </section>
131
- `}function pr(o){return o.replace(/[&<>"]/g,i=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[i]??i)}function De(o){return document.getElementById(o)}function mt(o,i=""){const c=De("status");c.textContent=o,c.className=i}function nn(){return De("cloudIssuer").value.trim()}function Kt(){return De("podHomeUrl").value.trim()}function Si(o){De("podHomeUrl").value=qt(o),De("storageHome").textContent=De("podHomeUrl").value}function or(){const o=sn(De("storagePath").value);return De("storagePath").value=o,o}function Vt(){return De("spResourceUrl").value.trim()}function on(o){De("spResourceUrl").value=o}function qt(o){const i=new URL(tn(o||window.location.origin,window.location.origin));return i.hash="",i.search="",i.pathname.endsWith("/")||(i.pathname=`${i.pathname}/`),i.href}function sn(o){const i=String(o||"").trim();if(!i)return _r;if(/^https?:\/\//iu.test(i)){const c=new URL(i);return`${c.pathname.replace(/^\/+/,"")}${c.hash}`||_r}return i.replace(/^\/+/,"")||_r}function bi(o){const i=sn(o),c=i.indexOf("#"),s=c>=0?i.slice(0,c):i,p=c>=0?i.slice(c):"",v=s.lastIndexOf("/"),d=v>=0?s.slice(0,v+1):"",b=v>=0?s.slice(v+1):s;if(!b)throw new Error(`Storage path must include a file name: ${i}`);return{storagePath:i,documentPath:s,tableBase:`/${d}`,recordId:`${b}${p||"#this"}`}}function an(o,i){const c=bi(i);return new URL(c.documentPath,qt(o)).href}function un(){De("loggedIn").textContent=String(Ke.info.isLoggedIn),De("webId").textContent=Ke.info.webId??"-",De("storageHome").textContent=Kt()||"-"}function Dt(o={}){De("report").value=JSON.stringify({generatedAt:new Date().toISOString(),cloudIssuer:nn(),podHomeUrl:Kt(),storagePath:or(),spResourceUrl:Vt(),session:{isLoggedIn:Ke.info.isLoggedIn,webId:Ke.info.webId,sessionId:Ke.info.sessionId},...o},null,2)}async function ca(){const o=qt(nn()),i=new URL("/app/inrupt-smoke.html",window.location.origin);i.searchParams.set("issuer",o),i.searchParams.set("storagePath",or()),Kt()&&i.searchParams.set("home",Kt()),Vt()&&i.searchParams.set("sp",Vt()),await Ke.login({oidcIssuer:o,redirectUrl:i.href,clientName:"Xpod Inrupt Smoke",tokenType:"DPoP"})}async function cn(o){const i=performance.now(),c=tn(o,window.location.origin),s=await Ke.fetch(c,{method:"GET",cache:"no-store"}),p=await s.text();return{url:c,status:s.status,ok:s.ok,elapsedMs:Math.round(performance.now()-i),headers:Array.from(s.headers.entries()),bodyPreview:p.slice(0,8192)}}async function la(){try{mt("checking cloud discovery...","warn");const o=new URL("/.well-known/openid-configuration",qt(nn())).href,i=await cn(o);mt(`discovery HTTP ${i.status}`,i.ok?"ok":"fail"),Dt({discovery:i})}catch(o){sr(o)}}async function Ei(){if(!Ke.info.isLoggedIn||!Ke.info.webId)throw new Error("Login first; storage discovery needs session.info.webId.");const o=Ke.info.webId,i=ya(o),c=await cn(i);if(!c.ok)throw new Error(`Failed to read WebID profile ${i}: HTTP ${c.status}`);const s=qt(ga(o,c.bodyPreview));return Si(s),Vt()||on(an(s,or())),un(),{webId:o,profileUrl:i,storageUrl:s,profile:c}}async function ha(){try{mt("discovering storage home from WebID profile...","warn");const o=await Ei();mt(`storage home ${o.storageUrl}`,"ok"),Dt({storage:o})}catch(o){sr(o)}}async function Fi(){if(Kt()){const o=qt(Kt());return Si(o),o}return(await Ei()).storageUrl}async function da(){if(Vt())return new URL(Vt()).href;const o=await Fi(),i=an(o,or());return on(i),i}async function fa(){try{mt("fetching SP resource with Inrupt session...","warn");const o=await cn(await da());mt(`SP resource HTTP ${o.status}`,o.ok?"ok":"fail"),Dt({spResource:o})}catch(o){sr(o)}}function ga(o,i){const c=pa(i);if(c)return c;const s=[mr,qr].map(h=>h.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&")).join("|"),p=new RegExp(`<(?:${s})>\\s+<([^>]+)>`,"iu"),v=i.match(p);if(v?.[1])return v[1];const d=/\b(?:solid|pim):storage\s+<([^>]+)>/iu,b=i.match(d);if(b?.[1])return b[1];const w=new RegExp(`<${Or(o)}>[^.]+(?:<${Or(mr)}>|solid:storage|<${Or(qr)}>|pim:storage)\\s+<([^>]+)>`,"isu"),l=i.match(w);if(l?.[1])return l[1];throw new Error(`WebID profile has no solid:storage / ${mr} binding.`)}function pa(o){try{return $r(JSON.parse(o))}catch{return null}}function $r(o){if(Array.isArray(o)){for(const i of o){const c=$r(i);if(c)return c}return null}if(!Ai(o))return null;for(const i of Object.keys(o))if(i===mr||i===qr||i==="solid:storage"||i==="pim:storage"){const c=xi(o[i]);if(c)return c}for(const i of Object.values(o)){const c=$r(i);if(c)return c}return null}function xi(o){if(typeof o=="string"&&/^https?:\/\//iu.test(o))return o;if(Array.isArray(o)){for(const i of o){const c=xi(i);if(c)return c}return null}if(Ai(o)){const i=o["@id"];if(typeof i=="string"&&/^https?:\/\//iu.test(i))return i}return null}function Ai(o){return typeof o=="object"&&o!==null}function ya(o){const i=new URL(tn(o,window.location.origin));return i.hash="",i.href}function Or(o){return o.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&")}function va(){return typeof crypto.randomUUID=="function"?crypto.randomUUID():Math.random().toString(36).slice(2)}async function ma(){try{mt("writing smoke data through drizzle-solid...","warn");const o=await Fi(),i=bi(or()),{drizzle:c,podTable:s,string:p}=await ra(async()=>{const{drizzle:S,podTable:R,string:A}=await import("./index-BikOyGPu.js");return{drizzle:S,podTable:R,string:A}},__vite__mapDeps([0,1])),v=s("inruptSmokeData",{id:p("id").primaryKey(),value:p("value").predicate("http://schema.org/text"),createdAt:p("createdAt").predicate("http://schema.org/dateCreated")},{base:i.tableBase,type:na}),d=c(Ke,{podUrl:o,resourcePreparation:"best-effort",schema:{inruptSmokeData:v}});await d.init(v),await d.deleteById(v,i.recordId).catch(()=>{});const b=`xpod-inrupt-smoke ${new Date().toISOString()} ${va()}`,w=new Date().toISOString();await d.insert(v).values({id:i.recordId,value:b,createdAt:w});const l=await d.findById(v,i.recordId),h=l?.value===b;if(await d.deleteById(v,i.recordId).catch(()=>{}),!h)throw new Error(`drizzle-solid readback mismatch for ${i.recordId}`);const u=an(o,i.storagePath);on(u),mt("drizzle-solid write/read/delete OK","ok"),Dt({drizzleSolid:{ok:!0,podUrl:o,storagePath:i.storagePath,tableBase:i.tableBase,recordId:i.recordId,resourceUrl:u,wrote:{value:b,createdAt:w},readBack:l,deleted:!0}})}catch(o){sr(o)}}async function _a(){await Ke.logout({logoutType:"app"}),un(),mt("logged out","warn"),Dt()}function sr(o){const i=o instanceof Error?o.message:String(o);mt(i,"fail"),Dt({error:i})}async function wa(){ua(),De("loginButton").addEventListener("click",()=>{ca()}),De("discoveryButton").addEventListener("click",()=>{la()}),De("storageButton").addEventListener("click",()=>{ha()}),De("resourceButton").addEventListener("click",()=>{fa()}),De("drizzleButton").addEventListener("click",()=>{ma()}),De("logoutButton").addEventListener("click",()=>{_a()});try{if(await Ke.handleIncomingRedirect({restorePreviousSession:!0}),Ke.info.isLoggedIn&&(!Ke.info.webId||!Er(Ke.info.webId,window.location.origin)))throw await Ke.logout({logoutType:"app"}).catch(()=>{}),new Error("Restored WebID does not belong to the current Xpod origin.");un(),mt(Ke.info.isLoggedIn?"logged in":"not logged in",Ke.info.isLoggedIn?"ok":"warn"),Dt()}catch(o){sr(o)}}wa();export{ra as _,ds as r,Qr as v};
131
+ `}function pr(o){return o.replace(/[&<>"]/g,i=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[i]??i)}function De(o){return document.getElementById(o)}function mt(o,i=""){const c=De("status");c.textContent=o,c.className=i}function nn(){return De("cloudIssuer").value.trim()}function Kt(){return De("podHomeUrl").value.trim()}function Si(o){De("podHomeUrl").value=qt(o),De("storageHome").textContent=De("podHomeUrl").value}function or(){const o=sn(De("storagePath").value);return De("storagePath").value=o,o}function Vt(){return De("spResourceUrl").value.trim()}function on(o){De("spResourceUrl").value=o}function qt(o){const i=new URL(tn(o||window.location.origin,window.location.origin));return i.hash="",i.search="",i.pathname.endsWith("/")||(i.pathname=`${i.pathname}/`),i.href}function sn(o){const i=String(o||"").trim();if(!i)return _r;if(/^https?:\/\//iu.test(i)){const c=new URL(i);return`${c.pathname.replace(/^\/+/,"")}${c.hash}`||_r}return i.replace(/^\/+/,"")||_r}function bi(o){const i=sn(o),c=i.indexOf("#"),s=c>=0?i.slice(0,c):i,p=c>=0?i.slice(c):"",v=s.lastIndexOf("/"),d=v>=0?s.slice(0,v+1):"",b=v>=0?s.slice(v+1):s;if(!b)throw new Error(`Storage path must include a file name: ${i}`);return{storagePath:i,documentPath:s,tableBase:`/${d}`,recordId:`${b}${p||"#this"}`}}function an(o,i){const c=bi(i);return new URL(c.documentPath,qt(o)).href}function un(){De("loggedIn").textContent=String(Ke.info.isLoggedIn),De("webId").textContent=Ke.info.webId??"-",De("storageHome").textContent=Kt()||"-"}function Dt(o={}){De("report").value=JSON.stringify({generatedAt:new Date().toISOString(),cloudIssuer:nn(),podHomeUrl:Kt(),storagePath:or(),spResourceUrl:Vt(),session:{isLoggedIn:Ke.info.isLoggedIn,webId:Ke.info.webId,sessionId:Ke.info.sessionId},...o},null,2)}async function ca(){const o=qt(nn()),i=new URL("/app/inrupt-smoke.html",window.location.origin);i.searchParams.set("issuer",o),i.searchParams.set("storagePath",or()),Kt()&&i.searchParams.set("home",Kt()),Vt()&&i.searchParams.set("sp",Vt()),await Ke.login({oidcIssuer:o,redirectUrl:i.href,clientName:"Xpod Inrupt Smoke",tokenType:"DPoP"})}async function cn(o){const i=performance.now(),c=tn(o,window.location.origin),s=await Ke.fetch(c,{method:"GET",cache:"no-store"}),p=await s.text();return{url:c,status:s.status,ok:s.ok,elapsedMs:Math.round(performance.now()-i),headers:Array.from(s.headers.entries()),bodyPreview:p.slice(0,8192)}}async function la(){try{mt("checking cloud discovery...","warn");const o=new URL("/.well-known/openid-configuration",qt(nn())).href,i=await cn(o);mt(`discovery HTTP ${i.status}`,i.ok?"ok":"fail"),Dt({discovery:i})}catch(o){sr(o)}}async function Ei(){if(!Ke.info.isLoggedIn||!Ke.info.webId)throw new Error("Login first; storage discovery needs session.info.webId.");const o=Ke.info.webId,i=ya(o),c=await cn(i);if(!c.ok)throw new Error(`Failed to read WebID profile ${i}: HTTP ${c.status}`);const s=qt(ga(o,c.bodyPreview));return Si(s),Vt()||on(an(s,or())),un(),{webId:o,profileUrl:i,storageUrl:s,profile:c}}async function ha(){try{mt("discovering storage home from WebID profile...","warn");const o=await Ei();mt(`storage home ${o.storageUrl}`,"ok"),Dt({storage:o})}catch(o){sr(o)}}async function Fi(){if(Kt()){const o=qt(Kt());return Si(o),o}return(await Ei()).storageUrl}async function da(){if(Vt())return new URL(Vt()).href;const o=await Fi(),i=an(o,or());return on(i),i}async function fa(){try{mt("fetching SP resource with Inrupt session...","warn");const o=await cn(await da());mt(`SP resource HTTP ${o.status}`,o.ok?"ok":"fail"),Dt({spResource:o})}catch(o){sr(o)}}function ga(o,i){const c=pa(i);if(c)return c;const s=[mr,qr].map(h=>h.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&")).join("|"),p=new RegExp(`<(?:${s})>\\s+<([^>]+)>`,"iu"),v=i.match(p);if(v?.[1])return v[1];const d=/\b(?:solid|pim):storage\s+<([^>]+)>/iu,b=i.match(d);if(b?.[1])return b[1];const w=new RegExp(`<${Or(o)}>[^.]+(?:<${Or(mr)}>|solid:storage|<${Or(qr)}>|pim:storage)\\s+<([^>]+)>`,"isu"),l=i.match(w);if(l?.[1])return l[1];throw new Error(`WebID profile has no solid:storage / ${mr} binding.`)}function pa(o){try{return $r(JSON.parse(o))}catch{return null}}function $r(o){if(Array.isArray(o)){for(const i of o){const c=$r(i);if(c)return c}return null}if(!Ai(o))return null;for(const i of Object.keys(o))if(i===mr||i===qr||i==="solid:storage"||i==="pim:storage"){const c=xi(o[i]);if(c)return c}for(const i of Object.values(o)){const c=$r(i);if(c)return c}return null}function xi(o){if(typeof o=="string"&&/^https?:\/\//iu.test(o))return o;if(Array.isArray(o)){for(const i of o){const c=xi(i);if(c)return c}return null}if(Ai(o)){const i=o["@id"];if(typeof i=="string"&&/^https?:\/\//iu.test(i))return i}return null}function Ai(o){return typeof o=="object"&&o!==null}function ya(o){const i=new URL(tn(o,window.location.origin));return i.hash="",i.href}function Or(o){return o.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&")}function va(){return typeof crypto.randomUUID=="function"?crypto.randomUUID():Math.random().toString(36).slice(2)}async function ma(){try{mt("writing smoke data through drizzle-solid...","warn");const o=await Fi(),i=bi(or()),{drizzle:c,podTable:s,string:p}=await ra(async()=>{const{drizzle:S,podTable:R,string:A}=await import("./index-BCZVzMpj.js");return{drizzle:S,podTable:R,string:A}},__vite__mapDeps([0,1])),v=s("inruptSmokeData",{id:p("id").primaryKey(),value:p("value").predicate("http://schema.org/text"),createdAt:p("createdAt").predicate("http://schema.org/dateCreated")},{base:i.tableBase,type:na}),d=c(Ke,{podUrl:o,resourcePreparation:"best-effort",schema:{inruptSmokeData:v}});await d.init(v),await d.deleteById(v,i.recordId).catch(()=>{});const b=`xpod-inrupt-smoke ${new Date().toISOString()} ${va()}`,w=new Date().toISOString();await d.insert(v).values({id:i.recordId,value:b,createdAt:w});const l=await d.findById(v,i.recordId),h=l?.value===b;if(await d.deleteById(v,i.recordId).catch(()=>{}),!h)throw new Error(`drizzle-solid readback mismatch for ${i.recordId}`);const u=an(o,i.storagePath);on(u),mt("drizzle-solid write/read/delete OK","ok"),Dt({drizzleSolid:{ok:!0,podUrl:o,storagePath:i.storagePath,tableBase:i.tableBase,recordId:i.recordId,resourceUrl:u,wrote:{value:b,createdAt:w},readBack:l,deleted:!0}})}catch(o){sr(o)}}async function _a(){await Ke.logout({logoutType:"app"}),un(),mt("logged out","warn"),Dt()}function sr(o){const i=o instanceof Error?o.message:String(o);mt(i,"fail"),Dt({error:i})}async function wa(){ua(),De("loginButton").addEventListener("click",()=>{ca()}),De("discoveryButton").addEventListener("click",()=>{la()}),De("storageButton").addEventListener("click",()=>{ha()}),De("resourceButton").addEventListener("click",()=>{fa()}),De("drizzleButton").addEventListener("click",()=>{ma()}),De("logoutButton").addEventListener("click",()=>{_a()});try{if(await Ke.handleIncomingRedirect({restorePreviousSession:!0}),Ke.info.isLoggedIn&&(!Ke.info.webId||!Er(Ke.info.webId,window.location.origin)))throw await Ke.logout({logoutType:"app"}).catch(()=>{}),new Error("Restored WebID does not belong to the current Xpod origin.");un(),mt(Ke.info.isLoggedIn?"logged in":"not logged in",Ke.info.isLoggedIn?"ok":"warn"),Dt()}catch(o){sr(o)}}wa();export{ra as _,ds as r,Qr as v};