@sifxprime/krouter 0.5.66 → 0.5.67

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 (371) hide show
  1. package/app/.next-cli-build/BUILD_ID +1 -1
  2. package/app/.next-cli-build/app-path-routes-manifest.json +4 -4
  3. package/app/.next-cli-build/build-manifest.json +2 -2
  4. package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
  5. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page.js.nft.json +1 -1
  6. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
  7. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page.js.nft.json +1 -1
  8. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  9. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  10. package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
  11. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page.js.nft.json +1 -1
  12. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  13. package/app/.next-cli-build/server/app/(dashboard)/dashboard/environment/page_client-reference-manifest.js +1 -1
  14. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
  15. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
  16. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
  17. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
  18. package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
  19. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page.js.nft.json +1 -1
  20. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  21. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  22. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  23. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  24. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  25. package/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
  26. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
  27. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
  28. package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  29. package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  30. package/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
  31. package/app/.next-cli-build/server/app/_global-error.html +1 -1
  32. package/app/.next-cli-build/server/app/_global-error.rsc +1 -1
  33. package/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
  34. package/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  35. package/app/.next-cli-build/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  36. package/app/.next-cli-build/server/app/_global-error.segments/_head.segment.rsc +1 -1
  37. package/app/.next-cli-build/server/app/_global-error.segments/_index.segment.rsc +1 -1
  38. package/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  39. package/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
  40. package/app/.next-cli-build/server/app/_not-found.html +1 -1
  41. package/app/.next-cli-build/server/app/_not-found.rsc +3 -3
  42. package/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +3 -3
  43. package/app/.next-cli-build/server/app/_not-found.segments/_head.segment.rsc +1 -1
  44. package/app/.next-cli-build/server/app/_not-found.segments/_index.segment.rsc +3 -3
  45. package/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  46. package/app/.next-cli-build/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  47. package/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  48. package/app/.next-cli-build/server/app/api/auth/login/route.js.nft.json +1 -1
  49. package/app/.next-cli-build/server/app/api/auth/logout/route.js.nft.json +1 -1
  50. package/app/.next-cli-build/server/app/api/auth/oidc/callback/route.js.nft.json +1 -1
  51. package/app/.next-cli-build/server/app/api/auth/oidc/start/route.js.nft.json +1 -1
  52. package/app/.next-cli-build/server/app/api/auth/oidc/test/route.js.nft.json +1 -1
  53. package/app/.next-cli-build/server/app/api/auth/reset-password/route.js.nft.json +1 -1
  54. package/app/.next-cli-build/server/app/api/auth/status/route.js.nft.json +1 -1
  55. package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js.nft.json +1 -1
  56. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js.nft.json +1 -1
  57. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/route.js.nft.json +1 -1
  58. package/app/.next-cli-build/server/app/api/cli-tools/copilot-settings/route.js.nft.json +1 -1
  59. package/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js.nft.json +1 -1
  60. package/app/.next-cli-build/server/app/api/combos/[id]/route.js.nft.json +1 -1
  61. package/app/.next-cli-build/server/app/api/combos/route.js.nft.json +1 -1
  62. package/app/.next-cli-build/server/app/api/import/route.js.nft.json +1 -1
  63. package/app/.next-cli-build/server/app/api/keys/[id]/route.js.nft.json +1 -1
  64. package/app/.next-cli-build/server/app/api/keys/route.js.nft.json +1 -1
  65. package/app/.next-cli-build/server/app/api/media-providers/tts/deepgram/voices/route.js.nft.json +1 -1
  66. package/app/.next-cli-build/server/app/api/media-providers/tts/elevenlabs/voices/route.js.nft.json +1 -1
  67. package/app/.next-cli-build/server/app/api/media-providers/tts/inworld/voices/route.js.nft.json +1 -1
  68. package/app/.next-cli-build/server/app/api/media-providers/tts/minimax/voices/route.js.nft.json +1 -1
  69. package/app/.next-cli-build/server/app/api/mitm/cert/route.js.nft.json +1 -1
  70. package/app/.next-cli-build/server/app/api/models/alias/route.js.nft.json +1 -1
  71. package/app/.next-cli-build/server/app/api/models/availability/route.js.nft.json +1 -1
  72. package/app/.next-cli-build/server/app/api/models/custom/route.js.nft.json +1 -1
  73. package/app/.next-cli-build/server/app/api/models/disabled/route.js.nft.json +1 -1
  74. package/app/.next-cli-build/server/app/api/models/live/route.js.nft.json +1 -1
  75. package/app/.next-cli-build/server/app/api/models/route.js +1 -1
  76. package/app/.next-cli-build/server/app/api/models/route.js.nft.json +1 -1
  77. package/app/.next-cli-build/server/app/api/models/test/route.js +1 -1
  78. package/app/.next-cli-build/server/app/api/models/test/route.js.nft.json +1 -1
  79. package/app/.next-cli-build/server/app/api/oauth/[provider]/[action]/route.js.nft.json +1 -1
  80. package/app/.next-cli-build/server/app/api/oauth/codex/bulk-import/route.js.nft.json +1 -1
  81. package/app/.next-cli-build/server/app/api/oauth/codex/import-token/route.js.nft.json +1 -1
  82. package/app/.next-cli-build/server/app/api/oauth/cursor/import/route.js.nft.json +1 -1
  83. package/app/.next-cli-build/server/app/api/oauth/gitlab/pat/route.js.nft.json +1 -1
  84. package/app/.next-cli-build/server/app/api/oauth/iflow/cookie/route.js.nft.json +1 -1
  85. package/app/.next-cli-build/server/app/api/oauth/kiro/import/route.js.nft.json +1 -1
  86. package/app/.next-cli-build/server/app/api/oauth/kiro/social-exchange/route.js.nft.json +1 -1
  87. package/app/.next-cli-build/server/app/api/pricing/route.js.nft.json +1 -1
  88. package/app/.next-cli-build/server/app/api/provider-nodes/[id]/route.js.nft.json +1 -1
  89. package/app/.next-cli-build/server/app/api/provider-nodes/route.js.nft.json +1 -1
  90. package/app/.next-cli-build/server/app/api/providers/[id]/models/route.js.nft.json +1 -1
  91. package/app/.next-cli-build/server/app/api/providers/[id]/route.js.nft.json +1 -1
  92. package/app/.next-cli-build/server/app/api/providers/[id]/test/route.js.nft.json +1 -1
  93. package/app/.next-cli-build/server/app/api/providers/[id]/test-models/route.js +1 -1
  94. package/app/.next-cli-build/server/app/api/providers/[id]/test-models/route.js.nft.json +1 -1
  95. package/app/.next-cli-build/server/app/api/providers/client/route.js.nft.json +1 -1
  96. package/app/.next-cli-build/server/app/api/providers/route.js +1 -1
  97. package/app/.next-cli-build/server/app/api/providers/route.js.nft.json +1 -1
  98. package/app/.next-cli-build/server/app/api/providers/test-batch/route.js.nft.json +1 -1
  99. package/app/.next-cli-build/server/app/api/providers/validate/route.js.nft.json +1 -1
  100. package/app/.next-cli-build/server/app/api/proxy-pools/[id]/route.js.nft.json +1 -1
  101. package/app/.next-cli-build/server/app/api/proxy-pools/[id]/test/route.js.nft.json +1 -1
  102. package/app/.next-cli-build/server/app/api/proxy-pools/cloudflare-deploy/route.js.nft.json +1 -1
  103. package/app/.next-cli-build/server/app/api/proxy-pools/deno-deploy/route.js.nft.json +1 -1
  104. package/app/.next-cli-build/server/app/api/proxy-pools/route.js.nft.json +1 -1
  105. package/app/.next-cli-build/server/app/api/proxy-pools/vercel-deploy/route.js.nft.json +1 -1
  106. package/app/.next-cli-build/server/app/api/settings/database/route.js.nft.json +1 -1
  107. package/app/.next-cli-build/server/app/api/settings/require-login/route.js.nft.json +1 -1
  108. package/app/.next-cli-build/server/app/api/settings/route.js.nft.json +1 -1
  109. package/app/.next-cli-build/server/app/api/translator/console-logs/route.js +1 -1
  110. package/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js +1 -1
  111. package/app/.next-cli-build/server/app/api/translator/send/route.js.nft.json +1 -1
  112. package/app/.next-cli-build/server/app/api/translator/translate/route.js.nft.json +1 -1
  113. package/app/.next-cli-build/server/app/api/tunnel/disable/route.js.nft.json +1 -1
  114. package/app/.next-cli-build/server/app/api/tunnel/enable/route.js.nft.json +1 -1
  115. package/app/.next-cli-build/server/app/api/tunnel/status/route.js.nft.json +1 -1
  116. package/app/.next-cli-build/server/app/api/tunnel/tailscale-check/route.js.nft.json +1 -1
  117. package/app/.next-cli-build/server/app/api/tunnel/tailscale-disable/route.js.nft.json +1 -1
  118. package/app/.next-cli-build/server/app/api/tunnel/tailscale-enable/route.js.nft.json +1 -1
  119. package/app/.next-cli-build/server/app/api/tunnel/tailscale-install/route.js.nft.json +1 -1
  120. package/app/.next-cli-build/server/app/api/usage/[connectionId]/route.js.nft.json +1 -1
  121. package/app/.next-cli-build/server/app/api/usage/chart/route.js.nft.json +1 -1
  122. package/app/.next-cli-build/server/app/api/usage/history/route.js.nft.json +1 -1
  123. package/app/.next-cli-build/server/app/api/usage/providers/route.js.nft.json +1 -1
  124. package/app/.next-cli-build/server/app/api/usage/request-details/route.js.nft.json +1 -1
  125. package/app/.next-cli-build/server/app/api/usage/request-logs/route.js.nft.json +1 -1
  126. package/app/.next-cli-build/server/app/api/usage/stats/route.js.nft.json +1 -1
  127. package/app/.next-cli-build/server/app/api/usage/stream/route.js.nft.json +1 -1
  128. package/app/.next-cli-build/server/app/api/v1/api/chat/route.js.nft.json +1 -1
  129. package/app/.next-cli-build/server/app/api/v1/audio/speech/route.js.nft.json +1 -1
  130. package/app/.next-cli-build/server/app/api/v1/audio/transcriptions/route.js.nft.json +1 -1
  131. package/app/.next-cli-build/server/app/api/v1/chat/completions/route.js.nft.json +1 -1
  132. package/app/.next-cli-build/server/app/api/v1/embeddings/route.js.nft.json +1 -1
  133. package/app/.next-cli-build/server/app/api/v1/images/generations/route.js.nft.json +1 -1
  134. package/app/.next-cli-build/server/app/api/v1/messages/route.js.nft.json +1 -1
  135. package/app/.next-cli-build/server/app/api/v1/models/[kind]/route.js.nft.json +1 -1
  136. package/app/.next-cli-build/server/app/api/v1/models/route.js.nft.json +1 -1
  137. package/app/.next-cli-build/server/app/api/v1/responses/compact/route.js.nft.json +1 -1
  138. package/app/.next-cli-build/server/app/api/v1/responses/route.js.nft.json +1 -1
  139. package/app/.next-cli-build/server/app/api/v1/route.js.nft.json +1 -1
  140. package/app/.next-cli-build/server/app/api/v1/search/route.js.nft.json +1 -1
  141. package/app/.next-cli-build/server/app/api/v1/web/fetch/route.js.nft.json +1 -1
  142. package/app/.next-cli-build/server/app/api/v1beta/models/[...path]/route.js.nft.json +1 -1
  143. package/app/.next-cli-build/server/app/api/version/route.js +1 -1
  144. package/app/.next-cli-build/server/app/api/version/shutdown/route.js +1 -1
  145. package/app/.next-cli-build/server/app/api/version/shutdown/route.js.nft.json +1 -1
  146. package/app/.next-cli-build/server/app/api/version/update/route.js +1 -1
  147. package/app/.next-cli-build/server/app/api/version/update/route.js.nft.json +1 -1
  148. package/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
  149. package/app/.next-cli-build/server/app/callback.html +1 -1
  150. package/app/.next-cli-build/server/app/callback.rsc +3 -3
  151. package/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +3 -3
  152. package/app/.next-cli-build/server/app/callback.segments/_head.segment.rsc +1 -1
  153. package/app/.next-cli-build/server/app/callback.segments/_index.segment.rsc +3 -3
  154. package/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +1 -1
  155. package/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +1 -1
  156. package/app/.next-cli-build/server/app/callback.segments/callback.segment.rsc +1 -1
  157. package/app/.next-cli-build/server/app/dashboard/basic-chat.html +1 -1
  158. package/app/.next-cli-build/server/app/dashboard/basic-chat.rsc +5 -5
  159. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat/__PAGE__.segment.rsc +2 -2
  160. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat.segment.rsc +1 -1
  161. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  162. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  163. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_full.segment.rsc +5 -5
  164. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_head.segment.rsc +1 -1
  165. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_index.segment.rsc +3 -3
  166. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +1 -1
  167. package/app/.next-cli-build/server/app/dashboard/cli-tools.html +1 -1
  168. package/app/.next-cli-build/server/app/dashboard/cli-tools.rsc +5 -5
  169. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +2 -2
  170. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools.segment.rsc +1 -1
  171. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  172. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  173. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_full.segment.rsc +5 -5
  174. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_head.segment.rsc +1 -1
  175. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_index.segment.rsc +3 -3
  176. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +1 -1
  177. package/app/.next-cli-build/server/app/dashboard/combos.html +1 -1
  178. package/app/.next-cli-build/server/app/dashboard/combos.rsc +5 -5
  179. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +2 -2
  180. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos.segment.rsc +1 -1
  181. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  182. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  183. package/app/.next-cli-build/server/app/dashboard/combos.segments/_full.segment.rsc +5 -5
  184. package/app/.next-cli-build/server/app/dashboard/combos.segments/_head.segment.rsc +1 -1
  185. package/app/.next-cli-build/server/app/dashboard/combos.segments/_index.segment.rsc +3 -3
  186. package/app/.next-cli-build/server/app/dashboard/combos.segments/_tree.segment.rsc +1 -1
  187. package/app/.next-cli-build/server/app/dashboard/endpoint.html +1 -1
  188. package/app/.next-cli-build/server/app/dashboard/endpoint.rsc +5 -5
  189. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +2 -2
  190. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint.segment.rsc +1 -1
  191. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  192. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  193. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_full.segment.rsc +5 -5
  194. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_head.segment.rsc +1 -1
  195. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_index.segment.rsc +3 -3
  196. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_tree.segment.rsc +1 -1
  197. package/app/.next-cli-build/server/app/dashboard/environment.html +1 -1
  198. package/app/.next-cli-build/server/app/dashboard/environment.rsc +5 -5
  199. package/app/.next-cli-build/server/app/dashboard/environment.segments/!KGRhc2hib2FyZCk/dashboard/environment/__PAGE__.segment.rsc +2 -2
  200. package/app/.next-cli-build/server/app/dashboard/environment.segments/!KGRhc2hib2FyZCk/dashboard/environment.segment.rsc +1 -1
  201. package/app/.next-cli-build/server/app/dashboard/environment.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  202. package/app/.next-cli-build/server/app/dashboard/environment.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  203. package/app/.next-cli-build/server/app/dashboard/environment.segments/_full.segment.rsc +5 -5
  204. package/app/.next-cli-build/server/app/dashboard/environment.segments/_head.segment.rsc +1 -1
  205. package/app/.next-cli-build/server/app/dashboard/environment.segments/_index.segment.rsc +3 -3
  206. package/app/.next-cli-build/server/app/dashboard/environment.segments/_tree.segment.rsc +1 -1
  207. package/app/.next-cli-build/server/app/dashboard/media-providers/web.html +1 -1
  208. package/app/.next-cli-build/server/app/dashboard/media-providers/web.rsc +5 -5
  209. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web/__PAGE__.segment.rsc +2 -2
  210. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web.segment.rsc +1 -1
  211. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers.segment.rsc +1 -1
  212. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  213. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  214. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_full.segment.rsc +5 -5
  215. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_head.segment.rsc +1 -1
  216. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_index.segment.rsc +3 -3
  217. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_tree.segment.rsc +1 -1
  218. package/app/.next-cli-build/server/app/dashboard/mitm.html +1 -1
  219. package/app/.next-cli-build/server/app/dashboard/mitm.rsc +5 -5
  220. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +2 -2
  221. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm.segment.rsc +1 -1
  222. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  223. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  224. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_full.segment.rsc +5 -5
  225. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_head.segment.rsc +1 -1
  226. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_index.segment.rsc +3 -3
  227. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_tree.segment.rsc +1 -1
  228. package/app/.next-cli-build/server/app/dashboard/profile.html +1 -1
  229. package/app/.next-cli-build/server/app/dashboard/profile.rsc +5 -5
  230. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +2 -2
  231. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile.segment.rsc +1 -1
  232. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  233. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  234. package/app/.next-cli-build/server/app/dashboard/profile.segments/_full.segment.rsc +5 -5
  235. package/app/.next-cli-build/server/app/dashboard/profile.segments/_head.segment.rsc +1 -1
  236. package/app/.next-cli-build/server/app/dashboard/profile.segments/_index.segment.rsc +3 -3
  237. package/app/.next-cli-build/server/app/dashboard/profile.segments/_tree.segment.rsc +1 -1
  238. package/app/.next-cli-build/server/app/dashboard/providers/new.html +1 -1
  239. package/app/.next-cli-build/server/app/dashboard/providers/new.rsc +5 -5
  240. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +2 -2
  241. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new.segment.rsc +1 -1
  242. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  243. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  244. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  245. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_full.segment.rsc +5 -5
  246. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_head.segment.rsc +1 -1
  247. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_index.segment.rsc +3 -3
  248. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_tree.segment.rsc +1 -1
  249. package/app/.next-cli-build/server/app/dashboard/providers.html +1 -1
  250. package/app/.next-cli-build/server/app/dashboard/providers.rsc +5 -5
  251. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +2 -2
  252. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  253. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  254. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  255. package/app/.next-cli-build/server/app/dashboard/providers.segments/_full.segment.rsc +5 -5
  256. package/app/.next-cli-build/server/app/dashboard/providers.segments/_head.segment.rsc +1 -1
  257. package/app/.next-cli-build/server/app/dashboard/providers.segments/_index.segment.rsc +3 -3
  258. package/app/.next-cli-build/server/app/dashboard/providers.segments/_tree.segment.rsc +1 -1
  259. package/app/.next-cli-build/server/app/dashboard/proxy-pools.html +1 -1
  260. package/app/.next-cli-build/server/app/dashboard/proxy-pools.rsc +5 -5
  261. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +2 -2
  262. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools.segment.rsc +1 -1
  263. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  264. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  265. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +5 -5
  266. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_head.segment.rsc +1 -1
  267. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_index.segment.rsc +3 -3
  268. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +1 -1
  269. package/app/.next-cli-build/server/app/dashboard/quota.html +2 -2
  270. package/app/.next-cli-build/server/app/dashboard/quota.rsc +6 -6
  271. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +3 -3
  272. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota.segment.rsc +1 -1
  273. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  274. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  275. package/app/.next-cli-build/server/app/dashboard/quota.segments/_full.segment.rsc +6 -6
  276. package/app/.next-cli-build/server/app/dashboard/quota.segments/_head.segment.rsc +1 -1
  277. package/app/.next-cli-build/server/app/dashboard/quota.segments/_index.segment.rsc +3 -3
  278. package/app/.next-cli-build/server/app/dashboard/quota.segments/_tree.segment.rsc +1 -1
  279. package/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  280. package/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
  281. package/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +3 -3
  282. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +3 -3
  283. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
  284. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +3 -3
  285. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +1 -1
  286. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +1 -1
  287. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing.segment.rsc +1 -1
  288. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings.segment.rsc +1 -1
  289. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard.segment.rsc +1 -1
  290. package/app/.next-cli-build/server/app/dashboard/skills.html +1 -1
  291. package/app/.next-cli-build/server/app/dashboard/skills.rsc +5 -5
  292. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills/__PAGE__.segment.rsc +2 -2
  293. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills.segment.rsc +1 -1
  294. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  295. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  296. package/app/.next-cli-build/server/app/dashboard/skills.segments/_full.segment.rsc +5 -5
  297. package/app/.next-cli-build/server/app/dashboard/skills.segments/_head.segment.rsc +1 -1
  298. package/app/.next-cli-build/server/app/dashboard/skills.segments/_index.segment.rsc +3 -3
  299. package/app/.next-cli-build/server/app/dashboard/skills.segments/_tree.segment.rsc +1 -1
  300. package/app/.next-cli-build/server/app/dashboard/translator.html +1 -1
  301. package/app/.next-cli-build/server/app/dashboard/translator.rsc +5 -5
  302. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +2 -2
  303. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator.segment.rsc +1 -1
  304. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  305. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  306. package/app/.next-cli-build/server/app/dashboard/translator.segments/_full.segment.rsc +5 -5
  307. package/app/.next-cli-build/server/app/dashboard/translator.segments/_head.segment.rsc +1 -1
  308. package/app/.next-cli-build/server/app/dashboard/translator.segments/_index.segment.rsc +3 -3
  309. package/app/.next-cli-build/server/app/dashboard/translator.segments/_tree.segment.rsc +1 -1
  310. package/app/.next-cli-build/server/app/dashboard/usage.html +1 -1
  311. package/app/.next-cli-build/server/app/dashboard/usage.rsc +5 -5
  312. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +2 -2
  313. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage.segment.rsc +1 -1
  314. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  315. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  316. package/app/.next-cli-build/server/app/dashboard/usage.segments/_full.segment.rsc +5 -5
  317. package/app/.next-cli-build/server/app/dashboard/usage.segments/_head.segment.rsc +1 -1
  318. package/app/.next-cli-build/server/app/dashboard/usage.segments/_index.segment.rsc +3 -3
  319. package/app/.next-cli-build/server/app/dashboard/usage.segments/_tree.segment.rsc +1 -1
  320. package/app/.next-cli-build/server/app/dashboard.html +1 -1
  321. package/app/.next-cli-build/server/app/dashboard.rsc +5 -5
  322. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +2 -2
  323. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  324. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  325. package/app/.next-cli-build/server/app/dashboard.segments/_full.segment.rsc +5 -5
  326. package/app/.next-cli-build/server/app/dashboard.segments/_head.segment.rsc +1 -1
  327. package/app/.next-cli-build/server/app/dashboard.segments/_index.segment.rsc +3 -3
  328. package/app/.next-cli-build/server/app/dashboard.segments/_tree.segment.rsc +1 -1
  329. package/app/.next-cli-build/server/app/index.html +1 -1
  330. package/app/.next-cli-build/server/app/index.rsc +3 -3
  331. package/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  332. package/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +3 -3
  333. package/app/.next-cli-build/server/app/index.segments/_head.segment.rsc +1 -1
  334. package/app/.next-cli-build/server/app/index.segments/_index.segment.rsc +3 -3
  335. package/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +1 -1
  336. package/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
  337. package/app/.next-cli-build/server/app/landing.html +1 -1
  338. package/app/.next-cli-build/server/app/landing.rsc +3 -3
  339. package/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +3 -3
  340. package/app/.next-cli-build/server/app/landing.segments/_head.segment.rsc +1 -1
  341. package/app/.next-cli-build/server/app/landing.segments/_index.segment.rsc +3 -3
  342. package/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +1 -1
  343. package/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +1 -1
  344. package/app/.next-cli-build/server/app/landing.segments/landing.segment.rsc +1 -1
  345. package/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
  346. package/app/.next-cli-build/server/app/login.html +1 -1
  347. package/app/.next-cli-build/server/app/login.rsc +4 -4
  348. package/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +4 -4
  349. package/app/.next-cli-build/server/app/login.segments/_head.segment.rsc +1 -1
  350. package/app/.next-cli-build/server/app/login.segments/_index.segment.rsc +3 -3
  351. package/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +1 -1
  352. package/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
  353. package/app/.next-cli-build/server/app/login.segments/login.segment.rsc +1 -1
  354. package/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
  355. package/app/.next-cli-build/server/app-paths-manifest.json +4 -4
  356. package/app/.next-cli-build/server/chunks/2365.js +1 -1
  357. package/app/.next-cli-build/server/chunks/706.js +1 -1
  358. package/app/.next-cli-build/server/chunks/7153.js +1 -1
  359. package/app/.next-cli-build/server/chunks/8361.js +1 -1
  360. package/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
  361. package/app/.next-cli-build/server/pages/404.html +1 -1
  362. package/app/.next-cli-build/server/pages/500.html +1 -1
  363. package/app/.next-cli-build/static/chunks/{1321-c5560af49b424619.js → 1321-ca396ed5c0918836.js} +1 -1
  364. package/app/cli/.build-home/.krouter/db/backups/{upgrade-0.5.61-to-0.5.62-0.5.62-20260626-175449 → upgrade-0.5.65-to-0.5.66-0.5.66-20260628-021324}/data.sqlite +0 -0
  365. package/app/cli/.build-home/.krouter/db/data.sqlite +0 -0
  366. package/app/cli/package.json +1 -1
  367. package/app/package.json +1 -1
  368. package/app/src/mitm/server.js +33 -35
  369. package/package.json +1 -1
  370. /package/app/.next-cli-build/static/{UBapuzdakD2WA5lzaPu9L → l63VYOZseXwQzQvtTiruo}/_buildManifest.js +0 -0
  371. /package/app/.next-cli-build/static/{UBapuzdakD2WA5lzaPu9L → l63VYOZseXwQzQvtTiruo}/_ssgManifest.js +0 -0
@@ -1,66 +1,64 @@
1
- var F=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var rr=F((vh,Gn)=>{var Bu=require("fs"),Hr=require("path"),Mn=require("os"),Gr="krouter";function qn(){return process.platform==="win32"?Hr.join(process.env.APPDATA||Hr.join(Mn.homedir(),"AppData","Roaming"),Gr):Hr.join(Mn.homedir(),`.${Gr}`)}function bu(){let e=process.env.DATA_DIR;if(!e)return qn();try{return Bu.mkdirSync(e,{recursive:!0}),e}catch(t){if(t?.code==="EACCES"||t?.code==="EPERM")return console.warn(`[DATA_DIR] '${e}' not writable \u2192 fallback ~/.${Gr}`),qn();throw t}}var Hn=bu(),_u=Hr.join(Hn,"mitm");Gn.exports={DATA_DIR:Hn,MITM_DIR:_u,APP_NAME:Gr}});var Sr=F((mh,Qn)=>{var zn=require("fs"),wu=process.env.NODE_ENV==="development",Nu=(()=>{if(process.platform==="win32")return null;for(let e of["/usr/sbin/lsof","/usr/bin/lsof","/sbin/lsof"])try{return zn.accessSync(e,zn.constants.X_OK),e}catch{}return"lsof"})(),Ru=["daily-cloudcode-pa.googleapis.com","cloudcode-pa.googleapis.com","api.individual.githubcopilot.com","q.us-east-1.amazonaws.com","codewhisperer.us-east-1.amazonaws.com","runtime.us-east-1.kiro.dev","api2.cursor.sh","api.anthropic.com"],Lu={antigravity:[":generateContent",":streamGenerateContent"],copilot:["/chat/completions","/v1/messages","/responses"],kiro:["/generateAssistantResponse"],cursor:["/BidiAppend","/RunSSE","/RunPoll","/Run"],claude:["/v1/messages"]},ku={antigravity:{"gemini-default":"gemini-3.5-flash-low","gemini-3.5-flash-high":"gemini-3-flash-agent","gemini-3.5-flash-medium":"gemini-3.5-flash-low","gemini-3.5-flash-extra-low":"gemini-3.5-flash-extra-low","gemini-3.1-pro-high":"gemini-pro-agent","gemini-3-pro-high":"gemini-pro-agent","gemini-3-pro-low":"gemini-3.1-pro-low"}},Du={antigravity:[{match:/flash.*extra.*low|extra.*low.*flash|flash.*low|low.*flash/i,alias:"gemini-3.5-flash-extra-low"},{match:/flash.*medium|medium.*flash/i,alias:"gemini-3.5-flash-low"},{match:/flash.*agent|agent.*flash|flash/i,alias:"gemini-3-flash-agent"},{match:/pro.*low|low.*pro/i,alias:"gemini-3.1-pro-low"},{match:/gemini.*pro|pro.*gemini/i,alias:"gemini-pro-agent"},{match:/opus/i,alias:"claude-opus-4-6-thinking"},{match:/sonnet|claude/i,alias:"claude-sonnet-4-6"},{match:/gpt.*oss|oss/i,alias:"gpt-oss-120b-medium"}]},Uu={antigravity:[/^tab[_-]/i]},Pu=["recordCodeAssistMetrics","recordTrajectoryAnalytics","fetchAdminControls","listExperiments","fetchUserInfo"];function Ou(e){let t=(e||"").split(":")[0];return t==="api.individual.githubcopilot.com"?"copilot":t==="daily-cloudcode-pa.googleapis.com"||t==="cloudcode-pa.googleapis.com"?"antigravity":t==="q.us-east-1.amazonaws.com"||t==="codewhisperer.us-east-1.amazonaws.com"||t==="runtime.us-east-1.kiro.dev"?"kiro":t==="api2.cursor.sh"?"cursor":t==="api.anthropic.com"?"claude":null}Qn.exports={IS_DEV:wu,LSOF_BIN:Nu,TARGET_HOSTS:Ru,URL_PATTERNS:Lu,MODEL_SYNONYMS:ku,MODEL_PATTERNS:Du,MODEL_NO_MAP:Uu,LOG_BLACKLIST_URL_PARTS:Pu,getToolForHost:Ou}});var _t=F((Ch,Wn)=>{var Ht=require("fs"),zr=require("path"),_a=require("zlib"),{DATA_DIR:Vu}=rr(),{LOG_BLACKLIST_URL_PARTS:Fu}=Sr();function $n(){return new Date().toLocaleTimeString("en-US",{hour12:!1})}var Ku=e=>console.log(`[${$n()}] [MITM] ${e}`),Mu=e=>console.error(`[${$n()}] \u274C [MITM] ${e}`),Gt=zr.join(Vu,"logs","mitm");Ht.existsSync(Gt)||Ht.mkdirSync(Gt,{recursive:!0});function qu(){try{if(!Ht.existsSync(Gt))return;for(let e of Ht.readdirSync(Gt))try{Ht.rmSync(zr.join(Gt,e),{recursive:!0,force:!0})}catch{}}catch{}}var Hu=/^\s*(\{\s*\}|\[\s*\]|null)?\s*$/;function Yn(e,t=80){return String(e).replace(/[^a-zA-Z0-9]/g,"_").substring(0,t)}function jn(e){return e?Fu.some(t=>e.includes(t)):!1}function Gu(e,t){if(!e||e.length===0)return e;try{let a=(t||"").toLowerCase();if(a.includes("gzip"))return _a.gunzipSync(e);if(a.includes("br"))return _a.brotliDecompressSync(e);if(a.includes("deflate"))return _a.inflateSync(e)}catch{}return e}function zu(e,t,a="raw"){if(jn(e.url))return null;try{let r=new Date().toISOString().replace(/[:.]/g,"-"),n=Yn((e.headers.host||"")+e.url),s=zr.join(Gt,`${r}_${a}_${n}.req.json`),i=null;try{i=JSON.parse(t.toString())}catch{}return Ht.writeFileSync(s,JSON.stringify({method:e.method,url:e.url,host:e.headers.host,headers:e.headers,body:i??t.toString("utf8")},null,2)),s}catch{return null}}function Qu(e,t="raw"){if(jn(e.url))return null;let a=new Date().toISOString().replace(/[:.]/g,"-"),r=Yn((e.headers.host||"")+e.url),n=zr.join(Gt,`${a}_${t}_${r}.res.txt`),s=0,i={},o=[];return{writeHeader:(u,l)=>{s=u,i=l||{}},writeChunk:u=>{u!=null&&o.push(Buffer.isBuffer(u)?u:Buffer.from(u))},end:()=>{try{let u=Buffer.concat(o),l=i["content-encoding"]||i["Content-Encoding"],f=Gu(u,l).toString("utf8");if(Hu.test(f))return;let g={...i};delete g["content-encoding"],delete g["Content-Encoding"];let v=`STATUS: ${s}
1
+ var F=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var nr=F((Ch,Qn)=>{var bu=require("fs"),Gr=require("path"),Hn=require("os"),zr="krouter";function Gn(){return process.platform==="win32"?Gr.join(process.env.APPDATA||Gr.join(Hn.homedir(),"AppData","Roaming"),zr):Gr.join(Hn.homedir(),`.${zr}`)}function _u(){let e=process.env.DATA_DIR;if(!e)return Gn();try{return bu.mkdirSync(e,{recursive:!0}),e}catch(t){if(t?.code==="EACCES"||t?.code==="EPERM")return console.warn(`[DATA_DIR] '${e}' not writable \u2192 fallback ~/.${zr}`),Gn();throw t}}var zn=_u(),wu=Gr.join(zn,"mitm");Qn.exports={DATA_DIR:zn,MITM_DIR:wu,APP_NAME:zr}});var Tr=F((Eh,Yn)=>{var $n=require("fs"),Nu=process.env.NODE_ENV==="development",Ru=(()=>{if(process.platform==="win32")return null;for(let e of["/usr/sbin/lsof","/usr/bin/lsof","/sbin/lsof"])try{return $n.accessSync(e,$n.constants.X_OK),e}catch{}return"lsof"})(),Lu=["daily-cloudcode-pa.googleapis.com","cloudcode-pa.googleapis.com","api.individual.githubcopilot.com","q.us-east-1.amazonaws.com","codewhisperer.us-east-1.amazonaws.com","runtime.us-east-1.kiro.dev","api2.cursor.sh","api.anthropic.com"],ku={antigravity:[":generateContent",":streamGenerateContent"],copilot:["/chat/completions","/v1/messages","/responses"],kiro:["/generateAssistantResponse"],cursor:["/BidiAppend","/RunSSE","/RunPoll","/Run"],claude:["/v1/messages"]},Du={antigravity:{"gemini-default":"gemini-3.5-flash-low","gemini-3.5-flash-high":"gemini-3-flash-agent","gemini-3.5-flash-medium":"gemini-3.5-flash-low","gemini-3.5-flash-extra-low":"gemini-3.5-flash-extra-low","gemini-3.1-pro-high":"gemini-pro-agent","gemini-3-pro-high":"gemini-pro-agent","gemini-3-pro-low":"gemini-3.1-pro-low"}},Uu={antigravity:[{match:/flash.*extra.*low|extra.*low.*flash|flash.*low|low.*flash/i,alias:"gemini-3.5-flash-extra-low"},{match:/flash.*medium|medium.*flash/i,alias:"gemini-3.5-flash-low"},{match:/flash.*agent|agent.*flash|flash/i,alias:"gemini-3-flash-agent"},{match:/pro.*low|low.*pro/i,alias:"gemini-3.1-pro-low"},{match:/gemini.*pro|pro.*gemini/i,alias:"gemini-pro-agent"},{match:/opus/i,alias:"claude-opus-4-6-thinking"},{match:/sonnet|claude/i,alias:"claude-sonnet-4-6"},{match:/gpt.*oss|oss/i,alias:"gpt-oss-120b-medium"}]},Pu={antigravity:[/^tab[_-]/i]},Ou=["recordCodeAssistMetrics","recordTrajectoryAnalytics","fetchAdminControls","listExperiments","fetchUserInfo"];function Vu(e){let t=(e||"").split(":")[0];return t==="api.individual.githubcopilot.com"?"copilot":t==="daily-cloudcode-pa.googleapis.com"||t==="cloudcode-pa.googleapis.com"?"antigravity":t==="q.us-east-1.amazonaws.com"||t==="codewhisperer.us-east-1.amazonaws.com"||t==="runtime.us-east-1.kiro.dev"?"kiro":t==="api2.cursor.sh"?"cursor":t==="api.anthropic.com"?"claude":null}Yn.exports={IS_DEV:Nu,LSOF_BIN:Ru,TARGET_HOSTS:Lu,URL_PATTERNS:ku,MODEL_SYNONYMS:Du,MODEL_PATTERNS:Uu,MODEL_NO_MAP:Pu,LOG_BLACKLIST_URL_PARTS:Ou,getToolForHost:Vu}});var _t=F((xh,Jn)=>{var Ht=require("fs"),Qr=require("path"),wa=require("zlib"),{DATA_DIR:Fu}=nr(),{LOG_BLACKLIST_URL_PARTS:Ku}=Tr();function jn(){return new Date().toLocaleTimeString("en-US",{hour12:!1})}var Mu=e=>console.log(`[${jn()}] [MITM] ${e}`),qu=e=>console.error(`[${jn()}] \u274C [MITM] ${e}`),Gt=Qr.join(Fu,"logs","mitm");Ht.existsSync(Gt)||Ht.mkdirSync(Gt,{recursive:!0});function Hu(){try{if(!Ht.existsSync(Gt))return;for(let e of Ht.readdirSync(Gt))try{Ht.rmSync(Qr.join(Gt,e),{recursive:!0,force:!0})}catch{}}catch{}}var Gu=/^\s*(\{\s*\}|\[\s*\]|null)?\s*$/;function Wn(e,t=80){return String(e).replace(/[^a-zA-Z0-9]/g,"_").substring(0,t)}function Xn(e){return e?Ku.some(t=>e.includes(t)):!1}function zu(e,t){if(!e||e.length===0)return e;try{let a=(t||"").toLowerCase();if(a.includes("gzip"))return wa.gunzipSync(e);if(a.includes("br"))return wa.brotliDecompressSync(e);if(a.includes("deflate"))return wa.inflateSync(e)}catch{}return e}function Qu(e,t,a="raw"){if(Xn(e.url))return null;try{let r=new Date().toISOString().replace(/[:.]/g,"-"),n=Wn((e.headers.host||"")+e.url),s=Qr.join(Gt,`${r}_${a}_${n}.req.json`),i=null;try{i=JSON.parse(t.toString())}catch{}return Ht.writeFileSync(s,JSON.stringify({method:e.method,url:e.url,host:e.headers.host,headers:e.headers,body:i??t.toString("utf8")},null,2)),s}catch{return null}}function $u(e,t="raw"){if(Xn(e.url))return null;let a=new Date().toISOString().replace(/[:.]/g,"-"),r=Wn((e.headers.host||"")+e.url),n=Qr.join(Gt,`${a}_${t}_${r}.res.txt`),s=0,i={},o=[];return{writeHeader:(u,l)=>{s=u,i=l||{}},writeChunk:u=>{u!=null&&o.push(Buffer.isBuffer(u)?u:Buffer.from(u))},end:()=>{try{let u=Buffer.concat(o),l=i["content-encoding"]||i["Content-Encoding"],f=zu(u,l).toString("utf8");if(Gu.test(f))return;let g={...i};delete g["content-encoding"],delete g["Content-Encoding"];let v=`STATUS: ${s}
2
2
  HEADERS: ${JSON.stringify(g,null,2)}
3
3
  ---BODY---
4
- ${f}`;Ht.writeFileSync(n,v)}catch{}},file:n}}Wn.exports={log:Ku,err:Mu,dumpRequest:zu,createResponseDumper:Qu,clearDumpDir:qu}});var $=F((Eh,Xn)=>{Xn.exports={options:{usePureJavaScript:!1}}});var ei=F((xh,Zn)=>{var wa={};Zn.exports=wa;var Jn={};wa.encode=function(e,t,a){if(typeof t!="string")throw new TypeError('"alphabet" must be a string.');if(a!==void 0&&typeof a!="number")throw new TypeError('"maxline" must be a number.');var r="";if(!(e instanceof Uint8Array))r=$u(e,t);else{var n=0,s=t.length,i=t.charAt(0),o=[0];for(n=0;n<e.length;++n){for(var u=0,l=e[n];u<o.length;++u)l+=o[u]<<8,o[u]=l%s,l=l/s|0;for(;l>0;)o.push(l%s),l=l/s|0}for(n=0;e[n]===0&&n<e.length-1;++n)r+=i;for(n=o.length-1;n>=0;--n)r+=t[o[n]]}if(a){var c=new RegExp(".{1,"+a+"}","g");r=r.match(c).join(`\r
5
- `)}return r};wa.decode=function(e,t){if(typeof e!="string")throw new TypeError('"input" must be a string.');if(typeof t!="string")throw new TypeError('"alphabet" must be a string.');var a=Jn[t];if(!a){a=Jn[t]=[];for(var r=0;r<t.length;++r)a[t.charCodeAt(r)]=r}e=e.replace(/\s/g,"");for(var n=t.length,s=t.charAt(0),i=[0],r=0;r<e.length;r++){var o=a[e.charCodeAt(r)];if(o===void 0)return;for(var u=0,l=o;u<i.length;++u)l+=i[u]*n,i[u]=l&255,l>>=8;for(;l>0;)i.push(l&255),l>>=8}for(var c=0;e[c]===s&&c<e.length-1;++c)i.push(0);return typeof Buffer<"u"?Buffer.from(i.reverse()):new Uint8Array(i.reverse())};function $u(e,t){var a=0,r=t.length,n=t.charAt(0),s=[0];for(a=0;a<e.length();++a){for(var i=0,o=e.at(a);i<s.length;++i)o+=s[i]<<8,s[i]=o%r,o=o/r|0;for(;o>0;)s.push(o%r),o=o/r|0}var u="";for(a=0;e.at(a)===0&&a<e.length()-1;++a)u+=n;for(a=s.length-1;a>=0;--a)u+=t[s[a]];return u}});var re=F((Sh,ni)=>{var ti=$(),ri=ei(),E=ni.exports=ti.util=ti.util||{};(function(){if(typeof process<"u"&&process.nextTick&&!process.browser){E.nextTick=process.nextTick,typeof setImmediate=="function"?E.setImmediate=setImmediate:E.setImmediate=E.nextTick;return}if(typeof setImmediate=="function"){E.setImmediate=function(){return setImmediate.apply(void 0,arguments)},E.nextTick=function(o){return setImmediate(o)};return}if(E.setImmediate=function(o){setTimeout(o,0)},typeof window<"u"&&typeof window.postMessage=="function"){let o=function(u){if(u.source===window&&u.data===e){u.stopPropagation();var l=t.slice();t.length=0,l.forEach(function(c){c()})}};var i=o,e="forge.setImmediate",t=[];E.setImmediate=function(u){t.push(u),t.length===1&&window.postMessage(e,"*")},window.addEventListener("message",o,!0)}if(typeof MutationObserver<"u"){var a=Date.now(),r=!0,n=document.createElement("div"),t=[];new MutationObserver(function(){var u=t.slice();t.length=0,u.forEach(function(l){l()})}).observe(n,{attributes:!0});var s=E.setImmediate;E.setImmediate=function(u){Date.now()-a>15?(a=Date.now(),s(u)):(t.push(u),t.length===1&&n.setAttribute("a",r=!r))}}E.nextTick=E.setImmediate})();E.isNodejs=typeof process<"u"&&process.versions&&process.versions.node;E.globalScope=(function(){return E.isNodejs?global:typeof self>"u"?window:self})();E.isArray=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"};E.isArrayBuffer=function(e){return typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer};E.isArrayBufferView=function(e){return e&&E.isArrayBuffer(e.buffer)&&e.byteLength!==void 0};function Tr(e){if(!(e===8||e===16||e===24||e===32))throw new Error("Only 8, 16, 24, or 32 bits supported: "+e)}E.ByteBuffer=Na;function Na(e){if(this.data="",this.read=0,typeof e=="string")this.data=e;else if(E.isArrayBuffer(e)||E.isArrayBufferView(e))if(typeof Buffer<"u"&&e instanceof Buffer)this.data=e.toString("binary");else{var t=new Uint8Array(e);try{this.data=String.fromCharCode.apply(null,t)}catch{for(var a=0;a<t.length;++a)this.putByte(t[a])}}else(e instanceof Na||typeof e=="object"&&typeof e.data=="string"&&typeof e.read=="number")&&(this.data=e.data,this.read=e.read);this._constructedStringLength=0}E.ByteStringBuffer=Na;var Yu=4096;E.ByteStringBuffer.prototype._optimizeConstructedString=function(e){this._constructedStringLength+=e,this._constructedStringLength>Yu&&(this.data.substr(0,1),this._constructedStringLength=0)};E.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read};E.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0};E.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))};E.ByteStringBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var a=this.data;t>0;)t&1&&(a+=e),t>>>=1,t>0&&(e+=e);return this.data=a,this._optimizeConstructedString(t),this};E.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this};E.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(E.encodeUtf8(e))};E.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))};E.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))};E.ByteStringBuffer.prototype.putInt32=function(e){return this.putBytes(String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))};E.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255))};E.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))};E.ByteStringBuffer.prototype.putInt32Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))};E.ByteStringBuffer.prototype.putInt=function(e,t){Tr(t);var a="";do t-=8,a+=String.fromCharCode(e>>t&255);while(t>0);return this.putBytes(a)};E.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<<t-1),this.putInt(e,t)};E.ByteStringBuffer.prototype.putBuffer=function(e){return this.putBytes(e.getBytes())};E.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)};E.ByteStringBuffer.prototype.getInt16=function(){var e=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,e};E.ByteStringBuffer.prototype.getInt24=function(){var e=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,e};E.ByteStringBuffer.prototype.getInt32=function(){var e=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,e};E.ByteStringBuffer.prototype.getInt16Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,e};E.ByteStringBuffer.prototype.getInt24Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,e};E.ByteStringBuffer.prototype.getInt32Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24;return this.read+=4,e};E.ByteStringBuffer.prototype.getInt=function(e){Tr(e);var t=0;do t=(t<<8)+this.data.charCodeAt(this.read++),e-=8;while(e>0);return t};E.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),a=2<<e-2;return t>=a&&(t-=a<<1),t};E.ByteStringBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):e===0?t="":(t=this.read===0?this.data:this.data.slice(this.read),this.clear()),t};E.ByteStringBuffer.prototype.bytes=function(e){return typeof e>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+e)};E.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)};E.ByteStringBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this};E.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)};E.ByteStringBuffer.prototype.copy=function(){var e=E.createBuffer(this.data);return e.read=this.read,e};E.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this};E.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this};E.ByteStringBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this};E.ByteStringBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.length;++t){var a=this.data.charCodeAt(t);a<16&&(e+="0"),e+=a.toString(16)}return e};E.ByteStringBuffer.prototype.toString=function(){return E.decodeUtf8(this.bytes())};function ju(e,t){t=t||{},this.read=t.readOffset||0,this.growSize=t.growSize||1024;var a=E.isArrayBuffer(e),r=E.isArrayBufferView(e);if(a||r){a?this.data=new DataView(e):this.data=new DataView(e.buffer,e.byteOffset,e.byteLength),this.write="writeOffset"in t?t.writeOffset:this.data.byteLength;return}this.data=new DataView(new ArrayBuffer(0)),this.write=0,e!=null&&this.putBytes(e),"writeOffset"in t&&(this.write=t.writeOffset)}E.DataBuffer=ju;E.DataBuffer.prototype.length=function(){return this.write-this.read};E.DataBuffer.prototype.isEmpty=function(){return this.length()<=0};E.DataBuffer.prototype.accommodate=function(e,t){if(this.length()>=e)return this;t=Math.max(t||this.growSize,e);var a=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),r=new Uint8Array(this.length()+t);return r.set(a),this.data=new DataView(r.buffer),this};E.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this};E.DataBuffer.prototype.fillWithByte=function(e,t){this.accommodate(t);for(var a=0;a<t;++a)this.data.setUint8(e);return this};E.DataBuffer.prototype.putBytes=function(e,t){if(E.isArrayBufferView(e)){var a=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r=a.byteLength-a.byteOffset;this.accommodate(r);var n=new Uint8Array(this.data.buffer,this.write);return n.set(a),this.write+=r,this}if(E.isArrayBuffer(e)){var a=new Uint8Array(e);this.accommodate(a.byteLength);var n=new Uint8Array(this.data.buffer);return n.set(a,this.write),this.write+=a.byteLength,this}if(e instanceof E.DataBuffer||typeof e=="object"&&typeof e.read=="number"&&typeof e.write=="number"&&E.isArrayBufferView(e.data)){var a=new Uint8Array(e.data.byteLength,e.read,e.length());this.accommodate(a.byteLength);var n=new Uint8Array(e.data.byteLength,this.write);return n.set(a),this.write+=a.byteLength,this}if(e instanceof E.ByteStringBuffer&&(e=e.data,t="binary"),t=t||"binary",typeof e=="string"){var s;if(t==="hex")return this.accommodate(Math.ceil(e.length/2)),s=new Uint8Array(this.data.buffer,this.write),this.write+=E.binary.hex.decode(e,s,this.write),this;if(t==="base64")return this.accommodate(Math.ceil(e.length/4)*3),s=new Uint8Array(this.data.buffer,this.write),this.write+=E.binary.base64.decode(e,s,this.write),this;if(t==="utf8"&&(e=E.encodeUtf8(e),t="binary"),t==="binary"||t==="raw")return this.accommodate(e.length),s=new Uint8Array(this.data.buffer,this.write),this.write+=E.binary.raw.decode(s),this;if(t==="utf16")return this.accommodate(e.length*2),s=new Uint16Array(this.data.buffer,this.write),this.write+=E.text.utf16.encode(s),this;throw new Error("Invalid encoding: "+t)}throw Error("Invalid parameter: "+e)};E.DataBuffer.prototype.putBuffer=function(e){return this.putBytes(e),e.clear(),this};E.DataBuffer.prototype.putString=function(e){return this.putBytes(e,"utf16")};E.DataBuffer.prototype.putInt16=function(e){return this.accommodate(2),this.data.setInt16(this.write,e),this.write+=2,this};E.DataBuffer.prototype.putInt24=function(e){return this.accommodate(3),this.data.setInt16(this.write,e>>8&65535),this.data.setInt8(this.write,e>>16&255),this.write+=3,this};E.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this};E.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this};E.DataBuffer.prototype.putInt24Le=function(e){return this.accommodate(3),this.data.setInt8(this.write,e>>16&255),this.data.setInt16(this.write,e>>8&65535,!0),this.write+=3,this};E.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this};E.DataBuffer.prototype.putInt=function(e,t){Tr(t),this.accommodate(t/8);do t-=8,this.data.setInt8(this.write++,e>>t&255);while(t>0);return this};E.DataBuffer.prototype.putSignedInt=function(e,t){return Tr(t),this.accommodate(t/8),e<0&&(e+=2<<t-1),this.putInt(e,t)};E.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)};E.DataBuffer.prototype.getInt16=function(){var e=this.data.getInt16(this.read);return this.read+=2,e};E.DataBuffer.prototype.getInt24=function(){var e=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,e};E.DataBuffer.prototype.getInt32=function(){var e=this.data.getInt32(this.read);return this.read+=4,e};E.DataBuffer.prototype.getInt16Le=function(){var e=this.data.getInt16(this.read,!0);return this.read+=2,e};E.DataBuffer.prototype.getInt24Le=function(){var e=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,e};E.DataBuffer.prototype.getInt32Le=function(){var e=this.data.getInt32(this.read,!0);return this.read+=4,e};E.DataBuffer.prototype.getInt=function(e){Tr(e);var t=0;do t=(t<<8)+this.data.getInt8(this.read++),e-=8;while(e>0);return t};E.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),a=2<<e-2;return t>=a&&(t-=a<<1),t};E.DataBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):e===0?t="":(t=this.read===0?this.data:this.data.slice(this.read),this.clear()),t};E.DataBuffer.prototype.bytes=function(e){return typeof e>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+e)};E.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)};E.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this};E.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)};E.DataBuffer.prototype.copy=function(){return new E.DataBuffer(this)};E.DataBuffer.prototype.compact=function(){if(this.read>0){var e=new Uint8Array(this.data.buffer,this.read),t=new Uint8Array(e.byteLength);t.set(e),this.data=new DataView(t),this.write-=this.read,this.read=0}return this};E.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this};E.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this};E.DataBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.byteLength;++t){var a=this.data.getUint8(t);a<16&&(e+="0"),e+=a.toString(16)}return e};E.DataBuffer.prototype.toString=function(e){var t=new Uint8Array(this.data,this.read,this.length());if(e=e||"utf8",e==="binary"||e==="raw")return E.binary.raw.encode(t);if(e==="hex")return E.binary.hex.encode(t);if(e==="base64")return E.binary.base64.encode(t);if(e==="utf8")return E.text.utf8.decode(t);if(e==="utf16")return E.text.utf16.decode(t);throw new Error("Invalid encoding: "+e)};E.createBuffer=function(e,t){return t=t||"raw",e!==void 0&&t==="utf8"&&(e=E.encodeUtf8(e)),new E.ByteBuffer(e)};E.fillString=function(e,t){for(var a="";t>0;)t&1&&(a+=e),t>>>=1,t>0&&(e+=e);return a};E.xorBytes=function(e,t,a){for(var r="",n="",s="",i=0,o=0;a>0;--a,++i)n=e.charCodeAt(i)^t.charCodeAt(i),o>=10&&(r+=s,s="",o=0),s+=String.fromCharCode(n),++o;return r+=s,r};E.hexToBytes=function(e){var t="",a=0;for(e.length&!0&&(a=1,t+=String.fromCharCode(parseInt(e[0],16)));a<e.length;a+=2)t+=String.fromCharCode(parseInt(e.substr(a,2),16));return t};E.bytesToHex=function(e){return E.createBuffer(e).toHex()};E.int32ToBytes=function(e){return String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255)};var wt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Nt=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],ai="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";E.encode64=function(e,t){for(var a="",r="",n,s,i,o=0;o<e.length;)n=e.charCodeAt(o++),s=e.charCodeAt(o++),i=e.charCodeAt(o++),a+=wt.charAt(n>>2),a+=wt.charAt((n&3)<<4|s>>4),isNaN(s)?a+="==":(a+=wt.charAt((s&15)<<2|i>>6),a+=isNaN(i)?"=":wt.charAt(i&63)),t&&a.length>t&&(r+=a.substr(0,t)+`\r
6
- `,a=a.substr(t));return r+=a,r};E.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t="",a,r,n,s,i=0;i<e.length;)a=Nt[e.charCodeAt(i++)-43],r=Nt[e.charCodeAt(i++)-43],n=Nt[e.charCodeAt(i++)-43],s=Nt[e.charCodeAt(i++)-43],t+=String.fromCharCode(a<<2|r>>4),n!==64&&(t+=String.fromCharCode((r&15)<<4|n>>2),s!==64&&(t+=String.fromCharCode((n&3)<<6|s)));return t};E.encodeUtf8=function(e){return unescape(encodeURIComponent(e))};E.decodeUtf8=function(e){return decodeURIComponent(escape(e))};E.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:ri.encode,decode:ri.decode}};E.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)};E.binary.raw.decode=function(e,t,a){var r=t;r||(r=new Uint8Array(e.length)),a=a||0;for(var n=a,s=0;s<e.length;++s)r[n++]=e.charCodeAt(s);return t?n-a:r};E.binary.hex.encode=E.bytesToHex;E.binary.hex.decode=function(e,t,a){var r=t;r||(r=new Uint8Array(Math.ceil(e.length/2))),a=a||0;var n=0,s=a;for(e.length&1&&(n=1,r[s++]=parseInt(e[0],16));n<e.length;n+=2)r[s++]=parseInt(e.substr(n,2),16);return t?s-a:r};E.binary.base64.encode=function(e,t){for(var a="",r="",n,s,i,o=0;o<e.byteLength;)n=e[o++],s=e[o++],i=e[o++],a+=wt.charAt(n>>2),a+=wt.charAt((n&3)<<4|s>>4),isNaN(s)?a+="==":(a+=wt.charAt((s&15)<<2|i>>6),a+=isNaN(i)?"=":wt.charAt(i&63)),t&&a.length>t&&(r+=a.substr(0,t)+`\r
7
- `,a=a.substr(t));return r+=a,r};E.binary.base64.decode=function(e,t,a){var r=t;r||(r=new Uint8Array(Math.ceil(e.length/4)*3)),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,""),a=a||0;for(var n,s,i,o,u=0,l=a;u<e.length;)n=Nt[e.charCodeAt(u++)-43],s=Nt[e.charCodeAt(u++)-43],i=Nt[e.charCodeAt(u++)-43],o=Nt[e.charCodeAt(u++)-43],r[l++]=n<<2|s>>4,i!==64&&(r[l++]=(s&15)<<4|i>>2,o!==64&&(r[l++]=(i&3)<<6|o));return t?l-a:r.subarray(0,l)};E.binary.base58.encode=function(e,t){return E.binary.baseN.encode(e,ai,t)};E.binary.base58.decode=function(e,t){return E.binary.baseN.decode(e,ai,t)};E.text={utf8:{},utf16:{}};E.text.utf8.encode=function(e,t,a){e=E.encodeUtf8(e);var r=t;r||(r=new Uint8Array(e.length)),a=a||0;for(var n=a,s=0;s<e.length;++s)r[n++]=e.charCodeAt(s);return t?n-a:r};E.text.utf8.decode=function(e){return E.decodeUtf8(String.fromCharCode.apply(null,e))};E.text.utf16.encode=function(e,t,a){var r=t;r||(r=new Uint8Array(e.length*2));var n=new Uint16Array(r.buffer);a=a||0;for(var s=a,i=a,o=0;o<e.length;++o)n[i++]=e.charCodeAt(o),s+=2;return t?s-a:r};E.text.utf16.decode=function(e){return String.fromCharCode.apply(null,new Uint16Array(e.buffer))};E.deflate=function(e,t,a){if(t=E.decode64(e.deflate(E.encode64(t)).rval),a){var r=2,n=t.charCodeAt(1);n&32&&(r=6),t=t.substring(r,t.length-4)}return t};E.inflate=function(e,t,a){var r=e.inflate(E.encode64(t)).rval;return r===null?null:E.decode64(r)};var Ra=function(e,t,a){if(!e)throw new Error("WebStorage not available.");var r;if(a===null?r=e.removeItem(t):(a=E.encode64(JSON.stringify(a)),r=e.setItem(t,a)),typeof r<"u"&&r.rval!==!0){var n=new Error(r.error.message);throw n.id=r.error.id,n.name=r.error.name,n}},La=function(e,t){if(!e)throw new Error("WebStorage not available.");var a=e.getItem(t);if(e.init)if(a.rval===null){if(a.error){var r=new Error(a.error.message);throw r.id=a.error.id,r.name=a.error.name,r}a=null}else a=a.rval;return a!==null&&(a=JSON.parse(E.decode64(a))),a},Wu=function(e,t,a,r){var n=La(e,t);n===null&&(n={}),n[a]=r,Ra(e,t,n)},Xu=function(e,t,a){var r=La(e,t);return r!==null&&(r=a in r?r[a]:null),r},Ju=function(e,t,a){var r=La(e,t);if(r!==null&&a in r){delete r[a];var n=!0;for(var s in r){n=!1;break}n&&(r=null),Ra(e,t,r)}},Zu=function(e,t){Ra(e,t,null)},Qr=function(e,t,a){var r=null;typeof a>"u"&&(a=["web","flash"]);var n,s=!1,i=null;for(var o in a){n=a[o];try{if(n==="flash"||n==="both"){if(t[0]===null)throw new Error("Flash local storage not available.");r=e.apply(this,t),s=n==="flash"}(n==="web"||n==="both")&&(t[0]=localStorage,r=e.apply(this,t),s=!0)}catch(u){i=u}if(s)break}if(!s)throw i;return r};E.setItem=function(e,t,a,r,n){Qr(Wu,arguments,n)};E.getItem=function(e,t,a,r){return Qr(Xu,arguments,r)};E.removeItem=function(e,t,a,r){Qr(Ju,arguments,r)};E.clearItems=function(e,t,a){Qr(Zu,arguments,a)};E.isEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0};E.format=function(e){for(var t=/%./g,a,r,n=0,s=[],i=0;a=t.exec(e);){r=e.substring(i,t.lastIndex-2),r.length>0&&s.push(r),i=t.lastIndex;var o=a[0][1];switch(o){case"s":case"o":n<arguments.length?s.push(arguments[n+++1]):s.push("<?>");break;case"%":s.push("%");break;default:s.push("<%"+o+"?>")}}return s.push(e.substring(i)),s.join("")};E.formatNumber=function(e,t,a,r){var n=e,s=isNaN(t=Math.abs(t))?2:t,i=a===void 0?",":a,o=r===void 0?".":r,u=n<0?"-":"",l=parseInt(n=Math.abs(+n||0).toFixed(s),10)+"",c=l.length>3?l.length%3:0;return u+(c?l.substr(0,c)+o:"")+l.substr(c).replace(/(\d{3})(?=\d)/g,"$1"+o)+(s?i+Math.abs(n-l).toFixed(s).slice(2):"")};E.formatSize=function(e){return e>=1073741824?e=E.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?e=E.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?e=E.formatNumber(e/1024,0)+" KiB":e=E.formatNumber(e,0)+" bytes",e};E.bytesFromIP=function(e){return e.indexOf(".")!==-1?E.bytesFromIPv4(e):e.indexOf(":")!==-1?E.bytesFromIPv6(e):null};E.bytesFromIPv4=function(e){if(e=e.split("."),e.length!==4)return null;for(var t=E.createBuffer(),a=0;a<e.length;++a){var r=parseInt(e[a],10);if(isNaN(r))return null;t.putByte(r)}return t.getBytes()};E.bytesFromIPv6=function(e){var t=0;e=e.split(":").filter(function(i){return i.length===0&&++t,!0});for(var a=(8-e.length+t)*2,r=E.createBuffer(),n=0;n<8;++n){if(!e[n]||e[n].length===0){r.fillWithByte(0,a),a=0;continue}var s=E.hexToBytes(e[n]);s.length<2&&r.putByte(0),r.putBytes(s)}return r.getBytes()};E.bytesToIP=function(e){return e.length===4?E.bytesToIPv4(e):e.length===16?E.bytesToIPv6(e):null};E.bytesToIPv4=function(e){if(e.length!==4)return null;for(var t=[],a=0;a<e.length;++a)t.push(e.charCodeAt(a));return t.join(".")};E.bytesToIPv6=function(e){if(e.length!==16)return null;for(var t=[],a=[],r=0,n=0;n<e.length;n+=2){for(var s=E.bytesToHex(e[n]+e[n+1]);s[0]==="0"&&s!=="0";)s=s.substr(1);if(s==="0"){var i=a[a.length-1],o=t.length;!i||o!==i.end+1?a.push({start:o,end:o}):(i.end=o,i.end-i.start>a[r].end-a[r].start&&(r=a.length-1))}t.push(s)}if(a.length>0){var u=a[r];u.end-u.start>0&&(t.splice(u.start,u.end-u.start+1,""),u.start===0&&t.unshift(""),u.end===7&&t.push(""))}return t.join(":")};E.estimateCores=function(e,t){if(typeof e=="function"&&(t=e,e={}),e=e||{},"cores"in E&&!e.update)return t(null,E.cores);if(typeof navigator<"u"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return E.cores=navigator.hardwareConcurrency,t(null,E.cores);if(typeof Worker>"u")return E.cores=1,t(null,E.cores);if(typeof Blob>"u")return E.cores=2,t(null,E.cores);var a=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",function(i){for(var o=Date.now(),u=o+4;Date.now()<u;);self.postMessage({st:o,et:u})})}.toString(),")()"],{type:"application/javascript"}));r([],5,16);function r(i,o,u){if(o===0){var l=Math.floor(i.reduce(function(c,f){return c+f},0)/i.length);return E.cores=Math.max(1,l),URL.revokeObjectURL(a),t(null,E.cores)}n(u,function(c,f){i.push(s(u,f)),r(i,o-1,u)})}function n(i,o){for(var u=[],l=[],c=0;c<i;++c){var f=new Worker(a);f.addEventListener("message",function(g){if(l.push(g.data),l.length===i){for(var v=0;v<i;++v)u[v].terminate();o(null,l)}}),u.push(f)}for(var c=0;c<i;++c)u[c].postMessage(c)}function s(i,o){for(var u=[],l=0;l<i;++l)for(var c=o[l],f=u[l]=[],g=0;g<i;++g)if(l!==g){var v=o[g];(c.st>v.st&&c.st<v.et||v.st>c.st&&v.st<c.et)&&f.push(g)}return u.reduce(function(y,x){return Math.max(y,x.length)},0)}}});var $r=F((Th,ii)=>{var xe=$();re();ii.exports=xe.cipher=xe.cipher||{};xe.cipher.algorithms=xe.cipher.algorithms||{};xe.cipher.createCipher=function(e,t){var a=e;if(typeof a=="string"&&(a=xe.cipher.getAlgorithm(a),a&&(a=a())),!a)throw new Error("Unsupported algorithm: "+e);return new xe.cipher.BlockCipher({algorithm:a,key:t,decrypt:!1})};xe.cipher.createDecipher=function(e,t){var a=e;if(typeof a=="string"&&(a=xe.cipher.getAlgorithm(a),a&&(a=a())),!a)throw new Error("Unsupported algorithm: "+e);return new xe.cipher.BlockCipher({algorithm:a,key:t,decrypt:!0})};xe.cipher.registerAlgorithm=function(e,t){e=e.toUpperCase(),xe.cipher.algorithms[e]=t};xe.cipher.getAlgorithm=function(e){return e=e.toUpperCase(),e in xe.cipher.algorithms?xe.cipher.algorithms[e]:null};var ka=xe.cipher.BlockCipher=function(e){this.algorithm=e.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=e.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=e.decrypt,this.algorithm.initialize(e)};ka.prototype.start=function(e){e=e||{};var t={};for(var a in e)t[a]=e[a];t.decrypt=this._decrypt,this._finish=!1,this._input=xe.util.createBuffer(),this.output=e.output||xe.util.createBuffer(),this.mode.start(t)};ka.prototype.update=function(e){for(e&&this._input.putBuffer(e);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()};ka.prototype.finish=function(e){e&&(this.mode.name==="ECB"||this.mode.name==="CBC")&&(this.mode.pad=function(a){return e(this.blockSize,a,!1)},this.mode.unpad=function(a){return e(this.blockSize,a,!0)});var t={};return t.decrypt=this._decrypt,t.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,t)||(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,t))||this.mode.afterFinish&&!this.mode.afterFinish(this.output,t))}});var Ua=F((Ih,si)=>{var Se=$();re();Se.cipher=Se.cipher||{};var j=si.exports=Se.cipher.modes=Se.cipher.modes||{};j.ecb=function(e){e=e||{},this.name="ECB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)};j.ecb.prototype.start=function(e){};j.ecb.prototype.encrypt=function(e,t,a){if(e.length()<this.blockSize&&!(a&&e.length()>0))return!0;for(var r=0;r<this._ints;++r)this._inBlock[r]=e.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var r=0;r<this._ints;++r)t.putInt32(this._outBlock[r])};j.ecb.prototype.decrypt=function(e,t,a){if(e.length()<this.blockSize&&!(a&&e.length()>0))return!0;for(var r=0;r<this._ints;++r)this._inBlock[r]=e.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var r=0;r<this._ints;++r)t.putInt32(this._outBlock[r])};j.ecb.prototype.pad=function(e,t){var a=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(a,a),!0};j.ecb.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var a=e.length(),r=e.at(a-1);return r>this.blockSize<<2?!1:(e.truncate(r),!0)};j.cbc=function(e){e=e||{},this.name="CBC",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)};j.cbc.prototype.start=function(e){if(e.iv===null){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else if("iv"in e)this._iv=Yr(e.iv,this.blockSize),this._prev=this._iv.slice(0);else throw new Error("Invalid IV parameter.")};j.cbc.prototype.encrypt=function(e,t,a){if(e.length()<this.blockSize&&!(a&&e.length()>0))return!0;for(var r=0;r<this._ints;++r)this._inBlock[r]=this._prev[r]^e.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var r=0;r<this._ints;++r)t.putInt32(this._outBlock[r]);this._prev=this._outBlock};j.cbc.prototype.decrypt=function(e,t,a){if(e.length()<this.blockSize&&!(a&&e.length()>0))return!0;for(var r=0;r<this._ints;++r)this._inBlock[r]=e.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var r=0;r<this._ints;++r)t.putInt32(this._prev[r]^this._outBlock[r]);this._prev=this._inBlock.slice(0)};j.cbc.prototype.pad=function(e,t){var a=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(a,a),!0};j.cbc.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var a=e.length(),r=e.at(a-1);return r>this.blockSize<<2?!1:(e.truncate(r),!0)};j.cfb=function(e){e=e||{},this.name="CFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=Se.util.createBuffer(),this._partialBytes=0};j.cfb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=Yr(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};j.cfb.prototype.encrypt=function(e,t,a){var r=e.length();if(r===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize){for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32()^this._outBlock[n],t.putInt32(this._inBlock[n]);return}var s=(this.blockSize-r)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialBlock[n]=e.getInt32()^this._outBlock[n],this._partialOutput.putInt32(this._partialBlock[n]);if(s>0)e.read-=this.blockSize;else for(var n=0;n<this._ints;++n)this._inBlock[n]=this._partialBlock[n];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!a)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0};j.cfb.prototype.decrypt=function(e,t,a){var r=e.length();if(r===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize){for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32(),t.putInt32(this._inBlock[n]^this._outBlock[n]);return}var s=(this.blockSize-r)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialBlock[n]=e.getInt32(),this._partialOutput.putInt32(this._partialBlock[n]^this._outBlock[n]);if(s>0)e.read-=this.blockSize;else for(var n=0;n<this._ints;++n)this._inBlock[n]=this._partialBlock[n];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!a)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0};j.ofb=function(e){e=e||{},this.name="OFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=Se.util.createBuffer(),this._partialBytes=0};j.ofb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=Yr(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};j.ofb.prototype.encrypt=function(e,t,a){var r=e.length();if(e.length()===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize){for(var n=0;n<this._ints;++n)t.putInt32(e.getInt32()^this._outBlock[n]),this._inBlock[n]=this._outBlock[n];return}var s=(this.blockSize-r)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialOutput.putInt32(e.getInt32()^this._outBlock[n]);if(s>0)e.read-=this.blockSize;else for(var n=0;n<this._ints;++n)this._inBlock[n]=this._outBlock[n];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!a)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0};j.ofb.prototype.decrypt=j.ofb.prototype.encrypt;j.ctr=function(e){e=e||{},this.name="CTR",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=Se.util.createBuffer(),this._partialBytes=0};j.ctr.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=Yr(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};j.ctr.prototype.encrypt=function(e,t,a){var r=e.length();if(r===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize)for(var n=0;n<this._ints;++n)t.putInt32(e.getInt32()^this._outBlock[n]);else{var s=(this.blockSize-r)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialOutput.putInt32(e.getInt32()^this._outBlock[n]);if(s>0&&(e.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!a)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0}jr(this._inBlock)};j.ctr.prototype.decrypt=j.ctr.prototype.encrypt;j.gcm=function(e){e=e||{},this.name="GCM",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=Se.util.createBuffer(),this._partialBytes=0,this._R=3774873600};j.gcm.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");var t=Se.util.createBuffer(e.iv);this._cipherLength=0;var a;if("additionalData"in e?a=Se.util.createBuffer(e.additionalData):a=Se.util.createBuffer(),"tagLength"in e?this._tagLength=e.tagLength:this._tagLength=128,this._tag=null,e.decrypt&&(this._tag=Se.util.createBuffer(e.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var r=t.length();if(r===12)this._j0=[t.getInt32(),t.getInt32(),t.getInt32(),1];else{for(this._j0=[0,0,0,0];t.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[t.getInt32(),t.getInt32(),t.getInt32(),t.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(Da(r*8)))}this._inBlock=this._j0.slice(0),jr(this._inBlock),this._partialBytes=0,a=Se.util.createBuffer(a),this._aDataLength=Da(a.length()*8);var n=a.length()%this.blockSize;for(n&&a.fillWithByte(0,this.blockSize-n),this._s=[0,0,0,0];a.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[a.getInt32(),a.getInt32(),a.getInt32(),a.getInt32()])};j.gcm.prototype.encrypt=function(e,t,a){var r=e.length();if(r===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize){for(var n=0;n<this._ints;++n)t.putInt32(this._outBlock[n]^=e.getInt32());this._cipherLength+=this.blockSize}else{var s=(this.blockSize-r)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialOutput.putInt32(e.getInt32()^this._outBlock[n]);if(s<=0||a){if(a){var i=r%this.blockSize;this._cipherLength+=i,this._partialOutput.truncate(this.blockSize-i)}else this._cipherLength+=this.blockSize;for(var n=0;n<this._ints;++n)this._outBlock[n]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!a)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),jr(this._inBlock)};j.gcm.prototype.decrypt=function(e,t,a){var r=e.length();if(r<this.blockSize&&!(a&&r>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),jr(this._inBlock),this._hashBlock[0]=e.getInt32(),this._hashBlock[1]=e.getInt32(),this._hashBlock[2]=e.getInt32(),this._hashBlock[3]=e.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var n=0;n<this._ints;++n)t.putInt32(this._outBlock[n]^this._hashBlock[n]);r<this.blockSize?this._cipherLength+=r%this.blockSize:this._cipherLength+=this.blockSize};j.gcm.prototype.afterFinish=function(e,t){var a=!0;t.decrypt&&t.overflow&&e.truncate(this.blockSize-t.overflow),this.tag=Se.util.createBuffer();var r=this._aDataLength.concat(Da(this._cipherLength*8));this._s=this.ghash(this._hashSubkey,this._s,r);var n=[];this.cipher.encrypt(this._j0,n);for(var s=0;s<this._ints;++s)this.tag.putInt32(this._s[s]^n[s]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),t.decrypt&&this.tag.bytes()!==this._tag&&(a=!1),a};j.gcm.prototype.multiply=function(e,t){for(var a=[0,0,0,0],r=t.slice(0),n=0;n<128;++n){var s=e[n/32|0]&1<<31-n%32;s&&(a[0]^=r[0],a[1]^=r[1],a[2]^=r[2],a[3]^=r[3]),this.pow(r,r)}return a};j.gcm.prototype.pow=function(e,t){for(var a=e[3]&1,r=3;r>0;--r)t[r]=e[r]>>>1|(e[r-1]&1)<<31;t[0]=e[0]>>>1,a&&(t[0]^=this._R)};j.gcm.prototype.tableMultiply=function(e){for(var t=[0,0,0,0],a=0;a<32;++a){var r=a/8|0,n=e[r]>>>(7-a%8)*4&15,s=this._m[a][n];t[0]^=s[0],t[1]^=s[1],t[2]^=s[2],t[3]^=s[3]}return t};j.gcm.prototype.ghash=function(e,t,a){return t[0]^=a[0],t[1]^=a[1],t[2]^=a[2],t[3]^=a[3],this.tableMultiply(t)};j.gcm.prototype.generateHashTable=function(e,t){for(var a=8/t,r=4*a,n=16*a,s=new Array(n),i=0;i<n;++i){var o=[0,0,0,0],u=i/r|0,l=(r-1-i%r)*t;o[u]=1<<t-1<<l,s[i]=this.generateSubHashTable(this.multiply(o,e),t)}return s};j.gcm.prototype.generateSubHashTable=function(e,t){var a=1<<t,r=a>>>1,n=new Array(a);n[r]=e.slice(0);for(var s=r>>>1;s>0;)this.pow(n[2*s],n[s]=[]),s>>=1;for(s=2;s<r;){for(var i=1;i<s;++i){var o=n[s],u=n[i];n[s+i]=[o[0]^u[0],o[1]^u[1],o[2]^u[2],o[3]^u[3]]}s*=2}for(n[0]=[0,0,0,0],s=r+1;s<a;++s){var l=n[s^r];n[s]=[e[0]^l[0],e[1]^l[1],e[2]^l[2],e[3]^l[3]]}return n};function Yr(e,t){if(typeof e=="string"&&(e=Se.util.createBuffer(e)),Se.util.isArray(e)&&e.length>4){var a=e;e=Se.util.createBuffer();for(var r=0;r<a.length;++r)e.putByte(a[r])}if(e.length()<t)throw new Error("Invalid IV length; got "+e.length()+" bytes and expected "+t+" bytes.");if(!Se.util.isArray(e)){for(var n=[],s=t/4,r=0;r<s;++r)n.push(e.getInt32());e=n}return e}function jr(e){e[e.length-1]=e[e.length-1]+1&4294967295}function Da(e){return[e/4294967296|0,e&4294967295]}});var Rt=F((Ah,ci)=>{var le=$();$r();Ua();re();ci.exports=le.aes=le.aes||{};le.aes.startEncrypting=function(e,t,a,r){var n=Wr({key:e,output:a,decrypt:!1,mode:r});return n.start(t),n};le.aes.createEncryptionCipher=function(e,t){return Wr({key:e,output:null,decrypt:!1,mode:t})};le.aes.startDecrypting=function(e,t,a,r){var n=Wr({key:e,output:a,decrypt:!0,mode:r});return n.start(t),n};le.aes.createDecryptionCipher=function(e,t){return Wr({key:e,output:null,decrypt:!0,mode:t})};le.aes.Algorithm=function(e,t){Va||ui();var a=this;a.name=e,a.mode=new t({blockSize:16,cipher:{encrypt:function(r,n){return Oa(a._w,r,n,!1)},decrypt:function(r,n){return Oa(a._w,r,n,!0)}}}),a._init=!1};le.aes.Algorithm.prototype.initialize=function(e){if(!this._init){var t=e.key,a;if(typeof t=="string"&&(t.length===16||t.length===24||t.length===32))t=le.util.createBuffer(t);else if(le.util.isArray(t)&&(t.length===16||t.length===24||t.length===32)){a=t,t=le.util.createBuffer();for(var r=0;r<a.length;++r)t.putByte(a[r])}if(!le.util.isArray(t)){a=t,t=[];var n=a.length();if(n===16||n===24||n===32){n=n>>>2;for(var r=0;r<n;++r)t.push(a.getInt32())}}if(!le.util.isArray(t)||!(t.length===4||t.length===6||t.length===8))throw new Error("Invalid key parameter.");var s=this.mode.name,i=["CFB","OFB","CTR","GCM"].indexOf(s)!==-1;this._w=li(t,e.decrypt&&!i),this._init=!0}};le.aes._expandKey=function(e,t){return Va||ui(),li(e,t)};le.aes._updateBlock=Oa;nr("AES-ECB",le.cipher.modes.ecb);nr("AES-CBC",le.cipher.modes.cbc);nr("AES-CFB",le.cipher.modes.cfb);nr("AES-OFB",le.cipher.modes.ofb);nr("AES-CTR",le.cipher.modes.ctr);nr("AES-GCM",le.cipher.modes.gcm);function nr(e,t){var a=function(){return new le.aes.Algorithm(e,t)};le.cipher.registerAlgorithm(e,a)}var Va=!1,ar=4,He,Pa,oi,zt,ut;function ui(){Va=!0,oi=[0,1,2,4,8,16,32,64,128,27,54];for(var e=new Array(256),t=0;t<128;++t)e[t]=t<<1,e[t+128]=t+128<<1^283;He=new Array(256),Pa=new Array(256),zt=new Array(4),ut=new Array(4);for(var t=0;t<4;++t)zt[t]=new Array(256),ut[t]=new Array(256);for(var a=0,r=0,n,s,i,o,u,l,c,t=0;t<256;++t){o=r^r<<1^r<<2^r<<3^r<<4,o=o>>8^o&255^99,He[a]=o,Pa[o]=a,u=e[o],n=e[a],s=e[n],i=e[s],l=u<<24^o<<16^o<<8^(o^u),c=(n^s^i)<<24^(a^i)<<16^(a^s^i)<<8^(a^n^i);for(var f=0;f<4;++f)zt[f][a]=l,ut[f][o]=c,l=l<<24|l>>>8,c=c<<24|c>>>8;a===0?a=r=1:(a=n^e[e[e[n^i]]],r^=e[e[r]])}}function li(e,t){for(var a=e.slice(0),r,n=1,s=a.length,i=s+6+1,o=ar*i,u=s;u<o;++u)r=a[u-1],u%s===0?(r=He[r>>>16&255]<<24^He[r>>>8&255]<<16^He[r&255]<<8^He[r>>>24]^oi[n]<<24,n++):s>6&&u%s===4&&(r=He[r>>>24]<<24^He[r>>>16&255]<<16^He[r>>>8&255]<<8^He[r&255]),a[u]=a[u-s]^r;if(t){var l,c=ut[0],f=ut[1],g=ut[2],v=ut[3],y=a.slice(0);o=a.length;for(var u=0,x=o-ar;u<o;u+=ar,x-=ar)if(u===0||u===o-ar)y[u]=a[x],y[u+1]=a[x+3],y[u+2]=a[x+2],y[u+3]=a[x+1];else for(var S=0;S<ar;++S)l=a[x+S],y[u+(3&-S)]=c[He[l>>>24]]^f[He[l>>>16&255]]^g[He[l>>>8&255]]^v[He[l&255]];a=y}return a}function Oa(e,t,a,r){var n=e.length/4-1,s,i,o,u,l;r?(s=ut[0],i=ut[1],o=ut[2],u=ut[3],l=Pa):(s=zt[0],i=zt[1],o=zt[2],u=zt[3],l=He);var c,f,g,v,y,x,S;c=t[0]^e[0],f=t[r?3:1]^e[1],g=t[2]^e[2],v=t[r?1:3]^e[3];for(var I=3,B=1;B<n;++B)y=s[c>>>24]^i[f>>>16&255]^o[g>>>8&255]^u[v&255]^e[++I],x=s[f>>>24]^i[g>>>16&255]^o[v>>>8&255]^u[c&255]^e[++I],S=s[g>>>24]^i[v>>>16&255]^o[c>>>8&255]^u[f&255]^e[++I],v=s[v>>>24]^i[c>>>16&255]^o[f>>>8&255]^u[g&255]^e[++I],c=y,f=x,g=S;a[0]=l[c>>>24]<<24^l[f>>>16&255]<<16^l[g>>>8&255]<<8^l[v&255]^e[++I],a[r?3:1]=l[f>>>24]<<24^l[g>>>16&255]<<16^l[v>>>8&255]<<8^l[c&255]^e[++I],a[2]=l[g>>>24]<<24^l[v>>>16&255]<<16^l[c>>>8&255]<<8^l[f&255]^e[++I],a[r?1:3]=l[v>>>24]<<24^l[c>>>16&255]<<16^l[f>>>8&255]<<8^l[g&255]^e[++I]}function Wr(e){e=e||{};var t=(e.mode||"CBC").toUpperCase(),a="AES-"+t,r;e.decrypt?r=le.cipher.createDecipher(a,e.key):r=le.cipher.createCipher(a,e.key);var n=r.start;return r.start=function(s,i){var o=null;i instanceof le.util.ByteBuffer&&(o=i,i={}),i=i||{},i.output=o,i.iv=s,n.call(r,i)},r}});var Lt=F((Bh,fi)=>{var Ir=$();Ir.pki=Ir.pki||{};var Fa=fi.exports=Ir.pki.oids=Ir.oids=Ir.oids||{};function N(e,t){Fa[e]=t,Fa[t]=e}function ae(e,t){Fa[e]=t}N("1.2.840.113549.1.1.1","rsaEncryption");N("1.2.840.113549.1.1.4","md5WithRSAEncryption");N("1.2.840.113549.1.1.5","sha1WithRSAEncryption");N("1.2.840.113549.1.1.7","RSAES-OAEP");N("1.2.840.113549.1.1.8","mgf1");N("1.2.840.113549.1.1.9","pSpecified");N("1.2.840.113549.1.1.10","RSASSA-PSS");N("1.2.840.113549.1.1.11","sha256WithRSAEncryption");N("1.2.840.113549.1.1.12","sha384WithRSAEncryption");N("1.2.840.113549.1.1.13","sha512WithRSAEncryption");N("1.3.101.112","EdDSA25519");N("1.2.840.10040.4.3","dsa-with-sha1");N("1.3.14.3.2.7","desCBC");N("1.3.14.3.2.26","sha1");N("1.3.14.3.2.29","sha1WithRSASignature");N("2.16.840.1.101.3.4.2.1","sha256");N("2.16.840.1.101.3.4.2.2","sha384");N("2.16.840.1.101.3.4.2.3","sha512");N("2.16.840.1.101.3.4.2.4","sha224");N("2.16.840.1.101.3.4.2.5","sha512-224");N("2.16.840.1.101.3.4.2.6","sha512-256");N("1.2.840.113549.2.2","md2");N("1.2.840.113549.2.5","md5");N("1.2.840.113549.1.7.1","data");N("1.2.840.113549.1.7.2","signedData");N("1.2.840.113549.1.7.3","envelopedData");N("1.2.840.113549.1.7.4","signedAndEnvelopedData");N("1.2.840.113549.1.7.5","digestedData");N("1.2.840.113549.1.7.6","encryptedData");N("1.2.840.113549.1.9.1","emailAddress");N("1.2.840.113549.1.9.2","unstructuredName");N("1.2.840.113549.1.9.3","contentType");N("1.2.840.113549.1.9.4","messageDigest");N("1.2.840.113549.1.9.5","signingTime");N("1.2.840.113549.1.9.6","counterSignature");N("1.2.840.113549.1.9.7","challengePassword");N("1.2.840.113549.1.9.8","unstructuredAddress");N("1.2.840.113549.1.9.14","extensionRequest");N("1.2.840.113549.1.9.20","friendlyName");N("1.2.840.113549.1.9.21","localKeyId");N("1.2.840.113549.1.9.22.1","x509Certificate");N("1.2.840.113549.1.12.10.1.1","keyBag");N("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag");N("1.2.840.113549.1.12.10.1.3","certBag");N("1.2.840.113549.1.12.10.1.4","crlBag");N("1.2.840.113549.1.12.10.1.5","secretBag");N("1.2.840.113549.1.12.10.1.6","safeContentsBag");N("1.2.840.113549.1.5.13","pkcs5PBES2");N("1.2.840.113549.1.5.12","pkcs5PBKDF2");N("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4");N("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4");N("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC");N("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC");N("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC");N("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC");N("1.2.840.113549.2.7","hmacWithSHA1");N("1.2.840.113549.2.8","hmacWithSHA224");N("1.2.840.113549.2.9","hmacWithSHA256");N("1.2.840.113549.2.10","hmacWithSHA384");N("1.2.840.113549.2.11","hmacWithSHA512");N("1.2.840.113549.3.7","des-EDE3-CBC");N("2.16.840.1.101.3.4.1.2","aes128-CBC");N("2.16.840.1.101.3.4.1.22","aes192-CBC");N("2.16.840.1.101.3.4.1.42","aes256-CBC");N("2.5.4.3","commonName");N("2.5.4.4","surname");N("2.5.4.5","serialNumber");N("2.5.4.6","countryName");N("2.5.4.7","localityName");N("2.5.4.8","stateOrProvinceName");N("2.5.4.9","streetAddress");N("2.5.4.10","organizationName");N("2.5.4.11","organizationalUnitName");N("2.5.4.12","title");N("2.5.4.13","description");N("2.5.4.15","businessCategory");N("2.5.4.17","postalCode");N("2.5.4.42","givenName");N("2.5.4.65","pseudonym");N("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName");N("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName");N("2.16.840.1.113730.1.1","nsCertType");N("2.16.840.1.113730.1.13","nsComment");ae("2.5.29.1","authorityKeyIdentifier");ae("2.5.29.2","keyAttributes");ae("2.5.29.3","certificatePolicies");ae("2.5.29.4","keyUsageRestriction");ae("2.5.29.5","policyMapping");ae("2.5.29.6","subtreesConstraint");ae("2.5.29.7","subjectAltName");ae("2.5.29.8","issuerAltName");ae("2.5.29.9","subjectDirectoryAttributes");ae("2.5.29.10","basicConstraints");ae("2.5.29.11","nameConstraints");ae("2.5.29.12","policyConstraints");ae("2.5.29.13","basicConstraints");N("2.5.29.14","subjectKeyIdentifier");N("2.5.29.15","keyUsage");ae("2.5.29.16","privateKeyUsagePeriod");N("2.5.29.17","subjectAltName");N("2.5.29.18","issuerAltName");N("2.5.29.19","basicConstraints");ae("2.5.29.20","cRLNumber");ae("2.5.29.21","cRLReason");ae("2.5.29.22","expirationDate");ae("2.5.29.23","instructionCode");ae("2.5.29.24","invalidityDate");ae("2.5.29.25","cRLDistributionPoints");ae("2.5.29.26","issuingDistributionPoint");ae("2.5.29.27","deltaCRLIndicator");ae("2.5.29.28","issuingDistributionPoint");ae("2.5.29.29","certificateIssuer");ae("2.5.29.30","nameConstraints");N("2.5.29.31","cRLDistributionPoints");N("2.5.29.32","certificatePolicies");ae("2.5.29.33","policyMappings");ae("2.5.29.34","policyConstraints");N("2.5.29.35","authorityKeyIdentifier");ae("2.5.29.36","policyConstraints");N("2.5.29.37","extKeyUsage");ae("2.5.29.46","freshestCRL");ae("2.5.29.54","inhibitAnyPolicy");N("1.3.6.1.4.1.11129.2.4.2","timestampList");N("1.3.6.1.5.5.7.1.1","authorityInfoAccess");N("1.3.6.1.5.5.7.3.1","serverAuth");N("1.3.6.1.5.5.7.3.2","clientAuth");N("1.3.6.1.5.5.7.3.3","codeSigning");N("1.3.6.1.5.5.7.3.4","emailProtection");N("1.3.6.1.5.5.7.3.8","timeStamping")});var lt=F((bh,hi)=>{var de=$();re();Lt();var U=hi.exports=de.asn1=de.asn1||{};U.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192};U.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30};U.maxDepth=256;U.create=function(e,t,a,r,n){if(de.util.isArray(r)){for(var s=[],i=0;i<r.length;++i)r[i]!==void 0&&s.push(r[i]);r=s}var o={tagClass:e,type:t,constructed:a,composed:a||de.util.isArray(r),value:r};return n&&"bitStringContents"in n&&(o.bitStringContents=n.bitStringContents,o.original=U.copy(o)),o};U.copy=function(e,t){var a;if(de.util.isArray(e)){a=[];for(var r=0;r<e.length;++r)a.push(U.copy(e[r],t));return a}return typeof e=="string"?e:(a={tagClass:e.tagClass,type:e.type,constructed:e.constructed,composed:e.composed,value:U.copy(e.value,t)},t&&!t.excludeBitStringContents&&(a.bitStringContents=e.bitStringContents),a)};U.equals=function(e,t,a){if(de.util.isArray(e)){if(!de.util.isArray(t)||e.length!==t.length)return!1;for(var r=0;r<e.length;++r)if(!U.equals(e[r],t[r]))return!1;return!0}if(typeof e!=typeof t)return!1;if(typeof e=="string")return e===t;var n=e.tagClass===t.tagClass&&e.type===t.type&&e.constructed===t.constructed&&e.composed===t.composed&&U.equals(e.value,t.value);return a&&a.includeBitStringContents&&(n=n&&e.bitStringContents===t.bitStringContents),n};U.getBerValueLength=function(e){var t=e.getByte();if(t!==128){var a,r=t&128;return r?a=e.getInt((t&127)<<3):a=t,a}};function Ar(e,t,a){if(a>t){var r=new Error("Too few bytes to parse DER.");throw r.available=e.length(),r.remaining=t,r.requested=a,r}}var e0=function(e,t){var a=e.getByte();if(t--,a!==128){var r,n=a&128;if(!n)r=a;else{var s=a&127;Ar(e,t,s),r=e.getInt(s<<3)}if(r<0)throw new Error("Negative length: "+r);return r}};U.fromDer=function(e,t){t===void 0&&(t={strict:!0,parseAllBytes:!0,decodeBitStrings:!0}),typeof t=="boolean"&&(t={strict:t,parseAllBytes:!0,decodeBitStrings:!0}),"strict"in t||(t.strict=!0),"parseAllBytes"in t||(t.parseAllBytes=!0),"decodeBitStrings"in t||(t.decodeBitStrings=!0),"maxDepth"in t||(t.maxDepth=U.maxDepth),typeof e=="string"&&(e=de.util.createBuffer(e));var a=e.length(),r=Xr(e,e.length(),0,t);if(t.parseAllBytes&&e.length()!==0){var n=new Error("Unparsed DER bytes remain after ASN.1 parsing.");throw n.byteCount=a,n.remaining=e.length(),n}return r};function Xr(e,t,a,r){if(a>=r.maxDepth)throw new Error("ASN.1 parsing error: Max depth exceeded.");var n;Ar(e,t,2);var s=e.getByte();t--;var i=s&192,o=s&31;n=e.length();var u=e0(e,t);if(t-=n-e.length(),u!==void 0&&u>t){if(r.strict){var l=new Error("Too few bytes to read ASN.1 value.");throw l.available=e.length(),l.remaining=t,l.requested=u,l}u=t}var c,f,g=(s&32)===32;if(g)if(c=[],u===void 0)for(;;){if(Ar(e,t,2),e.bytes(2)==="\0\0"){e.getBytes(2),t-=2;break}n=e.length(),c.push(Xr(e,t,a+1,r)),t-=n-e.length()}else for(;u>0;)n=e.length(),c.push(Xr(e,u,a+1,r)),t-=n-e.length(),u-=n-e.length();if(c===void 0&&i===U.Class.UNIVERSAL&&o===U.Type.BITSTRING&&(f=e.bytes(u)),c===void 0&&r.decodeBitStrings&&i===U.Class.UNIVERSAL&&o===U.Type.BITSTRING&&u>1){var v=e.read,y=t,x=0;if(o===U.Type.BITSTRING&&(Ar(e,t,1),x=e.getByte(),t--),x===0)try{n=e.length();var S={strict:!0,decodeBitStrings:!0},I=Xr(e,t,a+1,S),B=n-e.length();t-=B,o==U.Type.BITSTRING&&B++;var b=I.tagClass;B===u&&(b===U.Class.UNIVERSAL||b===U.Class.CONTEXT_SPECIFIC)&&(c=[I])}catch{}c===void 0&&(e.read=v,t=y)}if(c===void 0){if(u===void 0){if(r.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");u=t}if(o===U.Type.BMPSTRING)for(c="";u>0;u-=2)Ar(e,t,2),c+=String.fromCharCode(e.getInt16()),t-=2;else c=e.getBytes(u),t-=u}var P=f===void 0?null:{bitStringContents:f};return U.create(i,o,g,c,P)}U.toDer=function(e){var t=de.util.createBuffer(),a=e.tagClass|e.type,r=de.util.createBuffer(),n=!1;if("bitStringContents"in e&&(n=!0,e.original&&(n=U.equals(e,e.original))),n)r.putBytes(e.bitStringContents);else if(e.composed){e.constructed?a|=32:r.putByte(0);for(var s=0;s<e.value.length;++s)e.value[s]!==void 0&&r.putBuffer(U.toDer(e.value[s]))}else if(e.type===U.Type.BMPSTRING)for(var s=0;s<e.value.length;++s)r.putInt16(e.value.charCodeAt(s));else e.type===U.Type.INTEGER&&e.value.length>1&&(e.value.charCodeAt(0)===0&&(e.value.charCodeAt(1)&128)===0||e.value.charCodeAt(0)===255&&(e.value.charCodeAt(1)&128)===128)?r.putBytes(e.value.substr(1)):r.putBytes(e.value);if(t.putByte(a),r.length()<=127)t.putByte(r.length()&127);else{var i=r.length(),o="";do o+=String.fromCharCode(i&255),i=i>>>8;while(i>0);t.putByte(o.length|128);for(var s=o.length-1;s>=0;--s)t.putByte(o.charCodeAt(s))}return t.putBuffer(r),t};U.oidToDer=function(e){var t=e.split("."),a=de.util.createBuffer();a.putByte(40*parseInt(t[0],10)+parseInt(t[1],10));for(var r,n,s,i,o=2;o<t.length;++o){if(r=!0,n=[],s=parseInt(t[o],10),s>4294967295)throw new Error("OID value too large; max is 32-bits.");do i=s&127,s=s>>>7,r||(i|=128),n.push(i),r=!1;while(s>0);for(var u=n.length-1;u>=0;--u)a.putByte(n[u])}return a};U.derToOid=function(e){var t;typeof e=="string"&&(e=de.util.createBuffer(e));var a=e.getByte();t=Math.floor(a/40)+"."+a%40;for(var r=0;e.length()>0;){if(r>70368744177663)throw new Error("OID value too large; max is 53-bits.");a=e.getByte(),r=r*128,a&128?r+=a&127:(t+="."+(r+a),r=0)}return t};U.utcTimeToDate=function(e){var t=new Date,a=parseInt(e.substr(0,2),10);a=a>=50?1900+a:2e3+a;var r=parseInt(e.substr(2,2),10)-1,n=parseInt(e.substr(4,2),10),s=parseInt(e.substr(6,2),10),i=parseInt(e.substr(8,2),10),o=0;if(e.length>11){var u=e.charAt(10),l=10;u!=="+"&&u!=="-"&&(o=parseInt(e.substr(10,2),10),l+=2)}if(t.setUTCFullYear(a,r,n),t.setUTCHours(s,i,o,0),l&&(u=e.charAt(l),u==="+"||u==="-")){var c=parseInt(e.substr(l+1,2),10),f=parseInt(e.substr(l+4,2),10),g=c*60+f;g*=6e4,u==="+"?t.setTime(+t-g):t.setTime(+t+g)}return t};U.generalizedTimeToDate=function(e){var t=new Date,a=parseInt(e.substr(0,4),10),r=parseInt(e.substr(4,2),10)-1,n=parseInt(e.substr(6,2),10),s=parseInt(e.substr(8,2),10),i=parseInt(e.substr(10,2),10),o=parseInt(e.substr(12,2),10),u=0,l=0,c=!1;e.charAt(e.length-1)==="Z"&&(c=!0);var f=e.length-5,g=e.charAt(f);if(g==="+"||g==="-"){var v=parseInt(e.substr(f+1,2),10),y=parseInt(e.substr(f+4,2),10);l=v*60+y,l*=6e4,g==="+"&&(l*=-1),c=!0}return e.charAt(14)==="."&&(u=parseFloat(e.substr(14),10)*1e3),c?(t.setUTCFullYear(a,r,n),t.setUTCHours(s,i,o,u),t.setTime(+t+l)):(t.setFullYear(a,r,n),t.setHours(s,i,o,u)),t};U.dateToUtcTime=function(e){if(typeof e=="string")return e;var t="",a=[];a.push((""+e.getUTCFullYear()).substr(2)),a.push(""+(e.getUTCMonth()+1)),a.push(""+e.getUTCDate()),a.push(""+e.getUTCHours()),a.push(""+e.getUTCMinutes()),a.push(""+e.getUTCSeconds());for(var r=0;r<a.length;++r)a[r].length<2&&(t+="0"),t+=a[r];return t+="Z",t};U.dateToGeneralizedTime=function(e){if(typeof e=="string")return e;var t="",a=[];a.push(""+e.getUTCFullYear()),a.push(""+(e.getUTCMonth()+1)),a.push(""+e.getUTCDate()),a.push(""+e.getUTCHours()),a.push(""+e.getUTCMinutes()),a.push(""+e.getUTCSeconds());for(var r=0;r<a.length;++r)a[r].length<2&&(t+="0"),t+=a[r];return t+="Z",t};U.integerToDer=function(e){var t=de.util.createBuffer();if(e>=-128&&e<128)return t.putSignedInt(e,8);if(e>=-32768&&e<32768)return t.putSignedInt(e,16);if(e>=-8388608&&e<8388608)return t.putSignedInt(e,24);if(e>=-2147483648&&e<2147483648)return t.putSignedInt(e,32);var a=new Error("Integer too large; max is 32-bits.");throw a.integer=e,a};U.derToInteger=function(e){typeof e=="string"&&(e=de.util.createBuffer(e));var t=e.length()*8;if(t>32)throw new Error("Integer too large; max is 32-bits.");return e.getSignedInt(t)};U.validate=function(e,t,a,r){var n=!1;if((e.tagClass===t.tagClass||typeof t.tagClass>"u")&&(e.type===t.type||typeof t.type>"u"))if(e.constructed===t.constructed||typeof t.constructed>"u"){if(n=!0,t.value&&de.util.isArray(t.value))for(var s=0,i=0;n&&i<t.value.length;++i){var o=t.value[i];n=!!o.optional;var u=e.value[s];if(!u){o.optional||(n=!1,r&&r.push("["+t.name+'] Missing required element. Expected tag class "'+o.tagClass+'", type "'+o.type+'"'));continue}var l=typeof o.tagClass<"u"&&typeof o.type<"u";if(l&&(u.tagClass!==o.tagClass||u.type!==o.type))if(o.optional){n=!0;continue}else{n=!1,r&&r.push("["+t.name+"] Tag mismatch. Expected ("+o.tagClass+","+o.type+"), got ("+u.tagClass+","+u.type+")");break}var c=U.validate(u,o,a,r);if(c)++s,n=!0;else if(o.optional)n=!0;else{n=!1;break}}if(n&&a&&(t.capture&&(a[t.capture]=e.value),t.captureAsn1&&(a[t.captureAsn1]=e),t.captureBitStringContents&&"bitStringContents"in e&&(a[t.captureBitStringContents]=e.bitStringContents),t.captureBitStringValue&&"bitStringContents"in e)){var f;if(e.bitStringContents.length<2)a[t.captureBitStringValue]="";else{var g=e.bitStringContents.charCodeAt(0);if(g!==0)throw new Error("captureBitStringValue only supported for zero unused bits");a[t.captureBitStringValue]=e.bitStringContents.slice(1)}}}else r&&r.push("["+t.name+'] Expected constructed "'+t.constructed+'", got "'+e.constructed+'"');else r&&(e.tagClass!==t.tagClass&&r.push("["+t.name+'] Expected tag class "'+t.tagClass+'", got "'+e.tagClass+'"'),e.type!==t.type&&r.push("["+t.name+'] Expected type "'+t.type+'", got "'+e.type+'"'));return n};var di=/[^\\u0000-\\u00ff]/;U.prettyPrint=function(e,t,a){var r="";t=t||0,a=a||2,t>0&&(r+=`
4
+ ${f}`;Ht.writeFileSync(n,v)}catch{}},file:n}}Jn.exports={log:Mu,err:qu,dumpRequest:Qu,createResponseDumper:$u,clearDumpDir:Hu}});var $=F((Sh,Zn)=>{Zn.exports={options:{usePureJavaScript:!1}}});var ri=F((Th,ti)=>{var Na={};ti.exports=Na;var ei={};Na.encode=function(e,t,a){if(typeof t!="string")throw new TypeError('"alphabet" must be a string.');if(a!==void 0&&typeof a!="number")throw new TypeError('"maxline" must be a number.');var r="";if(!(e instanceof Uint8Array))r=Yu(e,t);else{var n=0,s=t.length,i=t.charAt(0),o=[0];for(n=0;n<e.length;++n){for(var u=0,l=e[n];u<o.length;++u)l+=o[u]<<8,o[u]=l%s,l=l/s|0;for(;l>0;)o.push(l%s),l=l/s|0}for(n=0;e[n]===0&&n<e.length-1;++n)r+=i;for(n=o.length-1;n>=0;--n)r+=t[o[n]]}if(a){var c=new RegExp(".{1,"+a+"}","g");r=r.match(c).join(`\r
5
+ `)}return r};Na.decode=function(e,t){if(typeof e!="string")throw new TypeError('"input" must be a string.');if(typeof t!="string")throw new TypeError('"alphabet" must be a string.');var a=ei[t];if(!a){a=ei[t]=[];for(var r=0;r<t.length;++r)a[t.charCodeAt(r)]=r}e=e.replace(/\s/g,"");for(var n=t.length,s=t.charAt(0),i=[0],r=0;r<e.length;r++){var o=a[e.charCodeAt(r)];if(o===void 0)return;for(var u=0,l=o;u<i.length;++u)l+=i[u]*n,i[u]=l&255,l>>=8;for(;l>0;)i.push(l&255),l>>=8}for(var c=0;e[c]===s&&c<e.length-1;++c)i.push(0);return typeof Buffer<"u"?Buffer.from(i.reverse()):new Uint8Array(i.reverse())};function Yu(e,t){var a=0,r=t.length,n=t.charAt(0),s=[0];for(a=0;a<e.length();++a){for(var i=0,o=e.at(a);i<s.length;++i)o+=s[i]<<8,s[i]=o%r,o=o/r|0;for(;o>0;)s.push(o%r),o=o/r|0}var u="";for(a=0;e.at(a)===0&&a<e.length()-1;++a)u+=n;for(a=s.length-1;a>=0;--a)u+=t[s[a]];return u}});var re=F((Ih,si)=>{var ai=$(),ni=ri(),E=si.exports=ai.util=ai.util||{};(function(){if(typeof process<"u"&&process.nextTick&&!process.browser){E.nextTick=process.nextTick,typeof setImmediate=="function"?E.setImmediate=setImmediate:E.setImmediate=E.nextTick;return}if(typeof setImmediate=="function"){E.setImmediate=function(){return setImmediate.apply(void 0,arguments)},E.nextTick=function(o){return setImmediate(o)};return}if(E.setImmediate=function(o){setTimeout(o,0)},typeof window<"u"&&typeof window.postMessage=="function"){let o=function(u){if(u.source===window&&u.data===e){u.stopPropagation();var l=t.slice();t.length=0,l.forEach(function(c){c()})}};var i=o,e="forge.setImmediate",t=[];E.setImmediate=function(u){t.push(u),t.length===1&&window.postMessage(e,"*")},window.addEventListener("message",o,!0)}if(typeof MutationObserver<"u"){var a=Date.now(),r=!0,n=document.createElement("div"),t=[];new MutationObserver(function(){var u=t.slice();t.length=0,u.forEach(function(l){l()})}).observe(n,{attributes:!0});var s=E.setImmediate;E.setImmediate=function(u){Date.now()-a>15?(a=Date.now(),s(u)):(t.push(u),t.length===1&&n.setAttribute("a",r=!r))}}E.nextTick=E.setImmediate})();E.isNodejs=typeof process<"u"&&process.versions&&process.versions.node;E.globalScope=(function(){return E.isNodejs?global:typeof self>"u"?window:self})();E.isArray=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"};E.isArrayBuffer=function(e){return typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer};E.isArrayBufferView=function(e){return e&&E.isArrayBuffer(e.buffer)&&e.byteLength!==void 0};function Ir(e){if(!(e===8||e===16||e===24||e===32))throw new Error("Only 8, 16, 24, or 32 bits supported: "+e)}E.ByteBuffer=Ra;function Ra(e){if(this.data="",this.read=0,typeof e=="string")this.data=e;else if(E.isArrayBuffer(e)||E.isArrayBufferView(e))if(typeof Buffer<"u"&&e instanceof Buffer)this.data=e.toString("binary");else{var t=new Uint8Array(e);try{this.data=String.fromCharCode.apply(null,t)}catch{for(var a=0;a<t.length;++a)this.putByte(t[a])}}else(e instanceof Ra||typeof e=="object"&&typeof e.data=="string"&&typeof e.read=="number")&&(this.data=e.data,this.read=e.read);this._constructedStringLength=0}E.ByteStringBuffer=Ra;var ju=4096;E.ByteStringBuffer.prototype._optimizeConstructedString=function(e){this._constructedStringLength+=e,this._constructedStringLength>ju&&(this.data.substr(0,1),this._constructedStringLength=0)};E.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read};E.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0};E.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))};E.ByteStringBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var a=this.data;t>0;)t&1&&(a+=e),t>>>=1,t>0&&(e+=e);return this.data=a,this._optimizeConstructedString(t),this};E.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this};E.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(E.encodeUtf8(e))};E.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))};E.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))};E.ByteStringBuffer.prototype.putInt32=function(e){return this.putBytes(String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))};E.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255))};E.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))};E.ByteStringBuffer.prototype.putInt32Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))};E.ByteStringBuffer.prototype.putInt=function(e,t){Ir(t);var a="";do t-=8,a+=String.fromCharCode(e>>t&255);while(t>0);return this.putBytes(a)};E.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<<t-1),this.putInt(e,t)};E.ByteStringBuffer.prototype.putBuffer=function(e){return this.putBytes(e.getBytes())};E.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)};E.ByteStringBuffer.prototype.getInt16=function(){var e=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,e};E.ByteStringBuffer.prototype.getInt24=function(){var e=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,e};E.ByteStringBuffer.prototype.getInt32=function(){var e=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,e};E.ByteStringBuffer.prototype.getInt16Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,e};E.ByteStringBuffer.prototype.getInt24Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,e};E.ByteStringBuffer.prototype.getInt32Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24;return this.read+=4,e};E.ByteStringBuffer.prototype.getInt=function(e){Ir(e);var t=0;do t=(t<<8)+this.data.charCodeAt(this.read++),e-=8;while(e>0);return t};E.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),a=2<<e-2;return t>=a&&(t-=a<<1),t};E.ByteStringBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):e===0?t="":(t=this.read===0?this.data:this.data.slice(this.read),this.clear()),t};E.ByteStringBuffer.prototype.bytes=function(e){return typeof e>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+e)};E.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)};E.ByteStringBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this};E.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)};E.ByteStringBuffer.prototype.copy=function(){var e=E.createBuffer(this.data);return e.read=this.read,e};E.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this};E.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this};E.ByteStringBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this};E.ByteStringBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.length;++t){var a=this.data.charCodeAt(t);a<16&&(e+="0"),e+=a.toString(16)}return e};E.ByteStringBuffer.prototype.toString=function(){return E.decodeUtf8(this.bytes())};function Wu(e,t){t=t||{},this.read=t.readOffset||0,this.growSize=t.growSize||1024;var a=E.isArrayBuffer(e),r=E.isArrayBufferView(e);if(a||r){a?this.data=new DataView(e):this.data=new DataView(e.buffer,e.byteOffset,e.byteLength),this.write="writeOffset"in t?t.writeOffset:this.data.byteLength;return}this.data=new DataView(new ArrayBuffer(0)),this.write=0,e!=null&&this.putBytes(e),"writeOffset"in t&&(this.write=t.writeOffset)}E.DataBuffer=Wu;E.DataBuffer.prototype.length=function(){return this.write-this.read};E.DataBuffer.prototype.isEmpty=function(){return this.length()<=0};E.DataBuffer.prototype.accommodate=function(e,t){if(this.length()>=e)return this;t=Math.max(t||this.growSize,e);var a=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),r=new Uint8Array(this.length()+t);return r.set(a),this.data=new DataView(r.buffer),this};E.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this};E.DataBuffer.prototype.fillWithByte=function(e,t){this.accommodate(t);for(var a=0;a<t;++a)this.data.setUint8(e);return this};E.DataBuffer.prototype.putBytes=function(e,t){if(E.isArrayBufferView(e)){var a=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r=a.byteLength-a.byteOffset;this.accommodate(r);var n=new Uint8Array(this.data.buffer,this.write);return n.set(a),this.write+=r,this}if(E.isArrayBuffer(e)){var a=new Uint8Array(e);this.accommodate(a.byteLength);var n=new Uint8Array(this.data.buffer);return n.set(a,this.write),this.write+=a.byteLength,this}if(e instanceof E.DataBuffer||typeof e=="object"&&typeof e.read=="number"&&typeof e.write=="number"&&E.isArrayBufferView(e.data)){var a=new Uint8Array(e.data.byteLength,e.read,e.length());this.accommodate(a.byteLength);var n=new Uint8Array(e.data.byteLength,this.write);return n.set(a),this.write+=a.byteLength,this}if(e instanceof E.ByteStringBuffer&&(e=e.data,t="binary"),t=t||"binary",typeof e=="string"){var s;if(t==="hex")return this.accommodate(Math.ceil(e.length/2)),s=new Uint8Array(this.data.buffer,this.write),this.write+=E.binary.hex.decode(e,s,this.write),this;if(t==="base64")return this.accommodate(Math.ceil(e.length/4)*3),s=new Uint8Array(this.data.buffer,this.write),this.write+=E.binary.base64.decode(e,s,this.write),this;if(t==="utf8"&&(e=E.encodeUtf8(e),t="binary"),t==="binary"||t==="raw")return this.accommodate(e.length),s=new Uint8Array(this.data.buffer,this.write),this.write+=E.binary.raw.decode(s),this;if(t==="utf16")return this.accommodate(e.length*2),s=new Uint16Array(this.data.buffer,this.write),this.write+=E.text.utf16.encode(s),this;throw new Error("Invalid encoding: "+t)}throw Error("Invalid parameter: "+e)};E.DataBuffer.prototype.putBuffer=function(e){return this.putBytes(e),e.clear(),this};E.DataBuffer.prototype.putString=function(e){return this.putBytes(e,"utf16")};E.DataBuffer.prototype.putInt16=function(e){return this.accommodate(2),this.data.setInt16(this.write,e),this.write+=2,this};E.DataBuffer.prototype.putInt24=function(e){return this.accommodate(3),this.data.setInt16(this.write,e>>8&65535),this.data.setInt8(this.write,e>>16&255),this.write+=3,this};E.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this};E.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this};E.DataBuffer.prototype.putInt24Le=function(e){return this.accommodate(3),this.data.setInt8(this.write,e>>16&255),this.data.setInt16(this.write,e>>8&65535,!0),this.write+=3,this};E.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this};E.DataBuffer.prototype.putInt=function(e,t){Ir(t),this.accommodate(t/8);do t-=8,this.data.setInt8(this.write++,e>>t&255);while(t>0);return this};E.DataBuffer.prototype.putSignedInt=function(e,t){return Ir(t),this.accommodate(t/8),e<0&&(e+=2<<t-1),this.putInt(e,t)};E.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)};E.DataBuffer.prototype.getInt16=function(){var e=this.data.getInt16(this.read);return this.read+=2,e};E.DataBuffer.prototype.getInt24=function(){var e=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,e};E.DataBuffer.prototype.getInt32=function(){var e=this.data.getInt32(this.read);return this.read+=4,e};E.DataBuffer.prototype.getInt16Le=function(){var e=this.data.getInt16(this.read,!0);return this.read+=2,e};E.DataBuffer.prototype.getInt24Le=function(){var e=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,e};E.DataBuffer.prototype.getInt32Le=function(){var e=this.data.getInt32(this.read,!0);return this.read+=4,e};E.DataBuffer.prototype.getInt=function(e){Ir(e);var t=0;do t=(t<<8)+this.data.getInt8(this.read++),e-=8;while(e>0);return t};E.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),a=2<<e-2;return t>=a&&(t-=a<<1),t};E.DataBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):e===0?t="":(t=this.read===0?this.data:this.data.slice(this.read),this.clear()),t};E.DataBuffer.prototype.bytes=function(e){return typeof e>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+e)};E.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)};E.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this};E.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)};E.DataBuffer.prototype.copy=function(){return new E.DataBuffer(this)};E.DataBuffer.prototype.compact=function(){if(this.read>0){var e=new Uint8Array(this.data.buffer,this.read),t=new Uint8Array(e.byteLength);t.set(e),this.data=new DataView(t),this.write-=this.read,this.read=0}return this};E.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this};E.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this};E.DataBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.byteLength;++t){var a=this.data.getUint8(t);a<16&&(e+="0"),e+=a.toString(16)}return e};E.DataBuffer.prototype.toString=function(e){var t=new Uint8Array(this.data,this.read,this.length());if(e=e||"utf8",e==="binary"||e==="raw")return E.binary.raw.encode(t);if(e==="hex")return E.binary.hex.encode(t);if(e==="base64")return E.binary.base64.encode(t);if(e==="utf8")return E.text.utf8.decode(t);if(e==="utf16")return E.text.utf16.decode(t);throw new Error("Invalid encoding: "+e)};E.createBuffer=function(e,t){return t=t||"raw",e!==void 0&&t==="utf8"&&(e=E.encodeUtf8(e)),new E.ByteBuffer(e)};E.fillString=function(e,t){for(var a="";t>0;)t&1&&(a+=e),t>>>=1,t>0&&(e+=e);return a};E.xorBytes=function(e,t,a){for(var r="",n="",s="",i=0,o=0;a>0;--a,++i)n=e.charCodeAt(i)^t.charCodeAt(i),o>=10&&(r+=s,s="",o=0),s+=String.fromCharCode(n),++o;return r+=s,r};E.hexToBytes=function(e){var t="",a=0;for(e.length&!0&&(a=1,t+=String.fromCharCode(parseInt(e[0],16)));a<e.length;a+=2)t+=String.fromCharCode(parseInt(e.substr(a,2),16));return t};E.bytesToHex=function(e){return E.createBuffer(e).toHex()};E.int32ToBytes=function(e){return String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255)};var wt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Nt=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],ii="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";E.encode64=function(e,t){for(var a="",r="",n,s,i,o=0;o<e.length;)n=e.charCodeAt(o++),s=e.charCodeAt(o++),i=e.charCodeAt(o++),a+=wt.charAt(n>>2),a+=wt.charAt((n&3)<<4|s>>4),isNaN(s)?a+="==":(a+=wt.charAt((s&15)<<2|i>>6),a+=isNaN(i)?"=":wt.charAt(i&63)),t&&a.length>t&&(r+=a.substr(0,t)+`\r
6
+ `,a=a.substr(t));return r+=a,r};E.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t="",a,r,n,s,i=0;i<e.length;)a=Nt[e.charCodeAt(i++)-43],r=Nt[e.charCodeAt(i++)-43],n=Nt[e.charCodeAt(i++)-43],s=Nt[e.charCodeAt(i++)-43],t+=String.fromCharCode(a<<2|r>>4),n!==64&&(t+=String.fromCharCode((r&15)<<4|n>>2),s!==64&&(t+=String.fromCharCode((n&3)<<6|s)));return t};E.encodeUtf8=function(e){return unescape(encodeURIComponent(e))};E.decodeUtf8=function(e){return decodeURIComponent(escape(e))};E.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:ni.encode,decode:ni.decode}};E.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)};E.binary.raw.decode=function(e,t,a){var r=t;r||(r=new Uint8Array(e.length)),a=a||0;for(var n=a,s=0;s<e.length;++s)r[n++]=e.charCodeAt(s);return t?n-a:r};E.binary.hex.encode=E.bytesToHex;E.binary.hex.decode=function(e,t,a){var r=t;r||(r=new Uint8Array(Math.ceil(e.length/2))),a=a||0;var n=0,s=a;for(e.length&1&&(n=1,r[s++]=parseInt(e[0],16));n<e.length;n+=2)r[s++]=parseInt(e.substr(n,2),16);return t?s-a:r};E.binary.base64.encode=function(e,t){for(var a="",r="",n,s,i,o=0;o<e.byteLength;)n=e[o++],s=e[o++],i=e[o++],a+=wt.charAt(n>>2),a+=wt.charAt((n&3)<<4|s>>4),isNaN(s)?a+="==":(a+=wt.charAt((s&15)<<2|i>>6),a+=isNaN(i)?"=":wt.charAt(i&63)),t&&a.length>t&&(r+=a.substr(0,t)+`\r
7
+ `,a=a.substr(t));return r+=a,r};E.binary.base64.decode=function(e,t,a){var r=t;r||(r=new Uint8Array(Math.ceil(e.length/4)*3)),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,""),a=a||0;for(var n,s,i,o,u=0,l=a;u<e.length;)n=Nt[e.charCodeAt(u++)-43],s=Nt[e.charCodeAt(u++)-43],i=Nt[e.charCodeAt(u++)-43],o=Nt[e.charCodeAt(u++)-43],r[l++]=n<<2|s>>4,i!==64&&(r[l++]=(s&15)<<4|i>>2,o!==64&&(r[l++]=(i&3)<<6|o));return t?l-a:r.subarray(0,l)};E.binary.base58.encode=function(e,t){return E.binary.baseN.encode(e,ii,t)};E.binary.base58.decode=function(e,t){return E.binary.baseN.decode(e,ii,t)};E.text={utf8:{},utf16:{}};E.text.utf8.encode=function(e,t,a){e=E.encodeUtf8(e);var r=t;r||(r=new Uint8Array(e.length)),a=a||0;for(var n=a,s=0;s<e.length;++s)r[n++]=e.charCodeAt(s);return t?n-a:r};E.text.utf8.decode=function(e){return E.decodeUtf8(String.fromCharCode.apply(null,e))};E.text.utf16.encode=function(e,t,a){var r=t;r||(r=new Uint8Array(e.length*2));var n=new Uint16Array(r.buffer);a=a||0;for(var s=a,i=a,o=0;o<e.length;++o)n[i++]=e.charCodeAt(o),s+=2;return t?s-a:r};E.text.utf16.decode=function(e){return String.fromCharCode.apply(null,new Uint16Array(e.buffer))};E.deflate=function(e,t,a){if(t=E.decode64(e.deflate(E.encode64(t)).rval),a){var r=2,n=t.charCodeAt(1);n&32&&(r=6),t=t.substring(r,t.length-4)}return t};E.inflate=function(e,t,a){var r=e.inflate(E.encode64(t)).rval;return r===null?null:E.decode64(r)};var La=function(e,t,a){if(!e)throw new Error("WebStorage not available.");var r;if(a===null?r=e.removeItem(t):(a=E.encode64(JSON.stringify(a)),r=e.setItem(t,a)),typeof r<"u"&&r.rval!==!0){var n=new Error(r.error.message);throw n.id=r.error.id,n.name=r.error.name,n}},ka=function(e,t){if(!e)throw new Error("WebStorage not available.");var a=e.getItem(t);if(e.init)if(a.rval===null){if(a.error){var r=new Error(a.error.message);throw r.id=a.error.id,r.name=a.error.name,r}a=null}else a=a.rval;return a!==null&&(a=JSON.parse(E.decode64(a))),a},Xu=function(e,t,a,r){var n=ka(e,t);n===null&&(n={}),n[a]=r,La(e,t,n)},Ju=function(e,t,a){var r=ka(e,t);return r!==null&&(r=a in r?r[a]:null),r},Zu=function(e,t,a){var r=ka(e,t);if(r!==null&&a in r){delete r[a];var n=!0;for(var s in r){n=!1;break}n&&(r=null),La(e,t,r)}},e0=function(e,t){La(e,t,null)},$r=function(e,t,a){var r=null;typeof a>"u"&&(a=["web","flash"]);var n,s=!1,i=null;for(var o in a){n=a[o];try{if(n==="flash"||n==="both"){if(t[0]===null)throw new Error("Flash local storage not available.");r=e.apply(this,t),s=n==="flash"}(n==="web"||n==="both")&&(t[0]=localStorage,r=e.apply(this,t),s=!0)}catch(u){i=u}if(s)break}if(!s)throw i;return r};E.setItem=function(e,t,a,r,n){$r(Xu,arguments,n)};E.getItem=function(e,t,a,r){return $r(Ju,arguments,r)};E.removeItem=function(e,t,a,r){$r(Zu,arguments,r)};E.clearItems=function(e,t,a){$r(e0,arguments,a)};E.isEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0};E.format=function(e){for(var t=/%./g,a,r,n=0,s=[],i=0;a=t.exec(e);){r=e.substring(i,t.lastIndex-2),r.length>0&&s.push(r),i=t.lastIndex;var o=a[0][1];switch(o){case"s":case"o":n<arguments.length?s.push(arguments[n+++1]):s.push("<?>");break;case"%":s.push("%");break;default:s.push("<%"+o+"?>")}}return s.push(e.substring(i)),s.join("")};E.formatNumber=function(e,t,a,r){var n=e,s=isNaN(t=Math.abs(t))?2:t,i=a===void 0?",":a,o=r===void 0?".":r,u=n<0?"-":"",l=parseInt(n=Math.abs(+n||0).toFixed(s),10)+"",c=l.length>3?l.length%3:0;return u+(c?l.substr(0,c)+o:"")+l.substr(c).replace(/(\d{3})(?=\d)/g,"$1"+o)+(s?i+Math.abs(n-l).toFixed(s).slice(2):"")};E.formatSize=function(e){return e>=1073741824?e=E.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?e=E.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?e=E.formatNumber(e/1024,0)+" KiB":e=E.formatNumber(e,0)+" bytes",e};E.bytesFromIP=function(e){return e.indexOf(".")!==-1?E.bytesFromIPv4(e):e.indexOf(":")!==-1?E.bytesFromIPv6(e):null};E.bytesFromIPv4=function(e){if(e=e.split("."),e.length!==4)return null;for(var t=E.createBuffer(),a=0;a<e.length;++a){var r=parseInt(e[a],10);if(isNaN(r))return null;t.putByte(r)}return t.getBytes()};E.bytesFromIPv6=function(e){var t=0;e=e.split(":").filter(function(i){return i.length===0&&++t,!0});for(var a=(8-e.length+t)*2,r=E.createBuffer(),n=0;n<8;++n){if(!e[n]||e[n].length===0){r.fillWithByte(0,a),a=0;continue}var s=E.hexToBytes(e[n]);s.length<2&&r.putByte(0),r.putBytes(s)}return r.getBytes()};E.bytesToIP=function(e){return e.length===4?E.bytesToIPv4(e):e.length===16?E.bytesToIPv6(e):null};E.bytesToIPv4=function(e){if(e.length!==4)return null;for(var t=[],a=0;a<e.length;++a)t.push(e.charCodeAt(a));return t.join(".")};E.bytesToIPv6=function(e){if(e.length!==16)return null;for(var t=[],a=[],r=0,n=0;n<e.length;n+=2){for(var s=E.bytesToHex(e[n]+e[n+1]);s[0]==="0"&&s!=="0";)s=s.substr(1);if(s==="0"){var i=a[a.length-1],o=t.length;!i||o!==i.end+1?a.push({start:o,end:o}):(i.end=o,i.end-i.start>a[r].end-a[r].start&&(r=a.length-1))}t.push(s)}if(a.length>0){var u=a[r];u.end-u.start>0&&(t.splice(u.start,u.end-u.start+1,""),u.start===0&&t.unshift(""),u.end===7&&t.push(""))}return t.join(":")};E.estimateCores=function(e,t){if(typeof e=="function"&&(t=e,e={}),e=e||{},"cores"in E&&!e.update)return t(null,E.cores);if(typeof navigator<"u"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return E.cores=navigator.hardwareConcurrency,t(null,E.cores);if(typeof Worker>"u")return E.cores=1,t(null,E.cores);if(typeof Blob>"u")return E.cores=2,t(null,E.cores);var a=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",function(i){for(var o=Date.now(),u=o+4;Date.now()<u;);self.postMessage({st:o,et:u})})}.toString(),")()"],{type:"application/javascript"}));r([],5,16);function r(i,o,u){if(o===0){var l=Math.floor(i.reduce(function(c,f){return c+f},0)/i.length);return E.cores=Math.max(1,l),URL.revokeObjectURL(a),t(null,E.cores)}n(u,function(c,f){i.push(s(u,f)),r(i,o-1,u)})}function n(i,o){for(var u=[],l=[],c=0;c<i;++c){var f=new Worker(a);f.addEventListener("message",function(g){if(l.push(g.data),l.length===i){for(var v=0;v<i;++v)u[v].terminate();o(null,l)}}),u.push(f)}for(var c=0;c<i;++c)u[c].postMessage(c)}function s(i,o){for(var u=[],l=0;l<i;++l)for(var c=o[l],f=u[l]=[],g=0;g<i;++g)if(l!==g){var v=o[g];(c.st>v.st&&c.st<v.et||v.st>c.st&&v.st<c.et)&&f.push(g)}return u.reduce(function(y,x){return Math.max(y,x.length)},0)}}});var Yr=F((Ah,oi)=>{var xe=$();re();oi.exports=xe.cipher=xe.cipher||{};xe.cipher.algorithms=xe.cipher.algorithms||{};xe.cipher.createCipher=function(e,t){var a=e;if(typeof a=="string"&&(a=xe.cipher.getAlgorithm(a),a&&(a=a())),!a)throw new Error("Unsupported algorithm: "+e);return new xe.cipher.BlockCipher({algorithm:a,key:t,decrypt:!1})};xe.cipher.createDecipher=function(e,t){var a=e;if(typeof a=="string"&&(a=xe.cipher.getAlgorithm(a),a&&(a=a())),!a)throw new Error("Unsupported algorithm: "+e);return new xe.cipher.BlockCipher({algorithm:a,key:t,decrypt:!0})};xe.cipher.registerAlgorithm=function(e,t){e=e.toUpperCase(),xe.cipher.algorithms[e]=t};xe.cipher.getAlgorithm=function(e){return e=e.toUpperCase(),e in xe.cipher.algorithms?xe.cipher.algorithms[e]:null};var Da=xe.cipher.BlockCipher=function(e){this.algorithm=e.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=e.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=e.decrypt,this.algorithm.initialize(e)};Da.prototype.start=function(e){e=e||{};var t={};for(var a in e)t[a]=e[a];t.decrypt=this._decrypt,this._finish=!1,this._input=xe.util.createBuffer(),this.output=e.output||xe.util.createBuffer(),this.mode.start(t)};Da.prototype.update=function(e){for(e&&this._input.putBuffer(e);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()};Da.prototype.finish=function(e){e&&(this.mode.name==="ECB"||this.mode.name==="CBC")&&(this.mode.pad=function(a){return e(this.blockSize,a,!1)},this.mode.unpad=function(a){return e(this.blockSize,a,!0)});var t={};return t.decrypt=this._decrypt,t.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,t)||(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,t))||this.mode.afterFinish&&!this.mode.afterFinish(this.output,t))}});var Pa=F((Bh,ui)=>{var Se=$();re();Se.cipher=Se.cipher||{};var j=ui.exports=Se.cipher.modes=Se.cipher.modes||{};j.ecb=function(e){e=e||{},this.name="ECB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)};j.ecb.prototype.start=function(e){};j.ecb.prototype.encrypt=function(e,t,a){if(e.length()<this.blockSize&&!(a&&e.length()>0))return!0;for(var r=0;r<this._ints;++r)this._inBlock[r]=e.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var r=0;r<this._ints;++r)t.putInt32(this._outBlock[r])};j.ecb.prototype.decrypt=function(e,t,a){if(e.length()<this.blockSize&&!(a&&e.length()>0))return!0;for(var r=0;r<this._ints;++r)this._inBlock[r]=e.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var r=0;r<this._ints;++r)t.putInt32(this._outBlock[r])};j.ecb.prototype.pad=function(e,t){var a=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(a,a),!0};j.ecb.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var a=e.length(),r=e.at(a-1);return r>this.blockSize<<2?!1:(e.truncate(r),!0)};j.cbc=function(e){e=e||{},this.name="CBC",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)};j.cbc.prototype.start=function(e){if(e.iv===null){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else if("iv"in e)this._iv=jr(e.iv,this.blockSize),this._prev=this._iv.slice(0);else throw new Error("Invalid IV parameter.")};j.cbc.prototype.encrypt=function(e,t,a){if(e.length()<this.blockSize&&!(a&&e.length()>0))return!0;for(var r=0;r<this._ints;++r)this._inBlock[r]=this._prev[r]^e.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var r=0;r<this._ints;++r)t.putInt32(this._outBlock[r]);this._prev=this._outBlock};j.cbc.prototype.decrypt=function(e,t,a){if(e.length()<this.blockSize&&!(a&&e.length()>0))return!0;for(var r=0;r<this._ints;++r)this._inBlock[r]=e.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var r=0;r<this._ints;++r)t.putInt32(this._prev[r]^this._outBlock[r]);this._prev=this._inBlock.slice(0)};j.cbc.prototype.pad=function(e,t){var a=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(a,a),!0};j.cbc.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var a=e.length(),r=e.at(a-1);return r>this.blockSize<<2?!1:(e.truncate(r),!0)};j.cfb=function(e){e=e||{},this.name="CFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=Se.util.createBuffer(),this._partialBytes=0};j.cfb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=jr(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};j.cfb.prototype.encrypt=function(e,t,a){var r=e.length();if(r===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize){for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32()^this._outBlock[n],t.putInt32(this._inBlock[n]);return}var s=(this.blockSize-r)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialBlock[n]=e.getInt32()^this._outBlock[n],this._partialOutput.putInt32(this._partialBlock[n]);if(s>0)e.read-=this.blockSize;else for(var n=0;n<this._ints;++n)this._inBlock[n]=this._partialBlock[n];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!a)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0};j.cfb.prototype.decrypt=function(e,t,a){var r=e.length();if(r===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize){for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32(),t.putInt32(this._inBlock[n]^this._outBlock[n]);return}var s=(this.blockSize-r)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialBlock[n]=e.getInt32(),this._partialOutput.putInt32(this._partialBlock[n]^this._outBlock[n]);if(s>0)e.read-=this.blockSize;else for(var n=0;n<this._ints;++n)this._inBlock[n]=this._partialBlock[n];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!a)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0};j.ofb=function(e){e=e||{},this.name="OFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=Se.util.createBuffer(),this._partialBytes=0};j.ofb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=jr(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};j.ofb.prototype.encrypt=function(e,t,a){var r=e.length();if(e.length()===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize){for(var n=0;n<this._ints;++n)t.putInt32(e.getInt32()^this._outBlock[n]),this._inBlock[n]=this._outBlock[n];return}var s=(this.blockSize-r)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialOutput.putInt32(e.getInt32()^this._outBlock[n]);if(s>0)e.read-=this.blockSize;else for(var n=0;n<this._ints;++n)this._inBlock[n]=this._outBlock[n];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!a)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0};j.ofb.prototype.decrypt=j.ofb.prototype.encrypt;j.ctr=function(e){e=e||{},this.name="CTR",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=Se.util.createBuffer(),this._partialBytes=0};j.ctr.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=jr(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};j.ctr.prototype.encrypt=function(e,t,a){var r=e.length();if(r===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize)for(var n=0;n<this._ints;++n)t.putInt32(e.getInt32()^this._outBlock[n]);else{var s=(this.blockSize-r)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialOutput.putInt32(e.getInt32()^this._outBlock[n]);if(s>0&&(e.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!a)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0}Wr(this._inBlock)};j.ctr.prototype.decrypt=j.ctr.prototype.encrypt;j.gcm=function(e){e=e||{},this.name="GCM",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=Se.util.createBuffer(),this._partialBytes=0,this._R=3774873600};j.gcm.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");var t=Se.util.createBuffer(e.iv);this._cipherLength=0;var a;if("additionalData"in e?a=Se.util.createBuffer(e.additionalData):a=Se.util.createBuffer(),"tagLength"in e?this._tagLength=e.tagLength:this._tagLength=128,this._tag=null,e.decrypt&&(this._tag=Se.util.createBuffer(e.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var r=t.length();if(r===12)this._j0=[t.getInt32(),t.getInt32(),t.getInt32(),1];else{for(this._j0=[0,0,0,0];t.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[t.getInt32(),t.getInt32(),t.getInt32(),t.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(Ua(r*8)))}this._inBlock=this._j0.slice(0),Wr(this._inBlock),this._partialBytes=0,a=Se.util.createBuffer(a),this._aDataLength=Ua(a.length()*8);var n=a.length()%this.blockSize;for(n&&a.fillWithByte(0,this.blockSize-n),this._s=[0,0,0,0];a.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[a.getInt32(),a.getInt32(),a.getInt32(),a.getInt32()])};j.gcm.prototype.encrypt=function(e,t,a){var r=e.length();if(r===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize){for(var n=0;n<this._ints;++n)t.putInt32(this._outBlock[n]^=e.getInt32());this._cipherLength+=this.blockSize}else{var s=(this.blockSize-r)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialOutput.putInt32(e.getInt32()^this._outBlock[n]);if(s<=0||a){if(a){var i=r%this.blockSize;this._cipherLength+=i,this._partialOutput.truncate(this.blockSize-i)}else this._cipherLength+=this.blockSize;for(var n=0;n<this._ints;++n)this._outBlock[n]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!a)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),Wr(this._inBlock)};j.gcm.prototype.decrypt=function(e,t,a){var r=e.length();if(r<this.blockSize&&!(a&&r>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),Wr(this._inBlock),this._hashBlock[0]=e.getInt32(),this._hashBlock[1]=e.getInt32(),this._hashBlock[2]=e.getInt32(),this._hashBlock[3]=e.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var n=0;n<this._ints;++n)t.putInt32(this._outBlock[n]^this._hashBlock[n]);r<this.blockSize?this._cipherLength+=r%this.blockSize:this._cipherLength+=this.blockSize};j.gcm.prototype.afterFinish=function(e,t){var a=!0;t.decrypt&&t.overflow&&e.truncate(this.blockSize-t.overflow),this.tag=Se.util.createBuffer();var r=this._aDataLength.concat(Ua(this._cipherLength*8));this._s=this.ghash(this._hashSubkey,this._s,r);var n=[];this.cipher.encrypt(this._j0,n);for(var s=0;s<this._ints;++s)this.tag.putInt32(this._s[s]^n[s]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),t.decrypt&&this.tag.bytes()!==this._tag&&(a=!1),a};j.gcm.prototype.multiply=function(e,t){for(var a=[0,0,0,0],r=t.slice(0),n=0;n<128;++n){var s=e[n/32|0]&1<<31-n%32;s&&(a[0]^=r[0],a[1]^=r[1],a[2]^=r[2],a[3]^=r[3]),this.pow(r,r)}return a};j.gcm.prototype.pow=function(e,t){for(var a=e[3]&1,r=3;r>0;--r)t[r]=e[r]>>>1|(e[r-1]&1)<<31;t[0]=e[0]>>>1,a&&(t[0]^=this._R)};j.gcm.prototype.tableMultiply=function(e){for(var t=[0,0,0,0],a=0;a<32;++a){var r=a/8|0,n=e[r]>>>(7-a%8)*4&15,s=this._m[a][n];t[0]^=s[0],t[1]^=s[1],t[2]^=s[2],t[3]^=s[3]}return t};j.gcm.prototype.ghash=function(e,t,a){return t[0]^=a[0],t[1]^=a[1],t[2]^=a[2],t[3]^=a[3],this.tableMultiply(t)};j.gcm.prototype.generateHashTable=function(e,t){for(var a=8/t,r=4*a,n=16*a,s=new Array(n),i=0;i<n;++i){var o=[0,0,0,0],u=i/r|0,l=(r-1-i%r)*t;o[u]=1<<t-1<<l,s[i]=this.generateSubHashTable(this.multiply(o,e),t)}return s};j.gcm.prototype.generateSubHashTable=function(e,t){var a=1<<t,r=a>>>1,n=new Array(a);n[r]=e.slice(0);for(var s=r>>>1;s>0;)this.pow(n[2*s],n[s]=[]),s>>=1;for(s=2;s<r;){for(var i=1;i<s;++i){var o=n[s],u=n[i];n[s+i]=[o[0]^u[0],o[1]^u[1],o[2]^u[2],o[3]^u[3]]}s*=2}for(n[0]=[0,0,0,0],s=r+1;s<a;++s){var l=n[s^r];n[s]=[e[0]^l[0],e[1]^l[1],e[2]^l[2],e[3]^l[3]]}return n};function jr(e,t){if(typeof e=="string"&&(e=Se.util.createBuffer(e)),Se.util.isArray(e)&&e.length>4){var a=e;e=Se.util.createBuffer();for(var r=0;r<a.length;++r)e.putByte(a[r])}if(e.length()<t)throw new Error("Invalid IV length; got "+e.length()+" bytes and expected "+t+" bytes.");if(!Se.util.isArray(e)){for(var n=[],s=t/4,r=0;r<s;++r)n.push(e.getInt32());e=n}return e}function Wr(e){e[e.length-1]=e[e.length-1]+1&4294967295}function Ua(e){return[e/4294967296|0,e&4294967295]}});var Rt=F((bh,di)=>{var le=$();Yr();Pa();re();di.exports=le.aes=le.aes||{};le.aes.startEncrypting=function(e,t,a,r){var n=Xr({key:e,output:a,decrypt:!1,mode:r});return n.start(t),n};le.aes.createEncryptionCipher=function(e,t){return Xr({key:e,output:null,decrypt:!1,mode:t})};le.aes.startDecrypting=function(e,t,a,r){var n=Xr({key:e,output:a,decrypt:!0,mode:r});return n.start(t),n};le.aes.createDecryptionCipher=function(e,t){return Xr({key:e,output:null,decrypt:!0,mode:t})};le.aes.Algorithm=function(e,t){Fa||ci();var a=this;a.name=e,a.mode=new t({blockSize:16,cipher:{encrypt:function(r,n){return Va(a._w,r,n,!1)},decrypt:function(r,n){return Va(a._w,r,n,!0)}}}),a._init=!1};le.aes.Algorithm.prototype.initialize=function(e){if(!this._init){var t=e.key,a;if(typeof t=="string"&&(t.length===16||t.length===24||t.length===32))t=le.util.createBuffer(t);else if(le.util.isArray(t)&&(t.length===16||t.length===24||t.length===32)){a=t,t=le.util.createBuffer();for(var r=0;r<a.length;++r)t.putByte(a[r])}if(!le.util.isArray(t)){a=t,t=[];var n=a.length();if(n===16||n===24||n===32){n=n>>>2;for(var r=0;r<n;++r)t.push(a.getInt32())}}if(!le.util.isArray(t)||!(t.length===4||t.length===6||t.length===8))throw new Error("Invalid key parameter.");var s=this.mode.name,i=["CFB","OFB","CTR","GCM"].indexOf(s)!==-1;this._w=fi(t,e.decrypt&&!i),this._init=!0}};le.aes._expandKey=function(e,t){return Fa||ci(),fi(e,t)};le.aes._updateBlock=Va;sr("AES-ECB",le.cipher.modes.ecb);sr("AES-CBC",le.cipher.modes.cbc);sr("AES-CFB",le.cipher.modes.cfb);sr("AES-OFB",le.cipher.modes.ofb);sr("AES-CTR",le.cipher.modes.ctr);sr("AES-GCM",le.cipher.modes.gcm);function sr(e,t){var a=function(){return new le.aes.Algorithm(e,t)};le.cipher.registerAlgorithm(e,a)}var Fa=!1,ir=4,He,Oa,li,zt,ut;function ci(){Fa=!0,li=[0,1,2,4,8,16,32,64,128,27,54];for(var e=new Array(256),t=0;t<128;++t)e[t]=t<<1,e[t+128]=t+128<<1^283;He=new Array(256),Oa=new Array(256),zt=new Array(4),ut=new Array(4);for(var t=0;t<4;++t)zt[t]=new Array(256),ut[t]=new Array(256);for(var a=0,r=0,n,s,i,o,u,l,c,t=0;t<256;++t){o=r^r<<1^r<<2^r<<3^r<<4,o=o>>8^o&255^99,He[a]=o,Oa[o]=a,u=e[o],n=e[a],s=e[n],i=e[s],l=u<<24^o<<16^o<<8^(o^u),c=(n^s^i)<<24^(a^i)<<16^(a^s^i)<<8^(a^n^i);for(var f=0;f<4;++f)zt[f][a]=l,ut[f][o]=c,l=l<<24|l>>>8,c=c<<24|c>>>8;a===0?a=r=1:(a=n^e[e[e[n^i]]],r^=e[e[r]])}}function fi(e,t){for(var a=e.slice(0),r,n=1,s=a.length,i=s+6+1,o=ir*i,u=s;u<o;++u)r=a[u-1],u%s===0?(r=He[r>>>16&255]<<24^He[r>>>8&255]<<16^He[r&255]<<8^He[r>>>24]^li[n]<<24,n++):s>6&&u%s===4&&(r=He[r>>>24]<<24^He[r>>>16&255]<<16^He[r>>>8&255]<<8^He[r&255]),a[u]=a[u-s]^r;if(t){var l,c=ut[0],f=ut[1],g=ut[2],v=ut[3],y=a.slice(0);o=a.length;for(var u=0,x=o-ir;u<o;u+=ir,x-=ir)if(u===0||u===o-ir)y[u]=a[x],y[u+1]=a[x+3],y[u+2]=a[x+2],y[u+3]=a[x+1];else for(var S=0;S<ir;++S)l=a[x+S],y[u+(3&-S)]=c[He[l>>>24]]^f[He[l>>>16&255]]^g[He[l>>>8&255]]^v[He[l&255]];a=y}return a}function Va(e,t,a,r){var n=e.length/4-1,s,i,o,u,l;r?(s=ut[0],i=ut[1],o=ut[2],u=ut[3],l=Oa):(s=zt[0],i=zt[1],o=zt[2],u=zt[3],l=He);var c,f,g,v,y,x,S;c=t[0]^e[0],f=t[r?3:1]^e[1],g=t[2]^e[2],v=t[r?1:3]^e[3];for(var T=3,B=1;B<n;++B)y=s[c>>>24]^i[f>>>16&255]^o[g>>>8&255]^u[v&255]^e[++T],x=s[f>>>24]^i[g>>>16&255]^o[v>>>8&255]^u[c&255]^e[++T],S=s[g>>>24]^i[v>>>16&255]^o[c>>>8&255]^u[f&255]^e[++T],v=s[v>>>24]^i[c>>>16&255]^o[f>>>8&255]^u[g&255]^e[++T],c=y,f=x,g=S;a[0]=l[c>>>24]<<24^l[f>>>16&255]<<16^l[g>>>8&255]<<8^l[v&255]^e[++T],a[r?3:1]=l[f>>>24]<<24^l[g>>>16&255]<<16^l[v>>>8&255]<<8^l[c&255]^e[++T],a[2]=l[g>>>24]<<24^l[v>>>16&255]<<16^l[c>>>8&255]<<8^l[f&255]^e[++T],a[r?1:3]=l[v>>>24]<<24^l[c>>>16&255]<<16^l[f>>>8&255]<<8^l[g&255]^e[++T]}function Xr(e){e=e||{};var t=(e.mode||"CBC").toUpperCase(),a="AES-"+t,r;e.decrypt?r=le.cipher.createDecipher(a,e.key):r=le.cipher.createCipher(a,e.key);var n=r.start;return r.start=function(s,i){var o=null;i instanceof le.util.ByteBuffer&&(o=i,i={}),i=i||{},i.output=o,i.iv=s,n.call(r,i)},r}});var Lt=F((_h,hi)=>{var Ar=$();Ar.pki=Ar.pki||{};var Ka=hi.exports=Ar.pki.oids=Ar.oids=Ar.oids||{};function N(e,t){Ka[e]=t,Ka[t]=e}function ae(e,t){Ka[e]=t}N("1.2.840.113549.1.1.1","rsaEncryption");N("1.2.840.113549.1.1.4","md5WithRSAEncryption");N("1.2.840.113549.1.1.5","sha1WithRSAEncryption");N("1.2.840.113549.1.1.7","RSAES-OAEP");N("1.2.840.113549.1.1.8","mgf1");N("1.2.840.113549.1.1.9","pSpecified");N("1.2.840.113549.1.1.10","RSASSA-PSS");N("1.2.840.113549.1.1.11","sha256WithRSAEncryption");N("1.2.840.113549.1.1.12","sha384WithRSAEncryption");N("1.2.840.113549.1.1.13","sha512WithRSAEncryption");N("1.3.101.112","EdDSA25519");N("1.2.840.10040.4.3","dsa-with-sha1");N("1.3.14.3.2.7","desCBC");N("1.3.14.3.2.26","sha1");N("1.3.14.3.2.29","sha1WithRSASignature");N("2.16.840.1.101.3.4.2.1","sha256");N("2.16.840.1.101.3.4.2.2","sha384");N("2.16.840.1.101.3.4.2.3","sha512");N("2.16.840.1.101.3.4.2.4","sha224");N("2.16.840.1.101.3.4.2.5","sha512-224");N("2.16.840.1.101.3.4.2.6","sha512-256");N("1.2.840.113549.2.2","md2");N("1.2.840.113549.2.5","md5");N("1.2.840.113549.1.7.1","data");N("1.2.840.113549.1.7.2","signedData");N("1.2.840.113549.1.7.3","envelopedData");N("1.2.840.113549.1.7.4","signedAndEnvelopedData");N("1.2.840.113549.1.7.5","digestedData");N("1.2.840.113549.1.7.6","encryptedData");N("1.2.840.113549.1.9.1","emailAddress");N("1.2.840.113549.1.9.2","unstructuredName");N("1.2.840.113549.1.9.3","contentType");N("1.2.840.113549.1.9.4","messageDigest");N("1.2.840.113549.1.9.5","signingTime");N("1.2.840.113549.1.9.6","counterSignature");N("1.2.840.113549.1.9.7","challengePassword");N("1.2.840.113549.1.9.8","unstructuredAddress");N("1.2.840.113549.1.9.14","extensionRequest");N("1.2.840.113549.1.9.20","friendlyName");N("1.2.840.113549.1.9.21","localKeyId");N("1.2.840.113549.1.9.22.1","x509Certificate");N("1.2.840.113549.1.12.10.1.1","keyBag");N("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag");N("1.2.840.113549.1.12.10.1.3","certBag");N("1.2.840.113549.1.12.10.1.4","crlBag");N("1.2.840.113549.1.12.10.1.5","secretBag");N("1.2.840.113549.1.12.10.1.6","safeContentsBag");N("1.2.840.113549.1.5.13","pkcs5PBES2");N("1.2.840.113549.1.5.12","pkcs5PBKDF2");N("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4");N("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4");N("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC");N("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC");N("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC");N("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC");N("1.2.840.113549.2.7","hmacWithSHA1");N("1.2.840.113549.2.8","hmacWithSHA224");N("1.2.840.113549.2.9","hmacWithSHA256");N("1.2.840.113549.2.10","hmacWithSHA384");N("1.2.840.113549.2.11","hmacWithSHA512");N("1.2.840.113549.3.7","des-EDE3-CBC");N("2.16.840.1.101.3.4.1.2","aes128-CBC");N("2.16.840.1.101.3.4.1.22","aes192-CBC");N("2.16.840.1.101.3.4.1.42","aes256-CBC");N("2.5.4.3","commonName");N("2.5.4.4","surname");N("2.5.4.5","serialNumber");N("2.5.4.6","countryName");N("2.5.4.7","localityName");N("2.5.4.8","stateOrProvinceName");N("2.5.4.9","streetAddress");N("2.5.4.10","organizationName");N("2.5.4.11","organizationalUnitName");N("2.5.4.12","title");N("2.5.4.13","description");N("2.5.4.15","businessCategory");N("2.5.4.17","postalCode");N("2.5.4.42","givenName");N("2.5.4.65","pseudonym");N("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName");N("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName");N("2.16.840.1.113730.1.1","nsCertType");N("2.16.840.1.113730.1.13","nsComment");ae("2.5.29.1","authorityKeyIdentifier");ae("2.5.29.2","keyAttributes");ae("2.5.29.3","certificatePolicies");ae("2.5.29.4","keyUsageRestriction");ae("2.5.29.5","policyMapping");ae("2.5.29.6","subtreesConstraint");ae("2.5.29.7","subjectAltName");ae("2.5.29.8","issuerAltName");ae("2.5.29.9","subjectDirectoryAttributes");ae("2.5.29.10","basicConstraints");ae("2.5.29.11","nameConstraints");ae("2.5.29.12","policyConstraints");ae("2.5.29.13","basicConstraints");N("2.5.29.14","subjectKeyIdentifier");N("2.5.29.15","keyUsage");ae("2.5.29.16","privateKeyUsagePeriod");N("2.5.29.17","subjectAltName");N("2.5.29.18","issuerAltName");N("2.5.29.19","basicConstraints");ae("2.5.29.20","cRLNumber");ae("2.5.29.21","cRLReason");ae("2.5.29.22","expirationDate");ae("2.5.29.23","instructionCode");ae("2.5.29.24","invalidityDate");ae("2.5.29.25","cRLDistributionPoints");ae("2.5.29.26","issuingDistributionPoint");ae("2.5.29.27","deltaCRLIndicator");ae("2.5.29.28","issuingDistributionPoint");ae("2.5.29.29","certificateIssuer");ae("2.5.29.30","nameConstraints");N("2.5.29.31","cRLDistributionPoints");N("2.5.29.32","certificatePolicies");ae("2.5.29.33","policyMappings");ae("2.5.29.34","policyConstraints");N("2.5.29.35","authorityKeyIdentifier");ae("2.5.29.36","policyConstraints");N("2.5.29.37","extKeyUsage");ae("2.5.29.46","freshestCRL");ae("2.5.29.54","inhibitAnyPolicy");N("1.3.6.1.4.1.11129.2.4.2","timestampList");N("1.3.6.1.5.5.7.1.1","authorityInfoAccess");N("1.3.6.1.5.5.7.3.1","serverAuth");N("1.3.6.1.5.5.7.3.2","clientAuth");N("1.3.6.1.5.5.7.3.3","codeSigning");N("1.3.6.1.5.5.7.3.4","emailProtection");N("1.3.6.1.5.5.7.3.8","timeStamping")});var lt=F((wh,gi)=>{var de=$();re();Lt();var U=gi.exports=de.asn1=de.asn1||{};U.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192};U.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30};U.maxDepth=256;U.create=function(e,t,a,r,n){if(de.util.isArray(r)){for(var s=[],i=0;i<r.length;++i)r[i]!==void 0&&s.push(r[i]);r=s}var o={tagClass:e,type:t,constructed:a,composed:a||de.util.isArray(r),value:r};return n&&"bitStringContents"in n&&(o.bitStringContents=n.bitStringContents,o.original=U.copy(o)),o};U.copy=function(e,t){var a;if(de.util.isArray(e)){a=[];for(var r=0;r<e.length;++r)a.push(U.copy(e[r],t));return a}return typeof e=="string"?e:(a={tagClass:e.tagClass,type:e.type,constructed:e.constructed,composed:e.composed,value:U.copy(e.value,t)},t&&!t.excludeBitStringContents&&(a.bitStringContents=e.bitStringContents),a)};U.equals=function(e,t,a){if(de.util.isArray(e)){if(!de.util.isArray(t)||e.length!==t.length)return!1;for(var r=0;r<e.length;++r)if(!U.equals(e[r],t[r]))return!1;return!0}if(typeof e!=typeof t)return!1;if(typeof e=="string")return e===t;var n=e.tagClass===t.tagClass&&e.type===t.type&&e.constructed===t.constructed&&e.composed===t.composed&&U.equals(e.value,t.value);return a&&a.includeBitStringContents&&(n=n&&e.bitStringContents===t.bitStringContents),n};U.getBerValueLength=function(e){var t=e.getByte();if(t!==128){var a,r=t&128;return r?a=e.getInt((t&127)<<3):a=t,a}};function Br(e,t,a){if(a>t){var r=new Error("Too few bytes to parse DER.");throw r.available=e.length(),r.remaining=t,r.requested=a,r}}var t0=function(e,t){var a=e.getByte();if(t--,a!==128){var r,n=a&128;if(!n)r=a;else{var s=a&127;Br(e,t,s),r=e.getInt(s<<3)}if(r<0)throw new Error("Negative length: "+r);return r}};U.fromDer=function(e,t){t===void 0&&(t={strict:!0,parseAllBytes:!0,decodeBitStrings:!0}),typeof t=="boolean"&&(t={strict:t,parseAllBytes:!0,decodeBitStrings:!0}),"strict"in t||(t.strict=!0),"parseAllBytes"in t||(t.parseAllBytes=!0),"decodeBitStrings"in t||(t.decodeBitStrings=!0),"maxDepth"in t||(t.maxDepth=U.maxDepth),typeof e=="string"&&(e=de.util.createBuffer(e));var a=e.length(),r=Jr(e,e.length(),0,t);if(t.parseAllBytes&&e.length()!==0){var n=new Error("Unparsed DER bytes remain after ASN.1 parsing.");throw n.byteCount=a,n.remaining=e.length(),n}return r};function Jr(e,t,a,r){if(a>=r.maxDepth)throw new Error("ASN.1 parsing error: Max depth exceeded.");var n;Br(e,t,2);var s=e.getByte();t--;var i=s&192,o=s&31;n=e.length();var u=t0(e,t);if(t-=n-e.length(),u!==void 0&&u>t){if(r.strict){var l=new Error("Too few bytes to read ASN.1 value.");throw l.available=e.length(),l.remaining=t,l.requested=u,l}u=t}var c,f,g=(s&32)===32;if(g)if(c=[],u===void 0)for(;;){if(Br(e,t,2),e.bytes(2)==="\0\0"){e.getBytes(2),t-=2;break}n=e.length(),c.push(Jr(e,t,a+1,r)),t-=n-e.length()}else for(;u>0;)n=e.length(),c.push(Jr(e,u,a+1,r)),t-=n-e.length(),u-=n-e.length();if(c===void 0&&i===U.Class.UNIVERSAL&&o===U.Type.BITSTRING&&(f=e.bytes(u)),c===void 0&&r.decodeBitStrings&&i===U.Class.UNIVERSAL&&o===U.Type.BITSTRING&&u>1){var v=e.read,y=t,x=0;if(o===U.Type.BITSTRING&&(Br(e,t,1),x=e.getByte(),t--),x===0)try{n=e.length();var S={strict:!0,decodeBitStrings:!0},T=Jr(e,t,a+1,S),B=n-e.length();t-=B,o==U.Type.BITSTRING&&B++;var b=T.tagClass;B===u&&(b===U.Class.UNIVERSAL||b===U.Class.CONTEXT_SPECIFIC)&&(c=[T])}catch{}c===void 0&&(e.read=v,t=y)}if(c===void 0){if(u===void 0){if(r.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");u=t}if(o===U.Type.BMPSTRING)for(c="";u>0;u-=2)Br(e,t,2),c+=String.fromCharCode(e.getInt16()),t-=2;else c=e.getBytes(u),t-=u}var P=f===void 0?null:{bitStringContents:f};return U.create(i,o,g,c,P)}U.toDer=function(e){var t=de.util.createBuffer(),a=e.tagClass|e.type,r=de.util.createBuffer(),n=!1;if("bitStringContents"in e&&(n=!0,e.original&&(n=U.equals(e,e.original))),n)r.putBytes(e.bitStringContents);else if(e.composed){e.constructed?a|=32:r.putByte(0);for(var s=0;s<e.value.length;++s)e.value[s]!==void 0&&r.putBuffer(U.toDer(e.value[s]))}else if(e.type===U.Type.BMPSTRING)for(var s=0;s<e.value.length;++s)r.putInt16(e.value.charCodeAt(s));else e.type===U.Type.INTEGER&&e.value.length>1&&(e.value.charCodeAt(0)===0&&(e.value.charCodeAt(1)&128)===0||e.value.charCodeAt(0)===255&&(e.value.charCodeAt(1)&128)===128)?r.putBytes(e.value.substr(1)):r.putBytes(e.value);if(t.putByte(a),r.length()<=127)t.putByte(r.length()&127);else{var i=r.length(),o="";do o+=String.fromCharCode(i&255),i=i>>>8;while(i>0);t.putByte(o.length|128);for(var s=o.length-1;s>=0;--s)t.putByte(o.charCodeAt(s))}return t.putBuffer(r),t};U.oidToDer=function(e){var t=e.split("."),a=de.util.createBuffer();a.putByte(40*parseInt(t[0],10)+parseInt(t[1],10));for(var r,n,s,i,o=2;o<t.length;++o){if(r=!0,n=[],s=parseInt(t[o],10),s>4294967295)throw new Error("OID value too large; max is 32-bits.");do i=s&127,s=s>>>7,r||(i|=128),n.push(i),r=!1;while(s>0);for(var u=n.length-1;u>=0;--u)a.putByte(n[u])}return a};U.derToOid=function(e){var t;typeof e=="string"&&(e=de.util.createBuffer(e));var a=e.getByte();t=Math.floor(a/40)+"."+a%40;for(var r=0;e.length()>0;){if(r>70368744177663)throw new Error("OID value too large; max is 53-bits.");a=e.getByte(),r=r*128,a&128?r+=a&127:(t+="."+(r+a),r=0)}return t};U.utcTimeToDate=function(e){var t=new Date,a=parseInt(e.substr(0,2),10);a=a>=50?1900+a:2e3+a;var r=parseInt(e.substr(2,2),10)-1,n=parseInt(e.substr(4,2),10),s=parseInt(e.substr(6,2),10),i=parseInt(e.substr(8,2),10),o=0;if(e.length>11){var u=e.charAt(10),l=10;u!=="+"&&u!=="-"&&(o=parseInt(e.substr(10,2),10),l+=2)}if(t.setUTCFullYear(a,r,n),t.setUTCHours(s,i,o,0),l&&(u=e.charAt(l),u==="+"||u==="-")){var c=parseInt(e.substr(l+1,2),10),f=parseInt(e.substr(l+4,2),10),g=c*60+f;g*=6e4,u==="+"?t.setTime(+t-g):t.setTime(+t+g)}return t};U.generalizedTimeToDate=function(e){var t=new Date,a=parseInt(e.substr(0,4),10),r=parseInt(e.substr(4,2),10)-1,n=parseInt(e.substr(6,2),10),s=parseInt(e.substr(8,2),10),i=parseInt(e.substr(10,2),10),o=parseInt(e.substr(12,2),10),u=0,l=0,c=!1;e.charAt(e.length-1)==="Z"&&(c=!0);var f=e.length-5,g=e.charAt(f);if(g==="+"||g==="-"){var v=parseInt(e.substr(f+1,2),10),y=parseInt(e.substr(f+4,2),10);l=v*60+y,l*=6e4,g==="+"&&(l*=-1),c=!0}return e.charAt(14)==="."&&(u=parseFloat(e.substr(14),10)*1e3),c?(t.setUTCFullYear(a,r,n),t.setUTCHours(s,i,o,u),t.setTime(+t+l)):(t.setFullYear(a,r,n),t.setHours(s,i,o,u)),t};U.dateToUtcTime=function(e){if(typeof e=="string")return e;var t="",a=[];a.push((""+e.getUTCFullYear()).substr(2)),a.push(""+(e.getUTCMonth()+1)),a.push(""+e.getUTCDate()),a.push(""+e.getUTCHours()),a.push(""+e.getUTCMinutes()),a.push(""+e.getUTCSeconds());for(var r=0;r<a.length;++r)a[r].length<2&&(t+="0"),t+=a[r];return t+="Z",t};U.dateToGeneralizedTime=function(e){if(typeof e=="string")return e;var t="",a=[];a.push(""+e.getUTCFullYear()),a.push(""+(e.getUTCMonth()+1)),a.push(""+e.getUTCDate()),a.push(""+e.getUTCHours()),a.push(""+e.getUTCMinutes()),a.push(""+e.getUTCSeconds());for(var r=0;r<a.length;++r)a[r].length<2&&(t+="0"),t+=a[r];return t+="Z",t};U.integerToDer=function(e){var t=de.util.createBuffer();if(e>=-128&&e<128)return t.putSignedInt(e,8);if(e>=-32768&&e<32768)return t.putSignedInt(e,16);if(e>=-8388608&&e<8388608)return t.putSignedInt(e,24);if(e>=-2147483648&&e<2147483648)return t.putSignedInt(e,32);var a=new Error("Integer too large; max is 32-bits.");throw a.integer=e,a};U.derToInteger=function(e){typeof e=="string"&&(e=de.util.createBuffer(e));var t=e.length()*8;if(t>32)throw new Error("Integer too large; max is 32-bits.");return e.getSignedInt(t)};U.validate=function(e,t,a,r){var n=!1;if((e.tagClass===t.tagClass||typeof t.tagClass>"u")&&(e.type===t.type||typeof t.type>"u"))if(e.constructed===t.constructed||typeof t.constructed>"u"){if(n=!0,t.value&&de.util.isArray(t.value))for(var s=0,i=0;n&&i<t.value.length;++i){var o=t.value[i];n=!!o.optional;var u=e.value[s];if(!u){o.optional||(n=!1,r&&r.push("["+t.name+'] Missing required element. Expected tag class "'+o.tagClass+'", type "'+o.type+'"'));continue}var l=typeof o.tagClass<"u"&&typeof o.type<"u";if(l&&(u.tagClass!==o.tagClass||u.type!==o.type))if(o.optional){n=!0;continue}else{n=!1,r&&r.push("["+t.name+"] Tag mismatch. Expected ("+o.tagClass+","+o.type+"), got ("+u.tagClass+","+u.type+")");break}var c=U.validate(u,o,a,r);if(c)++s,n=!0;else if(o.optional)n=!0;else{n=!1;break}}if(n&&a&&(t.capture&&(a[t.capture]=e.value),t.captureAsn1&&(a[t.captureAsn1]=e),t.captureBitStringContents&&"bitStringContents"in e&&(a[t.captureBitStringContents]=e.bitStringContents),t.captureBitStringValue&&"bitStringContents"in e)){var f;if(e.bitStringContents.length<2)a[t.captureBitStringValue]="";else{var g=e.bitStringContents.charCodeAt(0);if(g!==0)throw new Error("captureBitStringValue only supported for zero unused bits");a[t.captureBitStringValue]=e.bitStringContents.slice(1)}}}else r&&r.push("["+t.name+'] Expected constructed "'+t.constructed+'", got "'+e.constructed+'"');else r&&(e.tagClass!==t.tagClass&&r.push("["+t.name+'] Expected tag class "'+t.tagClass+'", got "'+e.tagClass+'"'),e.type!==t.type&&r.push("["+t.name+'] Expected type "'+t.type+'", got "'+e.type+'"'));return n};var pi=/[^\\u0000-\\u00ff]/;U.prettyPrint=function(e,t,a){var r="";t=t||0,a=a||2,t>0&&(r+=`
8
8
  `);for(var n="",s=0;s<t*a;++s)n+=" ";switch(r+=n+"Tag: ",e.tagClass){case U.Class.UNIVERSAL:r+="Universal:";break;case U.Class.APPLICATION:r+="Application:";break;case U.Class.CONTEXT_SPECIFIC:r+="Context-Specific:";break;case U.Class.PRIVATE:r+="Private:";break}if(e.tagClass===U.Class.UNIVERSAL)switch(r+=e.type,e.type){case U.Type.NONE:r+=" (None)";break;case U.Type.BOOLEAN:r+=" (Boolean)";break;case U.Type.INTEGER:r+=" (Integer)";break;case U.Type.BITSTRING:r+=" (Bit string)";break;case U.Type.OCTETSTRING:r+=" (Octet string)";break;case U.Type.NULL:r+=" (Null)";break;case U.Type.OID:r+=" (Object Identifier)";break;case U.Type.ODESC:r+=" (Object Descriptor)";break;case U.Type.EXTERNAL:r+=" (External or Instance of)";break;case U.Type.REAL:r+=" (Real)";break;case U.Type.ENUMERATED:r+=" (Enumerated)";break;case U.Type.EMBEDDED:r+=" (Embedded PDV)";break;case U.Type.UTF8:r+=" (UTF8)";break;case U.Type.ROID:r+=" (Relative Object Identifier)";break;case U.Type.SEQUENCE:r+=" (Sequence)";break;case U.Type.SET:r+=" (Set)";break;case U.Type.PRINTABLESTRING:r+=" (Printable String)";break;case U.Type.IA5String:r+=" (IA5String (ASCII))";break;case U.Type.UTCTIME:r+=" (UTC time)";break;case U.Type.GENERALIZEDTIME:r+=" (Generalized time)";break;case U.Type.BMPSTRING:r+=" (BMP String)";break}else r+=e.type;if(r+=`
9
9
  `,r+=n+"Constructed: "+e.constructed+`
10
- `,e.composed){for(var i=0,o="",s=0;s<e.value.length;++s)e.value[s]!==void 0&&(i+=1,o+=U.prettyPrint(e.value[s],t+1,a),s+1<e.value.length&&(o+=","));r+=n+"Sub values: "+i+o}else{if(r+=n+"Value: ",e.type===U.Type.OID){var u=U.derToOid(e.value);r+=u,de.pki&&de.pki.oids&&u in de.pki.oids&&(r+=" ("+de.pki.oids[u]+") ")}if(e.type===U.Type.INTEGER)try{r+=U.derToInteger(e.value)}catch{r+="0x"+de.util.bytesToHex(e.value)}else if(e.type===U.Type.BITSTRING){if(e.value.length>1?r+="0x"+de.util.bytesToHex(e.value.slice(1)):r+="(none)",e.value.length>0){var l=e.value.charCodeAt(0);l==1?r+=" (1 unused bit shown)":l>1&&(r+=" ("+l+" unused bits shown)")}}else if(e.type===U.Type.OCTETSTRING)di.test(e.value)||(r+="("+e.value+") "),r+="0x"+de.util.bytesToHex(e.value);else if(e.type===U.Type.UTF8)try{r+=de.util.decodeUtf8(e.value)}catch(c){if(c.message==="URI malformed")r+="0x"+de.util.bytesToHex(e.value)+" (malformed UTF8)";else throw c}else e.type===U.Type.PRINTABLESTRING||e.type===U.Type.IA5String?r+=e.value:di.test(e.value)?r+="0x"+de.util.bytesToHex(e.value):e.value.length===0?r+="[null]":r+=e.value}return r}});var ft=F((_h,pi)=>{var Jr=$();pi.exports=Jr.md=Jr.md||{};Jr.md.algorithms=Jr.md.algorithms||{}});var ir=F((wh,gi)=>{var St=$();ft();re();var t0=gi.exports=St.hmac=St.hmac||{};t0.create=function(){var e=null,t=null,a=null,r=null,n={};return n.start=function(s,i){if(s!==null)if(typeof s=="string")if(s=s.toLowerCase(),s in St.md.algorithms)t=St.md.algorithms[s].create();else throw new Error('Unknown hash algorithm "'+s+'"');else t=s;if(i===null)i=e;else{if(typeof i=="string")i=St.util.createBuffer(i);else if(St.util.isArray(i)){var o=i;i=St.util.createBuffer();for(var u=0;u<o.length;++u)i.putByte(o[u])}var l=i.length();l>t.blockLength&&(t.start(),t.update(i.bytes()),i=t.digest()),a=St.util.createBuffer(),r=St.util.createBuffer(),l=i.length();for(var u=0;u<l;++u){var o=i.at(u);a.putByte(54^o),r.putByte(92^o)}if(l<t.blockLength)for(var o=t.blockLength-l,u=0;u<o;++u)a.putByte(54),r.putByte(92);e=i,a=a.bytes(),r=r.bytes()}t.start(),t.update(a)},n.update=function(s){t.update(s)},n.getMac=function(){var s=t.digest().bytes();return t.start(),t.update(r),t.update(s),t.digest()},n.digest=n.getMac,n}});var ea=F((Nh,Ci)=>{var dt=$();ft();re();var vi=Ci.exports=dt.md5=dt.md5||{};dt.md.md5=dt.md.algorithms.md5=vi;vi.create=function(){mi||r0();var e=null,t=dt.util.createBuffer(),a=new Array(16),r={algorithm:"md5",blockLength:64,digestLength:16,messageLength:0,fullMessageLength:null,messageLengthSize:8};return r.start=function(){r.messageLength=0,r.fullMessageLength=r.messageLength64=[];for(var n=r.messageLengthSize/4,s=0;s<n;++s)r.fullMessageLength.push(0);return t=dt.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878},r},r.start(),r.update=function(n,s){s==="utf8"&&(n=dt.util.encodeUtf8(n));var i=n.length;r.messageLength+=i,i=[i/4294967296>>>0,i>>>0];for(var o=r.fullMessageLength.length-1;o>=0;--o)r.fullMessageLength[o]+=i[1],i[1]=i[0]+(r.fullMessageLength[o]/4294967296>>>0),r.fullMessageLength[o]=r.fullMessageLength[o]>>>0,i[0]=i[1]/4294967296>>>0;return t.putBytes(n),yi(e,a,t),(t.read>2048||t.length()===0)&&t.compact(),r},r.digest=function(){var n=dt.util.createBuffer();n.putBytes(t.bytes());var s=r.fullMessageLength[r.fullMessageLength.length-1]+r.messageLengthSize,i=s&r.blockLength-1;n.putBytes(Ka.substr(0,r.blockLength-i));for(var o,u=0,l=r.fullMessageLength.length-1;l>=0;--l)o=r.fullMessageLength[l]*8+u,u=o/4294967296>>>0,n.putInt32Le(o>>>0);var c={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3};yi(c,a,n);var f=dt.util.createBuffer();return f.putInt32Le(c.h0),f.putInt32Le(c.h1),f.putInt32Le(c.h2),f.putInt32Le(c.h3),f},r};var Ka=null,Zr=null,Br=null,sr=null,mi=!1;function r0(){Ka="\x80",Ka+=dt.util.fillString("\0",64),Zr=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,6,11,0,5,10,15,4,9,14,3,8,13,2,7,12,5,8,11,14,1,4,7,10,13,0,3,6,9,12,15,2,0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9],Br=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],sr=new Array(64);for(var e=0;e<64;++e)sr[e]=Math.floor(Math.abs(Math.sin(e+1))*4294967296);mi=!0}function yi(e,t,a){for(var r,n,s,i,o,u,l,c,f=a.length();f>=64;){for(n=e.h0,s=e.h1,i=e.h2,o=e.h3,c=0;c<16;++c)t[c]=a.getInt32Le(),u=o^s&(i^o),r=n+u+sr[c]+t[c],l=Br[c],n=o,o=i,i=s,s+=r<<l|r>>>32-l;for(;c<32;++c)u=i^o&(s^i),r=n+u+sr[c]+t[Zr[c]],l=Br[c],n=o,o=i,i=s,s+=r<<l|r>>>32-l;for(;c<48;++c)u=s^i^o,r=n+u+sr[c]+t[Zr[c]],l=Br[c],n=o,o=i,i=s,s+=r<<l|r>>>32-l;for(;c<64;++c)u=i^(s|~o),r=n+u+sr[c]+t[Zr[c]],l=Br[c],n=o,o=i,i=s,s+=r<<l|r>>>32-l;e.h0=e.h0+n|0,e.h1=e.h1+s|0,e.h2=e.h2+i|0,e.h3=e.h3+o|0,f-=64}}});var Qt=F((Rh,xi)=>{var ra=$();re();var Ei=xi.exports=ra.pem=ra.pem||{};Ei.encode=function(e,t){t=t||{};var a="-----BEGIN "+e.type+`-----\r
11
- `,r;if(e.procType&&(r={name:"Proc-Type",values:[String(e.procType.version),e.procType.type]},a+=ta(r)),e.contentDomain&&(r={name:"Content-Domain",values:[e.contentDomain]},a+=ta(r)),e.dekInfo&&(r={name:"DEK-Info",values:[e.dekInfo.algorithm]},e.dekInfo.parameters&&r.values.push(e.dekInfo.parameters),a+=ta(r)),e.headers)for(var n=0;n<e.headers.length;++n)a+=ta(e.headers[n]);return e.procType&&(a+=`\r
12
- `),a+=ra.util.encode64(e.body,t.maxline||64)+`\r
10
+ `,e.composed){for(var i=0,o="",s=0;s<e.value.length;++s)e.value[s]!==void 0&&(i+=1,o+=U.prettyPrint(e.value[s],t+1,a),s+1<e.value.length&&(o+=","));r+=n+"Sub values: "+i+o}else{if(r+=n+"Value: ",e.type===U.Type.OID){var u=U.derToOid(e.value);r+=u,de.pki&&de.pki.oids&&u in de.pki.oids&&(r+=" ("+de.pki.oids[u]+") ")}if(e.type===U.Type.INTEGER)try{r+=U.derToInteger(e.value)}catch{r+="0x"+de.util.bytesToHex(e.value)}else if(e.type===U.Type.BITSTRING){if(e.value.length>1?r+="0x"+de.util.bytesToHex(e.value.slice(1)):r+="(none)",e.value.length>0){var l=e.value.charCodeAt(0);l==1?r+=" (1 unused bit shown)":l>1&&(r+=" ("+l+" unused bits shown)")}}else if(e.type===U.Type.OCTETSTRING)pi.test(e.value)||(r+="("+e.value+") "),r+="0x"+de.util.bytesToHex(e.value);else if(e.type===U.Type.UTF8)try{r+=de.util.decodeUtf8(e.value)}catch(c){if(c.message==="URI malformed")r+="0x"+de.util.bytesToHex(e.value)+" (malformed UTF8)";else throw c}else e.type===U.Type.PRINTABLESTRING||e.type===U.Type.IA5String?r+=e.value:pi.test(e.value)?r+="0x"+de.util.bytesToHex(e.value):e.value.length===0?r+="[null]":r+=e.value}return r}});var ft=F((Nh,yi)=>{var Zr=$();yi.exports=Zr.md=Zr.md||{};Zr.md.algorithms=Zr.md.algorithms||{}});var or=F((Rh,vi)=>{var St=$();ft();re();var r0=vi.exports=St.hmac=St.hmac||{};r0.create=function(){var e=null,t=null,a=null,r=null,n={};return n.start=function(s,i){if(s!==null)if(typeof s=="string")if(s=s.toLowerCase(),s in St.md.algorithms)t=St.md.algorithms[s].create();else throw new Error('Unknown hash algorithm "'+s+'"');else t=s;if(i===null)i=e;else{if(typeof i=="string")i=St.util.createBuffer(i);else if(St.util.isArray(i)){var o=i;i=St.util.createBuffer();for(var u=0;u<o.length;++u)i.putByte(o[u])}var l=i.length();l>t.blockLength&&(t.start(),t.update(i.bytes()),i=t.digest()),a=St.util.createBuffer(),r=St.util.createBuffer(),l=i.length();for(var u=0;u<l;++u){var o=i.at(u);a.putByte(54^o),r.putByte(92^o)}if(l<t.blockLength)for(var o=t.blockLength-l,u=0;u<o;++u)a.putByte(54),r.putByte(92);e=i,a=a.bytes(),r=r.bytes()}t.start(),t.update(a)},n.update=function(s){t.update(s)},n.getMac=function(){var s=t.digest().bytes();return t.start(),t.update(r),t.update(s),t.digest()},n.digest=n.getMac,n}});var ta=F((Lh,xi)=>{var dt=$();ft();re();var Ci=xi.exports=dt.md5=dt.md5||{};dt.md.md5=dt.md.algorithms.md5=Ci;Ci.create=function(){Ei||a0();var e=null,t=dt.util.createBuffer(),a=new Array(16),r={algorithm:"md5",blockLength:64,digestLength:16,messageLength:0,fullMessageLength:null,messageLengthSize:8};return r.start=function(){r.messageLength=0,r.fullMessageLength=r.messageLength64=[];for(var n=r.messageLengthSize/4,s=0;s<n;++s)r.fullMessageLength.push(0);return t=dt.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878},r},r.start(),r.update=function(n,s){s==="utf8"&&(n=dt.util.encodeUtf8(n));var i=n.length;r.messageLength+=i,i=[i/4294967296>>>0,i>>>0];for(var o=r.fullMessageLength.length-1;o>=0;--o)r.fullMessageLength[o]+=i[1],i[1]=i[0]+(r.fullMessageLength[o]/4294967296>>>0),r.fullMessageLength[o]=r.fullMessageLength[o]>>>0,i[0]=i[1]/4294967296>>>0;return t.putBytes(n),mi(e,a,t),(t.read>2048||t.length()===0)&&t.compact(),r},r.digest=function(){var n=dt.util.createBuffer();n.putBytes(t.bytes());var s=r.fullMessageLength[r.fullMessageLength.length-1]+r.messageLengthSize,i=s&r.blockLength-1;n.putBytes(Ma.substr(0,r.blockLength-i));for(var o,u=0,l=r.fullMessageLength.length-1;l>=0;--l)o=r.fullMessageLength[l]*8+u,u=o/4294967296>>>0,n.putInt32Le(o>>>0);var c={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3};mi(c,a,n);var f=dt.util.createBuffer();return f.putInt32Le(c.h0),f.putInt32Le(c.h1),f.putInt32Le(c.h2),f.putInt32Le(c.h3),f},r};var Ma=null,ea=null,br=null,ur=null,Ei=!1;function a0(){Ma="\x80",Ma+=dt.util.fillString("\0",64),ea=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,6,11,0,5,10,15,4,9,14,3,8,13,2,7,12,5,8,11,14,1,4,7,10,13,0,3,6,9,12,15,2,0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9],br=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],ur=new Array(64);for(var e=0;e<64;++e)ur[e]=Math.floor(Math.abs(Math.sin(e+1))*4294967296);Ei=!0}function mi(e,t,a){for(var r,n,s,i,o,u,l,c,f=a.length();f>=64;){for(n=e.h0,s=e.h1,i=e.h2,o=e.h3,c=0;c<16;++c)t[c]=a.getInt32Le(),u=o^s&(i^o),r=n+u+ur[c]+t[c],l=br[c],n=o,o=i,i=s,s+=r<<l|r>>>32-l;for(;c<32;++c)u=i^o&(s^i),r=n+u+ur[c]+t[ea[c]],l=br[c],n=o,o=i,i=s,s+=r<<l|r>>>32-l;for(;c<48;++c)u=s^i^o,r=n+u+ur[c]+t[ea[c]],l=br[c],n=o,o=i,i=s,s+=r<<l|r>>>32-l;for(;c<64;++c)u=i^(s|~o),r=n+u+ur[c]+t[ea[c]],l=br[c],n=o,o=i,i=s,s+=r<<l|r>>>32-l;e.h0=e.h0+n|0,e.h1=e.h1+s|0,e.h2=e.h2+i|0,e.h3=e.h3+o|0,f-=64}}});var Qt=F((kh,Ti)=>{var aa=$();re();var Si=Ti.exports=aa.pem=aa.pem||{};Si.encode=function(e,t){t=t||{};var a="-----BEGIN "+e.type+`-----\r
11
+ `,r;if(e.procType&&(r={name:"Proc-Type",values:[String(e.procType.version),e.procType.type]},a+=ra(r)),e.contentDomain&&(r={name:"Content-Domain",values:[e.contentDomain]},a+=ra(r)),e.dekInfo&&(r={name:"DEK-Info",values:[e.dekInfo.algorithm]},e.dekInfo.parameters&&r.values.push(e.dekInfo.parameters),a+=ra(r)),e.headers)for(var n=0;n<e.headers.length;++n)a+=ra(e.headers[n]);return e.procType&&(a+=`\r
12
+ `),a+=aa.util.encode64(e.body,t.maxline||64)+`\r
13
13
  `,a+="-----END "+e.type+`-----\r
14
- `,a};Ei.decode=function(e){for(var t=[],a=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,r=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,n=/\r?\n/,s;s=a.exec(e),!!s;){var i=s[1];i==="NEW CERTIFICATE REQUEST"&&(i="CERTIFICATE REQUEST");var o={type:i,procType:null,contentDomain:null,dekInfo:null,headers:[],body:ra.util.decode64(s[3])};if(t.push(o),!!s[2]){for(var u=s[2].split(n),l=0;s&&l<u.length;){for(var c=u[l].replace(/\s+$/,""),f=l+1;f<u.length;++f){var g=u[f];if(!/\s/.test(g[0]))break;c+=g,l=f}if(s=c.match(r),s){for(var v={name:s[1],values:[]},y=s[2].split(","),x=0;x<y.length;++x)v.values.push(a0(y[x]));if(o.procType)if(!o.contentDomain&&v.name==="Content-Domain")o.contentDomain=y[0]||"";else if(!o.dekInfo&&v.name==="DEK-Info"){if(v.values.length===0)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');o.dekInfo={algorithm:y[0],parameters:y[1]||null}}else o.headers.push(v);else{if(v.name!=="Proc-Type")throw new Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');if(v.values.length!==2)throw new Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');o.procType={version:y[0],type:y[1]}}}++l}if(o.procType==="ENCRYPTED"&&!o.dekInfo)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".')}}if(t.length===0)throw new Error("Invalid PEM formatted message.");return t};function ta(e){for(var t=e.name+": ",a=[],r=function(u,l){return" "+l},n=0;n<e.values.length;++n)a.push(e.values[n].replace(/^(\S+\r\n)/,r));t+=a.join(",")+`\r
14
+ `,a};Si.decode=function(e){for(var t=[],a=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,r=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,n=/\r?\n/,s;s=a.exec(e),!!s;){var i=s[1];i==="NEW CERTIFICATE REQUEST"&&(i="CERTIFICATE REQUEST");var o={type:i,procType:null,contentDomain:null,dekInfo:null,headers:[],body:aa.util.decode64(s[3])};if(t.push(o),!!s[2]){for(var u=s[2].split(n),l=0;s&&l<u.length;){for(var c=u[l].replace(/\s+$/,""),f=l+1;f<u.length;++f){var g=u[f];if(!/\s/.test(g[0]))break;c+=g,l=f}if(s=c.match(r),s){for(var v={name:s[1],values:[]},y=s[2].split(","),x=0;x<y.length;++x)v.values.push(n0(y[x]));if(o.procType)if(!o.contentDomain&&v.name==="Content-Domain")o.contentDomain=y[0]||"";else if(!o.dekInfo&&v.name==="DEK-Info"){if(v.values.length===0)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');o.dekInfo={algorithm:y[0],parameters:y[1]||null}}else o.headers.push(v);else{if(v.name!=="Proc-Type")throw new Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');if(v.values.length!==2)throw new Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');o.procType={version:y[0],type:y[1]}}}++l}if(o.procType==="ENCRYPTED"&&!o.dekInfo)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".')}}if(t.length===0)throw new Error("Invalid PEM formatted message.");return t};function ra(e){for(var t=e.name+": ",a=[],r=function(u,l){return" "+l},n=0;n<e.values.length;++n)a.push(e.values[n].replace(/^(\S+\r\n)/,r));t+=a.join(",")+`\r
15
15
  `;for(var s=0,i=-1,n=0;n<t.length;++n,++s)if(s>65&&i!==-1){var o=t[i];o===","?(++i,t=t.substr(0,i)+`\r
16
16
  `+t.substr(i)):t=t.substr(0,i)+`\r
17
- `+o+t.substr(i+1),s=n-i-1,i=-1,++n}else(t[n]===" "||t[n]===" "||t[n]===",")&&(i=n);return t}function a0(e){return e.replace(/^\s+/,"")}});var br=F((Lh,Ti)=>{var pe=$();$r();Ua();re();Ti.exports=pe.des=pe.des||{};pe.des.startEncrypting=function(e,t,a,r){var n=aa({key:e,output:a,decrypt:!1,mode:r||(t===null?"ECB":"CBC")});return n.start(t),n};pe.des.createEncryptionCipher=function(e,t){return aa({key:e,output:null,decrypt:!1,mode:t})};pe.des.startDecrypting=function(e,t,a,r){var n=aa({key:e,output:a,decrypt:!0,mode:r||(t===null?"ECB":"CBC")});return n.start(t),n};pe.des.createDecryptionCipher=function(e,t){return aa({key:e,output:null,decrypt:!0,mode:t})};pe.des.Algorithm=function(e,t){var a=this;a.name=e,a.mode=new t({blockSize:8,cipher:{encrypt:function(r,n){return Si(a._keys,r,n,!1)},decrypt:function(r,n){return Si(a._keys,r,n,!0)}}}),a._init=!1};pe.des.Algorithm.prototype.initialize=function(e){if(!this._init){var t=pe.util.createBuffer(e.key);if(this.name.indexOf("3DES")===0&&t.length()!==24)throw new Error("Invalid Triple-DES key size: "+t.length()*8);this._keys=d0(t),this._init=!0}};ht("DES-ECB",pe.cipher.modes.ecb);ht("DES-CBC",pe.cipher.modes.cbc);ht("DES-CFB",pe.cipher.modes.cfb);ht("DES-OFB",pe.cipher.modes.ofb);ht("DES-CTR",pe.cipher.modes.ctr);ht("3DES-ECB",pe.cipher.modes.ecb);ht("3DES-CBC",pe.cipher.modes.cbc);ht("3DES-CFB",pe.cipher.modes.cfb);ht("3DES-OFB",pe.cipher.modes.ofb);ht("3DES-CTR",pe.cipher.modes.ctr);function ht(e,t){var a=function(){return new pe.des.Algorithm(e,t)};pe.cipher.registerAlgorithm(e,a)}var n0=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],i0=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],s0=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],o0=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],u0=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],l0=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],c0=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],f0=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function d0(e){for(var t=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],a=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],r=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],n=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],s=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],i=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],o=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],u=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],l=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],c=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],f=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],g=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],v=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],y=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],x=e.length()>8?3:1,S=[],I=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],B=0,b,P=0;P<x;P++){var k=e.getInt32(),R=e.getInt32();b=(k>>>4^R)&252645135,R^=b,k^=b<<4,b=(R>>>-16^k)&65535,k^=b,R^=b<<-16,b=(k>>>2^R)&858993459,R^=b,k^=b<<2,b=(R>>>-16^k)&65535,k^=b,R^=b<<-16,b=(k>>>1^R)&1431655765,R^=b,k^=b<<1,b=(R>>>8^k)&16711935,k^=b,R^=b<<8,b=(k>>>1^R)&1431655765,R^=b,k^=b<<1,b=k<<8|R>>>20&240,k=R<<24|R<<8&16711680|R>>>8&65280|R>>>24&240,R=b;for(var z=0;z<I.length;++z){I[z]?(k=k<<2|k>>>26,R=R<<2|R>>>26):(k=k<<1|k>>>27,R=R<<1|R>>>27),k&=-15,R&=-15;var Y=t[k>>>28]|a[k>>>24&15]|r[k>>>20&15]|n[k>>>16&15]|s[k>>>12&15]|i[k>>>8&15]|o[k>>>4&15],ne=u[R>>>28]|l[R>>>24&15]|c[R>>>20&15]|f[R>>>16&15]|g[R>>>12&15]|v[R>>>8&15]|y[R>>>4&15];b=(ne>>>16^Y)&65535,S[B++]=Y^b,S[B++]=ne^b<<16}}return S}function Si(e,t,a,r){var n=e.length===32?3:9,s;n===3?s=r?[30,-2,-2]:[0,32,2]:s=r?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var i,o=t[0],u=t[1];i=(o>>>4^u)&252645135,u^=i,o^=i<<4,i=(o>>>16^u)&65535,u^=i,o^=i<<16,i=(u>>>2^o)&858993459,o^=i,u^=i<<2,i=(u>>>8^o)&16711935,o^=i,u^=i<<8,i=(o>>>1^u)&1431655765,u^=i,o^=i<<1,o=o<<1|o>>>31,u=u<<1|u>>>31;for(var l=0;l<n;l+=3){for(var c=s[l+1],f=s[l+2],g=s[l];g!=c;g+=f){var v=u^e[g],y=(u>>>4|u<<28)^e[g+1];i=o,o=u,u=i^(i0[v>>>24&63]|o0[v>>>16&63]|l0[v>>>8&63]|f0[v&63]|n0[y>>>24&63]|s0[y>>>16&63]|u0[y>>>8&63]|c0[y&63])}i=o,o=u,u=i}o=o>>>1|o<<31,u=u>>>1|u<<31,i=(o>>>1^u)&1431655765,u^=i,o^=i<<1,i=(u>>>8^o)&16711935,o^=i,u^=i<<8,i=(u>>>2^o)&858993459,o^=i,u^=i<<2,i=(o>>>16^u)&65535,u^=i,o^=i<<16,i=(o>>>4^u)&252645135,u^=i,o^=i<<4,a[0]=o,a[1]=u}function aa(e){e=e||{};var t=(e.mode||"CBC").toUpperCase(),a="DES-"+t,r;e.decrypt?r=pe.cipher.createDecipher(a,e.key):r=pe.cipher.createCipher(a,e.key);var n=r.start;return r.start=function(s,i){var o=null;i instanceof pe.util.ByteBuffer&&(o=i,i={}),i=i||{},i.output=o,i.iv=s,n.call(r,i)},r}});var na=F((kh,Ii)=>{var Ge=$();ir();ft();re();var h0=Ge.pkcs5=Ge.pkcs5||{},Tt;Ge.util.isNodejs&&!Ge.options.usePureJavaScript&&(Tt=require("crypto"));Ii.exports=Ge.pbkdf2=h0.pbkdf2=function(e,t,a,r,n,s){if(typeof n=="function"&&(s=n,n=null),Ge.util.isNodejs&&!Ge.options.usePureJavaScript&&Tt.pbkdf2&&(n===null||typeof n!="object")&&(Tt.pbkdf2Sync.length>4||!n||n==="sha1"))return typeof n!="string"&&(n="sha1"),e=Buffer.from(e,"binary"),t=Buffer.from(t,"binary"),s?Tt.pbkdf2Sync.length===4?Tt.pbkdf2(e,t,a,r,function(b,P){if(b)return s(b);s(null,P.toString("binary"))}):Tt.pbkdf2(e,t,a,r,n,function(b,P){if(b)return s(b);s(null,P.toString("binary"))}):Tt.pbkdf2Sync.length===4?Tt.pbkdf2Sync(e,t,a,r).toString("binary"):Tt.pbkdf2Sync(e,t,a,r,n).toString("binary");if((typeof n>"u"||n===null)&&(n="sha1"),typeof n=="string"){if(!(n in Ge.md.algorithms))throw new Error("Unknown hash algorithm: "+n);n=Ge.md[n].create()}var i=n.digestLength;if(r>4294967295*i){var o=new Error("Derived key is too long.");if(s)return s(o);throw o}var u=Math.ceil(r/i),l=r-(u-1)*i,c=Ge.hmac.create();c.start(n,e);var f="",g,v,y;if(!s){for(var x=1;x<=u;++x){c.start(null,null),c.update(t),c.update(Ge.util.int32ToBytes(x)),g=y=c.digest().getBytes();for(var S=2;S<=a;++S)c.start(null,null),c.update(y),v=c.digest().getBytes(),g=Ge.util.xorBytes(g,v,i),y=v;f+=x<u?g:g.substr(0,l)}return f}var x=1,S;function I(){if(x>u)return s(null,f);c.start(null,null),c.update(t),c.update(Ge.util.int32ToBytes(x)),g=y=c.digest().getBytes(),S=2,B()}function B(){if(S<=a)return c.start(null,null),c.update(y),v=c.digest().getBytes(),g=Ge.util.xorBytes(g,v,i),y=v,++S,Ge.util.setImmediate(B);f+=x<u?g:g.substr(0,l),++x,I()}I()}});var qa=F((Dh,wi)=>{var pt=$();ft();re();var Bi=wi.exports=pt.sha256=pt.sha256||{};pt.md.sha256=pt.md.algorithms.sha256=Bi;Bi.create=function(){bi||p0();var e=null,t=pt.util.createBuffer(),a=new Array(64),r={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8};return r.start=function(){r.messageLength=0,r.fullMessageLength=r.messageLength64=[];for(var n=r.messageLengthSize/4,s=0;s<n;++s)r.fullMessageLength.push(0);return t=pt.util.createBuffer(),e={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},r},r.start(),r.update=function(n,s){s==="utf8"&&(n=pt.util.encodeUtf8(n));var i=n.length;r.messageLength+=i,i=[i/4294967296>>>0,i>>>0];for(var o=r.fullMessageLength.length-1;o>=0;--o)r.fullMessageLength[o]+=i[1],i[1]=i[0]+(r.fullMessageLength[o]/4294967296>>>0),r.fullMessageLength[o]=r.fullMessageLength[o]>>>0,i[0]=i[1]/4294967296>>>0;return t.putBytes(n),Ai(e,a,t),(t.read>2048||t.length()===0)&&t.compact(),r},r.digest=function(){var n=pt.util.createBuffer();n.putBytes(t.bytes());var s=r.fullMessageLength[r.fullMessageLength.length-1]+r.messageLengthSize,i=s&r.blockLength-1;n.putBytes(Ma.substr(0,r.blockLength-i));for(var o,u,l=r.fullMessageLength[0]*8,c=0;c<r.fullMessageLength.length-1;++c)o=r.fullMessageLength[c+1]*8,u=o/4294967296>>>0,l+=u,n.putInt32(l>>>0),l=o>>>0;n.putInt32(l);var f={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};Ai(f,a,n);var g=pt.util.createBuffer();return g.putInt32(f.h0),g.putInt32(f.h1),g.putInt32(f.h2),g.putInt32(f.h3),g.putInt32(f.h4),g.putInt32(f.h5),g.putInt32(f.h6),g.putInt32(f.h7),g},r};var Ma=null,bi=!1,_i=null;function p0(){Ma="\x80",Ma+=pt.util.fillString("\0",64),_i=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],bi=!0}function Ai(e,t,a){for(var r,n,s,i,o,u,l,c,f,g,v,y,x,S,I,B=a.length();B>=64;){for(l=0;l<16;++l)t[l]=a.getInt32();for(;l<64;++l)r=t[l-2],r=(r>>>17|r<<15)^(r>>>19|r<<13)^r>>>10,n=t[l-15],n=(n>>>7|n<<25)^(n>>>18|n<<14)^n>>>3,t[l]=r+t[l-7]+n+t[l-16]|0;for(c=e.h0,f=e.h1,g=e.h2,v=e.h3,y=e.h4,x=e.h5,S=e.h6,I=e.h7,l=0;l<64;++l)i=(y>>>6|y<<26)^(y>>>11|y<<21)^(y>>>25|y<<7),o=S^y&(x^S),s=(c>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10),u=c&f|g&(c^f),r=I+i+o+_i[l]+t[l],n=s+u,I=S,S=x,x=y,y=v+r>>>0,v=g,g=f,f=c,c=r+n>>>0;e.h0=e.h0+c|0,e.h1=e.h1+f|0,e.h2=e.h2+g|0,e.h3=e.h3+v|0,e.h4=e.h4+y|0,e.h5=e.h5+x|0,e.h6=e.h6+S|0,e.h7=e.h7+I|0,B-=64}}});var Ha=F((Uh,Ni)=>{var gt=$();re();var ia=null;gt.util.isNodejs&&!gt.options.usePureJavaScript&&!process.versions["node-webkit"]&&(ia=require("crypto"));var g0=Ni.exports=gt.prng=gt.prng||{};g0.create=function(e){for(var t={plugin:e,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},a=e.md,r=new Array(32),n=0;n<32;++n)r[n]=a.create();t.pools=r,t.pool=0,t.generate=function(l,c){if(!c)return t.generateSync(l);var f=t.plugin.cipher,g=t.plugin.increment,v=t.plugin.formatKey,y=t.plugin.formatSeed,x=gt.util.createBuffer();t.key=null,S();function S(I){if(I)return c(I);if(x.length()>=l)return c(null,x.getBytes(l));if(t.generated>1048575&&(t.key=null),t.key===null)return gt.util.nextTick(function(){s(S)});var B=f(t.key,t.seed);t.generated+=B.length,x.putBytes(B),t.key=v(f(t.key,g(t.seed))),t.seed=y(f(t.key,t.seed)),gt.util.setImmediate(S)}},t.generateSync=function(l){var c=t.plugin.cipher,f=t.plugin.increment,g=t.plugin.formatKey,v=t.plugin.formatSeed;t.key=null;for(var y=gt.util.createBuffer();y.length()<l;){t.generated>1048575&&(t.key=null),t.key===null&&i();var x=c(t.key,t.seed);t.generated+=x.length,y.putBytes(x),t.key=g(c(t.key,f(t.seed))),t.seed=v(c(t.key,t.seed))}return y.getBytes(l)};function s(l){if(t.pools[0].messageLength>=32)return o(),l();var c=32-t.pools[0].messageLength<<5;t.seedFile(c,function(f,g){if(f)return l(f);t.collect(g),o(),l()})}function i(){if(t.pools[0].messageLength>=32)return o();var l=32-t.pools[0].messageLength<<5;t.collect(t.seedFileSync(l)),o()}function o(){t.reseeds=t.reseeds===4294967295?0:t.reseeds+1;var l=t.plugin.md.create();l.update(t.keyBytes);for(var c=1,f=0;f<32;++f)t.reseeds%c===0&&(l.update(t.pools[f].digest().getBytes()),t.pools[f].start()),c=c<<1;t.keyBytes=l.digest().getBytes(),l.start(),l.update(t.keyBytes);var g=l.digest().getBytes();t.key=t.plugin.formatKey(t.keyBytes),t.seed=t.plugin.formatSeed(g),t.generated=0}function u(l){var c=null,f=gt.util.globalScope,g=f.crypto||f.msCrypto;g&&g.getRandomValues&&(c=function(k){return g.getRandomValues(k)});var v=gt.util.createBuffer();if(c)for(;v.length()<l;){var y=Math.max(1,Math.min(l-v.length(),65536)/4),x=new Uint32Array(Math.floor(y));try{c(x);for(var S=0;S<x.length;++S)v.putInt32(x[S])}catch(k){if(!(typeof QuotaExceededError<"u"&&k instanceof QuotaExceededError))throw k}}if(v.length()<l)for(var I,B,b,P=Math.floor(Math.random()*65536);v.length()<l;){B=16807*(P&65535),I=16807*(P>>16),B+=(I&32767)<<16,B+=I>>15,B=(B&2147483647)+(B>>31),P=B&4294967295;for(var S=0;S<3;++S)b=P>>>(S<<3),b^=Math.floor(Math.random()*256),v.putByte(b&255)}return v.getBytes(l)}return ia?(t.seedFile=function(l,c){ia.randomBytes(l,function(f,g){if(f)return c(f);c(null,g.toString())})},t.seedFileSync=function(l){return ia.randomBytes(l).toString()}):(t.seedFile=function(l,c){try{c(null,u(l))}catch(f){c(f)}},t.seedFileSync=u),t.collect=function(l){for(var c=l.length,f=0;f<c;++f)t.pools[t.pool].update(l.substr(f,1)),t.pool=t.pool===31?0:t.pool+1},t.collectInt=function(l,c){for(var f="",g=0;g<c;g+=8)f+=String.fromCharCode(l>>g&255);t.collect(f)},t.registerWorker=function(l){if(l===self)t.seedFile=function(f,g){function v(y){var x=y.data;x.forge&&x.forge.prng&&(self.removeEventListener("message",v),g(x.forge.prng.err,x.forge.prng.bytes))}self.addEventListener("message",v),self.postMessage({forge:{prng:{needed:f}}})};else{var c=function(f){var g=f.data;g.forge&&g.forge.prng&&t.seedFile(g.forge.prng.needed,function(v,y){l.postMessage({forge:{prng:{err:v,bytes:y}}})})};l.addEventListener("message",c)}},t}});var tt=F((Ph,Ga)=>{var Te=$();Rt();qa();Ha();re();(function(){if(Te.random&&Te.random.getBytes){Ga.exports=Te.random;return}(function(e){var t={},a=new Array(4),r=Te.util.createBuffer();t.formatKey=function(f){var g=Te.util.createBuffer(f);return f=new Array(4),f[0]=g.getInt32(),f[1]=g.getInt32(),f[2]=g.getInt32(),f[3]=g.getInt32(),Te.aes._expandKey(f,!1)},t.formatSeed=function(f){var g=Te.util.createBuffer(f);return f=new Array(4),f[0]=g.getInt32(),f[1]=g.getInt32(),f[2]=g.getInt32(),f[3]=g.getInt32(),f},t.cipher=function(f,g){return Te.aes._updateBlock(f,g,a,!1),r.putInt32(a[0]),r.putInt32(a[1]),r.putInt32(a[2]),r.putInt32(a[3]),r.getBytes()},t.increment=function(f){return++f[3],f},t.md=Te.md.sha256;function n(){var f=Te.prng.create(t);return f.getBytes=function(g,v){return f.generate(g,v)},f.getBytesSync=function(g){return f.generate(g)},f}var s=n(),i=null,o=Te.util.globalScope,u=o.crypto||o.msCrypto;if(u&&u.getRandomValues&&(i=function(f){return u.getRandomValues(f)}),Te.options.usePureJavaScript||!Te.util.isNodejs&&!i){if(typeof window>"u"||window.document,s.collectInt(+new Date,32),typeof navigator<"u"){var l="";for(var c in navigator)try{typeof navigator[c]=="string"&&(l+=navigator[c])}catch{}s.collect(l),l=null}e&&(e().mousemove(function(f){s.collectInt(f.clientX,16),s.collectInt(f.clientY,16)}),e().keypress(function(f){s.collectInt(f.charCode,8)}))}if(!Te.random)Te.random=s;else for(var c in s)Te.random[c]=s[c];Te.random.createInstance=n,Ga.exports=Te.random})(typeof jQuery<"u"?jQuery:null)})()});var Qa=F((Oh,ki)=>{var $e=$();re();var za=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],Ri=[1,2,3,5],y0=function(e,t){return e<<t&65535|(e&65535)>>16-t},v0=function(e,t){return(e&65535)>>t|e<<16-t&65535};ki.exports=$e.rc2=$e.rc2||{};$e.rc2.expandKey=function(e,t){typeof e=="string"&&(e=$e.util.createBuffer(e)),t=t||128;var a=e,r=e.length(),n=t,s=Math.ceil(n/8),i=255>>(n&7),o;for(o=r;o<128;o++)a.putByte(za[a.at(o-1)+a.at(o-r)&255]);for(a.setAt(128-s,za[a.at(128-s)&i]),o=127-s;o>=0;o--)a.setAt(o,za[a.at(o+1)^a.at(o+s)]);return a};var Li=function(e,t,a){var r=!1,n=null,s=null,i=null,o,u,l,c,f=[];for(e=$e.rc2.expandKey(e,t),l=0;l<64;l++)f.push(e.getInt16Le());a?(o=function(y){for(l=0;l<4;l++)y[l]+=f[c]+(y[(l+3)%4]&y[(l+2)%4])+(~y[(l+3)%4]&y[(l+1)%4]),y[l]=y0(y[l],Ri[l]),c++},u=function(y){for(l=0;l<4;l++)y[l]+=f[y[(l+3)%4]&63]}):(o=function(y){for(l=3;l>=0;l--)y[l]=v0(y[l],Ri[l]),y[l]-=f[c]+(y[(l+3)%4]&y[(l+2)%4])+(~y[(l+3)%4]&y[(l+1)%4]),c--},u=function(y){for(l=3;l>=0;l--)y[l]-=f[y[(l+3)%4]&63]});var g=function(y){var x=[];for(l=0;l<4;l++){var S=n.getInt16Le();i!==null&&(a?S^=i.getInt16Le():i.putInt16Le(S)),x.push(S&65535)}c=a?0:63;for(var I=0;I<y.length;I++)for(var B=0;B<y[I][0];B++)y[I][1](x);for(l=0;l<4;l++)i!==null&&(a?i.putInt16Le(x[l]):x[l]^=i.getInt16Le()),s.putInt16Le(x[l])},v=null;return v={start:function(y,x){y&&typeof y=="string"&&(y=$e.util.createBuffer(y)),r=!1,n=$e.util.createBuffer(),s=x||new $e.util.createBuffer,i=y,v.output=s},update:function(y){for(r||n.putBuffer(y);n.length()>=8;)g([[5,o],[1,u],[6,o],[1,u],[5,o]])},finish:function(y){var x=!0;if(a)if(y)x=y(8,n,!a);else{var S=n.length()===8?8:8-n.length();n.fillWithByte(S,S)}if(x&&(r=!0,v.update()),!a&&(x=n.length()===0,x))if(y)x=y(8,s,!a);else{var I=s.length(),B=s.at(I-1);B>I?x=!1:s.truncate(B)}return x}},v};$e.rc2.startEncrypting=function(e,t,a){var r=$e.rc2.createEncryptionCipher(e,128);return r.start(t,a),r};$e.rc2.createEncryptionCipher=function(e,t){return Li(e,t,!0)};$e.rc2.startDecrypting=function(e,t,a){var r=$e.rc2.createDecryptionCipher(e,128);return r.start(t,a),r};$e.rc2.createDecryptionCipher=function(e,t){return Li(e,t,!1)}});var wr=F((Vh,Mi)=>{var $a=$();Mi.exports=$a.jsbn=$a.jsbn||{};var It,m0=0xdeadbeefcafe,Di=(m0&16777215)==15715070;function _(e,t,a){this.data=[],e!=null&&(typeof e=="number"?this.fromNumber(e,t,a):t==null&&typeof e!="string"?this.fromString(e,256):this.fromString(e,t))}$a.jsbn.BigInteger=_;function Z(){return new _(null)}function C0(e,t,a,r,n,s){for(;--s>=0;){var i=t*this.data[e++]+a.data[r]+n;n=Math.floor(i/67108864),a.data[r++]=i&67108863}return n}function E0(e,t,a,r,n,s){for(var i=t&32767,o=t>>15;--s>=0;){var u=this.data[e]&32767,l=this.data[e++]>>15,c=o*u+l*i;u=i*u+((c&32767)<<15)+a.data[r]+(n&1073741823),n=(u>>>30)+(c>>>15)+o*l+(n>>>30),a.data[r++]=u&1073741823}return n}function Ui(e,t,a,r,n,s){for(var i=t&16383,o=t>>14;--s>=0;){var u=this.data[e]&16383,l=this.data[e++]>>14,c=o*u+l*i;u=i*u+((c&16383)<<14)+a.data[r]+n,n=(u>>28)+(c>>14)+o*l,a.data[r++]=u&268435455}return n}typeof navigator>"u"?(_.prototype.am=Ui,It=28):Di&&navigator.appName=="Microsoft Internet Explorer"?(_.prototype.am=E0,It=30):Di&&navigator.appName!="Netscape"?(_.prototype.am=C0,It=26):(_.prototype.am=Ui,It=28);_.prototype.DB=It;_.prototype.DM=(1<<It)-1;_.prototype.DV=1<<It;var Ya=52;_.prototype.FV=Math.pow(2,Ya);_.prototype.F1=Ya-It;_.prototype.F2=2*It-Ya;var x0="0123456789abcdefghijklmnopqrstuvwxyz",sa=new Array,or,rt;or=48;for(rt=0;rt<=9;++rt)sa[or++]=rt;or=97;for(rt=10;rt<36;++rt)sa[or++]=rt;or=65;for(rt=10;rt<36;++rt)sa[or++]=rt;function Pi(e){return x0.charAt(e)}function Oi(e,t){var a=sa[e.charCodeAt(t)];return a??-1}function S0(e){for(var t=this.t-1;t>=0;--t)e.data[t]=this.data[t];e.t=this.t,e.s=this.s}function T0(e){this.t=1,this.s=e<0?-1:0,e>0?this.data[0]=e:e<-1?this.data[0]=e+this.DV:this.t=0}function kt(e){var t=Z();return t.fromInt(e),t}function I0(e,t){var a;if(t==16)a=4;else if(t==8)a=3;else if(t==256)a=8;else if(t==2)a=1;else if(t==32)a=5;else if(t==4)a=2;else{this.fromRadix(e,t);return}this.t=0,this.s=0;for(var r=e.length,n=!1,s=0;--r>=0;){var i=a==8?e[r]&255:Oi(e,r);if(i<0){e.charAt(r)=="-"&&(n=!0);continue}n=!1,s==0?this.data[this.t++]=i:s+a>this.DB?(this.data[this.t-1]|=(i&(1<<this.DB-s)-1)<<s,this.data[this.t++]=i>>this.DB-s):this.data[this.t-1]|=i<<s,s+=a,s>=this.DB&&(s-=this.DB)}a==8&&(e[0]&128)!=0&&(this.s=-1,s>0&&(this.data[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),n&&_.ZERO.subTo(this,this)}function A0(){for(var e=this.s&this.DM;this.t>0&&this.data[this.t-1]==e;)--this.t}function B0(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(e==16)t=4;else if(e==8)t=3;else if(e==2)t=1;else if(e==32)t=5;else if(e==4)t=2;else return this.toRadix(e);var a=(1<<t)-1,r,n=!1,s="",i=this.t,o=this.DB-i*this.DB%t;if(i-- >0)for(o<this.DB&&(r=this.data[i]>>o)>0&&(n=!0,s=Pi(r));i>=0;)o<t?(r=(this.data[i]&(1<<o)-1)<<t-o,r|=this.data[--i]>>(o+=this.DB-t)):(r=this.data[i]>>(o-=t)&a,o<=0&&(o+=this.DB,--i)),r>0&&(n=!0),n&&(s+=Pi(r));return n?s:"0"}function b0(){var e=Z();return _.ZERO.subTo(this,e),e}function _0(){return this.s<0?this.negate():this}function w0(e){var t=this.s-e.s;if(t!=0)return t;var a=this.t;if(t=a-e.t,t!=0)return this.s<0?-t:t;for(;--a>=0;)if((t=this.data[a]-e.data[a])!=0)return t;return 0}function oa(e){var t=1,a;return(a=e>>>16)!=0&&(e=a,t+=16),(a=e>>8)!=0&&(e=a,t+=8),(a=e>>4)!=0&&(e=a,t+=4),(a=e>>2)!=0&&(e=a,t+=2),(a=e>>1)!=0&&(e=a,t+=1),t}function N0(){return this.t<=0?0:this.DB*(this.t-1)+oa(this.data[this.t-1]^this.s&this.DM)}function R0(e,t){var a;for(a=this.t-1;a>=0;--a)t.data[a+e]=this.data[a];for(a=e-1;a>=0;--a)t.data[a]=0;t.t=this.t+e,t.s=this.s}function L0(e,t){for(var a=e;a<this.t;++a)t.data[a-e]=this.data[a];t.t=Math.max(this.t-e,0),t.s=this.s}function k0(e,t){var a=e%this.DB,r=this.DB-a,n=(1<<r)-1,s=Math.floor(e/this.DB),i=this.s<<a&this.DM,o;for(o=this.t-1;o>=0;--o)t.data[o+s+1]=this.data[o]>>r|i,i=(this.data[o]&n)<<a;for(o=s-1;o>=0;--o)t.data[o]=0;t.data[s]=i,t.t=this.t+s+1,t.s=this.s,t.clamp()}function D0(e,t){t.s=this.s;var a=Math.floor(e/this.DB);if(a>=this.t){t.t=0;return}var r=e%this.DB,n=this.DB-r,s=(1<<r)-1;t.data[0]=this.data[a]>>r;for(var i=a+1;i<this.t;++i)t.data[i-a-1]|=(this.data[i]&s)<<n,t.data[i-a]=this.data[i]>>r;r>0&&(t.data[this.t-a-1]|=(this.s&s)<<n),t.t=this.t-a,t.clamp()}function U0(e,t){for(var a=0,r=0,n=Math.min(e.t,this.t);a<n;)r+=this.data[a]-e.data[a],t.data[a++]=r&this.DM,r>>=this.DB;if(e.t<this.t){for(r-=e.s;a<this.t;)r+=this.data[a],t.data[a++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;a<e.t;)r-=e.data[a],t.data[a++]=r&this.DM,r>>=this.DB;r-=e.s}t.s=r<0?-1:0,r<-1?t.data[a++]=this.DV+r:r>0&&(t.data[a++]=r),t.t=a,t.clamp()}function P0(e,t){var a=this.abs(),r=e.abs(),n=a.t;for(t.t=n+r.t;--n>=0;)t.data[n]=0;for(n=0;n<r.t;++n)t.data[n+a.t]=a.am(0,r.data[n],t,n,0,a.t);t.s=0,t.clamp(),this.s!=e.s&&_.ZERO.subTo(t,t)}function O0(e){for(var t=this.abs(),a=e.t=2*t.t;--a>=0;)e.data[a]=0;for(a=0;a<t.t-1;++a){var r=t.am(a,t.data[a],e,2*a,0,1);(e.data[a+t.t]+=t.am(a+1,2*t.data[a],e,2*a+1,r,t.t-a-1))>=t.DV&&(e.data[a+t.t]-=t.DV,e.data[a+t.t+1]=1)}e.t>0&&(e.data[e.t-1]+=t.am(a,t.data[a],e,2*a,0,1)),e.s=0,e.clamp()}function V0(e,t,a){var r=e.abs();if(!(r.t<=0)){var n=this.abs();if(n.t<r.t){t?.fromInt(0),a!=null&&this.copyTo(a);return}a==null&&(a=Z());var s=Z(),i=this.s,o=e.s,u=this.DB-oa(r.data[r.t-1]);u>0?(r.lShiftTo(u,s),n.lShiftTo(u,a)):(r.copyTo(s),n.copyTo(a));var l=s.t,c=s.data[l-1];if(c!=0){var f=c*(1<<this.F1)+(l>1?s.data[l-2]>>this.F2:0),g=this.FV/f,v=(1<<this.F1)/f,y=1<<this.F2,x=a.t,S=x-l,I=t??Z();for(s.dlShiftTo(S,I),a.compareTo(I)>=0&&(a.data[a.t++]=1,a.subTo(I,a)),_.ONE.dlShiftTo(l,I),I.subTo(s,s);s.t<l;)s.data[s.t++]=0;for(;--S>=0;){var B=a.data[--x]==c?this.DM:Math.floor(a.data[x]*g+(a.data[x-1]+y)*v);if((a.data[x]+=s.am(0,B,a,S,0,l))<B)for(s.dlShiftTo(S,I),a.subTo(I,a);a.data[x]<--B;)a.subTo(I,a)}t!=null&&(a.drShiftTo(l,t),i!=o&&_.ZERO.subTo(t,t)),a.t=l,a.clamp(),u>0&&a.rShiftTo(u,a),i<0&&_.ZERO.subTo(a,a)}}}function F0(e){var t=Z();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(_.ZERO)>0&&e.subTo(t,t),t}function $t(e){this.m=e}function K0(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e}function M0(e){return e}function q0(e){e.divRemTo(this.m,null,e)}function H0(e,t,a){e.multiplyTo(t,a),this.reduce(a)}function G0(e,t){e.squareTo(t),this.reduce(t)}$t.prototype.convert=K0;$t.prototype.revert=M0;$t.prototype.reduce=q0;$t.prototype.mulTo=H0;$t.prototype.sqrTo=G0;function z0(){if(this.t<1)return 0;var e=this.data[0];if((e&1)==0)return 0;var t=e&3;return t=t*(2-(e&15)*t)&15,t=t*(2-(e&255)*t)&255,t=t*(2-((e&65535)*t&65535))&65535,t=t*(2-e*t%this.DV)%this.DV,t>0?this.DV-t:-t}function Yt(e){this.m=e,this.mp=e.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function Q0(e){var t=Z();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(_.ZERO)>0&&this.m.subTo(t,t),t}function $0(e){var t=Z();return e.copyTo(t),this.reduce(t),t}function Y0(e){for(;e.t<=this.mt2;)e.data[e.t++]=0;for(var t=0;t<this.m.t;++t){var a=e.data[t]&32767,r=a*this.mpl+((a*this.mph+(e.data[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(a=t+this.m.t,e.data[a]+=this.m.am(0,r,e,t,0,this.m.t);e.data[a]>=e.DV;)e.data[a]-=e.DV,e.data[++a]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)}function j0(e,t){e.squareTo(t),this.reduce(t)}function W0(e,t,a){e.multiplyTo(t,a),this.reduce(a)}Yt.prototype.convert=Q0;Yt.prototype.revert=$0;Yt.prototype.reduce=Y0;Yt.prototype.mulTo=W0;Yt.prototype.sqrTo=j0;function X0(){return(this.t>0?this.data[0]&1:this.s)==0}function J0(e,t){if(e>4294967295||e<1)return _.ONE;var a=Z(),r=Z(),n=t.convert(this),s=oa(e)-1;for(n.copyTo(a);--s>=0;)if(t.sqrTo(a,r),(e&1<<s)>0)t.mulTo(r,n,a);else{var i=a;a=r,r=i}return t.revert(a)}function Z0(e,t){var a;return e<256||t.isEven()?a=new $t(t):a=new Yt(t),this.exp(e,a)}_.prototype.copyTo=S0;_.prototype.fromInt=T0;_.prototype.fromString=I0;_.prototype.clamp=A0;_.prototype.dlShiftTo=R0;_.prototype.drShiftTo=L0;_.prototype.lShiftTo=k0;_.prototype.rShiftTo=D0;_.prototype.subTo=U0;_.prototype.multiplyTo=P0;_.prototype.squareTo=O0;_.prototype.divRemTo=V0;_.prototype.invDigit=z0;_.prototype.isEven=X0;_.prototype.exp=J0;_.prototype.toString=B0;_.prototype.negate=b0;_.prototype.abs=_0;_.prototype.compareTo=w0;_.prototype.bitLength=N0;_.prototype.mod=F0;_.prototype.modPowInt=Z0;_.ZERO=kt(0);_.ONE=kt(1);function el(){var e=Z();return this.copyTo(e),e}function tl(){if(this.s<0){if(this.t==1)return this.data[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this.data[0];if(this.t==0)return 0}return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]}function rl(){return this.t==0?this.s:this.data[0]<<24>>24}function al(){return this.t==0?this.s:this.data[0]<<16>>16}function nl(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}function il(){return this.s<0?-1:this.t<=0||this.t==1&&this.data[0]<=0?0:1}function sl(e){if(e==null&&(e=10),this.signum()==0||e<2||e>36)return"0";var t=this.chunkSize(e),a=Math.pow(e,t),r=kt(a),n=Z(),s=Z(),i="";for(this.divRemTo(r,n,s);n.signum()>0;)i=(a+s.intValue()).toString(e).substr(1)+i,n.divRemTo(r,n,s);return s.intValue().toString(e)+i}function ol(e,t){this.fromInt(0),t==null&&(t=10);for(var a=this.chunkSize(t),r=Math.pow(t,a),n=!1,s=0,i=0,o=0;o<e.length;++o){var u=Oi(e,o);if(u<0){e.charAt(o)=="-"&&this.signum()==0&&(n=!0);continue}i=t*i+u,++s>=a&&(this.dMultiply(r),this.dAddOffset(i,0),s=0,i=0)}s>0&&(this.dMultiply(Math.pow(t,s)),this.dAddOffset(i,0)),n&&_.ZERO.subTo(this,this)}function ul(e,t,a){if(typeof t=="number")if(e<2)this.fromInt(1);else for(this.fromNumber(e,a),this.testBit(e-1)||this.bitwiseTo(_.ONE.shiftLeft(e-1),ja,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(_.ONE.shiftLeft(e-1),this);else{var r=new Array,n=e&7;r.length=(e>>3)+1,t.nextBytes(r),n>0?r[0]&=(1<<n)-1:r[0]=0,this.fromString(r,256)}}function ll(){var e=this.t,t=new Array;t[0]=this.s;var a=this.DB-e*this.DB%8,r,n=0;if(e-- >0)for(a<this.DB&&(r=this.data[e]>>a)!=(this.s&this.DM)>>a&&(t[n++]=r|this.s<<this.DB-a);e>=0;)a<8?(r=(this.data[e]&(1<<a)-1)<<8-a,r|=this.data[--e]>>(a+=this.DB-8)):(r=this.data[e]>>(a-=8)&255,a<=0&&(a+=this.DB,--e)),(r&128)!=0&&(r|=-256),n==0&&(this.s&128)!=(r&128)&&++n,(n>0||r!=this.s)&&(t[n++]=r);return t}function cl(e){return this.compareTo(e)==0}function fl(e){return this.compareTo(e)<0?this:e}function dl(e){return this.compareTo(e)>0?this:e}function hl(e,t,a){var r,n,s=Math.min(e.t,this.t);for(r=0;r<s;++r)a.data[r]=t(this.data[r],e.data[r]);if(e.t<this.t){for(n=e.s&this.DM,r=s;r<this.t;++r)a.data[r]=t(this.data[r],n);a.t=this.t}else{for(n=this.s&this.DM,r=s;r<e.t;++r)a.data[r]=t(n,e.data[r]);a.t=e.t}a.s=t(this.s,e.s),a.clamp()}function pl(e,t){return e&t}function gl(e){var t=Z();return this.bitwiseTo(e,pl,t),t}function ja(e,t){return e|t}function yl(e){var t=Z();return this.bitwiseTo(e,ja,t),t}function Vi(e,t){return e^t}function vl(e){var t=Z();return this.bitwiseTo(e,Vi,t),t}function Fi(e,t){return e&~t}function ml(e){var t=Z();return this.bitwiseTo(e,Fi,t),t}function Cl(){for(var e=Z(),t=0;t<this.t;++t)e.data[t]=this.DM&~this.data[t];return e.t=this.t,e.s=~this.s,e}function El(e){var t=Z();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t}function xl(e){var t=Z();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t}function Sl(e){if(e==0)return-1;var t=0;return(e&65535)==0&&(e>>=16,t+=16),(e&255)==0&&(e>>=8,t+=8),(e&15)==0&&(e>>=4,t+=4),(e&3)==0&&(e>>=2,t+=2),(e&1)==0&&++t,t}function Tl(){for(var e=0;e<this.t;++e)if(this.data[e]!=0)return e*this.DB+Sl(this.data[e]);return this.s<0?this.t*this.DB:-1}function Il(e){for(var t=0;e!=0;)e&=e-1,++t;return t}function Al(){for(var e=0,t=this.s&this.DM,a=0;a<this.t;++a)e+=Il(this.data[a]^t);return e}function Bl(e){var t=Math.floor(e/this.DB);return t>=this.t?this.s!=0:(this.data[t]&1<<e%this.DB)!=0}function bl(e,t){var a=_.ONE.shiftLeft(e);return this.bitwiseTo(a,t,a),a}function _l(e){return this.changeBit(e,ja)}function wl(e){return this.changeBit(e,Fi)}function Nl(e){return this.changeBit(e,Vi)}function Rl(e,t){for(var a=0,r=0,n=Math.min(e.t,this.t);a<n;)r+=this.data[a]+e.data[a],t.data[a++]=r&this.DM,r>>=this.DB;if(e.t<this.t){for(r+=e.s;a<this.t;)r+=this.data[a],t.data[a++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;a<e.t;)r+=e.data[a],t.data[a++]=r&this.DM,r>>=this.DB;r+=e.s}t.s=r<0?-1:0,r>0?t.data[a++]=r:r<-1&&(t.data[a++]=this.DV+r),t.t=a,t.clamp()}function Ll(e){var t=Z();return this.addTo(e,t),t}function kl(e){var t=Z();return this.subTo(e,t),t}function Dl(e){var t=Z();return this.multiplyTo(e,t),t}function Ul(){var e=Z();return this.squareTo(e),e}function Pl(e){var t=Z();return this.divRemTo(e,t,null),t}function Ol(e){var t=Z();return this.divRemTo(e,null,t),t}function Vl(e){var t=Z(),a=Z();return this.divRemTo(e,t,a),new Array(t,a)}function Fl(e){this.data[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}function Kl(e,t){if(e!=0){for(;this.t<=t;)this.data[this.t++]=0;for(this.data[t]+=e;this.data[t]>=this.DV;)this.data[t]-=this.DV,++t>=this.t&&(this.data[this.t++]=0),++this.data[t]}}function _r(){}function Ki(e){return e}function Ml(e,t,a){e.multiplyTo(t,a)}function ql(e,t){e.squareTo(t)}_r.prototype.convert=Ki;_r.prototype.revert=Ki;_r.prototype.mulTo=Ml;_r.prototype.sqrTo=ql;function Hl(e){return this.exp(e,new _r)}function Gl(e,t,a){var r=Math.min(this.t+e.t,t);for(a.s=0,a.t=r;r>0;)a.data[--r]=0;var n;for(n=a.t-this.t;r<n;++r)a.data[r+this.t]=this.am(0,e.data[r],a,r,0,this.t);for(n=Math.min(e.t,t);r<n;++r)this.am(0,e.data[r],a,r,0,t-r);a.clamp()}function zl(e,t,a){--t;var r=a.t=this.t+e.t-t;for(a.s=0;--r>=0;)a.data[r]=0;for(r=Math.max(t-this.t,0);r<e.t;++r)a.data[this.t+r-t]=this.am(t-r,e.data[r],a,0,0,this.t+r-t);a.clamp(),a.drShiftTo(1,a)}function ur(e){this.r2=Z(),this.q3=Z(),_.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}function Ql(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 t=Z();return e.copyTo(t),this.reduce(t),t}function $l(e){return e}function Yl(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)}function jl(e,t){e.squareTo(t),this.reduce(t)}function Wl(e,t,a){e.multiplyTo(t,a),this.reduce(a)}ur.prototype.convert=Ql;ur.prototype.revert=$l;ur.prototype.reduce=Yl;ur.prototype.mulTo=Wl;ur.prototype.sqrTo=jl;function Xl(e,t){var a=e.bitLength(),r,n=kt(1),s;if(a<=0)return n;a<18?r=1:a<48?r=3:a<144?r=4:a<768?r=5:r=6,a<8?s=new $t(t):t.isEven()?s=new ur(t):s=new Yt(t);var i=new Array,o=3,u=r-1,l=(1<<r)-1;if(i[1]=s.convert(this),r>1){var c=Z();for(s.sqrTo(i[1],c);o<=l;)i[o]=Z(),s.mulTo(c,i[o-2],i[o]),o+=2}var f=e.t-1,g,v=!0,y=Z(),x;for(a=oa(e.data[f])-1;f>=0;){for(a>=u?g=e.data[f]>>a-u&l:(g=(e.data[f]&(1<<a+1)-1)<<u-a,f>0&&(g|=e.data[f-1]>>this.DB+a-u)),o=r;(g&1)==0;)g>>=1,--o;if((a-=o)<0&&(a+=this.DB,--f),v)i[g].copyTo(n),v=!1;else{for(;o>1;)s.sqrTo(n,y),s.sqrTo(y,n),o-=2;o>0?s.sqrTo(n,y):(x=n,n=y,y=x),s.mulTo(y,i[g],n)}for(;f>=0&&(e.data[f]&1<<a)==0;)s.sqrTo(n,y),x=n,n=y,y=x,--a<0&&(a=this.DB-1,--f)}return s.revert(n)}function Jl(e){var t=this.s<0?this.negate():this.clone(),a=e.s<0?e.negate():e.clone();if(t.compareTo(a)<0){var r=t;t=a,a=r}var n=t.getLowestSetBit(),s=a.getLowestSetBit();if(s<0)return t;for(n<s&&(s=n),s>0&&(t.rShiftTo(s,t),a.rShiftTo(s,a));t.signum()>0;)(n=t.getLowestSetBit())>0&&t.rShiftTo(n,t),(n=a.getLowestSetBit())>0&&a.rShiftTo(n,a),t.compareTo(a)>=0?(t.subTo(a,t),t.rShiftTo(1,t)):(a.subTo(t,a),a.rShiftTo(1,a));return s>0&&a.lShiftTo(s,a),a}function Zl(e){if(e<=0)return 0;var t=this.DV%e,a=this.s<0?e-1:0;if(this.t>0)if(t==0)a=this.data[0]%e;else for(var r=this.t-1;r>=0;--r)a=(t*a+this.data[r])%e;return a}function ec(e){if(this.signum()==0)return _.ZERO;var t=e.isEven();if(this.isEven()&&t||e.signum()==0)return _.ZERO;for(var a=e.clone(),r=this.clone(),n=kt(1),s=kt(0),i=kt(0),o=kt(1);a.signum()!=0;){for(;a.isEven();)a.rShiftTo(1,a),t?((!n.isEven()||!s.isEven())&&(n.addTo(this,n),s.subTo(e,s)),n.rShiftTo(1,n)):s.isEven()||s.subTo(e,s),s.rShiftTo(1,s);for(;r.isEven();)r.rShiftTo(1,r),t?((!i.isEven()||!o.isEven())&&(i.addTo(this,i),o.subTo(e,o)),i.rShiftTo(1,i)):o.isEven()||o.subTo(e,o),o.rShiftTo(1,o);a.compareTo(r)>=0?(a.subTo(r,a),t&&n.subTo(i,n),s.subTo(o,s)):(r.subTo(a,r),t&&i.subTo(n,i),o.subTo(s,o))}if(r.compareTo(_.ONE)!=0)return _.ZERO;if(o.compareTo(e)>=0)return o.subtract(e);if(o.signum()<0)o.addTo(e,o);else return o;return o.signum()<0?o.add(e):o}var ct=[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],tc=(1<<26)/ct[ct.length-1];function rc(e){var t,a=this.abs();if(a.t==1&&a.data[0]<=ct[ct.length-1]){for(t=0;t<ct.length;++t)if(a.data[0]==ct[t])return!0;return!1}if(a.isEven())return!1;for(t=1;t<ct.length;){for(var r=ct[t],n=t+1;n<ct.length&&r<tc;)r*=ct[n++];for(r=a.modInt(r);t<n;)if(r%ct[t++]==0)return!1}return a.millerRabin(e)}function ac(e){var t=this.subtract(_.ONE),a=t.getLowestSetBit();if(a<=0)return!1;for(var r=t.shiftRight(a),n=nc(),s,i=0;i<e;++i){do s=new _(this.bitLength(),n);while(s.compareTo(_.ONE)<=0||s.compareTo(t)>=0);var o=s.modPow(r,this);if(o.compareTo(_.ONE)!=0&&o.compareTo(t)!=0){for(var u=1;u++<a&&o.compareTo(t)!=0;)if(o=o.modPowInt(2,this),o.compareTo(_.ONE)==0)return!1;if(o.compareTo(t)!=0)return!1}}return!0}function nc(){return{nextBytes:function(e){for(var t=0;t<e.length;++t)e[t]=Math.floor(Math.random()*256)}}}_.prototype.chunkSize=nl;_.prototype.toRadix=sl;_.prototype.fromRadix=ol;_.prototype.fromNumber=ul;_.prototype.bitwiseTo=hl;_.prototype.changeBit=bl;_.prototype.addTo=Rl;_.prototype.dMultiply=Fl;_.prototype.dAddOffset=Kl;_.prototype.multiplyLowerTo=Gl;_.prototype.multiplyUpperTo=zl;_.prototype.modInt=Zl;_.prototype.millerRabin=ac;_.prototype.clone=el;_.prototype.intValue=tl;_.prototype.byteValue=rl;_.prototype.shortValue=al;_.prototype.signum=il;_.prototype.toByteArray=ll;_.prototype.equals=cl;_.prototype.min=fl;_.prototype.max=dl;_.prototype.and=gl;_.prototype.or=yl;_.prototype.xor=vl;_.prototype.andNot=ml;_.prototype.not=Cl;_.prototype.shiftLeft=El;_.prototype.shiftRight=xl;_.prototype.getLowestSetBit=Tl;_.prototype.bitCount=Al;_.prototype.testBit=Bl;_.prototype.setBit=_l;_.prototype.clearBit=wl;_.prototype.flipBit=Nl;_.prototype.add=Ll;_.prototype.subtract=kl;_.prototype.multiply=Dl;_.prototype.divide=Pl;_.prototype.remainder=Ol;_.prototype.divideAndRemainder=Vl;_.prototype.modPow=Xl;_.prototype.modInverse=ec;_.prototype.pow=Hl;_.prototype.gcd=Jl;_.prototype.isProbablePrime=rc;_.prototype.square=Ul});var lr=F((Fh,zi)=>{var yt=$();ft();re();var Hi=zi.exports=yt.sha1=yt.sha1||{};yt.md.sha1=yt.md.algorithms.sha1=Hi;Hi.create=function(){Gi||ic();var e=null,t=yt.util.createBuffer(),a=new Array(80),r={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8};return r.start=function(){r.messageLength=0,r.fullMessageLength=r.messageLength64=[];for(var n=r.messageLengthSize/4,s=0;s<n;++s)r.fullMessageLength.push(0);return t=yt.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},r},r.start(),r.update=function(n,s){s==="utf8"&&(n=yt.util.encodeUtf8(n));var i=n.length;r.messageLength+=i,i=[i/4294967296>>>0,i>>>0];for(var o=r.fullMessageLength.length-1;o>=0;--o)r.fullMessageLength[o]+=i[1],i[1]=i[0]+(r.fullMessageLength[o]/4294967296>>>0),r.fullMessageLength[o]=r.fullMessageLength[o]>>>0,i[0]=i[1]/4294967296>>>0;return t.putBytes(n),qi(e,a,t),(t.read>2048||t.length()===0)&&t.compact(),r},r.digest=function(){var n=yt.util.createBuffer();n.putBytes(t.bytes());var s=r.fullMessageLength[r.fullMessageLength.length-1]+r.messageLengthSize,i=s&r.blockLength-1;n.putBytes(Wa.substr(0,r.blockLength-i));for(var o,u,l=r.fullMessageLength[0]*8,c=0;c<r.fullMessageLength.length-1;++c)o=r.fullMessageLength[c+1]*8,u=o/4294967296>>>0,l+=u,n.putInt32(l>>>0),l=o>>>0;n.putInt32(l);var f={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};qi(f,a,n);var g=yt.util.createBuffer();return g.putInt32(f.h0),g.putInt32(f.h1),g.putInt32(f.h2),g.putInt32(f.h3),g.putInt32(f.h4),g},r};var Wa=null,Gi=!1;function ic(){Wa="\x80",Wa+=yt.util.fillString("\0",64),Gi=!0}function qi(e,t,a){for(var r,n,s,i,o,u,l,c,f=a.length();f>=64;){for(n=e.h0,s=e.h1,i=e.h2,o=e.h3,u=e.h4,c=0;c<16;++c)r=a.getInt32(),t[c]=r,l=o^s&(i^o),r=(n<<5|n>>>27)+l+u+1518500249+r,u=o,o=i,i=(s<<30|s>>>2)>>>0,s=n,n=r;for(;c<20;++c)r=t[c-3]^t[c-8]^t[c-14]^t[c-16],r=r<<1|r>>>31,t[c]=r,l=o^s&(i^o),r=(n<<5|n>>>27)+l+u+1518500249+r,u=o,o=i,i=(s<<30|s>>>2)>>>0,s=n,n=r;for(;c<32;++c)r=t[c-3]^t[c-8]^t[c-14]^t[c-16],r=r<<1|r>>>31,t[c]=r,l=s^i^o,r=(n<<5|n>>>27)+l+u+1859775393+r,u=o,o=i,i=(s<<30|s>>>2)>>>0,s=n,n=r;for(;c<40;++c)r=t[c-6]^t[c-16]^t[c-28]^t[c-32],r=r<<2|r>>>30,t[c]=r,l=s^i^o,r=(n<<5|n>>>27)+l+u+1859775393+r,u=o,o=i,i=(s<<30|s>>>2)>>>0,s=n,n=r;for(;c<60;++c)r=t[c-6]^t[c-16]^t[c-28]^t[c-32],r=r<<2|r>>>30,t[c]=r,l=s&i|o&(s^i),r=(n<<5|n>>>27)+l+u+2400959708+r,u=o,o=i,i=(s<<30|s>>>2)>>>0,s=n,n=r;for(;c<80;++c)r=t[c-6]^t[c-16]^t[c-28]^t[c-32],r=r<<2|r>>>30,t[c]=r,l=s^i^o,r=(n<<5|n>>>27)+l+u+3395469782+r,u=o,o=i,i=(s<<30|s>>>2)>>>0,s=n,n=r;e.h0=e.h0+n|0,e.h1=e.h1+s|0,e.h2=e.h2+i|0,e.h3=e.h3+o|0,e.h4=e.h4+u|0,f-=64}}});var Xa=F((Kh,$i)=>{var vt=$();re();tt();lr();var Qi=$i.exports=vt.pkcs1=vt.pkcs1||{};Qi.encode_rsa_oaep=function(e,t,a){var r,n,s,i;typeof a=="string"?(r=a,n=arguments[3]||void 0,s=arguments[4]||void 0):a&&(r=a.label||void 0,n=a.seed||void 0,s=a.md||void 0,a.mgf1&&a.mgf1.md&&(i=a.mgf1.md)),s?s.start():s=vt.md.sha1.create(),i||(i=s);var o=Math.ceil(e.n.bitLength()/8),u=o-2*s.digestLength-2;if(t.length>u){var l=new Error("RSAES-OAEP input message length is too long.");throw l.length=t.length,l.maxLength=u,l}r||(r=""),s.update(r,"raw");for(var c=s.digest(),f="",g=u-t.length,v=0;v<g;v++)f+="\0";var y=c.getBytes()+f+""+t;if(!n)n=vt.random.getBytes(s.digestLength);else if(n.length!==s.digestLength){var l=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.");throw l.seedLength=n.length,l.digestLength=s.digestLength,l}var x=ua(n,o-s.digestLength-1,i),S=vt.util.xorBytes(y,x,y.length),I=ua(S,s.digestLength,i),B=vt.util.xorBytes(n,I,n.length);return"\0"+B+S};Qi.decode_rsa_oaep=function(e,t,a){var r,n,s;typeof a=="string"?(r=a,n=arguments[3]||void 0):a&&(r=a.label||void 0,n=a.md||void 0,a.mgf1&&a.mgf1.md&&(s=a.mgf1.md));var i=Math.ceil(e.n.bitLength()/8);if(t.length!==i){var S=new Error("RSAES-OAEP encoded message length is invalid.");throw S.length=t.length,S.expectedLength=i,S}if(n===void 0?n=vt.md.sha1.create():n.start(),s||(s=n),i<2*n.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");r||(r=""),n.update(r,"raw");for(var o=n.digest().getBytes(),u=t.charAt(0),l=t.substring(1,n.digestLength+1),c=t.substring(1+n.digestLength),f=ua(c,n.digestLength,s),g=vt.util.xorBytes(l,f,l.length),v=ua(g,i-n.digestLength-1,s),y=vt.util.xorBytes(c,v,c.length),x=y.substring(0,n.digestLength),S=u!=="\0",I=0;I<n.digestLength;++I)S|=o.charAt(I)!==x.charAt(I);for(var B=1,b=n.digestLength,P=n.digestLength;P<y.length;P++){var k=y.charCodeAt(P),R=k&1^1,z=B?65534:0;S|=k&z,B=B&R,b+=B}if(S||y.charCodeAt(b)!==1)throw new Error("Invalid RSAES-OAEP padding.");return y.substring(b+1)};function ua(e,t,a){a||(a=vt.md.sha1.create());for(var r="",n=Math.ceil(t/a.digestLength),s=0;s<n;++s){var i=String.fromCharCode(s>>24&255,s>>16&255,s>>8&255,s&255);a.start(),a.update(e+i),r+=a.digest().getBytes()}return r.substring(0,t)}});var Za=F((Mh,Ja)=>{var Dt=$();re();wr();tt();(function(){if(Dt.prime){Ja.exports=Dt.prime;return}var e=Ja.exports=Dt.prime=Dt.prime||{},t=Dt.jsbn.BigInteger,a=[6,4,2,4,2,4,6,2],r=new t(null);r.fromInt(30);var n=function(f,g){return f|g};e.generateProbablePrime=function(f,g,v){typeof g=="function"&&(v=g,g={}),g=g||{};var y=g.algorithm||"PRIMEINC";typeof y=="string"&&(y={name:y}),y.options=y.options||{};var x=g.prng||Dt.random,S={nextBytes:function(I){for(var B=x.getBytesSync(I.length),b=0;b<I.length;++b)I[b]=B.charCodeAt(b)}};if(y.name==="PRIMEINC")return s(f,S,y.options,v);throw new Error("Invalid prime generation algorithm: "+y.name)};function s(f,g,v,y){return"workers"in v?u(f,g,v,y):i(f,g,v,y)}function i(f,g,v,y){var x=l(f,g),S=0,I=c(x.bitLength());"millerRabinTests"in v&&(I=v.millerRabinTests);var B=10;"maxBlockTime"in v&&(B=v.maxBlockTime),o(x,f,g,S,I,B,y)}function o(f,g,v,y,x,S,I){var B=+new Date;do{if(f.bitLength()>g&&(f=l(g,v)),f.isProbablePrime(x))return I(null,f);f.dAddOffset(a[y++%8],0)}while(S<0||+new Date-B<S);Dt.util.setImmediate(function(){o(f,g,v,y,x,S,I)})}function u(f,g,v,y){if(typeof Worker>"u")return i(f,g,v,y);var x=l(f,g),S=v.workers,I=v.workLoad||100,B=I*30/8,b=v.workerScript||"forge/prime.worker.js";if(S===-1)return Dt.util.estimateCores(function(k,R){k&&(R=2),S=R-1,P()});P();function P(){S=Math.max(1,S);for(var k=[],R=0;R<S;++R)k[R]=new Worker(b);for(var z=S,R=0;R<S;++R)k[R].addEventListener("message",ne);var Y=!1;function ne(ie){if(!Y){--z;var ue=ie.data;if(ue.found){for(var fe=0;fe<k.length;++fe)k[fe].terminate();return Y=!0,y(null,new t(ue.prime,16))}x.bitLength()>f&&(x=l(f,g));var qe=x.toString(16);ie.target.postMessage({hex:qe,workLoad:I}),x.dAddOffset(B,0)}}}}function l(f,g){var v=new t(f,g),y=f-1;return v.testBit(y)||v.bitwiseTo(t.ONE.shiftLeft(y),n,v),v.dAddOffset(31-v.mod(r).byteValue(),0),v}function c(f){return f<=100?27:f<=150?18:f<=200?15:f<=250?12:f<=300?9:f<=350?8:f<=400?7:f<=500?6:f<=600?5:f<=800?4:f<=1250?3:2}})()});var Nr=F((qh,es)=>{var M=$();lt();wr();Lt();Xa();Za();tt();re();typeof ee>"u"&&(ee=M.jsbn.BigInteger);var ee,en=M.util.isNodejs?require("crypto"):null,T=M.asn1,at=M.util;M.pki=M.pki||{};es.exports=M.pki.rsa=M.rsa=M.rsa||{};var G=M.pki,sc=[6,4,2,4,2,4,6,2],oc={name:"PrivateKeyInfo",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:T.Class.UNIVERSAL,type:T.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:T.Class.UNIVERSAL,type:T.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},uc={name:"RSAPrivateKey",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},lc={name:"RSAPublicKey",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},cc=M.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:T.Class.UNIVERSAL,type:T.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:T.Class.UNIVERSAL,type:T.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},fc={name:"DigestInfo",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:T.Class.UNIVERSAL,type:T.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:T.Class.UNIVERSAL,type:T.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:T.Class.UNIVERSAL,type:T.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},dc=function(e){var t;if(e.algorithm in G.oids)t=G.oids[e.algorithm];else{var a=new Error("Unknown message digest algorithm.");throw a.algorithm=e.algorithm,a}var r=T.oidToDer(t).getBytes(),n=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[]),s=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[]);s.value.push(T.create(T.Class.UNIVERSAL,T.Type.OID,!1,r)),s.value.push(T.create(T.Class.UNIVERSAL,T.Type.NULL,!1,""));var i=T.create(T.Class.UNIVERSAL,T.Type.OCTETSTRING,!1,e.digest().getBytes());return n.value.push(s),n.value.push(i),T.toDer(n).getBytes()},Ji=function(e,t,a){if(a)return e.modPow(t.e,t.n);if(!t.p||!t.q)return e.modPow(t.d,t.n);t.dP||(t.dP=t.d.mod(t.p.subtract(ee.ONE))),t.dQ||(t.dQ=t.d.mod(t.q.subtract(ee.ONE))),t.qInv||(t.qInv=t.q.modInverse(t.p));var r;do r=new ee(M.util.bytesToHex(M.random.getBytes(t.n.bitLength()/8)),16);while(r.compareTo(t.n)>=0||!r.gcd(t.n).equals(ee.ONE));e=e.multiply(r.modPow(t.e,t.n)).mod(t.n);for(var n=e.mod(t.p).modPow(t.dP,t.p),s=e.mod(t.q).modPow(t.dQ,t.q);n.compareTo(s)<0;)n=n.add(t.p);var i=n.subtract(s).multiply(t.qInv).mod(t.p).multiply(t.q).add(s);return i=i.multiply(r.modInverse(t.n)).mod(t.n),i};G.rsa.encrypt=function(e,t,a){var r=a,n,s=Math.ceil(t.n.bitLength()/8);a!==!1&&a!==!0?(r=a===2,n=Zi(e,t,a)):(n=M.util.createBuffer(),n.putBytes(e));for(var i=new ee(n.toHex(),16),o=Ji(i,t,r),u=o.toString(16),l=M.util.createBuffer(),c=s-Math.ceil(u.length/2);c>0;)l.putByte(0),--c;return l.putBytes(M.util.hexToBytes(u)),l.getBytes()};G.rsa.decrypt=function(e,t,a,r){var n=Math.ceil(t.n.bitLength()/8);if(e.length!==n){var s=new Error("Encrypted message length is invalid.");throw s.length=e.length,s.expected=n,s}var i=new ee(M.util.createBuffer(e).toHex(),16);if(i.compareTo(t.n)>=0)throw new Error("Encrypted message is invalid.");for(var o=Ji(i,t,a),u=o.toString(16),l=M.util.createBuffer(),c=n-Math.ceil(u.length/2);c>0;)l.putByte(0),--c;return l.putBytes(M.util.hexToBytes(u)),r!==!1?la(l.getBytes(),t,a):l.getBytes()};G.rsa.createKeyPairGenerationState=function(e,t,a){typeof e=="string"&&(e=parseInt(e,10)),e=e||2048,a=a||{};var r=a.prng||M.random,n={nextBytes:function(o){for(var u=r.getBytesSync(o.length),l=0;l<o.length;++l)o[l]=u.charCodeAt(l)}},s=a.algorithm||"PRIMEINC",i;if(s==="PRIMEINC")i={algorithm:s,state:0,bits:e,rng:n,eInt:t||65537,e:new ee(null),p:null,q:null,qBits:e>>1,pBits:e-(e>>1),pqState:0,num:null,keys:null},i.e.fromInt(i.eInt);else throw new Error("Invalid key generation algorithm: "+s);return i};G.rsa.stepKeyPairGenerationState=function(e,t){"algorithm"in e||(e.algorithm="PRIMEINC");var a=new ee(null);a.fromInt(30);for(var r=0,n=function(f,g){return f|g},s=+new Date,i,o=0;e.keys===null&&(t<=0||o<t);){if(e.state===0){var u=e.p===null?e.pBits:e.qBits,l=u-1;e.pqState===0?(e.num=new ee(u,e.rng),e.num.testBit(l)||e.num.bitwiseTo(ee.ONE.shiftLeft(l),n,e.num),e.num.dAddOffset(31-e.num.mod(a).byteValue(),0),r=0,++e.pqState):e.pqState===1?e.num.bitLength()>u?e.pqState=0:e.num.isProbablePrime(pc(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(sc[r++%8],0):e.pqState===2?e.pqState=e.num.subtract(ee.ONE).gcd(e.e).compareTo(ee.ONE)===0?3:0:e.pqState===3&&(e.pqState=0,e.p===null?e.p=e.num:e.q=e.num,e.p!==null&&e.q!==null&&++e.state,e.num=null)}else if(e.state===1)e.p.compareTo(e.q)<0&&(e.num=e.p,e.p=e.q,e.q=e.num),++e.state;else if(e.state===2)e.p1=e.p.subtract(ee.ONE),e.q1=e.q.subtract(ee.ONE),e.phi=e.p1.multiply(e.q1),++e.state;else if(e.state===3)e.phi.gcd(e.e).compareTo(ee.ONE)===0?++e.state:(e.p=null,e.q=null,e.state=0);else if(e.state===4)e.n=e.p.multiply(e.q),e.n.bitLength()===e.bits?++e.state:(e.q=null,e.state=0);else if(e.state===5){var c=e.e.modInverse(e.phi);e.keys={privateKey:G.rsa.setPrivateKey(e.n,e.e,c,e.p,e.q,c.mod(e.p1),c.mod(e.q1),e.q.modInverse(e.p)),publicKey:G.rsa.setPublicKey(e.n,e.e)}}i=+new Date,o+=i-s,s=i}return e.keys!==null};G.rsa.generateKeyPair=function(e,t,a,r){if(arguments.length===1?typeof e=="object"?(a=e,e=void 0):typeof e=="function"&&(r=e,e=void 0):arguments.length===2?typeof e=="number"?typeof t=="function"?(r=t,t=void 0):typeof t!="number"&&(a=t,t=void 0):(a=e,r=t,e=void 0,t=void 0):arguments.length===3&&(typeof t=="number"?typeof a=="function"&&(r=a,a=void 0):(r=a,a=t,t=void 0)),a=a||{},e===void 0&&(e=a.bits||2048),t===void 0&&(t=a.e||65537),!M.options.usePureJavaScript&&!a.prng&&e>=256&&e<=16384&&(t===65537||t===3)){if(r){if(Yi("generateKeyPair"))return en.generateKeyPair("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(o,u,l){if(o)return r(o);r(null,{privateKey:G.privateKeyFromPem(l),publicKey:G.publicKeyFromPem(u)})});if(ji("generateKey")&&ji("exportKey"))return at.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:Xi(t),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(o){return at.globalScope.crypto.subtle.exportKey("pkcs8",o.privateKey)}).then(void 0,function(o){r(o)}).then(function(o){if(o){var u=G.privateKeyFromAsn1(T.fromDer(M.util.createBuffer(o)));r(null,{privateKey:u,publicKey:G.setRsaPublicKey(u.n,u.e)})}});if(Wi("generateKey")&&Wi("exportKey")){var n=at.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:Xi(t),hash:{name:"SHA-256"}},!0,["sign","verify"]);n.oncomplete=function(o){var u=o.target.result,l=at.globalScope.msCrypto.subtle.exportKey("pkcs8",u.privateKey);l.oncomplete=function(c){var f=c.target.result,g=G.privateKeyFromAsn1(T.fromDer(M.util.createBuffer(f)));r(null,{privateKey:g,publicKey:G.setRsaPublicKey(g.n,g.e)})},l.onerror=function(c){r(c)}},n.onerror=function(o){r(o)};return}}else if(Yi("generateKeyPairSync")){var s=en.generateKeyPairSync("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:G.privateKeyFromPem(s.privateKey),publicKey:G.publicKeyFromPem(s.publicKey)}}}var i=G.rsa.createKeyPairGenerationState(e,t,a);if(!r)return G.rsa.stepKeyPairGenerationState(i,0),i.keys;hc(i,a,r)};G.setRsaPublicKey=G.rsa.setPublicKey=function(e,t){var a={n:e,e:t};return a.encrypt=function(r,n,s){if(typeof n=="string"?n=n.toUpperCase():n===void 0&&(n="RSAES-PKCS1-V1_5"),n==="RSAES-PKCS1-V1_5")n={encode:function(o,u,l){return Zi(o,u,2).getBytes()}};else if(n==="RSA-OAEP"||n==="RSAES-OAEP")n={encode:function(o,u){return M.pkcs1.encode_rsa_oaep(u,o,s)}};else if(["RAW","NONE","NULL",null].indexOf(n)!==-1)n={encode:function(o){return o}};else if(typeof n=="string")throw new Error('Unsupported encryption scheme: "'+n+'".');var i=n.encode(r,a,!0);return G.rsa.encrypt(i,a,!0)},a.verify=function(r,n,s,i){typeof s=="string"?s=s.toUpperCase():s===void 0&&(s="RSASSA-PKCS1-V1_5"),i===void 0&&(i={_parseAllDigestBytes:!0,_skipPaddingChecks:!1}),"_parseAllDigestBytes"in i||(i._parseAllDigestBytes=!0),"_skipPaddingChecks"in i||(i._skipPaddingChecks=!1),s==="RSASSA-PKCS1-V1_5"?s={verify:function(u,l){l=la(l,a,!0,void 0,i);var c=T.fromDer(l,{parseAllBytes:i._parseAllDigestBytes}),f={},g=[];if(!T.validate(c,fc,f,g)||c.value.length!==2){var v=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.");throw v.errors=g,v}var y=T.derToOid(f.algorithmIdentifier);if(!(y===M.oids.md2||y===M.oids.md5||y===M.oids.sha1||y===M.oids.sha224||y===M.oids.sha256||y===M.oids.sha384||y===M.oids.sha512||y===M.oids["sha512-224"]||y===M.oids["sha512-256"])){var v=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.");throw v.oid=y,v}if((y===M.oids.md2||y===M.oids.md5)&&!("parameters"in f))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifier NULL parameters.");return u===f.digest}}:(s==="NONE"||s==="NULL"||s===null)&&(s={verify:function(u,l){return l=la(l,a,!0,void 0,i),u===l}});var o=G.rsa.decrypt(n,a,!0,!1);return s.verify(r,o,a.n.bitLength())},a};G.setRsaPrivateKey=G.rsa.setPrivateKey=function(e,t,a,r,n,s,i,o){var u={n:e,e:t,d:a,p:r,q:n,dP:s,dQ:i,qInv:o};return u.decrypt=function(l,c,f){typeof c=="string"?c=c.toUpperCase():c===void 0&&(c="RSAES-PKCS1-V1_5");var g=G.rsa.decrypt(l,u,!1,!1);if(c==="RSAES-PKCS1-V1_5")c={decode:la};else if(c==="RSA-OAEP"||c==="RSAES-OAEP")c={decode:function(v,y){return M.pkcs1.decode_rsa_oaep(y,v,f)}};else if(["RAW","NONE","NULL",null].indexOf(c)!==-1)c={decode:function(v){return v}};else throw new Error('Unsupported encryption scheme: "'+c+'".');return c.decode(g,u,!1)},u.sign=function(l,c){var f=!1;typeof c=="string"&&(c=c.toUpperCase()),c===void 0||c==="RSASSA-PKCS1-V1_5"?(c={encode:dc},f=1):(c==="NONE"||c==="NULL"||c===null)&&(c={encode:function(){return l}},f=1);var g=c.encode(l,u.n.bitLength());return G.rsa.encrypt(g,u,f)},u};G.wrapRsaPrivateKey=function(e){return T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,T.integerToDer(0).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(G.oids.rsaEncryption).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.NULL,!1,"")]),T.create(T.Class.UNIVERSAL,T.Type.OCTETSTRING,!1,T.toDer(e).getBytes())])};G.privateKeyFromAsn1=function(e){var t={},a=[];if(T.validate(e,oc,t,a)&&(e=T.fromDer(M.util.createBuffer(t.privateKey))),t={},a=[],!T.validate(e,uc,t,a)){var r=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw r.errors=a,r}var n,s,i,o,u,l,c,f;return n=M.util.createBuffer(t.privateKeyModulus).toHex(),s=M.util.createBuffer(t.privateKeyPublicExponent).toHex(),i=M.util.createBuffer(t.privateKeyPrivateExponent).toHex(),o=M.util.createBuffer(t.privateKeyPrime1).toHex(),u=M.util.createBuffer(t.privateKeyPrime2).toHex(),l=M.util.createBuffer(t.privateKeyExponent1).toHex(),c=M.util.createBuffer(t.privateKeyExponent2).toHex(),f=M.util.createBuffer(t.privateKeyCoefficient).toHex(),G.setRsaPrivateKey(new ee(n,16),new ee(s,16),new ee(i,16),new ee(o,16),new ee(u,16),new ee(l,16),new ee(c,16),new ee(f,16))};G.privateKeyToAsn1=G.privateKeyToRSAPrivateKey=function(e){return T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,T.integerToDer(0).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,mt(e.n)),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,mt(e.e)),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,mt(e.d)),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,mt(e.p)),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,mt(e.q)),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,mt(e.dP)),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,mt(e.dQ)),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,mt(e.qInv))])};G.publicKeyFromAsn1=function(e){var t={},a=[];if(T.validate(e,cc,t,a)){var r=T.derToOid(t.publicKeyOid);if(r!==G.oids.rsaEncryption){var n=new Error("Cannot read public key. Unknown OID.");throw n.oid=r,n}e=t.rsaPublicKey}if(a=[],!T.validate(e,lc,t,a)){var n=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.");throw n.errors=a,n}var s=M.util.createBuffer(t.publicKeyModulus).toHex(),i=M.util.createBuffer(t.publicKeyExponent).toHex();return G.setRsaPublicKey(new ee(s,16),new ee(i,16))};G.publicKeyToAsn1=G.publicKeyToSubjectPublicKeyInfo=function(e){return T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(G.oids.rsaEncryption).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.NULL,!1,"")]),T.create(T.Class.UNIVERSAL,T.Type.BITSTRING,!1,[G.publicKeyToRSAPublicKey(e)])])};G.publicKeyToRSAPublicKey=function(e){return T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,mt(e.n)),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,mt(e.e))])};function Zi(e,t,a){var r=M.util.createBuffer(),n=Math.ceil(t.n.bitLength()/8);if(e.length>n-11){var s=new Error("Message is too long for PKCS#1 v1.5 padding.");throw s.length=e.length,s.max=n-11,s}r.putByte(0),r.putByte(a);var i=n-3-e.length,o;if(a===0||a===1){o=a===0?0:255;for(var u=0;u<i;++u)r.putByte(o)}else for(;i>0;){for(var l=0,c=M.random.getBytes(i),u=0;u<i;++u)o=c.charCodeAt(u),o===0?++l:r.putByte(o);i=l}return r.putByte(0),r.putBytes(e),r}function la(e,t,a,r,n){var s=Math.ceil(t.n.bitLength()/8),i=M.util.createBuffer(e),o=i.getByte(),u=i.getByte();if(o!==0||a&&u!==0&&u!==1||!a&&u!==2||a&&u===0&&typeof r>"u")throw new Error("Encryption block is invalid.");var l=0;if(u===0){l=s-3-r;for(var c=0;c<l;++c)if(i.getByte()!==0)throw new Error("Encryption block is invalid.")}else if(u===1){for(l=0;i.length()>1;){if(i.getByte()!==255){--i.read;break}++l}if(l<8&&!(n&&n._skipPaddingChecks))throw new Error("Encryption block is invalid.")}else if(u===2){for(l=0;i.length()>1;){if(i.getByte()===0){--i.read;break}++l}if(l<8&&!(n&&n._skipPaddingChecks))throw new Error("Encryption block is invalid.")}var f=i.getByte();if(f!==0||l!==s-3-i.length())throw new Error("Encryption block is invalid.");return i.getBytes()}function hc(e,t,a){typeof t=="function"&&(a=t,t={}),t=t||{};var r={algorithm:{name:t.algorithm||"PRIMEINC",options:{workers:t.workers||2,workLoad:t.workLoad||100,workerScript:t.workerScript}}};"prng"in t&&(r.prng=t.prng),n();function n(){s(e.pBits,function(o,u){if(o)return a(o);if(e.p=u,e.q!==null)return i(o,e.q);s(e.qBits,i)})}function s(o,u){M.prime.generateProbablePrime(o,r,u)}function i(o,u){if(o)return a(o);if(e.q=u,e.p.compareTo(e.q)<0){var l=e.p;e.p=e.q,e.q=l}if(e.p.subtract(ee.ONE).gcd(e.e).compareTo(ee.ONE)!==0){e.p=null,n();return}if(e.q.subtract(ee.ONE).gcd(e.e).compareTo(ee.ONE)!==0){e.q=null,s(e.qBits,i);return}if(e.p1=e.p.subtract(ee.ONE),e.q1=e.q.subtract(ee.ONE),e.phi=e.p1.multiply(e.q1),e.phi.gcd(e.e).compareTo(ee.ONE)!==0){e.p=e.q=null,n();return}if(e.n=e.p.multiply(e.q),e.n.bitLength()!==e.bits){e.q=null,s(e.qBits,i);return}var c=e.e.modInverse(e.phi);e.keys={privateKey:G.rsa.setPrivateKey(e.n,e.e,c,e.p,e.q,c.mod(e.p1),c.mod(e.q1),e.q.modInverse(e.p)),publicKey:G.rsa.setPublicKey(e.n,e.e)},a(null,e.keys)}}function mt(e){var t=e.toString(16);t[0]>="8"&&(t="00"+t);var a=M.util.hexToBytes(t);return a.length>1&&(a.charCodeAt(0)===0&&(a.charCodeAt(1)&128)===0||a.charCodeAt(0)===255&&(a.charCodeAt(1)&128)===128)?a.substr(1):a}function pc(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}function Yi(e){return M.util.isNodejs&&typeof en[e]=="function"}function ji(e){return typeof at.globalScope<"u"&&typeof at.globalScope.crypto=="object"&&typeof at.globalScope.crypto.subtle=="object"&&typeof at.globalScope.crypto.subtle[e]=="function"}function Wi(e){return typeof at.globalScope<"u"&&typeof at.globalScope.msCrypto=="object"&&typeof at.globalScope.msCrypto.subtle=="object"&&typeof at.globalScope.msCrypto.subtle[e]=="function"}function Xi(e){for(var t=M.util.hexToBytes(e.toString(16)),a=new Uint8Array(t.length),r=0;r<t.length;++r)a[r]=t.charCodeAt(r);return a}});var tn=F((Hh,is)=>{var V=$();Rt();lt();br();ft();Lt();na();Qt();tt();Qa();Nr();re();typeof ts>"u"&&(ts=V.jsbn.BigInteger);var ts,A=V.asn1,Q=V.pki=V.pki||{};is.exports=Q.pbe=V.pbe=V.pbe||{};var jt=Q.oids,gc={name:"EncryptedPrivateKeyInfo",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:A.Class.UNIVERSAL,type:A.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:A.Class.UNIVERSAL,type:A.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},yc={name:"PBES2Algorithms",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:A.Class.UNIVERSAL,type:A.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:A.Class.UNIVERSAL,type:A.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:A.Class.UNIVERSAL,type:A.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:A.Class.UNIVERSAL,type:A.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:A.Class.UNIVERSAL,type:A.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:A.Class.UNIVERSAL,type:A.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:A.Class.UNIVERSAL,type:A.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},vc={name:"pkcs-12PbeParams",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:A.Class.UNIVERSAL,type:A.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:A.Class.UNIVERSAL,type:A.Type.INTEGER,constructed:!1,capture:"iterations"}]};Q.encryptPrivateKeyInfo=function(e,t,a){a=a||{},a.saltSize=a.saltSize||8,a.count=a.count||2048,a.algorithm=a.algorithm||"aes128",a.prfAlgorithm=a.prfAlgorithm||"sha1";var r=V.random.getBytesSync(a.saltSize),n=a.count,s=A.integerToDer(n),i,o,u;if(a.algorithm.indexOf("aes")===0||a.algorithm==="des"){var l,c,f;switch(a.algorithm){case"aes128":i=16,l=16,c=jt["aes128-CBC"],f=V.aes.createEncryptionCipher;break;case"aes192":i=24,l=16,c=jt["aes192-CBC"],f=V.aes.createEncryptionCipher;break;case"aes256":i=32,l=16,c=jt["aes256-CBC"],f=V.aes.createEncryptionCipher;break;case"des":i=8,l=8,c=jt.desCBC,f=V.des.createEncryptionCipher;break;default:var g=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw g.algorithm=a.algorithm,g}var v="hmacWith"+a.prfAlgorithm.toUpperCase(),y=ns(v),x=V.pkcs5.pbkdf2(t,r,n,i,y),S=V.random.getBytesSync(l),I=f(x);I.start(S),I.update(A.toDer(e)),I.finish(),u=I.output.getBytes();var B=mc(r,s,i,v);o=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(jt.pkcs5PBES2).getBytes()),A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(jt.pkcs5PBKDF2).getBytes()),B]),A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(c).getBytes()),A.create(A.Class.UNIVERSAL,A.Type.OCTETSTRING,!1,S)])])])}else if(a.algorithm==="3des"){i=24;var b=new V.util.ByteBuffer(r),x=Q.pbe.generatePkcs12Key(t,b,1,n,i),S=Q.pbe.generatePkcs12Key(t,b,2,n,i),I=V.des.createEncryptionCipher(x);I.start(S),I.update(A.toDer(e)),I.finish(),u=I.output.getBytes(),o=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(jt["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OCTETSTRING,!1,r),A.create(A.Class.UNIVERSAL,A.Type.INTEGER,!1,s.getBytes())])])}else{var g=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw g.algorithm=a.algorithm,g}var P=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[o,A.create(A.Class.UNIVERSAL,A.Type.OCTETSTRING,!1,u)]);return P};Q.decryptPrivateKeyInfo=function(e,t){var a=null,r={},n=[];if(!A.validate(e,gc,r,n)){var s=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=n,s}var i=A.derToOid(r.encryptionOid),o=Q.pbe.getCipher(i,r.encryptionParams,t),u=V.util.createBuffer(r.encryptedData);return o.update(u),o.finish()&&(a=A.fromDer(o.output)),a};Q.encryptedPrivateKeyToPem=function(e,t){var a={type:"ENCRYPTED PRIVATE KEY",body:A.toDer(e).getBytes()};return V.pem.encode(a,{maxline:t})};Q.encryptedPrivateKeyFromPem=function(e){var t=V.pem.decode(e)[0];if(t.type!=="ENCRYPTED PRIVATE KEY"){var a=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw a.headerType=t.type,a}if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return A.fromDer(t.body)};Q.encryptRsaPrivateKey=function(e,t,a){if(a=a||{},!a.legacy){var r=Q.wrapRsaPrivateKey(Q.privateKeyToAsn1(e));return r=Q.encryptPrivateKeyInfo(r,t,a),Q.encryptedPrivateKeyToPem(r)}var n,s,i,o;switch(a.algorithm){case"aes128":n="AES-128-CBC",i=16,s=V.random.getBytesSync(16),o=V.aes.createEncryptionCipher;break;case"aes192":n="AES-192-CBC",i=24,s=V.random.getBytesSync(16),o=V.aes.createEncryptionCipher;break;case"aes256":n="AES-256-CBC",i=32,s=V.random.getBytesSync(16),o=V.aes.createEncryptionCipher;break;case"3des":n="DES-EDE3-CBC",i=24,s=V.random.getBytesSync(8),o=V.des.createEncryptionCipher;break;case"des":n="DES-CBC",i=8,s=V.random.getBytesSync(8),o=V.des.createEncryptionCipher;break;default:var u=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+a.algorithm+'".');throw u.algorithm=a.algorithm,u}var l=V.pbe.opensslDeriveBytes(t,s.substr(0,8),i),c=o(l);c.start(s),c.update(A.toDer(Q.privateKeyToAsn1(e))),c.finish();var f={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:n,parameters:V.util.bytesToHex(s).toUpperCase()},body:c.output.getBytes()};return V.pem.encode(f)};Q.decryptRsaPrivateKey=function(e,t){var a=null,r=V.pem.decode(e)[0];if(r.type!=="ENCRYPTED PRIVATE KEY"&&r.type!=="PRIVATE KEY"&&r.type!=="RSA PRIVATE KEY"){var n=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".');throw n.headerType=n,n}if(r.procType&&r.procType.type==="ENCRYPTED"){var s,i;switch(r.dekInfo.algorithm){case"DES-CBC":s=8,i=V.des.createDecryptionCipher;break;case"DES-EDE3-CBC":s=24,i=V.des.createDecryptionCipher;break;case"AES-128-CBC":s=16,i=V.aes.createDecryptionCipher;break;case"AES-192-CBC":s=24,i=V.aes.createDecryptionCipher;break;case"AES-256-CBC":s=32,i=V.aes.createDecryptionCipher;break;case"RC2-40-CBC":s=5,i=function(f){return V.rc2.createDecryptionCipher(f,40)};break;case"RC2-64-CBC":s=8,i=function(f){return V.rc2.createDecryptionCipher(f,64)};break;case"RC2-128-CBC":s=16,i=function(f){return V.rc2.createDecryptionCipher(f,128)};break;default:var n=new Error('Could not decrypt private key; unsupported encryption algorithm "'+r.dekInfo.algorithm+'".');throw n.algorithm=r.dekInfo.algorithm,n}var o=V.util.hexToBytes(r.dekInfo.parameters),u=V.pbe.opensslDeriveBytes(t,o.substr(0,8),s),l=i(u);if(l.start(o),l.update(V.util.createBuffer(r.body)),l.finish())a=l.output.getBytes();else return a}else a=r.body;return r.type==="ENCRYPTED PRIVATE KEY"?a=Q.decryptPrivateKeyInfo(A.fromDer(a),t):a=A.fromDer(a),a!==null&&(a=Q.privateKeyFromAsn1(a)),a};Q.pbe.generatePkcs12Key=function(e,t,a,r,n,s){var i,o;if(typeof s>"u"||s===null){if(!("sha1"in V.md))throw new Error('"sha1" hash algorithm unavailable.');s=V.md.sha1.create()}var u=s.digestLength,l=s.blockLength,c=new V.util.ByteBuffer,f=new V.util.ByteBuffer;if(e!=null){for(o=0;o<e.length;o++)f.putInt16(e.charCodeAt(o));f.putInt16(0)}var g=f.length(),v=t.length(),y=new V.util.ByteBuffer;y.fillWithByte(a,l);var x=l*Math.ceil(v/l),S=new V.util.ByteBuffer;for(o=0;o<x;o++)S.putByte(t.at(o%v));var I=l*Math.ceil(g/l),B=new V.util.ByteBuffer;for(o=0;o<I;o++)B.putByte(f.at(o%g));var b=S;b.putBuffer(B);for(var P=Math.ceil(n/u),k=1;k<=P;k++){var R=new V.util.ByteBuffer;R.putBytes(y.bytes()),R.putBytes(b.bytes());for(var z=0;z<r;z++)s.start(),s.update(R.getBytes()),R=s.digest();var Y=new V.util.ByteBuffer;for(o=0;o<l;o++)Y.putByte(R.at(o%u));var ne=Math.ceil(v/l)+Math.ceil(g/l),ie=new V.util.ByteBuffer;for(i=0;i<ne;i++){var ue=new V.util.ByteBuffer(b.getBytes(l)),fe=511;for(o=Y.length()-1;o>=0;o--)fe=fe>>8,fe+=Y.at(o)+ue.at(o),ue.setAt(o,fe&255);ie.putBuffer(ue)}b=ie,c.putBuffer(R)}return c.truncate(c.length()-n),c};Q.pbe.getCipher=function(e,t,a){switch(e){case Q.oids.pkcs5PBES2:return Q.pbe.getCipherForPBES2(e,t,a);case Q.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case Q.oids["pbewithSHAAnd40BitRC2-CBC"]:return Q.pbe.getCipherForPKCS12PBE(e,t,a);default:var r=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw r.oid=e,r.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],r}};Q.pbe.getCipherForPBES2=function(e,t,a){var r={},n=[];if(!A.validate(t,yc,r,n)){var s=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=n,s}if(e=A.derToOid(r.kdfOid),e!==Q.oids.pkcs5PBKDF2){var s=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.");throw s.oid=e,s.supportedOids=["pkcs5PBKDF2"],s}if(e=A.derToOid(r.encOid),e!==Q.oids["aes128-CBC"]&&e!==Q.oids["aes192-CBC"]&&e!==Q.oids["aes256-CBC"]&&e!==Q.oids["des-EDE3-CBC"]&&e!==Q.oids.desCBC){var s=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.");throw s.oid=e,s.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],s}var i=r.kdfSalt,o=V.util.createBuffer(r.kdfIterationCount);o=o.getInt(o.length()<<3);var u,l;switch(Q.oids[e]){case"aes128-CBC":u=16,l=V.aes.createDecryptionCipher;break;case"aes192-CBC":u=24,l=V.aes.createDecryptionCipher;break;case"aes256-CBC":u=32,l=V.aes.createDecryptionCipher;break;case"des-EDE3-CBC":u=24,l=V.des.createDecryptionCipher;break;case"desCBC":u=8,l=V.des.createDecryptionCipher;break}var c=as(r.prfOid),f=V.pkcs5.pbkdf2(a,i,o,u,c),g=r.encIv,v=l(f);return v.start(g),v};Q.pbe.getCipherForPKCS12PBE=function(e,t,a){var r={},n=[];if(!A.validate(t,vc,r,n)){var s=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=n,s}var i=V.util.createBuffer(r.salt),o=V.util.createBuffer(r.iterations);o=o.getInt(o.length()<<3);var u,l,c;switch(e){case Q.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:u=24,l=8,c=V.des.startDecrypting;break;case Q.oids["pbewithSHAAnd40BitRC2-CBC"]:u=5,l=8,c=function(x,S){var I=V.rc2.createDecryptionCipher(x,40);return I.start(S,null),I};break;default:var s=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.");throw s.oid=e,s}var f=as(r.prfOid),g=Q.pbe.generatePkcs12Key(a,i,1,o,u,f);f.start();var v=Q.pbe.generatePkcs12Key(a,i,2,o,l,f);return c(g,v)};Q.pbe.opensslDeriveBytes=function(e,t,a,r){if(typeof r>"u"||r===null){if(!("md5"in V.md))throw new Error('"md5" hash algorithm unavailable.');r=V.md.md5.create()}t===null&&(t="");for(var n=[rs(r,e+t)],s=16,i=1;s<a;++i,s+=16)n.push(rs(r,n[i-1]+e+t));return n.join("").substr(0,a)};function rs(e,t){return e.start().update(t).digest().getBytes()}function as(e){var t;if(!e)t="hmacWithSHA1";else if(t=Q.oids[A.derToOid(e)],!t){var a=new Error("Unsupported PRF OID.");throw a.oid=e,a.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],a}return ns(t)}function ns(e){var t=V.md;switch(e){case"hmacWithSHA224":t=V.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":e=e.substr(8).toLowerCase();break;default:var a=new Error("Unsupported PRF algorithm.");throw a.algorithm=e,a.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],a}if(!t||!(e in t))throw new Error("Unknown hash algorithm: "+e);return t[e].create()}function mc(e,t,a,r){var n=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OCTETSTRING,!1,e),A.create(A.Class.UNIVERSAL,A.Type.INTEGER,!1,t.getBytes())]);return r!=="hmacWithSHA1"&&n.value.push(A.create(A.Class.UNIVERSAL,A.Type.INTEGER,!1,V.util.hexToBytes(a.toString(16))),A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(Q.oids[r]).getBytes()),A.create(A.Class.UNIVERSAL,A.Type.NULL,!1,"")])),n}});var rn=F((Gh,us)=>{var cr=$();lt();re();var O=cr.asn1,fr=us.exports=cr.pkcs7asn1=cr.pkcs7asn1||{};cr.pkcs7=cr.pkcs7||{};cr.pkcs7.asn1=fr;var ss={name:"ContentInfo",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:O.Class.UNIVERSAL,type:O.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:O.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};fr.contentInfoValidator=ss;var os={name:"EncryptedContentInfo",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:O.Class.UNIVERSAL,type:O.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:O.Class.UNIVERSAL,type:O.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:O.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:O.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};fr.envelopedDataValidator={name:"EnvelopedData",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:O.Class.UNIVERSAL,type:O.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:O.Class.UNIVERSAL,type:O.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(os)};fr.encryptedDataValidator={name:"EncryptedData",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:O.Class.UNIVERSAL,type:O.Type.INTEGER,constructed:!1,capture:"version"}].concat(os)};var Cc={name:"SignerInfo",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:O.Class.UNIVERSAL,type:O.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:O.Class.UNIVERSAL,type:O.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:O.Class.UNIVERSAL,type:O.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:O.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:O.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:O.Class.UNIVERSAL,type:O.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:O.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};fr.signedDataValidator={name:"SignedData",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:O.Class.UNIVERSAL,type:O.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:O.Class.UNIVERSAL,type:O.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},ss,{name:"SignedData.Certificates",tagClass:O.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:O.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:O.Class.UNIVERSAL,type:O.Type.SET,capture:"signerInfos",optional:!0,value:[Cc]}]};fr.recipientInfoValidator={name:"RecipientInfo",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:O.Class.UNIVERSAL,type:O.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:O.Class.UNIVERSAL,type:O.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:O.Class.UNIVERSAL,type:O.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:O.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter",optional:!0}]},{name:"RecipientInfo.encryptedKey",tagClass:O.Class.UNIVERSAL,type:O.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]}});var an=F((zh,ls)=>{var Wt=$();re();Wt.mgf=Wt.mgf||{};var Ec=ls.exports=Wt.mgf.mgf1=Wt.mgf1=Wt.mgf1||{};Ec.create=function(e){var t={generate:function(a,r){for(var n=new Wt.util.ByteBuffer,s=Math.ceil(r/e.digestLength),i=0;i<s;i++){var o=new Wt.util.ByteBuffer;o.putInt32(i),e.start(),e.update(a+o.getBytes()),n.putBuffer(e.digest())}return n.truncate(n.length()-r),n.getBytes()}};return t}});var fs=F((Qh,cs)=>{var ca=$();an();cs.exports=ca.mgf=ca.mgf||{};ca.mgf.mgf1=ca.mgf1});var fa=F(($h,ds)=>{var Xt=$();tt();re();var xc=ds.exports=Xt.pss=Xt.pss||{};xc.create=function(e){arguments.length===3&&(e={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var t=e.md,a=e.mgf,r=t.digestLength,n=e.salt||null;typeof n=="string"&&(n=Xt.util.createBuffer(n));var s;if("saltLength"in e)s=e.saltLength;else if(n!==null)s=n.length();else throw new Error("Salt length not specified or specific salt not given.");if(n!==null&&n.length()!==s)throw new Error("Given salt length does not match length of given salt.");var i=e.prng||Xt.random,o={};return o.encode=function(u,l){var c,f=l-1,g=Math.ceil(f/8),v=u.digest().getBytes();if(g<r+s+2)throw new Error("Message is too long to encrypt.");var y;n===null?y=i.getBytesSync(s):y=n.bytes();var x=new Xt.util.ByteBuffer;x.fillWithByte(0,8),x.putBytes(v),x.putBytes(y),t.start(),t.update(x.getBytes());var S=t.digest().getBytes(),I=new Xt.util.ByteBuffer;I.fillWithByte(0,g-s-r-2),I.putByte(1),I.putBytes(y);var B=I.getBytes(),b=g-r-1,P=a.generate(S,b),k="";for(c=0;c<b;c++)k+=String.fromCharCode(B.charCodeAt(c)^P.charCodeAt(c));var R=65280>>8*g-f&255;return k=String.fromCharCode(k.charCodeAt(0)&~R)+k.substr(1),k+S+"\xBC"},o.verify=function(u,l,c){var f,g=c-1,v=Math.ceil(g/8);if(l=l.substr(-v),v<r+s+2)throw new Error("Inconsistent parameters to PSS signature verification.");if(l.charCodeAt(v-1)!==188)throw new Error("Encoded message does not end in 0xBC.");var y=v-r-1,x=l.substr(0,y),S=l.substr(y,r),I=65280>>8*v-g&255;if((x.charCodeAt(0)&I)!==0)throw new Error("Bits beyond keysize not zero as expected.");var B=a.generate(S,y),b="";for(f=0;f<y;f++)b+=String.fromCharCode(x.charCodeAt(f)^B.charCodeAt(f));b=String.fromCharCode(b.charCodeAt(0)&~I)+b.substr(1);var P=v-r-s-2;for(f=0;f<P;f++)if(b.charCodeAt(f)!==0)throw new Error("Leftmost octets not zero as expected");if(b.charCodeAt(P)!==1)throw new Error("Inconsistent PSS signature, 0x01 marker not found");var k=b.substr(-s),R=new Xt.util.ByteBuffer;R.fillWithByte(0,8),R.putBytes(u),R.putBytes(k),t.start(),t.update(R.getBytes());var z=t.digest().getBytes();return S===z},o}});var pa=F((Yh,vs)=>{var q=$();Rt();lt();br();ft();fs();Lt();Qt();fa();Nr();re();var d=q.asn1,L=vs.exports=q.pki=q.pki||{},te=L.oids,ge={};ge.CN=te.commonName;ge.commonName="CN";ge.C=te.countryName;ge.countryName="C";ge.L=te.localityName;ge.localityName="L";ge.ST=te.stateOrProvinceName;ge.stateOrProvinceName="ST";ge.O=te.organizationName;ge.organizationName="O";ge.OU=te.organizationalUnitName;ge.organizationalUnitName="OU";ge.E=te.emailAddress;ge.emailAddress="E";var ps=q.pki.rsa.publicKeyValidator,Sc={name:"Certificate",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:d.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:d.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:d.Class.UNIVERSAL,type:d.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:d.Class.UNIVERSAL,type:d.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:d.Class.UNIVERSAL,type:d.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:d.Class.UNIVERSAL,type:d.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},ps,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:d.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:d.Class.UNIVERSAL,type:d.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:d.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:d.Class.UNIVERSAL,type:d.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:d.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:d.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:d.Class.UNIVERSAL,type:d.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},Tc={name:"rsapss",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:d.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:d.Class.UNIVERSAL,type:d.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:d.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:d.Class.UNIVERSAL,type:d.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:d.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:d.Class.UNIVERSAL,type:d.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:d.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:d.Class.UNIVERSAL,type:d.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},Ic={name:"CertificationRequestInfo",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},ps,{name:"CertificationRequestInfo.attributes",tagClass:d.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:d.Class.UNIVERSAL,type:d.Type.SET,constructed:!0}]}]}]},Ac={name:"CertificationRequest",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[Ic,{name:"CertificationRequest.signatureAlgorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:d.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:d.Class.UNIVERSAL,type:d.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};L.RDNAttributesAsArray=function(e,t){for(var a=[],r,n,s,i=0;i<e.value.length;++i){r=e.value[i];for(var o=0;o<r.value.length;++o)s={},n=r.value[o],s.type=d.derToOid(n.value[0].value),s.value=n.value[1].value,s.valueTagClass=n.value[1].type,s.type in te&&(s.name=te[s.type],s.name in ge&&(s.shortName=ge[s.name])),t&&(t.update(s.type),t.update(s.value)),a.push(s)}return a};L.CRIAttributesAsArray=function(e){for(var t=[],a=0;a<e.length;++a)for(var r=e[a],n=d.derToOid(r.value[0].value),s=r.value[1].value,i=0;i<s.length;++i){var o={};if(o.type=n,o.value=s[i].value,o.valueTagClass=s[i].type,o.type in te&&(o.name=te[o.type],o.name in ge&&(o.shortName=ge[o.name])),o.type===te.extensionRequest){o.extensions=[];for(var u=0;u<o.value.length;++u)o.extensions.push(L.certificateExtensionFromAsn1(o.value[u]))}t.push(o)}return t};function Ut(e,t){typeof t=="string"&&(t={shortName:t});for(var a=null,r,n=0;a===null&&n<e.attributes.length;++n)r=e.attributes[n],(t.type&&t.type===r.type||t.name&&t.name===r.name||t.shortName&&t.shortName===r.shortName)&&(a=r);return a}var da=function(e,t,a){var r={};if(e!==te["RSASSA-PSS"])return r;a&&(r={hash:{algorithmOid:te.sha1},mgf:{algorithmOid:te.mgf1,hash:{algorithmOid:te.sha1}},saltLength:20});var n={},s=[];if(!d.validate(t,Tc,n,s)){var i=new Error("Cannot read RSASSA-PSS parameter block.");throw i.errors=s,i}return n.hashOid!==void 0&&(r.hash=r.hash||{},r.hash.algorithmOid=d.derToOid(n.hashOid)),n.maskGenOid!==void 0&&(r.mgf=r.mgf||{},r.mgf.algorithmOid=d.derToOid(n.maskGenOid),r.mgf.hash=r.mgf.hash||{},r.mgf.hash.algorithmOid=d.derToOid(n.maskGenHashOid)),n.saltLength!==void 0&&(r.saltLength=n.saltLength.charCodeAt(0)),r},ha=function(e){switch(te[e.signatureOid]){case"sha1WithRSAEncryption":case"sha1WithRSASignature":return q.md.sha1.create();case"md5WithRSAEncryption":return q.md.md5.create();case"sha256WithRSAEncryption":return q.md.sha256.create();case"sha384WithRSAEncryption":return q.md.sha384.create();case"sha512WithRSAEncryption":return q.md.sha512.create();case"RSASSA-PSS":return q.md.sha256.create();default:var t=new Error("Could not compute "+e.type+" digest. Unknown signature OID.");throw t.signatureOid=e.signatureOid,t}},gs=function(e){var t=e.certificate,a;switch(t.signatureOid){case te.sha1WithRSAEncryption:case te.sha1WithRSASignature:break;case te["RSASSA-PSS"]:var r,n;if(r=te[t.signatureParameters.mgf.hash.algorithmOid],r===void 0||q.md[r]===void 0){var s=new Error("Unsupported MGF hash function.");throw s.oid=t.signatureParameters.mgf.hash.algorithmOid,s.name=r,s}if(n=te[t.signatureParameters.mgf.algorithmOid],n===void 0||q.mgf[n]===void 0){var s=new Error("Unsupported MGF function.");throw s.oid=t.signatureParameters.mgf.algorithmOid,s.name=n,s}if(n=q.mgf[n].create(q.md[r].create()),r=te[t.signatureParameters.hash.algorithmOid],r===void 0||q.md[r]===void 0){var s=new Error("Unsupported RSASSA-PSS hash function.");throw s.oid=t.signatureParameters.hash.algorithmOid,s.name=r,s}a=q.pss.create(q.md[r].create(),n,t.signatureParameters.saltLength);break}return t.publicKey.verify(e.md.digest().getBytes(),e.signature,a)};L.certificateFromPem=function(e,t,a){var r=q.pem.decode(e)[0];if(r.type!=="CERTIFICATE"&&r.type!=="X509 CERTIFICATE"&&r.type!=="TRUSTED CERTIFICATE"){var n=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw n.headerType=r.type,n}if(r.procType&&r.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var s=d.fromDer(r.body,a);return L.certificateFromAsn1(s,t)};L.certificateToPem=function(e,t){var a={type:"CERTIFICATE",body:d.toDer(L.certificateToAsn1(e)).getBytes()};return q.pem.encode(a,{maxline:t})};L.publicKeyFromPem=function(e){var t=q.pem.decode(e)[0];if(t.type!=="PUBLIC KEY"&&t.type!=="RSA PUBLIC KEY"){var a=new Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');throw a.headerType=t.type,a}if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert public key from PEM; PEM is encrypted.");var r=d.fromDer(t.body);return L.publicKeyFromAsn1(r)};L.publicKeyToPem=function(e,t){var a={type:"PUBLIC KEY",body:d.toDer(L.publicKeyToAsn1(e)).getBytes()};return q.pem.encode(a,{maxline:t})};L.publicKeyToRSAPublicKeyPem=function(e,t){var a={type:"RSA PUBLIC KEY",body:d.toDer(L.publicKeyToRSAPublicKey(e)).getBytes()};return q.pem.encode(a,{maxline:t})};L.getPublicKeyFingerprint=function(e,t){t=t||{};var a=t.md||q.md.sha1.create(),r=t.type||"RSAPublicKey",n;switch(r){case"RSAPublicKey":n=d.toDer(L.publicKeyToRSAPublicKey(e)).getBytes();break;case"SubjectPublicKeyInfo":n=d.toDer(L.publicKeyToAsn1(e)).getBytes();break;default:throw new Error('Unknown fingerprint type "'+t.type+'".')}a.start(),a.update(n);var s=a.digest();if(t.encoding==="hex"){var i=s.toHex();return t.delimiter?i.match(/.{2}/g).join(t.delimiter):i}else{if(t.encoding==="binary")return s.getBytes();if(t.encoding)throw new Error('Unknown encoding "'+t.encoding+'".')}return s};L.certificationRequestFromPem=function(e,t,a){var r=q.pem.decode(e)[0];if(r.type!=="CERTIFICATE REQUEST"){var n=new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw n.headerType=r.type,n}if(r.procType&&r.procType.type==="ENCRYPTED")throw new Error("Could not convert certification request from PEM; PEM is encrypted.");var s=d.fromDer(r.body,a);return L.certificationRequestFromAsn1(s,t)};L.certificationRequestToPem=function(e,t){var a={type:"CERTIFICATE REQUEST",body:d.toDer(L.certificationRequestToAsn1(e)).getBytes()};return q.pem.encode(a,{maxline:t})};L.createCertificate=function(){var e={};return e.version=2,e.serialNumber="00",e.signatureOid=null,e.signature=null,e.siginfo={},e.siginfo.algorithmOid=null,e.validity={},e.validity.notBefore=new Date,e.validity.notAfter=new Date,e.issuer={},e.issuer.getField=function(t){return Ut(e.issuer,t)},e.issuer.addField=function(t){nt([t]),e.issuer.attributes.push(t)},e.issuer.attributes=[],e.issuer.hash=null,e.subject={},e.subject.getField=function(t){return Ut(e.subject,t)},e.subject.addField=function(t){nt([t]),e.subject.attributes.push(t)},e.subject.attributes=[],e.subject.hash=null,e.extensions=[],e.publicKey=null,e.md=null,e.setSubject=function(t,a){nt(t),e.subject.attributes=t,delete e.subject.uniqueId,a&&(e.subject.uniqueId=a),e.subject.hash=null},e.setIssuer=function(t,a){nt(t),e.issuer.attributes=t,delete e.issuer.uniqueId,a&&(e.issuer.uniqueId=a),e.issuer.hash=null},e.setExtensions=function(t){for(var a=0;a<t.length;++a)ys(t[a],{cert:e});e.extensions=t},e.getExtension=function(t){typeof t=="string"&&(t={name:t});for(var a=null,r,n=0;a===null&&n<e.extensions.length;++n)r=e.extensions[n],(t.id&&r.id===t.id||t.name&&r.name===t.name)&&(a=r);return a},e.sign=function(t,a){e.md=a||q.md.sha1.create();var r=te[e.md.algorithm+"WithRSAEncryption"];if(!r){var n=new Error("Could not compute certificate digest. Unknown message digest algorithm OID.");throw n.algorithm=e.md.algorithm,n}e.signatureOid=e.siginfo.algorithmOid=r,e.tbsCertificate=L.getTBSCertificate(e);var s=d.toDer(e.tbsCertificate);e.md.update(s.getBytes()),e.signature=t.sign(e.md)},e.verify=function(t){var a=!1;if(!e.issued(t)){var r=t.issuer,n=e.subject,s=new Error("The parent certificate did not issue the given child certificate; the child certificate's issuer does not match the parent's subject.");throw s.expectedIssuer=n.attributes,s.actualIssuer=r.attributes,s}var i=t.md;if(i===null){i=ha({signatureOid:t.signatureOid,type:"certificate"});var o=t.tbsCertificate||L.getTBSCertificate(t),u=d.toDer(o);i.update(u.getBytes())}return i!==null&&(a=gs({certificate:e,md:i,signature:t.signature})),a},e.isIssuer=function(t){var a=!1,r=e.issuer,n=t.subject;if(r.hash&&n.hash)a=r.hash===n.hash;else if(r.attributes.length===n.attributes.length){a=!0;for(var s,i,o=0;a&&o<r.attributes.length;++o)s=r.attributes[o],i=n.attributes[o],(s.type!==i.type||s.value!==i.value)&&(a=!1)}return a},e.issued=function(t){return t.isIssuer(e)},e.generateSubjectKeyIdentifier=function(){return L.getPublicKeyFingerprint(e.publicKey,{type:"RSAPublicKey"})},e.verifySubjectKeyIdentifier=function(){for(var t=te.subjectKeyIdentifier,a=0;a<e.extensions.length;++a){var r=e.extensions[a];if(r.id===t){var n=e.generateSubjectKeyIdentifier().getBytes();return q.util.hexToBytes(r.subjectKeyIdentifier)===n}}return!1},e};L.certificateFromAsn1=function(e,t){var a={},r=[];if(!d.validate(e,Sc,a,r)){var n=new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.");throw n.errors=r,n}var s=d.derToOid(a.publicKeyOid);if(s!==L.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var i=L.createCertificate();i.version=a.certVersion?a.certVersion.charCodeAt(0):0;var o=q.util.createBuffer(a.certSerialNumber);i.serialNumber=o.toHex(),i.signatureOid=q.asn1.derToOid(a.certSignatureOid),i.signatureParameters=da(i.signatureOid,a.certSignatureParams,!0),i.siginfo.algorithmOid=q.asn1.derToOid(a.certinfoSignatureOid),i.siginfo.parameters=da(i.siginfo.algorithmOid,a.certinfoSignatureParams,!1),i.signature=a.certSignature;var u=[];if(a.certValidity1UTCTime!==void 0&&u.push(d.utcTimeToDate(a.certValidity1UTCTime)),a.certValidity2GeneralizedTime!==void 0&&u.push(d.generalizedTimeToDate(a.certValidity2GeneralizedTime)),a.certValidity3UTCTime!==void 0&&u.push(d.utcTimeToDate(a.certValidity3UTCTime)),a.certValidity4GeneralizedTime!==void 0&&u.push(d.generalizedTimeToDate(a.certValidity4GeneralizedTime)),u.length>2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(u.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(i.validity.notBefore=u[0],i.validity.notAfter=u[1],i.tbsCertificate=a.tbsCertificate,t){i.md=ha({signatureOid:i.signatureOid,type:"certificate"});var l=d.toDer(i.tbsCertificate);i.md.update(l.getBytes())}var c=q.md.sha1.create(),f=d.toDer(a.certIssuer);c.update(f.getBytes()),i.issuer.getField=function(y){return Ut(i.issuer,y)},i.issuer.addField=function(y){nt([y]),i.issuer.attributes.push(y)},i.issuer.attributes=L.RDNAttributesAsArray(a.certIssuer),a.certIssuerUniqueId&&(i.issuer.uniqueId=a.certIssuerUniqueId),i.issuer.hash=c.digest().toHex();var g=q.md.sha1.create(),v=d.toDer(a.certSubject);return g.update(v.getBytes()),i.subject.getField=function(y){return Ut(i.subject,y)},i.subject.addField=function(y){nt([y]),i.subject.attributes.push(y)},i.subject.attributes=L.RDNAttributesAsArray(a.certSubject),a.certSubjectUniqueId&&(i.subject.uniqueId=a.certSubjectUniqueId),i.subject.hash=g.digest().toHex(),a.certExtensions?i.extensions=L.certificateExtensionsFromAsn1(a.certExtensions):i.extensions=[],i.publicKey=L.publicKeyFromAsn1(a.subjectPublicKeyInfo),i};L.certificateExtensionsFromAsn1=function(e){for(var t=[],a=0;a<e.value.length;++a)for(var r=e.value[a],n=0;n<r.value.length;++n)t.push(L.certificateExtensionFromAsn1(r.value[n]));return t};L.certificateExtensionFromAsn1=function(e){var t={};if(t.id=d.derToOid(e.value[0].value),t.critical=!1,e.value[1].type===d.Type.BOOLEAN?(t.critical=e.value[1].value.charCodeAt(0)!==0,t.value=e.value[2].value):t.value=e.value[1].value,t.id in te){if(t.name=te[t.id],t.name==="keyUsage"){var a=d.fromDer(t.value),r=0,n=0;a.value.length>1&&(r=a.value.charCodeAt(1),n=a.value.length>2?a.value.charCodeAt(2):0),t.digitalSignature=(r&128)===128,t.nonRepudiation=(r&64)===64,t.keyEncipherment=(r&32)===32,t.dataEncipherment=(r&16)===16,t.keyAgreement=(r&8)===8,t.keyCertSign=(r&4)===4,t.cRLSign=(r&2)===2,t.encipherOnly=(r&1)===1,t.decipherOnly=(n&128)===128}else if(t.name==="basicConstraints"){var a=d.fromDer(t.value);a.value.length>0&&a.value[0].type===d.Type.BOOLEAN?t.cA=a.value[0].value.charCodeAt(0)!==0:t.cA=!1;var s=null;a.value.length>0&&a.value[0].type===d.Type.INTEGER?s=a.value[0].value:a.value.length>1&&(s=a.value[1].value),s!==null&&(t.pathLenConstraint=d.derToInteger(s))}else if(t.name==="extKeyUsage")for(var a=d.fromDer(t.value),i=0;i<a.value.length;++i){var o=d.derToOid(a.value[i].value);o in te?t[te[o]]=!0:t[o]=!0}else if(t.name==="nsCertType"){var a=d.fromDer(t.value),r=0;a.value.length>1&&(r=a.value.charCodeAt(1)),t.client=(r&128)===128,t.server=(r&64)===64,t.email=(r&32)===32,t.objsign=(r&16)===16,t.reserved=(r&8)===8,t.sslCA=(r&4)===4,t.emailCA=(r&2)===2,t.objCA=(r&1)===1}else if(t.name==="subjectAltName"||t.name==="issuerAltName"){t.altNames=[];for(var u,a=d.fromDer(t.value),l=0;l<a.value.length;++l){u=a.value[l];var c={type:u.type,value:u.value};switch(t.altNames.push(c),u.type){case 1:case 2:case 6:break;case 7:c.ip=q.util.bytesToIP(u.value);break;case 8:c.oid=d.derToOid(u.value);break;default:}}}else if(t.name==="subjectKeyIdentifier"){var a=d.fromDer(t.value);t.subjectKeyIdentifier=q.util.bytesToHex(a.value)}}return t};L.certificationRequestFromAsn1=function(e,t){var a={},r=[];if(!d.validate(e,Ac,a,r)){var n=new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.");throw n.errors=r,n}var s=d.derToOid(a.publicKeyOid);if(s!==L.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var i=L.createCertificationRequest();if(i.version=a.csrVersion?a.csrVersion.charCodeAt(0):0,i.signatureOid=q.asn1.derToOid(a.csrSignatureOid),i.signatureParameters=da(i.signatureOid,a.csrSignatureParams,!0),i.siginfo.algorithmOid=q.asn1.derToOid(a.csrSignatureOid),i.siginfo.parameters=da(i.siginfo.algorithmOid,a.csrSignatureParams,!1),i.signature=a.csrSignature,i.certificationRequestInfo=a.certificationRequestInfo,t){i.md=ha({signatureOid:i.signatureOid,type:"certification request"});var o=d.toDer(i.certificationRequestInfo);i.md.update(o.getBytes())}var u=q.md.sha1.create();return i.subject.getField=function(l){return Ut(i.subject,l)},i.subject.addField=function(l){nt([l]),i.subject.attributes.push(l)},i.subject.attributes=L.RDNAttributesAsArray(a.certificationRequestInfoSubject,u),i.subject.hash=u.digest().toHex(),i.publicKey=L.publicKeyFromAsn1(a.subjectPublicKeyInfo),i.getAttribute=function(l){return Ut(i,l)},i.addAttribute=function(l){nt([l]),i.attributes.push(l)},i.attributes=L.CRIAttributesAsArray(a.certificationRequestInfoAttributes||[]),i};L.createCertificationRequest=function(){var e={};return e.version=0,e.signatureOid=null,e.signature=null,e.siginfo={},e.siginfo.algorithmOid=null,e.subject={},e.subject.getField=function(t){return Ut(e.subject,t)},e.subject.addField=function(t){nt([t]),e.subject.attributes.push(t)},e.subject.attributes=[],e.subject.hash=null,e.publicKey=null,e.attributes=[],e.getAttribute=function(t){return Ut(e,t)},e.addAttribute=function(t){nt([t]),e.attributes.push(t)},e.md=null,e.setSubject=function(t){nt(t),e.subject.attributes=t,e.subject.hash=null},e.setAttributes=function(t){nt(t),e.attributes=t},e.sign=function(t,a){e.md=a||q.md.sha1.create();var r=te[e.md.algorithm+"WithRSAEncryption"];if(!r){var n=new Error("Could not compute certification request digest. Unknown message digest algorithm OID.");throw n.algorithm=e.md.algorithm,n}e.signatureOid=e.siginfo.algorithmOid=r,e.certificationRequestInfo=L.getCertificationRequestInfo(e);var s=d.toDer(e.certificationRequestInfo);e.md.update(s.getBytes()),e.signature=t.sign(e.md)},e.verify=function(){var t=!1,a=e.md;if(a===null){a=ha({signatureOid:e.signatureOid,type:"certification request"});var r=e.certificationRequestInfo||L.getCertificationRequestInfo(e),n=d.toDer(r);a.update(n.getBytes())}return a!==null&&(t=gs({certificate:e,md:a,signature:e.signature})),t},e};function dr(e){for(var t=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]),a,r,n=e.attributes,s=0;s<n.length;++s){a=n[s];var i=a.value,o=d.Type.PRINTABLESTRING;"valueTagClass"in a&&(o=a.valueTagClass,o===d.Type.UTF8&&(i=q.util.encodeUtf8(i))),r=d.create(d.Class.UNIVERSAL,d.Type.SET,!0,[d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(a.type).getBytes()),d.create(d.Class.UNIVERSAL,o,!1,i)])]),t.value.push(r)}return t}function nt(e){for(var t,a=0;a<e.length;++a){if(t=e[a],typeof t.name>"u"&&(t.type&&t.type in L.oids?t.name=L.oids[t.type]:t.shortName&&t.shortName in ge&&(t.name=L.oids[ge[t.shortName]])),typeof t.type>"u")if(t.name&&t.name in L.oids)t.type=L.oids[t.name];else{var r=new Error("Attribute type not specified.");throw r.attribute=t,r}if(typeof t.shortName>"u"&&t.name&&t.name in ge&&(t.shortName=ge[t.name]),t.type===te.extensionRequest&&(t.valueConstructed=!0,t.valueTagClass=d.Type.SEQUENCE,!t.value&&t.extensions)){t.value=[];for(var n=0;n<t.extensions.length;++n)t.value.push(L.certificateExtensionToAsn1(ys(t.extensions[n])))}if(typeof t.value>"u"){var r=new Error("Attribute value not specified.");throw r.attribute=t,r}}}function ys(e,t){if(t=t||{},typeof e.name>"u"&&e.id&&e.id in L.oids&&(e.name=L.oids[e.id]),typeof e.id>"u")if(e.name&&e.name in L.oids)e.id=L.oids[e.name];else{var a=new Error("Extension ID not specified.");throw a.extension=e,a}if(typeof e.value<"u")return e;if(e.name==="keyUsage"){var r=0,n=0,s=0;e.digitalSignature&&(n|=128,r=7),e.nonRepudiation&&(n|=64,r=6),e.keyEncipherment&&(n|=32,r=5),e.dataEncipherment&&(n|=16,r=4),e.keyAgreement&&(n|=8,r=3),e.keyCertSign&&(n|=4,r=2),e.cRLSign&&(n|=2,r=1),e.encipherOnly&&(n|=1,r=0),e.decipherOnly&&(s|=128,r=7);var i=String.fromCharCode(r);s!==0?i+=String.fromCharCode(n)+String.fromCharCode(s):n!==0&&(i+=String.fromCharCode(n)),e.value=d.create(d.Class.UNIVERSAL,d.Type.BITSTRING,!1,i)}else if(e.name==="basicConstraints")e.value=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]),e.cA&&e.value.value.push(d.create(d.Class.UNIVERSAL,d.Type.BOOLEAN,!1,"\xFF")),"pathLenConstraint"in e&&e.value.value.push(d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,d.integerToDer(e.pathLenConstraint).getBytes()));else if(e.name==="extKeyUsage"){e.value=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]);var o=e.value.value;for(var u in e)e[u]===!0&&(u in te?o.push(d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(te[u]).getBytes())):u.indexOf(".")!==-1&&o.push(d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(u).getBytes())))}else if(e.name==="nsCertType"){var r=0,n=0;e.client&&(n|=128,r=7),e.server&&(n|=64,r=6),e.email&&(n|=32,r=5),e.objsign&&(n|=16,r=4),e.reserved&&(n|=8,r=3),e.sslCA&&(n|=4,r=2),e.emailCA&&(n|=2,r=1),e.objCA&&(n|=1,r=0);var i=String.fromCharCode(r);n!==0&&(i+=String.fromCharCode(n)),e.value=d.create(d.Class.UNIVERSAL,d.Type.BITSTRING,!1,i)}else if(e.name==="subjectAltName"||e.name==="issuerAltName"){e.value=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]);for(var l,c=0;c<e.altNames.length;++c){l=e.altNames[c];var i=l.value;if(l.type===7&&l.ip){if(i=q.util.bytesFromIP(l.ip),i===null){var a=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw a.extension=e,a}}else l.type===8&&(l.oid?i=d.oidToDer(d.oidToDer(l.oid)):i=d.oidToDer(i));e.value.value.push(d.create(d.Class.CONTEXT_SPECIFIC,l.type,!1,i))}}else if(e.name==="nsComment"&&t.cert){if(!/^[\x00-\x7F]*$/.test(e.comment)||e.comment.length<1||e.comment.length>128)throw new Error('Invalid "nsComment" content.');e.value=d.create(d.Class.UNIVERSAL,d.Type.IA5STRING,!1,e.comment)}else if(e.name==="subjectKeyIdentifier"&&t.cert){var f=t.cert.generateSubjectKeyIdentifier();e.subjectKeyIdentifier=f.toHex(),e.value=d.create(d.Class.UNIVERSAL,d.Type.OCTETSTRING,!1,f.getBytes())}else if(e.name==="authorityKeyIdentifier"&&t.cert){e.value=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]);var o=e.value.value;if(e.keyIdentifier){var g=e.keyIdentifier===!0?t.cert.generateSubjectKeyIdentifier().getBytes():e.keyIdentifier;o.push(d.create(d.Class.CONTEXT_SPECIFIC,0,!1,g))}if(e.authorityCertIssuer){var v=[d.create(d.Class.CONTEXT_SPECIFIC,4,!0,[dr(e.authorityCertIssuer===!0?t.cert.issuer:e.authorityCertIssuer)])];o.push(d.create(d.Class.CONTEXT_SPECIFIC,1,!0,v))}if(e.serialNumber){var y=q.util.hexToBytes(e.serialNumber===!0?t.cert.serialNumber:e.serialNumber);o.push(d.create(d.Class.CONTEXT_SPECIFIC,2,!1,y))}}else if(e.name==="cRLDistributionPoints"){e.value=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]);for(var o=e.value.value,x=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]),S=d.create(d.Class.CONTEXT_SPECIFIC,0,!0,[]),l,c=0;c<e.altNames.length;++c){l=e.altNames[c];var i=l.value;if(l.type===7&&l.ip){if(i=q.util.bytesFromIP(l.ip),i===null){var a=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw a.extension=e,a}}else l.type===8&&(l.oid?i=d.oidToDer(d.oidToDer(l.oid)):i=d.oidToDer(i));S.value.push(d.create(d.Class.CONTEXT_SPECIFIC,l.type,!1,i))}x.value.push(d.create(d.Class.CONTEXT_SPECIFIC,0,!0,[S])),o.push(x)}if(typeof e.value>"u"){var a=new Error("Extension value not specified.");throw a.extension=e,a}return e}function nn(e,t){switch(e){case te["RSASSA-PSS"]:var a=[];return t.hash.algorithmOid!==void 0&&a.push(d.create(d.Class.CONTEXT_SPECIFIC,0,!0,[d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(t.hash.algorithmOid).getBytes()),d.create(d.Class.UNIVERSAL,d.Type.NULL,!1,"")])])),t.mgf.algorithmOid!==void 0&&a.push(d.create(d.Class.CONTEXT_SPECIFIC,1,!0,[d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(t.mgf.algorithmOid).getBytes()),d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(t.mgf.hash.algorithmOid).getBytes()),d.create(d.Class.UNIVERSAL,d.Type.NULL,!1,"")])])])),t.saltLength!==void 0&&a.push(d.create(d.Class.CONTEXT_SPECIFIC,2,!0,[d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,d.integerToDer(t.saltLength).getBytes())])),d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,a);default:return d.create(d.Class.UNIVERSAL,d.Type.NULL,!1,"")}}function Bc(e){var t=d.create(d.Class.CONTEXT_SPECIFIC,0,!0,[]);if(e.attributes.length===0)return t;for(var a=e.attributes,r=0;r<a.length;++r){var n=a[r],s=n.value,i=d.Type.UTF8;"valueTagClass"in n&&(i=n.valueTagClass),i===d.Type.UTF8&&(s=q.util.encodeUtf8(s));var o=!1;"valueConstructed"in n&&(o=n.valueConstructed);var u=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(n.type).getBytes()),d.create(d.Class.UNIVERSAL,d.Type.SET,!0,[d.create(d.Class.UNIVERSAL,i,o,s)])]);t.value.push(u)}return t}var bc=new Date("1950-01-01T00:00:00Z"),_c=new Date("2050-01-01T00:00:00Z");function hs(e){return e>=bc&&e<_c?d.create(d.Class.UNIVERSAL,d.Type.UTCTIME,!1,d.dateToUtcTime(e)):d.create(d.Class.UNIVERSAL,d.Type.GENERALIZEDTIME,!1,d.dateToGeneralizedTime(e))}L.getTBSCertificate=function(e){var t=hs(e.validity.notBefore),a=hs(e.validity.notAfter),r=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.CONTEXT_SPECIFIC,0,!0,[d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,d.integerToDer(e.version).getBytes())]),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,q.util.hexToBytes(e.serialNumber)),d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(e.siginfo.algorithmOid).getBytes()),nn(e.siginfo.algorithmOid,e.siginfo.parameters)]),dr(e.issuer),d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[t,a]),dr(e.subject),L.publicKeyToAsn1(e.publicKey)]);return e.issuer.uniqueId&&r.value.push(d.create(d.Class.CONTEXT_SPECIFIC,1,!0,[d.create(d.Class.UNIVERSAL,d.Type.BITSTRING,!1,"\0"+e.issuer.uniqueId)])),e.subject.uniqueId&&r.value.push(d.create(d.Class.CONTEXT_SPECIFIC,2,!0,[d.create(d.Class.UNIVERSAL,d.Type.BITSTRING,!1,"\0"+e.subject.uniqueId)])),e.extensions.length>0&&r.value.push(L.certificateExtensionsToAsn1(e.extensions)),r};L.getCertificationRequestInfo=function(e){var t=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,d.integerToDer(e.version).getBytes()),dr(e.subject),L.publicKeyToAsn1(e.publicKey),Bc(e)]);return t};L.distinguishedNameToAsn1=function(e){return dr(e)};L.certificateToAsn1=function(e){var t=e.tbsCertificate||L.getTBSCertificate(e);return d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[t,d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(e.signatureOid).getBytes()),nn(e.signatureOid,e.signatureParameters)]),d.create(d.Class.UNIVERSAL,d.Type.BITSTRING,!1,"\0"+e.signature)])};L.certificateExtensionsToAsn1=function(e){var t=d.create(d.Class.CONTEXT_SPECIFIC,3,!0,[]),a=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]);t.value.push(a);for(var r=0;r<e.length;++r)a.value.push(L.certificateExtensionToAsn1(e[r]));return t};L.certificateExtensionToAsn1=function(e){var t=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]);t.value.push(d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(e.id).getBytes())),e.critical&&t.value.push(d.create(d.Class.UNIVERSAL,d.Type.BOOLEAN,!1,"\xFF"));var a=e.value;return typeof e.value!="string"&&(a=d.toDer(a).getBytes()),t.value.push(d.create(d.Class.UNIVERSAL,d.Type.OCTETSTRING,!1,a)),t};L.certificationRequestToAsn1=function(e){var t=e.certificationRequestInfo||L.getCertificationRequestInfo(e);return d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[t,d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(e.signatureOid).getBytes()),nn(e.signatureOid,e.signatureParameters)]),d.create(d.Class.UNIVERSAL,d.Type.BITSTRING,!1,"\0"+e.signature)])};L.createCaStore=function(e){var t={certs:{}};t.getIssuer=function(i){var o=a(i.issuer);return o},t.addCertificate=function(i){if(typeof i=="string"&&(i=q.pki.certificateFromPem(i)),r(i.subject),!t.hasCertificate(i))if(i.subject.hash in t.certs){var o=t.certs[i.subject.hash];q.util.isArray(o)||(o=[o]),o.push(i),t.certs[i.subject.hash]=o}else t.certs[i.subject.hash]=i},t.hasCertificate=function(i){typeof i=="string"&&(i=q.pki.certificateFromPem(i));var o=a(i.subject);if(!o)return!1;q.util.isArray(o)||(o=[o]);for(var u=d.toDer(L.certificateToAsn1(i)).getBytes(),l=0;l<o.length;++l){var c=d.toDer(L.certificateToAsn1(o[l])).getBytes();if(u===c)return!0}return!1},t.listAllCertificates=function(){var i=[];for(var o in t.certs)if(t.certs.hasOwnProperty(o)){var u=t.certs[o];if(!q.util.isArray(u))i.push(u);else for(var l=0;l<u.length;++l)i.push(u[l])}return i},t.removeCertificate=function(i){var o;if(typeof i=="string"&&(i=q.pki.certificateFromPem(i)),r(i.subject),!t.hasCertificate(i))return null;var u=a(i.subject);if(!q.util.isArray(u))return o=t.certs[i.subject.hash],delete t.certs[i.subject.hash],o;for(var l=d.toDer(L.certificateToAsn1(i)).getBytes(),c=0;c<u.length;++c){var f=d.toDer(L.certificateToAsn1(u[c])).getBytes();l===f&&(o=u[c],u.splice(c,1))}return u.length===0&&delete t.certs[i.subject.hash],o};function a(i){return r(i),t.certs[i.hash]||null}function r(i){if(!i.hash){var o=q.md.sha1.create();i.attributes=L.RDNAttributesAsArray(dr(i),o),i.hash=o.digest().toHex()}}if(e)for(var n=0;n<e.length;++n){var s=e[n];t.addCertificate(s)}return t};L.certificateError={bad_certificate:"forge.pki.BadCertificate",unsupported_certificate:"forge.pki.UnsupportedCertificate",certificate_revoked:"forge.pki.CertificateRevoked",certificate_expired:"forge.pki.CertificateExpired",certificate_unknown:"forge.pki.CertificateUnknown",unknown_ca:"forge.pki.UnknownCertificateAuthority"};L.verifyCertificateChain=function(e,t,a){typeof a=="function"&&(a={verify:a}),a=a||{},t=t.slice(0);var r=t.slice(0),n=a.validityCheckDate;typeof n>"u"&&(n=new Date);var s=!0,i=null,o=0;do{var u=t.shift(),l=null,c=!1;if(n&&(n<u.validity.notBefore||n>u.validity.notAfter)&&(i={message:"Certificate is not valid yet or has expired.",error:L.certificateError.certificate_expired,notBefore:u.validity.notBefore,notAfter:u.validity.notAfter,now:n}),i===null){if(l=t[0]||e.getIssuer(u),l===null&&u.isIssuer(u)&&(c=!0,l=u),l){var f=l;q.util.isArray(f)||(f=[f]);for(var g=!1;!g&&f.length>0;){l=f.shift();try{g=l.verify(u)}catch{}}g||(i={message:"Certificate signature is invalid.",error:L.certificateError.bad_certificate})}i===null&&(!l||c)&&!e.hasCertificate(u)&&(i={message:"Certificate is not trusted.",error:L.certificateError.unknown_ca})}if(i===null&&l&&!u.isIssuer(l)&&(i={message:"Certificate issuer is invalid.",error:L.certificateError.bad_certificate}),i===null)for(var v={keyUsage:!0,basicConstraints:!0},y=0;i===null&&y<u.extensions.length;++y){var x=u.extensions[y];x.critical&&!(x.name in v)&&(i={message:"Certificate has an unsupported critical extension.",error:L.certificateError.unsupported_certificate})}if(i===null&&(!s||t.length===0&&(!l||c))){var S=u.getExtension("basicConstraints"),I=u.getExtension("keyUsage");if(I!==null&&(!I.keyCertSign||S===null)&&(i={message:"Certificate keyUsage or basicConstraints conflict or indicate that the certificate is not a CA. If the certificate is the only one in the chain or isn't the first then the certificate must be a valid CA.",error:L.certificateError.bad_certificate}),i===null&&S===null&&(i={message:"Certificate is missing basicConstraints extension and cannot be used as a CA.",error:L.certificateError.bad_certificate}),i===null&&S!==null&&!S.cA&&(i={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:L.certificateError.bad_certificate}),i===null&&I!==null&&"pathLenConstraint"in S){var B=o-1;B>S.pathLenConstraint&&(i={message:"Certificate basicConstraints pathLenConstraint violated.",error:L.certificateError.bad_certificate})}}var b=i===null?!0:i.error,P=a.verify?a.verify(b,o,r):b;if(P===!0)i=null;else throw b===!0&&(i={message:"The application rejected the certificate.",error:L.certificateError.bad_certificate}),(P||P===0)&&(typeof P=="object"&&!q.util.isArray(P)?(P.message&&(i.message=P.message),P.error&&(i.error=P.error)):typeof P=="string"&&(i.error=P)),i;s=!1,++o}while(t.length>0);return!0}});var on=F((jh,Cs)=>{var ce=$();lt();ir();Lt();rn();tn();tt();Nr();lr();re();pa();var m=ce.asn1,W=ce.pki,Lr=Cs.exports=ce.pkcs12=ce.pkcs12||{},ms={name:"ContentInfo",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.contentType",tagClass:m.Class.UNIVERSAL,type:m.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:m.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"content"}]},wc={name:"PFX",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.version",tagClass:m.Class.UNIVERSAL,type:m.Type.INTEGER,constructed:!1,capture:"version"},ms,{name:"PFX.macData",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"mac",value:[{name:"PFX.macData.mac",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm.algorithm",tagClass:m.Class.UNIVERSAL,type:m.Type.OID,constructed:!1,capture:"macAlgorithm"},{name:"PFX.macData.mac.digestAlgorithm.parameters",optional:!0,tagClass:m.Class.UNIVERSAL,captureAsn1:"macAlgorithmParameters"}]},{name:"PFX.macData.mac.digest",tagClass:m.Class.UNIVERSAL,type:m.Type.OCTETSTRING,constructed:!1,capture:"macDigest"}]},{name:"PFX.macData.macSalt",tagClass:m.Class.UNIVERSAL,type:m.Type.OCTETSTRING,constructed:!1,capture:"macSalt"},{name:"PFX.macData.iterations",tagClass:m.Class.UNIVERSAL,type:m.Type.INTEGER,constructed:!1,optional:!0,capture:"macIterations"}]}]},Nc={name:"SafeBag",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"SafeBag.bagId",tagClass:m.Class.UNIVERSAL,type:m.Type.OID,constructed:!1,capture:"bagId"},{name:"SafeBag.bagValue",tagClass:m.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"bagValue"},{name:"SafeBag.bagAttributes",tagClass:m.Class.UNIVERSAL,type:m.Type.SET,constructed:!0,optional:!0,capture:"bagAttributes"}]},Rc={name:"Attribute",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"Attribute.attrId",tagClass:m.Class.UNIVERSAL,type:m.Type.OID,constructed:!1,capture:"oid"},{name:"Attribute.attrValues",tagClass:m.Class.UNIVERSAL,type:m.Type.SET,constructed:!0,capture:"values"}]},Lc={name:"CertBag",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"CertBag.certId",tagClass:m.Class.UNIVERSAL,type:m.Type.OID,constructed:!1,capture:"certId"},{name:"CertBag.certValue",tagClass:m.Class.CONTEXT_SPECIFIC,constructed:!0,value:[{name:"CertBag.certValue[0]",tagClass:m.Class.UNIVERSAL,type:m.Class.OCTETSTRING,constructed:!1,capture:"cert"}]}]};function Rr(e,t,a,r){for(var n=[],s=0;s<e.length;s++)for(var i=0;i<e[s].safeBags.length;i++){var o=e[s].safeBags[i];if(!(r!==void 0&&o.type!==r)){if(t===null){n.push(o);continue}o.attributes[t]!==void 0&&o.attributes[t].indexOf(a)>=0&&n.push(o)}}return n}Lr.pkcs12FromAsn1=function(e,t,a){typeof t=="string"?(a=t,t=!0):t===void 0&&(t=!0);var r={},n=[];if(!m.validate(e,wc,r,n)){var s=new Error("Cannot read PKCS#12 PFX. ASN.1 object is not an PKCS#12 PFX.");throw s.errors=s,s}var i={version:r.version.charCodeAt(0),safeContents:[],getBags:function(S){var I={},B;return"localKeyId"in S?B=S.localKeyId:"localKeyIdHex"in S&&(B=ce.util.hexToBytes(S.localKeyIdHex)),B===void 0&&!("friendlyName"in S)&&"bagType"in S&&(I[S.bagType]=Rr(i.safeContents,null,null,S.bagType)),B!==void 0&&(I.localKeyId=Rr(i.safeContents,"localKeyId",B,S.bagType)),"friendlyName"in S&&(I.friendlyName=Rr(i.safeContents,"friendlyName",S.friendlyName,S.bagType)),I},getBagsByFriendlyName:function(S,I){return Rr(i.safeContents,"friendlyName",S,I)},getBagsByLocalKeyId:function(S,I){return Rr(i.safeContents,"localKeyId",S,I)}};if(r.version.charCodeAt(0)!==3){var s=new Error("PKCS#12 PFX of version other than 3 not supported.");throw s.version=r.version.charCodeAt(0),s}if(m.derToOid(r.contentType)!==W.oids.data){var s=new Error("Only PKCS#12 PFX in password integrity mode supported.");throw s.oid=m.derToOid(r.contentType),s}var o=r.content.value[0];if(o.tagClass!==m.Class.UNIVERSAL||o.type!==m.Type.OCTETSTRING)throw new Error("PKCS#12 authSafe content data is not an OCTET STRING.");if(o=sn(o),r.mac){var u=null,l=0,c=m.derToOid(r.macAlgorithm);switch(c){case W.oids.sha1:u=ce.md.sha1.create(),l=20;break;case W.oids.sha256:u=ce.md.sha256.create(),l=32;break;case W.oids.sha384:u=ce.md.sha384.create(),l=48;break;case W.oids.sha512:u=ce.md.sha512.create(),l=64;break;case W.oids.md5:u=ce.md.md5.create(),l=16;break}if(u===null)throw new Error("PKCS#12 uses unsupported MAC algorithm: "+c);var f=new ce.util.ByteBuffer(r.macSalt),g="macIterations"in r?parseInt(ce.util.bytesToHex(r.macIterations),16):1,v=Lr.generateKey(a,f,3,g,l,u),y=ce.hmac.create();y.start(u,v),y.update(o.value);var x=y.getMac();if(x.getBytes()!==r.macDigest)throw new Error("PKCS#12 MAC could not be verified. Invalid password?")}else if(Array.isArray(e.value)&&e.value.length>2)throw new Error("Invalid PKCS#12. macData field present but MAC was not validated.");return kc(i,o.value,t,a),i};function sn(e){if(e.composed||e.constructed){for(var t=ce.util.createBuffer(),a=0;a<e.value.length;++a)t.putBytes(e.value[a].value);e.composed=e.constructed=!1,e.value=t.getBytes()}return e}function kc(e,t,a,r){if(t=m.fromDer(t,a),t.tagClass!==m.Class.UNIVERSAL||t.type!==m.Type.SEQUENCE||t.constructed!==!0)throw new Error("PKCS#12 AuthenticatedSafe expected to be a SEQUENCE OF ContentInfo");for(var n=0;n<t.value.length;n++){var s=t.value[n],i={},o=[];if(!m.validate(s,ms,i,o)){var u=new Error("Cannot read ContentInfo.");throw u.errors=o,u}var l={encrypted:!1},c=null,f=i.content.value[0];switch(m.derToOid(i.contentType)){case W.oids.data:if(f.tagClass!==m.Class.UNIVERSAL||f.type!==m.Type.OCTETSTRING)throw new Error("PKCS#12 SafeContents Data is not an OCTET STRING.");c=sn(f).value;break;case W.oids.encryptedData:c=Dc(f,r),l.encrypted=!0;break;default:var u=new Error("Unsupported PKCS#12 contentType.");throw u.contentType=m.derToOid(i.contentType),u}l.safeBags=Uc(c,a,r),e.safeContents.push(l)}}function Dc(e,t){var a={},r=[];if(!m.validate(e,ce.pkcs7.asn1.encryptedDataValidator,a,r)){var n=new Error("Cannot read EncryptedContentInfo.");throw n.errors=r,n}var s=m.derToOid(a.contentType);if(s!==W.oids.data){var n=new Error("PKCS#12 EncryptedContentInfo ContentType is not Data.");throw n.oid=s,n}s=m.derToOid(a.encAlgorithm);var i=W.pbe.getCipher(s,a.encParameter,t),o=sn(a.encryptedContentAsn1),u=ce.util.createBuffer(o.value);if(i.update(u),!i.finish())throw new Error("Failed to decrypt PKCS#12 SafeContents.");return i.output.getBytes()}function Uc(e,t,a){if(!t&&e.length===0)return[];if(e=m.fromDer(e,t),e.tagClass!==m.Class.UNIVERSAL||e.type!==m.Type.SEQUENCE||e.constructed!==!0)throw new Error("PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag.");for(var r=[],n=0;n<e.value.length;n++){var s=e.value[n],i={},o=[];if(!m.validate(s,Nc,i,o)){var u=new Error("Cannot read SafeBag.");throw u.errors=o,u}var l={type:m.derToOid(i.bagId),attributes:Pc(i.bagAttributes)};r.push(l);var c,f,g=i.bagValue.value[0];switch(l.type){case W.oids.pkcs8ShroudedKeyBag:if(g=W.decryptPrivateKeyInfo(g,a),g===null)throw new Error("Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?");case W.oids.keyBag:try{l.key=W.privateKeyFromAsn1(g)}catch{l.key=null,l.asn1=g}continue;case W.oids.certBag:c=Lc,f=function(){if(m.derToOid(i.certId)!==W.oids.x509Certificate){var y=new Error("Unsupported certificate type, only X.509 supported.");throw y.oid=m.derToOid(i.certId),y}var x=m.fromDer(i.cert,t);try{l.cert=W.certificateFromAsn1(x,!0)}catch{l.cert=null,l.asn1=x}};break;default:var u=new Error("Unsupported PKCS#12 SafeBag type.");throw u.oid=l.type,u}if(c!==void 0&&!m.validate(g,c,i,o)){var u=new Error("Cannot read PKCS#12 "+c.name);throw u.errors=o,u}f()}return r}function Pc(e){var t={};if(e!==void 0)for(var a=0;a<e.length;++a){var r={},n=[];if(!m.validate(e[a],Rc,r,n)){var s=new Error("Cannot read PKCS#12 BagAttribute.");throw s.errors=n,s}var i=m.derToOid(r.oid);if(W.oids[i]!==void 0){t[W.oids[i]]=[];for(var o=0;o<r.values.length;++o)t[W.oids[i]].push(r.values[o].value)}}return t}Lr.toPkcs12Asn1=function(e,t,a,r){r=r||{},r.saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||r.encAlgorithm||"aes128","useMac"in r||(r.useMac=!0),"localKeyId"in r||(r.localKeyId=null),"generateLocalKeyId"in r||(r.generateLocalKeyId=!0);var n=r.localKeyId,s;if(n!==null)n=ce.util.hexToBytes(n);else if(r.generateLocalKeyId)if(t){var i=ce.util.isArray(t)?t[0]:t;typeof i=="string"&&(i=W.certificateFromPem(i));var o=ce.md.sha1.create();o.update(m.toDer(W.certificateToAsn1(i)).getBytes()),n=o.digest().getBytes()}else n=ce.random.getBytes(20);var u=[];n!==null&&u.push(m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(W.oids.localKeyId).getBytes()),m.create(m.Class.UNIVERSAL,m.Type.SET,!0,[m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,n)])])),"friendlyName"in r&&u.push(m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(W.oids.friendlyName).getBytes()),m.create(m.Class.UNIVERSAL,m.Type.SET,!0,[m.create(m.Class.UNIVERSAL,m.Type.BMPSTRING,!1,r.friendlyName)])])),u.length>0&&(s=m.create(m.Class.UNIVERSAL,m.Type.SET,!0,u));var l=[],c=[];t!==null&&(ce.util.isArray(t)?c=t:c=[t]);for(var f=[],g=0;g<c.length;++g){t=c[g],typeof t=="string"&&(t=W.certificateFromPem(t));var v=g===0?s:void 0,y=W.certificateToAsn1(t),x=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(W.oids.certBag).getBytes()),m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(W.oids.x509Certificate).getBytes()),m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,m.toDer(y).getBytes())])])]),v]);f.push(x)}if(f.length>0){var S=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,f),I=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(W.oids.data).getBytes()),m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,m.toDer(S).getBytes())])]);l.push(I)}var B=null;if(e!==null){var b=W.wrapRsaPrivateKey(W.privateKeyToAsn1(e));a===null?B=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(W.oids.keyBag).getBytes()),m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[b]),s]):B=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(W.oids.pkcs8ShroudedKeyBag).getBytes()),m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[W.encryptPrivateKeyInfo(b,a,r)]),s]);var P=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[B]),k=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(W.oids.data).getBytes()),m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,m.toDer(P).getBytes())])]);l.push(k)}var R=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,l),z;if(r.useMac){var o=ce.md.sha1.create(),Y=new ce.util.ByteBuffer(ce.random.getBytes(r.saltSize)),ne=r.count,e=Lr.generateKey(a,Y,3,ne,20),ie=ce.hmac.create();ie.start(o,e),ie.update(m.toDer(R).getBytes());var ue=ie.getMac();z=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(W.oids.sha1).getBytes()),m.create(m.Class.UNIVERSAL,m.Type.NULL,!1,"")]),m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,ue.getBytes())]),m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,Y.getBytes()),m.create(m.Class.UNIVERSAL,m.Type.INTEGER,!1,m.integerToDer(ne).getBytes())])}return m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.INTEGER,!1,m.integerToDer(3).getBytes()),m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(W.oids.data).getBytes()),m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,m.toDer(R).getBytes())])]),z])};Lr.generateKey=ce.pbe.generatePkcs12Key});var ln=F((Wh,Es)=>{var Pt=$();lt();Lt();tn();Qt();na();on();fa();Nr();re();pa();var un=Pt.asn1,hr=Es.exports=Pt.pki=Pt.pki||{};hr.pemToDer=function(e){var t=Pt.pem.decode(e)[0];if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert PEM to DER; PEM is encrypted.");return Pt.util.createBuffer(t.body)};hr.privateKeyFromPem=function(e){var t=Pt.pem.decode(e)[0];if(t.type!=="PRIVATE KEY"&&t.type!=="RSA PRIVATE KEY"){var a=new Error('Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');throw a.headerType=t.type,a}if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert private key from PEM; PEM is encrypted.");var r=un.fromDer(t.body);return hr.privateKeyFromAsn1(r)};hr.privateKeyToPem=function(e,t){var a={type:"RSA PRIVATE KEY",body:un.toDer(hr.privateKeyToAsn1(e)).getBytes()};return Pt.pem.encode(a,{maxline:t})};hr.privateKeyInfoToPem=function(e,t){var a={type:"PRIVATE KEY",body:un.toDer(e).getBytes()};return Pt.pem.encode(a,{maxline:t})}});var gn=F((Xh,_s)=>{var w=$();lt();ir();ea();Qt();ln();tt();lr();re();var ma=function(e,t,a,r){var n=w.util.createBuffer(),s=e.length>>1,i=s+(e.length&1),o=e.substr(0,i),u=e.substr(s,i),l=w.util.createBuffer(),c=w.hmac.create();a=t+a;var f=Math.ceil(r/16),g=Math.ceil(r/20);c.start("MD5",o);var v=w.util.createBuffer();l.putBytes(a);for(var y=0;y<f;++y)c.start(null,null),c.update(l.getBytes()),l.putBuffer(c.digest()),c.start(null,null),c.update(l.bytes()+a),v.putBuffer(c.digest());c.start("SHA1",u);var x=w.util.createBuffer();l.clear(),l.putBytes(a);for(var y=0;y<g;++y)c.start(null,null),c.update(l.getBytes()),l.putBuffer(c.digest()),c.start(null,null),c.update(l.bytes()+a),x.putBuffer(c.digest());return n.putBytes(w.util.xorBytes(v.getBytes(),x.getBytes(),r)),n},Oc=function(e,t,a){var r=w.hmac.create();r.start("SHA1",e);var n=w.util.createBuffer();return n.putInt32(t[0]),n.putInt32(t[1]),n.putByte(a.type),n.putByte(a.version.major),n.putByte(a.version.minor),n.putInt16(a.length),n.putBytes(a.fragment.bytes()),r.update(n.getBytes()),r.digest().getBytes()},Vc=function(e,t,a){var r=!1;try{var n=e.deflate(t.fragment.getBytes());t.fragment=w.util.createBuffer(n),t.length=n.length,r=!0}catch{}return r},Fc=function(e,t,a){var r=!1;try{var n=e.inflate(t.fragment.getBytes());t.fragment=w.util.createBuffer(n),t.length=n.length,r=!0}catch{}return r},je=function(e,t){var a=0;switch(t){case 1:a=e.getByte();break;case 2:a=e.getInt16();break;case 3:a=e.getInt24();break;case 4:a=e.getInt32();break}return w.util.createBuffer(e.getBytes(a))},it=function(e,t,a){e.putInt(a.length(),t<<3),e.putBuffer(a)},p={};p.Versions={TLS_1_0:{major:3,minor:1},TLS_1_1:{major:3,minor:2},TLS_1_2:{major:3,minor:3}};p.SupportedVersions=[p.Versions.TLS_1_1,p.Versions.TLS_1_0];p.Version=p.SupportedVersions[0];p.MaxFragment=15360;p.ConnectionEnd={server:0,client:1};p.PRFAlgorithm={tls_prf_sha256:0};p.BulkCipherAlgorithm={none:null,rc4:0,des3:1,aes:2};p.CipherType={stream:0,block:1,aead:2};p.MACAlgorithm={none:null,hmac_md5:0,hmac_sha1:1,hmac_sha256:2,hmac_sha384:3,hmac_sha512:4};p.CompressionMethod={none:0,deflate:1};p.ContentType={change_cipher_spec:20,alert:21,handshake:22,application_data:23,heartbeat:24};p.HandshakeType={hello_request:0,client_hello:1,server_hello:2,certificate:11,server_key_exchange:12,certificate_request:13,server_hello_done:14,certificate_verify:15,client_key_exchange:16,finished:20};p.Alert={};p.Alert.Level={warning:1,fatal:2};p.Alert.Description={close_notify:0,unexpected_message:10,bad_record_mac:20,decryption_failed:21,record_overflow:22,decompression_failure:30,handshake_failure:40,bad_certificate:42,unsupported_certificate:43,certificate_revoked:44,certificate_expired:45,certificate_unknown:46,illegal_parameter:47,unknown_ca:48,access_denied:49,decode_error:50,decrypt_error:51,export_restriction:60,protocol_version:70,insufficient_security:71,internal_error:80,user_canceled:90,no_renegotiation:100};p.HeartbeatMessageType={heartbeat_request:1,heartbeat_response:2};p.CipherSuites={};p.getCipherSuite=function(e){var t=null;for(var a in p.CipherSuites){var r=p.CipherSuites[a];if(r.id[0]===e.charCodeAt(0)&&r.id[1]===e.charCodeAt(1)){t=r;break}}return t};p.handleUnexpected=function(e,t){var a=!e.open&&e.entity===p.ConnectionEnd.client;a||e.error(e,{message:"Unexpected message. Received TLS record out of order.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.unexpected_message}})};p.handleHelloRequest=function(e,t,a){!e.handshaking&&e.handshakes>0&&(p.queue(e,p.createAlert(e,{level:p.Alert.Level.warning,description:p.Alert.Description.no_renegotiation})),p.flush(e)),e.process()};p.parseHelloMessage=function(e,t,a){var r=null,n=e.entity===p.ConnectionEnd.client;if(a<38)e.error(e,{message:n?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.illegal_parameter}});else{var s=t.fragment,i=s.length();if(r={version:{major:s.getByte(),minor:s.getByte()},random:w.util.createBuffer(s.getBytes(32)),session_id:je(s,1),extensions:[]},n?(r.cipher_suite=s.getBytes(2),r.compression_method=s.getByte()):(r.cipher_suites=je(s,2),r.compression_methods=je(s,1)),i=a-(i-s.length()),i>0){for(var o=je(s,2);o.length()>0;)r.extensions.push({type:[o.getByte(),o.getByte()],data:je(o,2)});if(!n)for(var u=0;u<r.extensions.length;++u){var l=r.extensions[u];if(l.type[0]===0&&l.type[1]===0)for(var c=je(l.data,2);c.length()>0;){var f=c.getByte();if(f!==0)break;e.session.extensions.server_name.serverNameList.push(je(c,2).getBytes())}}}if(e.session.version&&(r.version.major!==e.session.version.major||r.version.minor!==e.session.version.minor))return e.error(e,{message:"TLS version change is disallowed during renegotiation.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.protocol_version}});if(n)e.session.cipherSuite=p.getCipherSuite(r.cipher_suite);else for(var g=w.util.createBuffer(r.cipher_suites.bytes());g.length()>0&&(e.session.cipherSuite=p.getCipherSuite(g.getBytes(2)),e.session.cipherSuite===null););if(e.session.cipherSuite===null)return e.error(e,{message:"No cipher suites in common.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.handshake_failure},cipherSuite:w.util.bytesToHex(r.cipher_suite)});n?e.session.compressionMethod=r.compression_method:e.session.compressionMethod=p.CompressionMethod.none}return r};p.createSecurityParameters=function(e,t){var a=e.entity===p.ConnectionEnd.client,r=t.random.bytes(),n=a?e.session.sp.client_random:r,s=a?r:p.createRandom().getBytes();e.session.sp={entity:e.entity,prf_algorithm:p.PRFAlgorithm.tls_prf_sha256,bulk_cipher_algorithm:null,cipher_type:null,enc_key_length:null,block_length:null,fixed_iv_length:null,record_iv_length:null,mac_algorithm:null,mac_length:null,mac_key_length:null,compression_algorithm:e.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:n,server_random:s}};p.handleServerHello=function(e,t,a){var r=p.parseHelloMessage(e,t,a);if(!e.fail){if(r.version.minor<=e.version.minor)e.version.minor=r.version.minor;else return e.error(e,{message:"Incompatible TLS version.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.protocol_version}});e.session.version=e.version;var n=r.session_id.bytes();n.length>0&&n===e.session.id?(e.expect=Ts,e.session.resuming=!0,e.session.sp.server_random=r.random.bytes()):(e.expect=Mc,e.session.resuming=!1,p.createSecurityParameters(e,r)),e.session.id=n,e.process()}};p.handleClientHello=function(e,t,a){var r=p.parseHelloMessage(e,t,a);if(!e.fail){var n=r.session_id.bytes(),s=null;if(e.sessionCache&&(s=e.sessionCache.getSession(n),s===null?n="":(s.version.major!==r.version.major||s.version.minor>r.version.minor)&&(s=null,n="")),n.length===0&&(n=w.random.getBytes(32)),e.session.id=n,e.session.clientHelloVersion=r.version,e.session.sp={},s)e.version=e.session.version=s.version,e.session.sp=s.sp;else{for(var i,o=1;o<p.SupportedVersions.length&&(i=p.SupportedVersions[o],!(i.minor<=r.version.minor));++o);e.version={major:i.major,minor:i.minor},e.session.version=e.version}s!==null?(e.expect=hn,e.session.resuming=!0,e.session.sp.client_random=r.random.bytes()):(e.expect=e.verifyClient!==!1?Yc:dn,e.session.resuming=!1,p.createSecurityParameters(e,r)),e.open=!0,p.queue(e,p.createRecord(e,{type:p.ContentType.handshake,data:p.createServerHello(e)})),e.session.resuming?(p.queue(e,p.createRecord(e,{type:p.ContentType.change_cipher_spec,data:p.createChangeCipherSpec()})),e.state.pending=p.createConnectionState(e),e.state.current.write=e.state.pending.write,p.queue(e,p.createRecord(e,{type:p.ContentType.handshake,data:p.createFinished(e)}))):(p.queue(e,p.createRecord(e,{type:p.ContentType.handshake,data:p.createCertificate(e)})),e.fail||(p.queue(e,p.createRecord(e,{type:p.ContentType.handshake,data:p.createServerKeyExchange(e)})),e.verifyClient!==!1&&p.queue(e,p.createRecord(e,{type:p.ContentType.handshake,data:p.createCertificateRequest(e)})),p.queue(e,p.createRecord(e,{type:p.ContentType.handshake,data:p.createServerHelloDone(e)})))),p.flush(e),e.process()}};p.handleCertificate=function(e,t,a){if(a<3)return e.error(e,{message:"Invalid Certificate message. Message too short.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.illegal_parameter}});var r=t.fragment,n={certificate_list:je(r,3)},s,i,o=[];try{for(;n.certificate_list.length()>0;)s=je(n.certificate_list,3),i=w.asn1.fromDer(s),s=w.pki.certificateFromAsn1(i,!0),o.push(s)}catch(l){return e.error(e,{message:"Could not parse certificate list.",cause:l,send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.bad_certificate}})}var u=e.entity===p.ConnectionEnd.client;(u||e.verifyClient===!0)&&o.length===0?e.error(e,{message:u?"No server certificate provided.":"No client certificate provided.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.illegal_parameter}}):o.length===0?e.expect=u?xs:dn:(u?e.session.serverCertificate=o[0]:e.session.clientCertificate=o[0],p.verifyCertificateChain(e,o)&&(e.expect=u?xs:dn)),e.process()};p.handleServerKeyExchange=function(e,t,a){if(a>0)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.unsupported_certificate}});e.expect=qc,e.process()};p.handleClientKeyExchange=function(e,t,a){if(a<48)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.unsupported_certificate}});var r=t.fragment,n={enc_pre_master_secret:je(r,2).getBytes()},s=null;if(e.getPrivateKey)try{s=e.getPrivateKey(e,e.session.serverCertificate),s=w.pki.privateKeyFromPem(s)}catch(u){e.error(e,{message:"Could not get private key.",cause:u,send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.internal_error}})}if(s===null)return e.error(e,{message:"No private key set.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.internal_error}});try{var i=e.session.sp;i.pre_master_secret=s.decrypt(n.enc_pre_master_secret);var o=e.session.clientHelloVersion;if(o.major!==i.pre_master_secret.charCodeAt(0)||o.minor!==i.pre_master_secret.charCodeAt(1))throw new Error("TLS version rollback attack detected.")}catch{i.pre_master_secret=w.random.getBytes(48)}e.expect=hn,e.session.clientCertificate!==null&&(e.expect=jc),e.process()};p.handleCertificateRequest=function(e,t,a){if(a<3)return e.error(e,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.illegal_parameter}});var r=t.fragment,n={certificate_types:je(r,1),certificate_authorities:je(r,2)};e.session.certificateRequest=n,e.expect=Hc,e.process()};p.handleCertificateVerify=function(e,t,a){if(a<2)return e.error(e,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.illegal_parameter}});var r=t.fragment;r.read-=4;var n=r.bytes();r.read+=4;var s={signature:je(r,2).getBytes()},i=w.util.createBuffer();i.putBuffer(e.session.md5.digest()),i.putBuffer(e.session.sha1.digest()),i=i.getBytes();try{var o=e.session.clientCertificate;if(!o.publicKey.verify(i,s.signature,"NONE"))throw new Error("CertificateVerify signature does not match.");e.session.md5.update(n),e.session.sha1.update(n)}catch{return e.error(e,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.handshake_failure}})}e.expect=hn,e.process()};p.handleServerHelloDone=function(e,t,a){if(a>0)return e.error(e,{message:"Invalid ServerHelloDone message. Invalid length.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.record_overflow}});if(e.serverCertificate===null){var r={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.insufficient_security}},n=0,s=e.verify(e,r.alert.description,n,[]);if(s!==!0)return(s||s===0)&&(typeof s=="object"&&!w.util.isArray(s)?(s.message&&(r.message=s.message),s.alert&&(r.alert.description=s.alert)):typeof s=="number"&&(r.alert.description=s)),e.error(e,r)}e.session.certificateRequest!==null&&(t=p.createRecord(e,{type:p.ContentType.handshake,data:p.createCertificate(e)}),p.queue(e,t)),t=p.createRecord(e,{type:p.ContentType.handshake,data:p.createClientKeyExchange(e)}),p.queue(e,t),e.expect=Qc;var i=function(o,u){o.session.certificateRequest!==null&&o.session.clientCertificate!==null&&p.queue(o,p.createRecord(o,{type:p.ContentType.handshake,data:p.createCertificateVerify(o,u)})),p.queue(o,p.createRecord(o,{type:p.ContentType.change_cipher_spec,data:p.createChangeCipherSpec()})),o.state.pending=p.createConnectionState(o),o.state.current.write=o.state.pending.write,p.queue(o,p.createRecord(o,{type:p.ContentType.handshake,data:p.createFinished(o)})),o.expect=Ts,p.flush(o),o.process()};if(e.session.certificateRequest===null||e.session.clientCertificate===null)return i(e,null);p.getClientSignature(e,i)};p.handleChangeCipherSpec=function(e,t){if(t.fragment.getByte()!==1)return e.error(e,{message:"Invalid ChangeCipherSpec message received.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.illegal_parameter}});var a=e.entity===p.ConnectionEnd.client;(e.session.resuming&&a||!e.session.resuming&&!a)&&(e.state.pending=p.createConnectionState(e)),e.state.current.read=e.state.pending.read,(!e.session.resuming&&a||e.session.resuming&&!a)&&(e.state.pending=null),e.expect=a?Gc:Wc,e.process()};p.handleFinished=function(e,t,a){var r=t.fragment;r.read-=4;var n=r.bytes();r.read+=4;var s=t.fragment.getBytes();r=w.util.createBuffer(),r.putBuffer(e.session.md5.digest()),r.putBuffer(e.session.sha1.digest());var i=e.entity===p.ConnectionEnd.client,o=i?"server finished":"client finished",u=e.session.sp,l=12,c=ma;if(r=c(u.master_secret,o,r.getBytes(),l),r.getBytes()!==s)return e.error(e,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.decrypt_error}});e.session.md5.update(n),e.session.sha1.update(n),(e.session.resuming&&i||!e.session.resuming&&!i)&&(p.queue(e,p.createRecord(e,{type:p.ContentType.change_cipher_spec,data:p.createChangeCipherSpec()})),e.state.current.write=e.state.pending.write,e.state.pending=null,p.queue(e,p.createRecord(e,{type:p.ContentType.handshake,data:p.createFinished(e)}))),e.expect=i?zc:Xc,e.handshaking=!1,++e.handshakes,e.peerCertificate=i?e.session.serverCertificate:e.session.clientCertificate,p.flush(e),e.isConnected=!0,e.connected(e),e.process()};p.handleAlert=function(e,t){var a=t.fragment,r={level:a.getByte(),description:a.getByte()},n;switch(r.description){case p.Alert.Description.close_notify:n="Connection closed.";break;case p.Alert.Description.unexpected_message:n="Unexpected message.";break;case p.Alert.Description.bad_record_mac:n="Bad record MAC.";break;case p.Alert.Description.decryption_failed:n="Decryption failed.";break;case p.Alert.Description.record_overflow:n="Record overflow.";break;case p.Alert.Description.decompression_failure:n="Decompression failed.";break;case p.Alert.Description.handshake_failure:n="Handshake failure.";break;case p.Alert.Description.bad_certificate:n="Bad certificate.";break;case p.Alert.Description.unsupported_certificate:n="Unsupported certificate.";break;case p.Alert.Description.certificate_revoked:n="Certificate revoked.";break;case p.Alert.Description.certificate_expired:n="Certificate expired.";break;case p.Alert.Description.certificate_unknown:n="Certificate unknown.";break;case p.Alert.Description.illegal_parameter:n="Illegal parameter.";break;case p.Alert.Description.unknown_ca:n="Unknown certificate authority.";break;case p.Alert.Description.access_denied:n="Access denied.";break;case p.Alert.Description.decode_error:n="Decode error.";break;case p.Alert.Description.decrypt_error:n="Decrypt error.";break;case p.Alert.Description.export_restriction:n="Export restriction.";break;case p.Alert.Description.protocol_version:n="Unsupported protocol version.";break;case p.Alert.Description.insufficient_security:n="Insufficient security.";break;case p.Alert.Description.internal_error:n="Internal error.";break;case p.Alert.Description.user_canceled:n="User canceled.";break;case p.Alert.Description.no_renegotiation:n="Renegotiation not supported.";break;default:n="Unknown error.";break}if(r.description===p.Alert.Description.close_notify)return e.close();e.error(e,{message:n,send:!1,origin:e.entity===p.ConnectionEnd.client?"server":"client",alert:r}),e.process()};p.handleHandshake=function(e,t){var a=t.fragment,r=a.getByte(),n=a.getInt24();if(n>a.length())return e.fragmented=t,t.fragment=w.util.createBuffer(),a.read-=4,e.process();e.fragmented=null,a.read-=4;var s=a.bytes(n+4);a.read+=4,r in va[e.entity][e.expect]?(e.entity===p.ConnectionEnd.server&&!e.open&&!e.fail&&(e.handshaking=!0,e.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:w.md.md5.create(),sha1:w.md.sha1.create()}),r!==p.HandshakeType.hello_request&&r!==p.HandshakeType.certificate_verify&&r!==p.HandshakeType.finished&&(e.session.md5.update(s),e.session.sha1.update(s)),va[e.entity][e.expect][r](e,t,n)):p.handleUnexpected(e,t)};p.handleApplicationData=function(e,t){e.data.putBuffer(t.fragment),e.dataReady(e),e.process()};p.handleHeartbeat=function(e,t){var a=t.fragment,r=a.getByte(),n=a.getInt16(),s=a.getBytes(n);if(r===p.HeartbeatMessageType.heartbeat_request){if(e.handshaking||n>s.length)return e.process();p.queue(e,p.createRecord(e,{type:p.ContentType.heartbeat,data:p.createHeartbeat(p.HeartbeatMessageType.heartbeat_response,s)})),p.flush(e)}else if(r===p.HeartbeatMessageType.heartbeat_response){if(s!==e.expectedHeartbeatPayload)return e.process();e.heartbeatReceived&&e.heartbeatReceived(e,w.util.createBuffer(s))}e.process()};var Kc=0,Mc=1,xs=2,qc=3,Hc=4,Ts=5,Gc=6,zc=7,Qc=8,$c=0,Yc=1,dn=2,jc=3,hn=4,Wc=5,Xc=6,h=p.handleUnexpected,Is=p.handleChangeCipherSpec,Ae=p.handleAlert,ze=p.handleHandshake,As=p.handleApplicationData,Be=p.handleHeartbeat,pn=[];pn[p.ConnectionEnd.client]=[[h,Ae,ze,h,Be],[h,Ae,ze,h,Be],[h,Ae,ze,h,Be],[h,Ae,ze,h,Be],[h,Ae,ze,h,Be],[Is,Ae,h,h,Be],[h,Ae,ze,h,Be],[h,Ae,ze,As,Be],[h,Ae,ze,h,Be]];pn[p.ConnectionEnd.server]=[[h,Ae,ze,h,Be],[h,Ae,ze,h,Be],[h,Ae,ze,h,Be],[h,Ae,ze,h,Be],[Is,Ae,h,h,Be],[h,Ae,ze,h,Be],[h,Ae,ze,As,Be],[h,Ae,ze,h,Be]];var Ot=p.handleHelloRequest,Jc=p.handleServerHello,Bs=p.handleCertificate,Ss=p.handleServerKeyExchange,cn=p.handleCertificateRequest,ga=p.handleServerHelloDone,bs=p.handleFinished,va=[];va[p.ConnectionEnd.client]=[[h,h,Jc,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h],[Ot,h,h,h,h,h,h,h,h,h,h,Bs,Ss,cn,ga,h,h,h,h,h,h],[Ot,h,h,h,h,h,h,h,h,h,h,h,Ss,cn,ga,h,h,h,h,h,h],[Ot,h,h,h,h,h,h,h,h,h,h,h,h,cn,ga,h,h,h,h,h,h],[Ot,h,h,h,h,h,h,h,h,h,h,h,h,h,ga,h,h,h,h,h,h],[Ot,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h],[Ot,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,bs],[Ot,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h],[Ot,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h]];var Zc=p.handleClientHello,ef=p.handleClientKeyExchange,tf=p.handleCertificateVerify;va[p.ConnectionEnd.server]=[[h,Zc,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h],[h,h,h,h,h,h,h,h,h,h,h,Bs,h,h,h,h,h,h,h,h,h],[h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,ef,h,h,h,h],[h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,tf,h,h,h,h,h],[h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h],[h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,bs],[h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h],[h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h]];p.generateKeys=function(e,t){var a=ma,r=t.client_random+t.server_random;e.session.resuming||(t.master_secret=a(t.pre_master_secret,"master secret",r,48).bytes(),t.pre_master_secret=null),r=t.server_random+t.client_random;var n=2*t.mac_key_length+2*t.enc_key_length,s=e.version.major===p.Versions.TLS_1_0.major&&e.version.minor===p.Versions.TLS_1_0.minor;s&&(n+=2*t.fixed_iv_length);var i=a(t.master_secret,"key expansion",r,n),o={client_write_MAC_key:i.getBytes(t.mac_key_length),server_write_MAC_key:i.getBytes(t.mac_key_length),client_write_key:i.getBytes(t.enc_key_length),server_write_key:i.getBytes(t.enc_key_length)};return s&&(o.client_write_IV=i.getBytes(t.fixed_iv_length),o.server_write_IV=i.getBytes(t.fixed_iv_length)),o};p.createConnectionState=function(e){var t=e.entity===p.ConnectionEnd.client,a=function(){var s={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(i){return!0},compressionState:null,compressFunction:function(i){return!0},updateSequenceNumber:function(){s.sequenceNumber[1]===4294967295?(s.sequenceNumber[1]=0,++s.sequenceNumber[0]):++s.sequenceNumber[1]}};return s},r={read:a(),write:a()};if(r.read.update=function(s,i){return r.read.cipherFunction(i,r.read)?r.read.compressFunction(s,i,r.read)||s.error(s,{message:"Could not decompress record.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.decompression_failure}}):s.error(s,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.bad_record_mac}}),!s.fail},r.write.update=function(s,i){return r.write.compressFunction(s,i,r.write)?r.write.cipherFunction(i,r.write)||s.error(s,{message:"Could not encrypt record.",send:!1,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.internal_error}}):s.error(s,{message:"Could not compress record.",send:!1,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.internal_error}}),!s.fail},e.session){var n=e.session.sp;switch(e.session.cipherSuite.initSecurityParameters(n),n.keys=p.generateKeys(e,n),r.read.macKey=t?n.keys.server_write_MAC_key:n.keys.client_write_MAC_key,r.write.macKey=t?n.keys.client_write_MAC_key:n.keys.server_write_MAC_key,e.session.cipherSuite.initConnectionState(r,e,n),n.compression_algorithm){case p.CompressionMethod.none:break;case p.CompressionMethod.deflate:r.read.compressFunction=Fc,r.write.compressFunction=Vc;break;default:throw new Error("Unsupported compression algorithm.")}}return r};p.createRandom=function(){var e=new Date,t=+e+e.getTimezoneOffset()*6e4,a=w.util.createBuffer();return a.putInt32(t),a.putBytes(w.random.getBytes(28)),a};p.createRecord=function(e,t){if(!t.data)return null;var a={type:t.type,version:{major:e.version.major,minor:e.version.minor},length:t.data.length(),fragment:t.data};return a};p.createAlert=function(e,t){var a=w.util.createBuffer();return a.putByte(t.level),a.putByte(t.description),p.createRecord(e,{type:p.ContentType.alert,data:a})};p.createClientHello=function(e){e.session.clientHelloVersion={major:e.version.major,minor:e.version.minor};for(var t=w.util.createBuffer(),a=0;a<e.cipherSuites.length;++a){var r=e.cipherSuites[a];t.putByte(r.id[0]),t.putByte(r.id[1])}var n=t.length(),s=w.util.createBuffer();s.putByte(p.CompressionMethod.none);var i=s.length(),o=w.util.createBuffer();if(e.virtualHost){var u=w.util.createBuffer();u.putByte(0),u.putByte(0);var l=w.util.createBuffer();l.putByte(0),it(l,2,w.util.createBuffer(e.virtualHost));var c=w.util.createBuffer();it(c,2,l),it(u,2,c),o.putBuffer(u)}var f=o.length();f>0&&(f+=2);var g=e.session.id,v=g.length+1+2+4+28+2+n+1+i+f,y=w.util.createBuffer();return y.putByte(p.HandshakeType.client_hello),y.putInt24(v),y.putByte(e.version.major),y.putByte(e.version.minor),y.putBytes(e.session.sp.client_random),it(y,1,w.util.createBuffer(g)),it(y,2,t),it(y,1,s),f>0&&it(y,2,o),y};p.createServerHello=function(e){var t=e.session.id,a=t.length+1+2+4+28+2+1,r=w.util.createBuffer();return r.putByte(p.HandshakeType.server_hello),r.putInt24(a),r.putByte(e.version.major),r.putByte(e.version.minor),r.putBytes(e.session.sp.server_random),it(r,1,w.util.createBuffer(t)),r.putByte(e.session.cipherSuite.id[0]),r.putByte(e.session.cipherSuite.id[1]),r.putByte(e.session.compressionMethod),r};p.createCertificate=function(e){var t=e.entity===p.ConnectionEnd.client,a=null;if(e.getCertificate){var r;t?r=e.session.certificateRequest:r=e.session.extensions.server_name.serverNameList,a=e.getCertificate(e,r)}var n=w.util.createBuffer();if(a!==null)try{w.util.isArray(a)||(a=[a]);for(var s=null,i=0;i<a.length;++i){var o=w.pem.decode(a[i])[0];if(o.type!=="CERTIFICATE"&&o.type!=="X509 CERTIFICATE"&&o.type!=="TRUSTED CERTIFICATE"){var u=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw u.headerType=o.type,u}if(o.procType&&o.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var l=w.util.createBuffer(o.body);s===null&&(s=w.asn1.fromDer(l.bytes(),!1));var c=w.util.createBuffer();it(c,3,l),n.putBuffer(c)}a=w.pki.certificateFromAsn1(s),t?e.session.clientCertificate=a:e.session.serverCertificate=a}catch(v){return e.error(e,{message:"Could not send certificate list.",cause:v,send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.bad_certificate}})}var f=3+n.length(),g=w.util.createBuffer();return g.putByte(p.HandshakeType.certificate),g.putInt24(f),it(g,3,n),g};p.createClientKeyExchange=function(e){var t=w.util.createBuffer();t.putByte(e.session.clientHelloVersion.major),t.putByte(e.session.clientHelloVersion.minor),t.putBytes(w.random.getBytes(46));var a=e.session.sp;a.pre_master_secret=t.getBytes();var r=e.session.serverCertificate.publicKey;t=r.encrypt(a.pre_master_secret);var n=t.length+2,s=w.util.createBuffer();return s.putByte(p.HandshakeType.client_key_exchange),s.putInt24(n),s.putInt16(t.length),s.putBytes(t),s};p.createServerKeyExchange=function(e){var t=0,a=w.util.createBuffer();return t>0&&(a.putByte(p.HandshakeType.server_key_exchange),a.putInt24(t)),a};p.getClientSignature=function(e,t){var a=w.util.createBuffer();a.putBuffer(e.session.md5.digest()),a.putBuffer(e.session.sha1.digest()),a=a.getBytes(),e.getSignature=e.getSignature||function(r,n,s){var i=null;if(r.getPrivateKey)try{i=r.getPrivateKey(r,r.session.clientCertificate),i=w.pki.privateKeyFromPem(i)}catch(o){r.error(r,{message:"Could not get private key.",cause:o,send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.internal_error}})}i===null?r.error(r,{message:"No private key set.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.internal_error}}):n=i.sign(n,null),s(r,n)},e.getSignature(e,a,t)};p.createCertificateVerify=function(e,t){var a=t.length+2,r=w.util.createBuffer();return r.putByte(p.HandshakeType.certificate_verify),r.putInt24(a),r.putInt16(t.length),r.putBytes(t),r};p.createCertificateRequest=function(e){var t=w.util.createBuffer();t.putByte(1);var a=w.util.createBuffer();for(var r in e.caStore.certs){var n=e.caStore.certs[r],s=w.pki.distinguishedNameToAsn1(n.subject),i=w.asn1.toDer(s);a.putInt16(i.length()),a.putBuffer(i)}var o=1+t.length()+2+a.length(),u=w.util.createBuffer();return u.putByte(p.HandshakeType.certificate_request),u.putInt24(o),it(u,1,t),it(u,2,a),u};p.createServerHelloDone=function(e){var t=w.util.createBuffer();return t.putByte(p.HandshakeType.server_hello_done),t.putInt24(0),t};p.createChangeCipherSpec=function(){var e=w.util.createBuffer();return e.putByte(1),e};p.createFinished=function(e){var t=w.util.createBuffer();t.putBuffer(e.session.md5.digest()),t.putBuffer(e.session.sha1.digest());var a=e.entity===p.ConnectionEnd.client,r=e.session.sp,n=12,s=ma,i=a?"client finished":"server finished";t=s(r.master_secret,i,t.getBytes(),n);var o=w.util.createBuffer();return o.putByte(p.HandshakeType.finished),o.putInt24(t.length()),o.putBuffer(t),o};p.createHeartbeat=function(e,t,a){typeof a>"u"&&(a=t.length);var r=w.util.createBuffer();r.putByte(e),r.putInt16(a),r.putBytes(t);var n=r.length(),s=Math.max(16,n-a-3);return r.putBytes(w.random.getBytes(s)),r};p.queue=function(e,t){if(t&&!(t.fragment.length()===0&&(t.type===p.ContentType.handshake||t.type===p.ContentType.alert||t.type===p.ContentType.change_cipher_spec))){if(t.type===p.ContentType.handshake){var a=t.fragment.bytes();e.session.md5.update(a),e.session.sha1.update(a),a=null}var r;if(t.fragment.length()<=p.MaxFragment)r=[t];else{r=[];for(var n=t.fragment.bytes();n.length>p.MaxFragment;)r.push(p.createRecord(e,{type:t.type,data:w.util.createBuffer(n.slice(0,p.MaxFragment))})),n=n.slice(p.MaxFragment);n.length>0&&r.push(p.createRecord(e,{type:t.type,data:w.util.createBuffer(n)}))}for(var s=0;s<r.length&&!e.fail;++s){var i=r[s],o=e.state.current.write;o.update(e,i)&&e.records.push(i)}}};p.flush=function(e){for(var t=0;t<e.records.length;++t){var a=e.records[t];e.tlsData.putByte(a.type),e.tlsData.putByte(a.version.major),e.tlsData.putByte(a.version.minor),e.tlsData.putInt16(a.fragment.length()),e.tlsData.putBuffer(e.records[t].fragment)}return e.records=[],e.tlsDataReady(e)};var fn=function(e){switch(e){case!0:return!0;case w.pki.certificateError.bad_certificate:return p.Alert.Description.bad_certificate;case w.pki.certificateError.unsupported_certificate:return p.Alert.Description.unsupported_certificate;case w.pki.certificateError.certificate_revoked:return p.Alert.Description.certificate_revoked;case w.pki.certificateError.certificate_expired:return p.Alert.Description.certificate_expired;case w.pki.certificateError.certificate_unknown:return p.Alert.Description.certificate_unknown;case w.pki.certificateError.unknown_ca:return p.Alert.Description.unknown_ca;default:return p.Alert.Description.bad_certificate}},rf=function(e){switch(e){case!0:return!0;case p.Alert.Description.bad_certificate:return w.pki.certificateError.bad_certificate;case p.Alert.Description.unsupported_certificate:return w.pki.certificateError.unsupported_certificate;case p.Alert.Description.certificate_revoked:return w.pki.certificateError.certificate_revoked;case p.Alert.Description.certificate_expired:return w.pki.certificateError.certificate_expired;case p.Alert.Description.certificate_unknown:return w.pki.certificateError.certificate_unknown;case p.Alert.Description.unknown_ca:return w.pki.certificateError.unknown_ca;default:return w.pki.certificateError.bad_certificate}};p.verifyCertificateChain=function(e,t){try{var a={};for(var r in e.verifyOptions)a[r]=e.verifyOptions[r];a.verify=function(s,i,o){var u=fn(s),l=e.verify(e,s,i,o);if(l!==!0){if(typeof l=="object"&&!w.util.isArray(l)){var c=new Error("The application rejected the certificate.");throw c.send=!0,c.alert={level:p.Alert.Level.fatal,description:p.Alert.Description.bad_certificate},l.message&&(c.message=l.message),l.alert&&(c.alert.description=l.alert),c}l!==s&&(l=rf(l))}return l},w.pki.verifyCertificateChain(e.caStore,t,a)}catch(s){var n=s;(typeof n!="object"||w.util.isArray(n))&&(n={send:!0,alert:{level:p.Alert.Level.fatal,description:fn(s)}}),"send"in n||(n.send=!0),"alert"in n||(n.alert={level:p.Alert.Level.fatal,description:fn(n.error)}),e.error(e,n)}return!e.fail};p.createSessionCache=function(e,t){var a=null;if(e&&e.getSession&&e.setSession&&e.order)a=e;else{a={},a.cache=e||{},a.capacity=Math.max(t||100,1),a.order=[];for(var r in e)a.order.length<=t?a.order.push(r):delete e[r];a.getSession=function(n){var s=null,i=null;if(n?i=w.util.bytesToHex(n):a.order.length>0&&(i=a.order[0]),i!==null&&i in a.cache){s=a.cache[i],delete a.cache[i];for(var o in a.order)if(a.order[o]===i){a.order.splice(o,1);break}}return s},a.setSession=function(n,s){if(a.order.length===a.capacity){var i=a.order.shift();delete a.cache[i]}var i=w.util.bytesToHex(n);a.order.push(i),a.cache[i]=s}}return a};p.createConnection=function(e){var t=null;e.caStore?w.util.isArray(e.caStore)?t=w.pki.createCaStore(e.caStore):t=e.caStore:t=w.pki.createCaStore();var a=e.cipherSuites||null;if(a===null){a=[];for(var r in p.CipherSuites)a.push(p.CipherSuites[r])}var n=e.server?p.ConnectionEnd.server:p.ConnectionEnd.client,s=e.sessionCache?p.createSessionCache(e.sessionCache):null,i={version:{major:p.Version.major,minor:p.Version.minor},entity:n,sessionId:e.sessionId,caStore:t,sessionCache:s,cipherSuites:a,connected:e.connected,virtualHost:e.virtualHost||null,verifyClient:e.verifyClient||!1,verify:e.verify||function(c,f,g,v){return f},verifyOptions:e.verifyOptions||{},getCertificate:e.getCertificate||null,getPrivateKey:e.getPrivateKey||null,getSignature:e.getSignature||null,input:w.util.createBuffer(),tlsData:w.util.createBuffer(),data:w.util.createBuffer(),tlsDataReady:e.tlsDataReady,dataReady:e.dataReady,heartbeatReceived:e.heartbeatReceived,closed:e.closed,error:function(c,f){f.origin=f.origin||(c.entity===p.ConnectionEnd.client?"client":"server"),f.send&&(p.queue(c,p.createAlert(c,f.alert)),p.flush(c));var g=f.fatal!==!1;g&&(c.fail=!0),e.error(c,f),g&&c.close(!1)},deflate:e.deflate||null,inflate:e.inflate||null};i.reset=function(c){i.version={major:p.Version.major,minor:p.Version.minor},i.record=null,i.session=null,i.peerCertificate=null,i.state={pending:null,current:null},i.expect=i.entity===p.ConnectionEnd.client?Kc:$c,i.fragmented=null,i.records=[],i.open=!1,i.handshakes=0,i.handshaking=!1,i.isConnected=!1,i.fail=!(c||typeof c>"u"),i.input.clear(),i.tlsData.clear(),i.data.clear(),i.state.current=p.createConnectionState(i)},i.reset();var o=function(c,f){var g=f.type-p.ContentType.change_cipher_spec,v=pn[c.entity][c.expect];g in v?v[g](c,f):p.handleUnexpected(c,f)},u=function(c){var f=0,g=c.input,v=g.length();if(v<5)f=5-v;else{c.record={type:g.getByte(),version:{major:g.getByte(),minor:g.getByte()},length:g.getInt16(),fragment:w.util.createBuffer(),ready:!1};var y=c.record.version.major===c.version.major;y&&c.session&&c.session.version&&(y=c.record.version.minor===c.version.minor),y||c.error(c,{message:"Incompatible TLS version.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.protocol_version}})}return f},l=function(c){var f=0,g=c.input,v=g.length();if(v<c.record.length)f=c.record.length-v;else{c.record.fragment.putBytes(g.getBytes(c.record.length)),g.compact();var y=c.state.current.read;y.update(c,c.record)&&(c.fragmented!==null&&(c.fragmented.type===c.record.type?(c.fragmented.fragment.putBuffer(c.record.fragment),c.record=c.fragmented):c.error(c,{message:"Invalid fragmented record.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.unexpected_message}})),c.record.ready=!0)}return f};return i.handshake=function(c){if(i.entity!==p.ConnectionEnd.client)i.error(i,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(i.handshaking)i.error(i,{message:"Handshake already in progress.",fatal:!1});else{i.fail&&!i.open&&i.handshakes===0&&(i.fail=!1),i.handshaking=!0,c=c||"";var f=null;c.length>0&&(i.sessionCache&&(f=i.sessionCache.getSession(c)),f===null&&(c="")),c.length===0&&i.sessionCache&&(f=i.sessionCache.getSession(),f!==null&&(c=f.id)),i.session={id:c,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:w.md.md5.create(),sha1:w.md.sha1.create()},f&&(i.version=f.version,i.session.sp=f.sp),i.session.sp.client_random=p.createRandom().getBytes(),i.open=!0,p.queue(i,p.createRecord(i,{type:p.ContentType.handshake,data:p.createClientHello(i)})),p.flush(i)}},i.process=function(c){var f=0;return c&&i.input.putBytes(c),i.fail||(i.record!==null&&i.record.ready&&i.record.fragment.isEmpty()&&(i.record=null),i.record===null&&(f=u(i)),!i.fail&&i.record!==null&&!i.record.ready&&(f=l(i)),!i.fail&&i.record!==null&&i.record.ready&&o(i,i.record)),f},i.prepare=function(c){return p.queue(i,p.createRecord(i,{type:p.ContentType.application_data,data:w.util.createBuffer(c)})),p.flush(i)},i.prepareHeartbeatRequest=function(c,f){return c instanceof w.util.ByteBuffer&&(c=c.bytes()),typeof f>"u"&&(f=c.length),i.expectedHeartbeatPayload=c,p.queue(i,p.createRecord(i,{type:p.ContentType.heartbeat,data:p.createHeartbeat(p.HeartbeatMessageType.heartbeat_request,c,f)})),p.flush(i)},i.close=function(c){if(!i.fail&&i.sessionCache&&i.session){var f={id:i.session.id,version:i.session.version,sp:i.session.sp};f.sp.keys=null,i.sessionCache.setSession(f.id,f)}i.open&&(i.open=!1,i.input.clear(),(i.isConnected||i.handshaking)&&(i.isConnected=i.handshaking=!1,p.queue(i,p.createAlert(i,{level:p.Alert.Level.warning,description:p.Alert.Description.close_notify})),p.flush(i)),i.closed(i)),i.reset(c)},i};_s.exports=w.tls=w.tls||{};for(ya in p)typeof p[ya]!="function"&&(w.tls[ya]=p[ya]);var ya;w.tls.prf_tls1=ma;w.tls.hmac_sha1=Oc;w.tls.createSessionCache=p.createSessionCache;w.tls.createConnection=p.createConnection});var Rs=F((Jh,Ns)=>{var Vt=$();Rt();gn();var st=Ns.exports=Vt.tls;st.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA={id:[0,47],name:"TLS_RSA_WITH_AES_128_CBC_SHA",initSecurityParameters:function(e){e.bulk_cipher_algorithm=st.BulkCipherAlgorithm.aes,e.cipher_type=st.CipherType.block,e.enc_key_length=16,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=st.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:ws};st.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA={id:[0,53],name:"TLS_RSA_WITH_AES_256_CBC_SHA",initSecurityParameters:function(e){e.bulk_cipher_algorithm=st.BulkCipherAlgorithm.aes,e.cipher_type=st.CipherType.block,e.enc_key_length=32,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=st.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:ws};function ws(e,t,a){var r=t.entity===Vt.tls.ConnectionEnd.client;e.read.cipherState={init:!1,cipher:Vt.cipher.createDecipher("AES-CBC",r?a.keys.server_write_key:a.keys.client_write_key),iv:r?a.keys.server_write_IV:a.keys.client_write_IV},e.write.cipherState={init:!1,cipher:Vt.cipher.createCipher("AES-CBC",r?a.keys.client_write_key:a.keys.server_write_key),iv:r?a.keys.client_write_IV:a.keys.server_write_IV},e.read.cipherFunction=of,e.write.cipherFunction=af,e.read.macLength=e.write.macLength=a.mac_length,e.read.macFunction=e.write.macFunction=st.hmac_sha1}function af(e,t){var a=!1,r=t.macFunction(t.macKey,t.sequenceNumber,e);e.fragment.putBytes(r),t.updateSequenceNumber();var n;e.version.minor===st.Versions.TLS_1_0.minor?n=t.cipherState.init?null:t.cipherState.iv:n=Vt.random.getBytesSync(16),t.cipherState.init=!0;var s=t.cipherState.cipher;return s.start({iv:n}),e.version.minor>=st.Versions.TLS_1_1.minor&&s.output.putBytes(n),s.update(e.fragment),s.finish(nf)&&(e.fragment=s.output,e.length=e.fragment.length(),a=!0),a}function nf(e,t,a){if(!a){var r=e-t.length()%e;t.fillWithByte(r-1,r)}return!0}function sf(e,t,a){var r=!0;if(a){for(var n=t.length(),s=t.last(),i=n-1-s;i<n-1;++i)r=r&&t.at(i)==s;r&&t.truncate(s+1)}return r}function of(e,t){var a=!1,r;e.version.minor===st.Versions.TLS_1_0.minor?r=t.cipherState.init?null:t.cipherState.iv:r=e.fragment.getBytes(16),t.cipherState.init=!0;var n=t.cipherState.cipher;n.start({iv:r}),n.update(e.fragment),a=n.finish(sf);var s=t.macLength,i=Vt.random.getBytesSync(s),o=n.output.length();o>=s?(e.fragment=n.output.getBytes(o-s),i=n.output.getBytes(s)):e.fragment=n.output.getBytes(),e.fragment=Vt.util.createBuffer(e.fragment),e.length=e.fragment.length();var u=t.macFunction(t.macKey,t.sequenceNumber,e);return t.updateSequenceNumber(),a=uf(t.macKey,i,u)&&a,a}function uf(e,t,a){var r=Vt.hmac.create();return r.start("SHA1",e),r.update(t),t=r.digest().getBytes(),r.start(null,null),r.update(a),a=r.digest().getBytes(),t===a}});var mn=F((Zh,Us)=>{var he=$();ft();re();var kr=Us.exports=he.sha512=he.sha512||{};he.md.sha512=he.md.algorithms.sha512=kr;var ks=he.sha384=he.sha512.sha384=he.sha512.sha384||{};ks.create=function(){return kr.create("SHA-384")};he.md.sha384=he.md.algorithms.sha384=ks;he.sha512.sha256=he.sha512.sha256||{create:function(){return kr.create("SHA-512/256")}};he.md["sha512/256"]=he.md.algorithms["sha512/256"]=he.sha512.sha256;he.sha512.sha224=he.sha512.sha224||{create:function(){return kr.create("SHA-512/224")}};he.md["sha512/224"]=he.md.algorithms["sha512/224"]=he.sha512.sha224;kr.create=function(e){if(Ds||lf(),typeof e>"u"&&(e="SHA-512"),!(e in Jt))throw new Error("Invalid SHA-512 algorithm: "+e);for(var t=Jt[e],a=null,r=he.util.createBuffer(),n=new Array(80),s=0;s<80;++s)n[s]=new Array(2);var i=64;switch(e){case"SHA-384":i=48;break;case"SHA-512/256":i=32;break;case"SHA-512/224":i=28;break}var o={algorithm:e.replace("-","").toLowerCase(),blockLength:128,digestLength:i,messageLength:0,fullMessageLength:null,messageLengthSize:16};return o.start=function(){o.messageLength=0,o.fullMessageLength=o.messageLength128=[];for(var u=o.messageLengthSize/4,l=0;l<u;++l)o.fullMessageLength.push(0);r=he.util.createBuffer(),a=new Array(t.length);for(var l=0;l<t.length;++l)a[l]=t[l].slice(0);return o},o.start(),o.update=function(u,l){l==="utf8"&&(u=he.util.encodeUtf8(u));var c=u.length;o.messageLength+=c,c=[c/4294967296>>>0,c>>>0];for(var f=o.fullMessageLength.length-1;f>=0;--f)o.fullMessageLength[f]+=c[1],c[1]=c[0]+(o.fullMessageLength[f]/4294967296>>>0),o.fullMessageLength[f]=o.fullMessageLength[f]>>>0,c[0]=c[1]/4294967296>>>0;return r.putBytes(u),Ls(a,n,r),(r.read>2048||r.length()===0)&&r.compact(),o},o.digest=function(){var u=he.util.createBuffer();u.putBytes(r.bytes());var l=o.fullMessageLength[o.fullMessageLength.length-1]+o.messageLengthSize,c=l&o.blockLength-1;u.putBytes(yn.substr(0,o.blockLength-c));for(var f,g,v=o.fullMessageLength[0]*8,y=0;y<o.fullMessageLength.length-1;++y)f=o.fullMessageLength[y+1]*8,g=f/4294967296>>>0,v+=g,u.putInt32(v>>>0),v=f>>>0;u.putInt32(v);for(var x=new Array(a.length),y=0;y<a.length;++y)x[y]=a[y].slice(0);Ls(x,n,u);var S=he.util.createBuffer(),I;e==="SHA-512"?I=x.length:e==="SHA-384"?I=x.length-2:I=x.length-4;for(var y=0;y<I;++y)S.putInt32(x[y][0]),(y!==I-1||e!=="SHA-512/224")&&S.putInt32(x[y][1]);return S},o};var yn=null,Ds=!1,vn=null,Jt=null;function lf(){yn="\x80",yn+=he.util.fillString("\0",128),vn=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],Jt={},Jt["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],Jt["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],Jt["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],Jt["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],Ds=!0}function Ls(e,t,a){for(var r,n,s,i,o,u,l,c,f,g,v,y,x,S,I,B,b,P,k,R,z,Y,ne,ie,ue,fe,qe,et,se,ye,K,qt,tr,ve,me,Ee=a.length();Ee>=128;){for(se=0;se<16;++se)t[se][0]=a.getInt32()>>>0,t[se][1]=a.getInt32()>>>0;for(;se<80;++se)qt=t[se-2],ye=qt[0],K=qt[1],r=((ye>>>19|K<<13)^(K>>>29|ye<<3)^ye>>>6)>>>0,n=((ye<<13|K>>>19)^(K<<3|ye>>>29)^(ye<<26|K>>>6))>>>0,ve=t[se-15],ye=ve[0],K=ve[1],s=((ye>>>1|K<<31)^(ye>>>8|K<<24)^ye>>>7)>>>0,i=((ye<<31|K>>>1)^(ye<<24|K>>>8)^(ye<<25|K>>>7))>>>0,tr=t[se-7],me=t[se-16],K=n+tr[1]+i+me[1],t[se][0]=r+tr[0]+s+me[0]+(K/4294967296>>>0)>>>0,t[se][1]=K>>>0;for(x=e[0][0],S=e[0][1],I=e[1][0],B=e[1][1],b=e[2][0],P=e[2][1],k=e[3][0],R=e[3][1],z=e[4][0],Y=e[4][1],ne=e[5][0],ie=e[5][1],ue=e[6][0],fe=e[6][1],qe=e[7][0],et=e[7][1],se=0;se<80;++se)l=((z>>>14|Y<<18)^(z>>>18|Y<<14)^(Y>>>9|z<<23))>>>0,c=((z<<18|Y>>>14)^(z<<14|Y>>>18)^(Y<<23|z>>>9))>>>0,f=(ue^z&(ne^ue))>>>0,g=(fe^Y&(ie^fe))>>>0,o=((x>>>28|S<<4)^(S>>>2|x<<30)^(S>>>7|x<<25))>>>0,u=((x<<4|S>>>28)^(S<<30|x>>>2)^(S<<25|x>>>7))>>>0,v=(x&I|b&(x^I))>>>0,y=(S&B|P&(S^B))>>>0,K=et+c+g+vn[se][1]+t[se][1],r=qe+l+f+vn[se][0]+t[se][0]+(K/4294967296>>>0)>>>0,n=K>>>0,K=u+y,s=o+v+(K/4294967296>>>0)>>>0,i=K>>>0,qe=ue,et=fe,ue=ne,fe=ie,ne=z,ie=Y,K=R+n,z=k+r+(K/4294967296>>>0)>>>0,Y=K>>>0,k=b,R=P,b=I,P=B,I=x,B=S,K=n+i,x=r+s+(K/4294967296>>>0)>>>0,S=K>>>0;K=e[0][1]+S,e[0][0]=e[0][0]+x+(K/4294967296>>>0)>>>0,e[0][1]=K>>>0,K=e[1][1]+B,e[1][0]=e[1][0]+I+(K/4294967296>>>0)>>>0,e[1][1]=K>>>0,K=e[2][1]+P,e[2][0]=e[2][0]+b+(K/4294967296>>>0)>>>0,e[2][1]=K>>>0,K=e[3][1]+R,e[3][0]=e[3][0]+k+(K/4294967296>>>0)>>>0,e[3][1]=K>>>0,K=e[4][1]+Y,e[4][0]=e[4][0]+z+(K/4294967296>>>0)>>>0,e[4][1]=K>>>0,K=e[5][1]+ie,e[5][0]=e[5][0]+ne+(K/4294967296>>>0)>>>0,e[5][1]=K>>>0,K=e[6][1]+fe,e[6][0]=e[6][0]+ue+(K/4294967296>>>0)>>>0,e[6][1]=K>>>0,K=e[7][1]+et,e[7][0]=e[7][0]+qe+(K/4294967296>>>0)>>>0,e[7][1]=K>>>0,Ee-=128}}});var Ps=F(Cn=>{var cf=$();lt();var Ie=cf.asn1;Cn.privateKeyValidator={name:"PrivateKeyInfo",tagClass:Ie.Class.UNIVERSAL,type:Ie.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:Ie.Class.UNIVERSAL,type:Ie.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:Ie.Class.UNIVERSAL,type:Ie.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:Ie.Class.UNIVERSAL,type:Ie.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:Ie.Class.UNIVERSAL,type:Ie.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]};Cn.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:Ie.Class.UNIVERSAL,type:Ie.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:Ie.Class.UNIVERSAL,type:Ie.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:Ie.Class.UNIVERSAL,type:Ie.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{tagClass:Ie.Class.UNIVERSAL,type:Ie.Type.BITSTRING,constructed:!1,composed:!0,captureBitStringValue:"ed25519PublicKey"}]}});var js=F((tp,Ys)=>{var be=$();wr();tt();mn();re();var qs=Ps(),ff=qs.publicKeyValidator,df=qs.privateKeyValidator;typeof Os>"u"&&(Os=be.jsbn.BigInteger);var Os,xn=be.util.ByteBuffer,Ye=typeof Buffer>"u"?Uint8Array:Buffer;be.pki=be.pki||{};Ys.exports=be.pki.ed25519=be.ed25519=be.ed25519||{};var X=be.ed25519;X.constants={};X.constants.PUBLIC_KEY_BYTE_LENGTH=32;X.constants.PRIVATE_KEY_BYTE_LENGTH=64;X.constants.SEED_BYTE_LENGTH=32;X.constants.SIGN_BYTE_LENGTH=64;X.constants.HASH_BYTE_LENGTH=64;X.generateKeyPair=function(e){e=e||{};var t=e.seed;if(t===void 0)t=be.random.getBytesSync(X.constants.SEED_BYTE_LENGTH);else if(typeof t=="string"){if(t.length!==X.constants.SEED_BYTE_LENGTH)throw new TypeError('"seed" must be '+X.constants.SEED_BYTE_LENGTH+" bytes in length.")}else if(!(t instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, Uint8Array, or a binary string.');t=At({message:t,encoding:"binary"});for(var a=new Ye(X.constants.PUBLIC_KEY_BYTE_LENGTH),r=new Ye(X.constants.PRIVATE_KEY_BYTE_LENGTH),n=0;n<32;++n)r[n]=t[n];return yf(a,r),{publicKey:a,privateKey:r}};X.privateKeyFromAsn1=function(e){var t={},a=[],r=be.asn1.validate(e,df,t,a);if(!r){var n=new Error("Invalid Key.");throw n.errors=a,n}var s=be.asn1.derToOid(t.privateKeyOid),i=be.oids.EdDSA25519;if(s!==i)throw new Error('Invalid OID "'+s+'"; OID must be "'+i+'".');var o=t.privateKey,u=At({message:be.asn1.fromDer(o).value,encoding:"binary"});return{privateKeyBytes:u}};X.publicKeyFromAsn1=function(e){var t={},a=[],r=be.asn1.validate(e,ff,t,a);if(!r){var n=new Error("Invalid Key.");throw n.errors=a,n}var s=be.asn1.derToOid(t.publicKeyOid),i=be.oids.EdDSA25519;if(s!==i)throw new Error('Invalid OID "'+s+'"; OID must be "'+i+'".');var o=t.ed25519PublicKey;if(o.length!==X.constants.PUBLIC_KEY_BYTE_LENGTH)throw new Error("Key length is invalid.");return At({message:o,encoding:"binary"})};X.publicKeyFromPrivateKey=function(e){e=e||{};var t=At({message:e.privateKey,encoding:"binary"});if(t.length!==X.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+X.constants.PRIVATE_KEY_BYTE_LENGTH);for(var a=new Ye(X.constants.PUBLIC_KEY_BYTE_LENGTH),r=0;r<a.length;++r)a[r]=t[32+r];return a};X.sign=function(e){e=e||{};var t=At(e),a=At({message:e.privateKey,encoding:"binary"});if(a.length===X.constants.SEED_BYTE_LENGTH){var r=X.generateKeyPair({seed:a});a=r.privateKey}else if(a.length!==X.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+X.constants.SEED_BYTE_LENGTH+" or "+X.constants.PRIVATE_KEY_BYTE_LENGTH);var n=new Ye(X.constants.SIGN_BYTE_LENGTH+t.length);vf(n,t,t.length,a);for(var s=new Ye(X.constants.SIGN_BYTE_LENGTH),i=0;i<s.length;++i)s[i]=n[i];return s};X.verify=function(e){e=e||{};var t=At(e);if(e.signature===void 0)throw new TypeError('"options.signature" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a binary string.');var a=At({message:e.signature,encoding:"binary"});if(a.length!==X.constants.SIGN_BYTE_LENGTH)throw new TypeError('"options.signature" must have a byte length of '+X.constants.SIGN_BYTE_LENGTH);var r=At({message:e.publicKey,encoding:"binary"});if(r.length!==X.constants.PUBLIC_KEY_BYTE_LENGTH)throw new TypeError('"options.publicKey" must have a byte length of '+X.constants.PUBLIC_KEY_BYTE_LENGTH);var n=new Ye(X.constants.SIGN_BYTE_LENGTH+t.length),s=new Ye(X.constants.SIGN_BYTE_LENGTH+t.length),i;for(i=0;i<X.constants.SIGN_BYTE_LENGTH;++i)n[i]=a[i];for(i=0;i<t.length;++i)n[i+X.constants.SIGN_BYTE_LENGTH]=t[i];return mf(s,n,n.length,r)>=0};function At(e){var t=e.message;if(t instanceof Uint8Array||t instanceof Ye)return t;var a=e.encoding;if(t===void 0)if(e.md)t=e.md.digest().getBytes(),a="binary";else throw new TypeError('"options.message" or "options.md" not specified.');if(typeof t=="string"&&!a)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if(typeof t=="string"){if(typeof Buffer<"u")return Buffer.from(t,a);t=new xn(t,a)}else if(!(t instanceof xn))throw new TypeError('"options.message" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with "options.encoding" specifying its encoding.');for(var r=new Ye(t.length()),n=0;n<r.length;++n)r[n]=t.at(n);return r}var Sn=H(),Ca=H([1]),hf=H([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),pf=H([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),Vs=H([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),Fs=H([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),Dr=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]),gf=H([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function Ur(e,t){var a=be.md.sha512.create(),r=new xn(e);a.update(r.getBytes(t),"binary");var n=a.digest().getBytes();if(typeof Buffer<"u")return Buffer.from(n,"binary");for(var s=new Ye(X.constants.HASH_BYTE_LENGTH),i=0;i<64;++i)s[i]=n.charCodeAt(i);return s}function yf(e,t){var a=[H(),H(),H(),H()],r,n=Ur(t,32);for(n[0]&=248,n[31]&=127,n[31]|=64,Bn(a,n),An(e,a),r=0;r<32;++r)t[r+32]=e[r];return 0}function vf(e,t,a,r){var n,s,i=new Float64Array(64),o=[H(),H(),H(),H()],u=Ur(r,32);u[0]&=248,u[31]&=127,u[31]|=64;var l=a+64;for(n=0;n<a;++n)e[64+n]=t[n];for(n=0;n<32;++n)e[32+n]=u[32+n];var c=Ur(e.subarray(32),a+32);for(Tn(c),Bn(o,c),An(e,o),n=32;n<64;++n)e[n]=r[n];var f=Ur(e,a+64);for(Tn(f),n=32;n<64;++n)i[n]=0;for(n=0;n<32;++n)i[n]=c[n];for(n=0;n<32;++n)for(s=0;s<32;s++)i[n+s]+=f[n]*u[s];return Hs(e.subarray(32),i),l}function mf(e,t,a,r){var n,s,i=new Ye(32),o=[H(),H(),H(),H()],u=[H(),H(),H(),H()];if(s=-1,a<64||Ef(u,r)||!Cf(t,32))return-1;for(n=0;n<a;++n)e[n]=t[n];for(n=0;n<32;++n)e[n+32]=r[n];var l=Ur(e,a);if(Tn(l),Qs(o,u,l),Bn(u,t.subarray(32)),In(o,u),An(i,o),a-=64,Gs(t,0,i,0)){for(n=0;n<a;++n)e[n]=0;return-1}for(n=0;n<a;++n)e[n]=t[n+64];return s=a,s}function Cf(e,t){var a;for(a=31;a>=0;--a){if(e[t+a]<Dr[a])return!0;if(e[t+a]>Dr[a])return!1}return!1}function Hs(e,t){var a,r,n,s;for(r=63;r>=32;--r){for(a=0,n=r-32,s=r-12;n<s;++n)t[n]+=a-16*t[r]*Dr[n-(r-32)],a=t[n]+128>>8,t[n]-=a*256;t[n]+=a,t[r]=0}for(a=0,n=0;n<32;++n)t[n]+=a-(t[31]>>4)*Dr[n],a=t[n]>>8,t[n]&=255;for(n=0;n<32;++n)t[n]-=a*Dr[n];for(r=0;r<32;++r)t[r+1]+=t[r]>>8,e[r]=t[r]&255}function Tn(e){for(var t=new Float64Array(64),a=0;a<64;++a)t[a]=e[a],e[a]=0;Hs(e,t)}function In(e,t){var a=H(),r=H(),n=H(),s=H(),i=H(),o=H(),u=H(),l=H(),c=H();gr(a,e[1],e[0]),gr(c,t[1],t[0]),oe(a,a,c),pr(r,e[0],e[1]),pr(c,t[0],t[1]),oe(r,r,c),oe(n,e[3],t[3]),oe(n,n,pf),oe(s,e[2],t[2]),pr(s,s,s),gr(i,r,a),gr(o,s,n),pr(u,s,n),pr(l,r,a),oe(e[0],i,o),oe(e[1],l,u),oe(e[2],u,o),oe(e[3],i,l)}function Ks(e,t,a){for(var r=0;r<4;++r)$s(e[r],t[r],a)}function An(e,t){var a=H(),r=H(),n=H();If(n,t[2]),oe(a,t[0],n),oe(r,t[1],n),Ea(e,r),e[31]^=zs(a)<<7}function Ea(e,t){var a,r,n,s=H(),i=H();for(a=0;a<16;++a)i[a]=t[a];for(En(i),En(i),En(i),r=0;r<2;++r){for(s[0]=i[0]-65517,a=1;a<15;++a)s[a]=i[a]-65535-(s[a-1]>>16&1),s[a-1]&=65535;s[15]=i[15]-32767-(s[14]>>16&1),n=s[15]>>16&1,s[14]&=65535,$s(i,s,1-n)}for(a=0;a<16;a++)e[2*a]=i[a]&255,e[2*a+1]=i[a]>>8}function Ef(e,t){var a=H(),r=H(),n=H(),s=H(),i=H(),o=H(),u=H();return Ft(e[2],Ca),xf(e[1],t),Zt(n,e[1]),oe(s,n,hf),gr(n,n,e[2]),pr(s,e[2],s),Zt(i,s),Zt(o,i),oe(u,o,i),oe(a,u,n),oe(a,a,s),Sf(a,a),oe(a,a,n),oe(a,a,s),oe(a,a,s),oe(e[0],a,s),Zt(r,e[0]),oe(r,r,s),Ms(r,n)&&oe(e[0],e[0],gf),Zt(r,e[0]),oe(r,r,s),Ms(r,n)?-1:(zs(e[0])===t[31]>>7&&gr(e[0],Sn,e[0]),oe(e[3],e[0],e[1]),0)}function xf(e,t){var a;for(a=0;a<16;++a)e[a]=t[2*a]+(t[2*a+1]<<8);e[15]&=32767}function Sf(e,t){var a=H(),r;for(r=0;r<16;++r)a[r]=t[r];for(r=250;r>=0;--r)Zt(a,a),r!==1&&oe(a,a,t);for(r=0;r<16;++r)e[r]=a[r]}function Ms(e,t){var a=new Ye(32),r=new Ye(32);return Ea(a,e),Ea(r,t),Gs(a,0,r,0)}function Gs(e,t,a,r){return Tf(e,t,a,r,32)}function Tf(e,t,a,r,n){var s,i=0;for(s=0;s<n;++s)i|=e[t+s]^a[r+s];return(1&i-1>>>8)-1}function zs(e){var t=new Ye(32);return Ea(t,e),t[0]&1}function Qs(e,t,a){var r,n;for(Ft(e[0],Sn),Ft(e[1],Ca),Ft(e[2],Ca),Ft(e[3],Sn),n=255;n>=0;--n)r=a[n/8|0]>>(n&7)&1,Ks(e,t,r),In(t,e),In(e,e),Ks(e,t,r)}function Bn(e,t){var a=[H(),H(),H(),H()];Ft(a[0],Vs),Ft(a[1],Fs),Ft(a[2],Ca),oe(a[3],Vs,Fs),Qs(e,a,t)}function Ft(e,t){var a;for(a=0;a<16;a++)e[a]=t[a]|0}function If(e,t){var a=H(),r;for(r=0;r<16;++r)a[r]=t[r];for(r=253;r>=0;--r)Zt(a,a),r!==2&&r!==4&&oe(a,a,t);for(r=0;r<16;++r)e[r]=a[r]}function En(e){var t,a,r=1;for(t=0;t<16;++t)a=e[t]+r+65535,r=Math.floor(a/65536),e[t]=a-r*65536;e[0]+=r-1+37*(r-1)}function $s(e,t,a){for(var r,n=~(a-1),s=0;s<16;++s)r=n&(e[s]^t[s]),e[s]^=r,t[s]^=r}function H(e){var t,a=new Float64Array(16);if(e)for(t=0;t<e.length;++t)a[t]=e[t];return a}function pr(e,t,a){for(var r=0;r<16;++r)e[r]=t[r]+a[r]}function gr(e,t,a){for(var r=0;r<16;++r)e[r]=t[r]-a[r]}function Zt(e,t){oe(e,t,t)}function oe(e,t,a){var r,n,s=0,i=0,o=0,u=0,l=0,c=0,f=0,g=0,v=0,y=0,x=0,S=0,I=0,B=0,b=0,P=0,k=0,R=0,z=0,Y=0,ne=0,ie=0,ue=0,fe=0,qe=0,et=0,se=0,ye=0,K=0,qt=0,tr=0,ve=a[0],me=a[1],Ee=a[2],we=a[3],Ne=a[4],Re=a[5],Le=a[6],ke=a[7],De=a[8],Ue=a[9],Pe=a[10],Oe=a[11],Ve=a[12],Fe=a[13],Ke=a[14],Me=a[15];r=t[0],s+=r*ve,i+=r*me,o+=r*Ee,u+=r*we,l+=r*Ne,c+=r*Re,f+=r*Le,g+=r*ke,v+=r*De,y+=r*Ue,x+=r*Pe,S+=r*Oe,I+=r*Ve,B+=r*Fe,b+=r*Ke,P+=r*Me,r=t[1],i+=r*ve,o+=r*me,u+=r*Ee,l+=r*we,c+=r*Ne,f+=r*Re,g+=r*Le,v+=r*ke,y+=r*De,x+=r*Ue,S+=r*Pe,I+=r*Oe,B+=r*Ve,b+=r*Fe,P+=r*Ke,k+=r*Me,r=t[2],o+=r*ve,u+=r*me,l+=r*Ee,c+=r*we,f+=r*Ne,g+=r*Re,v+=r*Le,y+=r*ke,x+=r*De,S+=r*Ue,I+=r*Pe,B+=r*Oe,b+=r*Ve,P+=r*Fe,k+=r*Ke,R+=r*Me,r=t[3],u+=r*ve,l+=r*me,c+=r*Ee,f+=r*we,g+=r*Ne,v+=r*Re,y+=r*Le,x+=r*ke,S+=r*De,I+=r*Ue,B+=r*Pe,b+=r*Oe,P+=r*Ve,k+=r*Fe,R+=r*Ke,z+=r*Me,r=t[4],l+=r*ve,c+=r*me,f+=r*Ee,g+=r*we,v+=r*Ne,y+=r*Re,x+=r*Le,S+=r*ke,I+=r*De,B+=r*Ue,b+=r*Pe,P+=r*Oe,k+=r*Ve,R+=r*Fe,z+=r*Ke,Y+=r*Me,r=t[5],c+=r*ve,f+=r*me,g+=r*Ee,v+=r*we,y+=r*Ne,x+=r*Re,S+=r*Le,I+=r*ke,B+=r*De,b+=r*Ue,P+=r*Pe,k+=r*Oe,R+=r*Ve,z+=r*Fe,Y+=r*Ke,ne+=r*Me,r=t[6],f+=r*ve,g+=r*me,v+=r*Ee,y+=r*we,x+=r*Ne,S+=r*Re,I+=r*Le,B+=r*ke,b+=r*De,P+=r*Ue,k+=r*Pe,R+=r*Oe,z+=r*Ve,Y+=r*Fe,ne+=r*Ke,ie+=r*Me,r=t[7],g+=r*ve,v+=r*me,y+=r*Ee,x+=r*we,S+=r*Ne,I+=r*Re,B+=r*Le,b+=r*ke,P+=r*De,k+=r*Ue,R+=r*Pe,z+=r*Oe,Y+=r*Ve,ne+=r*Fe,ie+=r*Ke,ue+=r*Me,r=t[8],v+=r*ve,y+=r*me,x+=r*Ee,S+=r*we,I+=r*Ne,B+=r*Re,b+=r*Le,P+=r*ke,k+=r*De,R+=r*Ue,z+=r*Pe,Y+=r*Oe,ne+=r*Ve,ie+=r*Fe,ue+=r*Ke,fe+=r*Me,r=t[9],y+=r*ve,x+=r*me,S+=r*Ee,I+=r*we,B+=r*Ne,b+=r*Re,P+=r*Le,k+=r*ke,R+=r*De,z+=r*Ue,Y+=r*Pe,ne+=r*Oe,ie+=r*Ve,ue+=r*Fe,fe+=r*Ke,qe+=r*Me,r=t[10],x+=r*ve,S+=r*me,I+=r*Ee,B+=r*we,b+=r*Ne,P+=r*Re,k+=r*Le,R+=r*ke,z+=r*De,Y+=r*Ue,ne+=r*Pe,ie+=r*Oe,ue+=r*Ve,fe+=r*Fe,qe+=r*Ke,et+=r*Me,r=t[11],S+=r*ve,I+=r*me,B+=r*Ee,b+=r*we,P+=r*Ne,k+=r*Re,R+=r*Le,z+=r*ke,Y+=r*De,ne+=r*Ue,ie+=r*Pe,ue+=r*Oe,fe+=r*Ve,qe+=r*Fe,et+=r*Ke,se+=r*Me,r=t[12],I+=r*ve,B+=r*me,b+=r*Ee,P+=r*we,k+=r*Ne,R+=r*Re,z+=r*Le,Y+=r*ke,ne+=r*De,ie+=r*Ue,ue+=r*Pe,fe+=r*Oe,qe+=r*Ve,et+=r*Fe,se+=r*Ke,ye+=r*Me,r=t[13],B+=r*ve,b+=r*me,P+=r*Ee,k+=r*we,R+=r*Ne,z+=r*Re,Y+=r*Le,ne+=r*ke,ie+=r*De,ue+=r*Ue,fe+=r*Pe,qe+=r*Oe,et+=r*Ve,se+=r*Fe,ye+=r*Ke,K+=r*Me,r=t[14],b+=r*ve,P+=r*me,k+=r*Ee,R+=r*we,z+=r*Ne,Y+=r*Re,ne+=r*Le,ie+=r*ke,ue+=r*De,fe+=r*Ue,qe+=r*Pe,et+=r*Oe,se+=r*Ve,ye+=r*Fe,K+=r*Ke,qt+=r*Me,r=t[15],P+=r*ve,k+=r*me,R+=r*Ee,z+=r*we,Y+=r*Ne,ne+=r*Re,ie+=r*Le,ue+=r*ke,fe+=r*De,qe+=r*Ue,et+=r*Pe,se+=r*Oe,ye+=r*Ve,K+=r*Fe,qt+=r*Ke,tr+=r*Me,s+=38*k,i+=38*R,o+=38*z,u+=38*Y,l+=38*ne,c+=38*ie,f+=38*ue,g+=38*fe,v+=38*qe,y+=38*et,x+=38*se,S+=38*ye,I+=38*K,B+=38*qt,b+=38*tr,n=1,r=s+n+65535,n=Math.floor(r/65536),s=r-n*65536,r=i+n+65535,n=Math.floor(r/65536),i=r-n*65536,r=o+n+65535,n=Math.floor(r/65536),o=r-n*65536,r=u+n+65535,n=Math.floor(r/65536),u=r-n*65536,r=l+n+65535,n=Math.floor(r/65536),l=r-n*65536,r=c+n+65535,n=Math.floor(r/65536),c=r-n*65536,r=f+n+65535,n=Math.floor(r/65536),f=r-n*65536,r=g+n+65535,n=Math.floor(r/65536),g=r-n*65536,r=v+n+65535,n=Math.floor(r/65536),v=r-n*65536,r=y+n+65535,n=Math.floor(r/65536),y=r-n*65536,r=x+n+65535,n=Math.floor(r/65536),x=r-n*65536,r=S+n+65535,n=Math.floor(r/65536),S=r-n*65536,r=I+n+65535,n=Math.floor(r/65536),I=r-n*65536,r=B+n+65535,n=Math.floor(r/65536),B=r-n*65536,r=b+n+65535,n=Math.floor(r/65536),b=r-n*65536,r=P+n+65535,n=Math.floor(r/65536),P=r-n*65536,s+=n-1+37*(n-1),n=1,r=s+n+65535,n=Math.floor(r/65536),s=r-n*65536,r=i+n+65535,n=Math.floor(r/65536),i=r-n*65536,r=o+n+65535,n=Math.floor(r/65536),o=r-n*65536,r=u+n+65535,n=Math.floor(r/65536),u=r-n*65536,r=l+n+65535,n=Math.floor(r/65536),l=r-n*65536,r=c+n+65535,n=Math.floor(r/65536),c=r-n*65536,r=f+n+65535,n=Math.floor(r/65536),f=r-n*65536,r=g+n+65535,n=Math.floor(r/65536),g=r-n*65536,r=v+n+65535,n=Math.floor(r/65536),v=r-n*65536,r=y+n+65535,n=Math.floor(r/65536),y=r-n*65536,r=x+n+65535,n=Math.floor(r/65536),x=r-n*65536,r=S+n+65535,n=Math.floor(r/65536),S=r-n*65536,r=I+n+65535,n=Math.floor(r/65536),I=r-n*65536,r=B+n+65535,n=Math.floor(r/65536),B=r-n*65536,r=b+n+65535,n=Math.floor(r/65536),b=r-n*65536,r=P+n+65535,n=Math.floor(r/65536),P=r-n*65536,s+=n-1+37*(n-1),e[0]=s,e[1]=i,e[2]=o,e[3]=u,e[4]=l,e[5]=c,e[6]=f,e[7]=g,e[8]=v,e[9]=y,e[10]=x,e[11]=S,e[12]=I,e[13]=B,e[14]=b,e[15]=P}});var Zs=F((rp,Js)=>{var We=$();re();tt();wr();Js.exports=We.kem=We.kem||{};var Ws=We.jsbn.BigInteger;We.kem.rsa={};We.kem.rsa.create=function(e,t){t=t||{};var a=t.prng||We.random,r={};return r.encrypt=function(n,s){var i=Math.ceil(n.n.bitLength()/8),o;do o=new Ws(We.util.bytesToHex(a.getBytesSync(i)),16).mod(n.n);while(o.compareTo(Ws.ONE)<=0);o=We.util.hexToBytes(o.toString(16));var u=i-o.length;u>0&&(o=We.util.fillString("\0",u)+o);var l=n.encrypt(o,"NONE"),c=e.generate(o,s);return{encapsulation:l,key:c}},r.decrypt=function(n,s,i){var o=n.decrypt(s,"NONE");return e.generate(o,i)},r};We.kem.kdf1=function(e,t){Xs(this,e,0,t||e.digestLength)};We.kem.kdf2=function(e,t){Xs(this,e,1,t||e.digestLength)};function Xs(e,t,a,r){e.generate=function(n,s){for(var i=new We.util.ByteBuffer,o=Math.ceil(s/r)+a,u=new We.util.ByteBuffer,l=a;l<o;++l){u.putInt32(l),t.start(),t.update(n+u.getBytes());var c=t.digest();i.putBytes(c.getBytes(r))}return i.truncate(i.length()-s),i.getBytes()}}});var ao=F((ap,ro)=>{var J=$();re();ro.exports=J.log=J.log||{};J.log.levels=["none","error","warning","info","debug","verbose","max"];var xa={},wn=[],Or=null;J.log.LEVEL_LOCKED=2;J.log.NO_LEVEL_CHECK=4;J.log.INTERPOLATE=8;for(Ct=0;Ct<J.log.levels.length;++Ct)bn=J.log.levels[Ct],xa[bn]={index:Ct,name:bn.toUpperCase()};var bn,Ct;J.log.logMessage=function(e){for(var t=xa[e.level].index,a=0;a<wn.length;++a){var r=wn[a];if(r.flags&J.log.NO_LEVEL_CHECK)r.f(e);else{var n=xa[r.level].index;t<=n&&r.f(r,e)}}};J.log.prepareStandard=function(e){"standard"in e||(e.standard=xa[e.level].name+" ["+e.category+"] "+e.message)};J.log.prepareFull=function(e){if(!("full"in e)){var t=[e.message];t=t.concat([]),e.full=J.util.format.apply(this,t)}};J.log.prepareStandardFull=function(e){"standardFull"in e||(J.log.prepareStandard(e),e.standardFull=e.standard)};for(_n=["error","warning","info","debug","verbose"],Ct=0;Ct<_n.length;++Ct)(function(t){J.log[t]=function(a,r){var n=Array.prototype.slice.call(arguments).slice(2),s={timestamp:new Date,level:t,category:a,message:r,arguments:n};J.log.logMessage(s)}})(_n[Ct]);var _n,Ct;J.log.makeLogger=function(e){var t={flags:0,f:e};return J.log.setLevel(t,"none"),t};J.log.setLevel=function(e,t){var a=!1;if(e&&!(e.flags&J.log.LEVEL_LOCKED))for(var r=0;r<J.log.levels.length;++r){var n=J.log.levels[r];if(t==n){e.level=t,a=!0;break}}return a};J.log.lock=function(e,t){typeof t>"u"||t?e.flags|=J.log.LEVEL_LOCKED:e.flags&=~J.log.LEVEL_LOCKED};J.log.addLogger=function(e){wn.push(e)};typeof console<"u"&&"log"in console?(console.error&&console.warn&&console.info&&console.debug?(eo={error:console.error,warning:console.warn,info:console.info,debug:console.debug,verbose:console.debug},Vr=function(e,t){J.log.prepareStandard(t);var a=eo[t.level],r=[t.standard];r=r.concat(t.arguments.slice()),a.apply(console,r)},yr=J.log.makeLogger(Vr)):(Vr=function(t,a){J.log.prepareStandardFull(a),console.log(a.standardFull)},yr=J.log.makeLogger(Vr)),J.log.setLevel(yr,"debug"),J.log.addLogger(yr),Or=yr):console={log:function(){}};var yr,eo,Vr;Or!==null&&typeof window<"u"&&window.location&&(Pr=new URL(window.location.href).searchParams,Pr.has("console.level")&&J.log.setLevel(Or,Pr.get("console.level").slice(-1)[0]),Pr.has("console.lock")&&(to=Pr.get("console.lock").slice(-1)[0],to=="true"&&J.log.lock(Or)));var Pr,to;J.log.consoleLogger=Or});var io=F((np,no)=>{no.exports=ft();ea();lr();qa();mn()});var uo=F((ip,oo)=>{var D=$();Rt();lt();br();Lt();Qt();rn();tt();re();pa();var C=D.asn1,Qe=oo.exports=D.pkcs7=D.pkcs7||{};Qe.messageFromPem=function(e){var t=D.pem.decode(e)[0];if(t.type!=="PKCS7"){var a=new Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');throw a.headerType=t.type,a}if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");var r=C.fromDer(t.body);return Qe.messageFromAsn1(r)};Qe.messageToPem=function(e,t){var a={type:"PKCS7",body:C.toDer(e.toAsn1()).getBytes()};return D.pem.encode(a,{maxline:t})};Qe.messageFromAsn1=function(e){var t={},a=[];if(!C.validate(e,Qe.asn1.contentInfoValidator,t,a)){var r=new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw r.errors=a,r}var n=C.derToOid(t.contentType),s;switch(n){case D.pki.oids.envelopedData:s=Qe.createEnvelopedData();break;case D.pki.oids.encryptedData:s=Qe.createEncryptedData();break;case D.pki.oids.signedData:s=Qe.createSignedData();break;default:throw new Error("Cannot read PKCS#7 message. ContentType with OID "+n+" is not (yet) supported.")}return s.fromAsn1(t.content.value[0]),s};Qe.createSignedData=function(){var e=null;return e={type:D.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(r){if(Rn(e,r,Qe.asn1.signedDataValidator),e.certificates=[],e.crls=[],e.digestAlgorithmIdentifiers=[],e.contentInfo=null,e.signerInfos=[],e.rawCapture.certificates)for(var n=e.rawCapture.certificates.value,s=0;s<n.length;++s)e.certificates.push(D.pki.certificateFromAsn1(n[s]))},toAsn1:function(){e.contentInfo||e.sign();for(var r=[],n=0;n<e.certificates.length;++n)r.push(D.pki.certificateToAsn1(e.certificates[n]));var s=[],i=C.create(C.Class.CONTEXT_SPECIFIC,0,!0,[C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.INTEGER,!1,C.integerToDer(e.version).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.SET,!0,e.digestAlgorithmIdentifiers),e.contentInfo])]);return r.length>0&&i.value[0].value.push(C.create(C.Class.CONTEXT_SPECIFIC,0,!0,r)),s.length>0&&i.value[0].value.push(C.create(C.Class.CONTEXT_SPECIFIC,1,!0,s)),i.value[0].value.push(C.create(C.Class.UNIVERSAL,C.Type.SET,!0,e.signerInfos)),C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.type).getBytes()),i])},addSigner:function(r){var n=r.issuer,s=r.serialNumber;if(r.certificate){var i=r.certificate;typeof i=="string"&&(i=D.pki.certificateFromPem(i)),n=i.issuer.attributes,s=i.serialNumber}var o=r.key;if(!o)throw new Error("Could not add PKCS#7 signer; no private key specified.");typeof o=="string"&&(o=D.pki.privateKeyFromPem(o));var u=r.digestAlgorithm||D.pki.oids.sha1;switch(u){case D.pki.oids.sha1:case D.pki.oids.sha256:case D.pki.oids.sha384:case D.pki.oids.sha512:case D.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+u)}var l=r.authenticatedAttributes||[];if(l.length>0){for(var c=!1,f=!1,g=0;g<l.length;++g){var v=l[g];if(!c&&v.type===D.pki.oids.contentType){if(c=!0,f)break;continue}if(!f&&v.type===D.pki.oids.messageDigest){if(f=!0,c)break;continue}}if(!c||!f)throw new Error("Invalid signer.authenticatedAttributes. If signer.authenticatedAttributes is specified, then it must contain at least two attributes, PKCS #9 content-type and PKCS #9 message-digest.")}e.signers.push({key:o,version:1,issuer:n,serialNumber:s,digestAlgorithm:u,signatureAlgorithm:D.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:l,unauthenticatedAttributes:[]})},sign:function(r){if(r=r||{},(typeof e.content!="object"||e.contentInfo===null)&&(e.contentInfo=C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(D.pki.oids.data).getBytes())]),"content"in e)){var n;e.content instanceof D.util.ByteBuffer?n=e.content.bytes():typeof e.content=="string"&&(n=D.util.encodeUtf8(e.content)),r.detached?e.detachedContent=C.create(C.Class.UNIVERSAL,C.Type.OCTETSTRING,!1,n):e.contentInfo.value.push(C.create(C.Class.CONTEXT_SPECIFIC,0,!0,[C.create(C.Class.UNIVERSAL,C.Type.OCTETSTRING,!1,n)]))}if(e.signers.length!==0){var s=t();a(s)}},verify:function(){throw new Error("PKCS#7 signature verification not yet implemented.")},addCertificate:function(r){typeof r=="string"&&(r=D.pki.certificateFromPem(r)),e.certificates.push(r)},addCertificateRevokationList:function(r){throw new Error("PKCS#7 CRL support not yet implemented.")}},e;function t(){for(var r={},n=0;n<e.signers.length;++n){var s=e.signers[n],i=s.digestAlgorithm;i in r||(r[i]=D.md[D.pki.oids[i]].create()),s.authenticatedAttributes.length===0?s.md=r[i]:s.md=D.md[D.pki.oids[i]].create()}e.digestAlgorithmIdentifiers=[];for(var i in r)e.digestAlgorithmIdentifiers.push(C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(i).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.NULL,!1,"")]));return r}function a(r){var n;if(e.detachedContent?n=e.detachedContent:(n=e.contentInfo.value[1],n=n.value[0]),!n)throw new Error("Could not sign PKCS#7 message; there is no content to sign.");var s=C.derToOid(e.contentInfo.value[0].value),i=C.toDer(n);i.getByte(),C.getBerValueLength(i),i=i.getBytes();for(var o in r)r[o].start().update(i);for(var u=new Date,l=0;l<e.signers.length;++l){var c=e.signers[l];if(c.authenticatedAttributes.length===0){if(s!==D.pki.oids.data)throw new Error("Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data.")}else{c.authenticatedAttributesAsn1=C.create(C.Class.CONTEXT_SPECIFIC,0,!0,[]);for(var f=C.create(C.Class.UNIVERSAL,C.Type.SET,!0,[]),g=0;g<c.authenticatedAttributes.length;++g){var v=c.authenticatedAttributes[g];v.type===D.pki.oids.messageDigest?v.value=r[c.digestAlgorithm].digest():v.type===D.pki.oids.signingTime&&(v.value||(v.value=u)),f.value.push(Nn(v)),c.authenticatedAttributesAsn1.value.push(Nn(v))}i=C.toDer(f).getBytes(),c.md.start().update(i)}c.signature=c.key.sign(c.md,"RSASSA-PKCS1-V1_5")}e.signerInfos=Nf(e.signers)}};Qe.createEncryptedData=function(){var e=null;return e={type:D.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:D.pki.oids["aes256-CBC"]},fromAsn1:function(t){Rn(e,t,Qe.asn1.encryptedDataValidator)},decrypt:function(t){t!==void 0&&(e.encryptedContent.key=t),so(e)}},e};Qe.createEnvelopedData=function(){var e=null;return e={type:D.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:D.pki.oids["aes256-CBC"]},fromAsn1:function(t){var a=Rn(e,t,Qe.asn1.envelopedDataValidator);e.recipients=bf(a.recipientInfos.value)},toAsn1:function(){return C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.type).getBytes()),C.create(C.Class.CONTEXT_SPECIFIC,0,!0,[C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.INTEGER,!1,C.integerToDer(e.version).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.SET,!0,_f(e.recipients)),C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,Rf(e.encryptedContent))])])])},findRecipient:function(t){for(var a=t.issuer.attributes,r=0;r<e.recipients.length;++r){var n=e.recipients[r],s=n.issuer;if(n.serialNumber===t.serialNumber&&s.length===a.length){for(var i=!0,o=0;o<a.length;++o)if(s[o].type!==a[o].type||s[o].value!==a[o].value){i=!1;break}if(i)return n}}return null},decrypt:function(t,a){if(e.encryptedContent.key===void 0&&t!==void 0&&a!==void 0)switch(t.encryptedContent.algorithm){case D.pki.oids.rsaEncryption:case D.pki.oids.desCBC:var r=a.decrypt(t.encryptedContent.content);e.encryptedContent.key=D.util.createBuffer(r);break;default:throw new Error("Unsupported asymmetric cipher, OID "+t.encryptedContent.algorithm)}so(e)},addRecipient:function(t){e.recipients.push({version:0,issuer:t.issuer.attributes,serialNumber:t.serialNumber,encryptedContent:{algorithm:D.pki.oids.rsaEncryption,key:t.publicKey}})},encrypt:function(t,a){if(e.encryptedContent.content===void 0){a=a||e.encryptedContent.algorithm,t=t||e.encryptedContent.key;var r,n,s;switch(a){case D.pki.oids["aes128-CBC"]:r=16,n=16,s=D.aes.createEncryptionCipher;break;case D.pki.oids["aes192-CBC"]:r=24,n=16,s=D.aes.createEncryptionCipher;break;case D.pki.oids["aes256-CBC"]:r=32,n=16,s=D.aes.createEncryptionCipher;break;case D.pki.oids["des-EDE3-CBC"]:r=24,n=8,s=D.des.createEncryptionCipher;break;default:throw new Error("Unsupported symmetric cipher, OID "+a)}if(t===void 0)t=D.util.createBuffer(D.random.getBytes(r));else if(t.length()!=r)throw new Error("Symmetric key has wrong length; got "+t.length()+" bytes, expected "+r+".");e.encryptedContent.algorithm=a,e.encryptedContent.key=t,e.encryptedContent.parameter=D.util.createBuffer(D.random.getBytes(n));var i=s(t);if(i.start(e.encryptedContent.parameter.copy()),i.update(e.content),!i.finish())throw new Error("Symmetric encryption failed.");e.encryptedContent.content=i.output}for(var o=0;o<e.recipients.length;++o){var u=e.recipients[o];if(u.encryptedContent.content===void 0)switch(u.encryptedContent.algorithm){case D.pki.oids.rsaEncryption:u.encryptedContent.content=u.encryptedContent.key.encrypt(e.encryptedContent.key.data);break;default:throw new Error("Unsupported asymmetric cipher, OID "+u.encryptedContent.algorithm)}}}},e};function Af(e){var t={},a=[];if(!C.validate(e,Qe.asn1.recipientInfoValidator,t,a)){var r=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw r.errors=a,r}return{version:t.version.charCodeAt(0),issuer:D.pki.RDNAttributesAsArray(t.issuer),serialNumber:D.util.createBuffer(t.serial).toHex(),encryptedContent:{algorithm:C.derToOid(t.encAlgorithm),parameter:t.encParameter?t.encParameter.value:void 0,content:t.encKey}}}function Bf(e){return C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.INTEGER,!1,C.integerToDer(e.version).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[D.pki.distinguishedNameToAsn1({attributes:e.issuer}),C.create(C.Class.UNIVERSAL,C.Type.INTEGER,!1,D.util.hexToBytes(e.serialNumber))]),C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.encryptedContent.algorithm).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.NULL,!1,"")]),C.create(C.Class.UNIVERSAL,C.Type.OCTETSTRING,!1,e.encryptedContent.content)])}function bf(e){for(var t=[],a=0;a<e.length;++a)t.push(Af(e[a]));return t}function _f(e){for(var t=[],a=0;a<e.length;++a)t.push(Bf(e[a]));return t}function wf(e){var t=C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.INTEGER,!1,C.integerToDer(e.version).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[D.pki.distinguishedNameToAsn1({attributes:e.issuer}),C.create(C.Class.UNIVERSAL,C.Type.INTEGER,!1,D.util.hexToBytes(e.serialNumber))]),C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.digestAlgorithm).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.NULL,!1,"")])]);if(e.authenticatedAttributesAsn1&&t.value.push(e.authenticatedAttributesAsn1),t.value.push(C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.signatureAlgorithm).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.NULL,!1,"")])),t.value.push(C.create(C.Class.UNIVERSAL,C.Type.OCTETSTRING,!1,e.signature)),e.unauthenticatedAttributes.length>0){for(var a=C.create(C.Class.CONTEXT_SPECIFIC,1,!0,[]),r=0;r<e.unauthenticatedAttributes.length;++r){var n=e.unauthenticatedAttributes[r];a.values.push(Nn(n))}t.value.push(a)}return t}function Nf(e){for(var t=[],a=0;a<e.length;++a)t.push(wf(e[a]));return t}function Nn(e){var t;if(e.type===D.pki.oids.contentType)t=C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.value).getBytes());else if(e.type===D.pki.oids.messageDigest)t=C.create(C.Class.UNIVERSAL,C.Type.OCTETSTRING,!1,e.value.bytes());else if(e.type===D.pki.oids.signingTime){var a=new Date("1950-01-01T00:00:00Z"),r=new Date("2050-01-01T00:00:00Z"),n=e.value;if(typeof n=="string"){var s=Date.parse(n);isNaN(s)?n.length===13?n=C.utcTimeToDate(n):n=C.generalizedTimeToDate(n):n=new Date(s)}n>=a&&n<r?t=C.create(C.Class.UNIVERSAL,C.Type.UTCTIME,!1,C.dateToUtcTime(n)):t=C.create(C.Class.UNIVERSAL,C.Type.GENERALIZEDTIME,!1,C.dateToGeneralizedTime(n))}return C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.type).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.SET,!0,[t])])}function Rf(e){return[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(D.pki.oids.data).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.algorithm).getBytes()),e.parameter?C.create(C.Class.UNIVERSAL,C.Type.OCTETSTRING,!1,e.parameter.getBytes()):void 0]),C.create(C.Class.CONTEXT_SPECIFIC,0,!0,[C.create(C.Class.UNIVERSAL,C.Type.OCTETSTRING,!1,e.content.getBytes())])]}function Rn(e,t,a){var r={},n=[];if(!C.validate(t,a,r,n)){var s=new Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");throw s.errors=s,s}var i=C.derToOid(r.contentType);if(i!==D.pki.oids.data)throw new Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(r.encryptedContent){var o="";if(D.util.isArray(r.encryptedContent))for(var u=0;u<r.encryptedContent.length;++u){if(r.encryptedContent[u].type!==C.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");o+=r.encryptedContent[u].value}else o=r.encryptedContent;e.encryptedContent={algorithm:C.derToOid(r.encAlgorithm),parameter:D.util.createBuffer(r.encParameter.value),content:D.util.createBuffer(o)}}if(r.content){var o="";if(D.util.isArray(r.content))for(var u=0;u<r.content.length;++u){if(r.content[u].type!==C.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");o+=r.content[u].value}else o=r.content;e.content=D.util.createBuffer(o)}return e.version=r.version.charCodeAt(0),e.rawCapture=r,r}function so(e){if(e.encryptedContent.key===void 0)throw new Error("Symmetric key not available.");if(e.content===void 0){var t;switch(e.encryptedContent.algorithm){case D.pki.oids["aes128-CBC"]:case D.pki.oids["aes192-CBC"]:case D.pki.oids["aes256-CBC"]:t=D.aes.createDecryptionCipher(e.encryptedContent.key);break;case D.pki.oids.desCBC:case D.pki.oids["des-EDE3-CBC"]:t=D.des.createDecryptionCipher(e.encryptedContent.key);break;default:throw new Error("Unsupported symmetric cipher, OID "+e.encryptedContent.algorithm)}if(t.start(e.encryptedContent.parameter),t.update(e.encryptedContent.content),!t.finish())throw new Error("Symmetric decryption failed.");e.content=t.output}}});var co=F((sp,lo)=>{var Ce=$();Rt();ir();ea();lr();re();var Ta=lo.exports=Ce.ssh=Ce.ssh||{};Ta.privateKeyToPutty=function(e,t,a){a=a||"",t=t||"";var r="ssh-rsa",n=t===""?"none":"aes256-cbc",s="PuTTY-User-Key-File-2: "+r+`\r
17
+ `+o+t.substr(i+1),s=n-i-1,i=-1,++n}else(t[n]===" "||t[n]===" "||t[n]===",")&&(i=n);return t}function n0(e){return e.replace(/^\s+/,"")}});var _r=F((Dh,Ai)=>{var pe=$();Yr();Pa();re();Ai.exports=pe.des=pe.des||{};pe.des.startEncrypting=function(e,t,a,r){var n=na({key:e,output:a,decrypt:!1,mode:r||(t===null?"ECB":"CBC")});return n.start(t),n};pe.des.createEncryptionCipher=function(e,t){return na({key:e,output:null,decrypt:!1,mode:t})};pe.des.startDecrypting=function(e,t,a,r){var n=na({key:e,output:a,decrypt:!0,mode:r||(t===null?"ECB":"CBC")});return n.start(t),n};pe.des.createDecryptionCipher=function(e,t){return na({key:e,output:null,decrypt:!0,mode:t})};pe.des.Algorithm=function(e,t){var a=this;a.name=e,a.mode=new t({blockSize:8,cipher:{encrypt:function(r,n){return Ii(a._keys,r,n,!1)},decrypt:function(r,n){return Ii(a._keys,r,n,!0)}}}),a._init=!1};pe.des.Algorithm.prototype.initialize=function(e){if(!this._init){var t=pe.util.createBuffer(e.key);if(this.name.indexOf("3DES")===0&&t.length()!==24)throw new Error("Invalid Triple-DES key size: "+t.length()*8);this._keys=h0(t),this._init=!0}};ht("DES-ECB",pe.cipher.modes.ecb);ht("DES-CBC",pe.cipher.modes.cbc);ht("DES-CFB",pe.cipher.modes.cfb);ht("DES-OFB",pe.cipher.modes.ofb);ht("DES-CTR",pe.cipher.modes.ctr);ht("3DES-ECB",pe.cipher.modes.ecb);ht("3DES-CBC",pe.cipher.modes.cbc);ht("3DES-CFB",pe.cipher.modes.cfb);ht("3DES-OFB",pe.cipher.modes.ofb);ht("3DES-CTR",pe.cipher.modes.ctr);function ht(e,t){var a=function(){return new pe.des.Algorithm(e,t)};pe.cipher.registerAlgorithm(e,a)}var i0=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],s0=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],o0=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],u0=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],l0=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],c0=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],f0=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],d0=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function h0(e){for(var t=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],a=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],r=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],n=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],s=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],i=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],o=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],u=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],l=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],c=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],f=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],g=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],v=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],y=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],x=e.length()>8?3:1,S=[],T=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],B=0,b,P=0;P<x;P++){var k=e.getInt32(),R=e.getInt32();b=(k>>>4^R)&252645135,R^=b,k^=b<<4,b=(R>>>-16^k)&65535,k^=b,R^=b<<-16,b=(k>>>2^R)&858993459,R^=b,k^=b<<2,b=(R>>>-16^k)&65535,k^=b,R^=b<<-16,b=(k>>>1^R)&1431655765,R^=b,k^=b<<1,b=(R>>>8^k)&16711935,k^=b,R^=b<<8,b=(k>>>1^R)&1431655765,R^=b,k^=b<<1,b=k<<8|R>>>20&240,k=R<<24|R<<8&16711680|R>>>8&65280|R>>>24&240,R=b;for(var z=0;z<T.length;++z){T[z]?(k=k<<2|k>>>26,R=R<<2|R>>>26):(k=k<<1|k>>>27,R=R<<1|R>>>27),k&=-15,R&=-15;var Y=t[k>>>28]|a[k>>>24&15]|r[k>>>20&15]|n[k>>>16&15]|s[k>>>12&15]|i[k>>>8&15]|o[k>>>4&15],ne=u[R>>>28]|l[R>>>24&15]|c[R>>>20&15]|f[R>>>16&15]|g[R>>>12&15]|v[R>>>8&15]|y[R>>>4&15];b=(ne>>>16^Y)&65535,S[B++]=Y^b,S[B++]=ne^b<<16}}return S}function Ii(e,t,a,r){var n=e.length===32?3:9,s;n===3?s=r?[30,-2,-2]:[0,32,2]:s=r?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var i,o=t[0],u=t[1];i=(o>>>4^u)&252645135,u^=i,o^=i<<4,i=(o>>>16^u)&65535,u^=i,o^=i<<16,i=(u>>>2^o)&858993459,o^=i,u^=i<<2,i=(u>>>8^o)&16711935,o^=i,u^=i<<8,i=(o>>>1^u)&1431655765,u^=i,o^=i<<1,o=o<<1|o>>>31,u=u<<1|u>>>31;for(var l=0;l<n;l+=3){for(var c=s[l+1],f=s[l+2],g=s[l];g!=c;g+=f){var v=u^e[g],y=(u>>>4|u<<28)^e[g+1];i=o,o=u,u=i^(s0[v>>>24&63]|u0[v>>>16&63]|c0[v>>>8&63]|d0[v&63]|i0[y>>>24&63]|o0[y>>>16&63]|l0[y>>>8&63]|f0[y&63])}i=o,o=u,u=i}o=o>>>1|o<<31,u=u>>>1|u<<31,i=(o>>>1^u)&1431655765,u^=i,o^=i<<1,i=(u>>>8^o)&16711935,o^=i,u^=i<<8,i=(u>>>2^o)&858993459,o^=i,u^=i<<2,i=(o>>>16^u)&65535,u^=i,o^=i<<16,i=(o>>>4^u)&252645135,u^=i,o^=i<<4,a[0]=o,a[1]=u}function na(e){e=e||{};var t=(e.mode||"CBC").toUpperCase(),a="DES-"+t,r;e.decrypt?r=pe.cipher.createDecipher(a,e.key):r=pe.cipher.createCipher(a,e.key);var n=r.start;return r.start=function(s,i){var o=null;i instanceof pe.util.ByteBuffer&&(o=i,i={}),i=i||{},i.output=o,i.iv=s,n.call(r,i)},r}});var ia=F((Uh,Bi)=>{var Ge=$();or();ft();re();var p0=Ge.pkcs5=Ge.pkcs5||{},Tt;Ge.util.isNodejs&&!Ge.options.usePureJavaScript&&(Tt=require("crypto"));Bi.exports=Ge.pbkdf2=p0.pbkdf2=function(e,t,a,r,n,s){if(typeof n=="function"&&(s=n,n=null),Ge.util.isNodejs&&!Ge.options.usePureJavaScript&&Tt.pbkdf2&&(n===null||typeof n!="object")&&(Tt.pbkdf2Sync.length>4||!n||n==="sha1"))return typeof n!="string"&&(n="sha1"),e=Buffer.from(e,"binary"),t=Buffer.from(t,"binary"),s?Tt.pbkdf2Sync.length===4?Tt.pbkdf2(e,t,a,r,function(b,P){if(b)return s(b);s(null,P.toString("binary"))}):Tt.pbkdf2(e,t,a,r,n,function(b,P){if(b)return s(b);s(null,P.toString("binary"))}):Tt.pbkdf2Sync.length===4?Tt.pbkdf2Sync(e,t,a,r).toString("binary"):Tt.pbkdf2Sync(e,t,a,r,n).toString("binary");if((typeof n>"u"||n===null)&&(n="sha1"),typeof n=="string"){if(!(n in Ge.md.algorithms))throw new Error("Unknown hash algorithm: "+n);n=Ge.md[n].create()}var i=n.digestLength;if(r>4294967295*i){var o=new Error("Derived key is too long.");if(s)return s(o);throw o}var u=Math.ceil(r/i),l=r-(u-1)*i,c=Ge.hmac.create();c.start(n,e);var f="",g,v,y;if(!s){for(var x=1;x<=u;++x){c.start(null,null),c.update(t),c.update(Ge.util.int32ToBytes(x)),g=y=c.digest().getBytes();for(var S=2;S<=a;++S)c.start(null,null),c.update(y),v=c.digest().getBytes(),g=Ge.util.xorBytes(g,v,i),y=v;f+=x<u?g:g.substr(0,l)}return f}var x=1,S;function T(){if(x>u)return s(null,f);c.start(null,null),c.update(t),c.update(Ge.util.int32ToBytes(x)),g=y=c.digest().getBytes(),S=2,B()}function B(){if(S<=a)return c.start(null,null),c.update(y),v=c.digest().getBytes(),g=Ge.util.xorBytes(g,v,i),y=v,++S,Ge.util.setImmediate(B);f+=x<u?g:g.substr(0,l),++x,T()}T()}});var Ha=F((Ph,Ri)=>{var pt=$();ft();re();var _i=Ri.exports=pt.sha256=pt.sha256||{};pt.md.sha256=pt.md.algorithms.sha256=_i;_i.create=function(){wi||g0();var e=null,t=pt.util.createBuffer(),a=new Array(64),r={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8};return r.start=function(){r.messageLength=0,r.fullMessageLength=r.messageLength64=[];for(var n=r.messageLengthSize/4,s=0;s<n;++s)r.fullMessageLength.push(0);return t=pt.util.createBuffer(),e={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},r},r.start(),r.update=function(n,s){s==="utf8"&&(n=pt.util.encodeUtf8(n));var i=n.length;r.messageLength+=i,i=[i/4294967296>>>0,i>>>0];for(var o=r.fullMessageLength.length-1;o>=0;--o)r.fullMessageLength[o]+=i[1],i[1]=i[0]+(r.fullMessageLength[o]/4294967296>>>0),r.fullMessageLength[o]=r.fullMessageLength[o]>>>0,i[0]=i[1]/4294967296>>>0;return t.putBytes(n),bi(e,a,t),(t.read>2048||t.length()===0)&&t.compact(),r},r.digest=function(){var n=pt.util.createBuffer();n.putBytes(t.bytes());var s=r.fullMessageLength[r.fullMessageLength.length-1]+r.messageLengthSize,i=s&r.blockLength-1;n.putBytes(qa.substr(0,r.blockLength-i));for(var o,u,l=r.fullMessageLength[0]*8,c=0;c<r.fullMessageLength.length-1;++c)o=r.fullMessageLength[c+1]*8,u=o/4294967296>>>0,l+=u,n.putInt32(l>>>0),l=o>>>0;n.putInt32(l);var f={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};bi(f,a,n);var g=pt.util.createBuffer();return g.putInt32(f.h0),g.putInt32(f.h1),g.putInt32(f.h2),g.putInt32(f.h3),g.putInt32(f.h4),g.putInt32(f.h5),g.putInt32(f.h6),g.putInt32(f.h7),g},r};var qa=null,wi=!1,Ni=null;function g0(){qa="\x80",qa+=pt.util.fillString("\0",64),Ni=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],wi=!0}function bi(e,t,a){for(var r,n,s,i,o,u,l,c,f,g,v,y,x,S,T,B=a.length();B>=64;){for(l=0;l<16;++l)t[l]=a.getInt32();for(;l<64;++l)r=t[l-2],r=(r>>>17|r<<15)^(r>>>19|r<<13)^r>>>10,n=t[l-15],n=(n>>>7|n<<25)^(n>>>18|n<<14)^n>>>3,t[l]=r+t[l-7]+n+t[l-16]|0;for(c=e.h0,f=e.h1,g=e.h2,v=e.h3,y=e.h4,x=e.h5,S=e.h6,T=e.h7,l=0;l<64;++l)i=(y>>>6|y<<26)^(y>>>11|y<<21)^(y>>>25|y<<7),o=S^y&(x^S),s=(c>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10),u=c&f|g&(c^f),r=T+i+o+Ni[l]+t[l],n=s+u,T=S,S=x,x=y,y=v+r>>>0,v=g,g=f,f=c,c=r+n>>>0;e.h0=e.h0+c|0,e.h1=e.h1+f|0,e.h2=e.h2+g|0,e.h3=e.h3+v|0,e.h4=e.h4+y|0,e.h5=e.h5+x|0,e.h6=e.h6+S|0,e.h7=e.h7+T|0,B-=64}}});var Ga=F((Oh,Li)=>{var gt=$();re();var sa=null;gt.util.isNodejs&&!gt.options.usePureJavaScript&&!process.versions["node-webkit"]&&(sa=require("crypto"));var y0=Li.exports=gt.prng=gt.prng||{};y0.create=function(e){for(var t={plugin:e,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},a=e.md,r=new Array(32),n=0;n<32;++n)r[n]=a.create();t.pools=r,t.pool=0,t.generate=function(l,c){if(!c)return t.generateSync(l);var f=t.plugin.cipher,g=t.plugin.increment,v=t.plugin.formatKey,y=t.plugin.formatSeed,x=gt.util.createBuffer();t.key=null,S();function S(T){if(T)return c(T);if(x.length()>=l)return c(null,x.getBytes(l));if(t.generated>1048575&&(t.key=null),t.key===null)return gt.util.nextTick(function(){s(S)});var B=f(t.key,t.seed);t.generated+=B.length,x.putBytes(B),t.key=v(f(t.key,g(t.seed))),t.seed=y(f(t.key,t.seed)),gt.util.setImmediate(S)}},t.generateSync=function(l){var c=t.plugin.cipher,f=t.plugin.increment,g=t.plugin.formatKey,v=t.plugin.formatSeed;t.key=null;for(var y=gt.util.createBuffer();y.length()<l;){t.generated>1048575&&(t.key=null),t.key===null&&i();var x=c(t.key,t.seed);t.generated+=x.length,y.putBytes(x),t.key=g(c(t.key,f(t.seed))),t.seed=v(c(t.key,t.seed))}return y.getBytes(l)};function s(l){if(t.pools[0].messageLength>=32)return o(),l();var c=32-t.pools[0].messageLength<<5;t.seedFile(c,function(f,g){if(f)return l(f);t.collect(g),o(),l()})}function i(){if(t.pools[0].messageLength>=32)return o();var l=32-t.pools[0].messageLength<<5;t.collect(t.seedFileSync(l)),o()}function o(){t.reseeds=t.reseeds===4294967295?0:t.reseeds+1;var l=t.plugin.md.create();l.update(t.keyBytes);for(var c=1,f=0;f<32;++f)t.reseeds%c===0&&(l.update(t.pools[f].digest().getBytes()),t.pools[f].start()),c=c<<1;t.keyBytes=l.digest().getBytes(),l.start(),l.update(t.keyBytes);var g=l.digest().getBytes();t.key=t.plugin.formatKey(t.keyBytes),t.seed=t.plugin.formatSeed(g),t.generated=0}function u(l){var c=null,f=gt.util.globalScope,g=f.crypto||f.msCrypto;g&&g.getRandomValues&&(c=function(k){return g.getRandomValues(k)});var v=gt.util.createBuffer();if(c)for(;v.length()<l;){var y=Math.max(1,Math.min(l-v.length(),65536)/4),x=new Uint32Array(Math.floor(y));try{c(x);for(var S=0;S<x.length;++S)v.putInt32(x[S])}catch(k){if(!(typeof QuotaExceededError<"u"&&k instanceof QuotaExceededError))throw k}}if(v.length()<l)for(var T,B,b,P=Math.floor(Math.random()*65536);v.length()<l;){B=16807*(P&65535),T=16807*(P>>16),B+=(T&32767)<<16,B+=T>>15,B=(B&2147483647)+(B>>31),P=B&4294967295;for(var S=0;S<3;++S)b=P>>>(S<<3),b^=Math.floor(Math.random()*256),v.putByte(b&255)}return v.getBytes(l)}return sa?(t.seedFile=function(l,c){sa.randomBytes(l,function(f,g){if(f)return c(f);c(null,g.toString())})},t.seedFileSync=function(l){return sa.randomBytes(l).toString()}):(t.seedFile=function(l,c){try{c(null,u(l))}catch(f){c(f)}},t.seedFileSync=u),t.collect=function(l){for(var c=l.length,f=0;f<c;++f)t.pools[t.pool].update(l.substr(f,1)),t.pool=t.pool===31?0:t.pool+1},t.collectInt=function(l,c){for(var f="",g=0;g<c;g+=8)f+=String.fromCharCode(l>>g&255);t.collect(f)},t.registerWorker=function(l){if(l===self)t.seedFile=function(f,g){function v(y){var x=y.data;x.forge&&x.forge.prng&&(self.removeEventListener("message",v),g(x.forge.prng.err,x.forge.prng.bytes))}self.addEventListener("message",v),self.postMessage({forge:{prng:{needed:f}}})};else{var c=function(f){var g=f.data;g.forge&&g.forge.prng&&t.seedFile(g.forge.prng.needed,function(v,y){l.postMessage({forge:{prng:{err:v,bytes:y}}})})};l.addEventListener("message",c)}},t}});var tt=F((Vh,za)=>{var Te=$();Rt();Ha();Ga();re();(function(){if(Te.random&&Te.random.getBytes){za.exports=Te.random;return}(function(e){var t={},a=new Array(4),r=Te.util.createBuffer();t.formatKey=function(f){var g=Te.util.createBuffer(f);return f=new Array(4),f[0]=g.getInt32(),f[1]=g.getInt32(),f[2]=g.getInt32(),f[3]=g.getInt32(),Te.aes._expandKey(f,!1)},t.formatSeed=function(f){var g=Te.util.createBuffer(f);return f=new Array(4),f[0]=g.getInt32(),f[1]=g.getInt32(),f[2]=g.getInt32(),f[3]=g.getInt32(),f},t.cipher=function(f,g){return Te.aes._updateBlock(f,g,a,!1),r.putInt32(a[0]),r.putInt32(a[1]),r.putInt32(a[2]),r.putInt32(a[3]),r.getBytes()},t.increment=function(f){return++f[3],f},t.md=Te.md.sha256;function n(){var f=Te.prng.create(t);return f.getBytes=function(g,v){return f.generate(g,v)},f.getBytesSync=function(g){return f.generate(g)},f}var s=n(),i=null,o=Te.util.globalScope,u=o.crypto||o.msCrypto;if(u&&u.getRandomValues&&(i=function(f){return u.getRandomValues(f)}),Te.options.usePureJavaScript||!Te.util.isNodejs&&!i){if(typeof window>"u"||window.document,s.collectInt(+new Date,32),typeof navigator<"u"){var l="";for(var c in navigator)try{typeof navigator[c]=="string"&&(l+=navigator[c])}catch{}s.collect(l),l=null}e&&(e().mousemove(function(f){s.collectInt(f.clientX,16),s.collectInt(f.clientY,16)}),e().keypress(function(f){s.collectInt(f.charCode,8)}))}if(!Te.random)Te.random=s;else for(var c in s)Te.random[c]=s[c];Te.random.createInstance=n,za.exports=Te.random})(typeof jQuery<"u"?jQuery:null)})()});var $a=F((Fh,Ui)=>{var $e=$();re();var Qa=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],ki=[1,2,3,5],v0=function(e,t){return e<<t&65535|(e&65535)>>16-t},m0=function(e,t){return(e&65535)>>t|e<<16-t&65535};Ui.exports=$e.rc2=$e.rc2||{};$e.rc2.expandKey=function(e,t){typeof e=="string"&&(e=$e.util.createBuffer(e)),t=t||128;var a=e,r=e.length(),n=t,s=Math.ceil(n/8),i=255>>(n&7),o;for(o=r;o<128;o++)a.putByte(Qa[a.at(o-1)+a.at(o-r)&255]);for(a.setAt(128-s,Qa[a.at(128-s)&i]),o=127-s;o>=0;o--)a.setAt(o,Qa[a.at(o+1)^a.at(o+s)]);return a};var Di=function(e,t,a){var r=!1,n=null,s=null,i=null,o,u,l,c,f=[];for(e=$e.rc2.expandKey(e,t),l=0;l<64;l++)f.push(e.getInt16Le());a?(o=function(y){for(l=0;l<4;l++)y[l]+=f[c]+(y[(l+3)%4]&y[(l+2)%4])+(~y[(l+3)%4]&y[(l+1)%4]),y[l]=v0(y[l],ki[l]),c++},u=function(y){for(l=0;l<4;l++)y[l]+=f[y[(l+3)%4]&63]}):(o=function(y){for(l=3;l>=0;l--)y[l]=m0(y[l],ki[l]),y[l]-=f[c]+(y[(l+3)%4]&y[(l+2)%4])+(~y[(l+3)%4]&y[(l+1)%4]),c--},u=function(y){for(l=3;l>=0;l--)y[l]-=f[y[(l+3)%4]&63]});var g=function(y){var x=[];for(l=0;l<4;l++){var S=n.getInt16Le();i!==null&&(a?S^=i.getInt16Le():i.putInt16Le(S)),x.push(S&65535)}c=a?0:63;for(var T=0;T<y.length;T++)for(var B=0;B<y[T][0];B++)y[T][1](x);for(l=0;l<4;l++)i!==null&&(a?i.putInt16Le(x[l]):x[l]^=i.getInt16Le()),s.putInt16Le(x[l])},v=null;return v={start:function(y,x){y&&typeof y=="string"&&(y=$e.util.createBuffer(y)),r=!1,n=$e.util.createBuffer(),s=x||new $e.util.createBuffer,i=y,v.output=s},update:function(y){for(r||n.putBuffer(y);n.length()>=8;)g([[5,o],[1,u],[6,o],[1,u],[5,o]])},finish:function(y){var x=!0;if(a)if(y)x=y(8,n,!a);else{var S=n.length()===8?8:8-n.length();n.fillWithByte(S,S)}if(x&&(r=!0,v.update()),!a&&(x=n.length()===0,x))if(y)x=y(8,s,!a);else{var T=s.length(),B=s.at(T-1);B>T?x=!1:s.truncate(B)}return x}},v};$e.rc2.startEncrypting=function(e,t,a){var r=$e.rc2.createEncryptionCipher(e,128);return r.start(t,a),r};$e.rc2.createEncryptionCipher=function(e,t){return Di(e,t,!0)};$e.rc2.startDecrypting=function(e,t,a){var r=$e.rc2.createDecryptionCipher(e,128);return r.start(t,a),r};$e.rc2.createDecryptionCipher=function(e,t){return Di(e,t,!1)}});var Nr=F((Kh,Hi)=>{var Ya=$();Hi.exports=Ya.jsbn=Ya.jsbn||{};var It,C0=0xdeadbeefcafe,Pi=(C0&16777215)==15715070;function _(e,t,a){this.data=[],e!=null&&(typeof e=="number"?this.fromNumber(e,t,a):t==null&&typeof e!="string"?this.fromString(e,256):this.fromString(e,t))}Ya.jsbn.BigInteger=_;function Z(){return new _(null)}function E0(e,t,a,r,n,s){for(;--s>=0;){var i=t*this.data[e++]+a.data[r]+n;n=Math.floor(i/67108864),a.data[r++]=i&67108863}return n}function x0(e,t,a,r,n,s){for(var i=t&32767,o=t>>15;--s>=0;){var u=this.data[e]&32767,l=this.data[e++]>>15,c=o*u+l*i;u=i*u+((c&32767)<<15)+a.data[r]+(n&1073741823),n=(u>>>30)+(c>>>15)+o*l+(n>>>30),a.data[r++]=u&1073741823}return n}function Oi(e,t,a,r,n,s){for(var i=t&16383,o=t>>14;--s>=0;){var u=this.data[e]&16383,l=this.data[e++]>>14,c=o*u+l*i;u=i*u+((c&16383)<<14)+a.data[r]+n,n=(u>>28)+(c>>14)+o*l,a.data[r++]=u&268435455}return n}typeof navigator>"u"?(_.prototype.am=Oi,It=28):Pi&&navigator.appName=="Microsoft Internet Explorer"?(_.prototype.am=x0,It=30):Pi&&navigator.appName!="Netscape"?(_.prototype.am=E0,It=26):(_.prototype.am=Oi,It=28);_.prototype.DB=It;_.prototype.DM=(1<<It)-1;_.prototype.DV=1<<It;var ja=52;_.prototype.FV=Math.pow(2,ja);_.prototype.F1=ja-It;_.prototype.F2=2*It-ja;var S0="0123456789abcdefghijklmnopqrstuvwxyz",oa=new Array,lr,rt;lr=48;for(rt=0;rt<=9;++rt)oa[lr++]=rt;lr=97;for(rt=10;rt<36;++rt)oa[lr++]=rt;lr=65;for(rt=10;rt<36;++rt)oa[lr++]=rt;function Vi(e){return S0.charAt(e)}function Fi(e,t){var a=oa[e.charCodeAt(t)];return a??-1}function T0(e){for(var t=this.t-1;t>=0;--t)e.data[t]=this.data[t];e.t=this.t,e.s=this.s}function I0(e){this.t=1,this.s=e<0?-1:0,e>0?this.data[0]=e:e<-1?this.data[0]=e+this.DV:this.t=0}function kt(e){var t=Z();return t.fromInt(e),t}function A0(e,t){var a;if(t==16)a=4;else if(t==8)a=3;else if(t==256)a=8;else if(t==2)a=1;else if(t==32)a=5;else if(t==4)a=2;else{this.fromRadix(e,t);return}this.t=0,this.s=0;for(var r=e.length,n=!1,s=0;--r>=0;){var i=a==8?e[r]&255:Fi(e,r);if(i<0){e.charAt(r)=="-"&&(n=!0);continue}n=!1,s==0?this.data[this.t++]=i:s+a>this.DB?(this.data[this.t-1]|=(i&(1<<this.DB-s)-1)<<s,this.data[this.t++]=i>>this.DB-s):this.data[this.t-1]|=i<<s,s+=a,s>=this.DB&&(s-=this.DB)}a==8&&(e[0]&128)!=0&&(this.s=-1,s>0&&(this.data[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),n&&_.ZERO.subTo(this,this)}function B0(){for(var e=this.s&this.DM;this.t>0&&this.data[this.t-1]==e;)--this.t}function b0(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(e==16)t=4;else if(e==8)t=3;else if(e==2)t=1;else if(e==32)t=5;else if(e==4)t=2;else return this.toRadix(e);var a=(1<<t)-1,r,n=!1,s="",i=this.t,o=this.DB-i*this.DB%t;if(i-- >0)for(o<this.DB&&(r=this.data[i]>>o)>0&&(n=!0,s=Vi(r));i>=0;)o<t?(r=(this.data[i]&(1<<o)-1)<<t-o,r|=this.data[--i]>>(o+=this.DB-t)):(r=this.data[i]>>(o-=t)&a,o<=0&&(o+=this.DB,--i)),r>0&&(n=!0),n&&(s+=Vi(r));return n?s:"0"}function _0(){var e=Z();return _.ZERO.subTo(this,e),e}function w0(){return this.s<0?this.negate():this}function N0(e){var t=this.s-e.s;if(t!=0)return t;var a=this.t;if(t=a-e.t,t!=0)return this.s<0?-t:t;for(;--a>=0;)if((t=this.data[a]-e.data[a])!=0)return t;return 0}function ua(e){var t=1,a;return(a=e>>>16)!=0&&(e=a,t+=16),(a=e>>8)!=0&&(e=a,t+=8),(a=e>>4)!=0&&(e=a,t+=4),(a=e>>2)!=0&&(e=a,t+=2),(a=e>>1)!=0&&(e=a,t+=1),t}function R0(){return this.t<=0?0:this.DB*(this.t-1)+ua(this.data[this.t-1]^this.s&this.DM)}function L0(e,t){var a;for(a=this.t-1;a>=0;--a)t.data[a+e]=this.data[a];for(a=e-1;a>=0;--a)t.data[a]=0;t.t=this.t+e,t.s=this.s}function k0(e,t){for(var a=e;a<this.t;++a)t.data[a-e]=this.data[a];t.t=Math.max(this.t-e,0),t.s=this.s}function D0(e,t){var a=e%this.DB,r=this.DB-a,n=(1<<r)-1,s=Math.floor(e/this.DB),i=this.s<<a&this.DM,o;for(o=this.t-1;o>=0;--o)t.data[o+s+1]=this.data[o]>>r|i,i=(this.data[o]&n)<<a;for(o=s-1;o>=0;--o)t.data[o]=0;t.data[s]=i,t.t=this.t+s+1,t.s=this.s,t.clamp()}function U0(e,t){t.s=this.s;var a=Math.floor(e/this.DB);if(a>=this.t){t.t=0;return}var r=e%this.DB,n=this.DB-r,s=(1<<r)-1;t.data[0]=this.data[a]>>r;for(var i=a+1;i<this.t;++i)t.data[i-a-1]|=(this.data[i]&s)<<n,t.data[i-a]=this.data[i]>>r;r>0&&(t.data[this.t-a-1]|=(this.s&s)<<n),t.t=this.t-a,t.clamp()}function P0(e,t){for(var a=0,r=0,n=Math.min(e.t,this.t);a<n;)r+=this.data[a]-e.data[a],t.data[a++]=r&this.DM,r>>=this.DB;if(e.t<this.t){for(r-=e.s;a<this.t;)r+=this.data[a],t.data[a++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;a<e.t;)r-=e.data[a],t.data[a++]=r&this.DM,r>>=this.DB;r-=e.s}t.s=r<0?-1:0,r<-1?t.data[a++]=this.DV+r:r>0&&(t.data[a++]=r),t.t=a,t.clamp()}function O0(e,t){var a=this.abs(),r=e.abs(),n=a.t;for(t.t=n+r.t;--n>=0;)t.data[n]=0;for(n=0;n<r.t;++n)t.data[n+a.t]=a.am(0,r.data[n],t,n,0,a.t);t.s=0,t.clamp(),this.s!=e.s&&_.ZERO.subTo(t,t)}function V0(e){for(var t=this.abs(),a=e.t=2*t.t;--a>=0;)e.data[a]=0;for(a=0;a<t.t-1;++a){var r=t.am(a,t.data[a],e,2*a,0,1);(e.data[a+t.t]+=t.am(a+1,2*t.data[a],e,2*a+1,r,t.t-a-1))>=t.DV&&(e.data[a+t.t]-=t.DV,e.data[a+t.t+1]=1)}e.t>0&&(e.data[e.t-1]+=t.am(a,t.data[a],e,2*a,0,1)),e.s=0,e.clamp()}function F0(e,t,a){var r=e.abs();if(!(r.t<=0)){var n=this.abs();if(n.t<r.t){t?.fromInt(0),a!=null&&this.copyTo(a);return}a==null&&(a=Z());var s=Z(),i=this.s,o=e.s,u=this.DB-ua(r.data[r.t-1]);u>0?(r.lShiftTo(u,s),n.lShiftTo(u,a)):(r.copyTo(s),n.copyTo(a));var l=s.t,c=s.data[l-1];if(c!=0){var f=c*(1<<this.F1)+(l>1?s.data[l-2]>>this.F2:0),g=this.FV/f,v=(1<<this.F1)/f,y=1<<this.F2,x=a.t,S=x-l,T=t??Z();for(s.dlShiftTo(S,T),a.compareTo(T)>=0&&(a.data[a.t++]=1,a.subTo(T,a)),_.ONE.dlShiftTo(l,T),T.subTo(s,s);s.t<l;)s.data[s.t++]=0;for(;--S>=0;){var B=a.data[--x]==c?this.DM:Math.floor(a.data[x]*g+(a.data[x-1]+y)*v);if((a.data[x]+=s.am(0,B,a,S,0,l))<B)for(s.dlShiftTo(S,T),a.subTo(T,a);a.data[x]<--B;)a.subTo(T,a)}t!=null&&(a.drShiftTo(l,t),i!=o&&_.ZERO.subTo(t,t)),a.t=l,a.clamp(),u>0&&a.rShiftTo(u,a),i<0&&_.ZERO.subTo(a,a)}}}function K0(e){var t=Z();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(_.ZERO)>0&&e.subTo(t,t),t}function $t(e){this.m=e}function M0(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e}function q0(e){return e}function H0(e){e.divRemTo(this.m,null,e)}function G0(e,t,a){e.multiplyTo(t,a),this.reduce(a)}function z0(e,t){e.squareTo(t),this.reduce(t)}$t.prototype.convert=M0;$t.prototype.revert=q0;$t.prototype.reduce=H0;$t.prototype.mulTo=G0;$t.prototype.sqrTo=z0;function Q0(){if(this.t<1)return 0;var e=this.data[0];if((e&1)==0)return 0;var t=e&3;return t=t*(2-(e&15)*t)&15,t=t*(2-(e&255)*t)&255,t=t*(2-((e&65535)*t&65535))&65535,t=t*(2-e*t%this.DV)%this.DV,t>0?this.DV-t:-t}function Yt(e){this.m=e,this.mp=e.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function $0(e){var t=Z();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(_.ZERO)>0&&this.m.subTo(t,t),t}function Y0(e){var t=Z();return e.copyTo(t),this.reduce(t),t}function j0(e){for(;e.t<=this.mt2;)e.data[e.t++]=0;for(var t=0;t<this.m.t;++t){var a=e.data[t]&32767,r=a*this.mpl+((a*this.mph+(e.data[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(a=t+this.m.t,e.data[a]+=this.m.am(0,r,e,t,0,this.m.t);e.data[a]>=e.DV;)e.data[a]-=e.DV,e.data[++a]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)}function W0(e,t){e.squareTo(t),this.reduce(t)}function X0(e,t,a){e.multiplyTo(t,a),this.reduce(a)}Yt.prototype.convert=$0;Yt.prototype.revert=Y0;Yt.prototype.reduce=j0;Yt.prototype.mulTo=X0;Yt.prototype.sqrTo=W0;function J0(){return(this.t>0?this.data[0]&1:this.s)==0}function Z0(e,t){if(e>4294967295||e<1)return _.ONE;var a=Z(),r=Z(),n=t.convert(this),s=ua(e)-1;for(n.copyTo(a);--s>=0;)if(t.sqrTo(a,r),(e&1<<s)>0)t.mulTo(r,n,a);else{var i=a;a=r,r=i}return t.revert(a)}function el(e,t){var a;return e<256||t.isEven()?a=new $t(t):a=new Yt(t),this.exp(e,a)}_.prototype.copyTo=T0;_.prototype.fromInt=I0;_.prototype.fromString=A0;_.prototype.clamp=B0;_.prototype.dlShiftTo=L0;_.prototype.drShiftTo=k0;_.prototype.lShiftTo=D0;_.prototype.rShiftTo=U0;_.prototype.subTo=P0;_.prototype.multiplyTo=O0;_.prototype.squareTo=V0;_.prototype.divRemTo=F0;_.prototype.invDigit=Q0;_.prototype.isEven=J0;_.prototype.exp=Z0;_.prototype.toString=b0;_.prototype.negate=_0;_.prototype.abs=w0;_.prototype.compareTo=N0;_.prototype.bitLength=R0;_.prototype.mod=K0;_.prototype.modPowInt=el;_.ZERO=kt(0);_.ONE=kt(1);function tl(){var e=Z();return this.copyTo(e),e}function rl(){if(this.s<0){if(this.t==1)return this.data[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this.data[0];if(this.t==0)return 0}return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]}function al(){return this.t==0?this.s:this.data[0]<<24>>24}function nl(){return this.t==0?this.s:this.data[0]<<16>>16}function il(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}function sl(){return this.s<0?-1:this.t<=0||this.t==1&&this.data[0]<=0?0:1}function ol(e){if(e==null&&(e=10),this.signum()==0||e<2||e>36)return"0";var t=this.chunkSize(e),a=Math.pow(e,t),r=kt(a),n=Z(),s=Z(),i="";for(this.divRemTo(r,n,s);n.signum()>0;)i=(a+s.intValue()).toString(e).substr(1)+i,n.divRemTo(r,n,s);return s.intValue().toString(e)+i}function ul(e,t){this.fromInt(0),t==null&&(t=10);for(var a=this.chunkSize(t),r=Math.pow(t,a),n=!1,s=0,i=0,o=0;o<e.length;++o){var u=Fi(e,o);if(u<0){e.charAt(o)=="-"&&this.signum()==0&&(n=!0);continue}i=t*i+u,++s>=a&&(this.dMultiply(r),this.dAddOffset(i,0),s=0,i=0)}s>0&&(this.dMultiply(Math.pow(t,s)),this.dAddOffset(i,0)),n&&_.ZERO.subTo(this,this)}function ll(e,t,a){if(typeof t=="number")if(e<2)this.fromInt(1);else for(this.fromNumber(e,a),this.testBit(e-1)||this.bitwiseTo(_.ONE.shiftLeft(e-1),Wa,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(_.ONE.shiftLeft(e-1),this);else{var r=new Array,n=e&7;r.length=(e>>3)+1,t.nextBytes(r),n>0?r[0]&=(1<<n)-1:r[0]=0,this.fromString(r,256)}}function cl(){var e=this.t,t=new Array;t[0]=this.s;var a=this.DB-e*this.DB%8,r,n=0;if(e-- >0)for(a<this.DB&&(r=this.data[e]>>a)!=(this.s&this.DM)>>a&&(t[n++]=r|this.s<<this.DB-a);e>=0;)a<8?(r=(this.data[e]&(1<<a)-1)<<8-a,r|=this.data[--e]>>(a+=this.DB-8)):(r=this.data[e]>>(a-=8)&255,a<=0&&(a+=this.DB,--e)),(r&128)!=0&&(r|=-256),n==0&&(this.s&128)!=(r&128)&&++n,(n>0||r!=this.s)&&(t[n++]=r);return t}function fl(e){return this.compareTo(e)==0}function dl(e){return this.compareTo(e)<0?this:e}function hl(e){return this.compareTo(e)>0?this:e}function pl(e,t,a){var r,n,s=Math.min(e.t,this.t);for(r=0;r<s;++r)a.data[r]=t(this.data[r],e.data[r]);if(e.t<this.t){for(n=e.s&this.DM,r=s;r<this.t;++r)a.data[r]=t(this.data[r],n);a.t=this.t}else{for(n=this.s&this.DM,r=s;r<e.t;++r)a.data[r]=t(n,e.data[r]);a.t=e.t}a.s=t(this.s,e.s),a.clamp()}function gl(e,t){return e&t}function yl(e){var t=Z();return this.bitwiseTo(e,gl,t),t}function Wa(e,t){return e|t}function vl(e){var t=Z();return this.bitwiseTo(e,Wa,t),t}function Ki(e,t){return e^t}function ml(e){var t=Z();return this.bitwiseTo(e,Ki,t),t}function Mi(e,t){return e&~t}function Cl(e){var t=Z();return this.bitwiseTo(e,Mi,t),t}function El(){for(var e=Z(),t=0;t<this.t;++t)e.data[t]=this.DM&~this.data[t];return e.t=this.t,e.s=~this.s,e}function xl(e){var t=Z();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t}function Sl(e){var t=Z();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t}function Tl(e){if(e==0)return-1;var t=0;return(e&65535)==0&&(e>>=16,t+=16),(e&255)==0&&(e>>=8,t+=8),(e&15)==0&&(e>>=4,t+=4),(e&3)==0&&(e>>=2,t+=2),(e&1)==0&&++t,t}function Il(){for(var e=0;e<this.t;++e)if(this.data[e]!=0)return e*this.DB+Tl(this.data[e]);return this.s<0?this.t*this.DB:-1}function Al(e){for(var t=0;e!=0;)e&=e-1,++t;return t}function Bl(){for(var e=0,t=this.s&this.DM,a=0;a<this.t;++a)e+=Al(this.data[a]^t);return e}function bl(e){var t=Math.floor(e/this.DB);return t>=this.t?this.s!=0:(this.data[t]&1<<e%this.DB)!=0}function _l(e,t){var a=_.ONE.shiftLeft(e);return this.bitwiseTo(a,t,a),a}function wl(e){return this.changeBit(e,Wa)}function Nl(e){return this.changeBit(e,Mi)}function Rl(e){return this.changeBit(e,Ki)}function Ll(e,t){for(var a=0,r=0,n=Math.min(e.t,this.t);a<n;)r+=this.data[a]+e.data[a],t.data[a++]=r&this.DM,r>>=this.DB;if(e.t<this.t){for(r+=e.s;a<this.t;)r+=this.data[a],t.data[a++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;a<e.t;)r+=e.data[a],t.data[a++]=r&this.DM,r>>=this.DB;r+=e.s}t.s=r<0?-1:0,r>0?t.data[a++]=r:r<-1&&(t.data[a++]=this.DV+r),t.t=a,t.clamp()}function kl(e){var t=Z();return this.addTo(e,t),t}function Dl(e){var t=Z();return this.subTo(e,t),t}function Ul(e){var t=Z();return this.multiplyTo(e,t),t}function Pl(){var e=Z();return this.squareTo(e),e}function Ol(e){var t=Z();return this.divRemTo(e,t,null),t}function Vl(e){var t=Z();return this.divRemTo(e,null,t),t}function Fl(e){var t=Z(),a=Z();return this.divRemTo(e,t,a),new Array(t,a)}function Kl(e){this.data[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}function Ml(e,t){if(e!=0){for(;this.t<=t;)this.data[this.t++]=0;for(this.data[t]+=e;this.data[t]>=this.DV;)this.data[t]-=this.DV,++t>=this.t&&(this.data[this.t++]=0),++this.data[t]}}function wr(){}function qi(e){return e}function ql(e,t,a){e.multiplyTo(t,a)}function Hl(e,t){e.squareTo(t)}wr.prototype.convert=qi;wr.prototype.revert=qi;wr.prototype.mulTo=ql;wr.prototype.sqrTo=Hl;function Gl(e){return this.exp(e,new wr)}function zl(e,t,a){var r=Math.min(this.t+e.t,t);for(a.s=0,a.t=r;r>0;)a.data[--r]=0;var n;for(n=a.t-this.t;r<n;++r)a.data[r+this.t]=this.am(0,e.data[r],a,r,0,this.t);for(n=Math.min(e.t,t);r<n;++r)this.am(0,e.data[r],a,r,0,t-r);a.clamp()}function Ql(e,t,a){--t;var r=a.t=this.t+e.t-t;for(a.s=0;--r>=0;)a.data[r]=0;for(r=Math.max(t-this.t,0);r<e.t;++r)a.data[this.t+r-t]=this.am(t-r,e.data[r],a,0,0,this.t+r-t);a.clamp(),a.drShiftTo(1,a)}function cr(e){this.r2=Z(),this.q3=Z(),_.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}function $l(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 t=Z();return e.copyTo(t),this.reduce(t),t}function Yl(e){return e}function jl(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)}function Wl(e,t){e.squareTo(t),this.reduce(t)}function Xl(e,t,a){e.multiplyTo(t,a),this.reduce(a)}cr.prototype.convert=$l;cr.prototype.revert=Yl;cr.prototype.reduce=jl;cr.prototype.mulTo=Xl;cr.prototype.sqrTo=Wl;function Jl(e,t){var a=e.bitLength(),r,n=kt(1),s;if(a<=0)return n;a<18?r=1:a<48?r=3:a<144?r=4:a<768?r=5:r=6,a<8?s=new $t(t):t.isEven()?s=new cr(t):s=new Yt(t);var i=new Array,o=3,u=r-1,l=(1<<r)-1;if(i[1]=s.convert(this),r>1){var c=Z();for(s.sqrTo(i[1],c);o<=l;)i[o]=Z(),s.mulTo(c,i[o-2],i[o]),o+=2}var f=e.t-1,g,v=!0,y=Z(),x;for(a=ua(e.data[f])-1;f>=0;){for(a>=u?g=e.data[f]>>a-u&l:(g=(e.data[f]&(1<<a+1)-1)<<u-a,f>0&&(g|=e.data[f-1]>>this.DB+a-u)),o=r;(g&1)==0;)g>>=1,--o;if((a-=o)<0&&(a+=this.DB,--f),v)i[g].copyTo(n),v=!1;else{for(;o>1;)s.sqrTo(n,y),s.sqrTo(y,n),o-=2;o>0?s.sqrTo(n,y):(x=n,n=y,y=x),s.mulTo(y,i[g],n)}for(;f>=0&&(e.data[f]&1<<a)==0;)s.sqrTo(n,y),x=n,n=y,y=x,--a<0&&(a=this.DB-1,--f)}return s.revert(n)}function Zl(e){var t=this.s<0?this.negate():this.clone(),a=e.s<0?e.negate():e.clone();if(t.compareTo(a)<0){var r=t;t=a,a=r}var n=t.getLowestSetBit(),s=a.getLowestSetBit();if(s<0)return t;for(n<s&&(s=n),s>0&&(t.rShiftTo(s,t),a.rShiftTo(s,a));t.signum()>0;)(n=t.getLowestSetBit())>0&&t.rShiftTo(n,t),(n=a.getLowestSetBit())>0&&a.rShiftTo(n,a),t.compareTo(a)>=0?(t.subTo(a,t),t.rShiftTo(1,t)):(a.subTo(t,a),a.rShiftTo(1,a));return s>0&&a.lShiftTo(s,a),a}function ec(e){if(e<=0)return 0;var t=this.DV%e,a=this.s<0?e-1:0;if(this.t>0)if(t==0)a=this.data[0]%e;else for(var r=this.t-1;r>=0;--r)a=(t*a+this.data[r])%e;return a}function tc(e){if(this.signum()==0)return _.ZERO;var t=e.isEven();if(this.isEven()&&t||e.signum()==0)return _.ZERO;for(var a=e.clone(),r=this.clone(),n=kt(1),s=kt(0),i=kt(0),o=kt(1);a.signum()!=0;){for(;a.isEven();)a.rShiftTo(1,a),t?((!n.isEven()||!s.isEven())&&(n.addTo(this,n),s.subTo(e,s)),n.rShiftTo(1,n)):s.isEven()||s.subTo(e,s),s.rShiftTo(1,s);for(;r.isEven();)r.rShiftTo(1,r),t?((!i.isEven()||!o.isEven())&&(i.addTo(this,i),o.subTo(e,o)),i.rShiftTo(1,i)):o.isEven()||o.subTo(e,o),o.rShiftTo(1,o);a.compareTo(r)>=0?(a.subTo(r,a),t&&n.subTo(i,n),s.subTo(o,s)):(r.subTo(a,r),t&&i.subTo(n,i),o.subTo(s,o))}if(r.compareTo(_.ONE)!=0)return _.ZERO;if(o.compareTo(e)>=0)return o.subtract(e);if(o.signum()<0)o.addTo(e,o);else return o;return o.signum()<0?o.add(e):o}var ct=[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],rc=(1<<26)/ct[ct.length-1];function ac(e){var t,a=this.abs();if(a.t==1&&a.data[0]<=ct[ct.length-1]){for(t=0;t<ct.length;++t)if(a.data[0]==ct[t])return!0;return!1}if(a.isEven())return!1;for(t=1;t<ct.length;){for(var r=ct[t],n=t+1;n<ct.length&&r<rc;)r*=ct[n++];for(r=a.modInt(r);t<n;)if(r%ct[t++]==0)return!1}return a.millerRabin(e)}function nc(e){var t=this.subtract(_.ONE),a=t.getLowestSetBit();if(a<=0)return!1;for(var r=t.shiftRight(a),n=ic(),s,i=0;i<e;++i){do s=new _(this.bitLength(),n);while(s.compareTo(_.ONE)<=0||s.compareTo(t)>=0);var o=s.modPow(r,this);if(o.compareTo(_.ONE)!=0&&o.compareTo(t)!=0){for(var u=1;u++<a&&o.compareTo(t)!=0;)if(o=o.modPowInt(2,this),o.compareTo(_.ONE)==0)return!1;if(o.compareTo(t)!=0)return!1}}return!0}function ic(){return{nextBytes:function(e){for(var t=0;t<e.length;++t)e[t]=Math.floor(Math.random()*256)}}}_.prototype.chunkSize=il;_.prototype.toRadix=ol;_.prototype.fromRadix=ul;_.prototype.fromNumber=ll;_.prototype.bitwiseTo=pl;_.prototype.changeBit=_l;_.prototype.addTo=Ll;_.prototype.dMultiply=Kl;_.prototype.dAddOffset=Ml;_.prototype.multiplyLowerTo=zl;_.prototype.multiplyUpperTo=Ql;_.prototype.modInt=ec;_.prototype.millerRabin=nc;_.prototype.clone=tl;_.prototype.intValue=rl;_.prototype.byteValue=al;_.prototype.shortValue=nl;_.prototype.signum=sl;_.prototype.toByteArray=cl;_.prototype.equals=fl;_.prototype.min=dl;_.prototype.max=hl;_.prototype.and=yl;_.prototype.or=vl;_.prototype.xor=ml;_.prototype.andNot=Cl;_.prototype.not=El;_.prototype.shiftLeft=xl;_.prototype.shiftRight=Sl;_.prototype.getLowestSetBit=Il;_.prototype.bitCount=Bl;_.prototype.testBit=bl;_.prototype.setBit=wl;_.prototype.clearBit=Nl;_.prototype.flipBit=Rl;_.prototype.add=kl;_.prototype.subtract=Dl;_.prototype.multiply=Ul;_.prototype.divide=Ol;_.prototype.remainder=Vl;_.prototype.divideAndRemainder=Fl;_.prototype.modPow=Jl;_.prototype.modInverse=tc;_.prototype.pow=Gl;_.prototype.gcd=Zl;_.prototype.isProbablePrime=ac;_.prototype.square=Pl});var fr=F((Mh,$i)=>{var yt=$();ft();re();var zi=$i.exports=yt.sha1=yt.sha1||{};yt.md.sha1=yt.md.algorithms.sha1=zi;zi.create=function(){Qi||sc();var e=null,t=yt.util.createBuffer(),a=new Array(80),r={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8};return r.start=function(){r.messageLength=0,r.fullMessageLength=r.messageLength64=[];for(var n=r.messageLengthSize/4,s=0;s<n;++s)r.fullMessageLength.push(0);return t=yt.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},r},r.start(),r.update=function(n,s){s==="utf8"&&(n=yt.util.encodeUtf8(n));var i=n.length;r.messageLength+=i,i=[i/4294967296>>>0,i>>>0];for(var o=r.fullMessageLength.length-1;o>=0;--o)r.fullMessageLength[o]+=i[1],i[1]=i[0]+(r.fullMessageLength[o]/4294967296>>>0),r.fullMessageLength[o]=r.fullMessageLength[o]>>>0,i[0]=i[1]/4294967296>>>0;return t.putBytes(n),Gi(e,a,t),(t.read>2048||t.length()===0)&&t.compact(),r},r.digest=function(){var n=yt.util.createBuffer();n.putBytes(t.bytes());var s=r.fullMessageLength[r.fullMessageLength.length-1]+r.messageLengthSize,i=s&r.blockLength-1;n.putBytes(Xa.substr(0,r.blockLength-i));for(var o,u,l=r.fullMessageLength[0]*8,c=0;c<r.fullMessageLength.length-1;++c)o=r.fullMessageLength[c+1]*8,u=o/4294967296>>>0,l+=u,n.putInt32(l>>>0),l=o>>>0;n.putInt32(l);var f={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};Gi(f,a,n);var g=yt.util.createBuffer();return g.putInt32(f.h0),g.putInt32(f.h1),g.putInt32(f.h2),g.putInt32(f.h3),g.putInt32(f.h4),g},r};var Xa=null,Qi=!1;function sc(){Xa="\x80",Xa+=yt.util.fillString("\0",64),Qi=!0}function Gi(e,t,a){for(var r,n,s,i,o,u,l,c,f=a.length();f>=64;){for(n=e.h0,s=e.h1,i=e.h2,o=e.h3,u=e.h4,c=0;c<16;++c)r=a.getInt32(),t[c]=r,l=o^s&(i^o),r=(n<<5|n>>>27)+l+u+1518500249+r,u=o,o=i,i=(s<<30|s>>>2)>>>0,s=n,n=r;for(;c<20;++c)r=t[c-3]^t[c-8]^t[c-14]^t[c-16],r=r<<1|r>>>31,t[c]=r,l=o^s&(i^o),r=(n<<5|n>>>27)+l+u+1518500249+r,u=o,o=i,i=(s<<30|s>>>2)>>>0,s=n,n=r;for(;c<32;++c)r=t[c-3]^t[c-8]^t[c-14]^t[c-16],r=r<<1|r>>>31,t[c]=r,l=s^i^o,r=(n<<5|n>>>27)+l+u+1859775393+r,u=o,o=i,i=(s<<30|s>>>2)>>>0,s=n,n=r;for(;c<40;++c)r=t[c-6]^t[c-16]^t[c-28]^t[c-32],r=r<<2|r>>>30,t[c]=r,l=s^i^o,r=(n<<5|n>>>27)+l+u+1859775393+r,u=o,o=i,i=(s<<30|s>>>2)>>>0,s=n,n=r;for(;c<60;++c)r=t[c-6]^t[c-16]^t[c-28]^t[c-32],r=r<<2|r>>>30,t[c]=r,l=s&i|o&(s^i),r=(n<<5|n>>>27)+l+u+2400959708+r,u=o,o=i,i=(s<<30|s>>>2)>>>0,s=n,n=r;for(;c<80;++c)r=t[c-6]^t[c-16]^t[c-28]^t[c-32],r=r<<2|r>>>30,t[c]=r,l=s^i^o,r=(n<<5|n>>>27)+l+u+3395469782+r,u=o,o=i,i=(s<<30|s>>>2)>>>0,s=n,n=r;e.h0=e.h0+n|0,e.h1=e.h1+s|0,e.h2=e.h2+i|0,e.h3=e.h3+o|0,e.h4=e.h4+u|0,f-=64}}});var Ja=F((qh,ji)=>{var vt=$();re();tt();fr();var Yi=ji.exports=vt.pkcs1=vt.pkcs1||{};Yi.encode_rsa_oaep=function(e,t,a){var r,n,s,i;typeof a=="string"?(r=a,n=arguments[3]||void 0,s=arguments[4]||void 0):a&&(r=a.label||void 0,n=a.seed||void 0,s=a.md||void 0,a.mgf1&&a.mgf1.md&&(i=a.mgf1.md)),s?s.start():s=vt.md.sha1.create(),i||(i=s);var o=Math.ceil(e.n.bitLength()/8),u=o-2*s.digestLength-2;if(t.length>u){var l=new Error("RSAES-OAEP input message length is too long.");throw l.length=t.length,l.maxLength=u,l}r||(r=""),s.update(r,"raw");for(var c=s.digest(),f="",g=u-t.length,v=0;v<g;v++)f+="\0";var y=c.getBytes()+f+""+t;if(!n)n=vt.random.getBytes(s.digestLength);else if(n.length!==s.digestLength){var l=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.");throw l.seedLength=n.length,l.digestLength=s.digestLength,l}var x=la(n,o-s.digestLength-1,i),S=vt.util.xorBytes(y,x,y.length),T=la(S,s.digestLength,i),B=vt.util.xorBytes(n,T,n.length);return"\0"+B+S};Yi.decode_rsa_oaep=function(e,t,a){var r,n,s;typeof a=="string"?(r=a,n=arguments[3]||void 0):a&&(r=a.label||void 0,n=a.md||void 0,a.mgf1&&a.mgf1.md&&(s=a.mgf1.md));var i=Math.ceil(e.n.bitLength()/8);if(t.length!==i){var S=new Error("RSAES-OAEP encoded message length is invalid.");throw S.length=t.length,S.expectedLength=i,S}if(n===void 0?n=vt.md.sha1.create():n.start(),s||(s=n),i<2*n.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");r||(r=""),n.update(r,"raw");for(var o=n.digest().getBytes(),u=t.charAt(0),l=t.substring(1,n.digestLength+1),c=t.substring(1+n.digestLength),f=la(c,n.digestLength,s),g=vt.util.xorBytes(l,f,l.length),v=la(g,i-n.digestLength-1,s),y=vt.util.xorBytes(c,v,c.length),x=y.substring(0,n.digestLength),S=u!=="\0",T=0;T<n.digestLength;++T)S|=o.charAt(T)!==x.charAt(T);for(var B=1,b=n.digestLength,P=n.digestLength;P<y.length;P++){var k=y.charCodeAt(P),R=k&1^1,z=B?65534:0;S|=k&z,B=B&R,b+=B}if(S||y.charCodeAt(b)!==1)throw new Error("Invalid RSAES-OAEP padding.");return y.substring(b+1)};function la(e,t,a){a||(a=vt.md.sha1.create());for(var r="",n=Math.ceil(t/a.digestLength),s=0;s<n;++s){var i=String.fromCharCode(s>>24&255,s>>16&255,s>>8&255,s&255);a.start(),a.update(e+i),r+=a.digest().getBytes()}return r.substring(0,t)}});var en=F((Hh,Za)=>{var Dt=$();re();Nr();tt();(function(){if(Dt.prime){Za.exports=Dt.prime;return}var e=Za.exports=Dt.prime=Dt.prime||{},t=Dt.jsbn.BigInteger,a=[6,4,2,4,2,4,6,2],r=new t(null);r.fromInt(30);var n=function(f,g){return f|g};e.generateProbablePrime=function(f,g,v){typeof g=="function"&&(v=g,g={}),g=g||{};var y=g.algorithm||"PRIMEINC";typeof y=="string"&&(y={name:y}),y.options=y.options||{};var x=g.prng||Dt.random,S={nextBytes:function(T){for(var B=x.getBytesSync(T.length),b=0;b<T.length;++b)T[b]=B.charCodeAt(b)}};if(y.name==="PRIMEINC")return s(f,S,y.options,v);throw new Error("Invalid prime generation algorithm: "+y.name)};function s(f,g,v,y){return"workers"in v?u(f,g,v,y):i(f,g,v,y)}function i(f,g,v,y){var x=l(f,g),S=0,T=c(x.bitLength());"millerRabinTests"in v&&(T=v.millerRabinTests);var B=10;"maxBlockTime"in v&&(B=v.maxBlockTime),o(x,f,g,S,T,B,y)}function o(f,g,v,y,x,S,T){var B=+new Date;do{if(f.bitLength()>g&&(f=l(g,v)),f.isProbablePrime(x))return T(null,f);f.dAddOffset(a[y++%8],0)}while(S<0||+new Date-B<S);Dt.util.setImmediate(function(){o(f,g,v,y,x,S,T)})}function u(f,g,v,y){if(typeof Worker>"u")return i(f,g,v,y);var x=l(f,g),S=v.workers,T=v.workLoad||100,B=T*30/8,b=v.workerScript||"forge/prime.worker.js";if(S===-1)return Dt.util.estimateCores(function(k,R){k&&(R=2),S=R-1,P()});P();function P(){S=Math.max(1,S);for(var k=[],R=0;R<S;++R)k[R]=new Worker(b);for(var z=S,R=0;R<S;++R)k[R].addEventListener("message",ne);var Y=!1;function ne(ie){if(!Y){--z;var ue=ie.data;if(ue.found){for(var fe=0;fe<k.length;++fe)k[fe].terminate();return Y=!0,y(null,new t(ue.prime,16))}x.bitLength()>f&&(x=l(f,g));var qe=x.toString(16);ie.target.postMessage({hex:qe,workLoad:T}),x.dAddOffset(B,0)}}}}function l(f,g){var v=new t(f,g),y=f-1;return v.testBit(y)||v.bitwiseTo(t.ONE.shiftLeft(y),n,v),v.dAddOffset(31-v.mod(r).byteValue(),0),v}function c(f){return f<=100?27:f<=150?18:f<=200?15:f<=250?12:f<=300?9:f<=350?8:f<=400?7:f<=500?6:f<=600?5:f<=800?4:f<=1250?3:2}})()});var Rr=F((Gh,rs)=>{var M=$();lt();Nr();Lt();Ja();en();tt();re();typeof ee>"u"&&(ee=M.jsbn.BigInteger);var ee,tn=M.util.isNodejs?require("crypto"):null,I=M.asn1,at=M.util;M.pki=M.pki||{};rs.exports=M.pki.rsa=M.rsa=M.rsa||{};var G=M.pki,oc=[6,4,2,4,2,4,6,2],uc={name:"PrivateKeyInfo",tagClass:I.Class.UNIVERSAL,type:I.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:I.Class.UNIVERSAL,type:I.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:I.Class.UNIVERSAL,type:I.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:I.Class.UNIVERSAL,type:I.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:I.Class.UNIVERSAL,type:I.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},lc={name:"RSAPrivateKey",tagClass:I.Class.UNIVERSAL,type:I.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:I.Class.UNIVERSAL,type:I.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:I.Class.UNIVERSAL,type:I.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:I.Class.UNIVERSAL,type:I.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:I.Class.UNIVERSAL,type:I.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:I.Class.UNIVERSAL,type:I.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:I.Class.UNIVERSAL,type:I.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:I.Class.UNIVERSAL,type:I.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:I.Class.UNIVERSAL,type:I.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:I.Class.UNIVERSAL,type:I.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},cc={name:"RSAPublicKey",tagClass:I.Class.UNIVERSAL,type:I.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:I.Class.UNIVERSAL,type:I.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:I.Class.UNIVERSAL,type:I.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},fc=M.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:I.Class.UNIVERSAL,type:I.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:I.Class.UNIVERSAL,type:I.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:I.Class.UNIVERSAL,type:I.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:I.Class.UNIVERSAL,type:I.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:I.Class.UNIVERSAL,type:I.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},dc={name:"DigestInfo",tagClass:I.Class.UNIVERSAL,type:I.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:I.Class.UNIVERSAL,type:I.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:I.Class.UNIVERSAL,type:I.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:I.Class.UNIVERSAL,type:I.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:I.Class.UNIVERSAL,type:I.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},hc=function(e){var t;if(e.algorithm in G.oids)t=G.oids[e.algorithm];else{var a=new Error("Unknown message digest algorithm.");throw a.algorithm=e.algorithm,a}var r=I.oidToDer(t).getBytes(),n=I.create(I.Class.UNIVERSAL,I.Type.SEQUENCE,!0,[]),s=I.create(I.Class.UNIVERSAL,I.Type.SEQUENCE,!0,[]);s.value.push(I.create(I.Class.UNIVERSAL,I.Type.OID,!1,r)),s.value.push(I.create(I.Class.UNIVERSAL,I.Type.NULL,!1,""));var i=I.create(I.Class.UNIVERSAL,I.Type.OCTETSTRING,!1,e.digest().getBytes());return n.value.push(s),n.value.push(i),I.toDer(n).getBytes()},es=function(e,t,a){if(a)return e.modPow(t.e,t.n);if(!t.p||!t.q)return e.modPow(t.d,t.n);t.dP||(t.dP=t.d.mod(t.p.subtract(ee.ONE))),t.dQ||(t.dQ=t.d.mod(t.q.subtract(ee.ONE))),t.qInv||(t.qInv=t.q.modInverse(t.p));var r;do r=new ee(M.util.bytesToHex(M.random.getBytes(t.n.bitLength()/8)),16);while(r.compareTo(t.n)>=0||!r.gcd(t.n).equals(ee.ONE));e=e.multiply(r.modPow(t.e,t.n)).mod(t.n);for(var n=e.mod(t.p).modPow(t.dP,t.p),s=e.mod(t.q).modPow(t.dQ,t.q);n.compareTo(s)<0;)n=n.add(t.p);var i=n.subtract(s).multiply(t.qInv).mod(t.p).multiply(t.q).add(s);return i=i.multiply(r.modInverse(t.n)).mod(t.n),i};G.rsa.encrypt=function(e,t,a){var r=a,n,s=Math.ceil(t.n.bitLength()/8);a!==!1&&a!==!0?(r=a===2,n=ts(e,t,a)):(n=M.util.createBuffer(),n.putBytes(e));for(var i=new ee(n.toHex(),16),o=es(i,t,r),u=o.toString(16),l=M.util.createBuffer(),c=s-Math.ceil(u.length/2);c>0;)l.putByte(0),--c;return l.putBytes(M.util.hexToBytes(u)),l.getBytes()};G.rsa.decrypt=function(e,t,a,r){var n=Math.ceil(t.n.bitLength()/8);if(e.length!==n){var s=new Error("Encrypted message length is invalid.");throw s.length=e.length,s.expected=n,s}var i=new ee(M.util.createBuffer(e).toHex(),16);if(i.compareTo(t.n)>=0)throw new Error("Encrypted message is invalid.");for(var o=es(i,t,a),u=o.toString(16),l=M.util.createBuffer(),c=n-Math.ceil(u.length/2);c>0;)l.putByte(0),--c;return l.putBytes(M.util.hexToBytes(u)),r!==!1?ca(l.getBytes(),t,a):l.getBytes()};G.rsa.createKeyPairGenerationState=function(e,t,a){typeof e=="string"&&(e=parseInt(e,10)),e=e||2048,a=a||{};var r=a.prng||M.random,n={nextBytes:function(o){for(var u=r.getBytesSync(o.length),l=0;l<o.length;++l)o[l]=u.charCodeAt(l)}},s=a.algorithm||"PRIMEINC",i;if(s==="PRIMEINC")i={algorithm:s,state:0,bits:e,rng:n,eInt:t||65537,e:new ee(null),p:null,q:null,qBits:e>>1,pBits:e-(e>>1),pqState:0,num:null,keys:null},i.e.fromInt(i.eInt);else throw new Error("Invalid key generation algorithm: "+s);return i};G.rsa.stepKeyPairGenerationState=function(e,t){"algorithm"in e||(e.algorithm="PRIMEINC");var a=new ee(null);a.fromInt(30);for(var r=0,n=function(f,g){return f|g},s=+new Date,i,o=0;e.keys===null&&(t<=0||o<t);){if(e.state===0){var u=e.p===null?e.pBits:e.qBits,l=u-1;e.pqState===0?(e.num=new ee(u,e.rng),e.num.testBit(l)||e.num.bitwiseTo(ee.ONE.shiftLeft(l),n,e.num),e.num.dAddOffset(31-e.num.mod(a).byteValue(),0),r=0,++e.pqState):e.pqState===1?e.num.bitLength()>u?e.pqState=0:e.num.isProbablePrime(gc(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(oc[r++%8],0):e.pqState===2?e.pqState=e.num.subtract(ee.ONE).gcd(e.e).compareTo(ee.ONE)===0?3:0:e.pqState===3&&(e.pqState=0,e.p===null?e.p=e.num:e.q=e.num,e.p!==null&&e.q!==null&&++e.state,e.num=null)}else if(e.state===1)e.p.compareTo(e.q)<0&&(e.num=e.p,e.p=e.q,e.q=e.num),++e.state;else if(e.state===2)e.p1=e.p.subtract(ee.ONE),e.q1=e.q.subtract(ee.ONE),e.phi=e.p1.multiply(e.q1),++e.state;else if(e.state===3)e.phi.gcd(e.e).compareTo(ee.ONE)===0?++e.state:(e.p=null,e.q=null,e.state=0);else if(e.state===4)e.n=e.p.multiply(e.q),e.n.bitLength()===e.bits?++e.state:(e.q=null,e.state=0);else if(e.state===5){var c=e.e.modInverse(e.phi);e.keys={privateKey:G.rsa.setPrivateKey(e.n,e.e,c,e.p,e.q,c.mod(e.p1),c.mod(e.q1),e.q.modInverse(e.p)),publicKey:G.rsa.setPublicKey(e.n,e.e)}}i=+new Date,o+=i-s,s=i}return e.keys!==null};G.rsa.generateKeyPair=function(e,t,a,r){if(arguments.length===1?typeof e=="object"?(a=e,e=void 0):typeof e=="function"&&(r=e,e=void 0):arguments.length===2?typeof e=="number"?typeof t=="function"?(r=t,t=void 0):typeof t!="number"&&(a=t,t=void 0):(a=e,r=t,e=void 0,t=void 0):arguments.length===3&&(typeof t=="number"?typeof a=="function"&&(r=a,a=void 0):(r=a,a=t,t=void 0)),a=a||{},e===void 0&&(e=a.bits||2048),t===void 0&&(t=a.e||65537),!M.options.usePureJavaScript&&!a.prng&&e>=256&&e<=16384&&(t===65537||t===3)){if(r){if(Wi("generateKeyPair"))return tn.generateKeyPair("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(o,u,l){if(o)return r(o);r(null,{privateKey:G.privateKeyFromPem(l),publicKey:G.publicKeyFromPem(u)})});if(Xi("generateKey")&&Xi("exportKey"))return at.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:Zi(t),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(o){return at.globalScope.crypto.subtle.exportKey("pkcs8",o.privateKey)}).then(void 0,function(o){r(o)}).then(function(o){if(o){var u=G.privateKeyFromAsn1(I.fromDer(M.util.createBuffer(o)));r(null,{privateKey:u,publicKey:G.setRsaPublicKey(u.n,u.e)})}});if(Ji("generateKey")&&Ji("exportKey")){var n=at.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:Zi(t),hash:{name:"SHA-256"}},!0,["sign","verify"]);n.oncomplete=function(o){var u=o.target.result,l=at.globalScope.msCrypto.subtle.exportKey("pkcs8",u.privateKey);l.oncomplete=function(c){var f=c.target.result,g=G.privateKeyFromAsn1(I.fromDer(M.util.createBuffer(f)));r(null,{privateKey:g,publicKey:G.setRsaPublicKey(g.n,g.e)})},l.onerror=function(c){r(c)}},n.onerror=function(o){r(o)};return}}else if(Wi("generateKeyPairSync")){var s=tn.generateKeyPairSync("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:G.privateKeyFromPem(s.privateKey),publicKey:G.publicKeyFromPem(s.publicKey)}}}var i=G.rsa.createKeyPairGenerationState(e,t,a);if(!r)return G.rsa.stepKeyPairGenerationState(i,0),i.keys;pc(i,a,r)};G.setRsaPublicKey=G.rsa.setPublicKey=function(e,t){var a={n:e,e:t};return a.encrypt=function(r,n,s){if(typeof n=="string"?n=n.toUpperCase():n===void 0&&(n="RSAES-PKCS1-V1_5"),n==="RSAES-PKCS1-V1_5")n={encode:function(o,u,l){return ts(o,u,2).getBytes()}};else if(n==="RSA-OAEP"||n==="RSAES-OAEP")n={encode:function(o,u){return M.pkcs1.encode_rsa_oaep(u,o,s)}};else if(["RAW","NONE","NULL",null].indexOf(n)!==-1)n={encode:function(o){return o}};else if(typeof n=="string")throw new Error('Unsupported encryption scheme: "'+n+'".');var i=n.encode(r,a,!0);return G.rsa.encrypt(i,a,!0)},a.verify=function(r,n,s,i){typeof s=="string"?s=s.toUpperCase():s===void 0&&(s="RSASSA-PKCS1-V1_5"),i===void 0&&(i={_parseAllDigestBytes:!0,_skipPaddingChecks:!1}),"_parseAllDigestBytes"in i||(i._parseAllDigestBytes=!0),"_skipPaddingChecks"in i||(i._skipPaddingChecks=!1),s==="RSASSA-PKCS1-V1_5"?s={verify:function(u,l){l=ca(l,a,!0,void 0,i);var c=I.fromDer(l,{parseAllBytes:i._parseAllDigestBytes}),f={},g=[];if(!I.validate(c,dc,f,g)||c.value.length!==2){var v=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.");throw v.errors=g,v}var y=I.derToOid(f.algorithmIdentifier);if(!(y===M.oids.md2||y===M.oids.md5||y===M.oids.sha1||y===M.oids.sha224||y===M.oids.sha256||y===M.oids.sha384||y===M.oids.sha512||y===M.oids["sha512-224"]||y===M.oids["sha512-256"])){var v=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.");throw v.oid=y,v}if((y===M.oids.md2||y===M.oids.md5)&&!("parameters"in f))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifier NULL parameters.");return u===f.digest}}:(s==="NONE"||s==="NULL"||s===null)&&(s={verify:function(u,l){return l=ca(l,a,!0,void 0,i),u===l}});var o=G.rsa.decrypt(n,a,!0,!1);return s.verify(r,o,a.n.bitLength())},a};G.setRsaPrivateKey=G.rsa.setPrivateKey=function(e,t,a,r,n,s,i,o){var u={n:e,e:t,d:a,p:r,q:n,dP:s,dQ:i,qInv:o};return u.decrypt=function(l,c,f){typeof c=="string"?c=c.toUpperCase():c===void 0&&(c="RSAES-PKCS1-V1_5");var g=G.rsa.decrypt(l,u,!1,!1);if(c==="RSAES-PKCS1-V1_5")c={decode:ca};else if(c==="RSA-OAEP"||c==="RSAES-OAEP")c={decode:function(v,y){return M.pkcs1.decode_rsa_oaep(y,v,f)}};else if(["RAW","NONE","NULL",null].indexOf(c)!==-1)c={decode:function(v){return v}};else throw new Error('Unsupported encryption scheme: "'+c+'".');return c.decode(g,u,!1)},u.sign=function(l,c){var f=!1;typeof c=="string"&&(c=c.toUpperCase()),c===void 0||c==="RSASSA-PKCS1-V1_5"?(c={encode:hc},f=1):(c==="NONE"||c==="NULL"||c===null)&&(c={encode:function(){return l}},f=1);var g=c.encode(l,u.n.bitLength());return G.rsa.encrypt(g,u,f)},u};G.wrapRsaPrivateKey=function(e){return I.create(I.Class.UNIVERSAL,I.Type.SEQUENCE,!0,[I.create(I.Class.UNIVERSAL,I.Type.INTEGER,!1,I.integerToDer(0).getBytes()),I.create(I.Class.UNIVERSAL,I.Type.SEQUENCE,!0,[I.create(I.Class.UNIVERSAL,I.Type.OID,!1,I.oidToDer(G.oids.rsaEncryption).getBytes()),I.create(I.Class.UNIVERSAL,I.Type.NULL,!1,"")]),I.create(I.Class.UNIVERSAL,I.Type.OCTETSTRING,!1,I.toDer(e).getBytes())])};G.privateKeyFromAsn1=function(e){var t={},a=[];if(I.validate(e,uc,t,a)&&(e=I.fromDer(M.util.createBuffer(t.privateKey))),t={},a=[],!I.validate(e,lc,t,a)){var r=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw r.errors=a,r}var n,s,i,o,u,l,c,f;return n=M.util.createBuffer(t.privateKeyModulus).toHex(),s=M.util.createBuffer(t.privateKeyPublicExponent).toHex(),i=M.util.createBuffer(t.privateKeyPrivateExponent).toHex(),o=M.util.createBuffer(t.privateKeyPrime1).toHex(),u=M.util.createBuffer(t.privateKeyPrime2).toHex(),l=M.util.createBuffer(t.privateKeyExponent1).toHex(),c=M.util.createBuffer(t.privateKeyExponent2).toHex(),f=M.util.createBuffer(t.privateKeyCoefficient).toHex(),G.setRsaPrivateKey(new ee(n,16),new ee(s,16),new ee(i,16),new ee(o,16),new ee(u,16),new ee(l,16),new ee(c,16),new ee(f,16))};G.privateKeyToAsn1=G.privateKeyToRSAPrivateKey=function(e){return I.create(I.Class.UNIVERSAL,I.Type.SEQUENCE,!0,[I.create(I.Class.UNIVERSAL,I.Type.INTEGER,!1,I.integerToDer(0).getBytes()),I.create(I.Class.UNIVERSAL,I.Type.INTEGER,!1,mt(e.n)),I.create(I.Class.UNIVERSAL,I.Type.INTEGER,!1,mt(e.e)),I.create(I.Class.UNIVERSAL,I.Type.INTEGER,!1,mt(e.d)),I.create(I.Class.UNIVERSAL,I.Type.INTEGER,!1,mt(e.p)),I.create(I.Class.UNIVERSAL,I.Type.INTEGER,!1,mt(e.q)),I.create(I.Class.UNIVERSAL,I.Type.INTEGER,!1,mt(e.dP)),I.create(I.Class.UNIVERSAL,I.Type.INTEGER,!1,mt(e.dQ)),I.create(I.Class.UNIVERSAL,I.Type.INTEGER,!1,mt(e.qInv))])};G.publicKeyFromAsn1=function(e){var t={},a=[];if(I.validate(e,fc,t,a)){var r=I.derToOid(t.publicKeyOid);if(r!==G.oids.rsaEncryption){var n=new Error("Cannot read public key. Unknown OID.");throw n.oid=r,n}e=t.rsaPublicKey}if(a=[],!I.validate(e,cc,t,a)){var n=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.");throw n.errors=a,n}var s=M.util.createBuffer(t.publicKeyModulus).toHex(),i=M.util.createBuffer(t.publicKeyExponent).toHex();return G.setRsaPublicKey(new ee(s,16),new ee(i,16))};G.publicKeyToAsn1=G.publicKeyToSubjectPublicKeyInfo=function(e){return I.create(I.Class.UNIVERSAL,I.Type.SEQUENCE,!0,[I.create(I.Class.UNIVERSAL,I.Type.SEQUENCE,!0,[I.create(I.Class.UNIVERSAL,I.Type.OID,!1,I.oidToDer(G.oids.rsaEncryption).getBytes()),I.create(I.Class.UNIVERSAL,I.Type.NULL,!1,"")]),I.create(I.Class.UNIVERSAL,I.Type.BITSTRING,!1,[G.publicKeyToRSAPublicKey(e)])])};G.publicKeyToRSAPublicKey=function(e){return I.create(I.Class.UNIVERSAL,I.Type.SEQUENCE,!0,[I.create(I.Class.UNIVERSAL,I.Type.INTEGER,!1,mt(e.n)),I.create(I.Class.UNIVERSAL,I.Type.INTEGER,!1,mt(e.e))])};function ts(e,t,a){var r=M.util.createBuffer(),n=Math.ceil(t.n.bitLength()/8);if(e.length>n-11){var s=new Error("Message is too long for PKCS#1 v1.5 padding.");throw s.length=e.length,s.max=n-11,s}r.putByte(0),r.putByte(a);var i=n-3-e.length,o;if(a===0||a===1){o=a===0?0:255;for(var u=0;u<i;++u)r.putByte(o)}else for(;i>0;){for(var l=0,c=M.random.getBytes(i),u=0;u<i;++u)o=c.charCodeAt(u),o===0?++l:r.putByte(o);i=l}return r.putByte(0),r.putBytes(e),r}function ca(e,t,a,r,n){var s=Math.ceil(t.n.bitLength()/8),i=M.util.createBuffer(e),o=i.getByte(),u=i.getByte();if(o!==0||a&&u!==0&&u!==1||!a&&u!==2||a&&u===0&&typeof r>"u")throw new Error("Encryption block is invalid.");var l=0;if(u===0){l=s-3-r;for(var c=0;c<l;++c)if(i.getByte()!==0)throw new Error("Encryption block is invalid.")}else if(u===1){for(l=0;i.length()>1;){if(i.getByte()!==255){--i.read;break}++l}if(l<8&&!(n&&n._skipPaddingChecks))throw new Error("Encryption block is invalid.")}else if(u===2){for(l=0;i.length()>1;){if(i.getByte()===0){--i.read;break}++l}if(l<8&&!(n&&n._skipPaddingChecks))throw new Error("Encryption block is invalid.")}var f=i.getByte();if(f!==0||l!==s-3-i.length())throw new Error("Encryption block is invalid.");return i.getBytes()}function pc(e,t,a){typeof t=="function"&&(a=t,t={}),t=t||{};var r={algorithm:{name:t.algorithm||"PRIMEINC",options:{workers:t.workers||2,workLoad:t.workLoad||100,workerScript:t.workerScript}}};"prng"in t&&(r.prng=t.prng),n();function n(){s(e.pBits,function(o,u){if(o)return a(o);if(e.p=u,e.q!==null)return i(o,e.q);s(e.qBits,i)})}function s(o,u){M.prime.generateProbablePrime(o,r,u)}function i(o,u){if(o)return a(o);if(e.q=u,e.p.compareTo(e.q)<0){var l=e.p;e.p=e.q,e.q=l}if(e.p.subtract(ee.ONE).gcd(e.e).compareTo(ee.ONE)!==0){e.p=null,n();return}if(e.q.subtract(ee.ONE).gcd(e.e).compareTo(ee.ONE)!==0){e.q=null,s(e.qBits,i);return}if(e.p1=e.p.subtract(ee.ONE),e.q1=e.q.subtract(ee.ONE),e.phi=e.p1.multiply(e.q1),e.phi.gcd(e.e).compareTo(ee.ONE)!==0){e.p=e.q=null,n();return}if(e.n=e.p.multiply(e.q),e.n.bitLength()!==e.bits){e.q=null,s(e.qBits,i);return}var c=e.e.modInverse(e.phi);e.keys={privateKey:G.rsa.setPrivateKey(e.n,e.e,c,e.p,e.q,c.mod(e.p1),c.mod(e.q1),e.q.modInverse(e.p)),publicKey:G.rsa.setPublicKey(e.n,e.e)},a(null,e.keys)}}function mt(e){var t=e.toString(16);t[0]>="8"&&(t="00"+t);var a=M.util.hexToBytes(t);return a.length>1&&(a.charCodeAt(0)===0&&(a.charCodeAt(1)&128)===0||a.charCodeAt(0)===255&&(a.charCodeAt(1)&128)===128)?a.substr(1):a}function gc(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}function Wi(e){return M.util.isNodejs&&typeof tn[e]=="function"}function Xi(e){return typeof at.globalScope<"u"&&typeof at.globalScope.crypto=="object"&&typeof at.globalScope.crypto.subtle=="object"&&typeof at.globalScope.crypto.subtle[e]=="function"}function Ji(e){return typeof at.globalScope<"u"&&typeof at.globalScope.msCrypto=="object"&&typeof at.globalScope.msCrypto.subtle=="object"&&typeof at.globalScope.msCrypto.subtle[e]=="function"}function Zi(e){for(var t=M.util.hexToBytes(e.toString(16)),a=new Uint8Array(t.length),r=0;r<t.length;++r)a[r]=t.charCodeAt(r);return a}});var rn=F((zh,os)=>{var V=$();Rt();lt();_r();ft();Lt();ia();Qt();tt();$a();Rr();re();typeof as>"u"&&(as=V.jsbn.BigInteger);var as,A=V.asn1,Q=V.pki=V.pki||{};os.exports=Q.pbe=V.pbe=V.pbe||{};var jt=Q.oids,yc={name:"EncryptedPrivateKeyInfo",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:A.Class.UNIVERSAL,type:A.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:A.Class.UNIVERSAL,type:A.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},vc={name:"PBES2Algorithms",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:A.Class.UNIVERSAL,type:A.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:A.Class.UNIVERSAL,type:A.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:A.Class.UNIVERSAL,type:A.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:A.Class.UNIVERSAL,type:A.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:A.Class.UNIVERSAL,type:A.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:A.Class.UNIVERSAL,type:A.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:A.Class.UNIVERSAL,type:A.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},mc={name:"pkcs-12PbeParams",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:A.Class.UNIVERSAL,type:A.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:A.Class.UNIVERSAL,type:A.Type.INTEGER,constructed:!1,capture:"iterations"}]};Q.encryptPrivateKeyInfo=function(e,t,a){a=a||{},a.saltSize=a.saltSize||8,a.count=a.count||2048,a.algorithm=a.algorithm||"aes128",a.prfAlgorithm=a.prfAlgorithm||"sha1";var r=V.random.getBytesSync(a.saltSize),n=a.count,s=A.integerToDer(n),i,o,u;if(a.algorithm.indexOf("aes")===0||a.algorithm==="des"){var l,c,f;switch(a.algorithm){case"aes128":i=16,l=16,c=jt["aes128-CBC"],f=V.aes.createEncryptionCipher;break;case"aes192":i=24,l=16,c=jt["aes192-CBC"],f=V.aes.createEncryptionCipher;break;case"aes256":i=32,l=16,c=jt["aes256-CBC"],f=V.aes.createEncryptionCipher;break;case"des":i=8,l=8,c=jt.desCBC,f=V.des.createEncryptionCipher;break;default:var g=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw g.algorithm=a.algorithm,g}var v="hmacWith"+a.prfAlgorithm.toUpperCase(),y=ss(v),x=V.pkcs5.pbkdf2(t,r,n,i,y),S=V.random.getBytesSync(l),T=f(x);T.start(S),T.update(A.toDer(e)),T.finish(),u=T.output.getBytes();var B=Cc(r,s,i,v);o=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(jt.pkcs5PBES2).getBytes()),A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(jt.pkcs5PBKDF2).getBytes()),B]),A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(c).getBytes()),A.create(A.Class.UNIVERSAL,A.Type.OCTETSTRING,!1,S)])])])}else if(a.algorithm==="3des"){i=24;var b=new V.util.ByteBuffer(r),x=Q.pbe.generatePkcs12Key(t,b,1,n,i),S=Q.pbe.generatePkcs12Key(t,b,2,n,i),T=V.des.createEncryptionCipher(x);T.start(S),T.update(A.toDer(e)),T.finish(),u=T.output.getBytes(),o=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(jt["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OCTETSTRING,!1,r),A.create(A.Class.UNIVERSAL,A.Type.INTEGER,!1,s.getBytes())])])}else{var g=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw g.algorithm=a.algorithm,g}var P=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[o,A.create(A.Class.UNIVERSAL,A.Type.OCTETSTRING,!1,u)]);return P};Q.decryptPrivateKeyInfo=function(e,t){var a=null,r={},n=[];if(!A.validate(e,yc,r,n)){var s=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=n,s}var i=A.derToOid(r.encryptionOid),o=Q.pbe.getCipher(i,r.encryptionParams,t),u=V.util.createBuffer(r.encryptedData);return o.update(u),o.finish()&&(a=A.fromDer(o.output)),a};Q.encryptedPrivateKeyToPem=function(e,t){var a={type:"ENCRYPTED PRIVATE KEY",body:A.toDer(e).getBytes()};return V.pem.encode(a,{maxline:t})};Q.encryptedPrivateKeyFromPem=function(e){var t=V.pem.decode(e)[0];if(t.type!=="ENCRYPTED PRIVATE KEY"){var a=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw a.headerType=t.type,a}if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return A.fromDer(t.body)};Q.encryptRsaPrivateKey=function(e,t,a){if(a=a||{},!a.legacy){var r=Q.wrapRsaPrivateKey(Q.privateKeyToAsn1(e));return r=Q.encryptPrivateKeyInfo(r,t,a),Q.encryptedPrivateKeyToPem(r)}var n,s,i,o;switch(a.algorithm){case"aes128":n="AES-128-CBC",i=16,s=V.random.getBytesSync(16),o=V.aes.createEncryptionCipher;break;case"aes192":n="AES-192-CBC",i=24,s=V.random.getBytesSync(16),o=V.aes.createEncryptionCipher;break;case"aes256":n="AES-256-CBC",i=32,s=V.random.getBytesSync(16),o=V.aes.createEncryptionCipher;break;case"3des":n="DES-EDE3-CBC",i=24,s=V.random.getBytesSync(8),o=V.des.createEncryptionCipher;break;case"des":n="DES-CBC",i=8,s=V.random.getBytesSync(8),o=V.des.createEncryptionCipher;break;default:var u=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+a.algorithm+'".');throw u.algorithm=a.algorithm,u}var l=V.pbe.opensslDeriveBytes(t,s.substr(0,8),i),c=o(l);c.start(s),c.update(A.toDer(Q.privateKeyToAsn1(e))),c.finish();var f={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:n,parameters:V.util.bytesToHex(s).toUpperCase()},body:c.output.getBytes()};return V.pem.encode(f)};Q.decryptRsaPrivateKey=function(e,t){var a=null,r=V.pem.decode(e)[0];if(r.type!=="ENCRYPTED PRIVATE KEY"&&r.type!=="PRIVATE KEY"&&r.type!=="RSA PRIVATE KEY"){var n=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".');throw n.headerType=n,n}if(r.procType&&r.procType.type==="ENCRYPTED"){var s,i;switch(r.dekInfo.algorithm){case"DES-CBC":s=8,i=V.des.createDecryptionCipher;break;case"DES-EDE3-CBC":s=24,i=V.des.createDecryptionCipher;break;case"AES-128-CBC":s=16,i=V.aes.createDecryptionCipher;break;case"AES-192-CBC":s=24,i=V.aes.createDecryptionCipher;break;case"AES-256-CBC":s=32,i=V.aes.createDecryptionCipher;break;case"RC2-40-CBC":s=5,i=function(f){return V.rc2.createDecryptionCipher(f,40)};break;case"RC2-64-CBC":s=8,i=function(f){return V.rc2.createDecryptionCipher(f,64)};break;case"RC2-128-CBC":s=16,i=function(f){return V.rc2.createDecryptionCipher(f,128)};break;default:var n=new Error('Could not decrypt private key; unsupported encryption algorithm "'+r.dekInfo.algorithm+'".');throw n.algorithm=r.dekInfo.algorithm,n}var o=V.util.hexToBytes(r.dekInfo.parameters),u=V.pbe.opensslDeriveBytes(t,o.substr(0,8),s),l=i(u);if(l.start(o),l.update(V.util.createBuffer(r.body)),l.finish())a=l.output.getBytes();else return a}else a=r.body;return r.type==="ENCRYPTED PRIVATE KEY"?a=Q.decryptPrivateKeyInfo(A.fromDer(a),t):a=A.fromDer(a),a!==null&&(a=Q.privateKeyFromAsn1(a)),a};Q.pbe.generatePkcs12Key=function(e,t,a,r,n,s){var i,o;if(typeof s>"u"||s===null){if(!("sha1"in V.md))throw new Error('"sha1" hash algorithm unavailable.');s=V.md.sha1.create()}var u=s.digestLength,l=s.blockLength,c=new V.util.ByteBuffer,f=new V.util.ByteBuffer;if(e!=null){for(o=0;o<e.length;o++)f.putInt16(e.charCodeAt(o));f.putInt16(0)}var g=f.length(),v=t.length(),y=new V.util.ByteBuffer;y.fillWithByte(a,l);var x=l*Math.ceil(v/l),S=new V.util.ByteBuffer;for(o=0;o<x;o++)S.putByte(t.at(o%v));var T=l*Math.ceil(g/l),B=new V.util.ByteBuffer;for(o=0;o<T;o++)B.putByte(f.at(o%g));var b=S;b.putBuffer(B);for(var P=Math.ceil(n/u),k=1;k<=P;k++){var R=new V.util.ByteBuffer;R.putBytes(y.bytes()),R.putBytes(b.bytes());for(var z=0;z<r;z++)s.start(),s.update(R.getBytes()),R=s.digest();var Y=new V.util.ByteBuffer;for(o=0;o<l;o++)Y.putByte(R.at(o%u));var ne=Math.ceil(v/l)+Math.ceil(g/l),ie=new V.util.ByteBuffer;for(i=0;i<ne;i++){var ue=new V.util.ByteBuffer(b.getBytes(l)),fe=511;for(o=Y.length()-1;o>=0;o--)fe=fe>>8,fe+=Y.at(o)+ue.at(o),ue.setAt(o,fe&255);ie.putBuffer(ue)}b=ie,c.putBuffer(R)}return c.truncate(c.length()-n),c};Q.pbe.getCipher=function(e,t,a){switch(e){case Q.oids.pkcs5PBES2:return Q.pbe.getCipherForPBES2(e,t,a);case Q.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case Q.oids["pbewithSHAAnd40BitRC2-CBC"]:return Q.pbe.getCipherForPKCS12PBE(e,t,a);default:var r=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw r.oid=e,r.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],r}};Q.pbe.getCipherForPBES2=function(e,t,a){var r={},n=[];if(!A.validate(t,vc,r,n)){var s=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=n,s}if(e=A.derToOid(r.kdfOid),e!==Q.oids.pkcs5PBKDF2){var s=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.");throw s.oid=e,s.supportedOids=["pkcs5PBKDF2"],s}if(e=A.derToOid(r.encOid),e!==Q.oids["aes128-CBC"]&&e!==Q.oids["aes192-CBC"]&&e!==Q.oids["aes256-CBC"]&&e!==Q.oids["des-EDE3-CBC"]&&e!==Q.oids.desCBC){var s=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.");throw s.oid=e,s.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],s}var i=r.kdfSalt,o=V.util.createBuffer(r.kdfIterationCount);o=o.getInt(o.length()<<3);var u,l;switch(Q.oids[e]){case"aes128-CBC":u=16,l=V.aes.createDecryptionCipher;break;case"aes192-CBC":u=24,l=V.aes.createDecryptionCipher;break;case"aes256-CBC":u=32,l=V.aes.createDecryptionCipher;break;case"des-EDE3-CBC":u=24,l=V.des.createDecryptionCipher;break;case"desCBC":u=8,l=V.des.createDecryptionCipher;break}var c=is(r.prfOid),f=V.pkcs5.pbkdf2(a,i,o,u,c),g=r.encIv,v=l(f);return v.start(g),v};Q.pbe.getCipherForPKCS12PBE=function(e,t,a){var r={},n=[];if(!A.validate(t,mc,r,n)){var s=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=n,s}var i=V.util.createBuffer(r.salt),o=V.util.createBuffer(r.iterations);o=o.getInt(o.length()<<3);var u,l,c;switch(e){case Q.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:u=24,l=8,c=V.des.startDecrypting;break;case Q.oids["pbewithSHAAnd40BitRC2-CBC"]:u=5,l=8,c=function(x,S){var T=V.rc2.createDecryptionCipher(x,40);return T.start(S,null),T};break;default:var s=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.");throw s.oid=e,s}var f=is(r.prfOid),g=Q.pbe.generatePkcs12Key(a,i,1,o,u,f);f.start();var v=Q.pbe.generatePkcs12Key(a,i,2,o,l,f);return c(g,v)};Q.pbe.opensslDeriveBytes=function(e,t,a,r){if(typeof r>"u"||r===null){if(!("md5"in V.md))throw new Error('"md5" hash algorithm unavailable.');r=V.md.md5.create()}t===null&&(t="");for(var n=[ns(r,e+t)],s=16,i=1;s<a;++i,s+=16)n.push(ns(r,n[i-1]+e+t));return n.join("").substr(0,a)};function ns(e,t){return e.start().update(t).digest().getBytes()}function is(e){var t;if(!e)t="hmacWithSHA1";else if(t=Q.oids[A.derToOid(e)],!t){var a=new Error("Unsupported PRF OID.");throw a.oid=e,a.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],a}return ss(t)}function ss(e){var t=V.md;switch(e){case"hmacWithSHA224":t=V.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":e=e.substr(8).toLowerCase();break;default:var a=new Error("Unsupported PRF algorithm.");throw a.algorithm=e,a.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],a}if(!t||!(e in t))throw new Error("Unknown hash algorithm: "+e);return t[e].create()}function Cc(e,t,a,r){var n=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OCTETSTRING,!1,e),A.create(A.Class.UNIVERSAL,A.Type.INTEGER,!1,t.getBytes())]);return r!=="hmacWithSHA1"&&n.value.push(A.create(A.Class.UNIVERSAL,A.Type.INTEGER,!1,V.util.hexToBytes(a.toString(16))),A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(Q.oids[r]).getBytes()),A.create(A.Class.UNIVERSAL,A.Type.NULL,!1,"")])),n}});var an=F((Qh,cs)=>{var dr=$();lt();re();var O=dr.asn1,hr=cs.exports=dr.pkcs7asn1=dr.pkcs7asn1||{};dr.pkcs7=dr.pkcs7||{};dr.pkcs7.asn1=hr;var us={name:"ContentInfo",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:O.Class.UNIVERSAL,type:O.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:O.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};hr.contentInfoValidator=us;var ls={name:"EncryptedContentInfo",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:O.Class.UNIVERSAL,type:O.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:O.Class.UNIVERSAL,type:O.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:O.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:O.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};hr.envelopedDataValidator={name:"EnvelopedData",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:O.Class.UNIVERSAL,type:O.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:O.Class.UNIVERSAL,type:O.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(ls)};hr.encryptedDataValidator={name:"EncryptedData",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:O.Class.UNIVERSAL,type:O.Type.INTEGER,constructed:!1,capture:"version"}].concat(ls)};var Ec={name:"SignerInfo",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:O.Class.UNIVERSAL,type:O.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:O.Class.UNIVERSAL,type:O.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:O.Class.UNIVERSAL,type:O.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:O.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:O.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:O.Class.UNIVERSAL,type:O.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:O.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};hr.signedDataValidator={name:"SignedData",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:O.Class.UNIVERSAL,type:O.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:O.Class.UNIVERSAL,type:O.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},us,{name:"SignedData.Certificates",tagClass:O.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:O.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:O.Class.UNIVERSAL,type:O.Type.SET,capture:"signerInfos",optional:!0,value:[Ec]}]};hr.recipientInfoValidator={name:"RecipientInfo",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:O.Class.UNIVERSAL,type:O.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:O.Class.UNIVERSAL,type:O.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:O.Class.UNIVERSAL,type:O.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:O.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter",optional:!0}]},{name:"RecipientInfo.encryptedKey",tagClass:O.Class.UNIVERSAL,type:O.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]}});var nn=F(($h,fs)=>{var Wt=$();re();Wt.mgf=Wt.mgf||{};var xc=fs.exports=Wt.mgf.mgf1=Wt.mgf1=Wt.mgf1||{};xc.create=function(e){var t={generate:function(a,r){for(var n=new Wt.util.ByteBuffer,s=Math.ceil(r/e.digestLength),i=0;i<s;i++){var o=new Wt.util.ByteBuffer;o.putInt32(i),e.start(),e.update(a+o.getBytes()),n.putBuffer(e.digest())}return n.truncate(n.length()-r),n.getBytes()}};return t}});var hs=F((Yh,ds)=>{var fa=$();nn();ds.exports=fa.mgf=fa.mgf||{};fa.mgf.mgf1=fa.mgf1});var da=F((jh,ps)=>{var Xt=$();tt();re();var Sc=ps.exports=Xt.pss=Xt.pss||{};Sc.create=function(e){arguments.length===3&&(e={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var t=e.md,a=e.mgf,r=t.digestLength,n=e.salt||null;typeof n=="string"&&(n=Xt.util.createBuffer(n));var s;if("saltLength"in e)s=e.saltLength;else if(n!==null)s=n.length();else throw new Error("Salt length not specified or specific salt not given.");if(n!==null&&n.length()!==s)throw new Error("Given salt length does not match length of given salt.");var i=e.prng||Xt.random,o={};return o.encode=function(u,l){var c,f=l-1,g=Math.ceil(f/8),v=u.digest().getBytes();if(g<r+s+2)throw new Error("Message is too long to encrypt.");var y;n===null?y=i.getBytesSync(s):y=n.bytes();var x=new Xt.util.ByteBuffer;x.fillWithByte(0,8),x.putBytes(v),x.putBytes(y),t.start(),t.update(x.getBytes());var S=t.digest().getBytes(),T=new Xt.util.ByteBuffer;T.fillWithByte(0,g-s-r-2),T.putByte(1),T.putBytes(y);var B=T.getBytes(),b=g-r-1,P=a.generate(S,b),k="";for(c=0;c<b;c++)k+=String.fromCharCode(B.charCodeAt(c)^P.charCodeAt(c));var R=65280>>8*g-f&255;return k=String.fromCharCode(k.charCodeAt(0)&~R)+k.substr(1),k+S+"\xBC"},o.verify=function(u,l,c){var f,g=c-1,v=Math.ceil(g/8);if(l=l.substr(-v),v<r+s+2)throw new Error("Inconsistent parameters to PSS signature verification.");if(l.charCodeAt(v-1)!==188)throw new Error("Encoded message does not end in 0xBC.");var y=v-r-1,x=l.substr(0,y),S=l.substr(y,r),T=65280>>8*v-g&255;if((x.charCodeAt(0)&T)!==0)throw new Error("Bits beyond keysize not zero as expected.");var B=a.generate(S,y),b="";for(f=0;f<y;f++)b+=String.fromCharCode(x.charCodeAt(f)^B.charCodeAt(f));b=String.fromCharCode(b.charCodeAt(0)&~T)+b.substr(1);var P=v-r-s-2;for(f=0;f<P;f++)if(b.charCodeAt(f)!==0)throw new Error("Leftmost octets not zero as expected");if(b.charCodeAt(P)!==1)throw new Error("Inconsistent PSS signature, 0x01 marker not found");var k=b.substr(-s),R=new Xt.util.ByteBuffer;R.fillWithByte(0,8),R.putBytes(u),R.putBytes(k),t.start(),t.update(R.getBytes());var z=t.digest().getBytes();return S===z},o}});var ga=F((Wh,Cs)=>{var q=$();Rt();lt();_r();ft();hs();Lt();Qt();da();Rr();re();var d=q.asn1,L=Cs.exports=q.pki=q.pki||{},te=L.oids,ge={};ge.CN=te.commonName;ge.commonName="CN";ge.C=te.countryName;ge.countryName="C";ge.L=te.localityName;ge.localityName="L";ge.ST=te.stateOrProvinceName;ge.stateOrProvinceName="ST";ge.O=te.organizationName;ge.organizationName="O";ge.OU=te.organizationalUnitName;ge.organizationalUnitName="OU";ge.E=te.emailAddress;ge.emailAddress="E";var ys=q.pki.rsa.publicKeyValidator,Tc={name:"Certificate",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:d.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:d.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:d.Class.UNIVERSAL,type:d.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:d.Class.UNIVERSAL,type:d.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:d.Class.UNIVERSAL,type:d.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:d.Class.UNIVERSAL,type:d.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},ys,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:d.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:d.Class.UNIVERSAL,type:d.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:d.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:d.Class.UNIVERSAL,type:d.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:d.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:d.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:d.Class.UNIVERSAL,type:d.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},Ic={name:"rsapss",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:d.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:d.Class.UNIVERSAL,type:d.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:d.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:d.Class.UNIVERSAL,type:d.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:d.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:d.Class.UNIVERSAL,type:d.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:d.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:d.Class.UNIVERSAL,type:d.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},Ac={name:"CertificationRequestInfo",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},ys,{name:"CertificationRequestInfo.attributes",tagClass:d.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:d.Class.UNIVERSAL,type:d.Type.SET,constructed:!0}]}]}]},Bc={name:"CertificationRequest",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[Ac,{name:"CertificationRequest.signatureAlgorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:d.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:d.Class.UNIVERSAL,type:d.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};L.RDNAttributesAsArray=function(e,t){for(var a=[],r,n,s,i=0;i<e.value.length;++i){r=e.value[i];for(var o=0;o<r.value.length;++o)s={},n=r.value[o],s.type=d.derToOid(n.value[0].value),s.value=n.value[1].value,s.valueTagClass=n.value[1].type,s.type in te&&(s.name=te[s.type],s.name in ge&&(s.shortName=ge[s.name])),t&&(t.update(s.type),t.update(s.value)),a.push(s)}return a};L.CRIAttributesAsArray=function(e){for(var t=[],a=0;a<e.length;++a)for(var r=e[a],n=d.derToOid(r.value[0].value),s=r.value[1].value,i=0;i<s.length;++i){var o={};if(o.type=n,o.value=s[i].value,o.valueTagClass=s[i].type,o.type in te&&(o.name=te[o.type],o.name in ge&&(o.shortName=ge[o.name])),o.type===te.extensionRequest){o.extensions=[];for(var u=0;u<o.value.length;++u)o.extensions.push(L.certificateExtensionFromAsn1(o.value[u]))}t.push(o)}return t};function Ut(e,t){typeof t=="string"&&(t={shortName:t});for(var a=null,r,n=0;a===null&&n<e.attributes.length;++n)r=e.attributes[n],(t.type&&t.type===r.type||t.name&&t.name===r.name||t.shortName&&t.shortName===r.shortName)&&(a=r);return a}var ha=function(e,t,a){var r={};if(e!==te["RSASSA-PSS"])return r;a&&(r={hash:{algorithmOid:te.sha1},mgf:{algorithmOid:te.mgf1,hash:{algorithmOid:te.sha1}},saltLength:20});var n={},s=[];if(!d.validate(t,Ic,n,s)){var i=new Error("Cannot read RSASSA-PSS parameter block.");throw i.errors=s,i}return n.hashOid!==void 0&&(r.hash=r.hash||{},r.hash.algorithmOid=d.derToOid(n.hashOid)),n.maskGenOid!==void 0&&(r.mgf=r.mgf||{},r.mgf.algorithmOid=d.derToOid(n.maskGenOid),r.mgf.hash=r.mgf.hash||{},r.mgf.hash.algorithmOid=d.derToOid(n.maskGenHashOid)),n.saltLength!==void 0&&(r.saltLength=n.saltLength.charCodeAt(0)),r},pa=function(e){switch(te[e.signatureOid]){case"sha1WithRSAEncryption":case"sha1WithRSASignature":return q.md.sha1.create();case"md5WithRSAEncryption":return q.md.md5.create();case"sha256WithRSAEncryption":return q.md.sha256.create();case"sha384WithRSAEncryption":return q.md.sha384.create();case"sha512WithRSAEncryption":return q.md.sha512.create();case"RSASSA-PSS":return q.md.sha256.create();default:var t=new Error("Could not compute "+e.type+" digest. Unknown signature OID.");throw t.signatureOid=e.signatureOid,t}},vs=function(e){var t=e.certificate,a;switch(t.signatureOid){case te.sha1WithRSAEncryption:case te.sha1WithRSASignature:break;case te["RSASSA-PSS"]:var r,n;if(r=te[t.signatureParameters.mgf.hash.algorithmOid],r===void 0||q.md[r]===void 0){var s=new Error("Unsupported MGF hash function.");throw s.oid=t.signatureParameters.mgf.hash.algorithmOid,s.name=r,s}if(n=te[t.signatureParameters.mgf.algorithmOid],n===void 0||q.mgf[n]===void 0){var s=new Error("Unsupported MGF function.");throw s.oid=t.signatureParameters.mgf.algorithmOid,s.name=n,s}if(n=q.mgf[n].create(q.md[r].create()),r=te[t.signatureParameters.hash.algorithmOid],r===void 0||q.md[r]===void 0){var s=new Error("Unsupported RSASSA-PSS hash function.");throw s.oid=t.signatureParameters.hash.algorithmOid,s.name=r,s}a=q.pss.create(q.md[r].create(),n,t.signatureParameters.saltLength);break}return t.publicKey.verify(e.md.digest().getBytes(),e.signature,a)};L.certificateFromPem=function(e,t,a){var r=q.pem.decode(e)[0];if(r.type!=="CERTIFICATE"&&r.type!=="X509 CERTIFICATE"&&r.type!=="TRUSTED CERTIFICATE"){var n=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw n.headerType=r.type,n}if(r.procType&&r.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var s=d.fromDer(r.body,a);return L.certificateFromAsn1(s,t)};L.certificateToPem=function(e,t){var a={type:"CERTIFICATE",body:d.toDer(L.certificateToAsn1(e)).getBytes()};return q.pem.encode(a,{maxline:t})};L.publicKeyFromPem=function(e){var t=q.pem.decode(e)[0];if(t.type!=="PUBLIC KEY"&&t.type!=="RSA PUBLIC KEY"){var a=new Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');throw a.headerType=t.type,a}if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert public key from PEM; PEM is encrypted.");var r=d.fromDer(t.body);return L.publicKeyFromAsn1(r)};L.publicKeyToPem=function(e,t){var a={type:"PUBLIC KEY",body:d.toDer(L.publicKeyToAsn1(e)).getBytes()};return q.pem.encode(a,{maxline:t})};L.publicKeyToRSAPublicKeyPem=function(e,t){var a={type:"RSA PUBLIC KEY",body:d.toDer(L.publicKeyToRSAPublicKey(e)).getBytes()};return q.pem.encode(a,{maxline:t})};L.getPublicKeyFingerprint=function(e,t){t=t||{};var a=t.md||q.md.sha1.create(),r=t.type||"RSAPublicKey",n;switch(r){case"RSAPublicKey":n=d.toDer(L.publicKeyToRSAPublicKey(e)).getBytes();break;case"SubjectPublicKeyInfo":n=d.toDer(L.publicKeyToAsn1(e)).getBytes();break;default:throw new Error('Unknown fingerprint type "'+t.type+'".')}a.start(),a.update(n);var s=a.digest();if(t.encoding==="hex"){var i=s.toHex();return t.delimiter?i.match(/.{2}/g).join(t.delimiter):i}else{if(t.encoding==="binary")return s.getBytes();if(t.encoding)throw new Error('Unknown encoding "'+t.encoding+'".')}return s};L.certificationRequestFromPem=function(e,t,a){var r=q.pem.decode(e)[0];if(r.type!=="CERTIFICATE REQUEST"){var n=new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw n.headerType=r.type,n}if(r.procType&&r.procType.type==="ENCRYPTED")throw new Error("Could not convert certification request from PEM; PEM is encrypted.");var s=d.fromDer(r.body,a);return L.certificationRequestFromAsn1(s,t)};L.certificationRequestToPem=function(e,t){var a={type:"CERTIFICATE REQUEST",body:d.toDer(L.certificationRequestToAsn1(e)).getBytes()};return q.pem.encode(a,{maxline:t})};L.createCertificate=function(){var e={};return e.version=2,e.serialNumber="00",e.signatureOid=null,e.signature=null,e.siginfo={},e.siginfo.algorithmOid=null,e.validity={},e.validity.notBefore=new Date,e.validity.notAfter=new Date,e.issuer={},e.issuer.getField=function(t){return Ut(e.issuer,t)},e.issuer.addField=function(t){nt([t]),e.issuer.attributes.push(t)},e.issuer.attributes=[],e.issuer.hash=null,e.subject={},e.subject.getField=function(t){return Ut(e.subject,t)},e.subject.addField=function(t){nt([t]),e.subject.attributes.push(t)},e.subject.attributes=[],e.subject.hash=null,e.extensions=[],e.publicKey=null,e.md=null,e.setSubject=function(t,a){nt(t),e.subject.attributes=t,delete e.subject.uniqueId,a&&(e.subject.uniqueId=a),e.subject.hash=null},e.setIssuer=function(t,a){nt(t),e.issuer.attributes=t,delete e.issuer.uniqueId,a&&(e.issuer.uniqueId=a),e.issuer.hash=null},e.setExtensions=function(t){for(var a=0;a<t.length;++a)ms(t[a],{cert:e});e.extensions=t},e.getExtension=function(t){typeof t=="string"&&(t={name:t});for(var a=null,r,n=0;a===null&&n<e.extensions.length;++n)r=e.extensions[n],(t.id&&r.id===t.id||t.name&&r.name===t.name)&&(a=r);return a},e.sign=function(t,a){e.md=a||q.md.sha1.create();var r=te[e.md.algorithm+"WithRSAEncryption"];if(!r){var n=new Error("Could not compute certificate digest. Unknown message digest algorithm OID.");throw n.algorithm=e.md.algorithm,n}e.signatureOid=e.siginfo.algorithmOid=r,e.tbsCertificate=L.getTBSCertificate(e);var s=d.toDer(e.tbsCertificate);e.md.update(s.getBytes()),e.signature=t.sign(e.md)},e.verify=function(t){var a=!1;if(!e.issued(t)){var r=t.issuer,n=e.subject,s=new Error("The parent certificate did not issue the given child certificate; the child certificate's issuer does not match the parent's subject.");throw s.expectedIssuer=n.attributes,s.actualIssuer=r.attributes,s}var i=t.md;if(i===null){i=pa({signatureOid:t.signatureOid,type:"certificate"});var o=t.tbsCertificate||L.getTBSCertificate(t),u=d.toDer(o);i.update(u.getBytes())}return i!==null&&(a=vs({certificate:e,md:i,signature:t.signature})),a},e.isIssuer=function(t){var a=!1,r=e.issuer,n=t.subject;if(r.hash&&n.hash)a=r.hash===n.hash;else if(r.attributes.length===n.attributes.length){a=!0;for(var s,i,o=0;a&&o<r.attributes.length;++o)s=r.attributes[o],i=n.attributes[o],(s.type!==i.type||s.value!==i.value)&&(a=!1)}return a},e.issued=function(t){return t.isIssuer(e)},e.generateSubjectKeyIdentifier=function(){return L.getPublicKeyFingerprint(e.publicKey,{type:"RSAPublicKey"})},e.verifySubjectKeyIdentifier=function(){for(var t=te.subjectKeyIdentifier,a=0;a<e.extensions.length;++a){var r=e.extensions[a];if(r.id===t){var n=e.generateSubjectKeyIdentifier().getBytes();return q.util.hexToBytes(r.subjectKeyIdentifier)===n}}return!1},e};L.certificateFromAsn1=function(e,t){var a={},r=[];if(!d.validate(e,Tc,a,r)){var n=new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.");throw n.errors=r,n}var s=d.derToOid(a.publicKeyOid);if(s!==L.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var i=L.createCertificate();i.version=a.certVersion?a.certVersion.charCodeAt(0):0;var o=q.util.createBuffer(a.certSerialNumber);i.serialNumber=o.toHex(),i.signatureOid=q.asn1.derToOid(a.certSignatureOid),i.signatureParameters=ha(i.signatureOid,a.certSignatureParams,!0),i.siginfo.algorithmOid=q.asn1.derToOid(a.certinfoSignatureOid),i.siginfo.parameters=ha(i.siginfo.algorithmOid,a.certinfoSignatureParams,!1),i.signature=a.certSignature;var u=[];if(a.certValidity1UTCTime!==void 0&&u.push(d.utcTimeToDate(a.certValidity1UTCTime)),a.certValidity2GeneralizedTime!==void 0&&u.push(d.generalizedTimeToDate(a.certValidity2GeneralizedTime)),a.certValidity3UTCTime!==void 0&&u.push(d.utcTimeToDate(a.certValidity3UTCTime)),a.certValidity4GeneralizedTime!==void 0&&u.push(d.generalizedTimeToDate(a.certValidity4GeneralizedTime)),u.length>2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(u.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(i.validity.notBefore=u[0],i.validity.notAfter=u[1],i.tbsCertificate=a.tbsCertificate,t){i.md=pa({signatureOid:i.signatureOid,type:"certificate"});var l=d.toDer(i.tbsCertificate);i.md.update(l.getBytes())}var c=q.md.sha1.create(),f=d.toDer(a.certIssuer);c.update(f.getBytes()),i.issuer.getField=function(y){return Ut(i.issuer,y)},i.issuer.addField=function(y){nt([y]),i.issuer.attributes.push(y)},i.issuer.attributes=L.RDNAttributesAsArray(a.certIssuer),a.certIssuerUniqueId&&(i.issuer.uniqueId=a.certIssuerUniqueId),i.issuer.hash=c.digest().toHex();var g=q.md.sha1.create(),v=d.toDer(a.certSubject);return g.update(v.getBytes()),i.subject.getField=function(y){return Ut(i.subject,y)},i.subject.addField=function(y){nt([y]),i.subject.attributes.push(y)},i.subject.attributes=L.RDNAttributesAsArray(a.certSubject),a.certSubjectUniqueId&&(i.subject.uniqueId=a.certSubjectUniqueId),i.subject.hash=g.digest().toHex(),a.certExtensions?i.extensions=L.certificateExtensionsFromAsn1(a.certExtensions):i.extensions=[],i.publicKey=L.publicKeyFromAsn1(a.subjectPublicKeyInfo),i};L.certificateExtensionsFromAsn1=function(e){for(var t=[],a=0;a<e.value.length;++a)for(var r=e.value[a],n=0;n<r.value.length;++n)t.push(L.certificateExtensionFromAsn1(r.value[n]));return t};L.certificateExtensionFromAsn1=function(e){var t={};if(t.id=d.derToOid(e.value[0].value),t.critical=!1,e.value[1].type===d.Type.BOOLEAN?(t.critical=e.value[1].value.charCodeAt(0)!==0,t.value=e.value[2].value):t.value=e.value[1].value,t.id in te){if(t.name=te[t.id],t.name==="keyUsage"){var a=d.fromDer(t.value),r=0,n=0;a.value.length>1&&(r=a.value.charCodeAt(1),n=a.value.length>2?a.value.charCodeAt(2):0),t.digitalSignature=(r&128)===128,t.nonRepudiation=(r&64)===64,t.keyEncipherment=(r&32)===32,t.dataEncipherment=(r&16)===16,t.keyAgreement=(r&8)===8,t.keyCertSign=(r&4)===4,t.cRLSign=(r&2)===2,t.encipherOnly=(r&1)===1,t.decipherOnly=(n&128)===128}else if(t.name==="basicConstraints"){var a=d.fromDer(t.value);a.value.length>0&&a.value[0].type===d.Type.BOOLEAN?t.cA=a.value[0].value.charCodeAt(0)!==0:t.cA=!1;var s=null;a.value.length>0&&a.value[0].type===d.Type.INTEGER?s=a.value[0].value:a.value.length>1&&(s=a.value[1].value),s!==null&&(t.pathLenConstraint=d.derToInteger(s))}else if(t.name==="extKeyUsage")for(var a=d.fromDer(t.value),i=0;i<a.value.length;++i){var o=d.derToOid(a.value[i].value);o in te?t[te[o]]=!0:t[o]=!0}else if(t.name==="nsCertType"){var a=d.fromDer(t.value),r=0;a.value.length>1&&(r=a.value.charCodeAt(1)),t.client=(r&128)===128,t.server=(r&64)===64,t.email=(r&32)===32,t.objsign=(r&16)===16,t.reserved=(r&8)===8,t.sslCA=(r&4)===4,t.emailCA=(r&2)===2,t.objCA=(r&1)===1}else if(t.name==="subjectAltName"||t.name==="issuerAltName"){t.altNames=[];for(var u,a=d.fromDer(t.value),l=0;l<a.value.length;++l){u=a.value[l];var c={type:u.type,value:u.value};switch(t.altNames.push(c),u.type){case 1:case 2:case 6:break;case 7:c.ip=q.util.bytesToIP(u.value);break;case 8:c.oid=d.derToOid(u.value);break;default:}}}else if(t.name==="subjectKeyIdentifier"){var a=d.fromDer(t.value);t.subjectKeyIdentifier=q.util.bytesToHex(a.value)}}return t};L.certificationRequestFromAsn1=function(e,t){var a={},r=[];if(!d.validate(e,Bc,a,r)){var n=new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.");throw n.errors=r,n}var s=d.derToOid(a.publicKeyOid);if(s!==L.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var i=L.createCertificationRequest();if(i.version=a.csrVersion?a.csrVersion.charCodeAt(0):0,i.signatureOid=q.asn1.derToOid(a.csrSignatureOid),i.signatureParameters=ha(i.signatureOid,a.csrSignatureParams,!0),i.siginfo.algorithmOid=q.asn1.derToOid(a.csrSignatureOid),i.siginfo.parameters=ha(i.siginfo.algorithmOid,a.csrSignatureParams,!1),i.signature=a.csrSignature,i.certificationRequestInfo=a.certificationRequestInfo,t){i.md=pa({signatureOid:i.signatureOid,type:"certification request"});var o=d.toDer(i.certificationRequestInfo);i.md.update(o.getBytes())}var u=q.md.sha1.create();return i.subject.getField=function(l){return Ut(i.subject,l)},i.subject.addField=function(l){nt([l]),i.subject.attributes.push(l)},i.subject.attributes=L.RDNAttributesAsArray(a.certificationRequestInfoSubject,u),i.subject.hash=u.digest().toHex(),i.publicKey=L.publicKeyFromAsn1(a.subjectPublicKeyInfo),i.getAttribute=function(l){return Ut(i,l)},i.addAttribute=function(l){nt([l]),i.attributes.push(l)},i.attributes=L.CRIAttributesAsArray(a.certificationRequestInfoAttributes||[]),i};L.createCertificationRequest=function(){var e={};return e.version=0,e.signatureOid=null,e.signature=null,e.siginfo={},e.siginfo.algorithmOid=null,e.subject={},e.subject.getField=function(t){return Ut(e.subject,t)},e.subject.addField=function(t){nt([t]),e.subject.attributes.push(t)},e.subject.attributes=[],e.subject.hash=null,e.publicKey=null,e.attributes=[],e.getAttribute=function(t){return Ut(e,t)},e.addAttribute=function(t){nt([t]),e.attributes.push(t)},e.md=null,e.setSubject=function(t){nt(t),e.subject.attributes=t,e.subject.hash=null},e.setAttributes=function(t){nt(t),e.attributes=t},e.sign=function(t,a){e.md=a||q.md.sha1.create();var r=te[e.md.algorithm+"WithRSAEncryption"];if(!r){var n=new Error("Could not compute certification request digest. Unknown message digest algorithm OID.");throw n.algorithm=e.md.algorithm,n}e.signatureOid=e.siginfo.algorithmOid=r,e.certificationRequestInfo=L.getCertificationRequestInfo(e);var s=d.toDer(e.certificationRequestInfo);e.md.update(s.getBytes()),e.signature=t.sign(e.md)},e.verify=function(){var t=!1,a=e.md;if(a===null){a=pa({signatureOid:e.signatureOid,type:"certification request"});var r=e.certificationRequestInfo||L.getCertificationRequestInfo(e),n=d.toDer(r);a.update(n.getBytes())}return a!==null&&(t=vs({certificate:e,md:a,signature:e.signature})),t},e};function pr(e){for(var t=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]),a,r,n=e.attributes,s=0;s<n.length;++s){a=n[s];var i=a.value,o=d.Type.PRINTABLESTRING;"valueTagClass"in a&&(o=a.valueTagClass,o===d.Type.UTF8&&(i=q.util.encodeUtf8(i))),r=d.create(d.Class.UNIVERSAL,d.Type.SET,!0,[d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(a.type).getBytes()),d.create(d.Class.UNIVERSAL,o,!1,i)])]),t.value.push(r)}return t}function nt(e){for(var t,a=0;a<e.length;++a){if(t=e[a],typeof t.name>"u"&&(t.type&&t.type in L.oids?t.name=L.oids[t.type]:t.shortName&&t.shortName in ge&&(t.name=L.oids[ge[t.shortName]])),typeof t.type>"u")if(t.name&&t.name in L.oids)t.type=L.oids[t.name];else{var r=new Error("Attribute type not specified.");throw r.attribute=t,r}if(typeof t.shortName>"u"&&t.name&&t.name in ge&&(t.shortName=ge[t.name]),t.type===te.extensionRequest&&(t.valueConstructed=!0,t.valueTagClass=d.Type.SEQUENCE,!t.value&&t.extensions)){t.value=[];for(var n=0;n<t.extensions.length;++n)t.value.push(L.certificateExtensionToAsn1(ms(t.extensions[n])))}if(typeof t.value>"u"){var r=new Error("Attribute value not specified.");throw r.attribute=t,r}}}function ms(e,t){if(t=t||{},typeof e.name>"u"&&e.id&&e.id in L.oids&&(e.name=L.oids[e.id]),typeof e.id>"u")if(e.name&&e.name in L.oids)e.id=L.oids[e.name];else{var a=new Error("Extension ID not specified.");throw a.extension=e,a}if(typeof e.value<"u")return e;if(e.name==="keyUsage"){var r=0,n=0,s=0;e.digitalSignature&&(n|=128,r=7),e.nonRepudiation&&(n|=64,r=6),e.keyEncipherment&&(n|=32,r=5),e.dataEncipherment&&(n|=16,r=4),e.keyAgreement&&(n|=8,r=3),e.keyCertSign&&(n|=4,r=2),e.cRLSign&&(n|=2,r=1),e.encipherOnly&&(n|=1,r=0),e.decipherOnly&&(s|=128,r=7);var i=String.fromCharCode(r);s!==0?i+=String.fromCharCode(n)+String.fromCharCode(s):n!==0&&(i+=String.fromCharCode(n)),e.value=d.create(d.Class.UNIVERSAL,d.Type.BITSTRING,!1,i)}else if(e.name==="basicConstraints")e.value=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]),e.cA&&e.value.value.push(d.create(d.Class.UNIVERSAL,d.Type.BOOLEAN,!1,"\xFF")),"pathLenConstraint"in e&&e.value.value.push(d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,d.integerToDer(e.pathLenConstraint).getBytes()));else if(e.name==="extKeyUsage"){e.value=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]);var o=e.value.value;for(var u in e)e[u]===!0&&(u in te?o.push(d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(te[u]).getBytes())):u.indexOf(".")!==-1&&o.push(d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(u).getBytes())))}else if(e.name==="nsCertType"){var r=0,n=0;e.client&&(n|=128,r=7),e.server&&(n|=64,r=6),e.email&&(n|=32,r=5),e.objsign&&(n|=16,r=4),e.reserved&&(n|=8,r=3),e.sslCA&&(n|=4,r=2),e.emailCA&&(n|=2,r=1),e.objCA&&(n|=1,r=0);var i=String.fromCharCode(r);n!==0&&(i+=String.fromCharCode(n)),e.value=d.create(d.Class.UNIVERSAL,d.Type.BITSTRING,!1,i)}else if(e.name==="subjectAltName"||e.name==="issuerAltName"){e.value=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]);for(var l,c=0;c<e.altNames.length;++c){l=e.altNames[c];var i=l.value;if(l.type===7&&l.ip){if(i=q.util.bytesFromIP(l.ip),i===null){var a=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw a.extension=e,a}}else l.type===8&&(l.oid?i=d.oidToDer(d.oidToDer(l.oid)):i=d.oidToDer(i));e.value.value.push(d.create(d.Class.CONTEXT_SPECIFIC,l.type,!1,i))}}else if(e.name==="nsComment"&&t.cert){if(!/^[\x00-\x7F]*$/.test(e.comment)||e.comment.length<1||e.comment.length>128)throw new Error('Invalid "nsComment" content.');e.value=d.create(d.Class.UNIVERSAL,d.Type.IA5STRING,!1,e.comment)}else if(e.name==="subjectKeyIdentifier"&&t.cert){var f=t.cert.generateSubjectKeyIdentifier();e.subjectKeyIdentifier=f.toHex(),e.value=d.create(d.Class.UNIVERSAL,d.Type.OCTETSTRING,!1,f.getBytes())}else if(e.name==="authorityKeyIdentifier"&&t.cert){e.value=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]);var o=e.value.value;if(e.keyIdentifier){var g=e.keyIdentifier===!0?t.cert.generateSubjectKeyIdentifier().getBytes():e.keyIdentifier;o.push(d.create(d.Class.CONTEXT_SPECIFIC,0,!1,g))}if(e.authorityCertIssuer){var v=[d.create(d.Class.CONTEXT_SPECIFIC,4,!0,[pr(e.authorityCertIssuer===!0?t.cert.issuer:e.authorityCertIssuer)])];o.push(d.create(d.Class.CONTEXT_SPECIFIC,1,!0,v))}if(e.serialNumber){var y=q.util.hexToBytes(e.serialNumber===!0?t.cert.serialNumber:e.serialNumber);o.push(d.create(d.Class.CONTEXT_SPECIFIC,2,!1,y))}}else if(e.name==="cRLDistributionPoints"){e.value=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]);for(var o=e.value.value,x=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]),S=d.create(d.Class.CONTEXT_SPECIFIC,0,!0,[]),l,c=0;c<e.altNames.length;++c){l=e.altNames[c];var i=l.value;if(l.type===7&&l.ip){if(i=q.util.bytesFromIP(l.ip),i===null){var a=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw a.extension=e,a}}else l.type===8&&(l.oid?i=d.oidToDer(d.oidToDer(l.oid)):i=d.oidToDer(i));S.value.push(d.create(d.Class.CONTEXT_SPECIFIC,l.type,!1,i))}x.value.push(d.create(d.Class.CONTEXT_SPECIFIC,0,!0,[S])),o.push(x)}if(typeof e.value>"u"){var a=new Error("Extension value not specified.");throw a.extension=e,a}return e}function sn(e,t){switch(e){case te["RSASSA-PSS"]:var a=[];return t.hash.algorithmOid!==void 0&&a.push(d.create(d.Class.CONTEXT_SPECIFIC,0,!0,[d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(t.hash.algorithmOid).getBytes()),d.create(d.Class.UNIVERSAL,d.Type.NULL,!1,"")])])),t.mgf.algorithmOid!==void 0&&a.push(d.create(d.Class.CONTEXT_SPECIFIC,1,!0,[d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(t.mgf.algorithmOid).getBytes()),d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(t.mgf.hash.algorithmOid).getBytes()),d.create(d.Class.UNIVERSAL,d.Type.NULL,!1,"")])])])),t.saltLength!==void 0&&a.push(d.create(d.Class.CONTEXT_SPECIFIC,2,!0,[d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,d.integerToDer(t.saltLength).getBytes())])),d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,a);default:return d.create(d.Class.UNIVERSAL,d.Type.NULL,!1,"")}}function bc(e){var t=d.create(d.Class.CONTEXT_SPECIFIC,0,!0,[]);if(e.attributes.length===0)return t;for(var a=e.attributes,r=0;r<a.length;++r){var n=a[r],s=n.value,i=d.Type.UTF8;"valueTagClass"in n&&(i=n.valueTagClass),i===d.Type.UTF8&&(s=q.util.encodeUtf8(s));var o=!1;"valueConstructed"in n&&(o=n.valueConstructed);var u=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(n.type).getBytes()),d.create(d.Class.UNIVERSAL,d.Type.SET,!0,[d.create(d.Class.UNIVERSAL,i,o,s)])]);t.value.push(u)}return t}var _c=new Date("1950-01-01T00:00:00Z"),wc=new Date("2050-01-01T00:00:00Z");function gs(e){return e>=_c&&e<wc?d.create(d.Class.UNIVERSAL,d.Type.UTCTIME,!1,d.dateToUtcTime(e)):d.create(d.Class.UNIVERSAL,d.Type.GENERALIZEDTIME,!1,d.dateToGeneralizedTime(e))}L.getTBSCertificate=function(e){var t=gs(e.validity.notBefore),a=gs(e.validity.notAfter),r=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.CONTEXT_SPECIFIC,0,!0,[d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,d.integerToDer(e.version).getBytes())]),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,q.util.hexToBytes(e.serialNumber)),d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(e.siginfo.algorithmOid).getBytes()),sn(e.siginfo.algorithmOid,e.siginfo.parameters)]),pr(e.issuer),d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[t,a]),pr(e.subject),L.publicKeyToAsn1(e.publicKey)]);return e.issuer.uniqueId&&r.value.push(d.create(d.Class.CONTEXT_SPECIFIC,1,!0,[d.create(d.Class.UNIVERSAL,d.Type.BITSTRING,!1,"\0"+e.issuer.uniqueId)])),e.subject.uniqueId&&r.value.push(d.create(d.Class.CONTEXT_SPECIFIC,2,!0,[d.create(d.Class.UNIVERSAL,d.Type.BITSTRING,!1,"\0"+e.subject.uniqueId)])),e.extensions.length>0&&r.value.push(L.certificateExtensionsToAsn1(e.extensions)),r};L.getCertificationRequestInfo=function(e){var t=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,d.integerToDer(e.version).getBytes()),pr(e.subject),L.publicKeyToAsn1(e.publicKey),bc(e)]);return t};L.distinguishedNameToAsn1=function(e){return pr(e)};L.certificateToAsn1=function(e){var t=e.tbsCertificate||L.getTBSCertificate(e);return d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[t,d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(e.signatureOid).getBytes()),sn(e.signatureOid,e.signatureParameters)]),d.create(d.Class.UNIVERSAL,d.Type.BITSTRING,!1,"\0"+e.signature)])};L.certificateExtensionsToAsn1=function(e){var t=d.create(d.Class.CONTEXT_SPECIFIC,3,!0,[]),a=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]);t.value.push(a);for(var r=0;r<e.length;++r)a.value.push(L.certificateExtensionToAsn1(e[r]));return t};L.certificateExtensionToAsn1=function(e){var t=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]);t.value.push(d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(e.id).getBytes())),e.critical&&t.value.push(d.create(d.Class.UNIVERSAL,d.Type.BOOLEAN,!1,"\xFF"));var a=e.value;return typeof e.value!="string"&&(a=d.toDer(a).getBytes()),t.value.push(d.create(d.Class.UNIVERSAL,d.Type.OCTETSTRING,!1,a)),t};L.certificationRequestToAsn1=function(e){var t=e.certificationRequestInfo||L.getCertificationRequestInfo(e);return d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[t,d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(e.signatureOid).getBytes()),sn(e.signatureOid,e.signatureParameters)]),d.create(d.Class.UNIVERSAL,d.Type.BITSTRING,!1,"\0"+e.signature)])};L.createCaStore=function(e){var t={certs:{}};t.getIssuer=function(i){var o=a(i.issuer);return o},t.addCertificate=function(i){if(typeof i=="string"&&(i=q.pki.certificateFromPem(i)),r(i.subject),!t.hasCertificate(i))if(i.subject.hash in t.certs){var o=t.certs[i.subject.hash];q.util.isArray(o)||(o=[o]),o.push(i),t.certs[i.subject.hash]=o}else t.certs[i.subject.hash]=i},t.hasCertificate=function(i){typeof i=="string"&&(i=q.pki.certificateFromPem(i));var o=a(i.subject);if(!o)return!1;q.util.isArray(o)||(o=[o]);for(var u=d.toDer(L.certificateToAsn1(i)).getBytes(),l=0;l<o.length;++l){var c=d.toDer(L.certificateToAsn1(o[l])).getBytes();if(u===c)return!0}return!1},t.listAllCertificates=function(){var i=[];for(var o in t.certs)if(t.certs.hasOwnProperty(o)){var u=t.certs[o];if(!q.util.isArray(u))i.push(u);else for(var l=0;l<u.length;++l)i.push(u[l])}return i},t.removeCertificate=function(i){var o;if(typeof i=="string"&&(i=q.pki.certificateFromPem(i)),r(i.subject),!t.hasCertificate(i))return null;var u=a(i.subject);if(!q.util.isArray(u))return o=t.certs[i.subject.hash],delete t.certs[i.subject.hash],o;for(var l=d.toDer(L.certificateToAsn1(i)).getBytes(),c=0;c<u.length;++c){var f=d.toDer(L.certificateToAsn1(u[c])).getBytes();l===f&&(o=u[c],u.splice(c,1))}return u.length===0&&delete t.certs[i.subject.hash],o};function a(i){return r(i),t.certs[i.hash]||null}function r(i){if(!i.hash){var o=q.md.sha1.create();i.attributes=L.RDNAttributesAsArray(pr(i),o),i.hash=o.digest().toHex()}}if(e)for(var n=0;n<e.length;++n){var s=e[n];t.addCertificate(s)}return t};L.certificateError={bad_certificate:"forge.pki.BadCertificate",unsupported_certificate:"forge.pki.UnsupportedCertificate",certificate_revoked:"forge.pki.CertificateRevoked",certificate_expired:"forge.pki.CertificateExpired",certificate_unknown:"forge.pki.CertificateUnknown",unknown_ca:"forge.pki.UnknownCertificateAuthority"};L.verifyCertificateChain=function(e,t,a){typeof a=="function"&&(a={verify:a}),a=a||{},t=t.slice(0);var r=t.slice(0),n=a.validityCheckDate;typeof n>"u"&&(n=new Date);var s=!0,i=null,o=0;do{var u=t.shift(),l=null,c=!1;if(n&&(n<u.validity.notBefore||n>u.validity.notAfter)&&(i={message:"Certificate is not valid yet or has expired.",error:L.certificateError.certificate_expired,notBefore:u.validity.notBefore,notAfter:u.validity.notAfter,now:n}),i===null){if(l=t[0]||e.getIssuer(u),l===null&&u.isIssuer(u)&&(c=!0,l=u),l){var f=l;q.util.isArray(f)||(f=[f]);for(var g=!1;!g&&f.length>0;){l=f.shift();try{g=l.verify(u)}catch{}}g||(i={message:"Certificate signature is invalid.",error:L.certificateError.bad_certificate})}i===null&&(!l||c)&&!e.hasCertificate(u)&&(i={message:"Certificate is not trusted.",error:L.certificateError.unknown_ca})}if(i===null&&l&&!u.isIssuer(l)&&(i={message:"Certificate issuer is invalid.",error:L.certificateError.bad_certificate}),i===null)for(var v={keyUsage:!0,basicConstraints:!0},y=0;i===null&&y<u.extensions.length;++y){var x=u.extensions[y];x.critical&&!(x.name in v)&&(i={message:"Certificate has an unsupported critical extension.",error:L.certificateError.unsupported_certificate})}if(i===null&&(!s||t.length===0&&(!l||c))){var S=u.getExtension("basicConstraints"),T=u.getExtension("keyUsage");if(T!==null&&(!T.keyCertSign||S===null)&&(i={message:"Certificate keyUsage or basicConstraints conflict or indicate that the certificate is not a CA. If the certificate is the only one in the chain or isn't the first then the certificate must be a valid CA.",error:L.certificateError.bad_certificate}),i===null&&S===null&&(i={message:"Certificate is missing basicConstraints extension and cannot be used as a CA.",error:L.certificateError.bad_certificate}),i===null&&S!==null&&!S.cA&&(i={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:L.certificateError.bad_certificate}),i===null&&T!==null&&"pathLenConstraint"in S){var B=o-1;B>S.pathLenConstraint&&(i={message:"Certificate basicConstraints pathLenConstraint violated.",error:L.certificateError.bad_certificate})}}var b=i===null?!0:i.error,P=a.verify?a.verify(b,o,r):b;if(P===!0)i=null;else throw b===!0&&(i={message:"The application rejected the certificate.",error:L.certificateError.bad_certificate}),(P||P===0)&&(typeof P=="object"&&!q.util.isArray(P)?(P.message&&(i.message=P.message),P.error&&(i.error=P.error)):typeof P=="string"&&(i.error=P)),i;s=!1,++o}while(t.length>0);return!0}});var un=F((Xh,xs)=>{var ce=$();lt();or();Lt();an();rn();tt();Rr();fr();re();ga();var m=ce.asn1,W=ce.pki,kr=xs.exports=ce.pkcs12=ce.pkcs12||{},Es={name:"ContentInfo",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.contentType",tagClass:m.Class.UNIVERSAL,type:m.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:m.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"content"}]},Nc={name:"PFX",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.version",tagClass:m.Class.UNIVERSAL,type:m.Type.INTEGER,constructed:!1,capture:"version"},Es,{name:"PFX.macData",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"mac",value:[{name:"PFX.macData.mac",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm.algorithm",tagClass:m.Class.UNIVERSAL,type:m.Type.OID,constructed:!1,capture:"macAlgorithm"},{name:"PFX.macData.mac.digestAlgorithm.parameters",optional:!0,tagClass:m.Class.UNIVERSAL,captureAsn1:"macAlgorithmParameters"}]},{name:"PFX.macData.mac.digest",tagClass:m.Class.UNIVERSAL,type:m.Type.OCTETSTRING,constructed:!1,capture:"macDigest"}]},{name:"PFX.macData.macSalt",tagClass:m.Class.UNIVERSAL,type:m.Type.OCTETSTRING,constructed:!1,capture:"macSalt"},{name:"PFX.macData.iterations",tagClass:m.Class.UNIVERSAL,type:m.Type.INTEGER,constructed:!1,optional:!0,capture:"macIterations"}]}]},Rc={name:"SafeBag",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"SafeBag.bagId",tagClass:m.Class.UNIVERSAL,type:m.Type.OID,constructed:!1,capture:"bagId"},{name:"SafeBag.bagValue",tagClass:m.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"bagValue"},{name:"SafeBag.bagAttributes",tagClass:m.Class.UNIVERSAL,type:m.Type.SET,constructed:!0,optional:!0,capture:"bagAttributes"}]},Lc={name:"Attribute",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"Attribute.attrId",tagClass:m.Class.UNIVERSAL,type:m.Type.OID,constructed:!1,capture:"oid"},{name:"Attribute.attrValues",tagClass:m.Class.UNIVERSAL,type:m.Type.SET,constructed:!0,capture:"values"}]},kc={name:"CertBag",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"CertBag.certId",tagClass:m.Class.UNIVERSAL,type:m.Type.OID,constructed:!1,capture:"certId"},{name:"CertBag.certValue",tagClass:m.Class.CONTEXT_SPECIFIC,constructed:!0,value:[{name:"CertBag.certValue[0]",tagClass:m.Class.UNIVERSAL,type:m.Class.OCTETSTRING,constructed:!1,capture:"cert"}]}]};function Lr(e,t,a,r){for(var n=[],s=0;s<e.length;s++)for(var i=0;i<e[s].safeBags.length;i++){var o=e[s].safeBags[i];if(!(r!==void 0&&o.type!==r)){if(t===null){n.push(o);continue}o.attributes[t]!==void 0&&o.attributes[t].indexOf(a)>=0&&n.push(o)}}return n}kr.pkcs12FromAsn1=function(e,t,a){typeof t=="string"?(a=t,t=!0):t===void 0&&(t=!0);var r={},n=[];if(!m.validate(e,Nc,r,n)){var s=new Error("Cannot read PKCS#12 PFX. ASN.1 object is not an PKCS#12 PFX.");throw s.errors=s,s}var i={version:r.version.charCodeAt(0),safeContents:[],getBags:function(S){var T={},B;return"localKeyId"in S?B=S.localKeyId:"localKeyIdHex"in S&&(B=ce.util.hexToBytes(S.localKeyIdHex)),B===void 0&&!("friendlyName"in S)&&"bagType"in S&&(T[S.bagType]=Lr(i.safeContents,null,null,S.bagType)),B!==void 0&&(T.localKeyId=Lr(i.safeContents,"localKeyId",B,S.bagType)),"friendlyName"in S&&(T.friendlyName=Lr(i.safeContents,"friendlyName",S.friendlyName,S.bagType)),T},getBagsByFriendlyName:function(S,T){return Lr(i.safeContents,"friendlyName",S,T)},getBagsByLocalKeyId:function(S,T){return Lr(i.safeContents,"localKeyId",S,T)}};if(r.version.charCodeAt(0)!==3){var s=new Error("PKCS#12 PFX of version other than 3 not supported.");throw s.version=r.version.charCodeAt(0),s}if(m.derToOid(r.contentType)!==W.oids.data){var s=new Error("Only PKCS#12 PFX in password integrity mode supported.");throw s.oid=m.derToOid(r.contentType),s}var o=r.content.value[0];if(o.tagClass!==m.Class.UNIVERSAL||o.type!==m.Type.OCTETSTRING)throw new Error("PKCS#12 authSafe content data is not an OCTET STRING.");if(o=on(o),r.mac){var u=null,l=0,c=m.derToOid(r.macAlgorithm);switch(c){case W.oids.sha1:u=ce.md.sha1.create(),l=20;break;case W.oids.sha256:u=ce.md.sha256.create(),l=32;break;case W.oids.sha384:u=ce.md.sha384.create(),l=48;break;case W.oids.sha512:u=ce.md.sha512.create(),l=64;break;case W.oids.md5:u=ce.md.md5.create(),l=16;break}if(u===null)throw new Error("PKCS#12 uses unsupported MAC algorithm: "+c);var f=new ce.util.ByteBuffer(r.macSalt),g="macIterations"in r?parseInt(ce.util.bytesToHex(r.macIterations),16):1,v=kr.generateKey(a,f,3,g,l,u),y=ce.hmac.create();y.start(u,v),y.update(o.value);var x=y.getMac();if(x.getBytes()!==r.macDigest)throw new Error("PKCS#12 MAC could not be verified. Invalid password?")}else if(Array.isArray(e.value)&&e.value.length>2)throw new Error("Invalid PKCS#12. macData field present but MAC was not validated.");return Dc(i,o.value,t,a),i};function on(e){if(e.composed||e.constructed){for(var t=ce.util.createBuffer(),a=0;a<e.value.length;++a)t.putBytes(e.value[a].value);e.composed=e.constructed=!1,e.value=t.getBytes()}return e}function Dc(e,t,a,r){if(t=m.fromDer(t,a),t.tagClass!==m.Class.UNIVERSAL||t.type!==m.Type.SEQUENCE||t.constructed!==!0)throw new Error("PKCS#12 AuthenticatedSafe expected to be a SEQUENCE OF ContentInfo");for(var n=0;n<t.value.length;n++){var s=t.value[n],i={},o=[];if(!m.validate(s,Es,i,o)){var u=new Error("Cannot read ContentInfo.");throw u.errors=o,u}var l={encrypted:!1},c=null,f=i.content.value[0];switch(m.derToOid(i.contentType)){case W.oids.data:if(f.tagClass!==m.Class.UNIVERSAL||f.type!==m.Type.OCTETSTRING)throw new Error("PKCS#12 SafeContents Data is not an OCTET STRING.");c=on(f).value;break;case W.oids.encryptedData:c=Uc(f,r),l.encrypted=!0;break;default:var u=new Error("Unsupported PKCS#12 contentType.");throw u.contentType=m.derToOid(i.contentType),u}l.safeBags=Pc(c,a,r),e.safeContents.push(l)}}function Uc(e,t){var a={},r=[];if(!m.validate(e,ce.pkcs7.asn1.encryptedDataValidator,a,r)){var n=new Error("Cannot read EncryptedContentInfo.");throw n.errors=r,n}var s=m.derToOid(a.contentType);if(s!==W.oids.data){var n=new Error("PKCS#12 EncryptedContentInfo ContentType is not Data.");throw n.oid=s,n}s=m.derToOid(a.encAlgorithm);var i=W.pbe.getCipher(s,a.encParameter,t),o=on(a.encryptedContentAsn1),u=ce.util.createBuffer(o.value);if(i.update(u),!i.finish())throw new Error("Failed to decrypt PKCS#12 SafeContents.");return i.output.getBytes()}function Pc(e,t,a){if(!t&&e.length===0)return[];if(e=m.fromDer(e,t),e.tagClass!==m.Class.UNIVERSAL||e.type!==m.Type.SEQUENCE||e.constructed!==!0)throw new Error("PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag.");for(var r=[],n=0;n<e.value.length;n++){var s=e.value[n],i={},o=[];if(!m.validate(s,Rc,i,o)){var u=new Error("Cannot read SafeBag.");throw u.errors=o,u}var l={type:m.derToOid(i.bagId),attributes:Oc(i.bagAttributes)};r.push(l);var c,f,g=i.bagValue.value[0];switch(l.type){case W.oids.pkcs8ShroudedKeyBag:if(g=W.decryptPrivateKeyInfo(g,a),g===null)throw new Error("Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?");case W.oids.keyBag:try{l.key=W.privateKeyFromAsn1(g)}catch{l.key=null,l.asn1=g}continue;case W.oids.certBag:c=kc,f=function(){if(m.derToOid(i.certId)!==W.oids.x509Certificate){var y=new Error("Unsupported certificate type, only X.509 supported.");throw y.oid=m.derToOid(i.certId),y}var x=m.fromDer(i.cert,t);try{l.cert=W.certificateFromAsn1(x,!0)}catch{l.cert=null,l.asn1=x}};break;default:var u=new Error("Unsupported PKCS#12 SafeBag type.");throw u.oid=l.type,u}if(c!==void 0&&!m.validate(g,c,i,o)){var u=new Error("Cannot read PKCS#12 "+c.name);throw u.errors=o,u}f()}return r}function Oc(e){var t={};if(e!==void 0)for(var a=0;a<e.length;++a){var r={},n=[];if(!m.validate(e[a],Lc,r,n)){var s=new Error("Cannot read PKCS#12 BagAttribute.");throw s.errors=n,s}var i=m.derToOid(r.oid);if(W.oids[i]!==void 0){t[W.oids[i]]=[];for(var o=0;o<r.values.length;++o)t[W.oids[i]].push(r.values[o].value)}}return t}kr.toPkcs12Asn1=function(e,t,a,r){r=r||{},r.saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||r.encAlgorithm||"aes128","useMac"in r||(r.useMac=!0),"localKeyId"in r||(r.localKeyId=null),"generateLocalKeyId"in r||(r.generateLocalKeyId=!0);var n=r.localKeyId,s;if(n!==null)n=ce.util.hexToBytes(n);else if(r.generateLocalKeyId)if(t){var i=ce.util.isArray(t)?t[0]:t;typeof i=="string"&&(i=W.certificateFromPem(i));var o=ce.md.sha1.create();o.update(m.toDer(W.certificateToAsn1(i)).getBytes()),n=o.digest().getBytes()}else n=ce.random.getBytes(20);var u=[];n!==null&&u.push(m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(W.oids.localKeyId).getBytes()),m.create(m.Class.UNIVERSAL,m.Type.SET,!0,[m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,n)])])),"friendlyName"in r&&u.push(m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(W.oids.friendlyName).getBytes()),m.create(m.Class.UNIVERSAL,m.Type.SET,!0,[m.create(m.Class.UNIVERSAL,m.Type.BMPSTRING,!1,r.friendlyName)])])),u.length>0&&(s=m.create(m.Class.UNIVERSAL,m.Type.SET,!0,u));var l=[],c=[];t!==null&&(ce.util.isArray(t)?c=t:c=[t]);for(var f=[],g=0;g<c.length;++g){t=c[g],typeof t=="string"&&(t=W.certificateFromPem(t));var v=g===0?s:void 0,y=W.certificateToAsn1(t),x=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(W.oids.certBag).getBytes()),m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(W.oids.x509Certificate).getBytes()),m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,m.toDer(y).getBytes())])])]),v]);f.push(x)}if(f.length>0){var S=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,f),T=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(W.oids.data).getBytes()),m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,m.toDer(S).getBytes())])]);l.push(T)}var B=null;if(e!==null){var b=W.wrapRsaPrivateKey(W.privateKeyToAsn1(e));a===null?B=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(W.oids.keyBag).getBytes()),m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[b]),s]):B=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(W.oids.pkcs8ShroudedKeyBag).getBytes()),m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[W.encryptPrivateKeyInfo(b,a,r)]),s]);var P=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[B]),k=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(W.oids.data).getBytes()),m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,m.toDer(P).getBytes())])]);l.push(k)}var R=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,l),z;if(r.useMac){var o=ce.md.sha1.create(),Y=new ce.util.ByteBuffer(ce.random.getBytes(r.saltSize)),ne=r.count,e=kr.generateKey(a,Y,3,ne,20),ie=ce.hmac.create();ie.start(o,e),ie.update(m.toDer(R).getBytes());var ue=ie.getMac();z=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(W.oids.sha1).getBytes()),m.create(m.Class.UNIVERSAL,m.Type.NULL,!1,"")]),m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,ue.getBytes())]),m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,Y.getBytes()),m.create(m.Class.UNIVERSAL,m.Type.INTEGER,!1,m.integerToDer(ne).getBytes())])}return m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.INTEGER,!1,m.integerToDer(3).getBytes()),m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(W.oids.data).getBytes()),m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,m.toDer(R).getBytes())])]),z])};kr.generateKey=ce.pbe.generatePkcs12Key});var cn=F((Jh,Ss)=>{var Pt=$();lt();Lt();rn();Qt();ia();un();da();Rr();re();ga();var ln=Pt.asn1,gr=Ss.exports=Pt.pki=Pt.pki||{};gr.pemToDer=function(e){var t=Pt.pem.decode(e)[0];if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert PEM to DER; PEM is encrypted.");return Pt.util.createBuffer(t.body)};gr.privateKeyFromPem=function(e){var t=Pt.pem.decode(e)[0];if(t.type!=="PRIVATE KEY"&&t.type!=="RSA PRIVATE KEY"){var a=new Error('Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');throw a.headerType=t.type,a}if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert private key from PEM; PEM is encrypted.");var r=ln.fromDer(t.body);return gr.privateKeyFromAsn1(r)};gr.privateKeyToPem=function(e,t){var a={type:"RSA PRIVATE KEY",body:ln.toDer(gr.privateKeyToAsn1(e)).getBytes()};return Pt.pem.encode(a,{maxline:t})};gr.privateKeyInfoToPem=function(e,t){var a={type:"PRIVATE KEY",body:ln.toDer(e).getBytes()};return Pt.pem.encode(a,{maxline:t})}});var yn=F((Zh,Ns)=>{var w=$();lt();or();ta();Qt();cn();tt();fr();re();var Ca=function(e,t,a,r){var n=w.util.createBuffer(),s=e.length>>1,i=s+(e.length&1),o=e.substr(0,i),u=e.substr(s,i),l=w.util.createBuffer(),c=w.hmac.create();a=t+a;var f=Math.ceil(r/16),g=Math.ceil(r/20);c.start("MD5",o);var v=w.util.createBuffer();l.putBytes(a);for(var y=0;y<f;++y)c.start(null,null),c.update(l.getBytes()),l.putBuffer(c.digest()),c.start(null,null),c.update(l.bytes()+a),v.putBuffer(c.digest());c.start("SHA1",u);var x=w.util.createBuffer();l.clear(),l.putBytes(a);for(var y=0;y<g;++y)c.start(null,null),c.update(l.getBytes()),l.putBuffer(c.digest()),c.start(null,null),c.update(l.bytes()+a),x.putBuffer(c.digest());return n.putBytes(w.util.xorBytes(v.getBytes(),x.getBytes(),r)),n},Vc=function(e,t,a){var r=w.hmac.create();r.start("SHA1",e);var n=w.util.createBuffer();return n.putInt32(t[0]),n.putInt32(t[1]),n.putByte(a.type),n.putByte(a.version.major),n.putByte(a.version.minor),n.putInt16(a.length),n.putBytes(a.fragment.bytes()),r.update(n.getBytes()),r.digest().getBytes()},Fc=function(e,t,a){var r=!1;try{var n=e.deflate(t.fragment.getBytes());t.fragment=w.util.createBuffer(n),t.length=n.length,r=!0}catch{}return r},Kc=function(e,t,a){var r=!1;try{var n=e.inflate(t.fragment.getBytes());t.fragment=w.util.createBuffer(n),t.length=n.length,r=!0}catch{}return r},je=function(e,t){var a=0;switch(t){case 1:a=e.getByte();break;case 2:a=e.getInt16();break;case 3:a=e.getInt24();break;case 4:a=e.getInt32();break}return w.util.createBuffer(e.getBytes(a))},it=function(e,t,a){e.putInt(a.length(),t<<3),e.putBuffer(a)},p={};p.Versions={TLS_1_0:{major:3,minor:1},TLS_1_1:{major:3,minor:2},TLS_1_2:{major:3,minor:3}};p.SupportedVersions=[p.Versions.TLS_1_1,p.Versions.TLS_1_0];p.Version=p.SupportedVersions[0];p.MaxFragment=15360;p.ConnectionEnd={server:0,client:1};p.PRFAlgorithm={tls_prf_sha256:0};p.BulkCipherAlgorithm={none:null,rc4:0,des3:1,aes:2};p.CipherType={stream:0,block:1,aead:2};p.MACAlgorithm={none:null,hmac_md5:0,hmac_sha1:1,hmac_sha256:2,hmac_sha384:3,hmac_sha512:4};p.CompressionMethod={none:0,deflate:1};p.ContentType={change_cipher_spec:20,alert:21,handshake:22,application_data:23,heartbeat:24};p.HandshakeType={hello_request:0,client_hello:1,server_hello:2,certificate:11,server_key_exchange:12,certificate_request:13,server_hello_done:14,certificate_verify:15,client_key_exchange:16,finished:20};p.Alert={};p.Alert.Level={warning:1,fatal:2};p.Alert.Description={close_notify:0,unexpected_message:10,bad_record_mac:20,decryption_failed:21,record_overflow:22,decompression_failure:30,handshake_failure:40,bad_certificate:42,unsupported_certificate:43,certificate_revoked:44,certificate_expired:45,certificate_unknown:46,illegal_parameter:47,unknown_ca:48,access_denied:49,decode_error:50,decrypt_error:51,export_restriction:60,protocol_version:70,insufficient_security:71,internal_error:80,user_canceled:90,no_renegotiation:100};p.HeartbeatMessageType={heartbeat_request:1,heartbeat_response:2};p.CipherSuites={};p.getCipherSuite=function(e){var t=null;for(var a in p.CipherSuites){var r=p.CipherSuites[a];if(r.id[0]===e.charCodeAt(0)&&r.id[1]===e.charCodeAt(1)){t=r;break}}return t};p.handleUnexpected=function(e,t){var a=!e.open&&e.entity===p.ConnectionEnd.client;a||e.error(e,{message:"Unexpected message. Received TLS record out of order.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.unexpected_message}})};p.handleHelloRequest=function(e,t,a){!e.handshaking&&e.handshakes>0&&(p.queue(e,p.createAlert(e,{level:p.Alert.Level.warning,description:p.Alert.Description.no_renegotiation})),p.flush(e)),e.process()};p.parseHelloMessage=function(e,t,a){var r=null,n=e.entity===p.ConnectionEnd.client;if(a<38)e.error(e,{message:n?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.illegal_parameter}});else{var s=t.fragment,i=s.length();if(r={version:{major:s.getByte(),minor:s.getByte()},random:w.util.createBuffer(s.getBytes(32)),session_id:je(s,1),extensions:[]},n?(r.cipher_suite=s.getBytes(2),r.compression_method=s.getByte()):(r.cipher_suites=je(s,2),r.compression_methods=je(s,1)),i=a-(i-s.length()),i>0){for(var o=je(s,2);o.length()>0;)r.extensions.push({type:[o.getByte(),o.getByte()],data:je(o,2)});if(!n)for(var u=0;u<r.extensions.length;++u){var l=r.extensions[u];if(l.type[0]===0&&l.type[1]===0)for(var c=je(l.data,2);c.length()>0;){var f=c.getByte();if(f!==0)break;e.session.extensions.server_name.serverNameList.push(je(c,2).getBytes())}}}if(e.session.version&&(r.version.major!==e.session.version.major||r.version.minor!==e.session.version.minor))return e.error(e,{message:"TLS version change is disallowed during renegotiation.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.protocol_version}});if(n)e.session.cipherSuite=p.getCipherSuite(r.cipher_suite);else for(var g=w.util.createBuffer(r.cipher_suites.bytes());g.length()>0&&(e.session.cipherSuite=p.getCipherSuite(g.getBytes(2)),e.session.cipherSuite===null););if(e.session.cipherSuite===null)return e.error(e,{message:"No cipher suites in common.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.handshake_failure},cipherSuite:w.util.bytesToHex(r.cipher_suite)});n?e.session.compressionMethod=r.compression_method:e.session.compressionMethod=p.CompressionMethod.none}return r};p.createSecurityParameters=function(e,t){var a=e.entity===p.ConnectionEnd.client,r=t.random.bytes(),n=a?e.session.sp.client_random:r,s=a?r:p.createRandom().getBytes();e.session.sp={entity:e.entity,prf_algorithm:p.PRFAlgorithm.tls_prf_sha256,bulk_cipher_algorithm:null,cipher_type:null,enc_key_length:null,block_length:null,fixed_iv_length:null,record_iv_length:null,mac_algorithm:null,mac_length:null,mac_key_length:null,compression_algorithm:e.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:n,server_random:s}};p.handleServerHello=function(e,t,a){var r=p.parseHelloMessage(e,t,a);if(!e.fail){if(r.version.minor<=e.version.minor)e.version.minor=r.version.minor;else return e.error(e,{message:"Incompatible TLS version.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.protocol_version}});e.session.version=e.version;var n=r.session_id.bytes();n.length>0&&n===e.session.id?(e.expect=As,e.session.resuming=!0,e.session.sp.server_random=r.random.bytes()):(e.expect=qc,e.session.resuming=!1,p.createSecurityParameters(e,r)),e.session.id=n,e.process()}};p.handleClientHello=function(e,t,a){var r=p.parseHelloMessage(e,t,a);if(!e.fail){var n=r.session_id.bytes(),s=null;if(e.sessionCache&&(s=e.sessionCache.getSession(n),s===null?n="":(s.version.major!==r.version.major||s.version.minor>r.version.minor)&&(s=null,n="")),n.length===0&&(n=w.random.getBytes(32)),e.session.id=n,e.session.clientHelloVersion=r.version,e.session.sp={},s)e.version=e.session.version=s.version,e.session.sp=s.sp;else{for(var i,o=1;o<p.SupportedVersions.length&&(i=p.SupportedVersions[o],!(i.minor<=r.version.minor));++o);e.version={major:i.major,minor:i.minor},e.session.version=e.version}s!==null?(e.expect=pn,e.session.resuming=!0,e.session.sp.client_random=r.random.bytes()):(e.expect=e.verifyClient!==!1?jc:hn,e.session.resuming=!1,p.createSecurityParameters(e,r)),e.open=!0,p.queue(e,p.createRecord(e,{type:p.ContentType.handshake,data:p.createServerHello(e)})),e.session.resuming?(p.queue(e,p.createRecord(e,{type:p.ContentType.change_cipher_spec,data:p.createChangeCipherSpec()})),e.state.pending=p.createConnectionState(e),e.state.current.write=e.state.pending.write,p.queue(e,p.createRecord(e,{type:p.ContentType.handshake,data:p.createFinished(e)}))):(p.queue(e,p.createRecord(e,{type:p.ContentType.handshake,data:p.createCertificate(e)})),e.fail||(p.queue(e,p.createRecord(e,{type:p.ContentType.handshake,data:p.createServerKeyExchange(e)})),e.verifyClient!==!1&&p.queue(e,p.createRecord(e,{type:p.ContentType.handshake,data:p.createCertificateRequest(e)})),p.queue(e,p.createRecord(e,{type:p.ContentType.handshake,data:p.createServerHelloDone(e)})))),p.flush(e),e.process()}};p.handleCertificate=function(e,t,a){if(a<3)return e.error(e,{message:"Invalid Certificate message. Message too short.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.illegal_parameter}});var r=t.fragment,n={certificate_list:je(r,3)},s,i,o=[];try{for(;n.certificate_list.length()>0;)s=je(n.certificate_list,3),i=w.asn1.fromDer(s),s=w.pki.certificateFromAsn1(i,!0),o.push(s)}catch(l){return e.error(e,{message:"Could not parse certificate list.",cause:l,send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.bad_certificate}})}var u=e.entity===p.ConnectionEnd.client;(u||e.verifyClient===!0)&&o.length===0?e.error(e,{message:u?"No server certificate provided.":"No client certificate provided.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.illegal_parameter}}):o.length===0?e.expect=u?Ts:hn:(u?e.session.serverCertificate=o[0]:e.session.clientCertificate=o[0],p.verifyCertificateChain(e,o)&&(e.expect=u?Ts:hn)),e.process()};p.handleServerKeyExchange=function(e,t,a){if(a>0)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.unsupported_certificate}});e.expect=Hc,e.process()};p.handleClientKeyExchange=function(e,t,a){if(a<48)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.unsupported_certificate}});var r=t.fragment,n={enc_pre_master_secret:je(r,2).getBytes()},s=null;if(e.getPrivateKey)try{s=e.getPrivateKey(e,e.session.serverCertificate),s=w.pki.privateKeyFromPem(s)}catch(u){e.error(e,{message:"Could not get private key.",cause:u,send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.internal_error}})}if(s===null)return e.error(e,{message:"No private key set.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.internal_error}});try{var i=e.session.sp;i.pre_master_secret=s.decrypt(n.enc_pre_master_secret);var o=e.session.clientHelloVersion;if(o.major!==i.pre_master_secret.charCodeAt(0)||o.minor!==i.pre_master_secret.charCodeAt(1))throw new Error("TLS version rollback attack detected.")}catch{i.pre_master_secret=w.random.getBytes(48)}e.expect=pn,e.session.clientCertificate!==null&&(e.expect=Wc),e.process()};p.handleCertificateRequest=function(e,t,a){if(a<3)return e.error(e,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.illegal_parameter}});var r=t.fragment,n={certificate_types:je(r,1),certificate_authorities:je(r,2)};e.session.certificateRequest=n,e.expect=Gc,e.process()};p.handleCertificateVerify=function(e,t,a){if(a<2)return e.error(e,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.illegal_parameter}});var r=t.fragment;r.read-=4;var n=r.bytes();r.read+=4;var s={signature:je(r,2).getBytes()},i=w.util.createBuffer();i.putBuffer(e.session.md5.digest()),i.putBuffer(e.session.sha1.digest()),i=i.getBytes();try{var o=e.session.clientCertificate;if(!o.publicKey.verify(i,s.signature,"NONE"))throw new Error("CertificateVerify signature does not match.");e.session.md5.update(n),e.session.sha1.update(n)}catch{return e.error(e,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.handshake_failure}})}e.expect=pn,e.process()};p.handleServerHelloDone=function(e,t,a){if(a>0)return e.error(e,{message:"Invalid ServerHelloDone message. Invalid length.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.record_overflow}});if(e.serverCertificate===null){var r={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.insufficient_security}},n=0,s=e.verify(e,r.alert.description,n,[]);if(s!==!0)return(s||s===0)&&(typeof s=="object"&&!w.util.isArray(s)?(s.message&&(r.message=s.message),s.alert&&(r.alert.description=s.alert)):typeof s=="number"&&(r.alert.description=s)),e.error(e,r)}e.session.certificateRequest!==null&&(t=p.createRecord(e,{type:p.ContentType.handshake,data:p.createCertificate(e)}),p.queue(e,t)),t=p.createRecord(e,{type:p.ContentType.handshake,data:p.createClientKeyExchange(e)}),p.queue(e,t),e.expect=$c;var i=function(o,u){o.session.certificateRequest!==null&&o.session.clientCertificate!==null&&p.queue(o,p.createRecord(o,{type:p.ContentType.handshake,data:p.createCertificateVerify(o,u)})),p.queue(o,p.createRecord(o,{type:p.ContentType.change_cipher_spec,data:p.createChangeCipherSpec()})),o.state.pending=p.createConnectionState(o),o.state.current.write=o.state.pending.write,p.queue(o,p.createRecord(o,{type:p.ContentType.handshake,data:p.createFinished(o)})),o.expect=As,p.flush(o),o.process()};if(e.session.certificateRequest===null||e.session.clientCertificate===null)return i(e,null);p.getClientSignature(e,i)};p.handleChangeCipherSpec=function(e,t){if(t.fragment.getByte()!==1)return e.error(e,{message:"Invalid ChangeCipherSpec message received.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.illegal_parameter}});var a=e.entity===p.ConnectionEnd.client;(e.session.resuming&&a||!e.session.resuming&&!a)&&(e.state.pending=p.createConnectionState(e)),e.state.current.read=e.state.pending.read,(!e.session.resuming&&a||e.session.resuming&&!a)&&(e.state.pending=null),e.expect=a?zc:Xc,e.process()};p.handleFinished=function(e,t,a){var r=t.fragment;r.read-=4;var n=r.bytes();r.read+=4;var s=t.fragment.getBytes();r=w.util.createBuffer(),r.putBuffer(e.session.md5.digest()),r.putBuffer(e.session.sha1.digest());var i=e.entity===p.ConnectionEnd.client,o=i?"server finished":"client finished",u=e.session.sp,l=12,c=Ca;if(r=c(u.master_secret,o,r.getBytes(),l),r.getBytes()!==s)return e.error(e,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.decrypt_error}});e.session.md5.update(n),e.session.sha1.update(n),(e.session.resuming&&i||!e.session.resuming&&!i)&&(p.queue(e,p.createRecord(e,{type:p.ContentType.change_cipher_spec,data:p.createChangeCipherSpec()})),e.state.current.write=e.state.pending.write,e.state.pending=null,p.queue(e,p.createRecord(e,{type:p.ContentType.handshake,data:p.createFinished(e)}))),e.expect=i?Qc:Jc,e.handshaking=!1,++e.handshakes,e.peerCertificate=i?e.session.serverCertificate:e.session.clientCertificate,p.flush(e),e.isConnected=!0,e.connected(e),e.process()};p.handleAlert=function(e,t){var a=t.fragment,r={level:a.getByte(),description:a.getByte()},n;switch(r.description){case p.Alert.Description.close_notify:n="Connection closed.";break;case p.Alert.Description.unexpected_message:n="Unexpected message.";break;case p.Alert.Description.bad_record_mac:n="Bad record MAC.";break;case p.Alert.Description.decryption_failed:n="Decryption failed.";break;case p.Alert.Description.record_overflow:n="Record overflow.";break;case p.Alert.Description.decompression_failure:n="Decompression failed.";break;case p.Alert.Description.handshake_failure:n="Handshake failure.";break;case p.Alert.Description.bad_certificate:n="Bad certificate.";break;case p.Alert.Description.unsupported_certificate:n="Unsupported certificate.";break;case p.Alert.Description.certificate_revoked:n="Certificate revoked.";break;case p.Alert.Description.certificate_expired:n="Certificate expired.";break;case p.Alert.Description.certificate_unknown:n="Certificate unknown.";break;case p.Alert.Description.illegal_parameter:n="Illegal parameter.";break;case p.Alert.Description.unknown_ca:n="Unknown certificate authority.";break;case p.Alert.Description.access_denied:n="Access denied.";break;case p.Alert.Description.decode_error:n="Decode error.";break;case p.Alert.Description.decrypt_error:n="Decrypt error.";break;case p.Alert.Description.export_restriction:n="Export restriction.";break;case p.Alert.Description.protocol_version:n="Unsupported protocol version.";break;case p.Alert.Description.insufficient_security:n="Insufficient security.";break;case p.Alert.Description.internal_error:n="Internal error.";break;case p.Alert.Description.user_canceled:n="User canceled.";break;case p.Alert.Description.no_renegotiation:n="Renegotiation not supported.";break;default:n="Unknown error.";break}if(r.description===p.Alert.Description.close_notify)return e.close();e.error(e,{message:n,send:!1,origin:e.entity===p.ConnectionEnd.client?"server":"client",alert:r}),e.process()};p.handleHandshake=function(e,t){var a=t.fragment,r=a.getByte(),n=a.getInt24();if(n>a.length())return e.fragmented=t,t.fragment=w.util.createBuffer(),a.read-=4,e.process();e.fragmented=null,a.read-=4;var s=a.bytes(n+4);a.read+=4,r in ma[e.entity][e.expect]?(e.entity===p.ConnectionEnd.server&&!e.open&&!e.fail&&(e.handshaking=!0,e.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:w.md.md5.create(),sha1:w.md.sha1.create()}),r!==p.HandshakeType.hello_request&&r!==p.HandshakeType.certificate_verify&&r!==p.HandshakeType.finished&&(e.session.md5.update(s),e.session.sha1.update(s)),ma[e.entity][e.expect][r](e,t,n)):p.handleUnexpected(e,t)};p.handleApplicationData=function(e,t){e.data.putBuffer(t.fragment),e.dataReady(e),e.process()};p.handleHeartbeat=function(e,t){var a=t.fragment,r=a.getByte(),n=a.getInt16(),s=a.getBytes(n);if(r===p.HeartbeatMessageType.heartbeat_request){if(e.handshaking||n>s.length)return e.process();p.queue(e,p.createRecord(e,{type:p.ContentType.heartbeat,data:p.createHeartbeat(p.HeartbeatMessageType.heartbeat_response,s)})),p.flush(e)}else if(r===p.HeartbeatMessageType.heartbeat_response){if(s!==e.expectedHeartbeatPayload)return e.process();e.heartbeatReceived&&e.heartbeatReceived(e,w.util.createBuffer(s))}e.process()};var Mc=0,qc=1,Ts=2,Hc=3,Gc=4,As=5,zc=6,Qc=7,$c=8,Yc=0,jc=1,hn=2,Wc=3,pn=4,Xc=5,Jc=6,h=p.handleUnexpected,Bs=p.handleChangeCipherSpec,Ae=p.handleAlert,ze=p.handleHandshake,bs=p.handleApplicationData,Be=p.handleHeartbeat,gn=[];gn[p.ConnectionEnd.client]=[[h,Ae,ze,h,Be],[h,Ae,ze,h,Be],[h,Ae,ze,h,Be],[h,Ae,ze,h,Be],[h,Ae,ze,h,Be],[Bs,Ae,h,h,Be],[h,Ae,ze,h,Be],[h,Ae,ze,bs,Be],[h,Ae,ze,h,Be]];gn[p.ConnectionEnd.server]=[[h,Ae,ze,h,Be],[h,Ae,ze,h,Be],[h,Ae,ze,h,Be],[h,Ae,ze,h,Be],[Bs,Ae,h,h,Be],[h,Ae,ze,h,Be],[h,Ae,ze,bs,Be],[h,Ae,ze,h,Be]];var Ot=p.handleHelloRequest,Zc=p.handleServerHello,_s=p.handleCertificate,Is=p.handleServerKeyExchange,fn=p.handleCertificateRequest,ya=p.handleServerHelloDone,ws=p.handleFinished,ma=[];ma[p.ConnectionEnd.client]=[[h,h,Zc,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h],[Ot,h,h,h,h,h,h,h,h,h,h,_s,Is,fn,ya,h,h,h,h,h,h],[Ot,h,h,h,h,h,h,h,h,h,h,h,Is,fn,ya,h,h,h,h,h,h],[Ot,h,h,h,h,h,h,h,h,h,h,h,h,fn,ya,h,h,h,h,h,h],[Ot,h,h,h,h,h,h,h,h,h,h,h,h,h,ya,h,h,h,h,h,h],[Ot,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h],[Ot,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,ws],[Ot,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h],[Ot,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h]];var ef=p.handleClientHello,tf=p.handleClientKeyExchange,rf=p.handleCertificateVerify;ma[p.ConnectionEnd.server]=[[h,ef,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h],[h,h,h,h,h,h,h,h,h,h,h,_s,h,h,h,h,h,h,h,h,h],[h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,tf,h,h,h,h],[h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,rf,h,h,h,h,h],[h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h],[h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,ws],[h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h],[h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h]];p.generateKeys=function(e,t){var a=Ca,r=t.client_random+t.server_random;e.session.resuming||(t.master_secret=a(t.pre_master_secret,"master secret",r,48).bytes(),t.pre_master_secret=null),r=t.server_random+t.client_random;var n=2*t.mac_key_length+2*t.enc_key_length,s=e.version.major===p.Versions.TLS_1_0.major&&e.version.minor===p.Versions.TLS_1_0.minor;s&&(n+=2*t.fixed_iv_length);var i=a(t.master_secret,"key expansion",r,n),o={client_write_MAC_key:i.getBytes(t.mac_key_length),server_write_MAC_key:i.getBytes(t.mac_key_length),client_write_key:i.getBytes(t.enc_key_length),server_write_key:i.getBytes(t.enc_key_length)};return s&&(o.client_write_IV=i.getBytes(t.fixed_iv_length),o.server_write_IV=i.getBytes(t.fixed_iv_length)),o};p.createConnectionState=function(e){var t=e.entity===p.ConnectionEnd.client,a=function(){var s={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(i){return!0},compressionState:null,compressFunction:function(i){return!0},updateSequenceNumber:function(){s.sequenceNumber[1]===4294967295?(s.sequenceNumber[1]=0,++s.sequenceNumber[0]):++s.sequenceNumber[1]}};return s},r={read:a(),write:a()};if(r.read.update=function(s,i){return r.read.cipherFunction(i,r.read)?r.read.compressFunction(s,i,r.read)||s.error(s,{message:"Could not decompress record.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.decompression_failure}}):s.error(s,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.bad_record_mac}}),!s.fail},r.write.update=function(s,i){return r.write.compressFunction(s,i,r.write)?r.write.cipherFunction(i,r.write)||s.error(s,{message:"Could not encrypt record.",send:!1,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.internal_error}}):s.error(s,{message:"Could not compress record.",send:!1,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.internal_error}}),!s.fail},e.session){var n=e.session.sp;switch(e.session.cipherSuite.initSecurityParameters(n),n.keys=p.generateKeys(e,n),r.read.macKey=t?n.keys.server_write_MAC_key:n.keys.client_write_MAC_key,r.write.macKey=t?n.keys.client_write_MAC_key:n.keys.server_write_MAC_key,e.session.cipherSuite.initConnectionState(r,e,n),n.compression_algorithm){case p.CompressionMethod.none:break;case p.CompressionMethod.deflate:r.read.compressFunction=Kc,r.write.compressFunction=Fc;break;default:throw new Error("Unsupported compression algorithm.")}}return r};p.createRandom=function(){var e=new Date,t=+e+e.getTimezoneOffset()*6e4,a=w.util.createBuffer();return a.putInt32(t),a.putBytes(w.random.getBytes(28)),a};p.createRecord=function(e,t){if(!t.data)return null;var a={type:t.type,version:{major:e.version.major,minor:e.version.minor},length:t.data.length(),fragment:t.data};return a};p.createAlert=function(e,t){var a=w.util.createBuffer();return a.putByte(t.level),a.putByte(t.description),p.createRecord(e,{type:p.ContentType.alert,data:a})};p.createClientHello=function(e){e.session.clientHelloVersion={major:e.version.major,minor:e.version.minor};for(var t=w.util.createBuffer(),a=0;a<e.cipherSuites.length;++a){var r=e.cipherSuites[a];t.putByte(r.id[0]),t.putByte(r.id[1])}var n=t.length(),s=w.util.createBuffer();s.putByte(p.CompressionMethod.none);var i=s.length(),o=w.util.createBuffer();if(e.virtualHost){var u=w.util.createBuffer();u.putByte(0),u.putByte(0);var l=w.util.createBuffer();l.putByte(0),it(l,2,w.util.createBuffer(e.virtualHost));var c=w.util.createBuffer();it(c,2,l),it(u,2,c),o.putBuffer(u)}var f=o.length();f>0&&(f+=2);var g=e.session.id,v=g.length+1+2+4+28+2+n+1+i+f,y=w.util.createBuffer();return y.putByte(p.HandshakeType.client_hello),y.putInt24(v),y.putByte(e.version.major),y.putByte(e.version.minor),y.putBytes(e.session.sp.client_random),it(y,1,w.util.createBuffer(g)),it(y,2,t),it(y,1,s),f>0&&it(y,2,o),y};p.createServerHello=function(e){var t=e.session.id,a=t.length+1+2+4+28+2+1,r=w.util.createBuffer();return r.putByte(p.HandshakeType.server_hello),r.putInt24(a),r.putByte(e.version.major),r.putByte(e.version.minor),r.putBytes(e.session.sp.server_random),it(r,1,w.util.createBuffer(t)),r.putByte(e.session.cipherSuite.id[0]),r.putByte(e.session.cipherSuite.id[1]),r.putByte(e.session.compressionMethod),r};p.createCertificate=function(e){var t=e.entity===p.ConnectionEnd.client,a=null;if(e.getCertificate){var r;t?r=e.session.certificateRequest:r=e.session.extensions.server_name.serverNameList,a=e.getCertificate(e,r)}var n=w.util.createBuffer();if(a!==null)try{w.util.isArray(a)||(a=[a]);for(var s=null,i=0;i<a.length;++i){var o=w.pem.decode(a[i])[0];if(o.type!=="CERTIFICATE"&&o.type!=="X509 CERTIFICATE"&&o.type!=="TRUSTED CERTIFICATE"){var u=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw u.headerType=o.type,u}if(o.procType&&o.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var l=w.util.createBuffer(o.body);s===null&&(s=w.asn1.fromDer(l.bytes(),!1));var c=w.util.createBuffer();it(c,3,l),n.putBuffer(c)}a=w.pki.certificateFromAsn1(s),t?e.session.clientCertificate=a:e.session.serverCertificate=a}catch(v){return e.error(e,{message:"Could not send certificate list.",cause:v,send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.bad_certificate}})}var f=3+n.length(),g=w.util.createBuffer();return g.putByte(p.HandshakeType.certificate),g.putInt24(f),it(g,3,n),g};p.createClientKeyExchange=function(e){var t=w.util.createBuffer();t.putByte(e.session.clientHelloVersion.major),t.putByte(e.session.clientHelloVersion.minor),t.putBytes(w.random.getBytes(46));var a=e.session.sp;a.pre_master_secret=t.getBytes();var r=e.session.serverCertificate.publicKey;t=r.encrypt(a.pre_master_secret);var n=t.length+2,s=w.util.createBuffer();return s.putByte(p.HandshakeType.client_key_exchange),s.putInt24(n),s.putInt16(t.length),s.putBytes(t),s};p.createServerKeyExchange=function(e){var t=0,a=w.util.createBuffer();return t>0&&(a.putByte(p.HandshakeType.server_key_exchange),a.putInt24(t)),a};p.getClientSignature=function(e,t){var a=w.util.createBuffer();a.putBuffer(e.session.md5.digest()),a.putBuffer(e.session.sha1.digest()),a=a.getBytes(),e.getSignature=e.getSignature||function(r,n,s){var i=null;if(r.getPrivateKey)try{i=r.getPrivateKey(r,r.session.clientCertificate),i=w.pki.privateKeyFromPem(i)}catch(o){r.error(r,{message:"Could not get private key.",cause:o,send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.internal_error}})}i===null?r.error(r,{message:"No private key set.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.internal_error}}):n=i.sign(n,null),s(r,n)},e.getSignature(e,a,t)};p.createCertificateVerify=function(e,t){var a=t.length+2,r=w.util.createBuffer();return r.putByte(p.HandshakeType.certificate_verify),r.putInt24(a),r.putInt16(t.length),r.putBytes(t),r};p.createCertificateRequest=function(e){var t=w.util.createBuffer();t.putByte(1);var a=w.util.createBuffer();for(var r in e.caStore.certs){var n=e.caStore.certs[r],s=w.pki.distinguishedNameToAsn1(n.subject),i=w.asn1.toDer(s);a.putInt16(i.length()),a.putBuffer(i)}var o=1+t.length()+2+a.length(),u=w.util.createBuffer();return u.putByte(p.HandshakeType.certificate_request),u.putInt24(o),it(u,1,t),it(u,2,a),u};p.createServerHelloDone=function(e){var t=w.util.createBuffer();return t.putByte(p.HandshakeType.server_hello_done),t.putInt24(0),t};p.createChangeCipherSpec=function(){var e=w.util.createBuffer();return e.putByte(1),e};p.createFinished=function(e){var t=w.util.createBuffer();t.putBuffer(e.session.md5.digest()),t.putBuffer(e.session.sha1.digest());var a=e.entity===p.ConnectionEnd.client,r=e.session.sp,n=12,s=Ca,i=a?"client finished":"server finished";t=s(r.master_secret,i,t.getBytes(),n);var o=w.util.createBuffer();return o.putByte(p.HandshakeType.finished),o.putInt24(t.length()),o.putBuffer(t),o};p.createHeartbeat=function(e,t,a){typeof a>"u"&&(a=t.length);var r=w.util.createBuffer();r.putByte(e),r.putInt16(a),r.putBytes(t);var n=r.length(),s=Math.max(16,n-a-3);return r.putBytes(w.random.getBytes(s)),r};p.queue=function(e,t){if(t&&!(t.fragment.length()===0&&(t.type===p.ContentType.handshake||t.type===p.ContentType.alert||t.type===p.ContentType.change_cipher_spec))){if(t.type===p.ContentType.handshake){var a=t.fragment.bytes();e.session.md5.update(a),e.session.sha1.update(a),a=null}var r;if(t.fragment.length()<=p.MaxFragment)r=[t];else{r=[];for(var n=t.fragment.bytes();n.length>p.MaxFragment;)r.push(p.createRecord(e,{type:t.type,data:w.util.createBuffer(n.slice(0,p.MaxFragment))})),n=n.slice(p.MaxFragment);n.length>0&&r.push(p.createRecord(e,{type:t.type,data:w.util.createBuffer(n)}))}for(var s=0;s<r.length&&!e.fail;++s){var i=r[s],o=e.state.current.write;o.update(e,i)&&e.records.push(i)}}};p.flush=function(e){for(var t=0;t<e.records.length;++t){var a=e.records[t];e.tlsData.putByte(a.type),e.tlsData.putByte(a.version.major),e.tlsData.putByte(a.version.minor),e.tlsData.putInt16(a.fragment.length()),e.tlsData.putBuffer(e.records[t].fragment)}return e.records=[],e.tlsDataReady(e)};var dn=function(e){switch(e){case!0:return!0;case w.pki.certificateError.bad_certificate:return p.Alert.Description.bad_certificate;case w.pki.certificateError.unsupported_certificate:return p.Alert.Description.unsupported_certificate;case w.pki.certificateError.certificate_revoked:return p.Alert.Description.certificate_revoked;case w.pki.certificateError.certificate_expired:return p.Alert.Description.certificate_expired;case w.pki.certificateError.certificate_unknown:return p.Alert.Description.certificate_unknown;case w.pki.certificateError.unknown_ca:return p.Alert.Description.unknown_ca;default:return p.Alert.Description.bad_certificate}},af=function(e){switch(e){case!0:return!0;case p.Alert.Description.bad_certificate:return w.pki.certificateError.bad_certificate;case p.Alert.Description.unsupported_certificate:return w.pki.certificateError.unsupported_certificate;case p.Alert.Description.certificate_revoked:return w.pki.certificateError.certificate_revoked;case p.Alert.Description.certificate_expired:return w.pki.certificateError.certificate_expired;case p.Alert.Description.certificate_unknown:return w.pki.certificateError.certificate_unknown;case p.Alert.Description.unknown_ca:return w.pki.certificateError.unknown_ca;default:return w.pki.certificateError.bad_certificate}};p.verifyCertificateChain=function(e,t){try{var a={};for(var r in e.verifyOptions)a[r]=e.verifyOptions[r];a.verify=function(s,i,o){var u=dn(s),l=e.verify(e,s,i,o);if(l!==!0){if(typeof l=="object"&&!w.util.isArray(l)){var c=new Error("The application rejected the certificate.");throw c.send=!0,c.alert={level:p.Alert.Level.fatal,description:p.Alert.Description.bad_certificate},l.message&&(c.message=l.message),l.alert&&(c.alert.description=l.alert),c}l!==s&&(l=af(l))}return l},w.pki.verifyCertificateChain(e.caStore,t,a)}catch(s){var n=s;(typeof n!="object"||w.util.isArray(n))&&(n={send:!0,alert:{level:p.Alert.Level.fatal,description:dn(s)}}),"send"in n||(n.send=!0),"alert"in n||(n.alert={level:p.Alert.Level.fatal,description:dn(n.error)}),e.error(e,n)}return!e.fail};p.createSessionCache=function(e,t){var a=null;if(e&&e.getSession&&e.setSession&&e.order)a=e;else{a={},a.cache=e||{},a.capacity=Math.max(t||100,1),a.order=[];for(var r in e)a.order.length<=t?a.order.push(r):delete e[r];a.getSession=function(n){var s=null,i=null;if(n?i=w.util.bytesToHex(n):a.order.length>0&&(i=a.order[0]),i!==null&&i in a.cache){s=a.cache[i],delete a.cache[i];for(var o in a.order)if(a.order[o]===i){a.order.splice(o,1);break}}return s},a.setSession=function(n,s){if(a.order.length===a.capacity){var i=a.order.shift();delete a.cache[i]}var i=w.util.bytesToHex(n);a.order.push(i),a.cache[i]=s}}return a};p.createConnection=function(e){var t=null;e.caStore?w.util.isArray(e.caStore)?t=w.pki.createCaStore(e.caStore):t=e.caStore:t=w.pki.createCaStore();var a=e.cipherSuites||null;if(a===null){a=[];for(var r in p.CipherSuites)a.push(p.CipherSuites[r])}var n=e.server?p.ConnectionEnd.server:p.ConnectionEnd.client,s=e.sessionCache?p.createSessionCache(e.sessionCache):null,i={version:{major:p.Version.major,minor:p.Version.minor},entity:n,sessionId:e.sessionId,caStore:t,sessionCache:s,cipherSuites:a,connected:e.connected,virtualHost:e.virtualHost||null,verifyClient:e.verifyClient||!1,verify:e.verify||function(c,f,g,v){return f},verifyOptions:e.verifyOptions||{},getCertificate:e.getCertificate||null,getPrivateKey:e.getPrivateKey||null,getSignature:e.getSignature||null,input:w.util.createBuffer(),tlsData:w.util.createBuffer(),data:w.util.createBuffer(),tlsDataReady:e.tlsDataReady,dataReady:e.dataReady,heartbeatReceived:e.heartbeatReceived,closed:e.closed,error:function(c,f){f.origin=f.origin||(c.entity===p.ConnectionEnd.client?"client":"server"),f.send&&(p.queue(c,p.createAlert(c,f.alert)),p.flush(c));var g=f.fatal!==!1;g&&(c.fail=!0),e.error(c,f),g&&c.close(!1)},deflate:e.deflate||null,inflate:e.inflate||null};i.reset=function(c){i.version={major:p.Version.major,minor:p.Version.minor},i.record=null,i.session=null,i.peerCertificate=null,i.state={pending:null,current:null},i.expect=i.entity===p.ConnectionEnd.client?Mc:Yc,i.fragmented=null,i.records=[],i.open=!1,i.handshakes=0,i.handshaking=!1,i.isConnected=!1,i.fail=!(c||typeof c>"u"),i.input.clear(),i.tlsData.clear(),i.data.clear(),i.state.current=p.createConnectionState(i)},i.reset();var o=function(c,f){var g=f.type-p.ContentType.change_cipher_spec,v=gn[c.entity][c.expect];g in v?v[g](c,f):p.handleUnexpected(c,f)},u=function(c){var f=0,g=c.input,v=g.length();if(v<5)f=5-v;else{c.record={type:g.getByte(),version:{major:g.getByte(),minor:g.getByte()},length:g.getInt16(),fragment:w.util.createBuffer(),ready:!1};var y=c.record.version.major===c.version.major;y&&c.session&&c.session.version&&(y=c.record.version.minor===c.version.minor),y||c.error(c,{message:"Incompatible TLS version.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.protocol_version}})}return f},l=function(c){var f=0,g=c.input,v=g.length();if(v<c.record.length)f=c.record.length-v;else{c.record.fragment.putBytes(g.getBytes(c.record.length)),g.compact();var y=c.state.current.read;y.update(c,c.record)&&(c.fragmented!==null&&(c.fragmented.type===c.record.type?(c.fragmented.fragment.putBuffer(c.record.fragment),c.record=c.fragmented):c.error(c,{message:"Invalid fragmented record.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.unexpected_message}})),c.record.ready=!0)}return f};return i.handshake=function(c){if(i.entity!==p.ConnectionEnd.client)i.error(i,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(i.handshaking)i.error(i,{message:"Handshake already in progress.",fatal:!1});else{i.fail&&!i.open&&i.handshakes===0&&(i.fail=!1),i.handshaking=!0,c=c||"";var f=null;c.length>0&&(i.sessionCache&&(f=i.sessionCache.getSession(c)),f===null&&(c="")),c.length===0&&i.sessionCache&&(f=i.sessionCache.getSession(),f!==null&&(c=f.id)),i.session={id:c,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:w.md.md5.create(),sha1:w.md.sha1.create()},f&&(i.version=f.version,i.session.sp=f.sp),i.session.sp.client_random=p.createRandom().getBytes(),i.open=!0,p.queue(i,p.createRecord(i,{type:p.ContentType.handshake,data:p.createClientHello(i)})),p.flush(i)}},i.process=function(c){var f=0;return c&&i.input.putBytes(c),i.fail||(i.record!==null&&i.record.ready&&i.record.fragment.isEmpty()&&(i.record=null),i.record===null&&(f=u(i)),!i.fail&&i.record!==null&&!i.record.ready&&(f=l(i)),!i.fail&&i.record!==null&&i.record.ready&&o(i,i.record)),f},i.prepare=function(c){return p.queue(i,p.createRecord(i,{type:p.ContentType.application_data,data:w.util.createBuffer(c)})),p.flush(i)},i.prepareHeartbeatRequest=function(c,f){return c instanceof w.util.ByteBuffer&&(c=c.bytes()),typeof f>"u"&&(f=c.length),i.expectedHeartbeatPayload=c,p.queue(i,p.createRecord(i,{type:p.ContentType.heartbeat,data:p.createHeartbeat(p.HeartbeatMessageType.heartbeat_request,c,f)})),p.flush(i)},i.close=function(c){if(!i.fail&&i.sessionCache&&i.session){var f={id:i.session.id,version:i.session.version,sp:i.session.sp};f.sp.keys=null,i.sessionCache.setSession(f.id,f)}i.open&&(i.open=!1,i.input.clear(),(i.isConnected||i.handshaking)&&(i.isConnected=i.handshaking=!1,p.queue(i,p.createAlert(i,{level:p.Alert.Level.warning,description:p.Alert.Description.close_notify})),p.flush(i)),i.closed(i)),i.reset(c)},i};Ns.exports=w.tls=w.tls||{};for(va in p)typeof p[va]!="function"&&(w.tls[va]=p[va]);var va;w.tls.prf_tls1=Ca;w.tls.hmac_sha1=Vc;w.tls.createSessionCache=p.createSessionCache;w.tls.createConnection=p.createConnection});var ks=F((ep,Ls)=>{var Vt=$();Rt();yn();var st=Ls.exports=Vt.tls;st.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA={id:[0,47],name:"TLS_RSA_WITH_AES_128_CBC_SHA",initSecurityParameters:function(e){e.bulk_cipher_algorithm=st.BulkCipherAlgorithm.aes,e.cipher_type=st.CipherType.block,e.enc_key_length=16,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=st.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:Rs};st.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA={id:[0,53],name:"TLS_RSA_WITH_AES_256_CBC_SHA",initSecurityParameters:function(e){e.bulk_cipher_algorithm=st.BulkCipherAlgorithm.aes,e.cipher_type=st.CipherType.block,e.enc_key_length=32,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=st.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:Rs};function Rs(e,t,a){var r=t.entity===Vt.tls.ConnectionEnd.client;e.read.cipherState={init:!1,cipher:Vt.cipher.createDecipher("AES-CBC",r?a.keys.server_write_key:a.keys.client_write_key),iv:r?a.keys.server_write_IV:a.keys.client_write_IV},e.write.cipherState={init:!1,cipher:Vt.cipher.createCipher("AES-CBC",r?a.keys.client_write_key:a.keys.server_write_key),iv:r?a.keys.client_write_IV:a.keys.server_write_IV},e.read.cipherFunction=uf,e.write.cipherFunction=nf,e.read.macLength=e.write.macLength=a.mac_length,e.read.macFunction=e.write.macFunction=st.hmac_sha1}function nf(e,t){var a=!1,r=t.macFunction(t.macKey,t.sequenceNumber,e);e.fragment.putBytes(r),t.updateSequenceNumber();var n;e.version.minor===st.Versions.TLS_1_0.minor?n=t.cipherState.init?null:t.cipherState.iv:n=Vt.random.getBytesSync(16),t.cipherState.init=!0;var s=t.cipherState.cipher;return s.start({iv:n}),e.version.minor>=st.Versions.TLS_1_1.minor&&s.output.putBytes(n),s.update(e.fragment),s.finish(sf)&&(e.fragment=s.output,e.length=e.fragment.length(),a=!0),a}function sf(e,t,a){if(!a){var r=e-t.length()%e;t.fillWithByte(r-1,r)}return!0}function of(e,t,a){var r=!0;if(a){for(var n=t.length(),s=t.last(),i=n-1-s;i<n-1;++i)r=r&&t.at(i)==s;r&&t.truncate(s+1)}return r}function uf(e,t){var a=!1,r;e.version.minor===st.Versions.TLS_1_0.minor?r=t.cipherState.init?null:t.cipherState.iv:r=e.fragment.getBytes(16),t.cipherState.init=!0;var n=t.cipherState.cipher;n.start({iv:r}),n.update(e.fragment),a=n.finish(of);var s=t.macLength,i=Vt.random.getBytesSync(s),o=n.output.length();o>=s?(e.fragment=n.output.getBytes(o-s),i=n.output.getBytes(s)):e.fragment=n.output.getBytes(),e.fragment=Vt.util.createBuffer(e.fragment),e.length=e.fragment.length();var u=t.macFunction(t.macKey,t.sequenceNumber,e);return t.updateSequenceNumber(),a=lf(t.macKey,i,u)&&a,a}function lf(e,t,a){var r=Vt.hmac.create();return r.start("SHA1",e),r.update(t),t=r.digest().getBytes(),r.start(null,null),r.update(a),a=r.digest().getBytes(),t===a}});var Cn=F((tp,Os)=>{var he=$();ft();re();var Dr=Os.exports=he.sha512=he.sha512||{};he.md.sha512=he.md.algorithms.sha512=Dr;var Us=he.sha384=he.sha512.sha384=he.sha512.sha384||{};Us.create=function(){return Dr.create("SHA-384")};he.md.sha384=he.md.algorithms.sha384=Us;he.sha512.sha256=he.sha512.sha256||{create:function(){return Dr.create("SHA-512/256")}};he.md["sha512/256"]=he.md.algorithms["sha512/256"]=he.sha512.sha256;he.sha512.sha224=he.sha512.sha224||{create:function(){return Dr.create("SHA-512/224")}};he.md["sha512/224"]=he.md.algorithms["sha512/224"]=he.sha512.sha224;Dr.create=function(e){if(Ps||cf(),typeof e>"u"&&(e="SHA-512"),!(e in Jt))throw new Error("Invalid SHA-512 algorithm: "+e);for(var t=Jt[e],a=null,r=he.util.createBuffer(),n=new Array(80),s=0;s<80;++s)n[s]=new Array(2);var i=64;switch(e){case"SHA-384":i=48;break;case"SHA-512/256":i=32;break;case"SHA-512/224":i=28;break}var o={algorithm:e.replace("-","").toLowerCase(),blockLength:128,digestLength:i,messageLength:0,fullMessageLength:null,messageLengthSize:16};return o.start=function(){o.messageLength=0,o.fullMessageLength=o.messageLength128=[];for(var u=o.messageLengthSize/4,l=0;l<u;++l)o.fullMessageLength.push(0);r=he.util.createBuffer(),a=new Array(t.length);for(var l=0;l<t.length;++l)a[l]=t[l].slice(0);return o},o.start(),o.update=function(u,l){l==="utf8"&&(u=he.util.encodeUtf8(u));var c=u.length;o.messageLength+=c,c=[c/4294967296>>>0,c>>>0];for(var f=o.fullMessageLength.length-1;f>=0;--f)o.fullMessageLength[f]+=c[1],c[1]=c[0]+(o.fullMessageLength[f]/4294967296>>>0),o.fullMessageLength[f]=o.fullMessageLength[f]>>>0,c[0]=c[1]/4294967296>>>0;return r.putBytes(u),Ds(a,n,r),(r.read>2048||r.length()===0)&&r.compact(),o},o.digest=function(){var u=he.util.createBuffer();u.putBytes(r.bytes());var l=o.fullMessageLength[o.fullMessageLength.length-1]+o.messageLengthSize,c=l&o.blockLength-1;u.putBytes(vn.substr(0,o.blockLength-c));for(var f,g,v=o.fullMessageLength[0]*8,y=0;y<o.fullMessageLength.length-1;++y)f=o.fullMessageLength[y+1]*8,g=f/4294967296>>>0,v+=g,u.putInt32(v>>>0),v=f>>>0;u.putInt32(v);for(var x=new Array(a.length),y=0;y<a.length;++y)x[y]=a[y].slice(0);Ds(x,n,u);var S=he.util.createBuffer(),T;e==="SHA-512"?T=x.length:e==="SHA-384"?T=x.length-2:T=x.length-4;for(var y=0;y<T;++y)S.putInt32(x[y][0]),(y!==T-1||e!=="SHA-512/224")&&S.putInt32(x[y][1]);return S},o};var vn=null,Ps=!1,mn=null,Jt=null;function cf(){vn="\x80",vn+=he.util.fillString("\0",128),mn=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],Jt={},Jt["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],Jt["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],Jt["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],Jt["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],Ps=!0}function Ds(e,t,a){for(var r,n,s,i,o,u,l,c,f,g,v,y,x,S,T,B,b,P,k,R,z,Y,ne,ie,ue,fe,qe,et,se,ye,K,qt,ar,ve,me,Ee=a.length();Ee>=128;){for(se=0;se<16;++se)t[se][0]=a.getInt32()>>>0,t[se][1]=a.getInt32()>>>0;for(;se<80;++se)qt=t[se-2],ye=qt[0],K=qt[1],r=((ye>>>19|K<<13)^(K>>>29|ye<<3)^ye>>>6)>>>0,n=((ye<<13|K>>>19)^(K<<3|ye>>>29)^(ye<<26|K>>>6))>>>0,ve=t[se-15],ye=ve[0],K=ve[1],s=((ye>>>1|K<<31)^(ye>>>8|K<<24)^ye>>>7)>>>0,i=((ye<<31|K>>>1)^(ye<<24|K>>>8)^(ye<<25|K>>>7))>>>0,ar=t[se-7],me=t[se-16],K=n+ar[1]+i+me[1],t[se][0]=r+ar[0]+s+me[0]+(K/4294967296>>>0)>>>0,t[se][1]=K>>>0;for(x=e[0][0],S=e[0][1],T=e[1][0],B=e[1][1],b=e[2][0],P=e[2][1],k=e[3][0],R=e[3][1],z=e[4][0],Y=e[4][1],ne=e[5][0],ie=e[5][1],ue=e[6][0],fe=e[6][1],qe=e[7][0],et=e[7][1],se=0;se<80;++se)l=((z>>>14|Y<<18)^(z>>>18|Y<<14)^(Y>>>9|z<<23))>>>0,c=((z<<18|Y>>>14)^(z<<14|Y>>>18)^(Y<<23|z>>>9))>>>0,f=(ue^z&(ne^ue))>>>0,g=(fe^Y&(ie^fe))>>>0,o=((x>>>28|S<<4)^(S>>>2|x<<30)^(S>>>7|x<<25))>>>0,u=((x<<4|S>>>28)^(S<<30|x>>>2)^(S<<25|x>>>7))>>>0,v=(x&T|b&(x^T))>>>0,y=(S&B|P&(S^B))>>>0,K=et+c+g+mn[se][1]+t[se][1],r=qe+l+f+mn[se][0]+t[se][0]+(K/4294967296>>>0)>>>0,n=K>>>0,K=u+y,s=o+v+(K/4294967296>>>0)>>>0,i=K>>>0,qe=ue,et=fe,ue=ne,fe=ie,ne=z,ie=Y,K=R+n,z=k+r+(K/4294967296>>>0)>>>0,Y=K>>>0,k=b,R=P,b=T,P=B,T=x,B=S,K=n+i,x=r+s+(K/4294967296>>>0)>>>0,S=K>>>0;K=e[0][1]+S,e[0][0]=e[0][0]+x+(K/4294967296>>>0)>>>0,e[0][1]=K>>>0,K=e[1][1]+B,e[1][0]=e[1][0]+T+(K/4294967296>>>0)>>>0,e[1][1]=K>>>0,K=e[2][1]+P,e[2][0]=e[2][0]+b+(K/4294967296>>>0)>>>0,e[2][1]=K>>>0,K=e[3][1]+R,e[3][0]=e[3][0]+k+(K/4294967296>>>0)>>>0,e[3][1]=K>>>0,K=e[4][1]+Y,e[4][0]=e[4][0]+z+(K/4294967296>>>0)>>>0,e[4][1]=K>>>0,K=e[5][1]+ie,e[5][0]=e[5][0]+ne+(K/4294967296>>>0)>>>0,e[5][1]=K>>>0,K=e[6][1]+fe,e[6][0]=e[6][0]+ue+(K/4294967296>>>0)>>>0,e[6][1]=K>>>0,K=e[7][1]+et,e[7][0]=e[7][0]+qe+(K/4294967296>>>0)>>>0,e[7][1]=K>>>0,Ee-=128}}});var Vs=F(En=>{var ff=$();lt();var Ie=ff.asn1;En.privateKeyValidator={name:"PrivateKeyInfo",tagClass:Ie.Class.UNIVERSAL,type:Ie.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:Ie.Class.UNIVERSAL,type:Ie.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:Ie.Class.UNIVERSAL,type:Ie.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:Ie.Class.UNIVERSAL,type:Ie.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:Ie.Class.UNIVERSAL,type:Ie.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]};En.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:Ie.Class.UNIVERSAL,type:Ie.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:Ie.Class.UNIVERSAL,type:Ie.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:Ie.Class.UNIVERSAL,type:Ie.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{tagClass:Ie.Class.UNIVERSAL,type:Ie.Type.BITSTRING,constructed:!1,composed:!0,captureBitStringValue:"ed25519PublicKey"}]}});var Xs=F((ap,Ws)=>{var be=$();Nr();tt();Cn();re();var Gs=Vs(),df=Gs.publicKeyValidator,hf=Gs.privateKeyValidator;typeof Fs>"u"&&(Fs=be.jsbn.BigInteger);var Fs,Sn=be.util.ByteBuffer,Ye=typeof Buffer>"u"?Uint8Array:Buffer;be.pki=be.pki||{};Ws.exports=be.pki.ed25519=be.ed25519=be.ed25519||{};var X=be.ed25519;X.constants={};X.constants.PUBLIC_KEY_BYTE_LENGTH=32;X.constants.PRIVATE_KEY_BYTE_LENGTH=64;X.constants.SEED_BYTE_LENGTH=32;X.constants.SIGN_BYTE_LENGTH=64;X.constants.HASH_BYTE_LENGTH=64;X.generateKeyPair=function(e){e=e||{};var t=e.seed;if(t===void 0)t=be.random.getBytesSync(X.constants.SEED_BYTE_LENGTH);else if(typeof t=="string"){if(t.length!==X.constants.SEED_BYTE_LENGTH)throw new TypeError('"seed" must be '+X.constants.SEED_BYTE_LENGTH+" bytes in length.")}else if(!(t instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, Uint8Array, or a binary string.');t=At({message:t,encoding:"binary"});for(var a=new Ye(X.constants.PUBLIC_KEY_BYTE_LENGTH),r=new Ye(X.constants.PRIVATE_KEY_BYTE_LENGTH),n=0;n<32;++n)r[n]=t[n];return vf(a,r),{publicKey:a,privateKey:r}};X.privateKeyFromAsn1=function(e){var t={},a=[],r=be.asn1.validate(e,hf,t,a);if(!r){var n=new Error("Invalid Key.");throw n.errors=a,n}var s=be.asn1.derToOid(t.privateKeyOid),i=be.oids.EdDSA25519;if(s!==i)throw new Error('Invalid OID "'+s+'"; OID must be "'+i+'".');var o=t.privateKey,u=At({message:be.asn1.fromDer(o).value,encoding:"binary"});return{privateKeyBytes:u}};X.publicKeyFromAsn1=function(e){var t={},a=[],r=be.asn1.validate(e,df,t,a);if(!r){var n=new Error("Invalid Key.");throw n.errors=a,n}var s=be.asn1.derToOid(t.publicKeyOid),i=be.oids.EdDSA25519;if(s!==i)throw new Error('Invalid OID "'+s+'"; OID must be "'+i+'".');var o=t.ed25519PublicKey;if(o.length!==X.constants.PUBLIC_KEY_BYTE_LENGTH)throw new Error("Key length is invalid.");return At({message:o,encoding:"binary"})};X.publicKeyFromPrivateKey=function(e){e=e||{};var t=At({message:e.privateKey,encoding:"binary"});if(t.length!==X.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+X.constants.PRIVATE_KEY_BYTE_LENGTH);for(var a=new Ye(X.constants.PUBLIC_KEY_BYTE_LENGTH),r=0;r<a.length;++r)a[r]=t[32+r];return a};X.sign=function(e){e=e||{};var t=At(e),a=At({message:e.privateKey,encoding:"binary"});if(a.length===X.constants.SEED_BYTE_LENGTH){var r=X.generateKeyPair({seed:a});a=r.privateKey}else if(a.length!==X.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+X.constants.SEED_BYTE_LENGTH+" or "+X.constants.PRIVATE_KEY_BYTE_LENGTH);var n=new Ye(X.constants.SIGN_BYTE_LENGTH+t.length);mf(n,t,t.length,a);for(var s=new Ye(X.constants.SIGN_BYTE_LENGTH),i=0;i<s.length;++i)s[i]=n[i];return s};X.verify=function(e){e=e||{};var t=At(e);if(e.signature===void 0)throw new TypeError('"options.signature" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a binary string.');var a=At({message:e.signature,encoding:"binary"});if(a.length!==X.constants.SIGN_BYTE_LENGTH)throw new TypeError('"options.signature" must have a byte length of '+X.constants.SIGN_BYTE_LENGTH);var r=At({message:e.publicKey,encoding:"binary"});if(r.length!==X.constants.PUBLIC_KEY_BYTE_LENGTH)throw new TypeError('"options.publicKey" must have a byte length of '+X.constants.PUBLIC_KEY_BYTE_LENGTH);var n=new Ye(X.constants.SIGN_BYTE_LENGTH+t.length),s=new Ye(X.constants.SIGN_BYTE_LENGTH+t.length),i;for(i=0;i<X.constants.SIGN_BYTE_LENGTH;++i)n[i]=a[i];for(i=0;i<t.length;++i)n[i+X.constants.SIGN_BYTE_LENGTH]=t[i];return Cf(s,n,n.length,r)>=0};function At(e){var t=e.message;if(t instanceof Uint8Array||t instanceof Ye)return t;var a=e.encoding;if(t===void 0)if(e.md)t=e.md.digest().getBytes(),a="binary";else throw new TypeError('"options.message" or "options.md" not specified.');if(typeof t=="string"&&!a)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if(typeof t=="string"){if(typeof Buffer<"u")return Buffer.from(t,a);t=new Sn(t,a)}else if(!(t instanceof Sn))throw new TypeError('"options.message" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with "options.encoding" specifying its encoding.');for(var r=new Ye(t.length()),n=0;n<r.length;++n)r[n]=t.at(n);return r}var Tn=H(),Ea=H([1]),pf=H([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),gf=H([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),Ks=H([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),Ms=H([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),Ur=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]),yf=H([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function Pr(e,t){var a=be.md.sha512.create(),r=new Sn(e);a.update(r.getBytes(t),"binary");var n=a.digest().getBytes();if(typeof Buffer<"u")return Buffer.from(n,"binary");for(var s=new Ye(X.constants.HASH_BYTE_LENGTH),i=0;i<64;++i)s[i]=n.charCodeAt(i);return s}function vf(e,t){var a=[H(),H(),H(),H()],r,n=Pr(t,32);for(n[0]&=248,n[31]&=127,n[31]|=64,bn(a,n),Bn(e,a),r=0;r<32;++r)t[r+32]=e[r];return 0}function mf(e,t,a,r){var n,s,i=new Float64Array(64),o=[H(),H(),H(),H()],u=Pr(r,32);u[0]&=248,u[31]&=127,u[31]|=64;var l=a+64;for(n=0;n<a;++n)e[64+n]=t[n];for(n=0;n<32;++n)e[32+n]=u[32+n];var c=Pr(e.subarray(32),a+32);for(In(c),bn(o,c),Bn(e,o),n=32;n<64;++n)e[n]=r[n];var f=Pr(e,a+64);for(In(f),n=32;n<64;++n)i[n]=0;for(n=0;n<32;++n)i[n]=c[n];for(n=0;n<32;++n)for(s=0;s<32;s++)i[n+s]+=f[n]*u[s];return zs(e.subarray(32),i),l}function Cf(e,t,a,r){var n,s,i=new Ye(32),o=[H(),H(),H(),H()],u=[H(),H(),H(),H()];if(s=-1,a<64||xf(u,r)||!Ef(t,32))return-1;for(n=0;n<a;++n)e[n]=t[n];for(n=0;n<32;++n)e[n+32]=r[n];var l=Pr(e,a);if(In(l),Ys(o,u,l),bn(u,t.subarray(32)),An(o,u),Bn(i,o),a-=64,Qs(t,0,i,0)){for(n=0;n<a;++n)e[n]=0;return-1}for(n=0;n<a;++n)e[n]=t[n+64];return s=a,s}function Ef(e,t){var a;for(a=31;a>=0;--a){if(e[t+a]<Ur[a])return!0;if(e[t+a]>Ur[a])return!1}return!1}function zs(e,t){var a,r,n,s;for(r=63;r>=32;--r){for(a=0,n=r-32,s=r-12;n<s;++n)t[n]+=a-16*t[r]*Ur[n-(r-32)],a=t[n]+128>>8,t[n]-=a*256;t[n]+=a,t[r]=0}for(a=0,n=0;n<32;++n)t[n]+=a-(t[31]>>4)*Ur[n],a=t[n]>>8,t[n]&=255;for(n=0;n<32;++n)t[n]-=a*Ur[n];for(r=0;r<32;++r)t[r+1]+=t[r]>>8,e[r]=t[r]&255}function In(e){for(var t=new Float64Array(64),a=0;a<64;++a)t[a]=e[a],e[a]=0;zs(e,t)}function An(e,t){var a=H(),r=H(),n=H(),s=H(),i=H(),o=H(),u=H(),l=H(),c=H();vr(a,e[1],e[0]),vr(c,t[1],t[0]),oe(a,a,c),yr(r,e[0],e[1]),yr(c,t[0],t[1]),oe(r,r,c),oe(n,e[3],t[3]),oe(n,n,gf),oe(s,e[2],t[2]),yr(s,s,s),vr(i,r,a),vr(o,s,n),yr(u,s,n),yr(l,r,a),oe(e[0],i,o),oe(e[1],l,u),oe(e[2],u,o),oe(e[3],i,l)}function qs(e,t,a){for(var r=0;r<4;++r)js(e[r],t[r],a)}function Bn(e,t){var a=H(),r=H(),n=H();Af(n,t[2]),oe(a,t[0],n),oe(r,t[1],n),xa(e,r),e[31]^=$s(a)<<7}function xa(e,t){var a,r,n,s=H(),i=H();for(a=0;a<16;++a)i[a]=t[a];for(xn(i),xn(i),xn(i),r=0;r<2;++r){for(s[0]=i[0]-65517,a=1;a<15;++a)s[a]=i[a]-65535-(s[a-1]>>16&1),s[a-1]&=65535;s[15]=i[15]-32767-(s[14]>>16&1),n=s[15]>>16&1,s[14]&=65535,js(i,s,1-n)}for(a=0;a<16;a++)e[2*a]=i[a]&255,e[2*a+1]=i[a]>>8}function xf(e,t){var a=H(),r=H(),n=H(),s=H(),i=H(),o=H(),u=H();return Ft(e[2],Ea),Sf(e[1],t),Zt(n,e[1]),oe(s,n,pf),vr(n,n,e[2]),yr(s,e[2],s),Zt(i,s),Zt(o,i),oe(u,o,i),oe(a,u,n),oe(a,a,s),Tf(a,a),oe(a,a,n),oe(a,a,s),oe(a,a,s),oe(e[0],a,s),Zt(r,e[0]),oe(r,r,s),Hs(r,n)&&oe(e[0],e[0],yf),Zt(r,e[0]),oe(r,r,s),Hs(r,n)?-1:($s(e[0])===t[31]>>7&&vr(e[0],Tn,e[0]),oe(e[3],e[0],e[1]),0)}function Sf(e,t){var a;for(a=0;a<16;++a)e[a]=t[2*a]+(t[2*a+1]<<8);e[15]&=32767}function Tf(e,t){var a=H(),r;for(r=0;r<16;++r)a[r]=t[r];for(r=250;r>=0;--r)Zt(a,a),r!==1&&oe(a,a,t);for(r=0;r<16;++r)e[r]=a[r]}function Hs(e,t){var a=new Ye(32),r=new Ye(32);return xa(a,e),xa(r,t),Qs(a,0,r,0)}function Qs(e,t,a,r){return If(e,t,a,r,32)}function If(e,t,a,r,n){var s,i=0;for(s=0;s<n;++s)i|=e[t+s]^a[r+s];return(1&i-1>>>8)-1}function $s(e){var t=new Ye(32);return xa(t,e),t[0]&1}function Ys(e,t,a){var r,n;for(Ft(e[0],Tn),Ft(e[1],Ea),Ft(e[2],Ea),Ft(e[3],Tn),n=255;n>=0;--n)r=a[n/8|0]>>(n&7)&1,qs(e,t,r),An(t,e),An(e,e),qs(e,t,r)}function bn(e,t){var a=[H(),H(),H(),H()];Ft(a[0],Ks),Ft(a[1],Ms),Ft(a[2],Ea),oe(a[3],Ks,Ms),Ys(e,a,t)}function Ft(e,t){var a;for(a=0;a<16;a++)e[a]=t[a]|0}function Af(e,t){var a=H(),r;for(r=0;r<16;++r)a[r]=t[r];for(r=253;r>=0;--r)Zt(a,a),r!==2&&r!==4&&oe(a,a,t);for(r=0;r<16;++r)e[r]=a[r]}function xn(e){var t,a,r=1;for(t=0;t<16;++t)a=e[t]+r+65535,r=Math.floor(a/65536),e[t]=a-r*65536;e[0]+=r-1+37*(r-1)}function js(e,t,a){for(var r,n=~(a-1),s=0;s<16;++s)r=n&(e[s]^t[s]),e[s]^=r,t[s]^=r}function H(e){var t,a=new Float64Array(16);if(e)for(t=0;t<e.length;++t)a[t]=e[t];return a}function yr(e,t,a){for(var r=0;r<16;++r)e[r]=t[r]+a[r]}function vr(e,t,a){for(var r=0;r<16;++r)e[r]=t[r]-a[r]}function Zt(e,t){oe(e,t,t)}function oe(e,t,a){var r,n,s=0,i=0,o=0,u=0,l=0,c=0,f=0,g=0,v=0,y=0,x=0,S=0,T=0,B=0,b=0,P=0,k=0,R=0,z=0,Y=0,ne=0,ie=0,ue=0,fe=0,qe=0,et=0,se=0,ye=0,K=0,qt=0,ar=0,ve=a[0],me=a[1],Ee=a[2],we=a[3],Ne=a[4],Re=a[5],Le=a[6],ke=a[7],De=a[8],Ue=a[9],Pe=a[10],Oe=a[11],Ve=a[12],Fe=a[13],Ke=a[14],Me=a[15];r=t[0],s+=r*ve,i+=r*me,o+=r*Ee,u+=r*we,l+=r*Ne,c+=r*Re,f+=r*Le,g+=r*ke,v+=r*De,y+=r*Ue,x+=r*Pe,S+=r*Oe,T+=r*Ve,B+=r*Fe,b+=r*Ke,P+=r*Me,r=t[1],i+=r*ve,o+=r*me,u+=r*Ee,l+=r*we,c+=r*Ne,f+=r*Re,g+=r*Le,v+=r*ke,y+=r*De,x+=r*Ue,S+=r*Pe,T+=r*Oe,B+=r*Ve,b+=r*Fe,P+=r*Ke,k+=r*Me,r=t[2],o+=r*ve,u+=r*me,l+=r*Ee,c+=r*we,f+=r*Ne,g+=r*Re,v+=r*Le,y+=r*ke,x+=r*De,S+=r*Ue,T+=r*Pe,B+=r*Oe,b+=r*Ve,P+=r*Fe,k+=r*Ke,R+=r*Me,r=t[3],u+=r*ve,l+=r*me,c+=r*Ee,f+=r*we,g+=r*Ne,v+=r*Re,y+=r*Le,x+=r*ke,S+=r*De,T+=r*Ue,B+=r*Pe,b+=r*Oe,P+=r*Ve,k+=r*Fe,R+=r*Ke,z+=r*Me,r=t[4],l+=r*ve,c+=r*me,f+=r*Ee,g+=r*we,v+=r*Ne,y+=r*Re,x+=r*Le,S+=r*ke,T+=r*De,B+=r*Ue,b+=r*Pe,P+=r*Oe,k+=r*Ve,R+=r*Fe,z+=r*Ke,Y+=r*Me,r=t[5],c+=r*ve,f+=r*me,g+=r*Ee,v+=r*we,y+=r*Ne,x+=r*Re,S+=r*Le,T+=r*ke,B+=r*De,b+=r*Ue,P+=r*Pe,k+=r*Oe,R+=r*Ve,z+=r*Fe,Y+=r*Ke,ne+=r*Me,r=t[6],f+=r*ve,g+=r*me,v+=r*Ee,y+=r*we,x+=r*Ne,S+=r*Re,T+=r*Le,B+=r*ke,b+=r*De,P+=r*Ue,k+=r*Pe,R+=r*Oe,z+=r*Ve,Y+=r*Fe,ne+=r*Ke,ie+=r*Me,r=t[7],g+=r*ve,v+=r*me,y+=r*Ee,x+=r*we,S+=r*Ne,T+=r*Re,B+=r*Le,b+=r*ke,P+=r*De,k+=r*Ue,R+=r*Pe,z+=r*Oe,Y+=r*Ve,ne+=r*Fe,ie+=r*Ke,ue+=r*Me,r=t[8],v+=r*ve,y+=r*me,x+=r*Ee,S+=r*we,T+=r*Ne,B+=r*Re,b+=r*Le,P+=r*ke,k+=r*De,R+=r*Ue,z+=r*Pe,Y+=r*Oe,ne+=r*Ve,ie+=r*Fe,ue+=r*Ke,fe+=r*Me,r=t[9],y+=r*ve,x+=r*me,S+=r*Ee,T+=r*we,B+=r*Ne,b+=r*Re,P+=r*Le,k+=r*ke,R+=r*De,z+=r*Ue,Y+=r*Pe,ne+=r*Oe,ie+=r*Ve,ue+=r*Fe,fe+=r*Ke,qe+=r*Me,r=t[10],x+=r*ve,S+=r*me,T+=r*Ee,B+=r*we,b+=r*Ne,P+=r*Re,k+=r*Le,R+=r*ke,z+=r*De,Y+=r*Ue,ne+=r*Pe,ie+=r*Oe,ue+=r*Ve,fe+=r*Fe,qe+=r*Ke,et+=r*Me,r=t[11],S+=r*ve,T+=r*me,B+=r*Ee,b+=r*we,P+=r*Ne,k+=r*Re,R+=r*Le,z+=r*ke,Y+=r*De,ne+=r*Ue,ie+=r*Pe,ue+=r*Oe,fe+=r*Ve,qe+=r*Fe,et+=r*Ke,se+=r*Me,r=t[12],T+=r*ve,B+=r*me,b+=r*Ee,P+=r*we,k+=r*Ne,R+=r*Re,z+=r*Le,Y+=r*ke,ne+=r*De,ie+=r*Ue,ue+=r*Pe,fe+=r*Oe,qe+=r*Ve,et+=r*Fe,se+=r*Ke,ye+=r*Me,r=t[13],B+=r*ve,b+=r*me,P+=r*Ee,k+=r*we,R+=r*Ne,z+=r*Re,Y+=r*Le,ne+=r*ke,ie+=r*De,ue+=r*Ue,fe+=r*Pe,qe+=r*Oe,et+=r*Ve,se+=r*Fe,ye+=r*Ke,K+=r*Me,r=t[14],b+=r*ve,P+=r*me,k+=r*Ee,R+=r*we,z+=r*Ne,Y+=r*Re,ne+=r*Le,ie+=r*ke,ue+=r*De,fe+=r*Ue,qe+=r*Pe,et+=r*Oe,se+=r*Ve,ye+=r*Fe,K+=r*Ke,qt+=r*Me,r=t[15],P+=r*ve,k+=r*me,R+=r*Ee,z+=r*we,Y+=r*Ne,ne+=r*Re,ie+=r*Le,ue+=r*ke,fe+=r*De,qe+=r*Ue,et+=r*Pe,se+=r*Oe,ye+=r*Ve,K+=r*Fe,qt+=r*Ke,ar+=r*Me,s+=38*k,i+=38*R,o+=38*z,u+=38*Y,l+=38*ne,c+=38*ie,f+=38*ue,g+=38*fe,v+=38*qe,y+=38*et,x+=38*se,S+=38*ye,T+=38*K,B+=38*qt,b+=38*ar,n=1,r=s+n+65535,n=Math.floor(r/65536),s=r-n*65536,r=i+n+65535,n=Math.floor(r/65536),i=r-n*65536,r=o+n+65535,n=Math.floor(r/65536),o=r-n*65536,r=u+n+65535,n=Math.floor(r/65536),u=r-n*65536,r=l+n+65535,n=Math.floor(r/65536),l=r-n*65536,r=c+n+65535,n=Math.floor(r/65536),c=r-n*65536,r=f+n+65535,n=Math.floor(r/65536),f=r-n*65536,r=g+n+65535,n=Math.floor(r/65536),g=r-n*65536,r=v+n+65535,n=Math.floor(r/65536),v=r-n*65536,r=y+n+65535,n=Math.floor(r/65536),y=r-n*65536,r=x+n+65535,n=Math.floor(r/65536),x=r-n*65536,r=S+n+65535,n=Math.floor(r/65536),S=r-n*65536,r=T+n+65535,n=Math.floor(r/65536),T=r-n*65536,r=B+n+65535,n=Math.floor(r/65536),B=r-n*65536,r=b+n+65535,n=Math.floor(r/65536),b=r-n*65536,r=P+n+65535,n=Math.floor(r/65536),P=r-n*65536,s+=n-1+37*(n-1),n=1,r=s+n+65535,n=Math.floor(r/65536),s=r-n*65536,r=i+n+65535,n=Math.floor(r/65536),i=r-n*65536,r=o+n+65535,n=Math.floor(r/65536),o=r-n*65536,r=u+n+65535,n=Math.floor(r/65536),u=r-n*65536,r=l+n+65535,n=Math.floor(r/65536),l=r-n*65536,r=c+n+65535,n=Math.floor(r/65536),c=r-n*65536,r=f+n+65535,n=Math.floor(r/65536),f=r-n*65536,r=g+n+65535,n=Math.floor(r/65536),g=r-n*65536,r=v+n+65535,n=Math.floor(r/65536),v=r-n*65536,r=y+n+65535,n=Math.floor(r/65536),y=r-n*65536,r=x+n+65535,n=Math.floor(r/65536),x=r-n*65536,r=S+n+65535,n=Math.floor(r/65536),S=r-n*65536,r=T+n+65535,n=Math.floor(r/65536),T=r-n*65536,r=B+n+65535,n=Math.floor(r/65536),B=r-n*65536,r=b+n+65535,n=Math.floor(r/65536),b=r-n*65536,r=P+n+65535,n=Math.floor(r/65536),P=r-n*65536,s+=n-1+37*(n-1),e[0]=s,e[1]=i,e[2]=o,e[3]=u,e[4]=l,e[5]=c,e[6]=f,e[7]=g,e[8]=v,e[9]=y,e[10]=x,e[11]=S,e[12]=T,e[13]=B,e[14]=b,e[15]=P}});var to=F((np,eo)=>{var We=$();re();tt();Nr();eo.exports=We.kem=We.kem||{};var Js=We.jsbn.BigInteger;We.kem.rsa={};We.kem.rsa.create=function(e,t){t=t||{};var a=t.prng||We.random,r={};return r.encrypt=function(n,s){var i=Math.ceil(n.n.bitLength()/8),o;do o=new Js(We.util.bytesToHex(a.getBytesSync(i)),16).mod(n.n);while(o.compareTo(Js.ONE)<=0);o=We.util.hexToBytes(o.toString(16));var u=i-o.length;u>0&&(o=We.util.fillString("\0",u)+o);var l=n.encrypt(o,"NONE"),c=e.generate(o,s);return{encapsulation:l,key:c}},r.decrypt=function(n,s,i){var o=n.decrypt(s,"NONE");return e.generate(o,i)},r};We.kem.kdf1=function(e,t){Zs(this,e,0,t||e.digestLength)};We.kem.kdf2=function(e,t){Zs(this,e,1,t||e.digestLength)};function Zs(e,t,a,r){e.generate=function(n,s){for(var i=new We.util.ByteBuffer,o=Math.ceil(s/r)+a,u=new We.util.ByteBuffer,l=a;l<o;++l){u.putInt32(l),t.start(),t.update(n+u.getBytes());var c=t.digest();i.putBytes(c.getBytes(r))}return i.truncate(i.length()-s),i.getBytes()}}});var io=F((ip,no)=>{var J=$();re();no.exports=J.log=J.log||{};J.log.levels=["none","error","warning","info","debug","verbose","max"];var Sa={},Nn=[],Vr=null;J.log.LEVEL_LOCKED=2;J.log.NO_LEVEL_CHECK=4;J.log.INTERPOLATE=8;for(Ct=0;Ct<J.log.levels.length;++Ct)_n=J.log.levels[Ct],Sa[_n]={index:Ct,name:_n.toUpperCase()};var _n,Ct;J.log.logMessage=function(e){for(var t=Sa[e.level].index,a=0;a<Nn.length;++a){var r=Nn[a];if(r.flags&J.log.NO_LEVEL_CHECK)r.f(e);else{var n=Sa[r.level].index;t<=n&&r.f(r,e)}}};J.log.prepareStandard=function(e){"standard"in e||(e.standard=Sa[e.level].name+" ["+e.category+"] "+e.message)};J.log.prepareFull=function(e){if(!("full"in e)){var t=[e.message];t=t.concat([]),e.full=J.util.format.apply(this,t)}};J.log.prepareStandardFull=function(e){"standardFull"in e||(J.log.prepareStandard(e),e.standardFull=e.standard)};for(wn=["error","warning","info","debug","verbose"],Ct=0;Ct<wn.length;++Ct)(function(t){J.log[t]=function(a,r){var n=Array.prototype.slice.call(arguments).slice(2),s={timestamp:new Date,level:t,category:a,message:r,arguments:n};J.log.logMessage(s)}})(wn[Ct]);var wn,Ct;J.log.makeLogger=function(e){var t={flags:0,f:e};return J.log.setLevel(t,"none"),t};J.log.setLevel=function(e,t){var a=!1;if(e&&!(e.flags&J.log.LEVEL_LOCKED))for(var r=0;r<J.log.levels.length;++r){var n=J.log.levels[r];if(t==n){e.level=t,a=!0;break}}return a};J.log.lock=function(e,t){typeof t>"u"||t?e.flags|=J.log.LEVEL_LOCKED:e.flags&=~J.log.LEVEL_LOCKED};J.log.addLogger=function(e){Nn.push(e)};typeof console<"u"&&"log"in console?(console.error&&console.warn&&console.info&&console.debug?(ro={error:console.error,warning:console.warn,info:console.info,debug:console.debug,verbose:console.debug},Fr=function(e,t){J.log.prepareStandard(t);var a=ro[t.level],r=[t.standard];r=r.concat(t.arguments.slice()),a.apply(console,r)},mr=J.log.makeLogger(Fr)):(Fr=function(t,a){J.log.prepareStandardFull(a),console.log(a.standardFull)},mr=J.log.makeLogger(Fr)),J.log.setLevel(mr,"debug"),J.log.addLogger(mr),Vr=mr):console={log:function(){}};var mr,ro,Fr;Vr!==null&&typeof window<"u"&&window.location&&(Or=new URL(window.location.href).searchParams,Or.has("console.level")&&J.log.setLevel(Vr,Or.get("console.level").slice(-1)[0]),Or.has("console.lock")&&(ao=Or.get("console.lock").slice(-1)[0],ao=="true"&&J.log.lock(Vr)));var Or,ao;J.log.consoleLogger=Vr});var oo=F((sp,so)=>{so.exports=ft();ta();fr();Ha();Cn()});var co=F((op,lo)=>{var D=$();Rt();lt();_r();Lt();Qt();an();tt();re();ga();var C=D.asn1,Qe=lo.exports=D.pkcs7=D.pkcs7||{};Qe.messageFromPem=function(e){var t=D.pem.decode(e)[0];if(t.type!=="PKCS7"){var a=new Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');throw a.headerType=t.type,a}if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");var r=C.fromDer(t.body);return Qe.messageFromAsn1(r)};Qe.messageToPem=function(e,t){var a={type:"PKCS7",body:C.toDer(e.toAsn1()).getBytes()};return D.pem.encode(a,{maxline:t})};Qe.messageFromAsn1=function(e){var t={},a=[];if(!C.validate(e,Qe.asn1.contentInfoValidator,t,a)){var r=new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw r.errors=a,r}var n=C.derToOid(t.contentType),s;switch(n){case D.pki.oids.envelopedData:s=Qe.createEnvelopedData();break;case D.pki.oids.encryptedData:s=Qe.createEncryptedData();break;case D.pki.oids.signedData:s=Qe.createSignedData();break;default:throw new Error("Cannot read PKCS#7 message. ContentType with OID "+n+" is not (yet) supported.")}return s.fromAsn1(t.content.value[0]),s};Qe.createSignedData=function(){var e=null;return e={type:D.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(r){if(Ln(e,r,Qe.asn1.signedDataValidator),e.certificates=[],e.crls=[],e.digestAlgorithmIdentifiers=[],e.contentInfo=null,e.signerInfos=[],e.rawCapture.certificates)for(var n=e.rawCapture.certificates.value,s=0;s<n.length;++s)e.certificates.push(D.pki.certificateFromAsn1(n[s]))},toAsn1:function(){e.contentInfo||e.sign();for(var r=[],n=0;n<e.certificates.length;++n)r.push(D.pki.certificateToAsn1(e.certificates[n]));var s=[],i=C.create(C.Class.CONTEXT_SPECIFIC,0,!0,[C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.INTEGER,!1,C.integerToDer(e.version).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.SET,!0,e.digestAlgorithmIdentifiers),e.contentInfo])]);return r.length>0&&i.value[0].value.push(C.create(C.Class.CONTEXT_SPECIFIC,0,!0,r)),s.length>0&&i.value[0].value.push(C.create(C.Class.CONTEXT_SPECIFIC,1,!0,s)),i.value[0].value.push(C.create(C.Class.UNIVERSAL,C.Type.SET,!0,e.signerInfos)),C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.type).getBytes()),i])},addSigner:function(r){var n=r.issuer,s=r.serialNumber;if(r.certificate){var i=r.certificate;typeof i=="string"&&(i=D.pki.certificateFromPem(i)),n=i.issuer.attributes,s=i.serialNumber}var o=r.key;if(!o)throw new Error("Could not add PKCS#7 signer; no private key specified.");typeof o=="string"&&(o=D.pki.privateKeyFromPem(o));var u=r.digestAlgorithm||D.pki.oids.sha1;switch(u){case D.pki.oids.sha1:case D.pki.oids.sha256:case D.pki.oids.sha384:case D.pki.oids.sha512:case D.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+u)}var l=r.authenticatedAttributes||[];if(l.length>0){for(var c=!1,f=!1,g=0;g<l.length;++g){var v=l[g];if(!c&&v.type===D.pki.oids.contentType){if(c=!0,f)break;continue}if(!f&&v.type===D.pki.oids.messageDigest){if(f=!0,c)break;continue}}if(!c||!f)throw new Error("Invalid signer.authenticatedAttributes. If signer.authenticatedAttributes is specified, then it must contain at least two attributes, PKCS #9 content-type and PKCS #9 message-digest.")}e.signers.push({key:o,version:1,issuer:n,serialNumber:s,digestAlgorithm:u,signatureAlgorithm:D.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:l,unauthenticatedAttributes:[]})},sign:function(r){if(r=r||{},(typeof e.content!="object"||e.contentInfo===null)&&(e.contentInfo=C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(D.pki.oids.data).getBytes())]),"content"in e)){var n;e.content instanceof D.util.ByteBuffer?n=e.content.bytes():typeof e.content=="string"&&(n=D.util.encodeUtf8(e.content)),r.detached?e.detachedContent=C.create(C.Class.UNIVERSAL,C.Type.OCTETSTRING,!1,n):e.contentInfo.value.push(C.create(C.Class.CONTEXT_SPECIFIC,0,!0,[C.create(C.Class.UNIVERSAL,C.Type.OCTETSTRING,!1,n)]))}if(e.signers.length!==0){var s=t();a(s)}},verify:function(){throw new Error("PKCS#7 signature verification not yet implemented.")},addCertificate:function(r){typeof r=="string"&&(r=D.pki.certificateFromPem(r)),e.certificates.push(r)},addCertificateRevokationList:function(r){throw new Error("PKCS#7 CRL support not yet implemented.")}},e;function t(){for(var r={},n=0;n<e.signers.length;++n){var s=e.signers[n],i=s.digestAlgorithm;i in r||(r[i]=D.md[D.pki.oids[i]].create()),s.authenticatedAttributes.length===0?s.md=r[i]:s.md=D.md[D.pki.oids[i]].create()}e.digestAlgorithmIdentifiers=[];for(var i in r)e.digestAlgorithmIdentifiers.push(C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(i).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.NULL,!1,"")]));return r}function a(r){var n;if(e.detachedContent?n=e.detachedContent:(n=e.contentInfo.value[1],n=n.value[0]),!n)throw new Error("Could not sign PKCS#7 message; there is no content to sign.");var s=C.derToOid(e.contentInfo.value[0].value),i=C.toDer(n);i.getByte(),C.getBerValueLength(i),i=i.getBytes();for(var o in r)r[o].start().update(i);for(var u=new Date,l=0;l<e.signers.length;++l){var c=e.signers[l];if(c.authenticatedAttributes.length===0){if(s!==D.pki.oids.data)throw new Error("Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data.")}else{c.authenticatedAttributesAsn1=C.create(C.Class.CONTEXT_SPECIFIC,0,!0,[]);for(var f=C.create(C.Class.UNIVERSAL,C.Type.SET,!0,[]),g=0;g<c.authenticatedAttributes.length;++g){var v=c.authenticatedAttributes[g];v.type===D.pki.oids.messageDigest?v.value=r[c.digestAlgorithm].digest():v.type===D.pki.oids.signingTime&&(v.value||(v.value=u)),f.value.push(Rn(v)),c.authenticatedAttributesAsn1.value.push(Rn(v))}i=C.toDer(f).getBytes(),c.md.start().update(i)}c.signature=c.key.sign(c.md,"RSASSA-PKCS1-V1_5")}e.signerInfos=Rf(e.signers)}};Qe.createEncryptedData=function(){var e=null;return e={type:D.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:D.pki.oids["aes256-CBC"]},fromAsn1:function(t){Ln(e,t,Qe.asn1.encryptedDataValidator)},decrypt:function(t){t!==void 0&&(e.encryptedContent.key=t),uo(e)}},e};Qe.createEnvelopedData=function(){var e=null;return e={type:D.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:D.pki.oids["aes256-CBC"]},fromAsn1:function(t){var a=Ln(e,t,Qe.asn1.envelopedDataValidator);e.recipients=_f(a.recipientInfos.value)},toAsn1:function(){return C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.type).getBytes()),C.create(C.Class.CONTEXT_SPECIFIC,0,!0,[C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.INTEGER,!1,C.integerToDer(e.version).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.SET,!0,wf(e.recipients)),C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,Lf(e.encryptedContent))])])])},findRecipient:function(t){for(var a=t.issuer.attributes,r=0;r<e.recipients.length;++r){var n=e.recipients[r],s=n.issuer;if(n.serialNumber===t.serialNumber&&s.length===a.length){for(var i=!0,o=0;o<a.length;++o)if(s[o].type!==a[o].type||s[o].value!==a[o].value){i=!1;break}if(i)return n}}return null},decrypt:function(t,a){if(e.encryptedContent.key===void 0&&t!==void 0&&a!==void 0)switch(t.encryptedContent.algorithm){case D.pki.oids.rsaEncryption:case D.pki.oids.desCBC:var r=a.decrypt(t.encryptedContent.content);e.encryptedContent.key=D.util.createBuffer(r);break;default:throw new Error("Unsupported asymmetric cipher, OID "+t.encryptedContent.algorithm)}uo(e)},addRecipient:function(t){e.recipients.push({version:0,issuer:t.issuer.attributes,serialNumber:t.serialNumber,encryptedContent:{algorithm:D.pki.oids.rsaEncryption,key:t.publicKey}})},encrypt:function(t,a){if(e.encryptedContent.content===void 0){a=a||e.encryptedContent.algorithm,t=t||e.encryptedContent.key;var r,n,s;switch(a){case D.pki.oids["aes128-CBC"]:r=16,n=16,s=D.aes.createEncryptionCipher;break;case D.pki.oids["aes192-CBC"]:r=24,n=16,s=D.aes.createEncryptionCipher;break;case D.pki.oids["aes256-CBC"]:r=32,n=16,s=D.aes.createEncryptionCipher;break;case D.pki.oids["des-EDE3-CBC"]:r=24,n=8,s=D.des.createEncryptionCipher;break;default:throw new Error("Unsupported symmetric cipher, OID "+a)}if(t===void 0)t=D.util.createBuffer(D.random.getBytes(r));else if(t.length()!=r)throw new Error("Symmetric key has wrong length; got "+t.length()+" bytes, expected "+r+".");e.encryptedContent.algorithm=a,e.encryptedContent.key=t,e.encryptedContent.parameter=D.util.createBuffer(D.random.getBytes(n));var i=s(t);if(i.start(e.encryptedContent.parameter.copy()),i.update(e.content),!i.finish())throw new Error("Symmetric encryption failed.");e.encryptedContent.content=i.output}for(var o=0;o<e.recipients.length;++o){var u=e.recipients[o];if(u.encryptedContent.content===void 0)switch(u.encryptedContent.algorithm){case D.pki.oids.rsaEncryption:u.encryptedContent.content=u.encryptedContent.key.encrypt(e.encryptedContent.key.data);break;default:throw new Error("Unsupported asymmetric cipher, OID "+u.encryptedContent.algorithm)}}}},e};function Bf(e){var t={},a=[];if(!C.validate(e,Qe.asn1.recipientInfoValidator,t,a)){var r=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw r.errors=a,r}return{version:t.version.charCodeAt(0),issuer:D.pki.RDNAttributesAsArray(t.issuer),serialNumber:D.util.createBuffer(t.serial).toHex(),encryptedContent:{algorithm:C.derToOid(t.encAlgorithm),parameter:t.encParameter?t.encParameter.value:void 0,content:t.encKey}}}function bf(e){return C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.INTEGER,!1,C.integerToDer(e.version).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[D.pki.distinguishedNameToAsn1({attributes:e.issuer}),C.create(C.Class.UNIVERSAL,C.Type.INTEGER,!1,D.util.hexToBytes(e.serialNumber))]),C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.encryptedContent.algorithm).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.NULL,!1,"")]),C.create(C.Class.UNIVERSAL,C.Type.OCTETSTRING,!1,e.encryptedContent.content)])}function _f(e){for(var t=[],a=0;a<e.length;++a)t.push(Bf(e[a]));return t}function wf(e){for(var t=[],a=0;a<e.length;++a)t.push(bf(e[a]));return t}function Nf(e){var t=C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.INTEGER,!1,C.integerToDer(e.version).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[D.pki.distinguishedNameToAsn1({attributes:e.issuer}),C.create(C.Class.UNIVERSAL,C.Type.INTEGER,!1,D.util.hexToBytes(e.serialNumber))]),C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.digestAlgorithm).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.NULL,!1,"")])]);if(e.authenticatedAttributesAsn1&&t.value.push(e.authenticatedAttributesAsn1),t.value.push(C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.signatureAlgorithm).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.NULL,!1,"")])),t.value.push(C.create(C.Class.UNIVERSAL,C.Type.OCTETSTRING,!1,e.signature)),e.unauthenticatedAttributes.length>0){for(var a=C.create(C.Class.CONTEXT_SPECIFIC,1,!0,[]),r=0;r<e.unauthenticatedAttributes.length;++r){var n=e.unauthenticatedAttributes[r];a.values.push(Rn(n))}t.value.push(a)}return t}function Rf(e){for(var t=[],a=0;a<e.length;++a)t.push(Nf(e[a]));return t}function Rn(e){var t;if(e.type===D.pki.oids.contentType)t=C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.value).getBytes());else if(e.type===D.pki.oids.messageDigest)t=C.create(C.Class.UNIVERSAL,C.Type.OCTETSTRING,!1,e.value.bytes());else if(e.type===D.pki.oids.signingTime){var a=new Date("1950-01-01T00:00:00Z"),r=new Date("2050-01-01T00:00:00Z"),n=e.value;if(typeof n=="string"){var s=Date.parse(n);isNaN(s)?n.length===13?n=C.utcTimeToDate(n):n=C.generalizedTimeToDate(n):n=new Date(s)}n>=a&&n<r?t=C.create(C.Class.UNIVERSAL,C.Type.UTCTIME,!1,C.dateToUtcTime(n)):t=C.create(C.Class.UNIVERSAL,C.Type.GENERALIZEDTIME,!1,C.dateToGeneralizedTime(n))}return C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.type).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.SET,!0,[t])])}function Lf(e){return[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(D.pki.oids.data).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.algorithm).getBytes()),e.parameter?C.create(C.Class.UNIVERSAL,C.Type.OCTETSTRING,!1,e.parameter.getBytes()):void 0]),C.create(C.Class.CONTEXT_SPECIFIC,0,!0,[C.create(C.Class.UNIVERSAL,C.Type.OCTETSTRING,!1,e.content.getBytes())])]}function Ln(e,t,a){var r={},n=[];if(!C.validate(t,a,r,n)){var s=new Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");throw s.errors=s,s}var i=C.derToOid(r.contentType);if(i!==D.pki.oids.data)throw new Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(r.encryptedContent){var o="";if(D.util.isArray(r.encryptedContent))for(var u=0;u<r.encryptedContent.length;++u){if(r.encryptedContent[u].type!==C.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");o+=r.encryptedContent[u].value}else o=r.encryptedContent;e.encryptedContent={algorithm:C.derToOid(r.encAlgorithm),parameter:D.util.createBuffer(r.encParameter.value),content:D.util.createBuffer(o)}}if(r.content){var o="";if(D.util.isArray(r.content))for(var u=0;u<r.content.length;++u){if(r.content[u].type!==C.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");o+=r.content[u].value}else o=r.content;e.content=D.util.createBuffer(o)}return e.version=r.version.charCodeAt(0),e.rawCapture=r,r}function uo(e){if(e.encryptedContent.key===void 0)throw new Error("Symmetric key not available.");if(e.content===void 0){var t;switch(e.encryptedContent.algorithm){case D.pki.oids["aes128-CBC"]:case D.pki.oids["aes192-CBC"]:case D.pki.oids["aes256-CBC"]:t=D.aes.createDecryptionCipher(e.encryptedContent.key);break;case D.pki.oids.desCBC:case D.pki.oids["des-EDE3-CBC"]:t=D.des.createDecryptionCipher(e.encryptedContent.key);break;default:throw new Error("Unsupported symmetric cipher, OID "+e.encryptedContent.algorithm)}if(t.start(e.encryptedContent.parameter),t.update(e.encryptedContent.content),!t.finish())throw new Error("Symmetric decryption failed.");e.content=t.output}}});var ho=F((up,fo)=>{var Ce=$();Rt();or();ta();fr();re();var Ia=fo.exports=Ce.ssh=Ce.ssh||{};Ia.privateKeyToPutty=function(e,t,a){a=a||"",t=t||"";var r="ssh-rsa",n=t===""?"none":"aes256-cbc",s="PuTTY-User-Key-File-2: "+r+`\r
18
18
  `;s+="Encryption: "+n+`\r
19
19
  `,s+="Comment: "+a+`\r
20
- `;var i=Ce.util.createBuffer();vr(i,r),Et(i,e.e),Et(i,e.n);var o=Ce.util.encode64(i.bytes(),64),u=Math.floor(o.length/66)+1;s+="Public-Lines: "+u+`\r
21
- `,s+=o;var l=Ce.util.createBuffer();Et(l,e.d),Et(l,e.p),Et(l,e.q),Et(l,e.qInv);var c;if(!t)c=Ce.util.encode64(l.bytes(),64);else{var f=l.length()+16-1;f-=f%16;var g=Sa(l.bytes());g.truncate(g.length()-f+l.length()),l.putBuffer(g);var v=Ce.util.createBuffer();v.putBuffer(Sa("\0\0\0\0",t)),v.putBuffer(Sa("\0\0\0",t));var y=Ce.aes.createEncryptionCipher(v.truncate(8),"CBC");y.start(Ce.util.createBuffer().fillWithByte(0,16)),y.update(l.copy()),y.finish();var x=y.output;x.truncate(16),c=Ce.util.encode64(x.bytes(),64)}u=Math.floor(c.length/66)+1,s+=`\r
20
+ `;var i=Ce.util.createBuffer();Cr(i,r),Et(i,e.e),Et(i,e.n);var o=Ce.util.encode64(i.bytes(),64),u=Math.floor(o.length/66)+1;s+="Public-Lines: "+u+`\r
21
+ `,s+=o;var l=Ce.util.createBuffer();Et(l,e.d),Et(l,e.p),Et(l,e.q),Et(l,e.qInv);var c;if(!t)c=Ce.util.encode64(l.bytes(),64);else{var f=l.length()+16-1;f-=f%16;var g=Ta(l.bytes());g.truncate(g.length()-f+l.length()),l.putBuffer(g);var v=Ce.util.createBuffer();v.putBuffer(Ta("\0\0\0\0",t)),v.putBuffer(Ta("\0\0\0",t));var y=Ce.aes.createEncryptionCipher(v.truncate(8),"CBC");y.start(Ce.util.createBuffer().fillWithByte(0,16)),y.update(l.copy()),y.finish();var x=y.output;x.truncate(16),c=Ce.util.encode64(x.bytes(),64)}u=Math.floor(c.length/66)+1,s+=`\r
22
22
  Private-Lines: `+u+`\r
23
- `,s+=c;var S=Sa("putty-private-key-file-mac-key",t),I=Ce.util.createBuffer();vr(I,r),vr(I,n),vr(I,a),I.putInt32(i.length()),I.putBuffer(i),I.putInt32(l.length()),I.putBuffer(l);var B=Ce.hmac.create();return B.start("sha1",S),B.update(I.bytes()),s+=`\r
23
+ `,s+=c;var S=Ta("putty-private-key-file-mac-key",t),T=Ce.util.createBuffer();Cr(T,r),Cr(T,n),Cr(T,a),T.putInt32(i.length()),T.putBuffer(i),T.putInt32(l.length()),T.putBuffer(l);var B=Ce.hmac.create();return B.start("sha1",S),B.update(T.bytes()),s+=`\r
24
24
  Private-MAC: `+B.digest().toHex()+`\r
25
- `,s};Ta.publicKeyToOpenSSH=function(e,t){var a="ssh-rsa";t=t||"";var r=Ce.util.createBuffer();return vr(r,a),Et(r,e.e),Et(r,e.n),a+" "+Ce.util.encode64(r.bytes())+" "+t};Ta.privateKeyToOpenSSH=function(e,t){return t?Ce.pki.encryptRsaPrivateKey(e,t,{legacy:!0,algorithm:"aes128"}):Ce.pki.privateKeyToPem(e)};Ta.getPublicKeyFingerprint=function(e,t){t=t||{};var a=t.md||Ce.md.md5.create(),r="ssh-rsa",n=Ce.util.createBuffer();vr(n,r),Et(n,e.e),Et(n,e.n),a.start(),a.update(n.getBytes());var s=a.digest();if(t.encoding==="hex"){var i=s.toHex();return t.delimiter?i.match(/.{2}/g).join(t.delimiter):i}else{if(t.encoding==="binary")return s.getBytes();if(t.encoding)throw new Error('Unknown encoding "'+t.encoding+'".')}return s};function Et(e,t){var a=t.toString(16);a[0]>="8"&&(a="00"+a);var r=Ce.util.hexToBytes(a);e.putInt32(r.length),e.putBytes(r)}function vr(e,t){e.putInt32(t.length),e.putString(t)}function Sa(){for(var e=Ce.md.sha1.create(),t=arguments.length,a=0;a<t;++a)e.update(arguments[a]);return e.digest()}});var ho=F((op,fo)=>{fo.exports=$();Rt();Rs();lt();$r();br();js();ir();Zs();ao();io();an();na();Qt();Xa();on();uo();ln();Za();Ha();fa();tt();Qa();co();gn();re()});var vo=F((up,yo)=>{var po=require("path"),Xe=require("fs"),Je=ho(),{MITM_DIR:Ia}=rr(),Kt=po.join(Ia,"rootCA.key"),Bt=po.join(Ia,"rootCA.crt");function go(e){try{let t=Je.pki.certificateFromPem(Xe.readFileSync(e,"utf8")),a=new Date(Date.now()+720*60*60*1e3);return t.validity.notAfter<a}catch{return!0}}async function Lf(){let e=Xe.existsSync(Kt)&&Xe.existsSync(Bt);if(e&&!go(Bt))return console.log("\u2705 Root CA already exists"),{key:Kt,cert:Bt};if(e){console.log("\u{1F510} Root CA expired or expiring soon \u2014 regenerating...");try{Xe.unlinkSync(Kt)}catch{}try{Xe.unlinkSync(Bt)}catch{}}Xe.existsSync(Ia)||Xe.mkdirSync(Ia,{recursive:!0}),console.log("\u{1F510} Generating Root CA certificate...");let t=Je.pki.rsa.generateKeyPair(2048),a=Je.pki.createCertificate();a.publicKey=t.publicKey,a.serialNumber="01",a.validity.notBefore=new Date,a.validity.notAfter=new Date,a.validity.notAfter.setFullYear(a.validity.notBefore.getFullYear()+10);let r=[{name:"commonName",value:"9Router MITM Root CA"},{name:"organizationName",value:"kRouter"},{name:"countryName",value:"US"}];a.setSubject(r),a.setIssuer(r),a.setExtensions([{name:"basicConstraints",cA:!0,critical:!0},{name:"keyUsage",keyCertSign:!0,cRLSign:!0,critical:!0},{name:"subjectKeyIdentifier"}]),a.sign(t.privateKey,Je.md.sha256.create());let n=Je.pki.privateKeyToPem(t.privateKey),s=Je.pki.certificateToPem(a);return Xe.writeFileSync(Kt,n),Xe.writeFileSync(Bt,s),console.log("\u2705 Root CA generated successfully"),{key:Kt,cert:Bt}}function kf(){if(!Xe.existsSync(Kt)||!Xe.existsSync(Bt))throw new Error("Root CA not found. Generate it first.");let e=Xe.readFileSync(Kt,"utf8"),t=Xe.readFileSync(Bt,"utf8");return{key:Je.pki.privateKeyFromPem(e),cert:Je.pki.certificateFromPem(t)}}function Df(e,t){let a=Je.pki.rsa.generateKeyPair(2048),r=Je.pki.createCertificate();return r.publicKey=a.publicKey,r.serialNumber=Math.floor(Math.random()*1e6).toString(),r.validity.notBefore=new Date,r.validity.notAfter=new Date,r.validity.notAfter.setFullYear(r.validity.notBefore.getFullYear()+1),r.setSubject([{name:"commonName",value:e}]),r.setIssuer(t.cert.subject.attributes),r.setExtensions([{name:"basicConstraints",cA:!1},{name:"keyUsage",digitalSignature:!0,keyEncipherment:!0},{name:"extKeyUsage",serverAuth:!0,clientAuth:!0},{name:"subjectAltName",altNames:[{type:2,value:e},{type:2,value:`*.${e}`}]}]),r.sign(t.key,Je.md.sha256.create()),{key:Je.pki.privateKeyToPem(a.privateKey),cert:Je.pki.certificateToPem(r)}}yo.exports={generateRootCA:Lf,loadRootCA:kf,generateLeafCert:Df,isCertExpired:go,ROOT_CA_CERT_PATH:Bt,ROOT_CA_KEY_PATH:Kt}});var Co=F((dp,mo)=>{var lp=require("path"),cp=require("fs"),{MITM_DIR:fp}=rr(),{generateRootCA:Uf,loadRootCA:Pf,generateLeafCert:Of}=vo();async function Vf(){return await Uf()}function Ff(e){try{let t=Pf(),a=Of(e,t);return{key:a.key,cert:a.cert}}catch(t){return console.error(`Failed to generate cert for ${e}:`,t.message),null}}mo.exports={generateCert:Vf,getCertForDomain:Ff}});var To=F((hp,So)=>{var Eo=require("fs"),Kf=require("path"),{DATA_DIR:Mf}=rr(),xo=Kf.join(Mf,"mitm","aliases.json");function qf(){try{return Eo.existsSync(xo)?JSON.parse(Eo.readFileSync(xo,"utf-8")):null}catch{return null}}function Hf(e){return qf()?.[e]||null}So.exports={getMitmAlias:Hf}});var Bo=F((pp,Ao)=>{"use strict";var mr="1.23.2";function Gf(e){return!e||typeof e!="object"||Array.isArray(e)?!1:String(e.ideName||"").toLowerCase()==="antigravity"||String(e.ideType||"").toUpperCase()==="ANTIGRAVITY"?!0:Object.prototype.hasOwnProperty.call(e,"ideVersion")}function Io(e,t){return typeof e!="string"||!e.includes("antigravity/")?e:e.replace(/antigravity\/[^\s]+/,`antigravity/${t}`)}function zf(e,t){let a={...t},r=Io(a["user-agent"],mr),n=r!==a["user-agent"];n&&(a["user-agent"]=r);try{let s=JSON.parse(e.toString());return Gf(s?.metadata)?(s.metadata.ideVersion=mr,{bodyBuffer:Buffer.from(JSON.stringify(s)),headers:a,applied:!0,version:mr}):{bodyBuffer:e,headers:a,applied:n,version:mr}}catch{return{bodyBuffer:e,headers:a,applied:n,version:mr}}}Ao.exports={ANTIGRAVITY_IDE_VERSION:mr,applyAntigravityIdeVersionOverride:zf,rewriteAntigravityUserAgent:Io}});var Fr=F((gp,Ro)=>{var{log:Aa,err:Cr}=_t(),Qf=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t++){let a=t;for(let r=0;r<8;r++)a=a&1?3988292384^a>>>1:a>>>1;e[t]=a>>>0}return e})();function bo(e){let t=4294967295;for(let a=0;a<e.length;a++)t=Qf[(t^e[a])&255]^t>>>8;return(t^4294967295)>>>0}function Ln(e,t){let a=Buffer.from(e,"utf8"),r=Buffer.from(t,"utf8");if(a.length>255)throw new Error("EventStream header name too long");if(r.length>65535)throw new Error("EventStream header value too long");let n=Buffer.alloc(1+a.length+1+2+r.length),s=0;return n[s++]=a.length,a.copy(n,s),s+=a.length,n[s++]=7,n.writeUInt16BE(r.length,s),s+=2,r.copy(n,s),n}function _o(e,t="internalServerException"){let a=Buffer.from(JSON.stringify({message:String(e||"Upstream error")}),"utf8"),r=Buffer.concat([Ln(":message-type","exception"),Ln(":exception-type",t),Ln(":content-type","application/json")]),n=12+r.length+a.length+4,s=Buffer.alloc(n);return s.writeUInt32BE(n,0),s.writeUInt32BE(r.length,4),s.writeUInt32BE(bo(s.slice(0,8)),8),r.copy(s,12),a.copy(s,12+r.length),s.writeUInt32BE(bo(s.slice(0,n-4)),n-4),s}async function $f(e){try{let t=await e.text();if(!t)return`Upstream ${e.status}`;let a=t.toLowerCase();if(a.includes("monthly_request_count")||a.includes("servicequotaexceeded")||e.status===402&&a.includes("reached the limit"))return"Monthly Kiro quota exhausted on this account. Add another Kiro connection in kRouter dashboard, or wait until next billing cycle. (Provider returned MONTHLY_REQUEST_COUNT.)";try{let r=JSON.parse(t);return r?.error?.message||r?.message||r?.error||t.slice(0,500)}catch{return t.slice(0,500)}}catch{return`Upstream ${e.status}`}}var wo="http://localhost:20128",Yf=String(process.env.MITM_ROUTER_BASE||wo).trim().replace(/\/+$/,"")||wo,No=process.env.ROUTER_API_KEY,jf=new Set(["host","content-length","connection","transfer-encoding","content-type","authorization"]);async function Wf(e,t="/v1/chat/completions",a={}){let r={};for(let[s,i]of Object.entries(a))jf.has(s.toLowerCase())||(r[s]=i);return await fetch(`${Yf}${t}`,{method:"POST",headers:{...r,"Content-Type":"application/json",...No&&{Authorization:`Bearer ${No}`}},body:JSON.stringify(e)})}async function Xf(e,t,a){let r=e.headers.get("content-type")||"application/json",n=e.status||200,s={"Content-Type":r,"Cache-Control":"no-cache",Connection:"keep-alive"};if(r.includes("text/event-stream")&&(s["X-Accel-Buffering"]="no"),t.writeHead(n,s),a&&a.writeHeader(e.status,Object.fromEntries(e.headers)),!e.body){let u=await e.text().catch(()=>"");a&&(a.writeChunk(u),a.end()),t.end(u);return}let i=e.body.getReader(),o=new TextDecoder;try{for(;;){let{done:u,value:l}=await i.read();if(u)break;a&&a.writeChunk(l),t.write(o.decode(l,{stream:!0}))}}catch(u){Cr(`[MITM] pipeSSE upstream read failed: ${u.message}`),a&&a.writeChunk(`
25
+ `,s};Ia.publicKeyToOpenSSH=function(e,t){var a="ssh-rsa";t=t||"";var r=Ce.util.createBuffer();return Cr(r,a),Et(r,e.e),Et(r,e.n),a+" "+Ce.util.encode64(r.bytes())+" "+t};Ia.privateKeyToOpenSSH=function(e,t){return t?Ce.pki.encryptRsaPrivateKey(e,t,{legacy:!0,algorithm:"aes128"}):Ce.pki.privateKeyToPem(e)};Ia.getPublicKeyFingerprint=function(e,t){t=t||{};var a=t.md||Ce.md.md5.create(),r="ssh-rsa",n=Ce.util.createBuffer();Cr(n,r),Et(n,e.e),Et(n,e.n),a.start(),a.update(n.getBytes());var s=a.digest();if(t.encoding==="hex"){var i=s.toHex();return t.delimiter?i.match(/.{2}/g).join(t.delimiter):i}else{if(t.encoding==="binary")return s.getBytes();if(t.encoding)throw new Error('Unknown encoding "'+t.encoding+'".')}return s};function Et(e,t){var a=t.toString(16);a[0]>="8"&&(a="00"+a);var r=Ce.util.hexToBytes(a);e.putInt32(r.length),e.putBytes(r)}function Cr(e,t){e.putInt32(t.length),e.putString(t)}function Ta(){for(var e=Ce.md.sha1.create(),t=arguments.length,a=0;a<t;++a)e.update(arguments[a]);return e.digest()}});var go=F((lp,po)=>{po.exports=$();Rt();ks();lt();Yr();_r();Xs();or();to();io();oo();nn();ia();Qt();Ja();un();co();cn();en();Ga();da();tt();$a();ho();yn();re()});var Co=F((cp,mo)=>{var yo=require("path"),Xe=require("fs"),Je=go(),{MITM_DIR:Aa}=nr(),Kt=yo.join(Aa,"rootCA.key"),Bt=yo.join(Aa,"rootCA.crt");function vo(e){try{let t=Je.pki.certificateFromPem(Xe.readFileSync(e,"utf8")),a=new Date(Date.now()+720*60*60*1e3);return t.validity.notAfter<a}catch{return!0}}async function kf(){let e=Xe.existsSync(Kt)&&Xe.existsSync(Bt);if(e&&!vo(Bt))return console.log("\u2705 Root CA already exists"),{key:Kt,cert:Bt};if(e){console.log("\u{1F510} Root CA expired or expiring soon \u2014 regenerating...");try{Xe.unlinkSync(Kt)}catch{}try{Xe.unlinkSync(Bt)}catch{}}Xe.existsSync(Aa)||Xe.mkdirSync(Aa,{recursive:!0}),console.log("\u{1F510} Generating Root CA certificate...");let t=Je.pki.rsa.generateKeyPair(2048),a=Je.pki.createCertificate();a.publicKey=t.publicKey,a.serialNumber="01",a.validity.notBefore=new Date,a.validity.notAfter=new Date,a.validity.notAfter.setFullYear(a.validity.notBefore.getFullYear()+10);let r=[{name:"commonName",value:"9Router MITM Root CA"},{name:"organizationName",value:"kRouter"},{name:"countryName",value:"US"}];a.setSubject(r),a.setIssuer(r),a.setExtensions([{name:"basicConstraints",cA:!0,critical:!0},{name:"keyUsage",keyCertSign:!0,cRLSign:!0,critical:!0},{name:"subjectKeyIdentifier"}]),a.sign(t.privateKey,Je.md.sha256.create());let n=Je.pki.privateKeyToPem(t.privateKey),s=Je.pki.certificateToPem(a);return Xe.writeFileSync(Kt,n),Xe.writeFileSync(Bt,s),console.log("\u2705 Root CA generated successfully"),{key:Kt,cert:Bt}}function Df(){if(!Xe.existsSync(Kt)||!Xe.existsSync(Bt))throw new Error("Root CA not found. Generate it first.");let e=Xe.readFileSync(Kt,"utf8"),t=Xe.readFileSync(Bt,"utf8");return{key:Je.pki.privateKeyFromPem(e),cert:Je.pki.certificateFromPem(t)}}function Uf(e,t){let a=Je.pki.rsa.generateKeyPair(2048),r=Je.pki.createCertificate();return r.publicKey=a.publicKey,r.serialNumber=Math.floor(Math.random()*1e6).toString(),r.validity.notBefore=new Date,r.validity.notAfter=new Date,r.validity.notAfter.setFullYear(r.validity.notBefore.getFullYear()+1),r.setSubject([{name:"commonName",value:e}]),r.setIssuer(t.cert.subject.attributes),r.setExtensions([{name:"basicConstraints",cA:!1},{name:"keyUsage",digitalSignature:!0,keyEncipherment:!0},{name:"extKeyUsage",serverAuth:!0,clientAuth:!0},{name:"subjectAltName",altNames:[{type:2,value:e},{type:2,value:`*.${e}`}]}]),r.sign(t.key,Je.md.sha256.create()),{key:Je.pki.privateKeyToPem(a.privateKey),cert:Je.pki.certificateToPem(r)}}mo.exports={generateRootCA:kf,loadRootCA:Df,generateLeafCert:Uf,isCertExpired:vo,ROOT_CA_CERT_PATH:Bt,ROOT_CA_KEY_PATH:Kt}});var xo=F((pp,Eo)=>{var fp=require("path"),dp=require("fs"),{MITM_DIR:hp}=nr(),{generateRootCA:Pf,loadRootCA:Of,generateLeafCert:Vf}=Co();async function Ff(){return await Pf()}function Kf(e){try{let t=Of(),a=Vf(e,t);return{key:a.key,cert:a.cert}}catch(t){return console.error(`Failed to generate cert for ${e}:`,t.message),null}}Eo.exports={generateCert:Ff,getCertForDomain:Kf}});var Ao=F((gp,Io)=>{var So=require("fs"),Mf=require("path"),{DATA_DIR:qf}=nr(),To=Mf.join(qf,"mitm","aliases.json");function Hf(){try{return So.existsSync(To)?JSON.parse(So.readFileSync(To,"utf-8")):null}catch{return null}}function Gf(e){return Hf()?.[e]||null}Io.exports={getMitmAlias:Gf}});var _o=F((yp,bo)=>{"use strict";var Er="1.23.2";function zf(e){return!e||typeof e!="object"||Array.isArray(e)?!1:String(e.ideName||"").toLowerCase()==="antigravity"||String(e.ideType||"").toUpperCase()==="ANTIGRAVITY"?!0:Object.prototype.hasOwnProperty.call(e,"ideVersion")}function Bo(e,t){return typeof e!="string"||!e.includes("antigravity/")?e:e.replace(/antigravity\/[^\s]+/,`antigravity/${t}`)}function Qf(e,t){let a={...t},r=Bo(a["user-agent"],Er),n=r!==a["user-agent"];n&&(a["user-agent"]=r);try{let s=JSON.parse(e.toString());return zf(s?.metadata)?(s.metadata.ideVersion=Er,{bodyBuffer:Buffer.from(JSON.stringify(s)),headers:a,applied:!0,version:Er}):{bodyBuffer:e,headers:a,applied:n,version:Er}}catch{return{bodyBuffer:e,headers:a,applied:n,version:Er}}}bo.exports={ANTIGRAVITY_IDE_VERSION:Er,applyAntigravityIdeVersionOverride:Qf,rewriteAntigravityUserAgent:Bo}});var Kr=F((vp,ko)=>{var{log:Ba,err:xr}=_t(),$f=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t++){let a=t;for(let r=0;r<8;r++)a=a&1?3988292384^a>>>1:a>>>1;e[t]=a>>>0}return e})();function wo(e){let t=4294967295;for(let a=0;a<e.length;a++)t=$f[(t^e[a])&255]^t>>>8;return(t^4294967295)>>>0}function kn(e,t){let a=Buffer.from(e,"utf8"),r=Buffer.from(t,"utf8");if(a.length>255)throw new Error("EventStream header name too long");if(r.length>65535)throw new Error("EventStream header value too long");let n=Buffer.alloc(1+a.length+1+2+r.length),s=0;return n[s++]=a.length,a.copy(n,s),s+=a.length,n[s++]=7,n.writeUInt16BE(r.length,s),s+=2,r.copy(n,s),n}function No(e,t="internalServerException"){let a=Buffer.from(JSON.stringify({message:String(e||"Upstream error")}),"utf8"),r=Buffer.concat([kn(":message-type","exception"),kn(":exception-type",t),kn(":content-type","application/json")]),n=12+r.length+a.length+4,s=Buffer.alloc(n);return s.writeUInt32BE(n,0),s.writeUInt32BE(r.length,4),s.writeUInt32BE(wo(s.slice(0,8)),8),r.copy(s,12),a.copy(s,12+r.length),s.writeUInt32BE(wo(s.slice(0,n-4)),n-4),s}async function Yf(e){try{let t=await e.text();if(!t)return`Upstream ${e.status}`;let a=t.toLowerCase();if(a.includes("monthly_request_count")||a.includes("servicequotaexceeded")||e.status===402&&a.includes("reached the limit"))return"Monthly Kiro quota exhausted on this account. Add another Kiro connection in kRouter dashboard, or wait until next billing cycle. (Provider returned MONTHLY_REQUEST_COUNT.)";try{let r=JSON.parse(t);return r?.error?.message||r?.message||r?.error||t.slice(0,500)}catch{return t.slice(0,500)}}catch{return`Upstream ${e.status}`}}var Ro="http://localhost:20128",jf=String(process.env.MITM_ROUTER_BASE||Ro).trim().replace(/\/+$/,"")||Ro,Lo=process.env.ROUTER_API_KEY,Wf=new Set(["host","content-length","connection","transfer-encoding","content-type","authorization"]);async function Xf(e,t="/v1/chat/completions",a={}){let r={};for(let[s,i]of Object.entries(a))Wf.has(s.toLowerCase())||(r[s]=i);return await fetch(`${jf}${t}`,{method:"POST",headers:{...r,"Content-Type":"application/json",...Lo&&{Authorization:`Bearer ${Lo}`}},body:JSON.stringify(e)})}async function Jf(e,t,a){let r=e.headers.get("content-type")||"application/json",n=e.status||200,s={"Content-Type":r,"Cache-Control":"no-cache",Connection:"keep-alive"};if(r.includes("text/event-stream")&&(s["X-Accel-Buffering"]="no"),t.writeHead(n,s),a&&a.writeHeader(e.status,Object.fromEntries(e.headers)),!e.body){let u=await e.text().catch(()=>"");a&&(a.writeChunk(u),a.end()),t.end(u);return}let i=e.body.getReader(),o=new TextDecoder;try{for(;;){let{done:u,value:l}=await i.read();if(u)break;a&&a.writeChunk(l),t.write(o.decode(l,{stream:!0}))}}catch(u){xr(`[MITM] pipeSSE upstream read failed: ${u.message}`),a&&a.writeChunk(`
26
26
  [ERROR] ${u.message}
27
- `)}finally{if(a)try{a.end()}catch{}if(!t.writableEnded)try{t.end()}catch{}}}async function Jf(e,t,a,r){let n=e.headers.get("content-type")||"application/json",s={"Content-Type":n,"Cache-Control":"no-cache",Connection:"keep-alive"};if(n.includes("text/event-stream")&&(s["X-Accel-Buffering"]="no"),t.writeHead(200,s),!e.body){t.end(await e.text().catch(()=>""));return}let i=e.body.getReader(),o=new TextDecoder("utf-8",{fatal:!1}),u="",l=null;try{for(;;){let{done:c,value:f}=await i.read();if(c)break;u+=o.decode(f,{stream:!0});let g=u.split(`
28
- `);u=g.pop()||"";for(let v of g){let y=v.trim();if(!y||!y.startsWith("data:"))continue;let x=y.slice(5).trim();if(x!=="[DONE]"){process.env.DEBUG_MITM&&Aa(`[SSE in] ${x.slice(0,200)}`);try{let S=JSON.parse(x),I=a(S,r);if(I!=null){let B=Array.isArray(I)?I:[I];for(let b of B){if(process.env.DEBUG_MITM){let P=b.length||b.byteLength||0;Aa(`[write binary frame] (${P}B) first 20B: ${Array.from(b.slice(0,20)).join(",")}`)}t.write(Buffer.from(b))}}}catch{}}}}}catch(c){l=c,Cr(`[MITM] pipeTransformedSSE upstream read failed: ${c.message}`)}finally{try{let c=a(null,r);if(c!=null){let f=Array.isArray(c)?c:[c];for(let g of f)t.write(g)}}catch{}if(l&&!t.writableEnded)try{t.write(`data: ${JSON.stringify({error:{message:`Upstream read failed: ${l.message}`,type:"mitm_upstream_error"}})}
27
+ `)}finally{if(a)try{a.end()}catch{}if(!t.writableEnded)try{t.end()}catch{}}}async function Zf(e,t,a,r){let n=e.headers.get("content-type")||"application/json",s={"Content-Type":n,"Cache-Control":"no-cache",Connection:"keep-alive"};if(n.includes("text/event-stream")&&(s["X-Accel-Buffering"]="no"),t.writeHead(200,s),!e.body){t.end(await e.text().catch(()=>""));return}let i=e.body.getReader(),o=new TextDecoder("utf-8",{fatal:!1}),u="",l=null;try{for(;;){let{done:c,value:f}=await i.read();if(c)break;u+=o.decode(f,{stream:!0});let g=u.split(`
28
+ `);u=g.pop()||"";for(let v of g){let y=v.trim();if(!y||!y.startsWith("data:"))continue;let x=y.slice(5).trim();if(x!=="[DONE]"){process.env.DEBUG_MITM&&Ba(`[SSE in] ${x.slice(0,200)}`);try{let S=JSON.parse(x),T=a(S,r);if(T!=null){let B=Array.isArray(T)?T:[T];for(let b of B){if(process.env.DEBUG_MITM){let P=b.length||b.byteLength||0;Ba(`[write binary frame] (${P}B) first 20B: ${Array.from(b.slice(0,20)).join(",")}`)}t.write(Buffer.from(b))}}}catch{}}}}}catch(c){l=c,xr(`[MITM] pipeTransformedSSE upstream read failed: ${c.message}`)}finally{try{let c=a(null,r);if(c!=null){let f=Array.isArray(c)?c:[c];for(let g of f)t.write(g)}}catch{}if(l&&!t.writableEnded)try{t.write(`data: ${JSON.stringify({error:{message:`Upstream read failed: ${l.message}`,type:"mitm_upstream_error"}})}
29
29
 
30
30
  data: [DONE]
31
31
 
32
- `)}catch{}if(!t.writableEnded)try{t.end()}catch{}}}async function Zf(e,t,a,r){let n={"Content-Type":"application/vnd.amazon.eventstream","Cache-Control":"no-cache",Connection:"keep-alive"};if(!e.ok){let l=await $f(e);Cr(`[MITM] upstream ${e.status}: ${l}`),t.writeHead(200,n);try{t.write(_o(`[${e.status}] ${l}`))}catch(c){Cr(`[MITM] exception frame write failed: ${c.message}`)}t.end();return}if(t.writeHead(200,n),!e.body){t.end(await e.text().catch(()=>""));return}let s=e.body.getReader(),i=new TextDecoder("utf-8",{fatal:!1}),o="",u=null;try{for(;;){let{done:l,value:c}=await s.read();if(l)break;o+=i.decode(c,{stream:!0});let f=o.split(`
33
- `);o=f.pop()||"";for(let g of f){let v=g.trim();if(!v||!v.startsWith("data:"))continue;let y=v.slice(5).trim();if(y!=="[DONE]"){process.env.DEBUG_MITM&&Aa(`[SSE in] ${y.slice(0,200)}`);try{let x=JSON.parse(y),S=a(x,r);if(S!=null){let I=Array.isArray(S)?S:[S];for(let B of I){if(process.env.DEBUG_MITM){let b=B.length||B.byteLength||0;Aa(`[write binary frame] (${b}B) first 20B: ${Array.from(B.slice(0,20)).join(",")}`)}t.write(Buffer.from(B))}}}catch{}}}}}catch(l){u=l,Cr(`[MITM] pipeTransformedEventStream upstream read failed: ${l.message}`)}finally{try{let l=a(null,r);if(l!=null){let c=Array.isArray(l)?l:[l];for(let f of c)t.write(f)}}catch{}if(u&&!t.writableEnded)try{t.write(_o(`Upstream read failed: ${u.message}`))}catch(l){Cr(`[MITM] terminal exception frame write failed: ${l.message}`)}if(!t.writableEnded)try{t.end()}catch{}}}Ro.exports={fetchRouter:Wf,pipeSSE:Xf,pipeTransformedSSE:Jf,pipeTransformedEventStream:Zf}});var ko=F((yp,Lo)=>{var{err:ed,createResponseDumper:td}=_t(),{IS_DEV:rd}=Sr(),{fetchRouter:ad,pipeSSE:nd}=Fr();async function id(e,t,a,r){let n=rd?td(e,"intercept-antigravity"):null,s=e.url.includes(":streamGenerateContent");try{let i=JSON.parse(a.toString());i.model&&(i.model=r);let o=await ad(i,"/v1/chat/completions",e.headers);await nd(o,t,n)}catch(i){ed(`[antigravity] ${i.message}`),n&&(n.writeChunk(`
32
+ `)}catch{}if(!t.writableEnded)try{t.end()}catch{}}}async function ed(e,t,a,r){let n={"Content-Type":"application/vnd.amazon.eventstream","Cache-Control":"no-cache",Connection:"keep-alive"};if(!e.ok){let l=await Yf(e);xr(`[MITM] upstream ${e.status}: ${l}`),t.writeHead(200,n);try{t.write(No(`[${e.status}] ${l}`))}catch(c){xr(`[MITM] exception frame write failed: ${c.message}`)}t.end();return}if(t.writeHead(200,n),!e.body){t.end(await e.text().catch(()=>""));return}let s=e.body.getReader(),i=new TextDecoder("utf-8",{fatal:!1}),o="",u=null;try{for(;;){let{done:l,value:c}=await s.read();if(l)break;o+=i.decode(c,{stream:!0});let f=o.split(`
33
+ `);o=f.pop()||"";for(let g of f){let v=g.trim();if(!v||!v.startsWith("data:"))continue;let y=v.slice(5).trim();if(y!=="[DONE]"){process.env.DEBUG_MITM&&Ba(`[SSE in] ${y.slice(0,200)}`);try{let x=JSON.parse(y),S=a(x,r);if(S!=null){let T=Array.isArray(S)?S:[S];for(let B of T){if(process.env.DEBUG_MITM){let b=B.length||B.byteLength||0;Ba(`[write binary frame] (${b}B) first 20B: ${Array.from(B.slice(0,20)).join(",")}`)}t.write(Buffer.from(B))}}}catch{}}}}}catch(l){u=l,xr(`[MITM] pipeTransformedEventStream upstream read failed: ${l.message}`)}finally{try{let l=a(null,r);if(l!=null){let c=Array.isArray(l)?l:[l];for(let f of c)t.write(f)}}catch{}if(u&&!t.writableEnded)try{t.write(No(`Upstream read failed: ${u.message}`))}catch(l){xr(`[MITM] terminal exception frame write failed: ${l.message}`)}if(!t.writableEnded)try{t.end()}catch{}}}ko.exports={fetchRouter:Xf,pipeSSE:Jf,pipeTransformedSSE:Zf,pipeTransformedEventStream:ed}});var Uo=F((mp,Do)=>{var{err:td,createResponseDumper:rd}=_t(),{IS_DEV:ad}=Tr(),{fetchRouter:nd,pipeSSE:id}=Kr();async function sd(e,t,a,r){let n=ad?rd(e,"intercept-antigravity"):null,s=e.url.includes(":streamGenerateContent");try{let i=JSON.parse(a.toString());i.model&&(i.model=r);let o=await nd(i,"/v1/chat/completions",e.headers);await id(o,t,n)}catch(i){td(`[antigravity] ${i.message}`),n&&(n.writeChunk(`
34
34
  [ERROR] ${i.message}
35
35
  `),n.end()),s?(t.headersSent||t.writeHead(200,{"Content-Type":"text/event-stream"}),t.end(`data: ${JSON.stringify({error:{message:i.message}})}\r
36
36
  \r
37
- `)):(t.headersSent||t.writeHead(500,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:{message:i.message,type:"mitm_error"}})))}}Lo.exports={intercept:id}});var Uo=F((vp,Do)=>{var{err:sd}=_t(),{fetchRouter:od,pipeSSE:ud}=Fr(),ld={"/chat/completions":"/v1/chat/completions","/v1/messages":"/v1/messages","/responses":"/v1/responses"};function cd(e){for(let[t,a]of Object.entries(ld))if(e.includes(t))return a;return"/v1/chat/completions"}async function fd(e,t,a,r){try{let n=JSON.parse(a.toString());n.model=r;let s=cd(e.url),i=await od(n,s,e.headers);await ud(i,t)}catch(n){sd(`[copilot] ${n.message}`),t.headersSent||t.writeHead(500,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:{message:n.message,type:"mitm_error"}}))}}Do.exports={intercept:fd}});var Go=F((mp,Ho)=>{var{err:dd}=_t(),{IS_DEV:hd}=Sr(),{fetchRouter:pd,pipeTransformedEventStream:gd}=Fr(),yd=require("fs"),vd=require("path"),md=vd.join(__dirname,"../../../data/logs/mitm/kiro-debug.log");function Po(e){if(hd)try{yd.appendFileSync(md,`${new Date().toISOString()} ${e}
38
- `)}catch{}}var Cd=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t++){let a=t;for(let r=0;r<8;r++)a=a&1?3988292384^a>>>1:a>>>1;e[t]=a}return e})();function Oo(e){let t=4294967295;for(let a=0;a<e.length;a++)t=t>>>8^Cd[(t^e[a])&255];return(t^4294967295)>>>0}function Ed(e){return{modelId:e||null,toolCallInit:{},hasToolCalls:!1,finishSent:!1,usage:null,inThink:!1,thinkBuf:""}}function qo(e,t){if(!e)return{thinking:null,text:null};let a=e;t.inThink&&t.thinkBuf&&(a=t.thinkBuf+a,t.thinkBuf="",t.inThink=!1);let r=/<thinking>|<think>/i,n=a.match(r);if(!n)return{thinking:null,text:a};let s=n[0].toLowerCase(),i=s==="<think>"?"</think>":"</thinking>",o=n.index,u=a.indexOf(i,o+s.length);if(u===-1)return t.inThink=!0,t.thinkBuf=a.slice(o),{thinking:null,text:a.slice(0,o).trim()||null};let l=a.slice(o+s.length,u),c=a.slice(0,o).trim(),f=a.slice(u+i.length).trim(),g=[c,f].filter(Boolean).join(""),v=g?qo(g,{inThink:!1,thinkBuf:""}):{thinking:null,text:null};return{thinking:l||null,text:v.text||null}}var Vo=255,Fo=65535,Ko=16*1024*1024;function kn(e,t){let a=Buffer.from(e,"utf8"),r=Buffer.from(t,"utf8");if(a.length>Vo)throw new Error(`EventStream header name too long (${a.length} > ${Vo}): ${e.slice(0,32)}\u2026`);if(r.length>Fo)throw new Error(`EventStream header value too long (${r.length} > ${Fo}) for ${e}`);let n=Buffer.alloc(1+a.length+1+2+r.length),s=0;return n[s++]=a.length,a.copy(n,s),s+=a.length,n[s++]=7,n.writeUInt16BE(r.length,s),s+=2,r.copy(n,s),n}function xt(e,t){let a=Buffer.from(typeof t=="string"?t:JSON.stringify(t),"utf8"),r=Buffer.concat([kn(":message-type","event"),kn(":event-type",e),kn(":content-type","application/json")]),n=r.length,s=12+n+a.length+4;if(s>Ko)throw new Error(`EventStream frame too large (${s} bytes > ${Ko}) for event ${e}`);let i=Buffer.alloc(s);return i.writeUInt32BE(s,0),i.writeUInt32BE(n,4),i.writeUInt32BE(Oo(i.slice(0,8)),8),r.copy(i,12),a.copy(i,12+n),i.writeUInt32BE(Oo(i.slice(0,s-4)),s-4),i}function xd(e){if(typeof e=="string")return e;if(e==null)return"{}";try{return JSON.stringify(e)}catch{return"{}"}}function Mo(e){let t=[],a=e.userInputMessageContext?.toolResults||[];for(let i of a){let o=(i.content||[]).map(u=>u.text||"").join(`
39
- `);t.push({role:"tool",tool_call_id:i.toolUseId||"",content:o})}let r=Array.isArray(e.images)?e.images:[],n=[];for(let i of r){let o=i?.source?.bytes;if(!o)continue;let u=(i?.format||"png").toLowerCase(),c=new Set(["png","jpeg","jpg","gif","webp"]).has(u)?`image/${u==="jpg"?"jpeg":u}`:"image/png";n.push({type:"image_url",image_url:{url:`data:${c};base64,${o}`}})}let s=(e.content||"").trim();if(s||n.length>0||a.length===0)if(n.length>0){let i=[];s&&i.push({type:"text",text:s}),i.push(...n),t.push({role:"user",content:i})}else t.push({role:"user",content:s});return t}function Sd(e){let t=e.toolUses||[];return t.length>0?{role:"assistant",content:e.content||null,tool_calls:t.map(a=>({id:a.toolUseId||`call_${Date.now()}`,type:"function",function:{name:a.name||"",arguments:xd(a.input)}}))}:{role:"assistant",content:e.content||""}}function Td(e){let t=e.conversationState||{},a=t.history||[],r=t.currentMessage,n=[];for(let s of a)s.userInputMessage?n.push(...Mo(s.userInputMessage)):s.assistantResponseMessage&&n.push(Sd(s.assistantResponseMessage));return r?.userInputMessage&&n.push(...Mo(r.userInputMessage)),n}function Id(e){let t=e.conversationState||{},a=t.currentMessage?.userInputMessage?.userInputMessageContext?.tools||[],r=t.history?.find(s=>s.userInputMessage?.userInputMessageContext?.tools)?.userInputMessage?.userInputMessageContext?.tools||[],n=a.length>0?a:r;return n.length?n.map(s=>{let i=s.toolSpecification||s;return{type:"function",function:{name:i.name||"",description:i.description||`Tool: ${i.name||"unknown"}`,parameters:i.inputSchema?.json||{type:"object",properties:{},required:[]}}}}):[]}function Ad(e,t){if(!e){if(t.finishSent)return null;if(t.inThink&&t.thinkBuf){t.inThink=!1;let i=t.thinkBuf;return t.thinkBuf="",xt("reasoningContentEvent",{content:i,modelId:t.modelId||"kiro-unknown"})}return xt("messageStopEvent",{})}let a=[],r=e.choices?.[0],n=r?.delta||{};!t.modelId&&e.model&&(t.modelId=e.model);let s=t.modelId||"unknown";if(e.usage&&(t.usage=e.usage),n.tool_calls){t.hasToolCalls=!0;for(let i of n.tool_calls){let o=i.index??0;if(i.id&&i.function?.name&&!t.toolCallInit[o]&&(t.toolCallInit[o]={id:i.id,name:i.function.name},Po(`toolUseEvent init: ${i.function.name} (${i.id})`),a.push(xt("toolUseEvent",{name:i.function.name,toolUseId:i.id}))),i.function?.arguments){let u=t.toolCallInit[o];Po(`toolUseEvent fragment: ${i.function.arguments.slice(0,100)}`),a.push(xt("toolUseEvent",{input:i.function.arguments,name:u?.name||i.function?.name||"",toolUseId:u?.id||i.id||""}))}}}if(n.reasoning_content&&a.push(xt("reasoningContentEvent",{content:n.reasoning_content,modelId:s})),n.content){let{thinking:i,text:o}=qo(n.content,t);i&&a.push(xt("reasoningContentEvent",{content:i,modelId:s})),o&&a.push(xt("assistantResponseEvent",{content:o,modelId:s}))}if(r?.finish_reason){let i=Bd(t);i&&a.push(...Array.isArray(i)?i:[i])}return a.length===0?null:a.length===1?a[0]:a}function Bd(e){let t=[];if(e.hasToolCalls)for(let a of Object.keys(e.toolCallInit).sort()){let r=e.toolCallInit[a];t.push(xt("toolUseEvent",{name:r.name,stop:!0,toolUseId:r.id}))}else t.push(xt("messageStopEvent",{}));return e.finishSent=!0,e.usage&&t.push(xt("usageEvent",{inputTokens:e.usage.prompt_tokens||0,outputTokens:e.usage.completion_tokens||0})),e.toolCallInit={},t.length>0?t:null}async function bd(e,t,a,r){try{if(_d(a))throw new Error(`Binary EventStream format detected (${a.length}B) - request should use passthrough instead of intercept`);let n=JSON.parse(a.toString()),s=Td(n);if(s.length===0)throw new Error("codeWhispererToMessages produced 0 messages \u2014 check request body");let i=Id(n),o={model:r,messages:s,stream:!0,...i.length>0&&{tools:i,tool_choice:"auto"}},u=await pd(o,"/v1/chat/completions",e.headers),l=Ed(r);await gd(u,t,Ad,l)}catch(n){dd(`[Kiro MITM] Request processing failed: ${n.message}`),t.headersSent||t.writeHead(500,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:{message:n.message,type:"mitm_error",handler:"kiro"}}))}}function _d(e){if(!e||e.length<12)return!1;let t=e.readUInt32BE(0),a=e.readUInt32BE(4);return t>12&&t<1e6&&a<t-12}Ho.exports={intercept:bd}});var Qo=F((Cp,zo)=>{async function wd(e,t){t.writeHead(501,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:{message:"Cursor MITM support is coming soon.",type:"not_implemented"}}))}zo.exports={intercept:wd}});var Yo=F((Ep,$o)=>{var{err:Nd}=_t(),{fetchRouter:Rd,pipeSSE:Ld}=Fr();async function kd(e,t,a,r){try{let n=JSON.parse(a.toString());n.model&&r&&(n.model=r);let s=e.url.includes("count_tokens")?"/v1/messages/count_tokens":"/v1/messages",i=await Rd(n,s,e.headers);await Ld(i,t)}catch(n){Nd(`[claude] ${n.message}`),t.headersSent||t.writeHead(500,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:{message:n.message,type:"mitm_error"}}))}}$o.exports={intercept:kd}});var Wo=F((xp,jo)=>{var Dd={antigravity:["daily-cloudcode-pa.googleapis.com","cloudcode-pa.googleapis.com"],copilot:["api.individual.githubcopilot.com"],kiro:["runtime.us-east-1.kiro.dev","q.us-east-1.amazonaws.com","codewhisperer.us-east-1.amazonaws.com"],cursor:["api2.cursor.sh"],claude:["api.anthropic.com"]};jo.exports={TOOL_HOSTS:Dd}});var ru=F((Sp,tu)=>{var{exec:Xo,execSync:Ud}=require("child_process"),Jo=process.platform==="win32";function Zo(){if(Jo)try{return Ud("net session >nul 2>&1",{windowsHide:!0,stdio:"ignore"}),!0}catch{return!1}return typeof process.getuid=="function"&&process.getuid()===0}function eu(e){return`'${String(e).replace(/'/g,"''")}'`}function Pd(e){if(!Jo)return Promise.reject(new Error("Windows-only"));let t=Buffer.from(e,"utf16le").toString("base64");if(Zo())return new Promise((r,n)=>{Xo(`powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand ${t}`,{windowsHide:!0},(s,i,o)=>{s?n(new Error(o||s.message)):r(i)})});let a=`
37
+ `)):(t.headersSent||t.writeHead(500,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:{message:i.message,type:"mitm_error"}})))}}Do.exports={intercept:sd}});var Oo=F((Cp,Po)=>{var{err:od}=_t(),{fetchRouter:ud,pipeSSE:ld}=Kr(),cd={"/chat/completions":"/v1/chat/completions","/v1/messages":"/v1/messages","/responses":"/v1/responses"};function fd(e){for(let[t,a]of Object.entries(cd))if(e.includes(t))return a;return"/v1/chat/completions"}async function dd(e,t,a,r){try{let n=JSON.parse(a.toString());n.model=r;let s=fd(e.url),i=await ud(n,s,e.headers);await ld(i,t)}catch(n){od(`[copilot] ${n.message}`),t.headersSent||t.writeHead(500,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:{message:n.message,type:"mitm_error"}}))}}Po.exports={intercept:dd}});var Qo=F((Ep,zo)=>{var{err:hd}=_t(),{IS_DEV:pd}=Tr(),{fetchRouter:gd,pipeTransformedEventStream:yd}=Kr(),vd=require("fs"),md=require("path"),Cd=md.join(__dirname,"../../../data/logs/mitm/kiro-debug.log");function Vo(e){if(pd)try{vd.appendFileSync(Cd,`${new Date().toISOString()} ${e}
38
+ `)}catch{}}var Ed=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t++){let a=t;for(let r=0;r<8;r++)a=a&1?3988292384^a>>>1:a>>>1;e[t]=a}return e})();function Fo(e){let t=4294967295;for(let a=0;a<e.length;a++)t=t>>>8^Ed[(t^e[a])&255];return(t^4294967295)>>>0}function xd(e){return{modelId:e||null,toolCallInit:{},hasToolCalls:!1,finishSent:!1,usage:null,inThink:!1,thinkBuf:""}}function Go(e,t){if(!e)return{thinking:null,text:null};let a=e;t.inThink&&t.thinkBuf&&(a=t.thinkBuf+a,t.thinkBuf="",t.inThink=!1);let r=/<thinking>|<think>/i,n=a.match(r);if(!n)return{thinking:null,text:a};let s=n[0].toLowerCase(),i=s==="<think>"?"</think>":"</thinking>",o=n.index,u=a.indexOf(i,o+s.length);if(u===-1)return t.inThink=!0,t.thinkBuf=a.slice(o),{thinking:null,text:a.slice(0,o).trim()||null};let l=a.slice(o+s.length,u),c=a.slice(0,o).trim(),f=a.slice(u+i.length).trim(),g=[c,f].filter(Boolean).join(""),v=g?Go(g,{inThink:!1,thinkBuf:""}):{thinking:null,text:null};return{thinking:l||null,text:v.text||null}}var Ko=255,Mo=65535,qo=16*1024*1024;function Dn(e,t){let a=Buffer.from(e,"utf8"),r=Buffer.from(t,"utf8");if(a.length>Ko)throw new Error(`EventStream header name too long (${a.length} > ${Ko}): ${e.slice(0,32)}\u2026`);if(r.length>Mo)throw new Error(`EventStream header value too long (${r.length} > ${Mo}) for ${e}`);let n=Buffer.alloc(1+a.length+1+2+r.length),s=0;return n[s++]=a.length,a.copy(n,s),s+=a.length,n[s++]=7,n.writeUInt16BE(r.length,s),s+=2,r.copy(n,s),n}function xt(e,t){let a=Buffer.from(typeof t=="string"?t:JSON.stringify(t),"utf8"),r=Buffer.concat([Dn(":message-type","event"),Dn(":event-type",e),Dn(":content-type","application/json")]),n=r.length,s=12+n+a.length+4;if(s>qo)throw new Error(`EventStream frame too large (${s} bytes > ${qo}) for event ${e}`);let i=Buffer.alloc(s);return i.writeUInt32BE(s,0),i.writeUInt32BE(n,4),i.writeUInt32BE(Fo(i.slice(0,8)),8),r.copy(i,12),a.copy(i,12+n),i.writeUInt32BE(Fo(i.slice(0,s-4)),s-4),i}function Sd(e){if(typeof e=="string")return e;if(e==null)return"{}";try{return JSON.stringify(e)}catch{return"{}"}}function Ho(e){let t=[],a=e.userInputMessageContext?.toolResults||[];for(let i of a){let o=(i.content||[]).map(u=>u.text||"").join(`
39
+ `);t.push({role:"tool",tool_call_id:i.toolUseId||"",content:o})}let r=Array.isArray(e.images)?e.images:[],n=[];for(let i of r){let o=i?.source?.bytes;if(!o)continue;let u=(i?.format||"png").toLowerCase(),c=new Set(["png","jpeg","jpg","gif","webp"]).has(u)?`image/${u==="jpg"?"jpeg":u}`:"image/png";n.push({type:"image_url",image_url:{url:`data:${c};base64,${o}`}})}let s=(e.content||"").trim();if(s||n.length>0||a.length===0)if(n.length>0){let i=[];s&&i.push({type:"text",text:s}),i.push(...n),t.push({role:"user",content:i})}else t.push({role:"user",content:s});return t}function Td(e){let t=e.toolUses||[];return t.length>0?{role:"assistant",content:e.content||null,tool_calls:t.map(a=>({id:a.toolUseId||`call_${Date.now()}`,type:"function",function:{name:a.name||"",arguments:Sd(a.input)}}))}:{role:"assistant",content:e.content||""}}function Id(e){let t=e.conversationState||{},a=t.history||[],r=t.currentMessage,n=[];for(let s of a)s.userInputMessage?n.push(...Ho(s.userInputMessage)):s.assistantResponseMessage&&n.push(Td(s.assistantResponseMessage));return r?.userInputMessage&&n.push(...Ho(r.userInputMessage)),n}function Ad(e){let t=e.conversationState||{},a=t.currentMessage?.userInputMessage?.userInputMessageContext?.tools||[],r=t.history?.find(s=>s.userInputMessage?.userInputMessageContext?.tools)?.userInputMessage?.userInputMessageContext?.tools||[],n=a.length>0?a:r;return n.length?n.map(s=>{let i=s.toolSpecification||s;return{type:"function",function:{name:i.name||"",description:i.description||`Tool: ${i.name||"unknown"}`,parameters:i.inputSchema?.json||{type:"object",properties:{},required:[]}}}}):[]}function Bd(e,t){if(!e){if(t.finishSent)return null;if(t.inThink&&t.thinkBuf){t.inThink=!1;let i=t.thinkBuf;return t.thinkBuf="",xt("reasoningContentEvent",{content:i,modelId:t.modelId||"kiro-unknown"})}return xt("messageStopEvent",{})}let a=[],r=e.choices?.[0],n=r?.delta||{};!t.modelId&&e.model&&(t.modelId=e.model);let s=t.modelId||"unknown";if(e.usage&&(t.usage=e.usage),n.tool_calls){t.hasToolCalls=!0;for(let i of n.tool_calls){let o=i.index??0;if(i.id&&i.function?.name&&!t.toolCallInit[o]&&(t.toolCallInit[o]={id:i.id,name:i.function.name},Vo(`toolUseEvent init: ${i.function.name} (${i.id})`),a.push(xt("toolUseEvent",{name:i.function.name,toolUseId:i.id}))),i.function?.arguments){let u=t.toolCallInit[o];Vo(`toolUseEvent fragment: ${i.function.arguments.slice(0,100)}`),a.push(xt("toolUseEvent",{input:i.function.arguments,name:u?.name||i.function?.name||"",toolUseId:u?.id||i.id||""}))}}}if(n.reasoning_content&&a.push(xt("reasoningContentEvent",{content:n.reasoning_content,modelId:s})),n.content){let{thinking:i,text:o}=Go(n.content,t);i&&a.push(xt("reasoningContentEvent",{content:i,modelId:s})),o&&a.push(xt("assistantResponseEvent",{content:o,modelId:s}))}if(r?.finish_reason){let i=bd(t);i&&a.push(...Array.isArray(i)?i:[i])}return a.length===0?null:a.length===1?a[0]:a}function bd(e){let t=[];if(e.hasToolCalls)for(let a of Object.keys(e.toolCallInit).sort()){let r=e.toolCallInit[a];t.push(xt("toolUseEvent",{name:r.name,stop:!0,toolUseId:r.id}))}else t.push(xt("messageStopEvent",{}));return e.finishSent=!0,e.usage&&t.push(xt("usageEvent",{inputTokens:e.usage.prompt_tokens||0,outputTokens:e.usage.completion_tokens||0})),e.toolCallInit={},t.length>0?t:null}async function _d(e,t,a,r){try{if(wd(a))throw new Error(`Binary EventStream format detected (${a.length}B) - request should use passthrough instead of intercept`);let n=JSON.parse(a.toString()),s=Id(n);if(s.length===0)throw new Error("codeWhispererToMessages produced 0 messages \u2014 check request body");let i=Ad(n),o={model:r,messages:s,stream:!0,...i.length>0&&{tools:i,tool_choice:"auto"}},u=await gd(o,"/v1/chat/completions",e.headers),l=xd(r);await yd(u,t,Bd,l)}catch(n){hd(`[Kiro MITM] Request processing failed: ${n.message}`),t.headersSent||t.writeHead(500,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:{message:n.message,type:"mitm_error",handler:"kiro"}}))}}function wd(e){if(!e||e.length<12)return!1;let t=e.readUInt32BE(0),a=e.readUInt32BE(4);return t>12&&t<1e6&&a<t-12}zo.exports={intercept:_d}});var Yo=F((xp,$o)=>{async function Nd(e,t){t.writeHead(501,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:{message:"Cursor MITM support is coming soon.",type:"not_implemented"}}))}$o.exports={intercept:Nd}});var Wo=F((Sp,jo)=>{var{err:Rd}=_t(),{fetchRouter:Ld,pipeSSE:kd}=Kr();async function Dd(e,t,a,r){try{let n=JSON.parse(a.toString());n.model&&r&&(n.model=r);let s=e.url.includes("count_tokens")?"/v1/messages/count_tokens":"/v1/messages",i=await Ld(n,s,e.headers);await kd(i,t)}catch(n){Rd(`[claude] ${n.message}`),t.headersSent||t.writeHead(500,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:{message:n.message,type:"mitm_error"}}))}}jo.exports={intercept:Dd}});var Jo=F((Tp,Xo)=>{var Ud={antigravity:["daily-cloudcode-pa.googleapis.com","cloudcode-pa.googleapis.com"],copilot:["api.individual.githubcopilot.com"],kiro:["runtime.us-east-1.kiro.dev","q.us-east-1.amazonaws.com","codewhisperer.us-east-1.amazonaws.com"],cursor:["api2.cursor.sh"],claude:["api.anthropic.com"]};Xo.exports={TOOL_HOSTS:Ud}});var nu=F((Ip,au)=>{var{exec:Zo,execSync:Pd}=require("child_process"),eu=process.platform==="win32";function tu(){if(eu)try{return Pd("net session >nul 2>&1",{windowsHide:!0,stdio:"ignore"}),!0}catch{return!1}return typeof process.getuid=="function"&&process.getuid()===0}function ru(e){return`'${String(e).replace(/'/g,"''")}'`}function Od(e){if(!eu)return Promise.reject(new Error("Windows-only"));let t=Buffer.from(e,"utf16le").toString("base64");if(tu())return new Promise((r,n)=>{Zo(`powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand ${t}`,{windowsHide:!0},(s,i,o)=>{s?n(new Error(o||s.message)):r(i)})});let a=`
40
40
  $proc = Start-Process powershell -ArgumentList @(
41
41
  '-NoProfile','-NonInteractive','-ExecutionPolicy','Bypass',
42
42
  '-WindowStyle','Hidden','-EncodedCommand','${t}'
43
43
  ) -Verb RunAs -Wait -PassThru -WindowStyle Hidden;
44
44
  if ($proc.ExitCode -ne 0) { throw "Elevated command exited with code $($proc.ExitCode)" }
45
- `;return new Promise((r,n)=>{Xo(`powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command ${eu(a)}`,{windowsHide:!0},(s,i,o)=>{if(s){let u=o||s.message;u.includes("canceled by the user")||u.includes("operation was canceled")?n(new Error("User canceled UAC prompt")):n(new Error(u))}else r(i)})})}tu.exports={isAdmin:Zo,runElevatedPowerShell:Pd,quotePs:eu}});var fu=F((Bp,cu)=>{var{exec:Tp,spawn:au,execSync:Kr}=require("child_process"),_e=require("fs"),Od=require("path"),Ip=require("os"),{log:Ba,err:Vd}=_t(),{TOOL_HOSTS:Mt}=Wo(),{runElevatedPowerShell:nu,isAdmin:Ap}=ru();function iu(e,t,a){let r=`${e}.krouter.new`,n=`${e}.krouter.bak`;try{_e.writeFileSync(r,a,"utf8");try{_e.unlinkSync(n)}catch{}_e.renameSync(e,n);try{_e.renameSync(r,e)}catch(s){try{_e.renameSync(n,e)}catch{_e.writeFileSync(e,t,"utf8")}throw s}try{_e.unlinkSync(n)}catch{}}finally{try{_e.unlinkSync(r)}catch{}}}var bt=process.platform==="win32",su=process.platform==="darwin",Ze=bt?Od.join(process.env.SystemRoot||"C:\\Windows","System32","drivers","etc","hosts"):"/etc/hosts";function ba(){if(bt)return!1;try{return Kr("command -v sudo",{stdio:"ignore",windowsHide:!0}),!0}catch{return!1}}function ou(){if(bt||!ba())return!0;try{return Kr("sudo -n true",{stdio:"ignore",windowsHide:!0}),!0}catch{return!1}}function Fd(){return!bt&&ba()&&!ou()}function Mr(e,t){return new Promise((a,r)=>{let n=ba(),s=n?au("sudo",["-S","sh","-c",e],{stdio:["pipe","pipe","pipe"],windowsHide:!0}):au("sh",["-c",e],{stdio:["ignore","pipe","pipe"],windowsHide:!0}),i="",o="";s.stdout.on("data",u=>{i+=u}),s.stderr.on("data",u=>{o+=u}),s.on("close",u=>{u===0?a(i):r(new Error(o||`Exit code ${u}`))}),n&&(s.stdin.write(`${t}
46
- `),s.stdin.end())})}async function uu(e){bt||(su?await Mr("dscacheutil -flushcache && killall -HUP mDNSResponder",e):await Mr("resolvectl flush-caches 2>/dev/null || true",e))}function Dn(e=null){try{let t=_e.readFileSync(Ze,"utf8");return e?t.includes(e):Mt.antigravity.every(a=>t.includes(a))}catch{return!1}}function Kd(){try{let e=_e.readFileSync(Ze,"utf8"),t={};for(let[a,r]of Object.entries(Mt))t[a]=r.every(n=>e.includes(n));return t}catch{return Object.fromEntries(Object.keys(Mt).map(e=>[e,!1]))}}async function Md(e,t){let a=Mt[e];if(!a)throw new Error(`Unknown tool: ${e}`);let r=a.filter(n=>!Dn(n));if(r.length===0){Ba(`\u{1F310} DNS ${e}: already active`);return}try{if(bt){let n=_e.readFileSync(Ze,"utf8"),s=n.replace(/[\r\n\s]+$/g,""),i=r.map(u=>`127.0.0.1 ${u}`).join(`\r
45
+ `;return new Promise((r,n)=>{Zo(`powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command ${ru(a)}`,{windowsHide:!0},(s,i,o)=>{if(s){let u=o||s.message;u.includes("canceled by the user")||u.includes("operation was canceled")?n(new Error("User canceled UAC prompt")):n(new Error(u))}else r(i)})})}au.exports={isAdmin:tu,runElevatedPowerShell:Od,quotePs:ru}});var hu=F((_p,du)=>{var{exec:Ap,spawn:iu,execSync:Mr}=require("child_process"),_e=require("fs"),Vd=require("path"),Bp=require("os"),{log:ba,err:Fd}=_t(),{TOOL_HOSTS:Mt}=Jo(),{runElevatedPowerShell:su,isAdmin:bp}=nu();function ou(e,t,a){let r=`${e}.krouter.new`,n=`${e}.krouter.bak`;try{_e.writeFileSync(r,a,"utf8");try{_e.unlinkSync(n)}catch{}_e.renameSync(e,n);try{_e.renameSync(r,e)}catch(s){try{_e.renameSync(n,e)}catch{_e.writeFileSync(e,t,"utf8")}throw s}try{_e.unlinkSync(n)}catch{}}finally{try{_e.unlinkSync(r)}catch{}}}var bt=process.platform==="win32",uu=process.platform==="darwin",Ze=bt?Vd.join(process.env.SystemRoot||"C:\\Windows","System32","drivers","etc","hosts"):"/etc/hosts";function _a(){if(bt)return!1;try{return Mr("command -v sudo",{stdio:"ignore",windowsHide:!0}),!0}catch{return!1}}function lu(){if(bt||!_a())return!0;try{return Mr("sudo -n true",{stdio:"ignore",windowsHide:!0}),!0}catch{return!1}}function Kd(){return!bt&&_a()&&!lu()}function qr(e,t){return new Promise((a,r)=>{let n=_a(),s=n?iu("sudo",["-S","sh","-c",e],{stdio:["pipe","pipe","pipe"],windowsHide:!0}):iu("sh",["-c",e],{stdio:["ignore","pipe","pipe"],windowsHide:!0}),i="",o="";s.stdout.on("data",u=>{i+=u}),s.stderr.on("data",u=>{o+=u}),s.on("close",u=>{u===0?a(i):r(new Error(o||`Exit code ${u}`))}),n&&(s.stdin.write(`${t}
46
+ `),s.stdin.end())})}async function cu(e){bt||(uu?await qr("dscacheutil -flushcache && killall -HUP mDNSResponder",e):await qr("resolvectl flush-caches 2>/dev/null || true",e))}function Un(e=null){try{let t=_e.readFileSync(Ze,"utf8");return e?t.includes(e):Mt.antigravity.every(a=>t.includes(a))}catch{return!1}}function Md(){try{let e=_e.readFileSync(Ze,"utf8"),t={};for(let[a,r]of Object.entries(Mt))t[a]=r.every(n=>e.includes(n));return t}catch{return Object.fromEntries(Object.keys(Mt).map(e=>[e,!1]))}}async function qd(e,t){let a=Mt[e];if(!a)throw new Error(`Unknown tool: ${e}`);let r=a.filter(n=>!Un(n));if(r.length===0){ba(`\u{1F310} DNS ${e}: already active`);return}try{if(bt){let n=_e.readFileSync(Ze,"utf8"),s=n.replace(/[\r\n\s]+$/g,""),i=r.map(u=>`127.0.0.1 ${u}`).join(`\r
47
47
  `),o=`${s}\r
48
48
  ${i}\r
49
- `;iu(Ze,n,o),await nu("ipconfig /flushdns | Out-Null")}else{let s=_e.readFileSync(Ze,"utf8").replace(/[\r\n\s]+$/g,""),i=r.map(l=>`127.0.0.1 ${l}`).join(`
49
+ `;ou(Ze,n,o),await su("ipconfig /flushdns | Out-Null")}else{let s=_e.readFileSync(Ze,"utf8").replace(/[\r\n\s]+$/g,""),i=r.map(l=>`127.0.0.1 ${l}`).join(`
50
50
  `),u=`${s}
51
51
  ${i}
52
- `.replace(/'/g,"'\\''");await Mr(`printf '%s' '${u}' | tee ${Ze} > /dev/null`,t),await uu(t)}Ba(`\u{1F310} DNS ${e}: \u2705 added ${r.join(", ")}`)}catch(n){let s=n.message?.includes("incorrect password")?"Wrong sudo password":`Failed to add DNS entry: ${n.message}`;throw new Error(s)}}async function lu(e,t){let a=Mt[e];if(!a)throw new Error(`Unknown tool: ${e}`);let r=a.filter(n=>Dn(n));if(r.length===0){Ba(`\u{1F310} DNS ${e}: already inactive`);return}try{if(bt){let n=_e.readFileSync(Ze,"utf8"),i=n.split(/\r?\n/).filter(o=>!r.some(u=>o.includes(u))).join(`\r
52
+ `.replace(/'/g,"'\\''");await qr(`printf '%s' '${u}' | tee ${Ze} > /dev/null`,t),await cu(t)}ba(`\u{1F310} DNS ${e}: \u2705 added ${r.join(", ")}`)}catch(n){let s=n.message?.includes("incorrect password")?"Wrong sudo password":`Failed to add DNS entry: ${n.message}`;throw new Error(s)}}async function fu(e,t){let a=Mt[e];if(!a)throw new Error(`Unknown tool: ${e}`);let r=a.filter(n=>Un(n));if(r.length===0){ba(`\u{1F310} DNS ${e}: already inactive`);return}try{if(bt){let n=_e.readFileSync(Ze,"utf8"),i=n.split(/\r?\n/).filter(o=>!r.some(u=>o.includes(u))).join(`\r
53
53
  `).replace(/[\r\n\s]+$/g,"")+`\r
54
- `;iu(Ze,n,i),await nu("ipconfig /flushdns | Out-Null")}else{let o=(_e.readFileSync(Ze,"utf8").split(/\r?\n/).filter(u=>!r.some(l=>u.includes(l))).join(`
54
+ `;ou(Ze,n,i),await su("ipconfig /flushdns | Out-Null")}else{let o=(_e.readFileSync(Ze,"utf8").split(/\r?\n/).filter(u=>!r.some(l=>u.includes(l))).join(`
55
55
  `).replace(/[\r\n\s]+$/g,"")+`
56
- `).replace(/'/g,"'\\''");await Mr(`printf '%s' '${o}' | tee ${Ze} > /dev/null`,t),await uu(t)}Ba(`\u{1F310} DNS ${e}: \u2705 removed ${r.join(", ")}`)}catch(n){let s=n.message?.includes("incorrect password")?"Wrong sudo password":`Failed to remove DNS entry: ${n.message}`;throw new Error(s)}}async function qd(e){for(let t of Object.keys(Mt))try{await lu(t,e)}catch(a){Vd(`DNS ${t}: failed to remove \u2014 ${a.message}`)}}function Hd(){try{if(!_e.existsSync(Ze))return;let e=Object.values(Mt).flat(),t=_e.readFileSync(Ze,"utf8"),a=bt?`\r
56
+ `).replace(/'/g,"'\\''");await qr(`printf '%s' '${o}' | tee ${Ze} > /dev/null`,t),await cu(t)}ba(`\u{1F310} DNS ${e}: \u2705 removed ${r.join(", ")}`)}catch(n){let s=n.message?.includes("incorrect password")?"Wrong sudo password":`Failed to remove DNS entry: ${n.message}`;throw new Error(s)}}async function Hd(e){for(let t of Object.keys(Mt))try{await fu(t,e)}catch(a){Fd(`DNS ${t}: failed to remove \u2014 ${a.message}`)}}function Gd(){try{if(!_e.existsSync(Ze))return;let e=Object.values(Mt).flat(),t=_e.readFileSync(Ze,"utf8"),a=bt?`\r
57
57
  `:`
58
- `,n=t.split(/\r?\n/).filter(s=>!e.some(i=>s.includes(i))).join(a).replace(/[\r\n\s]+$/g,"")+a;if(n===t)return;if(_e.writeFileSync(Ze,n,"utf8"),bt)try{Kr("ipconfig /flushdns",{windowsHide:!0,stdio:"ignore"})}catch{}else if(su)try{Kr("dscacheutil -flushcache && killall -HUP mDNSResponder",{stdio:"ignore"})}catch{}else try{Kr("resolvectl flush-caches 2>/dev/null || true",{stdio:"ignore"})}catch{}}catch{}}cu.exports={TOOL_HOSTS:Mt,addDNSEntry:Md,removeDNSEntry:lu,removeAllDNSEntries:qd,removeAllDNSEntriesSync:Hd,execWithPassword:Mr,isSudoAvailable:ba,canRunSudoWithoutPassword:ou,isSudoPasswordRequired:Fd,checkDNSEntry:Dn,checkAllDNSStatus:Kd}});var Cu=require("https"),Gd=require("http2"),Eu=require("tls"),du=require("fs"),hu=require("path"),zd=require("dns"),{promisify:Qd}=require("util"),{execSync:Un}=require("child_process"),{log:Er,err:ot,dumpRequest:$d,createResponseDumper:Yd,clearDumpDir:jd}=_t(),{IS_DEV:bp,LSOF_BIN:Wd,TARGET_HOSTS:Xd,URL_PATTERNS:Jd,MODEL_SYNONYMS:Zd,MODEL_PATTERNS:eh,MODEL_NO_MAP:th,getToolForHost:xu}=Sr(),{DATA_DIR:_p,MITM_DIR:pu}=rr(),{getCertForDomain:rh}=Co(),{getMitmAlias:ah}=To(),{applyAntigravityIdeVersionOverride:nh}=Bo(),xr=443,gu=process.platform==="win32",Su=!0;jd();var yu={name:"x-request-source",value:"local"},ih={"cloudcode-pa.googleapis.com":"daily-cloudcode-pa.googleapis.com"},vu={antigravity:ko(),copilot:Uo(),kiro:Go(),cursor:Qo(),claude:Yo()},Pn=new Map,Tu;function sh(e,t){try{if(Pn.has(e))return t(null,Pn.get(e));let a=rh(e);if(!a)return t(new Error(`Failed to generate cert for ${e}`));let r=require("tls").createSecureContext({key:a.key,cert:`${a.cert}
59
- ${Tu}`});Pn.set(e,r),t(null,r)}catch(a){ot(`SNI error for ${e}: ${a.message}`),t(a)}}var Iu;try{let e=du.readFileSync(hu.join(pu,"rootCA.key")),t=du.readFileSync(hu.join(pu,"rootCA.crt"));Tu=t.toString("utf8"),Iu={key:e,cert:t,SNICallback:sh}}catch(e){ot(`Root CA not found: ${e.message}`),process.exit(1)}var On={},oh=300*1e3;async function Fn(e){if(require("net").isIP(e))return e;let t=On[e];if(t&&Date.now()-t.ts<oh)return t.ip;let a=new zd.Resolver;a.setServers(["8.8.8.8"]);let n=await Qd(a.resolve4.bind(a))(e);return On[e]={ip:n[0],ts:Date.now()},On[e].ip}function uh(e){return new Promise((t,a)=>{let r=[];e.on("data",n=>r.push(n)),e.on("end",()=>t(Buffer.concat(r))),e.on("error",a)})}function lh(e,t){let a=e.match(/\/models\/([^/:]+)/);if(a)return a[1];if(ch(t))return null;try{let r=JSON.parse(t.toString());return r.conversationState?r.conversationState.currentMessage?.userInputMessage?.modelId||null:r.model||null}catch{return null}}function ch(e){if(!e||e.length===0)return!1;let t=e.slice(0,Math.min(100,e.length)),a=0;for(let r=0;r<t.length;r++){let n=t[r];n<32&&n!==9&&n!==10&&n!==13&&a++,n>126&&a++}return a/t.length>.3}function fh(e,t){if(!t)return null;try{let a=ah(e);if(!a)return null;let r=String(t).replace(/^models\//,""),n=Zd?.[e]?.[r]||r;if(a[n])return a[n];let s=Object.keys(a).find(o=>o&&a[o]&&(n.startsWith(o)||o.startsWith(n)));if(s)return a[s];let i=eh?.[e]||[];for(let{match:o,alias:u}of i)if(o.test(n)&&a[u])return a[u];return null}catch{return null}}async function er(e,t,a,r){let n=(e.headers.host||Xd[0]).split(":")[0],s=e.url.includes(":generateContent")||e.url.includes(":streamGenerateContent"),i=s&&ih[n]||n;Er(`[passthrough] ${e.method} ${n}${e.url} \u2192 ${i}`);let o=Su?Yd(e,"passthrough"):null,l=xu(e.headers.host)==="antigravity"&&s?nh(a,e.headers):{bodyBuffer:a,headers:e.headers},c=l.bodyBuffer,f={...l.headers,host:i};c!==a&&(f["content-length"]=String(c.length));try{if(await dh(i)==="h2")return await hh(e,t,c,f,i,r,o)}catch(g){ot(`[mitm] ALPN negotiate failed: ${g.message}, fallback to HTTP/1.1`)}return Au(e,t,c,f,i,r,o)}var Vn=new Map;async function dh(e){if(Vn.has(e))return Vn.get(e);let t=await Fn(e);return new Promise((a,r)=>{let n=Eu.connect({host:t,port:443,servername:e,ALPNProtocols:["h2","http/1.1"],rejectUnauthorized:!1},()=>{let s=n.alpnProtocol||"http/1.1";Vn.set(e,s),Er(`\u{1F517} [mitm] ALPN ${e} \u2192 ${s}`),n.end(),a(s)});n.once("error",r),n.setTimeout(5e3,()=>{n.destroy(new Error("ALPN timeout"))})})}async function hh(e,t,a,r,n,s,i){let o=await Fn(n),u={};for(let[l,c]of Object.entries(r)){let f=l.toLowerCase();f==="host"||f==="connection"||f==="keep-alive"||f==="transfer-encoding"||f==="upgrade"||f==="proxy-connection"||(u[f]=c)}return u[":method"]=e.method,u[":path"]=e.url,u[":scheme"]="https",u[":authority"]=n,new Promise(l=>{let c=Gd.connect(`https://${n}`,{createConnection:()=>Eu.connect({host:o,port:443,servername:n,ALPNProtocols:["h2"],rejectUnauthorized:!1})});c.once("error",g=>{ot(`[mitm] http2 client error: ${g.message}`),i&&(i.writeChunk(`
60
- [ERROR h2] ${g.message}
61
- `),i.end()),t.headersSent||t.writeHead(502),t.writableEnded||t.end("Bad Gateway");try{c.close()}catch{}l()});let f=c.request(u,{endStream:a.length===0});a.length>0&&f.end(a),f.once("response",g=>{let v=g[":status"];Er(`[h2-response] ${e.method} ${n}${e.url} \u2192 ${v}`);let y={};for(let[S,I]of Object.entries(g))S.startsWith(":")||S==="connection"||S==="keep-alive"||S==="transfer-encoding"||(y[S]=I);t.writeHead(v,y),i&&i.writeHeader(v,y);let x=[];f.on("data",S=>{i&&i.writeChunk(S),s&&x.push(S),t.write(S)}),f.on("end",()=>{if(i&&i.end(),t.writableEnded||t.end(),s)try{s(Buffer.concat(x),y)}catch{}try{c.close()}catch{}l()})}),f.once("error",g=>{let v=g.message||"";if(!t.headersSent&&(v.includes("NGHTTP2")||v.includes("Stream closed"))){Er(`[mitm] http2 stream error (${v}) \u2014 falling back to http/1.1 retry`);try{c.close()}catch{}Au(e,t,a,r,n,s,i).then(l);return}ot(`[mitm] http2 stream error: ${v}`),i&&(i.writeChunk(`
62
- [ERROR h2-stream] ${v}
63
- `),i.end()),t.headersSent||t.writeHead(502),t.writableEnded||t.end();try{c.close()}catch{}l()})})}async function Au(e,t,a,r,n,s,i){let o=await Fn(n),u=Cu.request({hostname:o,port:443,path:e.url,method:e.method,headers:r,servername:n,rejectUnauthorized:!1},l=>{if(t.writeHead(l.statusCode,l.headers),i&&i.writeHeader(l.statusCode,l.headers),!s&&!i){l.pipe(t);return}let c=[];l.on("data",f=>{i&&i.writeChunk(f),s&&c.push(f),t.write(f)}),l.on("end",()=>{if(i&&i.end(),t.end(),s)try{s(Buffer.concat(c),l.headers)}catch{}})});u.on("error",l=>{ot(`Passthrough error: ${l.message}`),i&&(i.writeChunk(`
58
+ `,n=t.split(/\r?\n/).filter(s=>!e.some(i=>s.includes(i))).join(a).replace(/[\r\n\s]+$/g,"")+a;if(n===t)return;if(_e.writeFileSync(Ze,n,"utf8"),bt)try{Mr("ipconfig /flushdns",{windowsHide:!0,stdio:"ignore"})}catch{}else if(uu)try{Mr("dscacheutil -flushcache && killall -HUP mDNSResponder",{stdio:"ignore"})}catch{}else try{Mr("resolvectl flush-caches 2>/dev/null || true",{stdio:"ignore"})}catch{}}catch{}}du.exports={TOOL_HOSTS:Mt,addDNSEntry:qd,removeDNSEntry:fu,removeAllDNSEntries:Hd,removeAllDNSEntriesSync:Gd,execWithPassword:qr,isSudoAvailable:_a,canRunSudoWithoutPassword:lu,isSudoPasswordRequired:Kd,checkDNSEntry:Un,checkAllDNSStatus:Md}});var xu=require("https"),zd=require("http2"),Su=require("tls"),pu=require("fs"),gu=require("path"),Qd=require("dns"),{promisify:$d}=require("util"),{execSync:Pn}=require("child_process"),{log:rr,err:ot,dumpRequest:Yd,createResponseDumper:jd,clearDumpDir:Wd}=_t(),{IS_DEV:wp,LSOF_BIN:Xd,TARGET_HOSTS:Jd,URL_PATTERNS:Zd,MODEL_SYNONYMS:eh,MODEL_PATTERNS:th,MODEL_NO_MAP:rh,getToolForHost:Tu}=Tr(),{DATA_DIR:Np,MITM_DIR:yu}=nr(),{getCertForDomain:ah}=xo(),{getMitmAlias:nh}=Ao(),{applyAntigravityIdeVersionOverride:ih}=_o(),Sr=443,vu=process.platform==="win32",Iu=!0;Wd();var mu={name:"x-request-source",value:"local"},sh={"cloudcode-pa.googleapis.com":"daily-cloudcode-pa.googleapis.com"},Cu={antigravity:Uo(),copilot:Oo(),kiro:Qo(),cursor:Yo(),claude:Wo()},On=new Map,Au;function oh(e,t){try{if(On.has(e))return t(null,On.get(e));let a=ah(e);if(!a)return t(new Error(`Failed to generate cert for ${e}`));let r=require("tls").createSecureContext({key:a.key,cert:`${a.cert}
59
+ ${Au}`});On.set(e,r),t(null,r)}catch(a){ot(`SNI error for ${e}: ${a.message}`),t(a)}}var Bu;try{let e=pu.readFileSync(gu.join(yu,"rootCA.key")),t=pu.readFileSync(gu.join(yu,"rootCA.crt"));Au=t.toString("utf8"),Bu={key:e,cert:t,SNICallback:oh}}catch(e){ot(`Root CA not found: ${e.message}`),process.exit(1)}var Vn={},uh=300*1e3;async function Mn(e){if(require("net").isIP(e))return e;let t=Vn[e];if(t&&Date.now()-t.ts<uh)return t.ip;let a=new Qd.Resolver;a.setServers(["8.8.8.8"]);let n=await $d(a.resolve4.bind(a))(e);return Vn[e]={ip:n[0],ts:Date.now()},Vn[e].ip}function lh(e){return new Promise((t,a)=>{let r=[];e.on("data",n=>r.push(n)),e.on("end",()=>t(Buffer.concat(r))),e.on("error",a)})}function ch(e,t){let a=e.match(/\/models\/([^/:]+)/);if(a)return a[1];if(fh(t))return null;try{let r=JSON.parse(t.toString());return r.conversationState?r.conversationState.currentMessage?.userInputMessage?.modelId||null:r.model||null}catch{return null}}function fh(e){if(!e||e.length===0)return!1;let t=e.slice(0,Math.min(100,e.length)),a=0;for(let r=0;r<t.length;r++){let n=t[r];n<32&&n!==9&&n!==10&&n!==13&&a++,n>126&&a++}return a/t.length>.3}function dh(e,t){if(!t)return null;try{let a=nh(e);if(!a)return null;let r=String(t).replace(/^models\//,""),n=eh?.[e]?.[r]||r;if(a[n])return a[n];let s=Object.keys(a).find(o=>o&&a[o]&&(n.startsWith(o)||o.startsWith(n)));if(s)return a[s];let i=th?.[e]||[];for(let{match:o,alias:u}of i)if(o.test(n)&&a[u])return a[u];return null}catch{return null}}async function er(e,t,a,r){let n=(e.headers.host||Jd[0]).split(":")[0],s=e.url.includes(":generateContent")||e.url.includes(":streamGenerateContent"),i=s&&sh[n]||n;rr(`[passthrough] ${e.method} ${n}${e.url} \u2192 ${i}`);let o=Iu?jd(e,"passthrough"):null,l=Tu(e.headers.host)==="antigravity"&&s?ih(a,e.headers):{bodyBuffer:a,headers:e.headers},c=l.bodyBuffer,f={...l.headers,host:i};c!==a&&(f["content-length"]=String(c.length));try{if(await hh(i)==="h2")return await gh(e,t,c,f,i,r,o)}catch(g){ot(`[mitm] ALPN negotiate failed: ${g.message}, fallback to HTTP/1.1`)}return Kn(e,t,c,f,i,r,o)}var Fn=new Map;async function hh(e){if(Fn.has(e))return Fn.get(e);let t=await Mn(e);return new Promise((a,r)=>{let n=Su.connect({host:t,port:443,servername:e,ALPNProtocols:["h2","http/1.1"],rejectUnauthorized:!1},()=>{let s=n.alpnProtocol||"http/1.1";Fn.set(e,s),rr(`\u{1F517} [mitm] ALPN ${e} \u2192 ${s}`),n.end(),a(s)});n.once("error",r),n.setTimeout(5e3,()=>{n.destroy(new Error("ALPN timeout"))})})}var tr=new Map;async function ph(e,t){let a=tr.get(e);if(a&&!a.client.closed&&!a.client.destroyed)return a;let r=zd.connect(`https://${e}`,{createConnection:()=>Su.connect({host:t,port:443,servername:e,ALPNProtocols:["h2"],rejectUnauthorized:!1})}),n={client:r,activeStreams:0};tr.set(e,n);let s=()=>{tr.get(e)===n&&tr.delete(e);try{r.close()}catch{}};return r.on("error",s),r.on("close",s),r.on("goaway",s),n}async function gh(e,t,a,r,n,s,i){let o=await Mn(n),u={};for(let[l,c]of Object.entries(r)){let f=l.toLowerCase();f==="host"||f==="connection"||f==="keep-alive"||f==="transfer-encoding"||f==="upgrade"||f==="proxy-connection"||(u[f]=c)}return u[":method"]=e.method,u[":path"]=e.url,u[":scheme"]="https",u[":authority"]=n,new Promise(async l=>{let c;try{c=await ph(n,o)}catch(v){return ot(`[mitm] http2 connect error: ${v.message}`),t.headersSent||t.writeHead(502),t.writableEnded||t.end("Bad Gateway"),l()}c.activeStreams++;let f=()=>{c.activeStreams--,c.activeStreams===0&&setTimeout(()=>{if(c.activeStreams===0){tr.delete(n);try{c.client.close()}catch{}}},3e4).unref()},g;try{g=c.client.request(u,{endStream:a.length===0})}catch{return f(),tr.delete(n),rr("[mitm] http2 request failed on pooled session, retrying..."),Kn(e,t,a,r,n,s,i).then(l)}a.length>0&&g.end(a),g.once("response",v=>{let y=v[":status"];rr(`[h2-response] ${e.method} ${n}${e.url} \u2192 ${y}`);let x={};for(let[T,B]of Object.entries(v))T.startsWith(":")||T==="connection"||T==="keep-alive"||T==="transfer-encoding"||(x[T]=B);t.writeHead(y,x),i&&i.writeHeader(y,x);let S=[];g.on("data",T=>{i&&i.writeChunk(T),s&&S.push(T),t.write(T)}),g.on("end",()=>{if(i&&i.end(),t.writableEnded||t.end(),s)try{s(Buffer.concat(S),x)}catch{}f(),l()})}),g.once("error",v=>{f();let y=v.message||"";if(!t.headersSent&&(y.includes("NGHTTP2")||y.includes("Stream closed"))){rr(`[mitm] http2 stream error (${y}) \u2014 falling back to http/1.1 retry`),tr.delete(n),Kn(e,t,a,r,n,s,i).then(l);return}ot(`[mitm] http2 stream error: ${y}`),i&&(i.writeChunk(`
60
+ [ERROR h2-stream] ${y}
61
+ `),i.end()),t.headersSent||t.writeHead(502),t.writableEnded||t.end(),l()})})}async function Kn(e,t,a,r,n,s,i){let o=await Mn(n),u=xu.request({hostname:o,port:443,path:e.url,method:e.method,headers:r,servername:n,rejectUnauthorized:!1},l=>{if(t.writeHead(l.statusCode,l.headers),i&&i.writeHeader(l.statusCode,l.headers),!s&&!i){l.pipe(t);return}let c=[];l.on("data",f=>{i&&i.writeChunk(f),s&&c.push(f),t.write(f)}),l.on("end",()=>{if(i&&i.end(),t.end(),s)try{s(Buffer.concat(c),l.headers)}catch{}})});u.on("error",l=>{ot(`Passthrough error: ${l.message}`),i&&(i.writeChunk(`
64
62
  [ERROR] ${l.message}
65
- `),i.end()),t.headersSent||t.writeHead(502),t.end("Bad Gateway")}),a.length>0&&u.write(a),u.end()}var qr=Cu.createServer(Iu,async(e,t)=>{try{if(e.url==="/_mitm_health"){t.writeHead(200,{"Content-Type":"application/json"}),t.end(JSON.stringify({ok:!0,pid:process.pid}));return}let a=await uh(e);if(Su&&$d(e,a,"raw"),e.headers[yu.name]===yu.value)return er(e,t,a);let r=xu(e.headers.host);if(!r||!(Jd[r]||[]).some(u=>e.url.includes(u)))return er(e,t,a);if(r==="cursor")return vu[r].intercept(e,t,a,null,er);let i=lh(e.url,a);if(i&&(th[r]||[]).some(u=>u.test(i)))return er(e,t,a);let o=fh(r,i);return o?vu[r].intercept(e,t,a,o,er):er(e,t,a)}catch(a){ot(`Unhandled error: ${a.message}`),t.headersSent||t.writeHead(500,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:{message:a.message,type:"mitm_error"}}))}});function ph(e){try{let t=[];if(gu){let a=`powershell -NonInteractive -WindowStyle Hidden -Command "Get-NetTCPConnection -LocalPort ${e} -State Listen -ErrorAction SilentlyContinue | Select-Object -ExpandProperty OwningProcess"`,r=Un(a,{encoding:"utf-8",windowsHide:!0}).trim();if(!r)return;t=r.split(/\r?\n/).map(n=>n.trim()).filter(n=>n&&Number(n)!==process.pid&&Number(n)>4)}else{let a=Un(`${Wd} -nP -iTCP:${e} -sTCP:LISTEN -t`,{encoding:"utf-8",windowsHide:!0}).trim();if(!a)return;t=a.split(`
66
- `).filter(r=>r&&Number(r)!==process.pid)}if(t.length===0)return;t.forEach(a=>{try{gu?Un(`taskkill /F /PID ${a}`,{windowsHide:!0}):process.kill(Number(a),"SIGKILL")}catch(r){ot(`Failed to kill PID ${a}: ${r.message}`)}}),Er(`Killed ${t.length} process(es) on port ${e}`)}catch(t){if(t.status!==1)throw t}}try{ph(xr)}catch(e){ot(`Cannot kill process on port ${xr}: ${e.message}`),process.exit(1)}qr.requestTimeout=0;qr.headersTimeout=0;qr.listen(xr,()=>Er(`\u{1F680} Server ready on :${xr}`));qr.on("error",e=>{e.code==="EADDRINUSE"?ot(`Port ${xr} already in use`):e.code==="EACCES"?ot(`Permission denied for port ${xr}`):ot(e.message),process.exit(1)});var{removeAllDNSEntriesSync:gh}=fu(),mu=!1,Kn=()=>{if(mu)return;mu=!0,gh();let e=setTimeout(()=>process.exit(0),1500);qr.close(()=>{clearTimeout(e),process.exit(0)})};process.on("SIGTERM",Kn);process.on("SIGINT",Kn);process.platform==="win32"&&process.on("SIGBREAK",Kn);
63
+ `),i.end()),t.headersSent||t.writeHead(502),t.end("Bad Gateway")}),a.length>0&&u.write(a),u.end()}var Hr=xu.createServer(Bu,async(e,t)=>{try{if(e.url==="/_mitm_health"){t.writeHead(200,{"Content-Type":"application/json"}),t.end(JSON.stringify({ok:!0,pid:process.pid}));return}let a=await lh(e);if(Iu&&Yd(e,a,"raw"),e.headers[mu.name]===mu.value)return er(e,t,a);let r=Tu(e.headers.host);if(!r||!(Zd[r]||[]).some(u=>e.url.includes(u)))return er(e,t,a);if(r==="cursor")return Cu[r].intercept(e,t,a,null,er);let i=ch(e.url,a);if(i&&(rh[r]||[]).some(u=>u.test(i)))return er(e,t,a);let o=dh(r,i);return o?Cu[r].intercept(e,t,a,o,er):er(e,t,a)}catch(a){ot(`Unhandled error: ${a.message}`),t.headersSent||t.writeHead(500,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:{message:a.message,type:"mitm_error"}}))}});function yh(e){try{let t=[];if(vu){let a=`powershell -NonInteractive -WindowStyle Hidden -Command "Get-NetTCPConnection -LocalPort ${e} -State Listen -ErrorAction SilentlyContinue | Select-Object -ExpandProperty OwningProcess"`,r=Pn(a,{encoding:"utf-8",windowsHide:!0}).trim();if(!r)return;t=r.split(/\r?\n/).map(n=>n.trim()).filter(n=>n&&Number(n)!==process.pid&&Number(n)>4)}else{let a=Pn(`${Xd} -nP -iTCP:${e} -sTCP:LISTEN -t`,{encoding:"utf-8",windowsHide:!0}).trim();if(!a)return;t=a.split(`
64
+ `).filter(r=>r&&Number(r)!==process.pid)}if(t.length===0)return;t.forEach(a=>{try{vu?Pn(`taskkill /F /PID ${a}`,{windowsHide:!0}):process.kill(Number(a),"SIGKILL")}catch(r){ot(`Failed to kill PID ${a}: ${r.message}`)}}),rr(`Killed ${t.length} process(es) on port ${e}`)}catch(t){if(t.status!==1)throw t}}try{yh(Sr)}catch(e){ot(`Cannot kill process on port ${Sr}: ${e.message}`),process.exit(1)}Hr.requestTimeout=0;Hr.headersTimeout=0;Hr.listen(Sr,()=>rr(`\u{1F680} Server ready on :${Sr}`));Hr.on("error",e=>{e.code==="EADDRINUSE"?ot(`Port ${Sr} already in use`):e.code==="EACCES"?ot(`Permission denied for port ${Sr}`):ot(e.message),process.exit(1)});var{removeAllDNSEntriesSync:vh}=hu(),Eu=!1,qn=()=>{if(Eu)return;Eu=!0,vh();let e=setTimeout(()=>process.exit(0),1500);Hr.close(()=>{clearTimeout(e),process.exit(0)})};process.on("SIGTERM",qn);process.on("SIGINT",qn);process.platform==="win32"&&process.on("SIGBREAK",qn);