wiki-viewer 1.4.1 → 1.4.3

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 (159) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/build-manifest.json +3 -3
  3. package/.next/standalone/.next/prerender-manifest.json +3 -27
  4. package/.next/standalone/.next/server/app/_global-error/page.js +2 -2
  5. package/.next/standalone/.next/server/app/_global-error/page.js.nft.json +1 -1
  6. package/.next/standalone/.next/server/app/_global-error.html +1 -1
  7. package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
  8. package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  10. package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  11. package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  12. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  13. package/.next/standalone/.next/server/app/_not-found/page.js +4 -4
  14. package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
  15. package/.next/standalone/.next/server/app/_not-found.html +1 -1
  16. package/.next/standalone/.next/server/app/_not-found.rsc +1 -1
  17. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  18. package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  19. package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  20. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  21. package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  22. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  23. package/.next/standalone/.next/server/app/api/agent/activity/route.js +5 -5
  24. package/.next/standalone/.next/server/app/api/agent/activity/route.js.nft.json +1 -1
  25. package/.next/standalone/.next/server/app/api/agent/admin/agents/[agentId]/revoke/route.js +6 -6
  26. package/.next/standalone/.next/server/app/api/agent/admin/agents/[agentId]/revoke/route.js.nft.json +1 -1
  27. package/.next/standalone/.next/server/app/api/agent/admin/agents/route.js +6 -6
  28. package/.next/standalone/.next/server/app/api/agent/admin/agents/route.js.nft.json +1 -1
  29. package/.next/standalone/.next/server/app/api/agent/admin/registrations/[regId]/approve/route.js +6 -6
  30. package/.next/standalone/.next/server/app/api/agent/admin/registrations/[regId]/approve/route.js.nft.json +1 -1
  31. package/.next/standalone/.next/server/app/api/agent/admin/registrations/[regId]/deny/route.js +4 -4
  32. package/.next/standalone/.next/server/app/api/agent/admin/registrations/[regId]/deny/route.js.nft.json +1 -1
  33. package/.next/standalone/.next/server/app/api/agent/admin/registrations/route.js +4 -4
  34. package/.next/standalone/.next/server/app/api/agent/admin/registrations/route.js.nft.json +1 -1
  35. package/.next/standalone/.next/server/app/api/agent/events/[...path]/route.js +5 -5
  36. package/.next/standalone/.next/server/app/api/agent/events/[...path]/route.js.nft.json +1 -1
  37. package/.next/standalone/.next/server/app/api/agent/files/[...path]/route.js +4 -4
  38. package/.next/standalone/.next/server/app/api/agent/files/[...path]/route.js.nft.json +1 -1
  39. package/.next/standalone/.next/server/app/api/agent/internal/span/route.js +8 -8
  40. package/.next/standalone/.next/server/app/api/agent/internal/span/route.js.nft.json +1 -1
  41. package/.next/standalone/.next/server/app/api/agent/settings/route.js +7 -7
  42. package/.next/standalone/.next/server/app/api/agent/settings/route.js.nft.json +1 -1
  43. package/.next/standalone/.next/server/app/api/agent/sidecar/[...path]/route.js +7 -7
  44. package/.next/standalone/.next/server/app/api/agent/sidecar/[...path]/route.js.nft.json +1 -1
  45. package/.next/standalone/.next/server/app/api/app-proxy/[...path]/route.js.nft.json +1 -1
  46. package/.next/standalone/.next/server/app/api/auth/[...all]/route.js +3 -3
  47. package/.next/standalone/.next/server/app/api/auth/[...all]/route.js.nft.json +1 -1
  48. package/.next/standalone/.next/server/app/api/system/auth-config/route.js +5 -5
  49. package/.next/standalone/.next/server/app/api/system/auth-config/route.js.nft.json +1 -1
  50. package/.next/standalone/.next/server/app/api/system/auth-settings/route.js +4 -4
  51. package/.next/standalone/.next/server/app/api/system/auth-settings/route.js.nft.json +1 -1
  52. package/.next/standalone/.next/server/app/api/system/browse/route.js +6 -6
  53. package/.next/standalone/.next/server/app/api/system/browse/route.js.nft.json +1 -1
  54. package/.next/standalone/.next/server/app/api/system/clear-root/route.js +5 -5
  55. package/.next/standalone/.next/server/app/api/system/clear-root/route.js.nft.json +1 -1
  56. package/.next/standalone/.next/server/app/api/system/config/route.js +5 -5
  57. package/.next/standalone/.next/server/app/api/system/config/route.js.nft.json +1 -1
  58. package/.next/standalone/.next/server/app/api/system/pins/route.js +4 -4
  59. package/.next/standalone/.next/server/app/api/system/pins/route.js.nft.json +1 -1
  60. package/.next/standalone/.next/server/app/api/system/reveal/route.js +4 -4
  61. package/.next/standalone/.next/server/app/api/system/reveal/route.js.nft.json +1 -1
  62. package/.next/standalone/.next/server/app/api/system/root-status/route.js +4 -4
  63. package/.next/standalone/.next/server/app/api/system/root-status/route.js.nft.json +1 -1
  64. package/.next/standalone/.next/server/app/api/system/set-root/route.js +5 -5
  65. package/.next/standalone/.next/server/app/api/system/set-root/route.js.nft.json +1 -1
  66. package/.next/standalone/.next/server/app/api/wiki/app/route.js +6 -6
  67. package/.next/standalone/.next/server/app/api/wiki/app/route.js.nft.json +1 -1
  68. package/.next/standalone/.next/server/app/api/wiki/content/route.js +7 -7
  69. package/.next/standalone/.next/server/app/api/wiki/content/route.js.nft.json +1 -1
  70. package/.next/standalone/.next/server/app/api/wiki/folder/route.js +5 -5
  71. package/.next/standalone/.next/server/app/api/wiki/folder/route.js.nft.json +1 -1
  72. package/.next/standalone/.next/server/app/api/wiki/move/route.js +5 -5
  73. package/.next/standalone/.next/server/app/api/wiki/move/route.js.nft.json +1 -1
  74. package/.next/standalone/.next/server/app/api/wiki/new-file/route.js +5 -5
  75. package/.next/standalone/.next/server/app/api/wiki/new-file/route.js.nft.json +1 -1
  76. package/.next/standalone/.next/server/app/api/wiki/page/route.js +5 -5
  77. package/.next/standalone/.next/server/app/api/wiki/page/route.js.nft.json +1 -1
  78. package/.next/standalone/.next/server/app/api/wiki/route.js +5 -5
  79. package/.next/standalone/.next/server/app/api/wiki/route.js.nft.json +1 -1
  80. package/.next/standalone/.next/server/app/api/wiki/slugs/route.js +5 -5
  81. package/.next/standalone/.next/server/app/api/wiki/slugs/route.js.nft.json +1 -1
  82. package/.next/standalone/.next/server/app/api/wiki/upload/route.js +5 -5
  83. package/.next/standalone/.next/server/app/api/wiki/upload/route.js.nft.json +1 -1
  84. package/.next/standalone/.next/server/app/api/wiki/watch/route.js +6 -6
  85. package/.next/standalone/.next/server/app/api/wiki/watch/route.js.nft.json +1 -1
  86. package/.next/standalone/.next/server/app/index.html +1 -1
  87. package/.next/standalone/.next/server/app/index.rsc +2 -2
  88. package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  89. package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +2 -2
  90. package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  91. package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
  92. package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  93. package/.next/standalone/.next/server/app/page.js +4 -4
  94. package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
  95. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  96. package/.next/standalone/.next/server/app/signin/page.js +9 -4
  97. package/.next/standalone/.next/server/app/signin/page.js.nft.json +1 -1
  98. package/.next/standalone/.next/server/app/signin/page_client-reference-manifest.js +1 -1
  99. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__03h3~3e._.js → [root-of-the-server]__04udrya._.js} +2 -2
  100. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__04g0j8i._.js → [root-of-the-server]__0kdn1le._.js} +2 -2
  101. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0d89o98._.js → src_lib_auth_server_ts_00f4e0h._.js} +3 -3
  102. package/.next/standalone/.next/server/chunks/ssr/0biy_@better-auth_core_dist_121m_lh._.js +5 -0
  103. package/.next/standalone/.next/server/chunks/ssr/0dhv_better-auth_dist_adapters_kysely-adapter_index_mjs_08ymlcb._.js +3 -0
  104. package/.next/standalone/.next/server/chunks/ssr/0dti_kysely_dist_esm_0-t3o9q._.js +3 -0
  105. package/.next/standalone/.next/server/chunks/ssr/0dti_kysely_dist_esm_01._58q._.js +3 -0
  106. package/.next/standalone/.next/server/chunks/ssr/0p91_next_0f40gy0._.js +6 -0
  107. package/.next/standalone/.next/server/chunks/ssr/{0p91_next_dist_0~2d1tl._.js → 0p91_next_dist_10ud_sa._.js} +2 -2
  108. package/.next/standalone/.next/server/chunks/ssr/0sag_@better-auth_memory-adapter_dist_index_mjs_07-_ka6._.js +3 -0
  109. package/.next/standalone/.next/server/chunks/ssr/0ugq_@better-auth_kysely-adapter_dist_bun-sqlite-dialect-DzNwOpKv_mjs_0lruvb8._.js +3 -0
  110. package/.next/standalone/.next/server/chunks/ssr/0ugq_@better-auth_kysely-adapter_dist_d1-sqlite-dialect-C2B7YsIT_mjs_03n6~tc._.js +3 -0
  111. package/.next/standalone/.next/server/chunks/ssr/0ugq_@better-auth_kysely-adapter_dist_index_mjs_0gi5w.w._.js +4 -0
  112. package/.next/standalone/.next/server/chunks/ssr/0ugq_@better-auth_kysely-adapter_dist_node-sqlite-dialect_mjs_0l4.y~0._.js +3 -0
  113. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__026s8~z._.js +3 -0
  114. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__06mzg2t._.js +3 -0
  115. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0btcd4o._.js +12 -0
  116. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0c~og-9._.js +3 -0
  117. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__134_q7l._.js +1 -1
  118. package/.next/standalone/.next/server/chunks/ssr/_0pqaawz._.js +1 -1
  119. package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_051tcva._.js +3 -0
  120. package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_0o~d81.._.js +1 -1
  121. package/.next/standalone/.next/server/chunks/ssr/src_app_signin_00yk0vm._.js +452 -0
  122. package/.next/standalone/.next/server/chunks/ssr/src_app_signin_signin-form_tsx_0eznlbd._.js +3 -0
  123. package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
  124. package/.next/standalone/.next/server/middleware-manifest.json +5 -5
  125. package/.next/standalone/.next/server/pages/404.html +1 -1
  126. package/.next/standalone/.next/server/pages/500.html +1 -1
  127. package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
  128. package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
  129. package/.next/standalone/.next/static/chunks/09-jtayuhrq~b.js +1 -0
  130. package/.next/standalone/.next/static/chunks/0uv7ozzpiyp2_.js +1 -0
  131. package/.next/standalone/.next/static/chunks/135c~rq_ux73w.js +1 -0
  132. package/.next/standalone/docs/agent-fs-plan.md +230 -0
  133. package/.next/standalone/package.json +1 -1
  134. package/.next/standalone/src/app/signin/page.tsx +10 -225
  135. package/.next/standalone/src/app/signin/signin-form.tsx +238 -0
  136. package/.next/standalone/src/lib/auth/server.ts +14 -7
  137. package/.next/standalone/tsconfig.tsbuildinfo +1 -1
  138. package/package.json +1 -1
  139. package/.next/standalone/.next/server/app/signin.html +0 -1
  140. package/.next/standalone/.next/server/app/signin.meta +0 -15
  141. package/.next/standalone/.next/server/app/signin.rsc +0 -23
  142. package/.next/standalone/.next/server/app/signin.segments/_full.segment.rsc +0 -23
  143. package/.next/standalone/.next/server/app/signin.segments/_head.segment.rsc +0 -6
  144. package/.next/standalone/.next/server/app/signin.segments/_index.segment.rsc +0 -7
  145. package/.next/standalone/.next/server/app/signin.segments/_tree.segment.rsc +0 -3
  146. package/.next/standalone/.next/server/app/signin.segments/signin/__PAGE__.segment.rsc +0 -9
  147. package/.next/standalone/.next/server/app/signin.segments/signin.segment.rsc +0 -5
  148. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__088hqzy._.js +0 -3
  149. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0c147fo._.js +0 -3
  150. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0z.1v1z._.js +0 -3
  151. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__12zp2dm._.js +0 -3
  152. package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_0exqvyf._.js +0 -3
  153. package/.next/standalone/.next/server/chunks/ssr/src_app_signin_page_tsx_1143y49._.js +0 -3
  154. package/.next/standalone/.next/static/chunks/0-_39e4awbk8y.js +0 -1
  155. package/.next/standalone/.next/static/chunks/02bxx~2cg~s6~.js +0 -1
  156. package/.next/standalone/.next/static/chunks/0mj_f8ncf2tks.js +0 -1
  157. /package/.next/standalone/.next/static/{bNZLQMXPxlDzQicfJAh2f → kzOuSAQArtvD7uiAJ6ZLh}/_buildManifest.js +0 -0
  158. /package/.next/standalone/.next/static/{bNZLQMXPxlDzQicfJAh2f → kzOuSAQArtvD7uiAJ6ZLh}/_clientMiddlewareManifest.js +0 -0
  159. /package/.next/standalone/.next/static/{bNZLQMXPxlDzQicfJAh2f → kzOuSAQArtvD7uiAJ6ZLh}/_ssgManifest.js +0 -0
@@ -1,4 +1,4 @@
1
- module.exports=[660526,(e,t,r)=>{t.exports=e.x("node:os",()=>require("node:os"))},286607,(e,t,r)=>{t.exports=e.x("better-sqlite3",()=>require("better-sqlite3"))},254226,473845,798003,860780,e=>{"use strict";let t,r,n,i,a,o,s,c,l,d,u,p,f;var h,m,y,g,w=e.i(563811),b=e.i(560912);async function A(t,r){let n;if(t.database)n="function"==typeof t.database?t.database(t):await r(t);else{let r=Object.keys((0,w.getAuthTables)(t)).reduce((e,t)=>(e[t]=[],e),{}),{memoryAdapter:i}=await e.A(168315);n=i(r)(t)}return n.transaction||(b.logger.warn("Adapter does not correctly implement transaction function, patching it automatically. Please update your adapter implementation."),n.transaction=async e=>e(n)),n}var E=e.i(451894);async function v(t){return A(t,async t=>{let{createKyselyAdapter:r}=await e.A(317691),{kysely:n,databaseType:i,transaction:a}=await r(t);if(!n)throw new E.BetterAuthError("Failed to initialize database adapter");let{kyselyAdapter:o}=await e.A(317691);return o(n,{type:i||"sqlite",debugLogs:!!t.database&&"debugLogs"in t.database&&t.database.debugLogs,transaction:a})(t)})}var k=e.i(177730);function _(e){return"-"===e||"^"===e||"$"===e||"+"===e||"."===e||"("===e||")"===e||"|"===e||"["===e||"]"===e||"{"===e||"}"===e||"*"===e||"?"===e||"\\"===e?`\\${e}`:e}function S(e,t){if("string"!=typeof t)throw TypeError(`Sample must be a string, but ${typeof t} given`);return e.test(t)}function x(e,t){if("string"!=typeof e&&!Array.isArray(e))throw TypeError(`The first argument must be a single pattern string or an array of patterns, but ${typeof e} given`);if(("string"==typeof t||"boolean"==typeof t)&&(t={separator:t}),2==arguments.length&&!(void 0===t||"object"==typeof t&&null!==t&&!Array.isArray(t)))throw TypeError(`The second argument must be an options object or a string/boolean separator, but ${typeof t} given`);if("\\"===(t=t||{}).separator)throw Error("\\ is not a valid separator because it is used for escaping. Try setting the separator to `true` instead");let r=function e(t,r=!0){if(Array.isArray(t))return`(?:${t.map(t=>`^${e(t,r)}$`).join("|")})`;let n="",i="",a=".";!0===r?(n="/",i="[/\\\\]",a="[^/\\\\]"):r&&((i=function(e){let t="";for(let r=0;r<e.length;r++)t+=_(e[r]);return t}(n=r)).length>1?(i=`(?:${i})`,a=`((?!${i}).)`):a=`[^${i}]`);let o=r?`${i}+?`:"",s=r?`${i}*?`:"",c=r?t.split(n):[t],l="";for(let e=0;e<c.length;e++){let t=c[e],n=c[e+1],i="";if(t||!(e>0)){if(r&&(i=e===c.length-1?s:"**"!==n?o:""),r&&"**"===t){i&&(l+=0===e?"":i,l+=`(?:${a}*?${i})*?`);continue}for(let e=0;e<t.length;e++){let r=t[e];"\\"===r?e<t.length-1&&(l+=_(t[e+1]),e++):"?"===r?l+=a:"*"===r?l+=`${a}*?`:l+=_(r)}l+=i}}return l}(e,t.separator),n=RegExp(`^${r}$`,t.flags),i=S.bind(null,n);return i.options=t,i.pattern=e,i.regexp=n,i}var T=e.i(426232);function R(e){let t=e.length;for(;t>0&&47===e.charCodeAt(t-1);)t--;return t===e.length?e:e.slice(0,t)}function I(e,t="/api/auth"){try{let t=new URL(e);if("http:"!==t.protocol&&"https:"!==t.protocol)throw new E.BetterAuthError(`Invalid base URL: ${e}. URL must include 'http://' or 'https://'`)}catch(t){if(t instanceof E.BetterAuthError)throw t;throw new E.BetterAuthError(`Invalid base URL: ${e}. Please provide a valid base URL.`,{cause:t})}if(function(e){try{return"/"!==(R(new URL(e).pathname)||"/")}catch{throw new E.BetterAuthError(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}(e))return e;let r=R(e);return t&&"/"!==t?(t=t.startsWith("/")?t:`/${t}`,`${r}${t}`):r}function U(e,t){return!!e&&""!==e.trim()&&("proto"===t?"http"===e||"https"===e:"host"===t&&![/\.\./,/\0/,/[\s]/,/^[.]/,/[<>'"]/,/javascript:/i,/file:/i,/data:/i].some(t=>t.test(e))&&(/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*(:[0-9]{1,5})?$/.test(e)||/^(\d{1,3}\.){3}\d{1,3}(:[0-9]{1,5})?$/.test(e)||/^\[[0-9a-fA-F:]+\](:[0-9]{1,5})?$/.test(e)||/^localhost(:[0-9]{1,5})?$/i.test(e)))}function O(e,t,r,n,i){if(e)return I(e,t);if(!1!==n){let e=T.env.BETTER_AUTH_URL||T.env.NEXT_PUBLIC_BETTER_AUTH_URL||T.env.PUBLIC_BETTER_AUTH_URL||T.env.NUXT_PUBLIC_BETTER_AUTH_URL||T.env.NUXT_PUBLIC_AUTH_URL||("/"!==T.env.BASE_URL?T.env.BASE_URL:void 0);if(e)return I(e,t)}let a=r?.headers.get("x-forwarded-host"),o=r?.headers.get("x-forwarded-proto");if(a&&o&&i&&U(o,"proto")&&U(a,"host"))try{return I(`${o}://${a}`,t)}catch(e){}if(r){let e=P(r.url);if(!e)throw new E.BetterAuthError("Could not get origin from request. Please provide a valid base URL.");return I(e,t)}}function P(e){try{let t=new URL(e);return"null"===t.origin?null:t.origin}catch{return null}}function C(e){return"object"==typeof e&&null!==e&&"allowedHosts"in e&&Array.isArray(e.allowedHosts)}function D(e){return e instanceof Request||"object"==typeof e&&null!==e&&"[object Request]"===Object.prototype.toString.call(e)&&"string"==typeof e.url&&"object"==typeof e.headers&&null!==e.headers&&"function"==typeof e.headers.get}function L(e,t){let r=D(e)?e.headers:e;if(t){let e=r.get("x-forwarded-host");if(e&&U(e,"host"))return e}let n=r.get("host");if(n&&U(n,"host"))return n;if(D(e))try{return new URL(e.url).host}catch{}return null}let z=(e,t,r)=>{if(e.startsWith("/"))return!!r?.allowRelativePaths&&e.startsWith("/")&&/^\/(?!\/|\\|%2f|%5c)[\w\-.\+/@]*(?:\?[\w\-.\+/=&%@]*)?$/.test(e);if(t.includes("*")||t.includes("?")){if(t.includes("://"))return x(t)(P(e)||e);let r=function(e){try{return new URL(e).host}catch{return null}}(e);return!!r&&x(t)(r)}let n=function(e){try{return new URL(e).protocol}catch{return null}}(e);return"http:"!==n&&"https:"!==n&&n?e.startsWith(t):t===P(e)};function $(e){return!!e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then}var N=e.i(666680);function j(e,t){return new Promise((r,n)=>{(0,N.scrypt)(e.normalize("NFKC"),t,64,{N:16384,r:16,p:1,maxmem:0x4000000},(e,t)=>{e?n(e):r(t)})})}async function H(e){let t=(0,N.randomBytes)(16).toString("hex"),r=await j(e,t);return`${t}:${r.toString("hex")}`}async function B(e,t){let[r,n]=e.split(":");if(!r||!n)throw Error("Invalid password hash");return(await j(t,r)).toString("hex")===n}let V=async({hash:e,password:t})=>B(e,t);function M(e,t=""){if("number"!=typeof e){let r=t&&`"${t}" `;throw TypeError(`${r}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw RangeError(`${r}expected integer >= 0, got ${e}`)}}function K(e,t,r=""){let n=e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name&&"BYTES_PER_ELEMENT"in e&&1===e.BYTES_PER_ELEMENT,i=e?.length,a=void 0!==t;if(!n||a&&i!==t){let o=(r&&`"${r}" `)+"expected Uint8Array"+(a?` of length ${t}`:"")+", got "+(n?`length=${i}`:`type=${typeof e}`);if(!n)throw TypeError(o);throw RangeError(o)}return e}function W(e){if("function"!=typeof e||"function"!=typeof e.create)throw TypeError("Hash must wrapped by utils.createHasher");if(M(e.outputLen),M(e.blockLen),e.outputLen<1)throw Error('"outputLen" must be >= 1');if(e.blockLen<1)throw Error('"blockLen" must be >= 1')}function q(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function F(e,t){K(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw RangeError('"digestInto() output" expected to be of length >='+r)}function J(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Z(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function G(e,t){return e<<32-t|e>>>t}class Q{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if(W(e),K(t,void 0,"key"),this.iHash=e.create(),"function"!=typeof this.iHash.update)throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,n=new Uint8Array(r);n.set(t.length>r?e.create().update(t).digest():t);for(let e=0;e<n.length;e++)n[e]^=54;this.iHash.update(n),this.oHash=e.create();for(let e=0;e<n.length;e++)n[e]^=106;this.oHash.update(n),J(n)}update(e){return q(this),this.iHash.update(e),this}digestInto(e){q(this),F(e,this),this.finished=!0;let t=e.subarray(0,this.outputLen);this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:r,finished:n,destroyed:i,blockLen:a,outputLen:o}=this;return e.finished=n,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}let Y=((o=(e,t,r)=>new Q(e,t).update(r).digest()).create=(e,t)=>new Q(e,t),o),X=Uint8Array.of(0),ee=Uint8Array.of();class et{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,r,n){this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.buffer=new Uint8Array(e),this.view=Z(this.buffer)}update(e){q(this),K(e);let{view:t,buffer:r,blockLen:n}=this,i=e.length;for(let a=0;a<i;){let o=Math.min(n-this.pos,i-a);if(o===n){let t=Z(e);for(;n<=i-a;a+=n)this.process(t,a);continue}r.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===n&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){q(this),F(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:n,isLE:i}=this,{pos:a}=this;t[a++]=128,J(this.buffer.subarray(a)),this.padOffset>n-a&&(this.process(r,0),a=0);for(let e=a;e<n;e++)t[e]=0;r.setBigUint64(n-8,BigInt(8*this.length),i),this.process(r,0);let o=Z(e),s=this.outputLen;if(s%4)throw Error("_sha2: outputLen must be aligned to 32bit");let c=s/4,l=this.get();if(c>l.length)throw Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){(e||=new this.constructor).set(...this.get());let{blockLen:t,buffer:r,length:n,finished:i,destroyed:a,pos:o}=this;return e.destroyed=a,e.finished=i,e.length=n,e.pos=o,n%t&&e.buffer.set(r),e}clone(){return this._cloneInto()}}let er=Uint32Array.from([0x6a09e667,0xbb67ae85,0x3c6ef372,0xa54ff53a,0x510e527f,0x9b05688c,0x1f83d9ab,0x5be0cd19]),en=Uint32Array.from([0xc1059ed8,0x367cd507,0x3070dd17,0xf70e5939,0xffc00b31,0x68581511,0x64f98fa7,0xbefa4fa4]),ei=Uint32Array.from([0xcbbb9d5d,0xc1059ed8,0x629a292a,0x367cd507,0x9159015a,0x3070dd17,0x152fecd8,0xf70e5939,0x67332667,0xffc00b31,0x8eb44a87,0x68581511,0xdb0c2e0d,0x64f98fa7,0x47b5481d,0xbefa4fa4]),ea=Uint32Array.from([0x6a09e667,0xf3bcc908,0xbb67ae85,0x84caa73b,0x3c6ef372,0xfe94f82b,0xa54ff53a,0x5f1d36f1,0x510e527f,0xade682d1,0x9b05688c,0x2b3e6c1f,0x1f83d9ab,0xfb41bd6b,0x5be0cd19,0x137e2179]),eo=BigInt(0x100000000-1),es=BigInt(32),ec=Uint32Array.from([0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,0xe49b69c1,0xefbe4786,0xfc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x6ca6351,0x14292967,0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070,0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2]),el=new Uint32Array(64);class ed extends et{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:r,D:n,E:i,F:a,G:o,H:s}=this;return[e,t,r,n,i,a,o,s]}set(e,t,r,n,i,a,o,s){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|a,this.G=0|o,this.H=0|s}process(e,t){for(let r=0;r<16;r++,t+=4)el[r]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=el[e-15],r=el[e-2],n=G(t,7)^G(t,18)^t>>>3,i=G(r,17)^G(r,19)^r>>>10;el[e]=i+el[e-7]+n+el[e-16]|0}let{A:r,B:n,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){var d,u,p,f;let t=l+(G(o,6)^G(o,11)^G(o,25))+((d=o)&s^~d&c)+ec[e]+el[e]|0,h=(G(r,2)^G(r,13)^G(r,22))+((u=r)&(p=n)^u&(f=i)^p&f)|0;l=c,c=s,s=o,o=a+t|0,a=i,i=n,n=r,r=t+h|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(r,n,i,a,o,s,c,l)}roundClean(){J(el)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),J(this.buffer)}}class eu extends ed{A=0|er[0];B=0|er[1];C=0|er[2];D=0|er[3];E=0|er[4];F=0|er[5];G=0|er[6];H=0|er[7];constructor(){super(32)}}let ep=function(e,t=!1){let r=e.length,n=new Uint32Array(r),i=new Uint32Array(r);for(let a=0;a<r;a++){let{h:r,l:o}=function(e,t=!1){return t?{h:Number(e&eo),l:Number(e>>es&eo)}:{h:0|Number(e>>es&eo),l:0|Number(e&eo)}}(e[a],t);[n[a],i[a]]=[r,o]}return[n,i]}(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),ef=ep[0],eh=ep[1],em=new Uint32Array(80),ey=new Uint32Array(80),eg=function(e,t={}){let r=(t,r)=>e(r).update(t).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=t=>e(t),Object.assign(r,t),Object.freeze(r)}(()=>new eu,{oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,1])}),ew=new TextEncoder,eb=new TextDecoder;function eA(...e){let t=new Uint8Array(e.reduce((e,{length:t})=>e+t,0)),r=0;for(let n of e)t.set(n,r),r+=n.length;return t}function eE(e,t,r){if(t<0||t>=0x100000000)throw RangeError(`value must be >= 0 and <= ${0x100000000-1}. Received ${t}`);e.set([t>>>24,t>>>16,t>>>8,255&t],r)}function ev(e){let t=Math.floor(e/0x100000000),r=new Uint8Array(8);return eE(r,t,0),eE(r,e%0x100000000,4),r}function ek(e){let t=new Uint8Array(4);return eE(t,e),t}function e_(e){let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n>127)throw TypeError("non-ASCII string encountered in encode()");t[r]=n}return t}function eS(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64("string"==typeof e?e:eb.decode(e),{alphabet:"base64url"});let t=e;t instanceof Uint8Array&&(t=eb.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/");try{var r=t;if(Uint8Array.fromBase64)return Uint8Array.fromBase64(r);let e=atob(r),n=new Uint8Array(e.length);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);return n}catch{throw TypeError("The input to be decoded is not correctly encoded.")}}function ex(e){let t=e;return("string"==typeof t&&(t=ew.encode(t)),Uint8Array.prototype.toBase64)?t.toBase64({alphabet:"base64url",omitPadding:!0}):(function(e){if(Uint8Array.prototype.toBase64)return e.toBase64();let t=[];for(let r=0;r<e.length;r+=32768)t.push(String.fromCharCode.apply(null,e.subarray(r,r+32768)));return btoa(t.join(""))})(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}e.s(["decode",0,eS,"encode",0,ex],797379);let eT=Symbol();function eR(e,t){if(e)throw TypeError(`${t} can only be called once`)}function eI(e,t,r){try{return eS(e)}catch{throw new r(`Failed to base64url decode the ${t}`)}}async function eU(e,t){let r=`SHA-${e.slice(-3)}`;return new Uint8Array(await crypto.subtle.digest(r,t))}let eO=(e,t="algorithm.name")=>TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`);function eP(e,t){if(parseInt(e.hash.name.slice(4),10)!==t)throw eO(`SHA-${t}`,"algorithm.hash")}function eC(e,t){if(t&&!e.usages.includes(t))throw TypeError(`CryptoKey does not support this operation, its usages must include ${t}.`)}function eD(e,t,r){switch(t){case"A128GCM":case"A192GCM":case"A256GCM":{if("AES-GCM"!==e.algorithm.name)throw eO("AES-GCM");let r=parseInt(t.slice(1,4),10);if(e.algorithm.length!==r)throw eO(r,"algorithm.length");break}case"A128KW":case"A192KW":case"A256KW":{if("AES-KW"!==e.algorithm.name)throw eO("AES-KW");let r=parseInt(t.slice(1,4),10);if(e.algorithm.length!==r)throw eO(r,"algorithm.length");break}case"ECDH":switch(e.algorithm.name){case"ECDH":case"X25519":break;default:throw eO("ECDH or X25519")}break;case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":if("PBKDF2"!==e.algorithm.name)throw eO("PBKDF2");break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":if("RSA-OAEP"!==e.algorithm.name)throw eO("RSA-OAEP");eP(e.algorithm,parseInt(t.slice(9),10)||1);break;default:throw TypeError("CryptoKey does not support this operation")}eC(e,r)}function eL(e,t,...r){if((r=r.filter(Boolean)).length>2){let t=r.pop();e+=`one of type ${r.join(", ")}, or ${t}.`}else 2===r.length?e+=`one of type ${r[0]} or ${r[1]}.`:e+=`of type ${r[0]}.`;return null==t?e+=` Received ${t}`:"function"==typeof t&&t.name?e+=` Received function ${t.name}`:"object"==typeof t&&null!=t&&t.constructor?.name&&(e+=` Received an instance of ${t.constructor.name}`),e}let ez=(e,...t)=>eL("Key must be ",e,...t),e$=(e,t,...r)=>eL(`Key for the ${e} algorithm must be `,t,...r);class eN extends Error{static code="ERR_JOSE_GENERIC";code="ERR_JOSE_GENERIC";constructor(e,t){super(e,t),this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}class ej extends eN{static code="ERR_JWT_CLAIM_VALIDATION_FAILED";code="ERR_JWT_CLAIM_VALIDATION_FAILED";claim;reason;payload;constructor(e,t,r="unspecified",n="unspecified"){super(e,{cause:{claim:r,reason:n,payload:t}}),this.claim=r,this.reason=n,this.payload=t}}class eH extends eN{static code="ERR_JWT_EXPIRED";code="ERR_JWT_EXPIRED";claim;reason;payload;constructor(e,t,r="unspecified",n="unspecified"){super(e,{cause:{claim:r,reason:n,payload:t}}),this.claim=r,this.reason=n,this.payload=t}}class eB extends eN{static code="ERR_JOSE_ALG_NOT_ALLOWED";code="ERR_JOSE_ALG_NOT_ALLOWED"}class eV extends eN{static code="ERR_JOSE_NOT_SUPPORTED";code="ERR_JOSE_NOT_SUPPORTED"}class eM extends eN{static code="ERR_JWE_DECRYPTION_FAILED";code="ERR_JWE_DECRYPTION_FAILED";constructor(e="decryption operation failed",t){super(e,t)}}class eK extends eN{static code="ERR_JWE_INVALID";code="ERR_JWE_INVALID"}class eW extends eN{static code="ERR_JWS_INVALID";code="ERR_JWS_INVALID"}class eq extends eN{static code="ERR_JWT_INVALID";code="ERR_JWT_INVALID"}class eF extends eN{static code="ERR_JWK_INVALID";code="ERR_JWK_INVALID"}class eJ extends eN{static code="ERR_JWKS_INVALID";code="ERR_JWKS_INVALID"}class eZ extends eN{static code="ERR_JWKS_NO_MATCHING_KEY";code="ERR_JWKS_NO_MATCHING_KEY";constructor(e="no applicable key found in the JSON Web Key Set",t){super(e,t)}}class eG extends eN{[Symbol.asyncIterator];static code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";constructor(e="multiple matching keys found in the JSON Web Key Set",t){super(e,t)}}class eQ extends eN{static code="ERR_JWKS_TIMEOUT";code="ERR_JWKS_TIMEOUT";constructor(e="request timed out",t){super(e,t)}}class eY extends eN{static code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";constructor(e="signature verification failed",t){super(e,t)}}function eX(e){if(!e0(e))throw Error("CryptoKey instance expected")}let e0=e=>{if(e?.[Symbol.toStringTag]==="CryptoKey")return!0;try{return e instanceof CryptoKey}catch{return!1}},e1=e=>e?.[Symbol.toStringTag]==="KeyObject",e2=e=>e0(e)||e1(e);function e6(e){switch(e){case"A128GCM":return 128;case"A192GCM":return 192;case"A256GCM":case"A128CBC-HS256":return 256;case"A192CBC-HS384":return 384;case"A256CBC-HS512":return 512;default:throw new eV(`Unsupported JWE Algorithm: ${e}`)}}let e5=e=>crypto.getRandomValues(new Uint8Array(e6(e)>>3));function e8(e,t){let r=e.byteLength<<3;if(r!==t)throw new eK(`Invalid Content Encryption Key length. Expected ${t} bits, got ${r} bits`)}function e4(e){switch(e){case"A128GCM":case"A128GCMKW":case"A192GCM":case"A192GCMKW":case"A256GCM":case"A256GCMKW":return 96;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return 128;default:throw new eV(`Unsupported JWE Algorithm: ${e}`)}}function e3(e,t){if(t.length<<3!==e4(e))throw new eK("Invalid Initialization Vector length")}async function e9(e,t,r){if(!(t instanceof Uint8Array))throw TypeError(ez(t,"Uint8Array"));let n=parseInt(e.slice(1,4),10);return{encKey:await crypto.subtle.importKey("raw",t.subarray(n>>3),"AES-CBC",!1,[r]),macKey:await crypto.subtle.importKey("raw",t.subarray(0,n>>3),{hash:`SHA-${n<<1}`,name:"HMAC"},!1,["sign"]),keySize:n}}async function e7(e,t,r){return new Uint8Array((await crypto.subtle.sign("HMAC",e,t)).slice(0,r>>3))}async function te(e,t,r,n,i){let{encKey:a,macKey:o,keySize:s}=await e9(e,r,"encrypt"),c=new Uint8Array(await crypto.subtle.encrypt({iv:n,name:"AES-CBC"},a,t)),l=eA(i,n,c,ev(i.length<<3));return{ciphertext:c,tag:await e7(o,l,s),iv:n}}async function tt(e,t){if(!(e instanceof Uint8Array))throw TypeError("First argument must be a buffer");if(!(t instanceof Uint8Array))throw TypeError("Second argument must be a buffer");let r={name:"HMAC",hash:"SHA-256"},n=await crypto.subtle.generateKey(r,!1,["sign"]),i=new Uint8Array(await crypto.subtle.sign(r,n,e)),a=new Uint8Array(await crypto.subtle.sign(r,n,t)),o=0,s=-1;for(;++s<32;)o|=i[s]^a[s];return 0===o}async function tr(e,t,r,n,i,a){let o,s,{encKey:c,macKey:l,keySize:d}=await e9(e,t,"decrypt"),u=eA(a,n,r,ev(a.length<<3)),p=await e7(l,u,d);try{o=await tt(i,p)}catch{}if(!o)throw new eM;try{s=new Uint8Array(await crypto.subtle.decrypt({iv:n,name:"AES-CBC"},c,r))}catch{}if(!s)throw new eM;return s}async function tn(e,t,r,n,i){let a;r instanceof Uint8Array?a=await crypto.subtle.importKey("raw",r,"AES-GCM",!1,["encrypt"]):(eD(r,e,"encrypt"),a=r);let o=new Uint8Array(await crypto.subtle.encrypt({additionalData:i,iv:n,name:"AES-GCM",tagLength:128},a,t)),s=o.slice(-16);return{ciphertext:o.slice(0,-16),tag:s,iv:n}}async function ti(e,t,r,n,i,a){let o;t instanceof Uint8Array?o=await crypto.subtle.importKey("raw",t,"AES-GCM",!1,["decrypt"]):(eD(t,e,"decrypt"),o=t);try{return new Uint8Array(await crypto.subtle.decrypt({additionalData:a,iv:n,name:"AES-GCM",tagLength:128},o,eA(r,i)))}catch{throw new eM}}let ta="Unsupported JWE Content Encryption Algorithm";async function to(e,t,r,n,i){if(!e0(r)&&!(r instanceof Uint8Array))throw TypeError(ez(r,"CryptoKey","KeyObject","Uint8Array","JSON Web Key"));if(n)e3(e,n);else n=crypto.getRandomValues(new Uint8Array(e4(e)>>3));switch(e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return r instanceof Uint8Array&&e8(r,parseInt(e.slice(-3),10)),te(e,t,r,n,i);case"A128GCM":case"A192GCM":case"A256GCM":return r instanceof Uint8Array&&e8(r,parseInt(e.slice(1,4),10)),tn(e,t,r,n,i);default:throw new eV(ta)}}async function ts(e,t,r,n,i,a){if(!e0(t)&&!(t instanceof Uint8Array))throw TypeError(ez(t,"CryptoKey","KeyObject","Uint8Array","JSON Web Key"));if(!n)throw new eK("JWE Initialization Vector missing");if(!i)throw new eK("JWE Authentication Tag missing");switch(e3(e,n),e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return t instanceof Uint8Array&&e8(t,parseInt(e.slice(-3),10)),tr(e,t,r,n,i,a);case"A128GCM":case"A192GCM":case"A256GCM":return t instanceof Uint8Array&&e8(t,parseInt(e.slice(1,4),10)),ti(e,t,r,n,i,a);default:throw new eV(ta)}}function tc(e,t){if(e.algorithm.length!==parseInt(t.slice(1,4),10))throw TypeError(`Invalid key size for alg: ${t}`)}function tl(e,t,r){return e instanceof Uint8Array?crypto.subtle.importKey("raw",e,"AES-KW",!0,[r]):(eD(e,t,r),e)}async function td(e,t,r){let n=await tl(t,e,"wrapKey");tc(n,e);let i=await crypto.subtle.importKey("raw",r,{hash:"SHA-256",name:"HMAC"},!0,["sign"]);return new Uint8Array(await crypto.subtle.wrapKey("raw",i,n,"AES-KW"))}async function tu(e,t,r){let n=await tl(t,e,"unwrapKey");tc(n,e);let i=await crypto.subtle.unwrapKey("raw",r,n,"AES-KW",{hash:"SHA-256",name:"HMAC"},!0,["sign"]);return new Uint8Array(await crypto.subtle.exportKey("raw",i))}function tp(e){return eA(ek(e.length),e)}async function tf(e,t,r){let n=t>>3,i=Math.ceil(n/32),a=new Uint8Array(32*i);for(let t=1;t<=i;t++){let n=new Uint8Array(4+e.length+r.length);n.set(ek(t),0),n.set(e,4),n.set(r,4+e.length);let i=await eU("sha256",n);a.set(i,(t-1)*32)}return a.slice(0,n)}async function th(e,t,r,n,i=new Uint8Array,a=new Uint8Array){var o;eD(e,"ECDH"),eD(t,"ECDH","deriveBits");let s=eA(tp(e_(r)),tp(i),tp(a),ek(n),new Uint8Array);return tf(new Uint8Array(await crypto.subtle.deriveBits({name:e.algorithm.name,public:e},t,"X25519"===(o=e).algorithm.name?256:Math.ceil(parseInt(o.algorithm.namedCurve.slice(-3),10)/8)<<3)),n,s)}function tm(e){switch(e.algorithm.namedCurve){case"P-256":case"P-384":case"P-521":return!0;default:return"X25519"===e.algorithm.name}}async function ty(e,t,r,n){if(!(e instanceof Uint8Array)||e.length<8)throw new eK("PBES2 Salt Input must be 8 or more octets");if(!Number.isSafeInteger(r)||1!==Math.sign(r))throw new eK("PBES2 Count Input must be a positive integer");let i=eA(e_(t),Uint8Array.of(0),e),a=parseInt(t.slice(13,16),10),o={hash:`SHA-${t.slice(8,11)}`,iterations:r,name:"PBKDF2",salt:i},s=await (n instanceof Uint8Array?crypto.subtle.importKey("raw",n,"PBKDF2",!1,["deriveBits"]):(eD(n,t,"deriveBits"),n));return new Uint8Array(await crypto.subtle.deriveBits(o,s,a))}async function tg(e,t,r,n=2048,i=crypto.getRandomValues(new Uint8Array(16))){let a=await ty(i,e,n,t);return{encryptedKey:await td(e.slice(-6),a,r),p2c:n,p2s:ex(i)}}async function tw(e,t,r,n,i){let a=await ty(i,e,n,t);return tu(e.slice(-6),a,r)}function tb(e,t){if(e.startsWith("RS")||e.startsWith("PS")){let{modulusLength:r}=t.algorithm;if("number"!=typeof r||r<2048)throw TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}}function tA(e,t){let r=`SHA-${e.slice(-3)}`;switch(e){case"HS256":case"HS384":case"HS512":return{hash:r,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:r,name:"RSA-PSS",saltLength:parseInt(e.slice(-3),10)>>3};case"RS256":case"RS384":case"RS512":return{hash:r,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:r,name:"ECDSA",namedCurve:t.namedCurve};case"Ed25519":case"EdDSA":return{name:"Ed25519"};case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":return{name:e};default:throw new eV(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}async function tE(e,t,r){if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw TypeError(ez(t,"CryptoKey","KeyObject","JSON Web Key"));return crypto.subtle.importKey("raw",t,{hash:`SHA-${e.slice(-3)}`,name:"HMAC"},!1,[r])}switch(e){case"HS256":case"HS384":case"HS512":if("HMAC"!==t.algorithm.name)throw eO("HMAC");eP(t.algorithm,parseInt(e.slice(2),10));break;case"RS256":case"RS384":case"RS512":if("RSASSA-PKCS1-v1_5"!==t.algorithm.name)throw eO("RSASSA-PKCS1-v1_5");eP(t.algorithm,parseInt(e.slice(2),10));break;case"PS256":case"PS384":case"PS512":if("RSA-PSS"!==t.algorithm.name)throw eO("RSA-PSS");eP(t.algorithm,parseInt(e.slice(2),10));break;case"Ed25519":case"EdDSA":if("Ed25519"!==t.algorithm.name)throw eO("Ed25519");break;case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":let n;if(n=t.algorithm,n.name!==e)throw eO(e);break;case"ES256":case"ES384":case"ES512":{if("ECDSA"!==t.algorithm.name)throw eO("ECDSA");let r=function(e){switch(e){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw Error("unreachable")}}(e);if(t.algorithm.namedCurve!==r)throw eO(r,"algorithm.namedCurve");break}default:throw TypeError("CryptoKey does not support this operation")}return eC(t,r),t}async function tv(e,t,r){let n=await tE(e,t,"sign");return tb(e,n),new Uint8Array(await crypto.subtle.sign(tA(e,n.algorithm),n,r))}async function tk(e,t,r,n){let i=await tE(e,t,"verify");tb(e,i);let a=tA(e,i.algorithm);try{return await crypto.subtle.verify(a,i,r,n)}catch{return!1}}let t_=e=>{switch(e){case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return"RSA-OAEP";default:throw new eV(`alg ${e} is not supported either by JOSE or your javascript runtime`)}};async function tS(e,t,r){return eD(t,e,"encrypt"),tb(e,t),new Uint8Array(await crypto.subtle.encrypt(t_(e),t,r))}async function tx(e,t,r){return eD(t,e,"decrypt"),tb(e,t),new Uint8Array(await crypto.subtle.decrypt(t_(e),t,r))}function tT(e){if("object"!=typeof e||null===e||"[object Object]"!==Object.prototype.toString.call(e))return!1;if(null===Object.getPrototypeOf(e))return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function tR(...e){let t,r=e.filter(Boolean);if(0===r.length||1===r.length)return!0;for(let e of r){let r=Object.keys(e);if(!t||0===t.size){t=new Set(r);continue}for(let e of r){if(t.has(e))return!1;t.add(e)}}return!0}let tI=e=>tT(e)&&"string"==typeof e.kty,tU='Invalid or unsupported JWK "alg" (Algorithm) Parameter value';async function tO(e){if(!e.alg)throw TypeError('"alg" argument is required when "jwk.alg" is not present');let{algorithm:t,keyUsages:r}=function(e){let t,r;switch(e.kty){case"AKP":switch(e.alg){case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":t={name:e.alg},r=e.priv?["sign"]:["verify"];break;default:throw new eV(tU)}break;case"RSA":switch(e.alg){case"PS256":case"PS384":case"PS512":t={name:"RSA-PSS",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":t={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":t={name:"RSA-OAEP",hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`},r=e.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new eV(tU)}break;case"EC":switch(e.alg){case"ES256":case"ES384":case"ES512":t={name:"ECDSA",namedCurve:({ES256:"P-256",ES384:"P-384",ES512:"P-521"})[e.alg]},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:"ECDH",namedCurve:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new eV(tU)}break;case"OKP":switch(e.alg){case"Ed25519":case"EdDSA":t={name:"Ed25519"},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new eV(tU)}break;default:throw new eV('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:t,keyUsages:r}}(e),n={...e};return"AKP"!==n.kty&&delete n.alg,delete n.use,crypto.subtle.importKey("jwk",n,t,e.ext??(!e.d&&!e.priv),e.key_ops??r)}let tP="given KeyObject instance cannot be used for this algorithm",tC=async(e,r,n,i=!1)=>{let a=(t||=new WeakMap).get(e);if(a?.[n])return a[n];let o=await tO({...r,alg:n});return i&&Object.freeze(e),a?a[n]=o:t.set(e,{[n]:o}),o};async function tD(e,r){if(e instanceof Uint8Array||e0(e))return e;if(e1(e)){if("secret"===e.type)return e.export();if("toCryptoKey"in e&&"function"==typeof e.toCryptoKey)try{return((e,r)=>{let n,i=(t||=new WeakMap).get(e);if(i?.[r])return i[r];let a="public"===e.type,o=!!a;if("x25519"===e.asymmetricKeyType){switch(r){case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":break;default:throw TypeError(tP)}n=e.toCryptoKey(e.asymmetricKeyType,o,a?[]:["deriveBits"])}if("ed25519"===e.asymmetricKeyType){if("EdDSA"!==r&&"Ed25519"!==r)throw TypeError(tP);n=e.toCryptoKey(e.asymmetricKeyType,o,[a?"verify":"sign"])}switch(e.asymmetricKeyType){case"ml-dsa-44":case"ml-dsa-65":case"ml-dsa-87":if(r!==e.asymmetricKeyType.toUpperCase())throw TypeError(tP);n=e.toCryptoKey(e.asymmetricKeyType,o,[a?"verify":"sign"])}if("rsa"===e.asymmetricKeyType){let t;switch(r){case"RSA-OAEP":t="SHA-1";break;case"RS256":case"PS256":case"RSA-OAEP-256":t="SHA-256";break;case"RS384":case"PS384":case"RSA-OAEP-384":t="SHA-384";break;case"RS512":case"PS512":case"RSA-OAEP-512":t="SHA-512";break;default:throw TypeError(tP)}if(r.startsWith("RSA-OAEP"))return e.toCryptoKey({name:"RSA-OAEP",hash:t},o,a?["encrypt"]:["decrypt"]);n=e.toCryptoKey({name:r.startsWith("PS")?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:t},o,[a?"verify":"sign"])}if("ec"===e.asymmetricKeyType){let t=new Map([["prime256v1","P-256"],["secp384r1","P-384"],["secp521r1","P-521"]]).get(e.asymmetricKeyDetails?.namedCurve);if(!t)throw TypeError(tP);let i={ES256:"P-256",ES384:"P-384",ES512:"P-521"};i[r]&&t===i[r]&&(n=e.toCryptoKey({name:"ECDSA",namedCurve:t},o,[a?"verify":"sign"])),r.startsWith("ECDH-ES")&&(n=e.toCryptoKey({name:"ECDH",namedCurve:t},o,a?[]:["deriveBits"]))}if(!n)throw TypeError(tP);return i?i[r]=n:t.set(e,{[r]:n}),n})(e,r)}catch(e){if(e instanceof TypeError)throw e}let n=e.export({format:"jwk"});return tC(e,n,r)}if(tI(e))return e.k?eS(e.k):tC(e,e,r,!0);throw Error("unreachable")}async function tL(e,t,r){let n;if(!tT(e))throw TypeError("JWK must be an object");switch(t??=e.alg,n??=r?.extractable??e.ext,e.kty){case"oct":if("string"!=typeof e.k||!e.k)throw TypeError('missing "k" (Key Value) Parameter value');return eS(e.k);case"RSA":if("oth"in e&&void 0!==e.oth)throw new eV('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');return tO({...e,alg:t,ext:n});case"AKP":if("string"!=typeof e.alg||!e.alg)throw TypeError('missing "alg" (Algorithm) Parameter value');if(void 0!==t&&t!==e.alg)throw TypeError("JWK alg and alg option value mismatch");return tO({...e,ext:n});case"EC":case"OKP":return tO({...e,alg:t,ext:n});default:throw new eV('Unsupported "kty" (Key Type) Parameter value')}}async function tz(e){if(e1(e))if("secret"!==e.type)return e.export({format:"jwk"});else e=e.export();if(e instanceof Uint8Array)return{kty:"oct",k:ex(e)};if(!e0(e))throw TypeError(ez(e,"CryptoKey","KeyObject","Uint8Array"));if(!e.extractable)throw TypeError("non-extractable CryptoKey cannot be exported as a JWK");let{ext:t,key_ops:r,alg:n,use:i,...a}=await crypto.subtle.exportKey("jwk",e);return"AKP"===a.kty&&(a.alg=n),a}async function t$(e){return tz(e)}async function tN(e,t,r,n){let i=e.slice(0,7),a=await to(i,r,t,n,new Uint8Array);return{encryptedKey:a.ciphertext,iv:ex(a.iv),tag:ex(a.tag)}}async function tj(e,t,r,n,i){return ts(e.slice(0,7),t,r,n,i,new Uint8Array)}let tH='Invalid or unsupported "alg" (JWE Algorithm) header value';function tB(e){if(void 0===e)throw new eK("JWE Encrypted Key missing")}async function tV(e,t,r,n,i){switch(e){case"dir":if(void 0!==r)throw new eK("Encountered unexpected JWE Encrypted Key");return t;case"ECDH-ES":if(void 0!==r)throw new eK("Encountered unexpected JWE Encrypted Key");case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{let i,a;if(!tT(n.epk))throw new eK('JOSE Header "epk" (Ephemeral Public Key) missing or invalid');if(eX(t),!tm(t))throw new eV("ECDH with the provided key is not allowed or not supported by your javascript runtime");let o=await tL(n.epk,e);if(eX(o),void 0!==n.apu){if("string"!=typeof n.apu)throw new eK('JOSE Header "apu" (Agreement PartyUInfo) invalid');i=eI(n.apu,"apu",eK)}if(void 0!==n.apv){if("string"!=typeof n.apv)throw new eK('JOSE Header "apv" (Agreement PartyVInfo) invalid');a=eI(n.apv,"apv",eK)}let s=await th(o,t,"ECDH-ES"===e?n.enc:e,"ECDH-ES"===e?e6(n.enc):parseInt(e.slice(-5,-2),10),i,a);if("ECDH-ES"===e)return s;return tB(r),tu(e.slice(-6),s,r)}case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return tB(r),eX(t),tx(e,t,r);case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{let a;if(tB(r),"number"!=typeof n.p2c)throw new eK('JOSE Header "p2c" (PBES2 Count) missing or invalid');let o=i?.maxPBES2Count||1e4;if(n.p2c>o)throw new eK('JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds');if("string"!=typeof n.p2s)throw new eK('JOSE Header "p2s" (PBES2 Salt) missing or invalid');return a=eI(n.p2s,"p2s",eK),tw(e,t,r,n.p2c,a)}case"A128KW":case"A192KW":case"A256KW":return tB(r),tu(e,t,r);case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":if(tB(r),"string"!=typeof n.iv)throw new eK('JOSE Header "iv" (Initialization Vector) missing or invalid');if("string"!=typeof n.tag)throw new eK('JOSE Header "tag" (Authentication Tag) missing or invalid');return tj(e,t,r,eI(n.iv,"iv",eK),eI(n.tag,"tag",eK));default:throw new eV(tH)}}async function tM(e,t,r,n,i={}){let a,o,s;switch(e){case"dir":s=r;break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{let c;if(eX(r),!tm(r))throw new eV("ECDH with the provided key is not allowed or not supported by your javascript runtime");let{apu:l,apv:d}=i;c=i.epk?await tD(i.epk,e):(await crypto.subtle.generateKey(r.algorithm,!0,["deriveBits"])).privateKey;let{x:u,y:p,crv:f,kty:h}=await t$(c),m=await th(r,c,"ECDH-ES"===e?t:e,"ECDH-ES"===e?e6(t):parseInt(e.slice(-5,-2),10),l,d);if(o={epk:{x:u,crv:f,kty:h}},"EC"===h&&(o.epk.y=p),l&&(o.apu=ex(l)),d&&(o.apv=ex(d)),"ECDH-ES"===e){s=m;break}s=n||e5(t);let y=e.slice(-6);a=await td(y,m,s);break}case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":s=n||e5(t),eX(r),a=await tS(e,r,s);break;case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{s=n||e5(t);let{p2c:c,p2s:l}=i;({encryptedKey:a,...o}=await tg(e,r,s,c,l));break}case"A128KW":case"A192KW":case"A256KW":s=n||e5(t),a=await td(e,r,s);break;case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{s=n||e5(t);let{iv:c}=i;({encryptedKey:a,...o}=await tN(e,r,s,c));break}default:throw new eV(tH)}return{cek:s,encryptedKey:a,parameters:o}}function tK(e,t,r,n,i){let a;if(void 0!==i.crit&&n?.crit===void 0)throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!n||void 0===n.crit)return new Set;if(!Array.isArray(n.crit)||0===n.crit.length||n.crit.some(e=>"string"!=typeof e||0===e.length))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');for(let o of(a=void 0!==r?new Map([...Object.entries(r),...t.entries()]):t,n.crit)){if(!a.has(o))throw new eV(`Extension Header Parameter "${o}" is not recognized`);if(void 0===i[o])throw new e(`Extension Header Parameter "${o}" is missing`);if(a.get(o)&&void 0===n[o])throw new e(`Extension Header Parameter "${o}" MUST be integrity protected`)}return new Set(n.crit)}let tW=e=>e?.[Symbol.toStringTag],tq=(e,t,r)=>{if(void 0!==t.use){let e;switch(r){case"sign":case"verify":e="sig";break;case"encrypt":case"decrypt":e="enc"}if(t.use!==e)throw TypeError(`Invalid key for this operation, its "use" must be "${e}" when present`)}if(void 0!==t.alg&&t.alg!==e)throw TypeError(`Invalid key for this operation, its "alg" must be "${e}" when present`);if(Array.isArray(t.key_ops)){let n;switch(!0){case"sign"===r||"verify"===r:case"dir"===e:case e.includes("CBC-HS"):n=r;break;case e.startsWith("PBES2"):n="deriveBits";break;case/^A\d{3}(?:GCM)?(?:KW)?$/.test(e):n=!e.includes("GCM")&&e.endsWith("KW")?"encrypt"===r?"wrapKey":"unwrapKey":r;break;case"encrypt"===r&&e.startsWith("RSA"):n="wrapKey";break;case"decrypt"===r:n=e.startsWith("RSA")?"unwrapKey":"deriveBits"}if(n&&t.key_ops?.includes?.(n)===!1)throw TypeError(`Invalid key for this operation, its "key_ops" must include "${n}" when present`)}return!0};function tF(e,t,r){switch(e.substring(0,2)){case"A1":case"A2":case"di":case"HS":case"PB":((e,t,r)=>{if(!(t instanceof Uint8Array)){if(tI(t)){if("oct"===t.kty&&"string"==typeof t.k&&tq(e,t,r))return;throw TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present')}if(!e2(t))throw TypeError(e$(e,t,"CryptoKey","KeyObject","JSON Web Key","Uint8Array"));if("secret"!==t.type)throw TypeError(`${tW(t)} instances for symmetric algorithms must be of type "secret"`)}})(e,t,r);break;default:((e,t,r)=>{if(tI(t))switch(r){case"decrypt":case"sign":if("oct"!==t.kty&&("AKP"===t.kty&&"string"==typeof t.priv||"string"==typeof t.d)&&tq(e,t,r))return;throw TypeError("JSON Web Key for this operation must be a private JWK");case"encrypt":case"verify":if("oct"!==t.kty&&void 0===t.d&&void 0===t.priv&&tq(e,t,r))return;throw TypeError("JSON Web Key for this operation must be a public JWK")}if(!e2(t))throw TypeError(e$(e,t,"CryptoKey","KeyObject","JSON Web Key"));if("secret"===t.type)throw TypeError(`${tW(t)} instances for asymmetric algorithms must not be of type "secret"`);if("public"===t.type)switch(r){case"sign":throw TypeError(`${tW(t)} instances for asymmetric algorithm signing must be of type "private"`);case"decrypt":throw TypeError(`${tW(t)} instances for asymmetric algorithm decryption must be of type "private"`)}if("private"===t.type)switch(r){case"verify":throw TypeError(`${tW(t)} instances for asymmetric algorithm verifying must be of type "public"`);case"encrypt":throw TypeError(`${tW(t)} instances for asymmetric algorithm encryption must be of type "public"`)}})(e,t,r)}}function tJ(e){if(void 0===globalThis[e])throw new eV(`JWE "zip" (Compression Algorithm) Header Parameter requires the ${e} API.`)}async function tZ(e){tJ("CompressionStream");let t=new CompressionStream("deflate-raw"),r=t.writable.getWriter();r.write(e).catch(()=>{}),r.close().catch(()=>{});let n=[],i=t.readable.getReader();for(;;){let{value:e,done:t}=await i.read();if(t)break;n.push(e)}return eA(...n)}async function tG(e,t){tJ("DecompressionStream");let r=new DecompressionStream("deflate-raw"),n=r.writable.getWriter();n.write(e).catch(()=>{}),n.close().catch(()=>{});let i=[],a=0,o=r.readable.getReader();for(;;){let{value:e,done:r}=await o.read();if(r)break;if(i.push(e),a+=e.byteLength,t!==1/0&&a>t)throw new eK("Decompressed plaintext exceeded the configured limit")}return eA(...i)}class tQ{#e;#t;#r;#n;#i;#a;#o;#s;constructor(e){if(!(e instanceof Uint8Array))throw TypeError("plaintext must be an instance of Uint8Array");this.#e=e}setKeyManagementParameters(e){return eR(this.#s,"setKeyManagementParameters"),this.#s=e,this}setProtectedHeader(e){return eR(this.#t,"setProtectedHeader"),this.#t=e,this}setSharedUnprotectedHeader(e){return eR(this.#r,"setSharedUnprotectedHeader"),this.#r=e,this}setUnprotectedHeader(e){return eR(this.#n,"setUnprotectedHeader"),this.#n=e,this}setAdditionalAuthenticatedData(e){return this.#i=e,this}setContentEncryptionKey(e){return eR(this.#a,"setContentEncryptionKey"),this.#a=e,this}setInitializationVector(e){return eR(this.#o,"setInitializationVector"),this.#o=e,this}async encrypt(e,t){let r,n,i,a,o,s;if(!this.#t&&!this.#n&&!this.#r)throw new eK("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");if(!tR(this.#t,this.#n,this.#r))throw new eK("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");let c={...this.#t,...this.#n,...this.#r};if(tK(eK,new Map,t?.crit,this.#t,c),void 0!==c.zip&&"DEF"!==c.zip)throw new eV('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');if(void 0!==c.zip&&!this.#t?.zip)throw new eK('JWE "zip" (Compression Algorithm) Header Parameter MUST be in a protected header.');let{alg:l,enc:d}=c;if("string"!=typeof l||!l)throw new eK('JWE "alg" (Algorithm) Header Parameter missing or invalid');if("string"!=typeof d||!d)throw new eK('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');if(this.#a&&("dir"===l||"ECDH-ES"===l))throw TypeError(`setContentEncryptionKey cannot be called with JWE "alg" (Algorithm) Header ${l}`);tF("dir"===l?d:l,e,"encrypt");{let i,a=await tD(e,l);({cek:n,encryptedKey:r,parameters:i}=await tM(l,d,a,this.#a,this.#s)),i&&(t&&eT in t?this.#n?this.#n={...this.#n,...i}:this.setUnprotectedHeader(i):this.#t?this.#t={...this.#t,...i}:this.setProtectedHeader(i))}if(this.#t?o=e_(a=ex(JSON.stringify(this.#t))):(a="",o=new Uint8Array),this.#i){let e=e_(s=ex(this.#i));i=eA(o,e_("."),e)}else i=o;let u=this.#e;"DEF"===c.zip&&(u=await tZ(u).catch(e=>{throw new eK("Failed to compress plaintext",{cause:e})}));let{ciphertext:p,tag:f,iv:h}=await to(d,u,n,this.#o,i),m={ciphertext:ex(p)};return h&&(m.iv=ex(h)),f&&(m.tag=ex(f)),r&&(m.encrypted_key=ex(r)),s&&(m.aad=s),this.#t&&(m.protected=a),this.#r&&(m.unprotected=this.#r),this.#n&&(m.header=this.#n),m}}class tY{#c;constructor(e){this.#c=new tQ(e)}setContentEncryptionKey(e){return this.#c.setContentEncryptionKey(e),this}setInitializationVector(e){return this.#c.setInitializationVector(e),this}setProtectedHeader(e){return this.#c.setProtectedHeader(e),this}setKeyManagementParameters(e){return this.#c.setKeyManagementParameters(e),this}async encrypt(e,t){let r=await this.#c.encrypt(e,t);return[r.protected,r.encrypted_key,r.iv,r.ciphertext,r.tag].join(".")}}let tX=e=>Math.floor(e.getTime()/1e3),t0=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;function t1(e){let t,r=t0.exec(e);if(!r||r[4]&&r[1])throw TypeError("Invalid time period format");let n=parseFloat(r[2]);switch(r[3].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":t=Math.round(n);break;case"minute":case"minutes":case"min":case"mins":case"m":t=Math.round(60*n);break;case"hour":case"hours":case"hr":case"hrs":case"h":t=Math.round(3600*n);break;case"day":case"days":case"d":t=Math.round(86400*n);break;case"week":case"weeks":case"w":t=Math.round(604800*n);break;default:t=Math.round(0x1e187e0*n)}return"-"===r[1]||"ago"===r[4]?-t:t}function t2(e,t){if(!Number.isFinite(t))throw TypeError(`Invalid ${e} input`);return t}let t6=e=>e.includes("/")?e.toLowerCase():`application/${e.toLowerCase()}`;function t5(e,t,r={}){var n,i;let a,o;try{a=JSON.parse(eb.decode(t))}catch{}if(!tT(a))throw new eq("JWT Claims Set must be a top-level JSON object");let{typ:s}=r;if(s&&("string"!=typeof e.typ||t6(e.typ)!==t6(s)))throw new ej('unexpected "typ" JWT header value',a,"typ","check_failed");let{requiredClaims:c=[],issuer:l,subject:d,audience:u,maxTokenAge:p}=r,f=[...c];for(let e of(void 0!==p&&f.push("iat"),void 0!==u&&f.push("aud"),void 0!==d&&f.push("sub"),void 0!==l&&f.push("iss"),new Set(f.reverse())))if(!(e in a))throw new ej(`missing required "${e}" claim`,a,e,"missing");if(l&&!(Array.isArray(l)?l:[l]).includes(a.iss))throw new ej('unexpected "iss" claim value',a,"iss","check_failed");if(d&&a.sub!==d)throw new ej('unexpected "sub" claim value',a,"sub","check_failed");if(u&&(n=a.aud,i="string"==typeof u?[u]:u,"string"==typeof n?!i.includes(n):!(Array.isArray(n)&&i.some(Set.prototype.has.bind(new Set(n))))))throw new ej('unexpected "aud" claim value',a,"aud","check_failed");switch(typeof r.clockTolerance){case"string":o=t1(r.clockTolerance);break;case"number":o=r.clockTolerance;break;case"undefined":o=0;break;default:throw TypeError("Invalid clockTolerance option type")}let{currentDate:h}=r,m=tX(h||new Date);if((void 0!==a.iat||p)&&"number"!=typeof a.iat)throw new ej('"iat" claim must be a number',a,"iat","invalid");if(void 0!==a.nbf){if("number"!=typeof a.nbf)throw new ej('"nbf" claim must be a number',a,"nbf","invalid");if(a.nbf>m+o)throw new ej('"nbf" claim timestamp check failed',a,"nbf","check_failed")}if(void 0!==a.exp){if("number"!=typeof a.exp)throw new ej('"exp" claim must be a number',a,"exp","invalid");if(a.exp<=m-o)throw new eH('"exp" claim timestamp check failed',a,"exp","check_failed")}if(p){let e=m-a.iat;if(e-o>("number"==typeof p?p:t1(p)))throw new eH('"iat" claim timestamp check failed (too far in the past)',a,"iat","check_failed");if(e<0-o)throw new ej('"iat" claim timestamp check failed (it should be in the past)',a,"iat","check_failed")}return a}class t8{#l;constructor(e){if(!tT(e))throw TypeError("JWT Claims Set MUST be an object");this.#l=structuredClone(e)}data(){return ew.encode(JSON.stringify(this.#l))}get iss(){return this.#l.iss}set iss(e){this.#l.iss=e}get sub(){return this.#l.sub}set sub(e){this.#l.sub=e}get aud(){return this.#l.aud}set aud(e){this.#l.aud=e}set jti(e){this.#l.jti=e}set nbf(e){"number"==typeof e?this.#l.nbf=t2("setNotBefore",e):e instanceof Date?this.#l.nbf=t2("setNotBefore",tX(e)):this.#l.nbf=tX(new Date)+t1(e)}set exp(e){"number"==typeof e?this.#l.exp=t2("setExpirationTime",e):e instanceof Date?this.#l.exp=t2("setExpirationTime",tX(e)):this.#l.exp=tX(new Date)+t1(e)}set iat(e){void 0===e?this.#l.iat=tX(new Date):e instanceof Date?this.#l.iat=t2("setIssuedAt",tX(e)):"string"==typeof e?this.#l.iat=t2("setIssuedAt",tX(new Date)+t1(e)):this.#l.iat=t2("setIssuedAt",e)}}class t4{#a;#o;#s;#t;#d;#u;#p;#f;constructor(e={}){this.#f=new t8(e)}setIssuer(e){return this.#f.iss=e,this}setSubject(e){return this.#f.sub=e,this}setAudience(e){return this.#f.aud=e,this}setJti(e){return this.#f.jti=e,this}setNotBefore(e){return this.#f.nbf=e,this}setExpirationTime(e){return this.#f.exp=e,this}setIssuedAt(e){return this.#f.iat=e,this}setProtectedHeader(e){return eR(this.#t,"setProtectedHeader"),this.#t=e,this}setKeyManagementParameters(e){return eR(this.#s,"setKeyManagementParameters"),this.#s=e,this}setContentEncryptionKey(e){return eR(this.#a,"setContentEncryptionKey"),this.#a=e,this}setInitializationVector(e){return eR(this.#o,"setInitializationVector"),this.#o=e,this}replicateIssuerAsHeader(){return this.#d=!0,this}replicateSubjectAsHeader(){return this.#u=!0,this}replicateAudienceAsHeader(){return this.#p=!0,this}async encrypt(e,t){let r=new tY(this.#f.data());return this.#t&&(this.#d||this.#u||this.#p)&&(this.#t={...this.#t,iss:this.#d?this.#f.iss:void 0,sub:this.#u?this.#f.sub:void 0,aud:this.#p?this.#f.aud:void 0}),r.setProtectedHeader(this.#t),this.#o&&r.setInitializationVector(this.#o),this.#a&&r.setContentEncryptionKey(this.#a),this.#s&&r.setKeyManagementParameters(this.#s),r.encrypt(e,t)}}class t3{#l;#t;#n;constructor(e){if(!(e instanceof Uint8Array))throw TypeError("payload must be an instance of Uint8Array");this.#l=e}setProtectedHeader(e){return eR(this.#t,"setProtectedHeader"),this.#t=e,this}setUnprotectedHeader(e){return eR(this.#n,"setUnprotectedHeader"),this.#n=e,this}async sign(e,t){let r,n,i,a;if(!this.#t&&!this.#n)throw new eW("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!tR(this.#t,this.#n))throw new eW("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let o={...this.#t,...this.#n},s=tK(eW,new Map([["b64",!0]]),t?.crit,this.#t,o),c=!0;if(s.has("b64")&&"boolean"!=typeof(c=this.#t.b64))throw new eW('The "b64" (base64url-encode payload) Header Parameter must be a boolean');let{alg:l}=o;if("string"!=typeof l||!l)throw new eW('JWS "alg" (Algorithm) Header Parameter missing or invalid');tF(l,e,"sign"),c?n=e_(r=ex(this.#l)):(n=this.#l,r=""),this.#t?a=e_(i=ex(JSON.stringify(this.#t))):(i="",a=new Uint8Array);let d=eA(a,e_("."),n),u=await tD(e,l),p={signature:ex(await tv(l,u,d)),payload:r};return this.#n&&(p.header=this.#n),this.#t&&(p.protected=i),p}}class t9{#c;constructor(e){this.#c=new t3(e)}setProtectedHeader(e){return this.#c.setProtectedHeader(e),this}async sign(e,t){let r=await this.#c.sign(e,t);if(void 0===r.payload)throw TypeError("use the flattened module for creating JWS with b64: false");return`${r.protected}.${r.payload}.${r.signature}`}}class t7{#t;#f;constructor(e={}){this.#f=new t8(e)}setIssuer(e){return this.#f.iss=e,this}setSubject(e){return this.#f.sub=e,this}setAudience(e){return this.#f.aud=e,this}setJti(e){return this.#f.jti=e,this}setNotBefore(e){return this.#f.nbf=e,this}setExpirationTime(e){return this.#f.exp=e,this}setIssuedAt(e){return this.#f.iat=e,this}setProtectedHeader(e){return this.#t=e,this}async sign(e,t){let r=new t9(this.#f.data());if(r.setProtectedHeader(this.#t),Array.isArray(this.#t?.crit)&&this.#t.crit.includes("b64")&&!1===this.#t.b64)throw new eq("JWTs MUST NOT use unencoded payload");return r.sign(e,t)}}var re=e.i(797379),re=re;let rt=(e,t)=>{if("string"!=typeof e||!e)throw new eF(`${t} missing or invalid`)};async function rr(e,t){let r,n;if(tI(e))r=e;else if(e2(e))r=await t$(e);else throw TypeError(ez(e,"CryptoKey","KeyObject","JSON Web Key"));if("sha256"!==(t??="sha256")&&"sha384"!==t&&"sha512"!==t)throw TypeError('digestAlgorithm must one of "sha256", "sha384", or "sha512"');switch(r.kty){case"AKP":rt(r.alg,'"alg" (Algorithm) Parameter'),rt(r.pub,'"pub" (Public key) Parameter'),n={alg:r.alg,kty:r.kty,pub:r.pub};break;case"EC":rt(r.crv,'"crv" (Curve) Parameter'),rt(r.x,'"x" (X Coordinate) Parameter'),rt(r.y,'"y" (Y Coordinate) Parameter'),n={crv:r.crv,kty:r.kty,x:r.x,y:r.y};break;case"OKP":rt(r.crv,'"crv" (Subtype of Key Pair) Parameter'),rt(r.x,'"x" (Public Key) Parameter'),n={crv:r.crv,kty:r.kty,x:r.x};break;case"RSA":rt(r.e,'"e" (Exponent) Parameter'),rt(r.n,'"n" (Modulus) Parameter'),n={e:r.e,kty:r.kty,n:r.n};break;case"oct":rt(r.k,'"k" (Key Value) Parameter'),n={k:r.k,kty:r.kty};break;default:throw new eV('"kty" (Key Type) Parameter missing or unsupported')}let i=e_(JSON.stringify(n));return ex(await eU(t,i))}function rn(e){let t;if("string"==typeof e){let r=e.split(".");(3===r.length||5===r.length)&&([t]=r)}else if("object"==typeof e&&e)if("protected"in e)t=e.protected;else throw TypeError("Token does not contain a Protected Header");try{if("string"!=typeof t||!t)throw Error();let e=JSON.parse(eb.decode(eS(t)));if(!tT(e))throw Error();return e}catch{throw TypeError("Invalid Token or Protected Header formatting")}}function ri(e,t){if(void 0!==t&&(!Array.isArray(t)||t.some(e=>"string"!=typeof e)))throw TypeError(`"${e}" option must be an array of strings`);if(t)return new Set(t)}async function ra(e,t,r){let n,i,a,o,s,c;if(!tT(e))throw new eK("Flattened JWE must be an object");if(void 0===e.protected&&void 0===e.header&&void 0===e.unprotected)throw new eK("JOSE Header missing");if(void 0!==e.iv&&"string"!=typeof e.iv)throw new eK("JWE Initialization Vector incorrect type");if("string"!=typeof e.ciphertext)throw new eK("JWE Ciphertext missing or incorrect type");if(void 0!==e.tag&&"string"!=typeof e.tag)throw new eK("JWE Authentication Tag incorrect type");if(void 0!==e.protected&&"string"!=typeof e.protected)throw new eK("JWE Protected Header incorrect type");if(void 0!==e.encrypted_key&&"string"!=typeof e.encrypted_key)throw new eK("JWE Encrypted Key incorrect type");if(void 0!==e.aad&&"string"!=typeof e.aad)throw new eK("JWE AAD incorrect type");if(void 0!==e.header&&!tT(e.header))throw new eK("JWE Shared Unprotected Header incorrect type");if(void 0!==e.unprotected&&!tT(e.unprotected))throw new eK("JWE Per-Recipient Unprotected Header incorrect type");if(e.protected)try{let t=eS(e.protected);n=JSON.parse(eb.decode(t))}catch{throw new eK("JWE Protected Header is invalid")}if(!tR(n,e.header,e.unprotected))throw new eK("JWE Protected, JWE Unprotected Header, and JWE Per-Recipient Unprotected Header Parameter names must be disjoint");let l={...n,...e.header,...e.unprotected};if(tK(eK,new Map,r?.crit,n,l),void 0!==l.zip&&"DEF"!==l.zip)throw new eV('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');if(void 0!==l.zip&&!n?.zip)throw new eK('JWE "zip" (Compression Algorithm) Header Parameter MUST be in a protected header.');let{alg:d,enc:u}=l;if("string"!=typeof d||!d)throw new eK("missing JWE Algorithm (alg) in JWE Header");if("string"!=typeof u||!u)throw new eK("missing JWE Encryption Algorithm (enc) in JWE Header");let p=r&&ri("keyManagementAlgorithms",r.keyManagementAlgorithms),f=r&&ri("contentEncryptionAlgorithms",r.contentEncryptionAlgorithms);if(p&&!p.has(d)||!p&&d.startsWith("PBES2"))throw new eB('"alg" (Algorithm) Header Parameter value not allowed');if(f&&!f.has(u))throw new eB('"enc" (Encryption Algorithm) Header Parameter value not allowed');void 0!==e.encrypted_key&&(i=eI(e.encrypted_key,"encrypted_key",eK));let h=!1;"function"==typeof t&&(t=await t(n,e),h=!0),tF("dir"===d?u:d,t,"decrypt");let m=await tD(t,d);try{a=await tV(d,m,i,l,r)}catch(e){if(e instanceof TypeError||e instanceof eK||e instanceof eV)throw e;a=e5(u)}void 0!==e.iv&&(o=eI(e.iv,"iv",eK)),void 0!==e.tag&&(s=eI(e.tag,"tag",eK));let y=void 0!==e.protected?e_(e.protected):new Uint8Array;c=void 0!==e.aad?eA(y,e_("."),e_(e.aad)):y;let g=eI(e.ciphertext,"ciphertext",eK),w=await ts(u,a,g,o,s,c),b={plaintext:w};if("DEF"===l.zip){let e=r?.maxDecompressedLength??25e4;if(0===e)throw new eV('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');if(e!==1/0&&(!Number.isSafeInteger(e)||e<1))throw TypeError("maxDecompressedLength must be 0, a positive safe integer, or Infinity");b.plaintext=await tG(w,e).catch(e=>{if(e instanceof eK)throw e;throw new eK("Failed to decompress plaintext",{cause:e})})}return(void 0!==e.protected&&(b.protectedHeader=n),void 0!==e.aad&&(b.additionalAuthenticatedData=eI(e.aad,"aad",eK)),void 0!==e.unprotected&&(b.sharedUnprotectedHeader=e.unprotected),void 0!==e.header&&(b.unprotectedHeader=e.header),h)?{...b,key:m}:b}async function ro(e,t,r){if(e instanceof Uint8Array&&(e=eb.decode(e)),"string"!=typeof e)throw new eK("Compact JWE must be a string or Uint8Array");let{0:n,1:i,2:a,3:o,4:s,length:c}=e.split(".");if(5!==c)throw new eK("Invalid Compact JWE");let l=await ra({ciphertext:o,iv:a||void 0,protected:n,tag:s||void 0,encrypted_key:i||void 0},t,r),d={plaintext:l.plaintext,protectedHeader:l.protectedHeader};return"function"==typeof t?{...d,key:l.key}:d}async function rs(e,t,r){let n=await ro(e,t,r),i=t5(n.protectedHeader,n.plaintext,r),{protectedHeader:a}=n;if(void 0!==a.iss&&a.iss!==i.iss)throw new ej('replicated "iss" claim header parameter mismatch',i,"iss","mismatch");if(void 0!==a.sub&&a.sub!==i.sub)throw new ej('replicated "sub" claim header parameter mismatch',i,"sub","mismatch");if(void 0!==a.aud&&JSON.stringify(a.aud)!==JSON.stringify(i.aud))throw new ej('replicated "aud" claim header parameter mismatch',i,"aud","mismatch");let o={payload:i,protectedHeader:a};return"function"==typeof t?{...o,key:n.key}:o}async function rc(e,t,r){if(!tT(e))throw new eW("Flattened JWS must be an object");if(void 0===e.protected&&void 0===e.header)throw new eW('Flattened JWS must have either of the "protected" or "header" members');if(void 0!==e.protected&&"string"!=typeof e.protected)throw new eW("JWS Protected Header incorrect type");if(void 0===e.payload)throw new eW("JWS Payload missing");if("string"!=typeof e.signature)throw new eW("JWS Signature missing or incorrect type");if(void 0!==e.header&&!tT(e.header))throw new eW("JWS Unprotected Header incorrect type");let n={};if(e.protected)try{let t=eS(e.protected);n=JSON.parse(eb.decode(t))}catch{throw new eW("JWS Protected Header is invalid")}if(!tR(n,e.header))throw new eW("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let i={...n,...e.header},a=tK(eW,new Map([["b64",!0]]),r?.crit,n,i),o=!0;if(a.has("b64")&&"boolean"!=typeof(o=n.b64))throw new eW('The "b64" (base64url-encode payload) Header Parameter must be a boolean');let{alg:s}=i;if("string"!=typeof s||!s)throw new eW('JWS "alg" (Algorithm) Header Parameter missing or invalid');let c=r&&ri("algorithms",r.algorithms);if(c&&!c.has(s))throw new eB('"alg" (Algorithm) Header Parameter value not allowed');if(o){if("string"!=typeof e.payload)throw new eW("JWS Payload must be a string")}else if("string"!=typeof e.payload&&!(e.payload instanceof Uint8Array))throw new eW("JWS Payload must be a string or an Uint8Array instance");let l=!1;"function"==typeof t&&(t=await t(n,e),l=!0),tF(s,t,"verify");let d=eA(void 0!==e.protected?e_(e.protected):new Uint8Array,e_("."),"string"==typeof e.payload?o?e_(e.payload):ew.encode(e.payload):e.payload),u=eI(e.signature,"signature",eW),p=await tD(t,s);if(!await tk(s,p,u,d))throw new eY;let f={payload:o?eI(e.payload,"payload",eW):"string"==typeof e.payload?ew.encode(e.payload):e.payload};return(void 0!==e.protected&&(f.protectedHeader=n),void 0!==e.header&&(f.unprotectedHeader=e.header),l)?{...f,key:p}:f}async function rl(e,t,r){if(e instanceof Uint8Array&&(e=eb.decode(e)),"string"!=typeof e)throw new eW("Compact JWS must be a string or Uint8Array");let{0:n,1:i,2:a,length:o}=e.split(".");if(3!==o)throw new eW("Invalid Compact JWS");let s=await rc({payload:i,protected:n,signature:a},t,r),c={payload:s.payload,protectedHeader:s.protectedHeader};return"function"==typeof t?{...c,key:s.key}:c}async function rd(e,t,r){let n=await rl(e,t,r);if(n.protectedHeader.crit?.includes("b64")&&!1===n.protectedHeader.b64)throw new eq("JWTs MUST NOT use unencoded payload");let i={payload:t5(n.protectedHeader,n.payload,r),protectedHeader:n.protectedHeader};return"function"==typeof t?{...i,key:n.key}:i}async function ru(e,t,r=3600){return await new t7(e).setProtectedHeader({alg:"HS256"}).setIssuedAt().setExpirationTime(Math.floor(Date.now()/1e3)+r).sign(new TextEncoder().encode(t))}async function rp(e,t){try{return(await rd(e,new TextEncoder().encode(t))).payload}catch{return null}}let rf=new Uint8Array([66,101,116,116,101,114,65,117,116,104,46,106,115,32,71,101,110,101,114,97,116,101,100,32,69,110,99,114,121,112,116,105,111,110,32,75,101,121]),rh="A256CBC-HS512";function rm(e,t){var r,n,i;return r=new TextEncoder().encode(e),n=new TextEncoder().encode(t),function(e,t,r,n=32){W(e),M(n,"length"),K(t,void 0,"prk");let i=e.outputLen;if(t.length<i)throw Error('"prk" must be at least HashLen octets');if(n>255*i)throw Error("Length must be <= 255*HashLen");let a=Math.ceil(n/i);void 0===r?r=ee:K(r,void 0,"info");let o=new Uint8Array(a*i),s=Y.create(e,t),c=s._cloneInto(),l=new Uint8Array(s.outputLen);for(let e=0;e<a;e++)X[0]=e+1,c.update(0===e?ee:l).update(r).update(X).digestInto(l),o.set(l,i*e),s._cloneInto(c);return s.destroy(),c.destroy(),J(l,X),o.slice(0,n)}(eg,(i=n,W(eg),void 0===i&&(i=new Uint8Array(eg.outputLen)),Y(eg,i,r)),rf,64)}function ry(e){if("string"==typeof e)return[{version:0,value:e}];let t=[];for(let[r,n]of e.keys)t.push({version:r,value:n});return e.legacySecret&&!t.some(t=>t.value===e.legacySecret)&&t.push({version:-1,value:e.legacySecret}),t}async function rg(e,t,r,n=3600){let i=rm(function(e){if("string"==typeof e)return e;let t=e.keys.get(e.currentVersion);if(!t)throw Error(`Secret version ${e.currentVersion} not found in keys`);return t}(t),r),a=await rr({kty:"oct",k:re.encode(i)},"sha256");return await new t4(e).setProtectedHeader({alg:"dir",enc:rh,kid:a}).setIssuedAt().setExpirationTime((Date.now()/1e3|0)+n).setJti(crypto.randomUUID()).encrypt(i)}let rw={clockTolerance:15,keyManagementAlgorithms:["dir"],contentEncryptionAlgorithms:[rh,"A256GCM"]};async function rb(e,t,r){if(!e)return null;let n=!1;try{n=void 0!==rn(e).kid}catch{return null}try{let n=ry(t),{payload:i}=await rs(e,async e=>{let t=e.kid;if(void 0!==t){for(let e of n){let n=rm(e.value,r);if(t===await rr({kty:"oct",k:re.encode(n)},"sha256"))return n}throw Error("no matching decryption secret")}return n.length,rm(n[0].value,r)},rw);return i}catch{if(n)return null;let i=ry(t);if(i.length<=1)return null;for(let t=1;t<i.length;t++)try{let n=i[t],{payload:a}=await rs(e,rm(n.value,r),rw);return a}catch{continue}return null}}var rA=e.i(163738);function rE(e,t){if(!e||!t)return e;let r=Object.entries(t).filter(([,{returned:e}])=>!1===e).map(([e])=>e);return Object.entries(structuredClone(e)).filter(([e])=>!r.includes(e)).reduce((e,[t,r])=>({...e,[t]:r}),{})}let rv=new WeakMap;function rk(e,t,r){let n=`${t}:${r}`;rv.has(e)||rv.set(e,new Map);let i=rv.get(e);if(i.has(n))return i.get(n);let a="output"===r?(0,w.getAuthTables)(e)[t]?.fields??{}:{},o="user"===t||"session"===t||"account"===t?e[t]?.additionalFields:void 0,s={...a,...o??{}};for(let r of e.plugins||[])r.schema&&r.schema[t]&&(s={...s,...r.schema[t].fields});return i.set(n,s),s}function r_(e,t){return rE(t,rk(e,"user","output"))}function rS(e,t){let r=rk(e,"user","output"),n={};for(let e in r){let i=r[e];!1!==i.returned&&(e in t&&void 0!==t[e]?n[e]=t[e]:void 0!==i.defaultValue?n[e]="function"==typeof i.defaultValue?i.defaultValue():i.defaultValue:i.required||(n[e]=null))}return"id"in t&&(n.id=t.id),n}function rx(e,t){return rE(t,rk(e,"session","output"))}function rT(e,t){let r=t.action||"create",n=t.fields,i=Object.create(null);for(let t in n){if(t in e){if(!1===n[t].input){if(void 0!==n[t].defaultValue&&"update"!==r){i[t]=n[t].defaultValue;continue}if(e[t])throw E.APIError.from("BAD_REQUEST",{...rA.BASE_ERROR_CODES.FIELD_NOT_ALLOWED,message:`${t} is not allowed to be set`});continue}if(n[t].validator?.input&&void 0!==e[t]){let r=n[t].validator.input["~standard"].validate(e[t]);if(r instanceof Promise)throw E.APIError.from("INTERNAL_SERVER_ERROR",rA.BASE_ERROR_CODES.ASYNC_VALIDATION_NOT_SUPPORTED);if("issues"in r&&r.issues)throw E.APIError.from("BAD_REQUEST",{...rA.BASE_ERROR_CODES.VALIDATION_ERROR,message:r.issues[0]?.message||"Validation Error"});i[t]=r.value;continue}if(n[t].transform?.input&&void 0!==e[t]){i[t]=n[t].transform?.input(e[t]);continue}i[t]=e[t];continue}if(void 0!==n[t].defaultValue&&"create"===r){if("function"==typeof n[t].defaultValue){i[t]=n[t].defaultValue();continue}i[t]=n[t].defaultValue;continue}if(n[t].required&&"create"===r)throw E.APIError.from("BAD_REQUEST",{...rA.BASE_ERROR_CODES.MISSING_FIELD,message:`${t} is required`})}return i}function rR(e,t={},r){return rT(t,{fields:rk(e,"user","input"),action:r})}let rI=(e,t="ms")=>new Date(Date.now()+("sec"===t?1e3*e:e)),rU=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|months?|mo|years?|yrs?|y)(?: (ago|from now))?$/i;function rO(e){if(-1===e.indexOf("%"))return e;try{return decodeURIComponent(e)}catch{return e}}function rP(e){if(!e)return[];let t=[],r=0,n=0;for(;n<e.length;){if(","===e[n]){let i=n+1;for(;i<e.length&&" "===e[i];)i++;for(;i<e.length&&"="!==e[i]&&";"!==e[i]&&","!==e[i];)i++;if(i<e.length&&"="===e[i]){let i=e.slice(r,n).trim();for(i&&t.push(i),r=n+1;r<e.length&&" "===e[r];)r++;n=r;continue}}n++}let i=e.slice(r).trim();return i&&t.push(i),t}let rC=/^[\w!#$%&'*.^`|~+-]+$/,rD=/^[ !#-:<-[\]-~]*$/;function rL(e){return!(e.length<2)&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}function rz(e){let t=0,r=e.length;for(;t<r;){let r=e.charCodeAt(t);if(32!==r&&9!==r)break;t++}for(;r>t;){let t=e.charCodeAt(r-1);if(32!==t&&9!==t)break;r--}return 0===t&&r===e.length?e:e.slice(t,r)}function r$(e){let t=new Map;if(e.length<2)return t;for(let r of e.split(";")){let e=r.indexOf("=");if(-1===e)continue;let n=rz(r.slice(0,e)),i=rL(rz(r.slice(e+1)));rC.test(n)&&rD.test(i)&&t.set(n,rO(i))}return t}var rN=e.i(858544);function rj(e,t,r){function n(r,n){if(r._zod||Object.defineProperty(r,"_zod",{value:{def:n,constr:o,traits:new Set},enumerable:!1}),r._zod.traits.has(e))return;r._zod.traits.add(e),t(r,n);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in r||(r[t]=i[t].bind(r))}}let i=r?.Parent??Object;class a extends i{}function o(e){var t;let i=r?.Parent?new a:this;for(let r of(n(i,e),(t=i._zod).deferred??(t.deferred=[]),i._zod.deferred))r();return i}return Object.defineProperty(a,"name",{value:e}),Object.defineProperty(o,"init",{value:n}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>!!r?.Parent&&t instanceof r.Parent||t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}Symbol("zod_brand");class rH extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class rB extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(y=globalThis).__zod_globalConfig??(y.__zod_globalConfig={});let rV=globalThis.__zod_globalConfig;function rM(e){return e&&Object.assign(rV,e),rV}function rK(e){let t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,r])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function rW(e,t){return"bigint"==typeof t?t.toString():t}function rq(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function rF(e){return null==e}function rJ(e){let t=+!!e.startsWith("^"),r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function rZ(e,t){let r=e/t,n=Math.round(r),i=Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<i?0:r-n}let rG=Symbol("evaluating");function rQ(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==rG)return void 0===n&&(n=rG,n=r()),n},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function rY(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function rX(...e){let t={};for(let r of e)Object.assign(t,Object.getOwnPropertyDescriptors(r));return Object.defineProperties({},t)}function r0(e){return JSON.stringify(e)}function r1(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}let r2="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function r6(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}let r5=rq(()=>{if(rV.jitless||"u">typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return Function(""),!0}catch(e){return!1}});function r8(e){if(!1===r6(e))return!1;let t=e.constructor;if(void 0===t||"function"!=typeof t)return!0;let r=t.prototype;return!1!==r6(r)&&!1!==Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")}let r4=new Set(["string","number","symbol"]),r3=new Set(["string","number","bigint","boolean","symbol","undefined"]);function r9(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function r7(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function ne(e){if(!e)return{};if("string"==typeof e)return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");e.error=e.message}return(delete e.message,"string"==typeof e.error)?{...e,error:()=>e.error}:e}function nt(e){return"bigint"==typeof e?e.toString()+"n":"string"==typeof e?`"${e}"`:`${e}`}function nr(e){return Object.keys(e).filter(t=>"optional"===e[t]._zod.optin&&"optional"===e[t]._zod.optout)}let nn={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-0x80000000,0x7fffffff],uint32:[0,0xffffffff],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},ni={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function na(e,t=0){if(!0===e.aborted)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function no(e,t=0){if(!0===e.aborted)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function ns(e,t){return t.map(t=>(t.path??(t.path=[]),t.path.unshift(e),t))}function nc(e){return"string"==typeof e?e:e?.message}function nl(e,t,r){let n=e.message?e.message:nc(e.inst?._zod.def?.error?.(e))??nc(t?.error?.(e))??nc(r.customError?.(e))??nc(r.localeError?.(e))??"Invalid input",{inst:i,continue:a,input:o,...s}=e;return s.path??(s.path=[]),s.message=n,t?.reportInput&&(s.input=o),s}function nd(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function nu(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function np(...e){let[t,r,n]=e;return"string"==typeof t?{message:t,code:"custom",input:r,inst:n}:{...t}}function nf(e){let t=atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return r}function nh(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}e.s(["BIGINT_FORMAT_RANGES",0,ni,"Class",0,class{constructor(...e){}},"NUMBER_FORMAT_RANGES",0,nn,"aborted",0,na,"allowsEval",0,r5,"assert",0,function(e){},"assertEqual",0,function(e){return e},"assertIs",0,function(e){},"assertNever",0,function(e){throw Error("Unexpected value in exhaustive check")},"assertNotEqual",0,function(e){return e},"assignProp",0,rY,"base64ToUint8Array",0,nf,"base64urlToUint8Array",0,function(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return nf(t+r)},"cached",0,rq,"captureStackTrace",0,r2,"cleanEnum",0,function(e){return Object.entries(e).filter(([e,t])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])},"cleanRegex",0,rJ,"clone",0,r7,"cloneDef",0,function(e){return rX(e._zod.def)},"createTransparentProxy",0,function(e){let t;return new Proxy({},{get:(r,n,i)=>(t??(t=e()),Reflect.get(t,n,i)),set:(r,n,i,a)=>(t??(t=e()),Reflect.set(t,n,i,a)),has:(r,n)=>(t??(t=e()),Reflect.has(t,n)),deleteProperty:(r,n)=>(t??(t=e()),Reflect.deleteProperty(t,n)),ownKeys:r=>(t??(t=e()),Reflect.ownKeys(t)),getOwnPropertyDescriptor:(r,n)=>(t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)),defineProperty:(r,n,i)=>(t??(t=e()),Reflect.defineProperty(t,n,i))})},"defineLazy",0,rQ,"esc",0,r0,"escapeRegex",0,r9,"explicitlyAborted",0,no,"extend",0,function(e,t){if(!r8(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let r=e._zod.def.shape;for(let e in t)if(void 0!==Object.getOwnPropertyDescriptor(r,e))throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let n=rX(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return rY(this,"shape",r),r}});return r7(e,n)},"finalizeIssue",0,nl,"floatSafeRemainder",0,rZ,"getElementAtPath",0,function(e,t){return t?t.reduce((e,t)=>e?.[t],e):e},"getEnumValues",0,rK,"getLengthableOrigin",0,nu,"getParsedType",0,e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray(e))return"array";if(null===e)return"null";if(e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch)return"promise";if("u">typeof Map&&e instanceof Map)return"map";if("u">typeof Set&&e instanceof Set)return"set";if("u">typeof Date&&e instanceof Date)return"date";if("u">typeof File&&e instanceof File)return"file";return"object";default:throw Error(`Unknown data type: ${t}`)}},"getSizableOrigin",0,nd,"hexToUint8Array",0,function(e){let t=e.replace(/^0x/,"");if(t.length%2!=0)throw Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let e=0;e<t.length;e+=2)r[e/2]=Number.parseInt(t.slice(e,e+2),16);return r},"isObject",0,r6,"isPlainObject",0,r8,"issue",0,np,"joinValues",0,function(e,t="|"){return e.map(e=>nt(e)).join(t)},"jsonStringifyReplacer",0,rW,"merge",0,function(e,t){if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=rX(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return rY(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return r7(e,r)},"mergeDefs",0,rX,"normalizeParams",0,ne,"nullish",0,rF,"numKeys",0,function(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t},"objectClone",0,function(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))},"omit",0,function(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let i=rX(e._zod.def,{get shape(){let n={...e._zod.def.shape};for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete n[e]}return rY(this,"shape",n),n},checks:[]});return r7(e,i)},"optionalKeys",0,nr,"parsedType",0,function(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":if(null===e)return"null";if(Array.isArray(e))return"array";if(e&&Object.getPrototypeOf(e)!==Object.prototype&&"constructor"in e&&e.constructor)return e.constructor.name}return t},"partial",0,function(e,t,r){let n=t._zod.def.checks;if(n&&n.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let i=rX(t._zod.def,{get shape(){let n=t._zod.def.shape,i={...n};if(r)for(let t in r){if(!(t in n))throw Error(`Unrecognized key: "${t}"`);r[t]&&(i[t]=e?new e({type:"optional",innerType:n[t]}):n[t])}else for(let t in n)i[t]=e?new e({type:"optional",innerType:n[t]}):n[t];return rY(this,"shape",i),i},checks:[]});return r7(t,i)},"pick",0,function(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let i=rX(e._zod.def,{get shape(){let e={};for(let n in t){if(!(n in r.shape))throw Error(`Unrecognized key: "${n}"`);t[n]&&(e[n]=r.shape[n])}return rY(this,"shape",e),e},checks:[]});return r7(e,i)},"prefixIssues",0,ns,"primitiveTypes",0,r3,"promiseAllObject",0,function(e){let t=Object.keys(e);return Promise.all(t.map(t=>e[t])).then(e=>{let r={};for(let n=0;n<t.length;n++)r[t[n]]=e[n];return r})},"propertyKeyTypes",0,r4,"randomString",0,function(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r},"required",0,function(e,t,r){let n=rX(t._zod.def,{get shape(){let n=t._zod.def.shape,i={...n};if(r)for(let t in r){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);r[t]&&(i[t]=new e({type:"nonoptional",innerType:n[t]}))}else for(let t in n)i[t]=new e({type:"nonoptional",innerType:n[t]});return rY(this,"shape",i),i}});return r7(t,n)},"safeExtend",0,function(e,t){if(!r8(t))throw Error("Invalid input to safeExtend: expected a plain object");let r=rX(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return rY(this,"shape",r),r}});return r7(e,r)},"shallowClone",0,function(e){return r8(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e},"slugify",0,r1,"stringifyPrimitive",0,nt,"uint8ArrayToBase64",0,nh,"uint8ArrayToBase64url",0,function(e){return nh(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},"uint8ArrayToHex",0,function(e){return Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")},"unwrapMessage",0,nc],202721);let nm=/^[cC][0-9a-z]{6,}$/,ny=/^[0-9a-z]+$/,ng=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,nw=/^[0-9a-vA-V]{20}$/,nb=/^[A-Za-z0-9]{27}$/,nA=/^[a-zA-Z0-9_-]{21}$/,nE=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,nv=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,nk=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,n_=nk(4),nS=nk(6),nx=nk(7),nT=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,nR=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u;function nI(){return RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")}let nU=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,nO=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,nP=e=>{let t=r9(e??":");return RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},nC=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,nD=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,nL=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,nz=/^[A-Za-z0-9_-]*$/,n$=/^https?$/,nN=/^\+[1-9]\d{6,14}$/,nj="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",nH=RegExp(`^${nj}$`);function nB(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function nV(e){return RegExp(`^${nB(e)}$`)}function nM(e){let t=nB({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${t}(?:${r.join("|")})`;return RegExp(`^${nj}T(?:${n})$`)}let nK=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return RegExp(`^${t}$`)},nW=/^-?\d+n?$/,nq=/^-?\d+$/,nF=/^-?\d+(?:\.\d+)?$/,nJ=/^(?:true|false)$/i,nZ=/^null$/i,nG=/^undefined$/i,nQ=/^[^A-Z]*$/,nY=/^[^a-z]*$/;function nX(e,t){return RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function n0(e){return RegExp(`^[A-Za-z0-9_-]{${e}}$`)}let n1=nX(22,"=="),n2=n0(22),n6=nX(27,"="),n5=n0(27),n8=nX(43,"="),n4=n0(43),n3=nX(64,""),n9=n0(64),n7=nX(86,"=="),ie=n0(86);e.s(["base64",0,nL,"base64url",0,nz,"bigint",0,nW,"boolean",0,nJ,"browserEmail",0,/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,"cidrv4",0,nC,"cidrv6",0,nD,"cuid",0,nm,"cuid2",0,ny,"date",0,nH,"datetime",0,nM,"domain",0,/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,"duration",0,nE,"e164",0,nN,"email",0,nT,"emoji",0,nI,"extendedDuration",0,/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,"guid",0,nv,"hex",0,/^[0-9a-fA-F]*$/,"hostname",0,/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,"html5Email",0,/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,"httpProtocol",0,n$,"idnEmail",0,nR,"integer",0,nq,"ipv4",0,nU,"ipv6",0,nO,"ksuid",0,nb,"lowercase",0,nQ,"mac",0,nP,"md5_base64",0,n1,"md5_base64url",0,n2,"md5_hex",0,/^[0-9a-fA-F]{32}$/,"nanoid",0,nA,"null",0,nZ,"number",0,nF,"rfc5322Email",0,/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,"sha1_base64",0,n6,"sha1_base64url",0,n5,"sha1_hex",0,/^[0-9a-fA-F]{40}$/,"sha256_base64",0,n8,"sha256_base64url",0,n4,"sha256_hex",0,/^[0-9a-fA-F]{64}$/,"sha384_base64",0,n3,"sha384_base64url",0,n9,"sha384_hex",0,/^[0-9a-fA-F]{96}$/,"sha512_base64",0,n7,"sha512_base64url",0,ie,"sha512_hex",0,/^[0-9a-fA-F]{128}$/,"string",0,nK,"time",0,nV,"ulid",0,ng,"undefined",0,nG,"unicodeEmail",0,nR,"uppercase",0,nY,"uuid",0,nk,"uuid4",0,n_,"uuid6",0,nS,"uuid7",0,nx,"xid",0,nw],110107);let it=rj("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),ir={number:"number",bigint:"bigint",object:"date"},ii=rj("$ZodCheckLessThan",(e,t)=>{it.init(e,t);let r=ir[typeof t.value];e._zod.onattach.push(e=>{let r=e._zod.bag,n=(t.inclusive?r.maximum:r.exclusiveMaximum)??1/0;t.value<n&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:"object"==typeof t.value?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ia=rj("$ZodCheckGreaterThan",(e,t)=>{it.init(e,t);let r=ir[typeof t.value];e._zod.onattach.push(e=>{let r=e._zod.bag,n=(t.inclusive?r.minimum:r.exclusiveMinimum)??-1/0;t.value>n&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:"object"==typeof t.value?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),io=rj("$ZodCheckMultipleOf",(e,t)=>{it.init(e,t),e._zod.onattach.push(e=>{var r;(r=e._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof r.value?r.value%t.value===BigInt(0):0===rZ(r.value,t.value))||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),is=rj("$ZodCheckNumberFormat",(e,t)=>{it.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[i,a]=nn[t.format];e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,n.minimum=i,n.maximum=a,r&&(n.pattern=nq)}),e._zod.check=o=>{let s=o.value;if(r){if(!Number.isInteger(s))return void o.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});if(!Number.isSafeInteger(s))return void(s>0?o.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}))}s<i&&o.issues.push({origin:"number",input:s,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:"number",input:s,code:"too_big",maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),ic=rj("$ZodCheckBigIntFormat",(e,t)=>{it.init(e,t);let[r,n]=ni[t.format];e._zod.onattach.push(e=>{let i=e._zod.bag;i.format=t.format,i.minimum=r,i.maximum=n}),e._zod.check=i=>{let a=i.value;a<r&&i.issues.push({origin:"bigint",input:a,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),a>n&&i.issues.push({origin:"bigint",input:a,code:"too_big",maximum:n,inclusive:!0,inst:e,continue:!t.abort})}}),il=rj("$ZodCheckMaxSize",(e,t)=>{var r;it.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return!rF(t)&&void 0!==t.size}),e._zod.onattach.push(e=>{let r=e._zod.bag.maximum??1/0;t.maximum<r&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{let n=r.value;n.size<=t.maximum||r.issues.push({origin:nd(n),code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),id=rj("$ZodCheckMinSize",(e,t)=>{var r;it.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return!rF(t)&&void 0!==t.size}),e._zod.onattach.push(e=>{let r=e._zod.bag.minimum??-1/0;t.minimum>r&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{let n=r.value;n.size>=t.minimum||r.issues.push({origin:nd(n),code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),iu=rj("$ZodCheckSizeEquals",(e,t)=>{var r;it.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return!rF(t)&&void 0!==t.size}),e._zod.onattach.push(e=>{let r=e._zod.bag;r.minimum=t.size,r.maximum=t.size,r.size=t.size}),e._zod.check=r=>{let n=r.value,i=n.size;if(i===t.size)return;let a=i>t.size;r.issues.push({origin:nd(n),...a?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),ip=rj("$ZodCheckMaxLength",(e,t)=>{var r;it.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return!rF(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{let r=e._zod.bag.maximum??1/0;t.maximum<r&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{let n=r.value;if(n.length<=t.maximum)return;let i=nu(n);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),ih=rj("$ZodCheckMinLength",(e,t)=>{var r;it.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return!rF(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{let r=e._zod.bag.minimum??-1/0;t.minimum>r&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{let n=r.value;if(n.length>=t.minimum)return;let i=nu(n);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),im=rj("$ZodCheckLengthEquals",(e,t)=>{var r;it.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return!rF(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{let r=e._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=r=>{let n=r.value,i=n.length;if(i===t.length)return;let a=nu(n),o=i>t.length;r.issues.push({origin:a,...o?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),iy=rj("$ZodCheckStringFormat",(e,t)=>{var r,n;it.init(e,t),e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,t.pattern&&(r.patterns??(r.patterns=new Set),r.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),ig=rj("$ZodCheckRegex",(e,t)=>{iy.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),iw=rj("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=nQ),iy.init(e,t)}),ib=rj("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=nY),iy.init(e,t)}),iA=rj("$ZodCheckIncludes",(e,t)=>{it.init(e,t);let r=r9(t.includes),n=new RegExp("number"==typeof t.position?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),iE=rj("$ZodCheckStartsWith",(e,t)=>{it.init(e,t);let r=RegExp(`^${r9(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),iv=rj("$ZodCheckEndsWith",(e,t)=>{it.init(e,t);let r=RegExp(`.*${r9(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});(e,t)=>{it.init(e,t);let r=new Set(t.mime);e._zod.onattach.push(e=>{e._zod.bag.mime=t.mime}),e._zod.check=n=>{r.has(n.value.type)||n.issues.push({code:"invalid_value",values:t.mime,input:n.value.type,inst:e,continue:!t.abort})}};let ik=rj("$ZodCheckOverwrite",(e,t)=>{it.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class i_{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let t=e.split("\n").filter(e=>e),r=Math.min(...t.map(e=>e.length-e.trimStart().length));for(let e of t.map(e=>e.slice(r)).map(e=>" ".repeat(2*this.indent)+e))this.content.push(e)}compile(){return Function(...this?.args,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}}let iS=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,rW,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},ix=rj("$ZodError",iS),iT=rj("$ZodError",iS,{Parent:Error}),iR=e=>(t,r,n,i)=>{let a=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},a);if(o instanceof Promise)throw new rH;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>nl(e,a,rM())));throw r2(t,i?.callee),t}return o.value},iI=iR(iT),iU=e=>async(t,r,n,i)=>{let a=n?{...n,async:!0}:{async:!0},o=t._zod.run({value:r,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>nl(e,a,rM())));throw r2(t,i?.callee),t}return o.value},iO=iU(iT),iP=e=>(t,r,n)=>{let i=n?{...n,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},i);if(a instanceof Promise)throw new rH;return a.issues.length?{success:!1,error:new(e??ix)(a.issues.map(e=>nl(e,i,rM())))}:{success:!0,data:a.value}},iC=iP(iT),iD=e=>async(t,r,n)=>{let i=n?{...n,async:!0}:{async:!0},a=t._zod.run({value:r,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>nl(e,i,rM())))}:{success:!0,data:a.value}},iL=iD(iT),iz={major:4,minor:4,patch:3},i$=rj("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=iz;let n=[...e._zod.def.checks??[]];for(let t of(e._zod.traits.has("$ZodCheck")&&n.unshift(e),n))for(let r of t._zod.onattach)r(e);if(0===n.length)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,r)=>{let n,i=na(e);for(let a of t){if(a._zod.def.when){if(no(e)||!a._zod.def.when(e))continue}else if(i)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&r?.async===!1)throw new rH;if(n||o instanceof Promise)n=(n??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(i||(i=na(e,t)))});else{if(e.issues.length===t)continue;i||(i=na(e,t))}}return n?n.then(()=>e):e},r=(r,i,a)=>{if(na(r))return r.aborted=!0,r;let o=t(i,n,a);if(o instanceof Promise){if(!1===a.async)throw new rH;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if("backward"===a.direction){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>r(e,i,a)):r(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(!1===a.async)throw new rH;return o.then(e=>t(e,n,a))}return t(o,n,a)}}rQ(e,"~standard",()=>({validate:t=>{try{let r=iC(e,t);return r.success?{value:r.data}:{issues:r.error?.issues}}catch(r){return iL(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),iN=rj("$ZodString",(e,t)=>{i$.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??nK(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch(e){}return"string"==typeof r.value||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),ij=rj("$ZodStringFormat",(e,t)=>{iy.init(e,t),iN.init(e,t)}),iH=rj("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=nv),ij.init(e,t)}),iB=rj("$ZodUUID",(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=nk(e))}else t.pattern??(t.pattern=nk());ij.init(e,t)}),iV=rj("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=nT),ij.init(e,t)}),iM=rj("$ZodURL",(e,t)=>{ij.init(e,t),e._zod.check=r=>{try{let n=r.value.trim();if(!t.normalize&&t.protocol?.source===n$.source&&!/^https?:\/\//i.test(n))return void r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});let i=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=i.href:r.value=n;return}catch(n){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),iK=rj("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=nI()),ij.init(e,t)}),iW=rj("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=nA),ij.init(e,t)}),iq=rj("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=nm),ij.init(e,t)}),iF=rj("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ny),ij.init(e,t)}),iJ=rj("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ng),ij.init(e,t)}),iZ=rj("$ZodXID",(e,t)=>{t.pattern??(t.pattern=nw),ij.init(e,t)}),iG=rj("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=nb),ij.init(e,t)}),iQ=rj("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=nM(t)),ij.init(e,t)}),iY=rj("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=nH),ij.init(e,t)}),iX=rj("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=nV(t)),ij.init(e,t)}),i0=rj("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=nE),ij.init(e,t)}),i1=rj("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=nU),ij.init(e,t),e._zod.bag.format="ipv4"}),i2=rj("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=nO),ij.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),i6=((e,t)=>{t.pattern??(t.pattern=nP(t.delimiter)),ij.init(e,t),e._zod.bag.format="mac"},rj("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=nC),ij.init(e,t)})),i5=rj("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=nD),ij.init(e,t),e._zod.check=r=>{let n=r.value.split("/");try{if(2!==n.length)throw Error();let[e,t]=n;if(!t)throw Error();let r=Number(t);if(`${r}`!==t||r<0||r>128)throw Error();new URL(`http://[${e}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function i8(e){if(""===e)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let i4=rj("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=nL),ij.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{i8(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),i3=rj("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=nz),ij.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{!function(e){if(!nz.test(e))return!1;let t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return i8(t.padEnd(4*Math.ceil(t.length/4),"="))}(r.value)&&r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),i9=rj("$ZodE164",(e,t)=>{t.pattern??(t.pattern=nN),ij.init(e,t)}),i7=rj("$ZodJWT",(e,t)=>{ij.init(e,t),e._zod.check=r=>{!function(e,t=null){try{let r=e.split(".");if(3!==r.length)return!1;let[n]=r;if(!n)return!1;let i=JSON.parse(atob(n));if("typ"in i&&i?.typ!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))return!1;return!0}catch{return!1}}(r.value,t.alg)&&r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),ae=((e,t)=>{ij.init(e,t),e._zod.check=r=>{t.fn(r.value)||r.issues.push({code:"invalid_format",format:t.format,input:r.value,inst:e,continue:!t.abort})}},rj("$ZodNumber",(e,t)=>{i$.init(e,t),e._zod.pattern=e._zod.bag.pattern??nF,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch(e){}let i=r.value;if("number"==typeof i&&!Number.isNaN(i)&&Number.isFinite(i))return r;let a="number"==typeof i?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...a?{received:a}:{}}),r}})),at=rj("$ZodNumberFormat",(e,t)=>{is.init(e,t),ae.init(e,t)}),ar=rj("$ZodBoolean",(e,t)=>{i$.init(e,t),e._zod.pattern=nJ,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch(e){}let i=r.value;return"boolean"==typeof i||r.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),r}}),an=rj("$ZodBigInt",(e,t)=>{i$.init(e,t),e._zod.pattern=nW,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch(e){}return"bigint"==typeof r.value||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}}),ai=((e,t)=>{ic.init(e,t),an.init(e,t)},rj("$ZodAny",(e,t)=>{i$.init(e,t),e._zod.parse=e=>e})),aa=rj("$ZodUnknown",(e,t)=>{i$.init(e,t),e._zod.parse=e=>e}),ao=rj("$ZodNever",(e,t)=>{i$.init(e,t),e._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)}),as=((e,t)=>{i$.init(e,t),e._zod.parse=(t,r)=>{let n=t.value;return void 0===n||t.issues.push({expected:"void",code:"invalid_type",input:n,inst:e}),t}},rj("$ZodDate",(e,t)=>{i$.init(e,t),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=new Date(r.value)}catch(e){}let i=r.value,a=i instanceof Date;return a&&!Number.isNaN(i.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:i,...a?{received:"Invalid Date"}:{},inst:e}),r}}));function ac(e,t,r){e.issues.length&&t.issues.push(...ns(r,e.issues)),t.value[r]=e.value}let al=rj("$ZodArray",(e,t)=>{i$.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},n);s instanceof Promise?a.push(s.then(t=>ac(t,r,e))):ac(s,r,e)}return a.length?Promise.all(a).then(()=>r):r}});function ad(e,t,r,n,i,a){let o=r in n;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...ns(r,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}void 0===e.value?o&&(t.value[r]=void 0):t.value[r]=e.value}function au(e){let t=Object.keys(e.shape);for(let r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${r}": expected a Zod schema`);let r=nr(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function ap(e,t,r,n,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,d="optional"===c.optin,u="optional"===c.optout;for(let i in t){if("__proto__"===i||s.has(i))continue;if("never"===l){o.push(i);continue}let a=c.run({value:t[i],issues:[]},n);a instanceof Promise?e.push(a.then(e=>ad(e,r,i,t,d,u))):ad(a,r,i,t,d,u)}return(o.length&&r.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:a}),e.length)?Promise.all(e).then(()=>r):r}let af=rj("$ZodObject",(e,t)=>{let r;i$.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape");if(!n?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let r={...e};return Object.defineProperty(t,"shape",{value:r}),r}})}let i=rq(()=>au(t));rQ(e._zod,"propValues",()=>{let e=t.shape,r={};for(let t in e){let n=e[t]._zod;if(n.values)for(let e of(r[t]??(r[t]=new Set),n.values))r[t].add(e)}return r});let a=t.catchall;e._zod.parse=(t,n)=>{r??(r=i.value);let o=t.value;if(!r6(o))return t.issues.push({expected:"object",code:"invalid_type",input:o,inst:e}),t;t.value={};let s=[],c=r.shape;for(let e of r.keys){let r=c[e],i="optional"===r._zod.optin,a="optional"===r._zod.optout,l=r._zod.run({value:o[e],issues:[]},n);l instanceof Promise?s.push(l.then(r=>ad(r,t,e,o,i,a))):ad(l,t,e,o,i,a)}return a?ap(s,o,t,n,i.value,e):s.length?Promise.all(s).then(()=>t):t}}),ah=rj("$ZodObjectJIT",(e,t)=>{let r,n;af.init(e,t);let i=e._zod.parse,a=rq(()=>au(t)),o=!rV.jitless,s=o&&r5.value,c=t.catchall;e._zod.parse=(l,d)=>{n??(n=a.value);let u=l.value;return r6(u)?o&&s&&d?.async===!1&&!0!==d.jitless?(r||(r=(e=>{let t=new i_(["shape","payload","ctx"]),r=a.value,n=e=>{let t=r0(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");let i=Object.create(null),o=0;for(let e of r.keys)i[e]=`key_${o++}`;for(let a of(t.write("const newResult = {};"),r.keys)){let r=i[a],o=r0(a),s=e[a],c=s?._zod?.optin==="optional",l=s?._zod?.optout==="optional";t.write(`const ${r} = ${n(a)};`),c&&l?t.write(`
1
+ module.exports=[254226,473845,798003,860780,e=>{"use strict";let t,r,n,i,a,o,s,c,l,d,u,p,f;var h,m,y,g,w=e.i(563811),b=e.i(560912);async function A(t,r){let n;if(t.database)n="function"==typeof t.database?t.database(t):await r(t);else{let r=Object.keys((0,w.getAuthTables)(t)).reduce((e,t)=>(e[t]=[],e),{}),{memoryAdapter:i}=await e.A(168315);n=i(r)(t)}return n.transaction||(b.logger.warn("Adapter does not correctly implement transaction function, patching it automatically. Please update your adapter implementation."),n.transaction=async e=>e(n)),n}var E=e.i(451894);async function v(t){return A(t,async t=>{let{createKyselyAdapter:r}=await e.A(317691),{kysely:n,databaseType:i,transaction:a}=await r(t);if(!n)throw new E.BetterAuthError("Failed to initialize database adapter");let{kyselyAdapter:o}=await e.A(317691);return o(n,{type:i||"sqlite",debugLogs:!!t.database&&"debugLogs"in t.database&&t.database.debugLogs,transaction:a})(t)})}var k=e.i(177730);function _(e){return"-"===e||"^"===e||"$"===e||"+"===e||"."===e||"("===e||")"===e||"|"===e||"["===e||"]"===e||"{"===e||"}"===e||"*"===e||"?"===e||"\\"===e?`\\${e}`:e}function S(e,t){if("string"!=typeof t)throw TypeError(`Sample must be a string, but ${typeof t} given`);return e.test(t)}function x(e,t){if("string"!=typeof e&&!Array.isArray(e))throw TypeError(`The first argument must be a single pattern string or an array of patterns, but ${typeof e} given`);if(("string"==typeof t||"boolean"==typeof t)&&(t={separator:t}),2==arguments.length&&!(void 0===t||"object"==typeof t&&null!==t&&!Array.isArray(t)))throw TypeError(`The second argument must be an options object or a string/boolean separator, but ${typeof t} given`);if("\\"===(t=t||{}).separator)throw Error("\\ is not a valid separator because it is used for escaping. Try setting the separator to `true` instead");let r=function e(t,r=!0){if(Array.isArray(t))return`(?:${t.map(t=>`^${e(t,r)}$`).join("|")})`;let n="",i="",a=".";!0===r?(n="/",i="[/\\\\]",a="[^/\\\\]"):r&&((i=function(e){let t="";for(let r=0;r<e.length;r++)t+=_(e[r]);return t}(n=r)).length>1?(i=`(?:${i})`,a=`((?!${i}).)`):a=`[^${i}]`);let o=r?`${i}+?`:"",s=r?`${i}*?`:"",c=r?t.split(n):[t],l="";for(let e=0;e<c.length;e++){let t=c[e],n=c[e+1],i="";if(t||!(e>0)){if(r&&(i=e===c.length-1?s:"**"!==n?o:""),r&&"**"===t){i&&(l+=0===e?"":i,l+=`(?:${a}*?${i})*?`);continue}for(let e=0;e<t.length;e++){let r=t[e];"\\"===r?e<t.length-1&&(l+=_(t[e+1]),e++):"?"===r?l+=a:"*"===r?l+=`${a}*?`:l+=_(r)}l+=i}}return l}(e,t.separator),n=RegExp(`^${r}$`,t.flags),i=S.bind(null,n);return i.options=t,i.pattern=e,i.regexp=n,i}var T=e.i(426232);function R(e){let t=e.length;for(;t>0&&47===e.charCodeAt(t-1);)t--;return t===e.length?e:e.slice(0,t)}function I(e,t="/api/auth"){try{let t=new URL(e);if("http:"!==t.protocol&&"https:"!==t.protocol)throw new E.BetterAuthError(`Invalid base URL: ${e}. URL must include 'http://' or 'https://'`)}catch(t){if(t instanceof E.BetterAuthError)throw t;throw new E.BetterAuthError(`Invalid base URL: ${e}. Please provide a valid base URL.`,{cause:t})}if(function(e){try{return"/"!==(R(new URL(e).pathname)||"/")}catch{throw new E.BetterAuthError(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}(e))return e;let r=R(e);return t&&"/"!==t?(t=t.startsWith("/")?t:`/${t}`,`${r}${t}`):r}function U(e,t){return!!e&&""!==e.trim()&&("proto"===t?"http"===e||"https"===e:"host"===t&&![/\.\./,/\0/,/[\s]/,/^[.]/,/[<>'"]/,/javascript:/i,/file:/i,/data:/i].some(t=>t.test(e))&&(/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*(:[0-9]{1,5})?$/.test(e)||/^(\d{1,3}\.){3}\d{1,3}(:[0-9]{1,5})?$/.test(e)||/^\[[0-9a-fA-F:]+\](:[0-9]{1,5})?$/.test(e)||/^localhost(:[0-9]{1,5})?$/i.test(e)))}function O(e,t,r,n,i){if(e)return I(e,t);if(!1!==n){let e=T.env.BETTER_AUTH_URL||T.env.NEXT_PUBLIC_BETTER_AUTH_URL||T.env.PUBLIC_BETTER_AUTH_URL||T.env.NUXT_PUBLIC_BETTER_AUTH_URL||T.env.NUXT_PUBLIC_AUTH_URL||("/"!==T.env.BASE_URL?T.env.BASE_URL:void 0);if(e)return I(e,t)}let a=r?.headers.get("x-forwarded-host"),o=r?.headers.get("x-forwarded-proto");if(a&&o&&i&&U(o,"proto")&&U(a,"host"))try{return I(`${o}://${a}`,t)}catch(e){}if(r){let e=P(r.url);if(!e)throw new E.BetterAuthError("Could not get origin from request. Please provide a valid base URL.");return I(e,t)}}function P(e){try{let t=new URL(e);return"null"===t.origin?null:t.origin}catch{return null}}function C(e){return"object"==typeof e&&null!==e&&"allowedHosts"in e&&Array.isArray(e.allowedHosts)}function D(e){return e instanceof Request||"object"==typeof e&&null!==e&&"[object Request]"===Object.prototype.toString.call(e)&&"string"==typeof e.url&&"object"==typeof e.headers&&null!==e.headers&&"function"==typeof e.headers.get}function L(e,t){let r=D(e)?e.headers:e;if(t){let e=r.get("x-forwarded-host");if(e&&U(e,"host"))return e}let n=r.get("host");if(n&&U(n,"host"))return n;if(D(e))try{return new URL(e.url).host}catch{}return null}let z=(e,t,r)=>{if(e.startsWith("/"))return!!r?.allowRelativePaths&&e.startsWith("/")&&/^\/(?!\/|\\|%2f|%5c)[\w\-.\+/@]*(?:\?[\w\-.\+/=&%@]*)?$/.test(e);if(t.includes("*")||t.includes("?")){if(t.includes("://"))return x(t)(P(e)||e);let r=function(e){try{return new URL(e).host}catch{return null}}(e);return!!r&&x(t)(r)}let n=function(e){try{return new URL(e).protocol}catch{return null}}(e);return"http:"!==n&&"https:"!==n&&n?e.startsWith(t):t===P(e)};function $(e){return!!e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then}var N=e.i(666680);function j(e,t){return new Promise((r,n)=>{(0,N.scrypt)(e.normalize("NFKC"),t,64,{N:16384,r:16,p:1,maxmem:0x4000000},(e,t)=>{e?n(e):r(t)})})}async function H(e){let t=(0,N.randomBytes)(16).toString("hex"),r=await j(e,t);return`${t}:${r.toString("hex")}`}async function B(e,t){let[r,n]=e.split(":");if(!r||!n)throw Error("Invalid password hash");return(await j(t,r)).toString("hex")===n}let V=async({hash:e,password:t})=>B(e,t);function M(e,t=""){if("number"!=typeof e){let r=t&&`"${t}" `;throw TypeError(`${r}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw RangeError(`${r}expected integer >= 0, got ${e}`)}}function K(e,t,r=""){let n=e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name&&"BYTES_PER_ELEMENT"in e&&1===e.BYTES_PER_ELEMENT,i=e?.length,a=void 0!==t;if(!n||a&&i!==t){let o=(r&&`"${r}" `)+"expected Uint8Array"+(a?` of length ${t}`:"")+", got "+(n?`length=${i}`:`type=${typeof e}`);if(!n)throw TypeError(o);throw RangeError(o)}return e}function W(e){if("function"!=typeof e||"function"!=typeof e.create)throw TypeError("Hash must wrapped by utils.createHasher");if(M(e.outputLen),M(e.blockLen),e.outputLen<1)throw Error('"outputLen" must be >= 1');if(e.blockLen<1)throw Error('"blockLen" must be >= 1')}function q(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function F(e,t){K(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw RangeError('"digestInto() output" expected to be of length >='+r)}function J(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Z(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function G(e,t){return e<<32-t|e>>>t}class Q{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if(W(e),K(t,void 0,"key"),this.iHash=e.create(),"function"!=typeof this.iHash.update)throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,n=new Uint8Array(r);n.set(t.length>r?e.create().update(t).digest():t);for(let e=0;e<n.length;e++)n[e]^=54;this.iHash.update(n),this.oHash=e.create();for(let e=0;e<n.length;e++)n[e]^=106;this.oHash.update(n),J(n)}update(e){return q(this),this.iHash.update(e),this}digestInto(e){q(this),F(e,this),this.finished=!0;let t=e.subarray(0,this.outputLen);this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:r,finished:n,destroyed:i,blockLen:a,outputLen:o}=this;return e.finished=n,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}let Y=((o=(e,t,r)=>new Q(e,t).update(r).digest()).create=(e,t)=>new Q(e,t),o),X=Uint8Array.of(0),ee=Uint8Array.of();class et{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,r,n){this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.buffer=new Uint8Array(e),this.view=Z(this.buffer)}update(e){q(this),K(e);let{view:t,buffer:r,blockLen:n}=this,i=e.length;for(let a=0;a<i;){let o=Math.min(n-this.pos,i-a);if(o===n){let t=Z(e);for(;n<=i-a;a+=n)this.process(t,a);continue}r.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===n&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){q(this),F(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:n,isLE:i}=this,{pos:a}=this;t[a++]=128,J(this.buffer.subarray(a)),this.padOffset>n-a&&(this.process(r,0),a=0);for(let e=a;e<n;e++)t[e]=0;r.setBigUint64(n-8,BigInt(8*this.length),i),this.process(r,0);let o=Z(e),s=this.outputLen;if(s%4)throw Error("_sha2: outputLen must be aligned to 32bit");let c=s/4,l=this.get();if(c>l.length)throw Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){(e||=new this.constructor).set(...this.get());let{blockLen:t,buffer:r,length:n,finished:i,destroyed:a,pos:o}=this;return e.destroyed=a,e.finished=i,e.length=n,e.pos=o,n%t&&e.buffer.set(r),e}clone(){return this._cloneInto()}}let er=Uint32Array.from([0x6a09e667,0xbb67ae85,0x3c6ef372,0xa54ff53a,0x510e527f,0x9b05688c,0x1f83d9ab,0x5be0cd19]),en=Uint32Array.from([0xc1059ed8,0x367cd507,0x3070dd17,0xf70e5939,0xffc00b31,0x68581511,0x64f98fa7,0xbefa4fa4]),ei=Uint32Array.from([0xcbbb9d5d,0xc1059ed8,0x629a292a,0x367cd507,0x9159015a,0x3070dd17,0x152fecd8,0xf70e5939,0x67332667,0xffc00b31,0x8eb44a87,0x68581511,0xdb0c2e0d,0x64f98fa7,0x47b5481d,0xbefa4fa4]),ea=Uint32Array.from([0x6a09e667,0xf3bcc908,0xbb67ae85,0x84caa73b,0x3c6ef372,0xfe94f82b,0xa54ff53a,0x5f1d36f1,0x510e527f,0xade682d1,0x9b05688c,0x2b3e6c1f,0x1f83d9ab,0xfb41bd6b,0x5be0cd19,0x137e2179]),eo=BigInt(0x100000000-1),es=BigInt(32),ec=Uint32Array.from([0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,0xe49b69c1,0xefbe4786,0xfc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x6ca6351,0x14292967,0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070,0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2]),el=new Uint32Array(64);class ed extends et{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:r,D:n,E:i,F:a,G:o,H:s}=this;return[e,t,r,n,i,a,o,s]}set(e,t,r,n,i,a,o,s){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|a,this.G=0|o,this.H=0|s}process(e,t){for(let r=0;r<16;r++,t+=4)el[r]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=el[e-15],r=el[e-2],n=G(t,7)^G(t,18)^t>>>3,i=G(r,17)^G(r,19)^r>>>10;el[e]=i+el[e-7]+n+el[e-16]|0}let{A:r,B:n,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){var d,u,p,f;let t=l+(G(o,6)^G(o,11)^G(o,25))+((d=o)&s^~d&c)+ec[e]+el[e]|0,h=(G(r,2)^G(r,13)^G(r,22))+((u=r)&(p=n)^u&(f=i)^p&f)|0;l=c,c=s,s=o,o=a+t|0,a=i,i=n,n=r,r=t+h|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(r,n,i,a,o,s,c,l)}roundClean(){J(el)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),J(this.buffer)}}class eu extends ed{A=0|er[0];B=0|er[1];C=0|er[2];D=0|er[3];E=0|er[4];F=0|er[5];G=0|er[6];H=0|er[7];constructor(){super(32)}}let ep=function(e,t=!1){let r=e.length,n=new Uint32Array(r),i=new Uint32Array(r);for(let a=0;a<r;a++){let{h:r,l:o}=function(e,t=!1){return t?{h:Number(e&eo),l:Number(e>>es&eo)}:{h:0|Number(e>>es&eo),l:0|Number(e&eo)}}(e[a],t);[n[a],i[a]]=[r,o]}return[n,i]}(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),ef=ep[0],eh=ep[1],em=new Uint32Array(80),ey=new Uint32Array(80),eg=function(e,t={}){let r=(t,r)=>e(r).update(t).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=t=>e(t),Object.assign(r,t),Object.freeze(r)}(()=>new eu,{oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,1])}),ew=new TextEncoder,eb=new TextDecoder;function eA(...e){let t=new Uint8Array(e.reduce((e,{length:t})=>e+t,0)),r=0;for(let n of e)t.set(n,r),r+=n.length;return t}function eE(e,t,r){if(t<0||t>=0x100000000)throw RangeError(`value must be >= 0 and <= ${0x100000000-1}. Received ${t}`);e.set([t>>>24,t>>>16,t>>>8,255&t],r)}function ev(e){let t=Math.floor(e/0x100000000),r=new Uint8Array(8);return eE(r,t,0),eE(r,e%0x100000000,4),r}function ek(e){let t=new Uint8Array(4);return eE(t,e),t}function e_(e){let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n>127)throw TypeError("non-ASCII string encountered in encode()");t[r]=n}return t}function eS(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64("string"==typeof e?e:eb.decode(e),{alphabet:"base64url"});let t=e;t instanceof Uint8Array&&(t=eb.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/");try{var r=t;if(Uint8Array.fromBase64)return Uint8Array.fromBase64(r);let e=atob(r),n=new Uint8Array(e.length);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);return n}catch{throw TypeError("The input to be decoded is not correctly encoded.")}}function ex(e){let t=e;return("string"==typeof t&&(t=ew.encode(t)),Uint8Array.prototype.toBase64)?t.toBase64({alphabet:"base64url",omitPadding:!0}):(function(e){if(Uint8Array.prototype.toBase64)return e.toBase64();let t=[];for(let r=0;r<e.length;r+=32768)t.push(String.fromCharCode.apply(null,e.subarray(r,r+32768)));return btoa(t.join(""))})(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}e.s(["decode",0,eS,"encode",0,ex],797379);let eT=Symbol();function eR(e,t){if(e)throw TypeError(`${t} can only be called once`)}function eI(e,t,r){try{return eS(e)}catch{throw new r(`Failed to base64url decode the ${t}`)}}async function eU(e,t){let r=`SHA-${e.slice(-3)}`;return new Uint8Array(await crypto.subtle.digest(r,t))}let eO=(e,t="algorithm.name")=>TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`);function eP(e,t){if(parseInt(e.hash.name.slice(4),10)!==t)throw eO(`SHA-${t}`,"algorithm.hash")}function eC(e,t){if(t&&!e.usages.includes(t))throw TypeError(`CryptoKey does not support this operation, its usages must include ${t}.`)}function eD(e,t,r){switch(t){case"A128GCM":case"A192GCM":case"A256GCM":{if("AES-GCM"!==e.algorithm.name)throw eO("AES-GCM");let r=parseInt(t.slice(1,4),10);if(e.algorithm.length!==r)throw eO(r,"algorithm.length");break}case"A128KW":case"A192KW":case"A256KW":{if("AES-KW"!==e.algorithm.name)throw eO("AES-KW");let r=parseInt(t.slice(1,4),10);if(e.algorithm.length!==r)throw eO(r,"algorithm.length");break}case"ECDH":switch(e.algorithm.name){case"ECDH":case"X25519":break;default:throw eO("ECDH or X25519")}break;case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":if("PBKDF2"!==e.algorithm.name)throw eO("PBKDF2");break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":if("RSA-OAEP"!==e.algorithm.name)throw eO("RSA-OAEP");eP(e.algorithm,parseInt(t.slice(9),10)||1);break;default:throw TypeError("CryptoKey does not support this operation")}eC(e,r)}function eL(e,t,...r){if((r=r.filter(Boolean)).length>2){let t=r.pop();e+=`one of type ${r.join(", ")}, or ${t}.`}else 2===r.length?e+=`one of type ${r[0]} or ${r[1]}.`:e+=`of type ${r[0]}.`;return null==t?e+=` Received ${t}`:"function"==typeof t&&t.name?e+=` Received function ${t.name}`:"object"==typeof t&&null!=t&&t.constructor?.name&&(e+=` Received an instance of ${t.constructor.name}`),e}let ez=(e,...t)=>eL("Key must be ",e,...t),e$=(e,t,...r)=>eL(`Key for the ${e} algorithm must be `,t,...r);class eN extends Error{static code="ERR_JOSE_GENERIC";code="ERR_JOSE_GENERIC";constructor(e,t){super(e,t),this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}class ej extends eN{static code="ERR_JWT_CLAIM_VALIDATION_FAILED";code="ERR_JWT_CLAIM_VALIDATION_FAILED";claim;reason;payload;constructor(e,t,r="unspecified",n="unspecified"){super(e,{cause:{claim:r,reason:n,payload:t}}),this.claim=r,this.reason=n,this.payload=t}}class eH extends eN{static code="ERR_JWT_EXPIRED";code="ERR_JWT_EXPIRED";claim;reason;payload;constructor(e,t,r="unspecified",n="unspecified"){super(e,{cause:{claim:r,reason:n,payload:t}}),this.claim=r,this.reason=n,this.payload=t}}class eB extends eN{static code="ERR_JOSE_ALG_NOT_ALLOWED";code="ERR_JOSE_ALG_NOT_ALLOWED"}class eV extends eN{static code="ERR_JOSE_NOT_SUPPORTED";code="ERR_JOSE_NOT_SUPPORTED"}class eM extends eN{static code="ERR_JWE_DECRYPTION_FAILED";code="ERR_JWE_DECRYPTION_FAILED";constructor(e="decryption operation failed",t){super(e,t)}}class eK extends eN{static code="ERR_JWE_INVALID";code="ERR_JWE_INVALID"}class eW extends eN{static code="ERR_JWS_INVALID";code="ERR_JWS_INVALID"}class eq extends eN{static code="ERR_JWT_INVALID";code="ERR_JWT_INVALID"}class eF extends eN{static code="ERR_JWK_INVALID";code="ERR_JWK_INVALID"}class eJ extends eN{static code="ERR_JWKS_INVALID";code="ERR_JWKS_INVALID"}class eZ extends eN{static code="ERR_JWKS_NO_MATCHING_KEY";code="ERR_JWKS_NO_MATCHING_KEY";constructor(e="no applicable key found in the JSON Web Key Set",t){super(e,t)}}class eG extends eN{[Symbol.asyncIterator];static code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";constructor(e="multiple matching keys found in the JSON Web Key Set",t){super(e,t)}}class eQ extends eN{static code="ERR_JWKS_TIMEOUT";code="ERR_JWKS_TIMEOUT";constructor(e="request timed out",t){super(e,t)}}class eY extends eN{static code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";constructor(e="signature verification failed",t){super(e,t)}}function eX(e){if(!e0(e))throw Error("CryptoKey instance expected")}let e0=e=>{if(e?.[Symbol.toStringTag]==="CryptoKey")return!0;try{return e instanceof CryptoKey}catch{return!1}},e1=e=>e?.[Symbol.toStringTag]==="KeyObject",e2=e=>e0(e)||e1(e);function e6(e){switch(e){case"A128GCM":return 128;case"A192GCM":return 192;case"A256GCM":case"A128CBC-HS256":return 256;case"A192CBC-HS384":return 384;case"A256CBC-HS512":return 512;default:throw new eV(`Unsupported JWE Algorithm: ${e}`)}}let e5=e=>crypto.getRandomValues(new Uint8Array(e6(e)>>3));function e8(e,t){let r=e.byteLength<<3;if(r!==t)throw new eK(`Invalid Content Encryption Key length. Expected ${t} bits, got ${r} bits`)}function e4(e){switch(e){case"A128GCM":case"A128GCMKW":case"A192GCM":case"A192GCMKW":case"A256GCM":case"A256GCMKW":return 96;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return 128;default:throw new eV(`Unsupported JWE Algorithm: ${e}`)}}function e3(e,t){if(t.length<<3!==e4(e))throw new eK("Invalid Initialization Vector length")}async function e9(e,t,r){if(!(t instanceof Uint8Array))throw TypeError(ez(t,"Uint8Array"));let n=parseInt(e.slice(1,4),10);return{encKey:await crypto.subtle.importKey("raw",t.subarray(n>>3),"AES-CBC",!1,[r]),macKey:await crypto.subtle.importKey("raw",t.subarray(0,n>>3),{hash:`SHA-${n<<1}`,name:"HMAC"},!1,["sign"]),keySize:n}}async function e7(e,t,r){return new Uint8Array((await crypto.subtle.sign("HMAC",e,t)).slice(0,r>>3))}async function te(e,t,r,n,i){let{encKey:a,macKey:o,keySize:s}=await e9(e,r,"encrypt"),c=new Uint8Array(await crypto.subtle.encrypt({iv:n,name:"AES-CBC"},a,t)),l=eA(i,n,c,ev(i.length<<3));return{ciphertext:c,tag:await e7(o,l,s),iv:n}}async function tt(e,t){if(!(e instanceof Uint8Array))throw TypeError("First argument must be a buffer");if(!(t instanceof Uint8Array))throw TypeError("Second argument must be a buffer");let r={name:"HMAC",hash:"SHA-256"},n=await crypto.subtle.generateKey(r,!1,["sign"]),i=new Uint8Array(await crypto.subtle.sign(r,n,e)),a=new Uint8Array(await crypto.subtle.sign(r,n,t)),o=0,s=-1;for(;++s<32;)o|=i[s]^a[s];return 0===o}async function tr(e,t,r,n,i,a){let o,s,{encKey:c,macKey:l,keySize:d}=await e9(e,t,"decrypt"),u=eA(a,n,r,ev(a.length<<3)),p=await e7(l,u,d);try{o=await tt(i,p)}catch{}if(!o)throw new eM;try{s=new Uint8Array(await crypto.subtle.decrypt({iv:n,name:"AES-CBC"},c,r))}catch{}if(!s)throw new eM;return s}async function tn(e,t,r,n,i){let a;r instanceof Uint8Array?a=await crypto.subtle.importKey("raw",r,"AES-GCM",!1,["encrypt"]):(eD(r,e,"encrypt"),a=r);let o=new Uint8Array(await crypto.subtle.encrypt({additionalData:i,iv:n,name:"AES-GCM",tagLength:128},a,t)),s=o.slice(-16);return{ciphertext:o.slice(0,-16),tag:s,iv:n}}async function ti(e,t,r,n,i,a){let o;t instanceof Uint8Array?o=await crypto.subtle.importKey("raw",t,"AES-GCM",!1,["decrypt"]):(eD(t,e,"decrypt"),o=t);try{return new Uint8Array(await crypto.subtle.decrypt({additionalData:a,iv:n,name:"AES-GCM",tagLength:128},o,eA(r,i)))}catch{throw new eM}}let ta="Unsupported JWE Content Encryption Algorithm";async function to(e,t,r,n,i){if(!e0(r)&&!(r instanceof Uint8Array))throw TypeError(ez(r,"CryptoKey","KeyObject","Uint8Array","JSON Web Key"));if(n)e3(e,n);else n=crypto.getRandomValues(new Uint8Array(e4(e)>>3));switch(e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return r instanceof Uint8Array&&e8(r,parseInt(e.slice(-3),10)),te(e,t,r,n,i);case"A128GCM":case"A192GCM":case"A256GCM":return r instanceof Uint8Array&&e8(r,parseInt(e.slice(1,4),10)),tn(e,t,r,n,i);default:throw new eV(ta)}}async function ts(e,t,r,n,i,a){if(!e0(t)&&!(t instanceof Uint8Array))throw TypeError(ez(t,"CryptoKey","KeyObject","Uint8Array","JSON Web Key"));if(!n)throw new eK("JWE Initialization Vector missing");if(!i)throw new eK("JWE Authentication Tag missing");switch(e3(e,n),e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return t instanceof Uint8Array&&e8(t,parseInt(e.slice(-3),10)),tr(e,t,r,n,i,a);case"A128GCM":case"A192GCM":case"A256GCM":return t instanceof Uint8Array&&e8(t,parseInt(e.slice(1,4),10)),ti(e,t,r,n,i,a);default:throw new eV(ta)}}function tc(e,t){if(e.algorithm.length!==parseInt(t.slice(1,4),10))throw TypeError(`Invalid key size for alg: ${t}`)}function tl(e,t,r){return e instanceof Uint8Array?crypto.subtle.importKey("raw",e,"AES-KW",!0,[r]):(eD(e,t,r),e)}async function td(e,t,r){let n=await tl(t,e,"wrapKey");tc(n,e);let i=await crypto.subtle.importKey("raw",r,{hash:"SHA-256",name:"HMAC"},!0,["sign"]);return new Uint8Array(await crypto.subtle.wrapKey("raw",i,n,"AES-KW"))}async function tu(e,t,r){let n=await tl(t,e,"unwrapKey");tc(n,e);let i=await crypto.subtle.unwrapKey("raw",r,n,"AES-KW",{hash:"SHA-256",name:"HMAC"},!0,["sign"]);return new Uint8Array(await crypto.subtle.exportKey("raw",i))}function tp(e){return eA(ek(e.length),e)}async function tf(e,t,r){let n=t>>3,i=Math.ceil(n/32),a=new Uint8Array(32*i);for(let t=1;t<=i;t++){let n=new Uint8Array(4+e.length+r.length);n.set(ek(t),0),n.set(e,4),n.set(r,4+e.length);let i=await eU("sha256",n);a.set(i,(t-1)*32)}return a.slice(0,n)}async function th(e,t,r,n,i=new Uint8Array,a=new Uint8Array){var o;eD(e,"ECDH"),eD(t,"ECDH","deriveBits");let s=eA(tp(e_(r)),tp(i),tp(a),ek(n),new Uint8Array);return tf(new Uint8Array(await crypto.subtle.deriveBits({name:e.algorithm.name,public:e},t,"X25519"===(o=e).algorithm.name?256:Math.ceil(parseInt(o.algorithm.namedCurve.slice(-3),10)/8)<<3)),n,s)}function tm(e){switch(e.algorithm.namedCurve){case"P-256":case"P-384":case"P-521":return!0;default:return"X25519"===e.algorithm.name}}async function ty(e,t,r,n){if(!(e instanceof Uint8Array)||e.length<8)throw new eK("PBES2 Salt Input must be 8 or more octets");if(!Number.isSafeInteger(r)||1!==Math.sign(r))throw new eK("PBES2 Count Input must be a positive integer");let i=eA(e_(t),Uint8Array.of(0),e),a=parseInt(t.slice(13,16),10),o={hash:`SHA-${t.slice(8,11)}`,iterations:r,name:"PBKDF2",salt:i},s=await (n instanceof Uint8Array?crypto.subtle.importKey("raw",n,"PBKDF2",!1,["deriveBits"]):(eD(n,t,"deriveBits"),n));return new Uint8Array(await crypto.subtle.deriveBits(o,s,a))}async function tg(e,t,r,n=2048,i=crypto.getRandomValues(new Uint8Array(16))){let a=await ty(i,e,n,t);return{encryptedKey:await td(e.slice(-6),a,r),p2c:n,p2s:ex(i)}}async function tw(e,t,r,n,i){let a=await ty(i,e,n,t);return tu(e.slice(-6),a,r)}function tb(e,t){if(e.startsWith("RS")||e.startsWith("PS")){let{modulusLength:r}=t.algorithm;if("number"!=typeof r||r<2048)throw TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}}function tA(e,t){let r=`SHA-${e.slice(-3)}`;switch(e){case"HS256":case"HS384":case"HS512":return{hash:r,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:r,name:"RSA-PSS",saltLength:parseInt(e.slice(-3),10)>>3};case"RS256":case"RS384":case"RS512":return{hash:r,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:r,name:"ECDSA",namedCurve:t.namedCurve};case"Ed25519":case"EdDSA":return{name:"Ed25519"};case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":return{name:e};default:throw new eV(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}async function tE(e,t,r){if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw TypeError(ez(t,"CryptoKey","KeyObject","JSON Web Key"));return crypto.subtle.importKey("raw",t,{hash:`SHA-${e.slice(-3)}`,name:"HMAC"},!1,[r])}switch(e){case"HS256":case"HS384":case"HS512":if("HMAC"!==t.algorithm.name)throw eO("HMAC");eP(t.algorithm,parseInt(e.slice(2),10));break;case"RS256":case"RS384":case"RS512":if("RSASSA-PKCS1-v1_5"!==t.algorithm.name)throw eO("RSASSA-PKCS1-v1_5");eP(t.algorithm,parseInt(e.slice(2),10));break;case"PS256":case"PS384":case"PS512":if("RSA-PSS"!==t.algorithm.name)throw eO("RSA-PSS");eP(t.algorithm,parseInt(e.slice(2),10));break;case"Ed25519":case"EdDSA":if("Ed25519"!==t.algorithm.name)throw eO("Ed25519");break;case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":let n;if(n=t.algorithm,n.name!==e)throw eO(e);break;case"ES256":case"ES384":case"ES512":{if("ECDSA"!==t.algorithm.name)throw eO("ECDSA");let r=function(e){switch(e){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw Error("unreachable")}}(e);if(t.algorithm.namedCurve!==r)throw eO(r,"algorithm.namedCurve");break}default:throw TypeError("CryptoKey does not support this operation")}return eC(t,r),t}async function tv(e,t,r){let n=await tE(e,t,"sign");return tb(e,n),new Uint8Array(await crypto.subtle.sign(tA(e,n.algorithm),n,r))}async function tk(e,t,r,n){let i=await tE(e,t,"verify");tb(e,i);let a=tA(e,i.algorithm);try{return await crypto.subtle.verify(a,i,r,n)}catch{return!1}}let t_=e=>{switch(e){case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return"RSA-OAEP";default:throw new eV(`alg ${e} is not supported either by JOSE or your javascript runtime`)}};async function tS(e,t,r){return eD(t,e,"encrypt"),tb(e,t),new Uint8Array(await crypto.subtle.encrypt(t_(e),t,r))}async function tx(e,t,r){return eD(t,e,"decrypt"),tb(e,t),new Uint8Array(await crypto.subtle.decrypt(t_(e),t,r))}function tT(e){if("object"!=typeof e||null===e||"[object Object]"!==Object.prototype.toString.call(e))return!1;if(null===Object.getPrototypeOf(e))return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function tR(...e){let t,r=e.filter(Boolean);if(0===r.length||1===r.length)return!0;for(let e of r){let r=Object.keys(e);if(!t||0===t.size){t=new Set(r);continue}for(let e of r){if(t.has(e))return!1;t.add(e)}}return!0}let tI=e=>tT(e)&&"string"==typeof e.kty,tU='Invalid or unsupported JWK "alg" (Algorithm) Parameter value';async function tO(e){if(!e.alg)throw TypeError('"alg" argument is required when "jwk.alg" is not present');let{algorithm:t,keyUsages:r}=function(e){let t,r;switch(e.kty){case"AKP":switch(e.alg){case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":t={name:e.alg},r=e.priv?["sign"]:["verify"];break;default:throw new eV(tU)}break;case"RSA":switch(e.alg){case"PS256":case"PS384":case"PS512":t={name:"RSA-PSS",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":t={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":t={name:"RSA-OAEP",hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`},r=e.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new eV(tU)}break;case"EC":switch(e.alg){case"ES256":case"ES384":case"ES512":t={name:"ECDSA",namedCurve:({ES256:"P-256",ES384:"P-384",ES512:"P-521"})[e.alg]},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:"ECDH",namedCurve:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new eV(tU)}break;case"OKP":switch(e.alg){case"Ed25519":case"EdDSA":t={name:"Ed25519"},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new eV(tU)}break;default:throw new eV('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:t,keyUsages:r}}(e),n={...e};return"AKP"!==n.kty&&delete n.alg,delete n.use,crypto.subtle.importKey("jwk",n,t,e.ext??(!e.d&&!e.priv),e.key_ops??r)}let tP="given KeyObject instance cannot be used for this algorithm",tC=async(e,r,n,i=!1)=>{let a=(t||=new WeakMap).get(e);if(a?.[n])return a[n];let o=await tO({...r,alg:n});return i&&Object.freeze(e),a?a[n]=o:t.set(e,{[n]:o}),o};async function tD(e,r){if(e instanceof Uint8Array||e0(e))return e;if(e1(e)){if("secret"===e.type)return e.export();if("toCryptoKey"in e&&"function"==typeof e.toCryptoKey)try{return((e,r)=>{let n,i=(t||=new WeakMap).get(e);if(i?.[r])return i[r];let a="public"===e.type,o=!!a;if("x25519"===e.asymmetricKeyType){switch(r){case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":break;default:throw TypeError(tP)}n=e.toCryptoKey(e.asymmetricKeyType,o,a?[]:["deriveBits"])}if("ed25519"===e.asymmetricKeyType){if("EdDSA"!==r&&"Ed25519"!==r)throw TypeError(tP);n=e.toCryptoKey(e.asymmetricKeyType,o,[a?"verify":"sign"])}switch(e.asymmetricKeyType){case"ml-dsa-44":case"ml-dsa-65":case"ml-dsa-87":if(r!==e.asymmetricKeyType.toUpperCase())throw TypeError(tP);n=e.toCryptoKey(e.asymmetricKeyType,o,[a?"verify":"sign"])}if("rsa"===e.asymmetricKeyType){let t;switch(r){case"RSA-OAEP":t="SHA-1";break;case"RS256":case"PS256":case"RSA-OAEP-256":t="SHA-256";break;case"RS384":case"PS384":case"RSA-OAEP-384":t="SHA-384";break;case"RS512":case"PS512":case"RSA-OAEP-512":t="SHA-512";break;default:throw TypeError(tP)}if(r.startsWith("RSA-OAEP"))return e.toCryptoKey({name:"RSA-OAEP",hash:t},o,a?["encrypt"]:["decrypt"]);n=e.toCryptoKey({name:r.startsWith("PS")?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:t},o,[a?"verify":"sign"])}if("ec"===e.asymmetricKeyType){let t=new Map([["prime256v1","P-256"],["secp384r1","P-384"],["secp521r1","P-521"]]).get(e.asymmetricKeyDetails?.namedCurve);if(!t)throw TypeError(tP);let i={ES256:"P-256",ES384:"P-384",ES512:"P-521"};i[r]&&t===i[r]&&(n=e.toCryptoKey({name:"ECDSA",namedCurve:t},o,[a?"verify":"sign"])),r.startsWith("ECDH-ES")&&(n=e.toCryptoKey({name:"ECDH",namedCurve:t},o,a?[]:["deriveBits"]))}if(!n)throw TypeError(tP);return i?i[r]=n:t.set(e,{[r]:n}),n})(e,r)}catch(e){if(e instanceof TypeError)throw e}let n=e.export({format:"jwk"});return tC(e,n,r)}if(tI(e))return e.k?eS(e.k):tC(e,e,r,!0);throw Error("unreachable")}async function tL(e,t,r){let n;if(!tT(e))throw TypeError("JWK must be an object");switch(t??=e.alg,n??=r?.extractable??e.ext,e.kty){case"oct":if("string"!=typeof e.k||!e.k)throw TypeError('missing "k" (Key Value) Parameter value');return eS(e.k);case"RSA":if("oth"in e&&void 0!==e.oth)throw new eV('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');return tO({...e,alg:t,ext:n});case"AKP":if("string"!=typeof e.alg||!e.alg)throw TypeError('missing "alg" (Algorithm) Parameter value');if(void 0!==t&&t!==e.alg)throw TypeError("JWK alg and alg option value mismatch");return tO({...e,ext:n});case"EC":case"OKP":return tO({...e,alg:t,ext:n});default:throw new eV('Unsupported "kty" (Key Type) Parameter value')}}async function tz(e){if(e1(e))if("secret"!==e.type)return e.export({format:"jwk"});else e=e.export();if(e instanceof Uint8Array)return{kty:"oct",k:ex(e)};if(!e0(e))throw TypeError(ez(e,"CryptoKey","KeyObject","Uint8Array"));if(!e.extractable)throw TypeError("non-extractable CryptoKey cannot be exported as a JWK");let{ext:t,key_ops:r,alg:n,use:i,...a}=await crypto.subtle.exportKey("jwk",e);return"AKP"===a.kty&&(a.alg=n),a}async function t$(e){return tz(e)}async function tN(e,t,r,n){let i=e.slice(0,7),a=await to(i,r,t,n,new Uint8Array);return{encryptedKey:a.ciphertext,iv:ex(a.iv),tag:ex(a.tag)}}async function tj(e,t,r,n,i){return ts(e.slice(0,7),t,r,n,i,new Uint8Array)}let tH='Invalid or unsupported "alg" (JWE Algorithm) header value';function tB(e){if(void 0===e)throw new eK("JWE Encrypted Key missing")}async function tV(e,t,r,n,i){switch(e){case"dir":if(void 0!==r)throw new eK("Encountered unexpected JWE Encrypted Key");return t;case"ECDH-ES":if(void 0!==r)throw new eK("Encountered unexpected JWE Encrypted Key");case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{let i,a;if(!tT(n.epk))throw new eK('JOSE Header "epk" (Ephemeral Public Key) missing or invalid');if(eX(t),!tm(t))throw new eV("ECDH with the provided key is not allowed or not supported by your javascript runtime");let o=await tL(n.epk,e);if(eX(o),void 0!==n.apu){if("string"!=typeof n.apu)throw new eK('JOSE Header "apu" (Agreement PartyUInfo) invalid');i=eI(n.apu,"apu",eK)}if(void 0!==n.apv){if("string"!=typeof n.apv)throw new eK('JOSE Header "apv" (Agreement PartyVInfo) invalid');a=eI(n.apv,"apv",eK)}let s=await th(o,t,"ECDH-ES"===e?n.enc:e,"ECDH-ES"===e?e6(n.enc):parseInt(e.slice(-5,-2),10),i,a);if("ECDH-ES"===e)return s;return tB(r),tu(e.slice(-6),s,r)}case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return tB(r),eX(t),tx(e,t,r);case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{let a;if(tB(r),"number"!=typeof n.p2c)throw new eK('JOSE Header "p2c" (PBES2 Count) missing or invalid');let o=i?.maxPBES2Count||1e4;if(n.p2c>o)throw new eK('JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds');if("string"!=typeof n.p2s)throw new eK('JOSE Header "p2s" (PBES2 Salt) missing or invalid');return a=eI(n.p2s,"p2s",eK),tw(e,t,r,n.p2c,a)}case"A128KW":case"A192KW":case"A256KW":return tB(r),tu(e,t,r);case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":if(tB(r),"string"!=typeof n.iv)throw new eK('JOSE Header "iv" (Initialization Vector) missing or invalid');if("string"!=typeof n.tag)throw new eK('JOSE Header "tag" (Authentication Tag) missing or invalid');return tj(e,t,r,eI(n.iv,"iv",eK),eI(n.tag,"tag",eK));default:throw new eV(tH)}}async function tM(e,t,r,n,i={}){let a,o,s;switch(e){case"dir":s=r;break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{let c;if(eX(r),!tm(r))throw new eV("ECDH with the provided key is not allowed or not supported by your javascript runtime");let{apu:l,apv:d}=i;c=i.epk?await tD(i.epk,e):(await crypto.subtle.generateKey(r.algorithm,!0,["deriveBits"])).privateKey;let{x:u,y:p,crv:f,kty:h}=await t$(c),m=await th(r,c,"ECDH-ES"===e?t:e,"ECDH-ES"===e?e6(t):parseInt(e.slice(-5,-2),10),l,d);if(o={epk:{x:u,crv:f,kty:h}},"EC"===h&&(o.epk.y=p),l&&(o.apu=ex(l)),d&&(o.apv=ex(d)),"ECDH-ES"===e){s=m;break}s=n||e5(t);let y=e.slice(-6);a=await td(y,m,s);break}case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":s=n||e5(t),eX(r),a=await tS(e,r,s);break;case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{s=n||e5(t);let{p2c:c,p2s:l}=i;({encryptedKey:a,...o}=await tg(e,r,s,c,l));break}case"A128KW":case"A192KW":case"A256KW":s=n||e5(t),a=await td(e,r,s);break;case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{s=n||e5(t);let{iv:c}=i;({encryptedKey:a,...o}=await tN(e,r,s,c));break}default:throw new eV(tH)}return{cek:s,encryptedKey:a,parameters:o}}function tK(e,t,r,n,i){let a;if(void 0!==i.crit&&n?.crit===void 0)throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!n||void 0===n.crit)return new Set;if(!Array.isArray(n.crit)||0===n.crit.length||n.crit.some(e=>"string"!=typeof e||0===e.length))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');for(let o of(a=void 0!==r?new Map([...Object.entries(r),...t.entries()]):t,n.crit)){if(!a.has(o))throw new eV(`Extension Header Parameter "${o}" is not recognized`);if(void 0===i[o])throw new e(`Extension Header Parameter "${o}" is missing`);if(a.get(o)&&void 0===n[o])throw new e(`Extension Header Parameter "${o}" MUST be integrity protected`)}return new Set(n.crit)}let tW=e=>e?.[Symbol.toStringTag],tq=(e,t,r)=>{if(void 0!==t.use){let e;switch(r){case"sign":case"verify":e="sig";break;case"encrypt":case"decrypt":e="enc"}if(t.use!==e)throw TypeError(`Invalid key for this operation, its "use" must be "${e}" when present`)}if(void 0!==t.alg&&t.alg!==e)throw TypeError(`Invalid key for this operation, its "alg" must be "${e}" when present`);if(Array.isArray(t.key_ops)){let n;switch(!0){case"sign"===r||"verify"===r:case"dir"===e:case e.includes("CBC-HS"):n=r;break;case e.startsWith("PBES2"):n="deriveBits";break;case/^A\d{3}(?:GCM)?(?:KW)?$/.test(e):n=!e.includes("GCM")&&e.endsWith("KW")?"encrypt"===r?"wrapKey":"unwrapKey":r;break;case"encrypt"===r&&e.startsWith("RSA"):n="wrapKey";break;case"decrypt"===r:n=e.startsWith("RSA")?"unwrapKey":"deriveBits"}if(n&&t.key_ops?.includes?.(n)===!1)throw TypeError(`Invalid key for this operation, its "key_ops" must include "${n}" when present`)}return!0};function tF(e,t,r){switch(e.substring(0,2)){case"A1":case"A2":case"di":case"HS":case"PB":((e,t,r)=>{if(!(t instanceof Uint8Array)){if(tI(t)){if("oct"===t.kty&&"string"==typeof t.k&&tq(e,t,r))return;throw TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present')}if(!e2(t))throw TypeError(e$(e,t,"CryptoKey","KeyObject","JSON Web Key","Uint8Array"));if("secret"!==t.type)throw TypeError(`${tW(t)} instances for symmetric algorithms must be of type "secret"`)}})(e,t,r);break;default:((e,t,r)=>{if(tI(t))switch(r){case"decrypt":case"sign":if("oct"!==t.kty&&("AKP"===t.kty&&"string"==typeof t.priv||"string"==typeof t.d)&&tq(e,t,r))return;throw TypeError("JSON Web Key for this operation must be a private JWK");case"encrypt":case"verify":if("oct"!==t.kty&&void 0===t.d&&void 0===t.priv&&tq(e,t,r))return;throw TypeError("JSON Web Key for this operation must be a public JWK")}if(!e2(t))throw TypeError(e$(e,t,"CryptoKey","KeyObject","JSON Web Key"));if("secret"===t.type)throw TypeError(`${tW(t)} instances for asymmetric algorithms must not be of type "secret"`);if("public"===t.type)switch(r){case"sign":throw TypeError(`${tW(t)} instances for asymmetric algorithm signing must be of type "private"`);case"decrypt":throw TypeError(`${tW(t)} instances for asymmetric algorithm decryption must be of type "private"`)}if("private"===t.type)switch(r){case"verify":throw TypeError(`${tW(t)} instances for asymmetric algorithm verifying must be of type "public"`);case"encrypt":throw TypeError(`${tW(t)} instances for asymmetric algorithm encryption must be of type "public"`)}})(e,t,r)}}function tJ(e){if(void 0===globalThis[e])throw new eV(`JWE "zip" (Compression Algorithm) Header Parameter requires the ${e} API.`)}async function tZ(e){tJ("CompressionStream");let t=new CompressionStream("deflate-raw"),r=t.writable.getWriter();r.write(e).catch(()=>{}),r.close().catch(()=>{});let n=[],i=t.readable.getReader();for(;;){let{value:e,done:t}=await i.read();if(t)break;n.push(e)}return eA(...n)}async function tG(e,t){tJ("DecompressionStream");let r=new DecompressionStream("deflate-raw"),n=r.writable.getWriter();n.write(e).catch(()=>{}),n.close().catch(()=>{});let i=[],a=0,o=r.readable.getReader();for(;;){let{value:e,done:r}=await o.read();if(r)break;if(i.push(e),a+=e.byteLength,t!==1/0&&a>t)throw new eK("Decompressed plaintext exceeded the configured limit")}return eA(...i)}class tQ{#e;#t;#r;#n;#i;#a;#o;#s;constructor(e){if(!(e instanceof Uint8Array))throw TypeError("plaintext must be an instance of Uint8Array");this.#e=e}setKeyManagementParameters(e){return eR(this.#s,"setKeyManagementParameters"),this.#s=e,this}setProtectedHeader(e){return eR(this.#t,"setProtectedHeader"),this.#t=e,this}setSharedUnprotectedHeader(e){return eR(this.#r,"setSharedUnprotectedHeader"),this.#r=e,this}setUnprotectedHeader(e){return eR(this.#n,"setUnprotectedHeader"),this.#n=e,this}setAdditionalAuthenticatedData(e){return this.#i=e,this}setContentEncryptionKey(e){return eR(this.#a,"setContentEncryptionKey"),this.#a=e,this}setInitializationVector(e){return eR(this.#o,"setInitializationVector"),this.#o=e,this}async encrypt(e,t){let r,n,i,a,o,s;if(!this.#t&&!this.#n&&!this.#r)throw new eK("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");if(!tR(this.#t,this.#n,this.#r))throw new eK("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");let c={...this.#t,...this.#n,...this.#r};if(tK(eK,new Map,t?.crit,this.#t,c),void 0!==c.zip&&"DEF"!==c.zip)throw new eV('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');if(void 0!==c.zip&&!this.#t?.zip)throw new eK('JWE "zip" (Compression Algorithm) Header Parameter MUST be in a protected header.');let{alg:l,enc:d}=c;if("string"!=typeof l||!l)throw new eK('JWE "alg" (Algorithm) Header Parameter missing or invalid');if("string"!=typeof d||!d)throw new eK('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');if(this.#a&&("dir"===l||"ECDH-ES"===l))throw TypeError(`setContentEncryptionKey cannot be called with JWE "alg" (Algorithm) Header ${l}`);tF("dir"===l?d:l,e,"encrypt");{let i,a=await tD(e,l);({cek:n,encryptedKey:r,parameters:i}=await tM(l,d,a,this.#a,this.#s)),i&&(t&&eT in t?this.#n?this.#n={...this.#n,...i}:this.setUnprotectedHeader(i):this.#t?this.#t={...this.#t,...i}:this.setProtectedHeader(i))}if(this.#t?o=e_(a=ex(JSON.stringify(this.#t))):(a="",o=new Uint8Array),this.#i){let e=e_(s=ex(this.#i));i=eA(o,e_("."),e)}else i=o;let u=this.#e;"DEF"===c.zip&&(u=await tZ(u).catch(e=>{throw new eK("Failed to compress plaintext",{cause:e})}));let{ciphertext:p,tag:f,iv:h}=await to(d,u,n,this.#o,i),m={ciphertext:ex(p)};return h&&(m.iv=ex(h)),f&&(m.tag=ex(f)),r&&(m.encrypted_key=ex(r)),s&&(m.aad=s),this.#t&&(m.protected=a),this.#r&&(m.unprotected=this.#r),this.#n&&(m.header=this.#n),m}}class tY{#c;constructor(e){this.#c=new tQ(e)}setContentEncryptionKey(e){return this.#c.setContentEncryptionKey(e),this}setInitializationVector(e){return this.#c.setInitializationVector(e),this}setProtectedHeader(e){return this.#c.setProtectedHeader(e),this}setKeyManagementParameters(e){return this.#c.setKeyManagementParameters(e),this}async encrypt(e,t){let r=await this.#c.encrypt(e,t);return[r.protected,r.encrypted_key,r.iv,r.ciphertext,r.tag].join(".")}}let tX=e=>Math.floor(e.getTime()/1e3),t0=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;function t1(e){let t,r=t0.exec(e);if(!r||r[4]&&r[1])throw TypeError("Invalid time period format");let n=parseFloat(r[2]);switch(r[3].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":t=Math.round(n);break;case"minute":case"minutes":case"min":case"mins":case"m":t=Math.round(60*n);break;case"hour":case"hours":case"hr":case"hrs":case"h":t=Math.round(3600*n);break;case"day":case"days":case"d":t=Math.round(86400*n);break;case"week":case"weeks":case"w":t=Math.round(604800*n);break;default:t=Math.round(0x1e187e0*n)}return"-"===r[1]||"ago"===r[4]?-t:t}function t2(e,t){if(!Number.isFinite(t))throw TypeError(`Invalid ${e} input`);return t}let t6=e=>e.includes("/")?e.toLowerCase():`application/${e.toLowerCase()}`;function t5(e,t,r={}){var n,i;let a,o;try{a=JSON.parse(eb.decode(t))}catch{}if(!tT(a))throw new eq("JWT Claims Set must be a top-level JSON object");let{typ:s}=r;if(s&&("string"!=typeof e.typ||t6(e.typ)!==t6(s)))throw new ej('unexpected "typ" JWT header value',a,"typ","check_failed");let{requiredClaims:c=[],issuer:l,subject:d,audience:u,maxTokenAge:p}=r,f=[...c];for(let e of(void 0!==p&&f.push("iat"),void 0!==u&&f.push("aud"),void 0!==d&&f.push("sub"),void 0!==l&&f.push("iss"),new Set(f.reverse())))if(!(e in a))throw new ej(`missing required "${e}" claim`,a,e,"missing");if(l&&!(Array.isArray(l)?l:[l]).includes(a.iss))throw new ej('unexpected "iss" claim value',a,"iss","check_failed");if(d&&a.sub!==d)throw new ej('unexpected "sub" claim value',a,"sub","check_failed");if(u&&(n=a.aud,i="string"==typeof u?[u]:u,"string"==typeof n?!i.includes(n):!(Array.isArray(n)&&i.some(Set.prototype.has.bind(new Set(n))))))throw new ej('unexpected "aud" claim value',a,"aud","check_failed");switch(typeof r.clockTolerance){case"string":o=t1(r.clockTolerance);break;case"number":o=r.clockTolerance;break;case"undefined":o=0;break;default:throw TypeError("Invalid clockTolerance option type")}let{currentDate:h}=r,m=tX(h||new Date);if((void 0!==a.iat||p)&&"number"!=typeof a.iat)throw new ej('"iat" claim must be a number',a,"iat","invalid");if(void 0!==a.nbf){if("number"!=typeof a.nbf)throw new ej('"nbf" claim must be a number',a,"nbf","invalid");if(a.nbf>m+o)throw new ej('"nbf" claim timestamp check failed',a,"nbf","check_failed")}if(void 0!==a.exp){if("number"!=typeof a.exp)throw new ej('"exp" claim must be a number',a,"exp","invalid");if(a.exp<=m-o)throw new eH('"exp" claim timestamp check failed',a,"exp","check_failed")}if(p){let e=m-a.iat;if(e-o>("number"==typeof p?p:t1(p)))throw new eH('"iat" claim timestamp check failed (too far in the past)',a,"iat","check_failed");if(e<0-o)throw new ej('"iat" claim timestamp check failed (it should be in the past)',a,"iat","check_failed")}return a}class t8{#l;constructor(e){if(!tT(e))throw TypeError("JWT Claims Set MUST be an object");this.#l=structuredClone(e)}data(){return ew.encode(JSON.stringify(this.#l))}get iss(){return this.#l.iss}set iss(e){this.#l.iss=e}get sub(){return this.#l.sub}set sub(e){this.#l.sub=e}get aud(){return this.#l.aud}set aud(e){this.#l.aud=e}set jti(e){this.#l.jti=e}set nbf(e){"number"==typeof e?this.#l.nbf=t2("setNotBefore",e):e instanceof Date?this.#l.nbf=t2("setNotBefore",tX(e)):this.#l.nbf=tX(new Date)+t1(e)}set exp(e){"number"==typeof e?this.#l.exp=t2("setExpirationTime",e):e instanceof Date?this.#l.exp=t2("setExpirationTime",tX(e)):this.#l.exp=tX(new Date)+t1(e)}set iat(e){void 0===e?this.#l.iat=tX(new Date):e instanceof Date?this.#l.iat=t2("setIssuedAt",tX(e)):"string"==typeof e?this.#l.iat=t2("setIssuedAt",tX(new Date)+t1(e)):this.#l.iat=t2("setIssuedAt",e)}}class t4{#a;#o;#s;#t;#d;#u;#p;#f;constructor(e={}){this.#f=new t8(e)}setIssuer(e){return this.#f.iss=e,this}setSubject(e){return this.#f.sub=e,this}setAudience(e){return this.#f.aud=e,this}setJti(e){return this.#f.jti=e,this}setNotBefore(e){return this.#f.nbf=e,this}setExpirationTime(e){return this.#f.exp=e,this}setIssuedAt(e){return this.#f.iat=e,this}setProtectedHeader(e){return eR(this.#t,"setProtectedHeader"),this.#t=e,this}setKeyManagementParameters(e){return eR(this.#s,"setKeyManagementParameters"),this.#s=e,this}setContentEncryptionKey(e){return eR(this.#a,"setContentEncryptionKey"),this.#a=e,this}setInitializationVector(e){return eR(this.#o,"setInitializationVector"),this.#o=e,this}replicateIssuerAsHeader(){return this.#d=!0,this}replicateSubjectAsHeader(){return this.#u=!0,this}replicateAudienceAsHeader(){return this.#p=!0,this}async encrypt(e,t){let r=new tY(this.#f.data());return this.#t&&(this.#d||this.#u||this.#p)&&(this.#t={...this.#t,iss:this.#d?this.#f.iss:void 0,sub:this.#u?this.#f.sub:void 0,aud:this.#p?this.#f.aud:void 0}),r.setProtectedHeader(this.#t),this.#o&&r.setInitializationVector(this.#o),this.#a&&r.setContentEncryptionKey(this.#a),this.#s&&r.setKeyManagementParameters(this.#s),r.encrypt(e,t)}}class t3{#l;#t;#n;constructor(e){if(!(e instanceof Uint8Array))throw TypeError("payload must be an instance of Uint8Array");this.#l=e}setProtectedHeader(e){return eR(this.#t,"setProtectedHeader"),this.#t=e,this}setUnprotectedHeader(e){return eR(this.#n,"setUnprotectedHeader"),this.#n=e,this}async sign(e,t){let r,n,i,a;if(!this.#t&&!this.#n)throw new eW("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!tR(this.#t,this.#n))throw new eW("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let o={...this.#t,...this.#n},s=tK(eW,new Map([["b64",!0]]),t?.crit,this.#t,o),c=!0;if(s.has("b64")&&"boolean"!=typeof(c=this.#t.b64))throw new eW('The "b64" (base64url-encode payload) Header Parameter must be a boolean');let{alg:l}=o;if("string"!=typeof l||!l)throw new eW('JWS "alg" (Algorithm) Header Parameter missing or invalid');tF(l,e,"sign"),c?n=e_(r=ex(this.#l)):(n=this.#l,r=""),this.#t?a=e_(i=ex(JSON.stringify(this.#t))):(i="",a=new Uint8Array);let d=eA(a,e_("."),n),u=await tD(e,l),p={signature:ex(await tv(l,u,d)),payload:r};return this.#n&&(p.header=this.#n),this.#t&&(p.protected=i),p}}class t9{#c;constructor(e){this.#c=new t3(e)}setProtectedHeader(e){return this.#c.setProtectedHeader(e),this}async sign(e,t){let r=await this.#c.sign(e,t);if(void 0===r.payload)throw TypeError("use the flattened module for creating JWS with b64: false");return`${r.protected}.${r.payload}.${r.signature}`}}class t7{#t;#f;constructor(e={}){this.#f=new t8(e)}setIssuer(e){return this.#f.iss=e,this}setSubject(e){return this.#f.sub=e,this}setAudience(e){return this.#f.aud=e,this}setJti(e){return this.#f.jti=e,this}setNotBefore(e){return this.#f.nbf=e,this}setExpirationTime(e){return this.#f.exp=e,this}setIssuedAt(e){return this.#f.iat=e,this}setProtectedHeader(e){return this.#t=e,this}async sign(e,t){let r=new t9(this.#f.data());if(r.setProtectedHeader(this.#t),Array.isArray(this.#t?.crit)&&this.#t.crit.includes("b64")&&!1===this.#t.b64)throw new eq("JWTs MUST NOT use unencoded payload");return r.sign(e,t)}}var re=e.i(797379),re=re;let rt=(e,t)=>{if("string"!=typeof e||!e)throw new eF(`${t} missing or invalid`)};async function rr(e,t){let r,n;if(tI(e))r=e;else if(e2(e))r=await t$(e);else throw TypeError(ez(e,"CryptoKey","KeyObject","JSON Web Key"));if("sha256"!==(t??="sha256")&&"sha384"!==t&&"sha512"!==t)throw TypeError('digestAlgorithm must one of "sha256", "sha384", or "sha512"');switch(r.kty){case"AKP":rt(r.alg,'"alg" (Algorithm) Parameter'),rt(r.pub,'"pub" (Public key) Parameter'),n={alg:r.alg,kty:r.kty,pub:r.pub};break;case"EC":rt(r.crv,'"crv" (Curve) Parameter'),rt(r.x,'"x" (X Coordinate) Parameter'),rt(r.y,'"y" (Y Coordinate) Parameter'),n={crv:r.crv,kty:r.kty,x:r.x,y:r.y};break;case"OKP":rt(r.crv,'"crv" (Subtype of Key Pair) Parameter'),rt(r.x,'"x" (Public Key) Parameter'),n={crv:r.crv,kty:r.kty,x:r.x};break;case"RSA":rt(r.e,'"e" (Exponent) Parameter'),rt(r.n,'"n" (Modulus) Parameter'),n={e:r.e,kty:r.kty,n:r.n};break;case"oct":rt(r.k,'"k" (Key Value) Parameter'),n={k:r.k,kty:r.kty};break;default:throw new eV('"kty" (Key Type) Parameter missing or unsupported')}let i=e_(JSON.stringify(n));return ex(await eU(t,i))}function rn(e){let t;if("string"==typeof e){let r=e.split(".");(3===r.length||5===r.length)&&([t]=r)}else if("object"==typeof e&&e)if("protected"in e)t=e.protected;else throw TypeError("Token does not contain a Protected Header");try{if("string"!=typeof t||!t)throw Error();let e=JSON.parse(eb.decode(eS(t)));if(!tT(e))throw Error();return e}catch{throw TypeError("Invalid Token or Protected Header formatting")}}function ri(e,t){if(void 0!==t&&(!Array.isArray(t)||t.some(e=>"string"!=typeof e)))throw TypeError(`"${e}" option must be an array of strings`);if(t)return new Set(t)}async function ra(e,t,r){let n,i,a,o,s,c;if(!tT(e))throw new eK("Flattened JWE must be an object");if(void 0===e.protected&&void 0===e.header&&void 0===e.unprotected)throw new eK("JOSE Header missing");if(void 0!==e.iv&&"string"!=typeof e.iv)throw new eK("JWE Initialization Vector incorrect type");if("string"!=typeof e.ciphertext)throw new eK("JWE Ciphertext missing or incorrect type");if(void 0!==e.tag&&"string"!=typeof e.tag)throw new eK("JWE Authentication Tag incorrect type");if(void 0!==e.protected&&"string"!=typeof e.protected)throw new eK("JWE Protected Header incorrect type");if(void 0!==e.encrypted_key&&"string"!=typeof e.encrypted_key)throw new eK("JWE Encrypted Key incorrect type");if(void 0!==e.aad&&"string"!=typeof e.aad)throw new eK("JWE AAD incorrect type");if(void 0!==e.header&&!tT(e.header))throw new eK("JWE Shared Unprotected Header incorrect type");if(void 0!==e.unprotected&&!tT(e.unprotected))throw new eK("JWE Per-Recipient Unprotected Header incorrect type");if(e.protected)try{let t=eS(e.protected);n=JSON.parse(eb.decode(t))}catch{throw new eK("JWE Protected Header is invalid")}if(!tR(n,e.header,e.unprotected))throw new eK("JWE Protected, JWE Unprotected Header, and JWE Per-Recipient Unprotected Header Parameter names must be disjoint");let l={...n,...e.header,...e.unprotected};if(tK(eK,new Map,r?.crit,n,l),void 0!==l.zip&&"DEF"!==l.zip)throw new eV('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');if(void 0!==l.zip&&!n?.zip)throw new eK('JWE "zip" (Compression Algorithm) Header Parameter MUST be in a protected header.');let{alg:d,enc:u}=l;if("string"!=typeof d||!d)throw new eK("missing JWE Algorithm (alg) in JWE Header");if("string"!=typeof u||!u)throw new eK("missing JWE Encryption Algorithm (enc) in JWE Header");let p=r&&ri("keyManagementAlgorithms",r.keyManagementAlgorithms),f=r&&ri("contentEncryptionAlgorithms",r.contentEncryptionAlgorithms);if(p&&!p.has(d)||!p&&d.startsWith("PBES2"))throw new eB('"alg" (Algorithm) Header Parameter value not allowed');if(f&&!f.has(u))throw new eB('"enc" (Encryption Algorithm) Header Parameter value not allowed');void 0!==e.encrypted_key&&(i=eI(e.encrypted_key,"encrypted_key",eK));let h=!1;"function"==typeof t&&(t=await t(n,e),h=!0),tF("dir"===d?u:d,t,"decrypt");let m=await tD(t,d);try{a=await tV(d,m,i,l,r)}catch(e){if(e instanceof TypeError||e instanceof eK||e instanceof eV)throw e;a=e5(u)}void 0!==e.iv&&(o=eI(e.iv,"iv",eK)),void 0!==e.tag&&(s=eI(e.tag,"tag",eK));let y=void 0!==e.protected?e_(e.protected):new Uint8Array;c=void 0!==e.aad?eA(y,e_("."),e_(e.aad)):y;let g=eI(e.ciphertext,"ciphertext",eK),w=await ts(u,a,g,o,s,c),b={plaintext:w};if("DEF"===l.zip){let e=r?.maxDecompressedLength??25e4;if(0===e)throw new eV('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');if(e!==1/0&&(!Number.isSafeInteger(e)||e<1))throw TypeError("maxDecompressedLength must be 0, a positive safe integer, or Infinity");b.plaintext=await tG(w,e).catch(e=>{if(e instanceof eK)throw e;throw new eK("Failed to decompress plaintext",{cause:e})})}return(void 0!==e.protected&&(b.protectedHeader=n),void 0!==e.aad&&(b.additionalAuthenticatedData=eI(e.aad,"aad",eK)),void 0!==e.unprotected&&(b.sharedUnprotectedHeader=e.unprotected),void 0!==e.header&&(b.unprotectedHeader=e.header),h)?{...b,key:m}:b}async function ro(e,t,r){if(e instanceof Uint8Array&&(e=eb.decode(e)),"string"!=typeof e)throw new eK("Compact JWE must be a string or Uint8Array");let{0:n,1:i,2:a,3:o,4:s,length:c}=e.split(".");if(5!==c)throw new eK("Invalid Compact JWE");let l=await ra({ciphertext:o,iv:a||void 0,protected:n,tag:s||void 0,encrypted_key:i||void 0},t,r),d={plaintext:l.plaintext,protectedHeader:l.protectedHeader};return"function"==typeof t?{...d,key:l.key}:d}async function rs(e,t,r){let n=await ro(e,t,r),i=t5(n.protectedHeader,n.plaintext,r),{protectedHeader:a}=n;if(void 0!==a.iss&&a.iss!==i.iss)throw new ej('replicated "iss" claim header parameter mismatch',i,"iss","mismatch");if(void 0!==a.sub&&a.sub!==i.sub)throw new ej('replicated "sub" claim header parameter mismatch',i,"sub","mismatch");if(void 0!==a.aud&&JSON.stringify(a.aud)!==JSON.stringify(i.aud))throw new ej('replicated "aud" claim header parameter mismatch',i,"aud","mismatch");let o={payload:i,protectedHeader:a};return"function"==typeof t?{...o,key:n.key}:o}async function rc(e,t,r){if(!tT(e))throw new eW("Flattened JWS must be an object");if(void 0===e.protected&&void 0===e.header)throw new eW('Flattened JWS must have either of the "protected" or "header" members');if(void 0!==e.protected&&"string"!=typeof e.protected)throw new eW("JWS Protected Header incorrect type");if(void 0===e.payload)throw new eW("JWS Payload missing");if("string"!=typeof e.signature)throw new eW("JWS Signature missing or incorrect type");if(void 0!==e.header&&!tT(e.header))throw new eW("JWS Unprotected Header incorrect type");let n={};if(e.protected)try{let t=eS(e.protected);n=JSON.parse(eb.decode(t))}catch{throw new eW("JWS Protected Header is invalid")}if(!tR(n,e.header))throw new eW("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let i={...n,...e.header},a=tK(eW,new Map([["b64",!0]]),r?.crit,n,i),o=!0;if(a.has("b64")&&"boolean"!=typeof(o=n.b64))throw new eW('The "b64" (base64url-encode payload) Header Parameter must be a boolean');let{alg:s}=i;if("string"!=typeof s||!s)throw new eW('JWS "alg" (Algorithm) Header Parameter missing or invalid');let c=r&&ri("algorithms",r.algorithms);if(c&&!c.has(s))throw new eB('"alg" (Algorithm) Header Parameter value not allowed');if(o){if("string"!=typeof e.payload)throw new eW("JWS Payload must be a string")}else if("string"!=typeof e.payload&&!(e.payload instanceof Uint8Array))throw new eW("JWS Payload must be a string or an Uint8Array instance");let l=!1;"function"==typeof t&&(t=await t(n,e),l=!0),tF(s,t,"verify");let d=eA(void 0!==e.protected?e_(e.protected):new Uint8Array,e_("."),"string"==typeof e.payload?o?e_(e.payload):ew.encode(e.payload):e.payload),u=eI(e.signature,"signature",eW),p=await tD(t,s);if(!await tk(s,p,u,d))throw new eY;let f={payload:o?eI(e.payload,"payload",eW):"string"==typeof e.payload?ew.encode(e.payload):e.payload};return(void 0!==e.protected&&(f.protectedHeader=n),void 0!==e.header&&(f.unprotectedHeader=e.header),l)?{...f,key:p}:f}async function rl(e,t,r){if(e instanceof Uint8Array&&(e=eb.decode(e)),"string"!=typeof e)throw new eW("Compact JWS must be a string or Uint8Array");let{0:n,1:i,2:a,length:o}=e.split(".");if(3!==o)throw new eW("Invalid Compact JWS");let s=await rc({payload:i,protected:n,signature:a},t,r),c={payload:s.payload,protectedHeader:s.protectedHeader};return"function"==typeof t?{...c,key:s.key}:c}async function rd(e,t,r){let n=await rl(e,t,r);if(n.protectedHeader.crit?.includes("b64")&&!1===n.protectedHeader.b64)throw new eq("JWTs MUST NOT use unencoded payload");let i={payload:t5(n.protectedHeader,n.payload,r),protectedHeader:n.protectedHeader};return"function"==typeof t?{...i,key:n.key}:i}async function ru(e,t,r=3600){return await new t7(e).setProtectedHeader({alg:"HS256"}).setIssuedAt().setExpirationTime(Math.floor(Date.now()/1e3)+r).sign(new TextEncoder().encode(t))}async function rp(e,t){try{return(await rd(e,new TextEncoder().encode(t))).payload}catch{return null}}let rf=new Uint8Array([66,101,116,116,101,114,65,117,116,104,46,106,115,32,71,101,110,101,114,97,116,101,100,32,69,110,99,114,121,112,116,105,111,110,32,75,101,121]),rh="A256CBC-HS512";function rm(e,t){var r,n,i;return r=new TextEncoder().encode(e),n=new TextEncoder().encode(t),function(e,t,r,n=32){W(e),M(n,"length"),K(t,void 0,"prk");let i=e.outputLen;if(t.length<i)throw Error('"prk" must be at least HashLen octets');if(n>255*i)throw Error("Length must be <= 255*HashLen");let a=Math.ceil(n/i);void 0===r?r=ee:K(r,void 0,"info");let o=new Uint8Array(a*i),s=Y.create(e,t),c=s._cloneInto(),l=new Uint8Array(s.outputLen);for(let e=0;e<a;e++)X[0]=e+1,c.update(0===e?ee:l).update(r).update(X).digestInto(l),o.set(l,i*e),s._cloneInto(c);return s.destroy(),c.destroy(),J(l,X),o.slice(0,n)}(eg,(i=n,W(eg),void 0===i&&(i=new Uint8Array(eg.outputLen)),Y(eg,i,r)),rf,64)}function ry(e){if("string"==typeof e)return[{version:0,value:e}];let t=[];for(let[r,n]of e.keys)t.push({version:r,value:n});return e.legacySecret&&!t.some(t=>t.value===e.legacySecret)&&t.push({version:-1,value:e.legacySecret}),t}async function rg(e,t,r,n=3600){let i=rm(function(e){if("string"==typeof e)return e;let t=e.keys.get(e.currentVersion);if(!t)throw Error(`Secret version ${e.currentVersion} not found in keys`);return t}(t),r),a=await rr({kty:"oct",k:re.encode(i)},"sha256");return await new t4(e).setProtectedHeader({alg:"dir",enc:rh,kid:a}).setIssuedAt().setExpirationTime((Date.now()/1e3|0)+n).setJti(crypto.randomUUID()).encrypt(i)}let rw={clockTolerance:15,keyManagementAlgorithms:["dir"],contentEncryptionAlgorithms:[rh,"A256GCM"]};async function rb(e,t,r){if(!e)return null;let n=!1;try{n=void 0!==rn(e).kid}catch{return null}try{let n=ry(t),{payload:i}=await rs(e,async e=>{let t=e.kid;if(void 0!==t){for(let e of n){let n=rm(e.value,r);if(t===await rr({kty:"oct",k:re.encode(n)},"sha256"))return n}throw Error("no matching decryption secret")}return n.length,rm(n[0].value,r)},rw);return i}catch{if(n)return null;let i=ry(t);if(i.length<=1)return null;for(let t=1;t<i.length;t++)try{let n=i[t],{payload:a}=await rs(e,rm(n.value,r),rw);return a}catch{continue}return null}}var rA=e.i(163738);function rE(e,t){if(!e||!t)return e;let r=Object.entries(t).filter(([,{returned:e}])=>!1===e).map(([e])=>e);return Object.entries(structuredClone(e)).filter(([e])=>!r.includes(e)).reduce((e,[t,r])=>({...e,[t]:r}),{})}let rv=new WeakMap;function rk(e,t,r){let n=`${t}:${r}`;rv.has(e)||rv.set(e,new Map);let i=rv.get(e);if(i.has(n))return i.get(n);let a="output"===r?(0,w.getAuthTables)(e)[t]?.fields??{}:{},o="user"===t||"session"===t||"account"===t?e[t]?.additionalFields:void 0,s={...a,...o??{}};for(let r of e.plugins||[])r.schema&&r.schema[t]&&(s={...s,...r.schema[t].fields});return i.set(n,s),s}function r_(e,t){return rE(t,rk(e,"user","output"))}function rS(e,t){let r=rk(e,"user","output"),n={};for(let e in r){let i=r[e];!1!==i.returned&&(e in t&&void 0!==t[e]?n[e]=t[e]:void 0!==i.defaultValue?n[e]="function"==typeof i.defaultValue?i.defaultValue():i.defaultValue:i.required||(n[e]=null))}return"id"in t&&(n.id=t.id),n}function rx(e,t){return rE(t,rk(e,"session","output"))}function rT(e,t){let r=t.action||"create",n=t.fields,i=Object.create(null);for(let t in n){if(t in e){if(!1===n[t].input){if(void 0!==n[t].defaultValue&&"update"!==r){i[t]=n[t].defaultValue;continue}if(e[t])throw E.APIError.from("BAD_REQUEST",{...rA.BASE_ERROR_CODES.FIELD_NOT_ALLOWED,message:`${t} is not allowed to be set`});continue}if(n[t].validator?.input&&void 0!==e[t]){let r=n[t].validator.input["~standard"].validate(e[t]);if(r instanceof Promise)throw E.APIError.from("INTERNAL_SERVER_ERROR",rA.BASE_ERROR_CODES.ASYNC_VALIDATION_NOT_SUPPORTED);if("issues"in r&&r.issues)throw E.APIError.from("BAD_REQUEST",{...rA.BASE_ERROR_CODES.VALIDATION_ERROR,message:r.issues[0]?.message||"Validation Error"});i[t]=r.value;continue}if(n[t].transform?.input&&void 0!==e[t]){i[t]=n[t].transform?.input(e[t]);continue}i[t]=e[t];continue}if(void 0!==n[t].defaultValue&&"create"===r){if("function"==typeof n[t].defaultValue){i[t]=n[t].defaultValue();continue}i[t]=n[t].defaultValue;continue}if(n[t].required&&"create"===r)throw E.APIError.from("BAD_REQUEST",{...rA.BASE_ERROR_CODES.MISSING_FIELD,message:`${t} is required`})}return i}function rR(e,t={},r){return rT(t,{fields:rk(e,"user","input"),action:r})}let rI=(e,t="ms")=>new Date(Date.now()+("sec"===t?1e3*e:e)),rU=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|months?|mo|years?|yrs?|y)(?: (ago|from now))?$/i;function rO(e){if(-1===e.indexOf("%"))return e;try{return decodeURIComponent(e)}catch{return e}}function rP(e){if(!e)return[];let t=[],r=0,n=0;for(;n<e.length;){if(","===e[n]){let i=n+1;for(;i<e.length&&" "===e[i];)i++;for(;i<e.length&&"="!==e[i]&&";"!==e[i]&&","!==e[i];)i++;if(i<e.length&&"="===e[i]){let i=e.slice(r,n).trim();for(i&&t.push(i),r=n+1;r<e.length&&" "===e[r];)r++;n=r;continue}}n++}let i=e.slice(r).trim();return i&&t.push(i),t}let rC=/^[\w!#$%&'*.^`|~+-]+$/,rD=/^[ !#-:<-[\]-~]*$/;function rL(e){return!(e.length<2)&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}function rz(e){let t=0,r=e.length;for(;t<r;){let r=e.charCodeAt(t);if(32!==r&&9!==r)break;t++}for(;r>t;){let t=e.charCodeAt(r-1);if(32!==t&&9!==t)break;r--}return 0===t&&r===e.length?e:e.slice(t,r)}function r$(e){let t=new Map;if(e.length<2)return t;for(let r of e.split(";")){let e=r.indexOf("=");if(-1===e)continue;let n=rz(r.slice(0,e)),i=rL(rz(r.slice(e+1)));rC.test(n)&&rD.test(i)&&t.set(n,rO(i))}return t}var rN=e.i(858544);function rj(e,t,r){function n(r,n){if(r._zod||Object.defineProperty(r,"_zod",{value:{def:n,constr:o,traits:new Set},enumerable:!1}),r._zod.traits.has(e))return;r._zod.traits.add(e),t(r,n);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in r||(r[t]=i[t].bind(r))}}let i=r?.Parent??Object;class a extends i{}function o(e){var t;let i=r?.Parent?new a:this;for(let r of(n(i,e),(t=i._zod).deferred??(t.deferred=[]),i._zod.deferred))r();return i}return Object.defineProperty(a,"name",{value:e}),Object.defineProperty(o,"init",{value:n}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>!!r?.Parent&&t instanceof r.Parent||t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}Symbol("zod_brand");class rH extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class rB extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(y=globalThis).__zod_globalConfig??(y.__zod_globalConfig={});let rV=globalThis.__zod_globalConfig;function rM(e){return e&&Object.assign(rV,e),rV}function rK(e){let t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,r])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function rW(e,t){return"bigint"==typeof t?t.toString():t}function rq(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function rF(e){return null==e}function rJ(e){let t=+!!e.startsWith("^"),r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function rZ(e,t){let r=e/t,n=Math.round(r),i=Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<i?0:r-n}let rG=Symbol("evaluating");function rQ(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==rG)return void 0===n&&(n=rG,n=r()),n},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function rY(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function rX(...e){let t={};for(let r of e)Object.assign(t,Object.getOwnPropertyDescriptors(r));return Object.defineProperties({},t)}function r0(e){return JSON.stringify(e)}function r1(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}let r2="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function r6(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}let r5=rq(()=>{if(rV.jitless||"u">typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return Function(""),!0}catch(e){return!1}});function r8(e){if(!1===r6(e))return!1;let t=e.constructor;if(void 0===t||"function"!=typeof t)return!0;let r=t.prototype;return!1!==r6(r)&&!1!==Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")}let r4=new Set(["string","number","symbol"]),r3=new Set(["string","number","bigint","boolean","symbol","undefined"]);function r9(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function r7(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function ne(e){if(!e)return{};if("string"==typeof e)return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");e.error=e.message}return(delete e.message,"string"==typeof e.error)?{...e,error:()=>e.error}:e}function nt(e){return"bigint"==typeof e?e.toString()+"n":"string"==typeof e?`"${e}"`:`${e}`}function nr(e){return Object.keys(e).filter(t=>"optional"===e[t]._zod.optin&&"optional"===e[t]._zod.optout)}let nn={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-0x80000000,0x7fffffff],uint32:[0,0xffffffff],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},ni={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function na(e,t=0){if(!0===e.aborted)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function no(e,t=0){if(!0===e.aborted)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function ns(e,t){return t.map(t=>(t.path??(t.path=[]),t.path.unshift(e),t))}function nc(e){return"string"==typeof e?e:e?.message}function nl(e,t,r){let n=e.message?e.message:nc(e.inst?._zod.def?.error?.(e))??nc(t?.error?.(e))??nc(r.customError?.(e))??nc(r.localeError?.(e))??"Invalid input",{inst:i,continue:a,input:o,...s}=e;return s.path??(s.path=[]),s.message=n,t?.reportInput&&(s.input=o),s}function nd(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function nu(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function np(...e){let[t,r,n]=e;return"string"==typeof t?{message:t,code:"custom",input:r,inst:n}:{...t}}function nf(e){let t=atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return r}function nh(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}e.s(["BIGINT_FORMAT_RANGES",0,ni,"Class",0,class{constructor(...e){}},"NUMBER_FORMAT_RANGES",0,nn,"aborted",0,na,"allowsEval",0,r5,"assert",0,function(e){},"assertEqual",0,function(e){return e},"assertIs",0,function(e){},"assertNever",0,function(e){throw Error("Unexpected value in exhaustive check")},"assertNotEqual",0,function(e){return e},"assignProp",0,rY,"base64ToUint8Array",0,nf,"base64urlToUint8Array",0,function(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return nf(t+r)},"cached",0,rq,"captureStackTrace",0,r2,"cleanEnum",0,function(e){return Object.entries(e).filter(([e,t])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])},"cleanRegex",0,rJ,"clone",0,r7,"cloneDef",0,function(e){return rX(e._zod.def)},"createTransparentProxy",0,function(e){let t;return new Proxy({},{get:(r,n,i)=>(t??(t=e()),Reflect.get(t,n,i)),set:(r,n,i,a)=>(t??(t=e()),Reflect.set(t,n,i,a)),has:(r,n)=>(t??(t=e()),Reflect.has(t,n)),deleteProperty:(r,n)=>(t??(t=e()),Reflect.deleteProperty(t,n)),ownKeys:r=>(t??(t=e()),Reflect.ownKeys(t)),getOwnPropertyDescriptor:(r,n)=>(t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)),defineProperty:(r,n,i)=>(t??(t=e()),Reflect.defineProperty(t,n,i))})},"defineLazy",0,rQ,"esc",0,r0,"escapeRegex",0,r9,"explicitlyAborted",0,no,"extend",0,function(e,t){if(!r8(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let r=e._zod.def.shape;for(let e in t)if(void 0!==Object.getOwnPropertyDescriptor(r,e))throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let n=rX(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return rY(this,"shape",r),r}});return r7(e,n)},"finalizeIssue",0,nl,"floatSafeRemainder",0,rZ,"getElementAtPath",0,function(e,t){return t?t.reduce((e,t)=>e?.[t],e):e},"getEnumValues",0,rK,"getLengthableOrigin",0,nu,"getParsedType",0,e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray(e))return"array";if(null===e)return"null";if(e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch)return"promise";if("u">typeof Map&&e instanceof Map)return"map";if("u">typeof Set&&e instanceof Set)return"set";if("u">typeof Date&&e instanceof Date)return"date";if("u">typeof File&&e instanceof File)return"file";return"object";default:throw Error(`Unknown data type: ${t}`)}},"getSizableOrigin",0,nd,"hexToUint8Array",0,function(e){let t=e.replace(/^0x/,"");if(t.length%2!=0)throw Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let e=0;e<t.length;e+=2)r[e/2]=Number.parseInt(t.slice(e,e+2),16);return r},"isObject",0,r6,"isPlainObject",0,r8,"issue",0,np,"joinValues",0,function(e,t="|"){return e.map(e=>nt(e)).join(t)},"jsonStringifyReplacer",0,rW,"merge",0,function(e,t){if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=rX(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return rY(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return r7(e,r)},"mergeDefs",0,rX,"normalizeParams",0,ne,"nullish",0,rF,"numKeys",0,function(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t},"objectClone",0,function(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))},"omit",0,function(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let i=rX(e._zod.def,{get shape(){let n={...e._zod.def.shape};for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete n[e]}return rY(this,"shape",n),n},checks:[]});return r7(e,i)},"optionalKeys",0,nr,"parsedType",0,function(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":if(null===e)return"null";if(Array.isArray(e))return"array";if(e&&Object.getPrototypeOf(e)!==Object.prototype&&"constructor"in e&&e.constructor)return e.constructor.name}return t},"partial",0,function(e,t,r){let n=t._zod.def.checks;if(n&&n.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let i=rX(t._zod.def,{get shape(){let n=t._zod.def.shape,i={...n};if(r)for(let t in r){if(!(t in n))throw Error(`Unrecognized key: "${t}"`);r[t]&&(i[t]=e?new e({type:"optional",innerType:n[t]}):n[t])}else for(let t in n)i[t]=e?new e({type:"optional",innerType:n[t]}):n[t];return rY(this,"shape",i),i},checks:[]});return r7(t,i)},"pick",0,function(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let i=rX(e._zod.def,{get shape(){let e={};for(let n in t){if(!(n in r.shape))throw Error(`Unrecognized key: "${n}"`);t[n]&&(e[n]=r.shape[n])}return rY(this,"shape",e),e},checks:[]});return r7(e,i)},"prefixIssues",0,ns,"primitiveTypes",0,r3,"promiseAllObject",0,function(e){let t=Object.keys(e);return Promise.all(t.map(t=>e[t])).then(e=>{let r={};for(let n=0;n<t.length;n++)r[t[n]]=e[n];return r})},"propertyKeyTypes",0,r4,"randomString",0,function(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r},"required",0,function(e,t,r){let n=rX(t._zod.def,{get shape(){let n=t._zod.def.shape,i={...n};if(r)for(let t in r){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);r[t]&&(i[t]=new e({type:"nonoptional",innerType:n[t]}))}else for(let t in n)i[t]=new e({type:"nonoptional",innerType:n[t]});return rY(this,"shape",i),i}});return r7(t,n)},"safeExtend",0,function(e,t){if(!r8(t))throw Error("Invalid input to safeExtend: expected a plain object");let r=rX(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return rY(this,"shape",r),r}});return r7(e,r)},"shallowClone",0,function(e){return r8(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e},"slugify",0,r1,"stringifyPrimitive",0,nt,"uint8ArrayToBase64",0,nh,"uint8ArrayToBase64url",0,function(e){return nh(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},"uint8ArrayToHex",0,function(e){return Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")},"unwrapMessage",0,nc],202721);let nm=/^[cC][0-9a-z]{6,}$/,ny=/^[0-9a-z]+$/,ng=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,nw=/^[0-9a-vA-V]{20}$/,nb=/^[A-Za-z0-9]{27}$/,nA=/^[a-zA-Z0-9_-]{21}$/,nE=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,nv=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,nk=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,n_=nk(4),nS=nk(6),nx=nk(7),nT=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,nR=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u;function nI(){return RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")}let nU=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,nO=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,nP=e=>{let t=r9(e??":");return RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},nC=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,nD=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,nL=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,nz=/^[A-Za-z0-9_-]*$/,n$=/^https?$/,nN=/^\+[1-9]\d{6,14}$/,nj="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",nH=RegExp(`^${nj}$`);function nB(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function nV(e){return RegExp(`^${nB(e)}$`)}function nM(e){let t=nB({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${t}(?:${r.join("|")})`;return RegExp(`^${nj}T(?:${n})$`)}let nK=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return RegExp(`^${t}$`)},nW=/^-?\d+n?$/,nq=/^-?\d+$/,nF=/^-?\d+(?:\.\d+)?$/,nJ=/^(?:true|false)$/i,nZ=/^null$/i,nG=/^undefined$/i,nQ=/^[^A-Z]*$/,nY=/^[^a-z]*$/;function nX(e,t){return RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function n0(e){return RegExp(`^[A-Za-z0-9_-]{${e}}$`)}let n1=nX(22,"=="),n2=n0(22),n6=nX(27,"="),n5=n0(27),n8=nX(43,"="),n4=n0(43),n3=nX(64,""),n9=n0(64),n7=nX(86,"=="),ie=n0(86);e.s(["base64",0,nL,"base64url",0,nz,"bigint",0,nW,"boolean",0,nJ,"browserEmail",0,/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,"cidrv4",0,nC,"cidrv6",0,nD,"cuid",0,nm,"cuid2",0,ny,"date",0,nH,"datetime",0,nM,"domain",0,/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,"duration",0,nE,"e164",0,nN,"email",0,nT,"emoji",0,nI,"extendedDuration",0,/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,"guid",0,nv,"hex",0,/^[0-9a-fA-F]*$/,"hostname",0,/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,"html5Email",0,/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,"httpProtocol",0,n$,"idnEmail",0,nR,"integer",0,nq,"ipv4",0,nU,"ipv6",0,nO,"ksuid",0,nb,"lowercase",0,nQ,"mac",0,nP,"md5_base64",0,n1,"md5_base64url",0,n2,"md5_hex",0,/^[0-9a-fA-F]{32}$/,"nanoid",0,nA,"null",0,nZ,"number",0,nF,"rfc5322Email",0,/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,"sha1_base64",0,n6,"sha1_base64url",0,n5,"sha1_hex",0,/^[0-9a-fA-F]{40}$/,"sha256_base64",0,n8,"sha256_base64url",0,n4,"sha256_hex",0,/^[0-9a-fA-F]{64}$/,"sha384_base64",0,n3,"sha384_base64url",0,n9,"sha384_hex",0,/^[0-9a-fA-F]{96}$/,"sha512_base64",0,n7,"sha512_base64url",0,ie,"sha512_hex",0,/^[0-9a-fA-F]{128}$/,"string",0,nK,"time",0,nV,"ulid",0,ng,"undefined",0,nG,"unicodeEmail",0,nR,"uppercase",0,nY,"uuid",0,nk,"uuid4",0,n_,"uuid6",0,nS,"uuid7",0,nx,"xid",0,nw],110107);let it=rj("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),ir={number:"number",bigint:"bigint",object:"date"},ii=rj("$ZodCheckLessThan",(e,t)=>{it.init(e,t);let r=ir[typeof t.value];e._zod.onattach.push(e=>{let r=e._zod.bag,n=(t.inclusive?r.maximum:r.exclusiveMaximum)??1/0;t.value<n&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:"object"==typeof t.value?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ia=rj("$ZodCheckGreaterThan",(e,t)=>{it.init(e,t);let r=ir[typeof t.value];e._zod.onattach.push(e=>{let r=e._zod.bag,n=(t.inclusive?r.minimum:r.exclusiveMinimum)??-1/0;t.value>n&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:"object"==typeof t.value?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),io=rj("$ZodCheckMultipleOf",(e,t)=>{it.init(e,t),e._zod.onattach.push(e=>{var r;(r=e._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof r.value?r.value%t.value===BigInt(0):0===rZ(r.value,t.value))||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),is=rj("$ZodCheckNumberFormat",(e,t)=>{it.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[i,a]=nn[t.format];e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,n.minimum=i,n.maximum=a,r&&(n.pattern=nq)}),e._zod.check=o=>{let s=o.value;if(r){if(!Number.isInteger(s))return void o.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});if(!Number.isSafeInteger(s))return void(s>0?o.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}))}s<i&&o.issues.push({origin:"number",input:s,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:"number",input:s,code:"too_big",maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),ic=rj("$ZodCheckBigIntFormat",(e,t)=>{it.init(e,t);let[r,n]=ni[t.format];e._zod.onattach.push(e=>{let i=e._zod.bag;i.format=t.format,i.minimum=r,i.maximum=n}),e._zod.check=i=>{let a=i.value;a<r&&i.issues.push({origin:"bigint",input:a,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),a>n&&i.issues.push({origin:"bigint",input:a,code:"too_big",maximum:n,inclusive:!0,inst:e,continue:!t.abort})}}),il=rj("$ZodCheckMaxSize",(e,t)=>{var r;it.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return!rF(t)&&void 0!==t.size}),e._zod.onattach.push(e=>{let r=e._zod.bag.maximum??1/0;t.maximum<r&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{let n=r.value;n.size<=t.maximum||r.issues.push({origin:nd(n),code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),id=rj("$ZodCheckMinSize",(e,t)=>{var r;it.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return!rF(t)&&void 0!==t.size}),e._zod.onattach.push(e=>{let r=e._zod.bag.minimum??-1/0;t.minimum>r&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{let n=r.value;n.size>=t.minimum||r.issues.push({origin:nd(n),code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),iu=rj("$ZodCheckSizeEquals",(e,t)=>{var r;it.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return!rF(t)&&void 0!==t.size}),e._zod.onattach.push(e=>{let r=e._zod.bag;r.minimum=t.size,r.maximum=t.size,r.size=t.size}),e._zod.check=r=>{let n=r.value,i=n.size;if(i===t.size)return;let a=i>t.size;r.issues.push({origin:nd(n),...a?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),ip=rj("$ZodCheckMaxLength",(e,t)=>{var r;it.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return!rF(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{let r=e._zod.bag.maximum??1/0;t.maximum<r&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{let n=r.value;if(n.length<=t.maximum)return;let i=nu(n);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),ih=rj("$ZodCheckMinLength",(e,t)=>{var r;it.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return!rF(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{let r=e._zod.bag.minimum??-1/0;t.minimum>r&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{let n=r.value;if(n.length>=t.minimum)return;let i=nu(n);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),im=rj("$ZodCheckLengthEquals",(e,t)=>{var r;it.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return!rF(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{let r=e._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=r=>{let n=r.value,i=n.length;if(i===t.length)return;let a=nu(n),o=i>t.length;r.issues.push({origin:a,...o?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),iy=rj("$ZodCheckStringFormat",(e,t)=>{var r,n;it.init(e,t),e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,t.pattern&&(r.patterns??(r.patterns=new Set),r.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),ig=rj("$ZodCheckRegex",(e,t)=>{iy.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),iw=rj("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=nQ),iy.init(e,t)}),ib=rj("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=nY),iy.init(e,t)}),iA=rj("$ZodCheckIncludes",(e,t)=>{it.init(e,t);let r=r9(t.includes),n=new RegExp("number"==typeof t.position?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),iE=rj("$ZodCheckStartsWith",(e,t)=>{it.init(e,t);let r=RegExp(`^${r9(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),iv=rj("$ZodCheckEndsWith",(e,t)=>{it.init(e,t);let r=RegExp(`.*${r9(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});(e,t)=>{it.init(e,t);let r=new Set(t.mime);e._zod.onattach.push(e=>{e._zod.bag.mime=t.mime}),e._zod.check=n=>{r.has(n.value.type)||n.issues.push({code:"invalid_value",values:t.mime,input:n.value.type,inst:e,continue:!t.abort})}};let ik=rj("$ZodCheckOverwrite",(e,t)=>{it.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class i_{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let t=e.split("\n").filter(e=>e),r=Math.min(...t.map(e=>e.length-e.trimStart().length));for(let e of t.map(e=>e.slice(r)).map(e=>" ".repeat(2*this.indent)+e))this.content.push(e)}compile(){return Function(...this?.args,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}}let iS=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,rW,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},ix=rj("$ZodError",iS),iT=rj("$ZodError",iS,{Parent:Error}),iR=e=>(t,r,n,i)=>{let a=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},a);if(o instanceof Promise)throw new rH;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>nl(e,a,rM())));throw r2(t,i?.callee),t}return o.value},iI=iR(iT),iU=e=>async(t,r,n,i)=>{let a=n?{...n,async:!0}:{async:!0},o=t._zod.run({value:r,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>nl(e,a,rM())));throw r2(t,i?.callee),t}return o.value},iO=iU(iT),iP=e=>(t,r,n)=>{let i=n?{...n,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},i);if(a instanceof Promise)throw new rH;return a.issues.length?{success:!1,error:new(e??ix)(a.issues.map(e=>nl(e,i,rM())))}:{success:!0,data:a.value}},iC=iP(iT),iD=e=>async(t,r,n)=>{let i=n?{...n,async:!0}:{async:!0},a=t._zod.run({value:r,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>nl(e,i,rM())))}:{success:!0,data:a.value}},iL=iD(iT),iz={major:4,minor:4,patch:3},i$=rj("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=iz;let n=[...e._zod.def.checks??[]];for(let t of(e._zod.traits.has("$ZodCheck")&&n.unshift(e),n))for(let r of t._zod.onattach)r(e);if(0===n.length)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,r)=>{let n,i=na(e);for(let a of t){if(a._zod.def.when){if(no(e)||!a._zod.def.when(e))continue}else if(i)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&r?.async===!1)throw new rH;if(n||o instanceof Promise)n=(n??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(i||(i=na(e,t)))});else{if(e.issues.length===t)continue;i||(i=na(e,t))}}return n?n.then(()=>e):e},r=(r,i,a)=>{if(na(r))return r.aborted=!0,r;let o=t(i,n,a);if(o instanceof Promise){if(!1===a.async)throw new rH;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if("backward"===a.direction){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>r(e,i,a)):r(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(!1===a.async)throw new rH;return o.then(e=>t(e,n,a))}return t(o,n,a)}}rQ(e,"~standard",()=>({validate:t=>{try{let r=iC(e,t);return r.success?{value:r.data}:{issues:r.error?.issues}}catch(r){return iL(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),iN=rj("$ZodString",(e,t)=>{i$.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??nK(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch(e){}return"string"==typeof r.value||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),ij=rj("$ZodStringFormat",(e,t)=>{iy.init(e,t),iN.init(e,t)}),iH=rj("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=nv),ij.init(e,t)}),iB=rj("$ZodUUID",(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=nk(e))}else t.pattern??(t.pattern=nk());ij.init(e,t)}),iV=rj("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=nT),ij.init(e,t)}),iM=rj("$ZodURL",(e,t)=>{ij.init(e,t),e._zod.check=r=>{try{let n=r.value.trim();if(!t.normalize&&t.protocol?.source===n$.source&&!/^https?:\/\//i.test(n))return void r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});let i=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=i.href:r.value=n;return}catch(n){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),iK=rj("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=nI()),ij.init(e,t)}),iW=rj("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=nA),ij.init(e,t)}),iq=rj("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=nm),ij.init(e,t)}),iF=rj("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ny),ij.init(e,t)}),iJ=rj("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ng),ij.init(e,t)}),iZ=rj("$ZodXID",(e,t)=>{t.pattern??(t.pattern=nw),ij.init(e,t)}),iG=rj("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=nb),ij.init(e,t)}),iQ=rj("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=nM(t)),ij.init(e,t)}),iY=rj("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=nH),ij.init(e,t)}),iX=rj("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=nV(t)),ij.init(e,t)}),i0=rj("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=nE),ij.init(e,t)}),i1=rj("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=nU),ij.init(e,t),e._zod.bag.format="ipv4"}),i2=rj("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=nO),ij.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),i6=((e,t)=>{t.pattern??(t.pattern=nP(t.delimiter)),ij.init(e,t),e._zod.bag.format="mac"},rj("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=nC),ij.init(e,t)})),i5=rj("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=nD),ij.init(e,t),e._zod.check=r=>{let n=r.value.split("/");try{if(2!==n.length)throw Error();let[e,t]=n;if(!t)throw Error();let r=Number(t);if(`${r}`!==t||r<0||r>128)throw Error();new URL(`http://[${e}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function i8(e){if(""===e)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let i4=rj("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=nL),ij.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{i8(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),i3=rj("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=nz),ij.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{!function(e){if(!nz.test(e))return!1;let t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return i8(t.padEnd(4*Math.ceil(t.length/4),"="))}(r.value)&&r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),i9=rj("$ZodE164",(e,t)=>{t.pattern??(t.pattern=nN),ij.init(e,t)}),i7=rj("$ZodJWT",(e,t)=>{ij.init(e,t),e._zod.check=r=>{!function(e,t=null){try{let r=e.split(".");if(3!==r.length)return!1;let[n]=r;if(!n)return!1;let i=JSON.parse(atob(n));if("typ"in i&&i?.typ!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))return!1;return!0}catch{return!1}}(r.value,t.alg)&&r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),ae=((e,t)=>{ij.init(e,t),e._zod.check=r=>{t.fn(r.value)||r.issues.push({code:"invalid_format",format:t.format,input:r.value,inst:e,continue:!t.abort})}},rj("$ZodNumber",(e,t)=>{i$.init(e,t),e._zod.pattern=e._zod.bag.pattern??nF,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch(e){}let i=r.value;if("number"==typeof i&&!Number.isNaN(i)&&Number.isFinite(i))return r;let a="number"==typeof i?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...a?{received:a}:{}}),r}})),at=rj("$ZodNumberFormat",(e,t)=>{is.init(e,t),ae.init(e,t)}),ar=rj("$ZodBoolean",(e,t)=>{i$.init(e,t),e._zod.pattern=nJ,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch(e){}let i=r.value;return"boolean"==typeof i||r.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),r}}),an=rj("$ZodBigInt",(e,t)=>{i$.init(e,t),e._zod.pattern=nW,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch(e){}return"bigint"==typeof r.value||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}}),ai=((e,t)=>{ic.init(e,t),an.init(e,t)},rj("$ZodAny",(e,t)=>{i$.init(e,t),e._zod.parse=e=>e})),aa=rj("$ZodUnknown",(e,t)=>{i$.init(e,t),e._zod.parse=e=>e}),ao=rj("$ZodNever",(e,t)=>{i$.init(e,t),e._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)}),as=((e,t)=>{i$.init(e,t),e._zod.parse=(t,r)=>{let n=t.value;return void 0===n||t.issues.push({expected:"void",code:"invalid_type",input:n,inst:e}),t}},rj("$ZodDate",(e,t)=>{i$.init(e,t),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=new Date(r.value)}catch(e){}let i=r.value,a=i instanceof Date;return a&&!Number.isNaN(i.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:i,...a?{received:"Invalid Date"}:{},inst:e}),r}}));function ac(e,t,r){e.issues.length&&t.issues.push(...ns(r,e.issues)),t.value[r]=e.value}let al=rj("$ZodArray",(e,t)=>{i$.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},n);s instanceof Promise?a.push(s.then(t=>ac(t,r,e))):ac(s,r,e)}return a.length?Promise.all(a).then(()=>r):r}});function ad(e,t,r,n,i,a){let o=r in n;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...ns(r,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}void 0===e.value?o&&(t.value[r]=void 0):t.value[r]=e.value}function au(e){let t=Object.keys(e.shape);for(let r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${r}": expected a Zod schema`);let r=nr(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function ap(e,t,r,n,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,d="optional"===c.optin,u="optional"===c.optout;for(let i in t){if("__proto__"===i||s.has(i))continue;if("never"===l){o.push(i);continue}let a=c.run({value:t[i],issues:[]},n);a instanceof Promise?e.push(a.then(e=>ad(e,r,i,t,d,u))):ad(a,r,i,t,d,u)}return(o.length&&r.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:a}),e.length)?Promise.all(e).then(()=>r):r}let af=rj("$ZodObject",(e,t)=>{let r;i$.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape");if(!n?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let r={...e};return Object.defineProperty(t,"shape",{value:r}),r}})}let i=rq(()=>au(t));rQ(e._zod,"propValues",()=>{let e=t.shape,r={};for(let t in e){let n=e[t]._zod;if(n.values)for(let e of(r[t]??(r[t]=new Set),n.values))r[t].add(e)}return r});let a=t.catchall;e._zod.parse=(t,n)=>{r??(r=i.value);let o=t.value;if(!r6(o))return t.issues.push({expected:"object",code:"invalid_type",input:o,inst:e}),t;t.value={};let s=[],c=r.shape;for(let e of r.keys){let r=c[e],i="optional"===r._zod.optin,a="optional"===r._zod.optout,l=r._zod.run({value:o[e],issues:[]},n);l instanceof Promise?s.push(l.then(r=>ad(r,t,e,o,i,a))):ad(l,t,e,o,i,a)}return a?ap(s,o,t,n,i.value,e):s.length?Promise.all(s).then(()=>t):t}}),ah=rj("$ZodObjectJIT",(e,t)=>{let r,n;af.init(e,t);let i=e._zod.parse,a=rq(()=>au(t)),o=!rV.jitless,s=o&&r5.value,c=t.catchall;e._zod.parse=(l,d)=>{n??(n=a.value);let u=l.value;return r6(u)?o&&s&&d?.async===!1&&!0!==d.jitless?(r||(r=(e=>{let t=new i_(["shape","payload","ctx"]),r=a.value,n=e=>{let t=r0(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");let i=Object.create(null),o=0;for(let e of r.keys)i[e]=`key_${o++}`;for(let a of(t.write("const newResult = {};"),r.keys)){let r=i[a],o=r0(a),s=e[a],c=s?._zod?.optin==="optional",l=s?._zod?.optout==="optional";t.write(`const ${r} = ${n(a)};`),c&&l?t.write(`
2
2
  if (${r}.issues.length) {
3
3
  if (${o} in input) {
4
4
  payload.issues = payload.issues.concat(${r}.issues.map(iss => ({
@@ -447,6 +447,6 @@ To resolve this, you can:
447
447
  </script>
448
448
  <script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
449
449
  </body>
450
- </html>`),{headers:{"Content-Type":"text/html"}})})}let r=c5(),n=c5();for(let t of Object.values(e))if(!(!t.options||!t.path||t.options?.metadata?.SERVER_ONLY))for(let e of Array.isArray(t.options?.method)?t.options.method:[t.options?.method])c3(r,e,t.path,t);if(t?.routerMiddleware?.length)for(let{path:e,middleware:r}of t.routerMiddleware)c3(n,"*",e,r);let i=async e=>{let i=new URL(e.url),a=i.pathname,o=t?.basePath&&"/"!==t.basePath?a.split(t.basePath).reduce((e,r,n)=>(0!==n&&(n>1?e.push(`${t.basePath}${r}`):e.push(r)),e),[]).join(""):i.pathname;if(!o?.length||/\/{2,}/.test(o))return new Response(null,{status:404,statusText:"Not Found"});let s=function(e,t="",r){47===r.charCodeAt(r.length-1)&&(r=r.slice(0,-1));let n=e.static[r];if(n&&n.methods){let e=n.methods[t]||n.methods[""];if(void 0!==e)return e[0]}let i=c8(r),a=function e(t,r,n,i,a){if(a===i.length){if(r.methods){let e=r.methods[n]||r.methods[""];if(e)return e}if(r.param&&r.param.methods){let e=r.param.methods[n]||r.param.methods[""];if(e){let t=e[0].paramsMap;if(t?.[t?.length-1]?.[2])return e}}if(r.wildcard&&r.wildcard.methods){let e=r.wildcard.methods[n]||r.wildcard.methods[""];if(e){let t=e[0].paramsMap;if(t?.[t?.length-1]?.[2])return e}}return}let o=i[a];if(r.static){let s=r.static[o];if(s){let r=e(t,s,n,i,a+1);if(r)return r}}if(r.param){let s=e(t,r.param,n,i,a+1);if(s){if(r.param.hasRegexParam){let e=s.find(e=>e.paramsRegexp[a]?.test(o))||s.find(e=>!e.paramsRegexp[a]);return e?[e]:void 0}return s}}if(r.wildcard&&r.wildcard.methods)return r.wildcard.methods[n]||r.wildcard.methods[""]}(e,e.root,t,i,0)?.[0];if(void 0!==a)return{data:a.data,params:a.paramsMap?c4(i,a.paramsMap):void 0}}(r,e.method,o);if(o.endsWith("/")!==s?.data?.path?.endsWith("/")&&!t?.skipTrailingSlashes||!s?.data)return new Response(null,{status:404,statusText:"Not Found"});let c={};i.searchParams.forEach((e,t)=>{t in c?Array.isArray(c[t])?c[t].push(e):c[t]=[c[t],e]:c[t]=e});let l=s.data;try{let r=l.options.metadata?.allowedMediaTypes||t?.allowedMediaTypes,i={path:o,method:e.method,headers:e.headers,params:s.params?JSON.parse(JSON.stringify(s.params)):{},request:e,body:l.options.disableBody?void 0:await cP(l.options.cloneRequest?e.clone():e,r),query:c,_flag:"router",asResponse:!0,context:t?.routerContext},a=function(e,t="",r){47===r.charCodeAt(r.length-1)&&(r=r.slice(0,-1));let n=c8(r);return(function e(t,r,n,i,a,o=[]){let s=i[a];if(r.wildcard&&r.wildcard.methods){let e=r.wildcard.methods[n]||r.wildcard.methods[""];e&&o.push(...e)}if(r.param&&(e(t,r.param,n,i,a+1,o),a===i.length&&r.param.methods)){let e=r.param.methods[n]||r.param.methods[""];if(e){let t=e[0].paramsMap;t?.[t?.length-1]?.[2]&&o.push(...e)}}let c=r.static?.[s];if(c&&e(t,c,n,i,a+1,o),a===i.length&&r.methods){let e=r.methods[n]||r.methods[""];e&&o.push(...e)}return o})(e,e.root,t,n,0).map(e=>({data:e.data,params:e.paramsMap?c4(n,e.paramsMap):void 0}))}(n,"*",o);if(a?.length)for(let{data:e,params:t}of a){let r=await e({...i,params:t,asResponse:!1});if(r instanceof Response)return r}return await l(i)}catch(r){if(t?.onError)try{let n=await t.onError(r,e);if(n instanceof Response)return cN(n)}catch(e){if(cC(e))return cN(e);throw e}if(t?.throwError)throw r;if(cC(r))return cN(r);return console.error("# SERVER_ERROR: ",r),new Response(null,{status:500,statusText:"Internal Server Error"})}};return{handler:async e=>{let r=await t?.onRequest?.(e);if(r instanceof Response)return r;let n=cL(r)?r:e,a=await i(n),o=await t?.onResponse?.(a,n);return o instanceof Response?o:a},endpoints:e}})(r,{routerContext:e,openapi:{disabled:!0},basePath:i,routerMiddleware:[{path:"/**",middleware:ls},...n],allowedMediaTypes:["application/json"],skipTrailingSlashes:t.advanced?.skipTrailingSlashes??!1,async onRequest(t){let r=e.options.disabledPaths||[],n=ln(t.url,i);if(r.includes(n))return new Response("Not Found",{status:404});let a=t;for(let t of e.options.plugins||[])if(t.onRequest){let r=await (0,cl.withSpan)(`onRequest ${t.id}`,{[cs]:"onRequest",[cc]:`plugin:${t.id}`},()=>t.onRequest(a,e));if(r&&"response"in r)return r.response;r&&"request"in r&&(a=r.request)}return await ly(a,e)||a},async onResponse(t,r){for(let n of(await lg(r,e),e.options.plugins||[]))if(n.onResponse){let r=await (0,cl.withSpan)(`onResponse ${n.id}`,{[cs]:"onResponse",[cc]:`plugin:${n.id}`,[ca.ATTR_HTTP_RESPONSE_STATUS_CODE]:t.status},()=>n.onResponse(t,e));if(r)return r.response}return t},onError(r){if(c9(r)&&"FOUND"===r.status)return;if(t.onAPIError?.throw)throw r;if(t.onAPIError?.onError)return void t.onAPIError.onError(r,e);let n=t.logger?.level,i="error"===n||"warn"===n||"debug"===n?b.logger:void 0;if(t.logger?.disabled!==!0){if(r&&"object"==typeof r&&"message"in r&&"string"==typeof r.message&&(r.message.includes("no column")||r.message.includes("column")||r.message.includes("relation")||r.message.includes("table")||r.message.includes("does not exist")))return void e.logger?.error(r.message);c9(r)?("INTERNAL_SERVER_ERROR"===r.status&&e.logger.error(r.status,r),i?.error(r.message)):e.logger?.error(r&&"object"==typeof r&&"name"in r?r.name:"",r)}}})})(n,e);return s7(n.adapter,()=>o(t))},api:n,options:e,$context:r,$ERROR_CODES:{...e.plugins?.reduce((e,t)=>t.$ERROR_CODES?{...e,...t.$ERROR_CODES}:e,{}),...rA.BASE_ERROR_CODES}}})({database:pA,secret:function(){if(process.env.BETTER_AUTH_SECRET)return process.env.BETTER_AUTH_SECRET;if((0,uq.existsSync)(pb))return(0,uq.readFileSync)(pb,"utf-8").trim();let e=(0,N.randomBytes)(32).toString("base64");(0,uq.writeFileSync)(pb,e,{mode:384});try{(0,uq.chmodSync)(pb,384)}catch{}return e}(),baseURL:process.env.BETTER_AUTH_URL,account:{accountLinking:{enabled:!0,...pS.length?{trustedProviders:pS}:{}}},emailAndPassword:{enabled:p_,requireEmailVerification:!1,autoSignIn:!0},rateLimit:{enabled:!0,window:60,max:100,customRules:{"/sign-in/email":{window:60,max:20},"/sign-up/email":{window:60,max:10}}},socialProviders:pE,databaseHooks:{user:{create:{before:async e=>{if(!await py(e.email))throw Error("SIGNUP_NOT_ALLOWED");return{data:e}}}}},plugins:[pc()],trustedOrigins:(p=(process.env.WIKI_OWNER_HOSTS??"").split(",").map(e=>e.trim()).filter(Boolean),f=["",":3000",":3003"],Array.from(new Set(["http://localhost:3000","http://localhost:3003",...p.flatMap(e=>f.flatMap(t=>[`http://${e}${t}`,`https://${e}${t}`]))])))},ps),pT=Symbol.for("wiki-viewer.better-auth.migration-promise"),pR=globalThis;async function pI(e){return px.api.getSession({headers:e.headers})}async function pU(e){let t=await pI(e);return t?.user?{ok:!0,user:{id:t.user.id,email:t.user.email,name:t.user.name}}:{ok:!1}}pR[pT]||(pR[pT]=(async()=>{let t=await e.A(427669),{runMigrations:r}=await t.getMigrations(px.options);await r()})()),e.s(["auth",0,px,"getSessionFromRequest",0,pI,"passwordAuthEnabled",0,p_,"requireUser",0,pU],254226)}];
450
+ </html>`),{headers:{"Content-Type":"text/html"}})})}let r=c5(),n=c5();for(let t of Object.values(e))if(!(!t.options||!t.path||t.options?.metadata?.SERVER_ONLY))for(let e of Array.isArray(t.options?.method)?t.options.method:[t.options?.method])c3(r,e,t.path,t);if(t?.routerMiddleware?.length)for(let{path:e,middleware:r}of t.routerMiddleware)c3(n,"*",e,r);let i=async e=>{let i=new URL(e.url),a=i.pathname,o=t?.basePath&&"/"!==t.basePath?a.split(t.basePath).reduce((e,r,n)=>(0!==n&&(n>1?e.push(`${t.basePath}${r}`):e.push(r)),e),[]).join(""):i.pathname;if(!o?.length||/\/{2,}/.test(o))return new Response(null,{status:404,statusText:"Not Found"});let s=function(e,t="",r){47===r.charCodeAt(r.length-1)&&(r=r.slice(0,-1));let n=e.static[r];if(n&&n.methods){let e=n.methods[t]||n.methods[""];if(void 0!==e)return e[0]}let i=c8(r),a=function e(t,r,n,i,a){if(a===i.length){if(r.methods){let e=r.methods[n]||r.methods[""];if(e)return e}if(r.param&&r.param.methods){let e=r.param.methods[n]||r.param.methods[""];if(e){let t=e[0].paramsMap;if(t?.[t?.length-1]?.[2])return e}}if(r.wildcard&&r.wildcard.methods){let e=r.wildcard.methods[n]||r.wildcard.methods[""];if(e){let t=e[0].paramsMap;if(t?.[t?.length-1]?.[2])return e}}return}let o=i[a];if(r.static){let s=r.static[o];if(s){let r=e(t,s,n,i,a+1);if(r)return r}}if(r.param){let s=e(t,r.param,n,i,a+1);if(s){if(r.param.hasRegexParam){let e=s.find(e=>e.paramsRegexp[a]?.test(o))||s.find(e=>!e.paramsRegexp[a]);return e?[e]:void 0}return s}}if(r.wildcard&&r.wildcard.methods)return r.wildcard.methods[n]||r.wildcard.methods[""]}(e,e.root,t,i,0)?.[0];if(void 0!==a)return{data:a.data,params:a.paramsMap?c4(i,a.paramsMap):void 0}}(r,e.method,o);if(o.endsWith("/")!==s?.data?.path?.endsWith("/")&&!t?.skipTrailingSlashes||!s?.data)return new Response(null,{status:404,statusText:"Not Found"});let c={};i.searchParams.forEach((e,t)=>{t in c?Array.isArray(c[t])?c[t].push(e):c[t]=[c[t],e]:c[t]=e});let l=s.data;try{let r=l.options.metadata?.allowedMediaTypes||t?.allowedMediaTypes,i={path:o,method:e.method,headers:e.headers,params:s.params?JSON.parse(JSON.stringify(s.params)):{},request:e,body:l.options.disableBody?void 0:await cP(l.options.cloneRequest?e.clone():e,r),query:c,_flag:"router",asResponse:!0,context:t?.routerContext},a=function(e,t="",r){47===r.charCodeAt(r.length-1)&&(r=r.slice(0,-1));let n=c8(r);return(function e(t,r,n,i,a,o=[]){let s=i[a];if(r.wildcard&&r.wildcard.methods){let e=r.wildcard.methods[n]||r.wildcard.methods[""];e&&o.push(...e)}if(r.param&&(e(t,r.param,n,i,a+1,o),a===i.length&&r.param.methods)){let e=r.param.methods[n]||r.param.methods[""];if(e){let t=e[0].paramsMap;t?.[t?.length-1]?.[2]&&o.push(...e)}}let c=r.static?.[s];if(c&&e(t,c,n,i,a+1,o),a===i.length&&r.methods){let e=r.methods[n]||r.methods[""];e&&o.push(...e)}return o})(e,e.root,t,n,0).map(e=>({data:e.data,params:e.paramsMap?c4(n,e.paramsMap):void 0}))}(n,"*",o);if(a?.length)for(let{data:e,params:t}of a){let r=await e({...i,params:t,asResponse:!1});if(r instanceof Response)return r}return await l(i)}catch(r){if(t?.onError)try{let n=await t.onError(r,e);if(n instanceof Response)return cN(n)}catch(e){if(cC(e))return cN(e);throw e}if(t?.throwError)throw r;if(cC(r))return cN(r);return console.error("# SERVER_ERROR: ",r),new Response(null,{status:500,statusText:"Internal Server Error"})}};return{handler:async e=>{let r=await t?.onRequest?.(e);if(r instanceof Response)return r;let n=cL(r)?r:e,a=await i(n),o=await t?.onResponse?.(a,n);return o instanceof Response?o:a},endpoints:e}})(r,{routerContext:e,openapi:{disabled:!0},basePath:i,routerMiddleware:[{path:"/**",middleware:ls},...n],allowedMediaTypes:["application/json"],skipTrailingSlashes:t.advanced?.skipTrailingSlashes??!1,async onRequest(t){let r=e.options.disabledPaths||[],n=ln(t.url,i);if(r.includes(n))return new Response("Not Found",{status:404});let a=t;for(let t of e.options.plugins||[])if(t.onRequest){let r=await (0,cl.withSpan)(`onRequest ${t.id}`,{[cs]:"onRequest",[cc]:`plugin:${t.id}`},()=>t.onRequest(a,e));if(r&&"response"in r)return r.response;r&&"request"in r&&(a=r.request)}return await ly(a,e)||a},async onResponse(t,r){for(let n of(await lg(r,e),e.options.plugins||[]))if(n.onResponse){let r=await (0,cl.withSpan)(`onResponse ${n.id}`,{[cs]:"onResponse",[cc]:`plugin:${n.id}`,[ca.ATTR_HTTP_RESPONSE_STATUS_CODE]:t.status},()=>n.onResponse(t,e));if(r)return r.response}return t},onError(r){if(c9(r)&&"FOUND"===r.status)return;if(t.onAPIError?.throw)throw r;if(t.onAPIError?.onError)return void t.onAPIError.onError(r,e);let n=t.logger?.level,i="error"===n||"warn"===n||"debug"===n?b.logger:void 0;if(t.logger?.disabled!==!0){if(r&&"object"==typeof r&&"message"in r&&"string"==typeof r.message&&(r.message.includes("no column")||r.message.includes("column")||r.message.includes("relation")||r.message.includes("table")||r.message.includes("does not exist")))return void e.logger?.error(r.message);c9(r)?("INTERNAL_SERVER_ERROR"===r.status&&e.logger.error(r.status,r),i?.error(r.message)):e.logger?.error(r&&"object"==typeof r&&"name"in r?r.name:"",r)}}})})(n,e);return s7(n.adapter,()=>o(t))},api:n,options:e,$context:r,$ERROR_CODES:{...e.plugins?.reduce((e,t)=>t.$ERROR_CODES?{...e,...t.$ERROR_CODES}:e,{}),...rA.BASE_ERROR_CODES}}})({database:pA,secret:function(){if(process.env.BETTER_AUTH_SECRET)return process.env.BETTER_AUTH_SECRET;if((0,uq.existsSync)(pb))return(0,uq.readFileSync)(pb,"utf-8").trim();let e=(0,N.randomBytes)(32).toString("base64");(0,uq.writeFileSync)(pb,e,{mode:384});try{(0,uq.chmodSync)(pb,384)}catch{}return e}(),baseURL:process.env.BETTER_AUTH_URL,account:{accountLinking:{enabled:!0,...pS.length?{trustedProviders:pS,requireLocalEmailVerified:!1}:{}}},emailAndPassword:{enabled:p_,requireEmailVerification:!1,autoSignIn:!0},rateLimit:{enabled:!0,window:60,max:100,customRules:{"/sign-in/email":{window:60,max:20},"/sign-up/email":{window:60,max:10}}},socialProviders:pE,databaseHooks:{user:{create:{before:async e=>{if(!await py(e.email))throw Error("SIGNUP_NOT_ALLOWED");return{data:e}}}}},plugins:[pc()],trustedOrigins:(p=(process.env.WIKI_OWNER_HOSTS??"").split(",").map(e=>e.trim()).filter(Boolean),f=["",":3000",":3003"],Array.from(new Set(["http://localhost:3000","http://localhost:3003",...p.flatMap(e=>f.flatMap(t=>[`http://${e}${t}`,`https://${e}${t}`]))])))},ps),pT=Symbol.for("wiki-viewer.better-auth.migration-promise"),pR=globalThis;async function pI(e){return px.api.getSession({headers:e.headers})}async function pU(e){let t=await pI(e);return t?.user?{ok:!0,user:{id:t.user.id,email:t.user.email,name:t.user.name}}:{ok:!1}}pR[pT]||(pR[pT]=(async()=>{let t=await e.A(427669),{runMigrations:r}=await t.getMigrations(px.options);await r()})()),e.s(["auth",0,px,"getSessionFromRequest",0,pI,"passwordAuthEnabled",0,p_,"requireUser",0,pU],254226)}];
451
451
 
452
- //# sourceMappingURL=%5Broot-of-the-server%5D__0d89o98._.js.map
452
+ //# sourceMappingURL=src_lib_auth_server_ts_00f4e0h._.js.map