experimental-ash 0.34.0 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/docs/public/auth-and-route-protection.md +9 -0
  3. package/dist/docs/public/sandbox.md +42 -19
  4. package/dist/docs/public/session-context.md +1 -1
  5. package/dist/src/compiled/.vendor-stamp.json +2 -2
  6. package/dist/src/compiled/@vercel/sandbox/index.d.ts +11 -2
  7. package/dist/src/compiled/@vercel/sandbox/index.js +3 -3
  8. package/dist/src/compiled/@vercel/sandbox/package.json +1 -1
  9. package/dist/src/compiled/_chunks/node/{auth-ZhCJAHxl.js → auth-CVVvWjaK.js} +1 -1
  10. package/dist/src/compiled/_chunks/node/{version-D4IYmfaS.js → version-nR4RSpFw.js} +1 -1
  11. package/dist/src/execution/sandbox/bindings/vercel.d.ts +1 -1
  12. package/dist/src/execution/sandbox/session.js +1 -1
  13. package/dist/src/internal/application/package.js +1 -1
  14. package/dist/src/internal/logging.js +1 -1
  15. package/dist/src/packages/ash-scaffold/src/channels.js +1 -1
  16. package/dist/src/packages/ash-scaffold/src/web-template.js +2 -2
  17. package/dist/src/public/channels/auth.d.ts +22 -11
  18. package/dist/src/public/channels/auth.js +1 -1
  19. package/dist/src/public/definitions/sandbox.d.ts +1 -1
  20. package/dist/src/public/sandbox/index.d.ts +1 -1
  21. package/dist/src/public/sandbox/vercel-sandbox.d.ts +4 -4
  22. package/dist/src/runtime/governance/auth/oidc.js +1 -1
  23. package/dist/src/runtime/governance/auth/token-claims.d.ts +2 -0
  24. package/dist/src/runtime/governance/auth/token-claims.js +1 -1
  25. package/dist/src/runtime/governance/auth/types.d.ts +6 -0
  26. package/dist/src/shared/sandbox-session.d.ts +0 -17
  27. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "experimental-ash-compiled-vercel-sandbox",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "license": "Apache-2.0"
@@ -1,2 +1,2 @@
1
- import{c as e,o as t,r as n}from"./dist-BdTs18CF.js";import{n as r,t as i}from"./version-D4IYmfaS.js";import*as a from"node:path";import o from"node:path";import{homedir as s}from"node:os";import c from"node:fs";import{setTimeout as l}from"node:timers/promises";import*as u from"node:fs/promises";import d from"os";const f=r.string().transform((e,t)=>{try{return JSON.parse(e)}catch(e){return t.addIssue({code:r.ZodIssueCode.custom,message:`Invalid JSON: ${e.message}`}),r.NEVER}});var p=n(((e,n)=>{let r=t(`os`),i=t(`path`),a=/^win/i.test(process.platform);function o(e){return i.normalize(i.join(e,`.`))}let s=()=>{let{env:e}=process,t={};return t.home=()=>o(r.homedir?r.homedir():e.HOME),t.temp=()=>o(r.tmpdir?r.tmpdir():e.TMPDIR||e.TEMP||e.TMP),t},c=()=>{let{env:e}=process,t={};return t.home=()=>o(r.homedir?r.homedir():e.USERPROFILE||i.join(e.HOMEDRIVE,e.HOMEPATH)||e.HOME),t.temp=()=>o(r.tmpdir?r.tmpdir():e.TEMP||e.TMP||i.join(e.LOCALAPPDATA||e.SystemRoot||e.windir,`Temp`)),t};n.exports=new class e{constructor(){let t=function(){return new e};this._fn=t;let n=a?c():s();return Object.keys(n).forEach(e=>{this._fn[e]=n[e]}),this._fn}}})),m=n(((e,n)=>{let r=t(`path`),i=p(),a=()=>{let e={};return e.cache=()=>process.env.XDG_CACHE_HOME||r.join(i.home()||i.temp(),`.cache`),e.config=()=>process.env.XDG_CONFIG_HOME||r.join(i.home()||i.temp(),`.config`),e.data=()=>process.env.XDG_DATA_HOME||r.join(i.home()||i.temp(),`.local`,`share`),e.runtime=()=>process.env.XDG_RUNTIME_DIR||void 0,e.state=()=>process.env.XDG_STATE_HOME||r.join(i.home()||i.temp(),`.local`,`state`),e},o=()=>{let e={};return e.cache=()=>process.env.XDG_CACHE_HOME||r.join(r.join(i.home()||i.temp(),`Library`),`Caches`),e.config=()=>process.env.XDG_CONFIG_HOME||r.join(r.join(i.home()||i.temp(),`Library`),`Preferences`),e.data=()=>process.env.XDG_DATA_HOME||r.join(r.join(i.home()||i.temp(),`Library`),`Application Support`),e.runtime=()=>process.env.XDG_RUNTIME_DIR||void 0,e.state=()=>process.env.XDG_STATE_HOME||r.join(r.join(i.home()||i.temp(),`Library`),`State`),e},s=()=>{let e={};return e.cache=()=>{let e=process.env.LOCALAPPDATA||r.join(i.home()||i.temp(),`AppData`,`Local`);return process.env.XDG_CACHE_HOME||r.join(e,`xdg.cache`)},e.config=()=>{let e=process.env.APPDATA||r.join(i.home()||i.temp(),`AppData`,`Roaming`);return process.env.XDG_CONFIG_HOME||r.join(e,`xdg.config`)},e.data=()=>{let e=process.env.APPDATA||r.join(i.home()||i.temp(),`AppData`,`Roaming`);return process.env.XDG_DATA_HOME||r.join(e,`xdg.data`)},e.runtime=()=>process.env.XDG_RUNTIME_DIR||void 0,e.state=()=>{let e=process.env.LOCALAPPDATA||r.join(i.home()||i.temp(),`AppData`,`Local`);return process.env.XDG_STATE_HOME||r.join(e,`xdg.state`)},e},c=()=>{let e=function(){return c()},t={};return t=/^darwin$/i.test(process.platform)?o():/^win/i.test(process.platform)?s():a(),t.configDirs=()=>{let e=[];return e.push(t.config()),process.env.XDG_CONFIG_DIRS&&e.push(...process.env.XDG_CONFIG_DIRS.split(r.delimiter)),e},t.dataDirs=()=>{let e=[];return e.push(t.data()),process.env.XDG_DATA_DIRS&&e.push(...process.env.XDG_DATA_DIRS.split(r.delimiter)),e},Object.keys(t).forEach(n=>{e[n]=t[n]}),e};n.exports=c()})),h=e(n(((e,n)=>{let r=t(`path`),i=t(`os`),a=m(),o=/^win/i.test(process.platform);function s(e,t){if(e||={},typeof e!=`object`&&(e={isolated:e}),e.isolated=e.isolated===void 0||e.isolated===null?t:e.isolated,typeof e.isolated!=`boolean`)throw TypeError(`Expected boolean for "isolated" argument, got ${typeof e.isolated}`);return e}let c=(e,t)=>{let n={};return n.cache=(n={isolated:null})=>(n=s(n,t),r.join(a.cache(),n.isolated?e:``)),n.config=(n={isolated:null})=>(n=s(n,t),r.join(a.config(),n.isolated?e:``)),n.data=(n={isolated:null})=>(n=s(n,t),r.join(a.data(),n.isolated?e:``)),n.runtime=(n={isolated:null})=>(n=s(n,t),a.runtime()?r.join(a.runtime(),n.isolated?e:``):void 0),n.state=(n={isolated:null})=>(n=s(n,t),r.join(a.state(),n.isolated?e:``)),n.configDirs=(n={isolated:null})=>(n=s(n,t),a.configDirs().map(t=>r.join(t,n.isolated?e:``))),n.dataDirs=(n={isolated:null})=>(n=s(n,t),a.dataDirs().map(t=>r.join(t,n.isolated?e:``))),n},l=(e,t)=>{let{env:n}=process,o=i.homedir(),c=i.tmpdir(),l=n.APPDATA||r.join(o||c,`AppData`,`Roaming`),u=n.LOCALAPPDATA||r.join(o||c,`AppData`,`Local`),d={};return d.cache=(i={isolated:null})=>(i=s(i,t),!i.isolated||n.XDG_CACHE_HOME?r.join(a.cache(),i.isolated?e:``):r.join(u,i.isolated?e:``,`Cache`)),d.config=(i={isolated:null})=>(i=s(i,t),!i.isolated||n.XDG_CONFIG_HOME?r.join(a.config(),i.isolated?e:``):r.join(l,i.isolated?e:``,`Config`)),d.data=(i={isolated:null})=>(i=s(i,t),!i.isolated||n.XDG_DATA_HOME?r.join(a.data(),i.isolated?e:``):r.join(l,i.isolated?e:``,`Data`)),d.runtime=(n={isolated:null})=>(n=s(n,t),a.runtime()?r.join(a.runtime(),n.isolated?e:``):void 0),d.state=(i={isolated:null})=>(i=s(i,t),!i.isolated||n.XDG_STATE_HOME?r.join(a.state(),i.isolated?e:``):r.join(u,i.isolated?e:``,`State`)),d.configDirs=(i={isolated:null})=>{i=s(i,t);let a=[d.config(i)];return n.XDG_CONFIG_DIRS&&a.push(...n.XDG_CONFIG_DIRS.split(r.delimiter).map(t=>r.join(t,i.isolated?e:``))),a},d.dataDirs=(i={isolated:null})=>{i=s(i,t);let a=[d.data(i)];return n.XDG_DATA_DIRS&&a.push(...n.XDG_DATA_DIRS.split(r.delimiter).map(t=>r.join(t,i.isolated?e:``))),a},d};n.exports=new class e{constructor(n={name:null,suffix:null,isolated:!0}){let i=function(t={name:null,suffix:null,isolated:!0}){return new e(t)};this._fn=i,n||={},typeof n!=`object`&&(n={name:n});let a=n.name||``;if(typeof a!=`string`)throw TypeError(`Expected string for "name" argument, got ${typeof a}`);let s=n.suffix||``;if(typeof s!=`string`)throw TypeError(`Expected string for "suffix" argument, got ${typeof s}`);let u=n.isolated===void 0||n.isolated===null?!0:n.isolated;if(typeof u!=`boolean`)throw TypeError(`Expected boolean for "isolated" argument, got ${typeof u}`);a||=r.parse(process.pkg?process.execPath:t.main?t.main.filename:process.argv[0]).name,s&&(a+=s),this._fn.$name=()=>a,this._fn.$isolated=()=>u;let d=o?l(a,u):c(a,u);return Object.keys(d).forEach(e=>{this._fn[e]=d[e]}),this._fn}}}))(),1);const g=r.number().transform(e=>new Date(e*1e3)),_=r.object({token:r.string().min(1).optional(),refreshToken:r.string().min(1).optional(),expiresAt:g.optional()}),v=f.pipe(_),y=e=>{try{return c.lstatSync(e).isDirectory()}catch{return!1}},b=()=>{if(process.env.VERCEL_AUTH_CONFIG_DIR)return process.env.VERCEL_AUTH_CONFIG_DIR;let e=(0,h.default)(`com.vercel.cli`).dataDirs();return[...e,o.join(s(),`.now`),...(0,h.default)(`now`).dataDirs()].find(e=>y(e))||e[0]},x=()=>{try{let e=o.join(b(),`auth.json`);return v.parse(c.readFileSync(e,`utf8`))}catch{return null}};function S(e){let t=o.join(b(),`auth.json`);c.mkdirSync(o.dirname(t),{recursive:!0});let n={token:e.token,expiresAt:e.expiresAt&&Math.round(e.expiresAt.getTime()/1e3),refreshToken:e.refreshToken};c.writeFileSync(t,JSON.stringify(n)+`
1
+ import{c as e,o as t,r as n}from"./dist-BdTs18CF.js";import{n as r,t as i}from"./version-nR4RSpFw.js";import*as a from"node:path";import o from"node:path";import{homedir as s}from"node:os";import c from"node:fs";import{setTimeout as l}from"node:timers/promises";import*as u from"node:fs/promises";import d from"os";const f=r.string().transform((e,t)=>{try{return JSON.parse(e)}catch(e){return t.addIssue({code:r.ZodIssueCode.custom,message:`Invalid JSON: ${e.message}`}),r.NEVER}});var p=n(((e,n)=>{let r=t(`os`),i=t(`path`),a=/^win/i.test(process.platform);function o(e){return i.normalize(i.join(e,`.`))}let s=()=>{let{env:e}=process,t={};return t.home=()=>o(r.homedir?r.homedir():e.HOME),t.temp=()=>o(r.tmpdir?r.tmpdir():e.TMPDIR||e.TEMP||e.TMP),t},c=()=>{let{env:e}=process,t={};return t.home=()=>o(r.homedir?r.homedir():e.USERPROFILE||i.join(e.HOMEDRIVE,e.HOMEPATH)||e.HOME),t.temp=()=>o(r.tmpdir?r.tmpdir():e.TEMP||e.TMP||i.join(e.LOCALAPPDATA||e.SystemRoot||e.windir,`Temp`)),t};n.exports=new class e{constructor(){let t=function(){return new e};this._fn=t;let n=a?c():s();return Object.keys(n).forEach(e=>{this._fn[e]=n[e]}),this._fn}}})),m=n(((e,n)=>{let r=t(`path`),i=p(),a=()=>{let e={};return e.cache=()=>process.env.XDG_CACHE_HOME||r.join(i.home()||i.temp(),`.cache`),e.config=()=>process.env.XDG_CONFIG_HOME||r.join(i.home()||i.temp(),`.config`),e.data=()=>process.env.XDG_DATA_HOME||r.join(i.home()||i.temp(),`.local`,`share`),e.runtime=()=>process.env.XDG_RUNTIME_DIR||void 0,e.state=()=>process.env.XDG_STATE_HOME||r.join(i.home()||i.temp(),`.local`,`state`),e},o=()=>{let e={};return e.cache=()=>process.env.XDG_CACHE_HOME||r.join(r.join(i.home()||i.temp(),`Library`),`Caches`),e.config=()=>process.env.XDG_CONFIG_HOME||r.join(r.join(i.home()||i.temp(),`Library`),`Preferences`),e.data=()=>process.env.XDG_DATA_HOME||r.join(r.join(i.home()||i.temp(),`Library`),`Application Support`),e.runtime=()=>process.env.XDG_RUNTIME_DIR||void 0,e.state=()=>process.env.XDG_STATE_HOME||r.join(r.join(i.home()||i.temp(),`Library`),`State`),e},s=()=>{let e={};return e.cache=()=>{let e=process.env.LOCALAPPDATA||r.join(i.home()||i.temp(),`AppData`,`Local`);return process.env.XDG_CACHE_HOME||r.join(e,`xdg.cache`)},e.config=()=>{let e=process.env.APPDATA||r.join(i.home()||i.temp(),`AppData`,`Roaming`);return process.env.XDG_CONFIG_HOME||r.join(e,`xdg.config`)},e.data=()=>{let e=process.env.APPDATA||r.join(i.home()||i.temp(),`AppData`,`Roaming`);return process.env.XDG_DATA_HOME||r.join(e,`xdg.data`)},e.runtime=()=>process.env.XDG_RUNTIME_DIR||void 0,e.state=()=>{let e=process.env.LOCALAPPDATA||r.join(i.home()||i.temp(),`AppData`,`Local`);return process.env.XDG_STATE_HOME||r.join(e,`xdg.state`)},e},c=()=>{let e=function(){return c()},t={};return t=/^darwin$/i.test(process.platform)?o():/^win/i.test(process.platform)?s():a(),t.configDirs=()=>{let e=[];return e.push(t.config()),process.env.XDG_CONFIG_DIRS&&e.push(...process.env.XDG_CONFIG_DIRS.split(r.delimiter)),e},t.dataDirs=()=>{let e=[];return e.push(t.data()),process.env.XDG_DATA_DIRS&&e.push(...process.env.XDG_DATA_DIRS.split(r.delimiter)),e},Object.keys(t).forEach(n=>{e[n]=t[n]}),e};n.exports=c()})),h=e(n(((e,n)=>{let r=t(`path`),i=t(`os`),a=m(),o=/^win/i.test(process.platform);function s(e,t){if(e||={},typeof e!=`object`&&(e={isolated:e}),e.isolated=e.isolated===void 0||e.isolated===null?t:e.isolated,typeof e.isolated!=`boolean`)throw TypeError(`Expected boolean for "isolated" argument, got ${typeof e.isolated}`);return e}let c=(e,t)=>{let n={};return n.cache=(n={isolated:null})=>(n=s(n,t),r.join(a.cache(),n.isolated?e:``)),n.config=(n={isolated:null})=>(n=s(n,t),r.join(a.config(),n.isolated?e:``)),n.data=(n={isolated:null})=>(n=s(n,t),r.join(a.data(),n.isolated?e:``)),n.runtime=(n={isolated:null})=>(n=s(n,t),a.runtime()?r.join(a.runtime(),n.isolated?e:``):void 0),n.state=(n={isolated:null})=>(n=s(n,t),r.join(a.state(),n.isolated?e:``)),n.configDirs=(n={isolated:null})=>(n=s(n,t),a.configDirs().map(t=>r.join(t,n.isolated?e:``))),n.dataDirs=(n={isolated:null})=>(n=s(n,t),a.dataDirs().map(t=>r.join(t,n.isolated?e:``))),n},l=(e,t)=>{let{env:n}=process,o=i.homedir(),c=i.tmpdir(),l=n.APPDATA||r.join(o||c,`AppData`,`Roaming`),u=n.LOCALAPPDATA||r.join(o||c,`AppData`,`Local`),d={};return d.cache=(i={isolated:null})=>(i=s(i,t),!i.isolated||n.XDG_CACHE_HOME?r.join(a.cache(),i.isolated?e:``):r.join(u,i.isolated?e:``,`Cache`)),d.config=(i={isolated:null})=>(i=s(i,t),!i.isolated||n.XDG_CONFIG_HOME?r.join(a.config(),i.isolated?e:``):r.join(l,i.isolated?e:``,`Config`)),d.data=(i={isolated:null})=>(i=s(i,t),!i.isolated||n.XDG_DATA_HOME?r.join(a.data(),i.isolated?e:``):r.join(l,i.isolated?e:``,`Data`)),d.runtime=(n={isolated:null})=>(n=s(n,t),a.runtime()?r.join(a.runtime(),n.isolated?e:``):void 0),d.state=(i={isolated:null})=>(i=s(i,t),!i.isolated||n.XDG_STATE_HOME?r.join(a.state(),i.isolated?e:``):r.join(u,i.isolated?e:``,`State`)),d.configDirs=(i={isolated:null})=>{i=s(i,t);let a=[d.config(i)];return n.XDG_CONFIG_DIRS&&a.push(...n.XDG_CONFIG_DIRS.split(r.delimiter).map(t=>r.join(t,i.isolated?e:``))),a},d.dataDirs=(i={isolated:null})=>{i=s(i,t);let a=[d.data(i)];return n.XDG_DATA_DIRS&&a.push(...n.XDG_DATA_DIRS.split(r.delimiter).map(t=>r.join(t,i.isolated?e:``))),a},d};n.exports=new class e{constructor(n={name:null,suffix:null,isolated:!0}){let i=function(t={name:null,suffix:null,isolated:!0}){return new e(t)};this._fn=i,n||={},typeof n!=`object`&&(n={name:n});let a=n.name||``;if(typeof a!=`string`)throw TypeError(`Expected string for "name" argument, got ${typeof a}`);let s=n.suffix||``;if(typeof s!=`string`)throw TypeError(`Expected string for "suffix" argument, got ${typeof s}`);let u=n.isolated===void 0||n.isolated===null?!0:n.isolated;if(typeof u!=`boolean`)throw TypeError(`Expected boolean for "isolated" argument, got ${typeof u}`);a||=r.parse(process.pkg?process.execPath:t.main?t.main.filename:process.argv[0]).name,s&&(a+=s),this._fn.$name=()=>a,this._fn.$isolated=()=>u;let d=o?l(a,u):c(a,u);return Object.keys(d).forEach(e=>{this._fn[e]=d[e]}),this._fn}}}))(),1);const g=r.number().transform(e=>new Date(e*1e3)),_=r.object({token:r.string().min(1).optional(),refreshToken:r.string().min(1).optional(),expiresAt:g.optional()}),v=f.pipe(_),y=e=>{try{return c.lstatSync(e).isDirectory()}catch{return!1}},b=()=>{if(process.env.VERCEL_AUTH_CONFIG_DIR)return process.env.VERCEL_AUTH_CONFIG_DIR;let e=(0,h.default)(`com.vercel.cli`).dataDirs();return[...e,o.join(s(),`.now`),...(0,h.default)(`now`).dataDirs()].find(e=>y(e))||e[0]},x=()=>{try{let e=o.join(b(),`auth.json`);return v.parse(c.readFileSync(e,`utf8`))}catch{return null}};function S(e){let t=o.join(b(),`auth.json`);c.mkdirSync(o.dirname(t),{recursive:!0});let n={token:e.token,expiresAt:e.expiresAt&&Math.round(e.expiresAt.getTime()/1e3),refreshToken:e.refreshToken};c.writeFileSync(t,JSON.stringify(n)+`
2
2
  `)}const C=`${d.hostname()} @ vercel/sandbox/${i} node-${process.version} ${d.platform()} (${d.arch()})`,w=new URL(`https://vercel.com`),T=`cl_HYyOPBNtFMfHhaUn9L4QPfTZz6TP47bp`,E=r.object({issuer:r.string().url(),device_authorization_endpoint:r.string().url(),token_endpoint:r.string().url(),revocation_endpoint:r.string().url(),jwks_uri:r.string().url(),introspection_endpoint:r.string().url()});let D;const O=r.object({device_code:r.string(),user_code:r.string(),verification_uri:r.string().url(),verification_uri_complete:r.string().url(),expires_in:r.number(),interval:r.number()}),k=r.object({active:r.literal(!0),client_id:r.string(),session_id:r.string()}).or(r.object({active:r.literal(!1)}));async function A(){if(D)return D;let e=await fetch(new URL(`.well-known/openid-configuration`,w),{headers:{"Content-Type":`application/json`,"user-agent":C}});return D=E.parse(await e.json()),D}async function j(){let e=await A();return{async deviceAuthorizationRequest(){let t=await(await fetch(e.device_authorization_endpoint,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`,"user-agent":C},body:new URLSearchParams({client_id:T,scope:`openid offline_access`})})).json(),n=O.safeParse(t);if(!n.success)throw new F(`Failed to parse device authorization response: ${n.error.message}`,t);return{device_code:n.data.device_code,user_code:n.data.user_code,verification_uri:n.data.verification_uri,verification_uri_complete:n.data.verification_uri_complete,expiresAt:Date.now()+n.data.expires_in*1e3,interval:n.data.interval}},async deviceAccessTokenRequest(t){try{return[null,await fetch(e.token_endpoint,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`,"user-agent":C},body:new URLSearchParams({client_id:T,grant_type:`urn:ietf:params:oauth:grant-type:device_code`,device_code:t}),signal:AbortSignal.timeout(10*1e3)})]}catch(e){return e instanceof Error?[e]:[Error(`An unknown error occurred. See the logs for details.`,{cause:e})]}},async processTokenResponse(e){let t=await e.json(),n=M.safeParse(t);return n.success?[null,n.data]:[new F(`Failed to parse token response: ${n.error.message}`,t)]},async revokeToken(t){let n=await fetch(e.revocation_endpoint,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`,"user-agent":C},body:new URLSearchParams({token:t,client_id:T})});if(!n.ok)return new F(`Revocation request failed`,await n.json())},async refreshToken(t){let n=await fetch(e.token_endpoint,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`,"user-agent":C},body:new URLSearchParams({client_id:T,grant_type:`refresh_token`,refresh_token:t})}),[r,i]=await this.processTokenResponse(n);if(r)throw r;return i},async introspectToken(t){let n=await(await fetch(e.introspection_endpoint,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`,"user-agent":C},body:new URLSearchParams({token:t})})).json(),r=k.safeParse(n);if(!r.success)throw new F(`Failed to parse introspection response: ${r.error.message}`,n);return r.data}}}const M=r.object({access_token:r.string(),token_type:r.literal(`Bearer`),expires_in:r.number(),refresh_token:r.string().optional(),scope:r.string().optional()}),N=r.object({error:r.enum([`invalid_request`,`invalid_client`,`invalid_grant`,`unauthorized_client`,`unsupported_grant_type`,`invalid_scope`,`server_error`,`authorization_pending`,`slow_down`,`access_denied`,`expired_token`,`unsupported_token_type`]),error_description:r.string().optional(),error_uri:r.string().optional()});function P(e){try{return N.parse(e)}catch(e){return e instanceof r.ZodError?TypeError(`Invalid OAuth error response: ${e.message}`):TypeError(`Failed to parse OAuth error response`)}}var F=class extends Error{constructor(e,t){super(e),this.name=`OAuthError`;let n=P(t);if(n instanceof TypeError){let e=`Unexpected server response: ${JSON.stringify(t)}`;this.cause=Error(e,{cause:n}),this.code=`server_error`;return}let r=n.error;n.error_description&&(r+=`: ${n.error_description}`),n.error_uri&&(r+=` (${n.error_uri})`),this.cause=Error(r),this.code=n.error}};function I(e){return e instanceof F}async function*L({request:e,oauth:t}){let n=new AbortController;try{let r=e.interval*1e3;for(;Date.now()<e.expiresAt;){let[i,a]=await t.deviceAccessTokenRequest(e.device_code);if(i){if(i.message.includes(`timeout`)){r*=2,yield{_tag:`Timeout`,newInterval:r},await l(r,{signal:n.signal});continue}yield{_tag:`Error`,error:i};return}yield{_tag:`Response`,response:a.clone()};let[o,s]=await t.processTokenResponse(a);if(I(o)){let{code:e}=o;switch(e){case`authorization_pending`:await l(r,{signal:n.signal});continue;case`slow_down`:r+=5*1e3,yield{_tag:`SlowDown`,newInterval:r},await l(r,{signal:n.signal});continue;default:yield{_tag:`Error`,error:o.cause};return}}if(o){yield{_tag:`Error`,error:o};return}S({token:s.access_token,expiresAt:new Date(Date.now()+s.expires_in*1e3),refreshToken:s.refresh_token});return}yield{_tag:`Error`,error:Error(`Timed out waiting for authentication. Please try again.`)};return}finally{n.abort()}}var R=class extends Error{constructor(e){super(`HTTP ${e.statusCode}: ${e.responseText}`),this.name=`NotOk`,this.response=e}};async function z(e){let t=await fetch(`https://vercel.com/api${e.endpoint}`,{method:e.method,body:e.body,headers:{Authorization:`Bearer ${e.token}`,"Content-Type":`application/json`}});if(!t.ok){let e=await t.text();try{let{error:t}=JSON.parse(e);e=`${t.code.toUpperCase()}: ${t.message}`}catch{}throw new R({responseText:e,statusCode:t.status})}return await t.json()}const B=f.pipe(r.object({projectId:r.string(),orgId:r.string()}));async function V(e){let t=a.join(e,`.vercel`,`project.json`),n;try{n=await u.readFile(t,`utf-8`)}catch{return null}let r=B.safeParse(n);return r.success?{projectId:r.data.projectId,teamId:r.data.orgId}:null}const H=r.object({user:r.object({defaultTeamId:r.string().nullable(),username:r.string()})}),U=r.object({id:r.string(),slug:r.string(),updatedAt:r.number(),membership:r.object({role:r.string()}),billing:r.object({plan:r.string()})}),W=r.object({teams:r.array(U),pagination:r.object({count:r.number(),next:r.number().nullable()})}),G=`vercel-sandbox-default-project`;function K(e){return e instanceof R&&(e.response.statusCode===402||e.response.statusCode===403)}async function q(e){let t=await V(e.cwd??process.cwd());if(t){let n=await Y(e.token,t.teamId,t.projectId);return{...t,created:!1,...n}}if(e.teamId)return J(e.token,e.teamId);let{defaultTeamId:n,username:i}=(await z({token:e.token,endpoint:`/v2/user`}).then(H.parse)).user;if(n)try{let t=await J(e.token,n);try{let i=await z({token:e.token,endpoint:`/v2/teams/${encodeURIComponent(n)}`}).then(r.object({slug:r.string()}).parse);return{...t,teamSlug:i.slug}}catch{return t}}catch(e){if(!K(e))throw e}let a=null;do{let t=a===null?`/v2/teams?limit=20`:`/v2/teams?limit=20&until=${a}`,r=await z({token:e.token,endpoint:t}).then(W.parse);a=r.pagination.next;let o=r.teams.filter(e=>e.membership.role===`OWNER`&&e.billing.plan===`hobby`);if(o.length===0)continue;let s=o.find(e=>e.slug===i)??o.sort((e,t)=>t.updatedAt-e.updatedAt)[0];if(s&&s.id!==n)try{return{...await J(e.token,s.id),teamSlug:s.slug}}catch(e){if(!K(e))throw e}}while(a!==null);try{return{...await J(e.token,i),teamSlug:i}}catch(e){if(!K(e))throw e}throw new R({statusCode:403,responseText:`Authenticated as "${i}" but none of the available teams allow sandbox creation. Specify a team explicitly with --scope <team-id-or-slug>.`})}async function J(e,t){let n=t.startsWith(`team_`)?`teamId=${encodeURIComponent(t)}`:`slug=${encodeURIComponent(t)}`,r=!1;try{await z({token:e,endpoint:`/v2/projects/vercel-sandbox-default-project?${n}`})}catch(t){if(!(t instanceof R)||t.response.statusCode!==404)throw t;await z({token:e,endpoint:`/v11/projects?${n}`,method:`POST`,body:JSON.stringify({name:G})}),r=!0}return{projectId:G,teamId:t,created:r}}async function Y(e,t,n){try{let i=t.startsWith(`team_`)?`teamId=${encodeURIComponent(t)}`:`slug=${encodeURIComponent(t)}`,[a,o]=await Promise.all([z({token:e,endpoint:`/v2/teams/${encodeURIComponent(t)}`}).then(r.object({slug:r.string()}).parse),z({token:e,endpoint:`/v2/projects/${encodeURIComponent(n)}?${i}`}).then(r.object({name:r.string()}).parse)]);return{teamSlug:a.slug,projectSlug:o.name}}catch{return{}}}export{R as NotOk,j as OAuth,x as getAuth,q as inferScope,I as isOAuthError,L as pollForToken,S as updateAuthConfig};
@@ -1 +1 @@
1
- var e;(function(e){e.assertEqual=e=>e;function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(e||={});var t;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(t||={});const n=e.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),r=e=>{switch(typeof e){case`undefined`:return n.undefined;case`string`:return n.string;case`number`:return isNaN(e)?n.nan:n.number;case`boolean`:return n.boolean;case`function`:return n.function;case`bigint`:return n.bigint;case`symbol`:return n.symbol;case`object`:return Array.isArray(e)?n.array:e===null?n.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?n.promise:typeof Map<`u`&&e instanceof Map?n.map:typeof Set<`u`&&e instanceof Set?n.set:typeof Date<`u`&&e instanceof Date?n.date:n.object;default:return n.unknown}},i=e.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),a=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,`$1:`);var o=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(e){if(!(e instanceof t))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,e.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};o.create=e=>new o(e);const s=(t,r)=>{let a;switch(t.code){case i.invalid_type:a=t.received===n.undefined?`Required`:`Expected ${t.expected}, received ${t.received}`;break;case i.invalid_literal:a=`Invalid literal value, expected ${JSON.stringify(t.expected,e.jsonStringifyReplacer)}`;break;case i.unrecognized_keys:a=`Unrecognized key(s) in object: ${e.joinValues(t.keys,`, `)}`;break;case i.invalid_union:a=`Invalid input`;break;case i.invalid_union_discriminator:a=`Invalid discriminator value. Expected ${e.joinValues(t.options)}`;break;case i.invalid_enum_value:a=`Invalid enum value. Expected ${e.joinValues(t.options)}, received '${t.received}'`;break;case i.invalid_arguments:a=`Invalid function arguments`;break;case i.invalid_return_type:a=`Invalid function return type`;break;case i.invalid_date:a=`Invalid date`;break;case i.invalid_string:typeof t.validation==`object`?`includes`in t.validation?(a=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position==`number`&&(a=`${a} at one or more positions greater than or equal to ${t.validation.position}`)):`startsWith`in t.validation?a=`Invalid input: must start with "${t.validation.startsWith}"`:`endsWith`in t.validation?a=`Invalid input: must end with "${t.validation.endsWith}"`:e.assertNever(t.validation):a=t.validation===`regex`?`Invalid`:`Invalid ${t.validation}`;break;case i.too_small:a=t.type===`array`?`Array must contain ${t.exact?`exactly`:t.inclusive?`at least`:`more than`} ${t.minimum} element(s)`:t.type===`string`?`String must contain ${t.exact?`exactly`:t.inclusive?`at least`:`over`} ${t.minimum} character(s)`:t.type===`number`?`Number must be ${t.exact?`exactly equal to `:t.inclusive?`greater than or equal to `:`greater than `}${t.minimum}`:t.type===`date`?`Date must be ${t.exact?`exactly equal to `:t.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(t.minimum))}`:`Invalid input`;break;case i.too_big:a=t.type===`array`?`Array must contain ${t.exact?`exactly`:t.inclusive?`at most`:`less than`} ${t.maximum} element(s)`:t.type===`string`?`String must contain ${t.exact?`exactly`:t.inclusive?`at most`:`under`} ${t.maximum} character(s)`:t.type===`number`?`Number must be ${t.exact?`exactly`:t.inclusive?`less than or equal to`:`less than`} ${t.maximum}`:t.type===`bigint`?`BigInt must be ${t.exact?`exactly`:t.inclusive?`less than or equal to`:`less than`} ${t.maximum}`:t.type===`date`?`Date must be ${t.exact?`exactly`:t.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(t.maximum))}`:`Invalid input`;break;case i.custom:a=`Invalid input`;break;case i.invalid_intersection_types:a=`Intersection results could not be merged`;break;case i.not_multiple_of:a=`Number must be a multiple of ${t.multipleOf}`;break;case i.not_finite:a=`Number must be finite`;break;default:a=r.defaultError,e.assertNever(t)}return{message:a}};let c=s;function ee(e){c=e}function te(){return c}const ne=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}},re=[];function l(e,t){let n=te(),r=ne({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===s?void 0:s].filter(e=>!!e)});e.common.issues.push(r)}var u=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return d;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return d;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}};const d=Object.freeze({status:`aborted`}),ie=e=>({status:`dirty`,value:e}),f=e=>({status:`valid`,value:e}),ae=e=>e.status===`aborted`,oe=e=>e.status===`dirty`,p=e=>e.status===`valid`,m=e=>typeof Promise<`u`&&e instanceof Promise;function h(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function se(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}var g;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(g||={});var _,v,y=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};const ce=(e,t)=>{if(p(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new o(e.common.issues);return this._error=t,this._error}}};function b(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var x=class{get description(){return this._def.description}_getType(e){return r(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:r(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new u,ctx:{common:e.parent.common,data:e.data,parsedType:r(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(m(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:r(e)};return ce(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:r(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return p(n)?{value:n.value}:{issues:t.common.issues}}catch(e){((e?.message)?.toLowerCase())?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>p(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:r(e)},i=this._parse({data:e,path:n.path,parent:n});return ce(n,await(m(i)?i:Promise.resolve(i)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let a=e(t),o=()=>r.addIssue({code:i.custom,...n(t)});return typeof Promise<`u`&&a instanceof Promise?a.then(e=>e?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new q({schema:this,typeName:$.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return J.create(this,this._def)}nullable(){return Y.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return N.create(this)}promise(){return K.create(this,this._def)}or(e){return I.create([this,e],this._def)}and(e){return R.create(this,e,this._def)}transform(e){return new q({...b(this._def),schema:this,typeName:$.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new X({...b(this._def),innerType:this,defaultValue:t,typeName:$.ZodDefault})}brand(){return new Ve({typeName:$.ZodBranded,type:this,...b(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new Z({...b(this._def),innerType:this,catchValue:t,typeName:$.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return He.create(this,e)}readonly(){return Q.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const le=/^c[^\s-]{8,}$/i,ue=/^[0-9a-z]+$/,de=/^[0-9A-HJKMNP-TV-Z]{26}$/i,fe=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,pe=/^[a-z0-9_-]{21}$/i,me=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,he=/^[-+]?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)?)??$/,ge=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let _e;const ve=/^(?:(?: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])$/,ye=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,be=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,xe=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Se=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ce=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,we=`((\\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])))`,Te=RegExp(`^${we}$`);function Ee(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function De(e){return RegExp(`^${Ee(e)}$`)}function Oe(e){let t=`${we}T${Ee(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function ke(e,t){return!!((t===`v4`||!t)&&ve.test(e)||(t===`v6`||!t)&&be.test(e))}function Ae(e,t){if(!me.test(e))return!1;try{let[n]=e.split(`.`),r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||!i.typ||!i.alg||t&&i.alg!==t)}catch{return!1}}function je(e,t){return!!((t===`v4`||!t)&&ye.test(e)||(t===`v6`||!t)&&xe.test(e))}var S=class t extends x{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==n.string){let e=this._getOrReturnCtx(t);return l(e,{code:i.invalid_type,expected:n.string,received:e.parsedType}),d}let r=new u,a;for(let n of this._def.checks)if(n.kind===`min`)t.data.length<n.value&&(a=this._getOrReturnCtx(t,a),l(a,{code:i.too_small,minimum:n.value,type:`string`,inclusive:!0,exact:!1,message:n.message}),r.dirty());else if(n.kind===`max`)t.data.length>n.value&&(a=this._getOrReturnCtx(t,a),l(a,{code:i.too_big,maximum:n.value,type:`string`,inclusive:!0,exact:!1,message:n.message}),r.dirty());else if(n.kind===`length`){let e=t.data.length>n.value,o=t.data.length<n.value;(e||o)&&(a=this._getOrReturnCtx(t,a),e?l(a,{code:i.too_big,maximum:n.value,type:`string`,inclusive:!0,exact:!0,message:n.message}):o&&l(a,{code:i.too_small,minimum:n.value,type:`string`,inclusive:!0,exact:!0,message:n.message}),r.dirty())}else if(n.kind===`email`)ge.test(t.data)||(a=this._getOrReturnCtx(t,a),l(a,{validation:`email`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`emoji`)_e||=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`),_e.test(t.data)||(a=this._getOrReturnCtx(t,a),l(a,{validation:`emoji`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`uuid`)fe.test(t.data)||(a=this._getOrReturnCtx(t,a),l(a,{validation:`uuid`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`nanoid`)pe.test(t.data)||(a=this._getOrReturnCtx(t,a),l(a,{validation:`nanoid`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`cuid`)le.test(t.data)||(a=this._getOrReturnCtx(t,a),l(a,{validation:`cuid`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`cuid2`)ue.test(t.data)||(a=this._getOrReturnCtx(t,a),l(a,{validation:`cuid2`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`ulid`)de.test(t.data)||(a=this._getOrReturnCtx(t,a),l(a,{validation:`ulid`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`url`)try{new URL(t.data)}catch{a=this._getOrReturnCtx(t,a),l(a,{validation:`url`,code:i.invalid_string,message:n.message}),r.dirty()}else n.kind===`regex`?(n.regex.lastIndex=0,n.regex.test(t.data)||(a=this._getOrReturnCtx(t,a),l(a,{validation:`regex`,code:i.invalid_string,message:n.message}),r.dirty())):n.kind===`trim`?t.data=t.data.trim():n.kind===`includes`?t.data.includes(n.value,n.position)||(a=this._getOrReturnCtx(t,a),l(a,{code:i.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),r.dirty()):n.kind===`toLowerCase`?t.data=t.data.toLowerCase():n.kind===`toUpperCase`?t.data=t.data.toUpperCase():n.kind===`startsWith`?t.data.startsWith(n.value)||(a=this._getOrReturnCtx(t,a),l(a,{code:i.invalid_string,validation:{startsWith:n.value},message:n.message}),r.dirty()):n.kind===`endsWith`?t.data.endsWith(n.value)||(a=this._getOrReturnCtx(t,a),l(a,{code:i.invalid_string,validation:{endsWith:n.value},message:n.message}),r.dirty()):n.kind===`datetime`?Oe(n).test(t.data)||(a=this._getOrReturnCtx(t,a),l(a,{code:i.invalid_string,validation:`datetime`,message:n.message}),r.dirty()):n.kind===`date`?Te.test(t.data)||(a=this._getOrReturnCtx(t,a),l(a,{code:i.invalid_string,validation:`date`,message:n.message}),r.dirty()):n.kind===`time`?De(n).test(t.data)||(a=this._getOrReturnCtx(t,a),l(a,{code:i.invalid_string,validation:`time`,message:n.message}),r.dirty()):n.kind===`duration`?he.test(t.data)||(a=this._getOrReturnCtx(t,a),l(a,{validation:`duration`,code:i.invalid_string,message:n.message}),r.dirty()):n.kind===`ip`?ke(t.data,n.version)||(a=this._getOrReturnCtx(t,a),l(a,{validation:`ip`,code:i.invalid_string,message:n.message}),r.dirty()):n.kind===`jwt`?Ae(t.data,n.alg)||(a=this._getOrReturnCtx(t,a),l(a,{validation:`jwt`,code:i.invalid_string,message:n.message}),r.dirty()):n.kind===`cidr`?je(t.data,n.version)||(a=this._getOrReturnCtx(t,a),l(a,{validation:`cidr`,code:i.invalid_string,message:n.message}),r.dirty()):n.kind===`base64`?Se.test(t.data)||(a=this._getOrReturnCtx(t,a),l(a,{validation:`base64`,code:i.invalid_string,message:n.message}),r.dirty()):n.kind===`base64url`?Ce.test(t.data)||(a=this._getOrReturnCtx(t,a),l(a,{validation:`base64url`,code:i.invalid_string,message:n.message}),r.dirty()):e.assertNever(n);return{status:r.value,value:t.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:i.invalid_string,...g.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:`email`,...g.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...g.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...g.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...g.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...g.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...g.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...g.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...g.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...g.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...g.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...g.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...g.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...g.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...g.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...g.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...g.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...g.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...g.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...g.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...g.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...g.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...g.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...g.errToObj(t)})}nonempty(e){return this.min(1,g.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};S.create=e=>new S({checks:[],typeName:$.ZodString,coerce:e?.coerce??!1,...b(e)});function Me(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return parseInt(e.toFixed(i).replace(`.`,``))%parseInt(t.toFixed(i).replace(`.`,``))/10**i}var C=class t extends x{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==n.number){let e=this._getOrReturnCtx(t);return l(e,{code:i.invalid_type,expected:n.number,received:e.parsedType}),d}let r,a=new u;for(let n of this._def.checks)n.kind===`int`?e.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),l(r,{code:i.invalid_type,expected:`integer`,received:`float`,message:n.message}),a.dirty()):n.kind===`min`?(n.inclusive?t.data<n.value:t.data<=n.value)&&(r=this._getOrReturnCtx(t,r),l(r,{code:i.too_small,minimum:n.value,type:`number`,inclusive:n.inclusive,exact:!1,message:n.message}),a.dirty()):n.kind===`max`?(n.inclusive?t.data>n.value:t.data>=n.value)&&(r=this._getOrReturnCtx(t,r),l(r,{code:i.too_big,maximum:n.value,type:`number`,inclusive:n.inclusive,exact:!1,message:n.message}),a.dirty()):n.kind===`multipleOf`?Me(t.data,n.value)!==0&&(r=this._getOrReturnCtx(t,r),l(r,{code:i.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):n.kind===`finite`?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),l(r,{code:i.not_finite,message:n.message}),a.dirty()):e.assertNever(n);return{status:a.value,value:t.data}}gte(e,t){return this.setLimit(`min`,e,!0,g.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,g.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,g.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,g.toString(t))}setLimit(e,n,r,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:g.toString(i)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:`int`,message:g.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:g.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:g.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:g.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:g.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:g.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(t=>t.kind===`int`||t.kind===`multipleOf`&&e.isInteger(t.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};C.create=e=>new C({checks:[],typeName:$.ZodNumber,coerce:e?.coerce||!1,...b(e)});var w=class t extends x{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==n.bigint)return this._getInvalidInput(t);let r,a=new u;for(let n of this._def.checks)n.kind===`min`?(n.inclusive?t.data<n.value:t.data<=n.value)&&(r=this._getOrReturnCtx(t,r),l(r,{code:i.too_small,type:`bigint`,minimum:n.value,inclusive:n.inclusive,message:n.message}),a.dirty()):n.kind===`max`?(n.inclusive?t.data>n.value:t.data>=n.value)&&(r=this._getOrReturnCtx(t,r),l(r,{code:i.too_big,type:`bigint`,maximum:n.value,inclusive:n.inclusive,message:n.message}),a.dirty()):n.kind===`multipleOf`?t.data%n.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),l(r,{code:i.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):e.assertNever(n);return{status:a.value,value:t.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return l(t,{code:i.invalid_type,expected:n.bigint,received:t.parsedType}),d}gte(e,t){return this.setLimit(`min`,e,!0,g.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,g.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,g.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,g.toString(t))}setLimit(e,n,r,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:g.toString(i)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:g.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:g.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};w.create=e=>new w({checks:[],typeName:$.ZodBigInt,coerce:e?.coerce??!1,...b(e)});var T=class extends x{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==n.boolean){let t=this._getOrReturnCtx(e);return l(t,{code:i.invalid_type,expected:n.boolean,received:t.parsedType}),d}return f(e.data)}};T.create=e=>new T({typeName:$.ZodBoolean,coerce:e?.coerce||!1,...b(e)});var E=class t extends x{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==n.date){let e=this._getOrReturnCtx(t);return l(e,{code:i.invalid_type,expected:n.date,received:e.parsedType}),d}if(isNaN(t.data.getTime()))return l(this._getOrReturnCtx(t),{code:i.invalid_date}),d;let r=new u,a;for(let n of this._def.checks)n.kind===`min`?t.data.getTime()<n.value&&(a=this._getOrReturnCtx(t,a),l(a,{code:i.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:`date`}),r.dirty()):n.kind===`max`?t.data.getTime()>n.value&&(a=this._getOrReturnCtx(t,a),l(a,{code:i.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:`date`}),r.dirty()):e.assertNever(n);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:g.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:g.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};E.create=e=>new E({checks:[],coerce:e?.coerce||!1,typeName:$.ZodDate,...b(e)});var Ne=class extends x{_parse(e){if(this._getType(e)!==n.symbol){let t=this._getOrReturnCtx(e);return l(t,{code:i.invalid_type,expected:n.symbol,received:t.parsedType}),d}return f(e.data)}};Ne.create=e=>new Ne({typeName:$.ZodSymbol,...b(e)});var D=class extends x{_parse(e){if(this._getType(e)!==n.undefined){let t=this._getOrReturnCtx(e);return l(t,{code:i.invalid_type,expected:n.undefined,received:t.parsedType}),d}return f(e.data)}};D.create=e=>new D({typeName:$.ZodUndefined,...b(e)});var O=class extends x{_parse(e){if(this._getType(e)!==n.null){let t=this._getOrReturnCtx(e);return l(t,{code:i.invalid_type,expected:n.null,received:t.parsedType}),d}return f(e.data)}};O.create=e=>new O({typeName:$.ZodNull,...b(e)});var k=class extends x{constructor(){super(...arguments),this._any=!0}_parse(e){return f(e.data)}};k.create=e=>new k({typeName:$.ZodAny,...b(e)});var A=class extends x{constructor(){super(...arguments),this._unknown=!0}_parse(e){return f(e.data)}};A.create=e=>new A({typeName:$.ZodUnknown,...b(e)});var j=class extends x{_parse(e){let t=this._getOrReturnCtx(e);return l(t,{code:i.invalid_type,expected:n.never,received:t.parsedType}),d}};j.create=e=>new j({typeName:$.ZodNever,...b(e)});var M=class extends x{_parse(e){if(this._getType(e)!==n.undefined){let t=this._getOrReturnCtx(e);return l(t,{code:i.invalid_type,expected:n.void,received:t.parsedType}),d}return f(e.data)}};M.create=e=>new M({typeName:$.ZodVoid,...b(e)});var N=class e extends x{_parse(e){let{ctx:t,status:r}=this._processInputParams(e),a=this._def;if(t.parsedType!==n.array)return l(t,{code:i.invalid_type,expected:n.array,received:t.parsedType}),d;if(a.exactLength!==null){let e=t.data.length>a.exactLength.value,n=t.data.length<a.exactLength.value;(e||n)&&(l(t,{code:e?i.too_big:i.too_small,minimum:n?a.exactLength.value:void 0,maximum:e?a.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:a.exactLength.message}),r.dirty())}if(a.minLength!==null&&t.data.length<a.minLength.value&&(l(t,{code:i.too_small,minimum:a.minLength.value,type:`array`,inclusive:!0,exact:!1,message:a.minLength.message}),r.dirty()),a.maxLength!==null&&t.data.length>a.maxLength.value&&(l(t,{code:i.too_big,maximum:a.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:a.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>a.type._parseAsync(new y(t,e,t.path,n)))).then(e=>u.mergeArray(r,e));let o=[...t.data].map((e,n)=>a.type._parseSync(new y(t,e,t.path,n)));return u.mergeArray(r,o)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:g.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:g.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:g.toString(n)}})}nonempty(e){return this.min(1,e)}};N.create=(e,t)=>new N({type:e,minLength:null,maxLength:null,exactLength:null,typeName:$.ZodArray,...b(t)});function P(e){if(e instanceof F){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=J.create(P(r))}return new F({...e._def,shape:()=>t})}else if(e instanceof N)return new N({...e._def,type:P(e.element)});else if(e instanceof J)return J.create(P(e.unwrap()));else if(e instanceof Y)return Y.create(P(e.unwrap()));else if(e instanceof z)return z.create(e.items.map(e=>P(e)));else return e}var F=class t extends x{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),n=e.objectKeys(t);return this._cached={shape:t,keys:n}}_parse(e){if(this._getType(e)!==n.object){let t=this._getOrReturnCtx(e);return l(t,{code:i.invalid_type,expected:n.object,received:t.parsedType}),d}let{status:t,ctx:r}=this._processInputParams(e),{shape:a,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof j&&this._def.unknownKeys===`strip`))for(let e in r.data)o.includes(e)||s.push(e);let c=[];for(let e of o){let t=a[e],n=r.data[e];c.push({key:{status:`valid`,value:e},value:t._parse(new y(r,n,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof j){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of s)c.push({key:{status:`valid`,value:e},value:{status:`valid`,value:r.data[e]}});else if(e===`strict`)s.length>0&&(l(r,{code:i.unrecognized_keys,keys:s}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of s){let n=r.data[t];c.push({key:{status:`valid`,value:t},value:e._parse(new y(r,n,r.path,t)),alwaysSet:t in r.data})}}return r.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of c){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>u.mergeObjectSync(t,e)):u.mergeObjectSync(t,c)}get shape(){return this._def.shape()}strict(e){return g.errToObj,new t({...this._def,unknownKeys:`strict`,...e===void 0?{}:{errorMap:(t,n)=>{var r;let i=(r=this._def).errorMap?.call(r,t,n).message??n.defaultError;return t.code===`unrecognized_keys`?{message:g.errToObj(e).message??i}:{message:i}}}})}strip(){return new t({...this._def,unknownKeys:`strip`})}passthrough(){return new t({...this._def,unknownKeys:`passthrough`})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:$.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new t({...this._def,catchall:e})}pick(n){let r={};return e.objectKeys(n).forEach(e=>{n[e]&&this.shape[e]&&(r[e]=this.shape[e])}),new t({...this._def,shape:()=>r})}omit(n){let r={};return e.objectKeys(this.shape).forEach(e=>{n[e]||(r[e]=this.shape[e])}),new t({...this._def,shape:()=>r})}deepPartial(){return P(this)}partial(n){let r={};return e.objectKeys(this.shape).forEach(e=>{let t=this.shape[e];n&&!n[e]?r[e]=t:r[e]=t.optional()}),new t({...this._def,shape:()=>r})}required(n){let r={};return e.objectKeys(this.shape).forEach(e=>{if(n&&!n[e])r[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof J;)t=t._def.innerType;r[e]=t}}),new t({...this._def,shape:()=>r})}keyof(){return Re(e.objectKeys(this.shape))}};F.create=(e,t)=>new F({shape:()=>e,unknownKeys:`strip`,catchall:j.create(),typeName:$.ZodObject,...b(t)}),F.strictCreate=(e,t)=>new F({shape:()=>e,unknownKeys:`strict`,catchall:j.create(),typeName:$.ZodObject,...b(t)}),F.lazycreate=(e,t)=>new F({shape:e,unknownKeys:`strip`,catchall:j.create(),typeName:$.ZodObject,...b(t)});var I=class extends x{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new o(e.ctx.common.issues));return l(t,{code:i.invalid_union,unionErrors:n}),d}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let a=r.map(e=>new o(e));return l(t,{code:i.invalid_union,unionErrors:a}),d}}get options(){return this._def.options}};I.create=(e,t)=>new I({options:e,typeName:$.ZodUnion,...b(t)});const L=t=>t instanceof H?L(t.schema):t instanceof q?L(t.innerType()):t instanceof U?[t.value]:t instanceof W?t.options:t instanceof G?e.objectValues(t.enum):t instanceof X?L(t._def.innerType):t instanceof D?[void 0]:t instanceof O?[null]:t instanceof J?[void 0,...L(t.unwrap())]:t instanceof Y?[null,...L(t.unwrap())]:t instanceof Ve||t instanceof Q?L(t.unwrap()):t instanceof Z?L(t._def.innerType):[];var Pe=class e extends x{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==n.object)return l(t,{code:i.invalid_type,expected:n.object,received:t.parsedType}),d;let r=this.discriminator,a=t.data[r],o=this.optionsMap.get(a);return o?t.common.async?o._parseAsync({data:t.data,path:t.path,parent:t}):o._parseSync({data:t.data,path:t.path,parent:t}):(l(t,{code:i.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),d)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=L(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:$.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...b(r)})}};function Fe(t,i){let a=r(t),o=r(i);if(t===i)return{valid:!0,data:t};if(a===n.object&&o===n.object){let n=e.objectKeys(i),r=e.objectKeys(t).filter(e=>n.indexOf(e)!==-1),a={...t,...i};for(let e of r){let n=Fe(t[e],i[e]);if(!n.valid)return{valid:!1};a[e]=n.data}return{valid:!0,data:a}}else if(a===n.array&&o===n.array){if(t.length!==i.length)return{valid:!1};let e=[];for(let n=0;n<t.length;n++){let r=t[n],a=i[n],o=Fe(r,a);if(!o.valid)return{valid:!1};e.push(o.data)}return{valid:!0,data:e}}else if(a===n.date&&o===n.date&&+t==+i)return{valid:!0,data:t};else return{valid:!1}}var R=class extends x{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(ae(e)||ae(r))return d;let a=Fe(e.value,r.value);return a.valid?((oe(e)||oe(r))&&t.dirty(),{status:t.value,value:a.data}):(l(n,{code:i.invalid_intersection_types}),d)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};R.create=(e,t,n)=>new R({left:e,right:t,typeName:$.ZodIntersection,...b(n)});var z=class e extends x{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==n.array)return l(r,{code:i.invalid_type,expected:n.array,received:r.parsedType}),d;if(r.data.length<this._def.items.length)return l(r,{code:i.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),d;!this._def.rest&&r.data.length>this._def.items.length&&(l(r,{code:i.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let a=[...r.data].map((e,t)=>{let n=this._def.items[t]||this._def.rest;return n?n._parse(new y(r,e,r.path,t)):null}).filter(e=>!!e);return r.common.async?Promise.all(a).then(e=>u.mergeArray(t,e)):u.mergeArray(t,a)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};z.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new z({items:e,typeName:$.ZodTuple,rest:null,...b(t)})};var Ie=class e extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==n.object)return l(r,{code:i.invalid_type,expected:n.object,received:r.parsedType}),d;let a=[],o=this._def.keyType,s=this._def.valueType;for(let e in r.data)a.push({key:o._parse(new y(r,e,r.path,e)),value:s._parse(new y(r,r.data[e],r.path,e)),alwaysSet:e in r.data});return r.common.async?u.mergeObjectAsync(t,a):u.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof x?new e({keyType:t,valueType:n,typeName:$.ZodRecord,...b(r)}):new e({keyType:S.create(),valueType:t,typeName:$.ZodRecord,...b(n)})}},B=class extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==n.map)return l(r,{code:i.invalid_type,expected:n.map,received:r.parsedType}),d;let a=this._def.keyType,o=this._def.valueType,s=[...r.data.entries()].map(([e,t],n)=>({key:a._parse(new y(r,e,r.path,[n,`key`])),value:o._parse(new y(r,t,r.path,[n,`value`]))}));if(r.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of s){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return d;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of s){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return d;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};B.create=(e,t,n)=>new B({valueType:t,keyType:e,typeName:$.ZodMap,...b(n)});var V=class e extends x{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==n.set)return l(r,{code:i.invalid_type,expected:n.set,received:r.parsedType}),d;let a=this._def;a.minSize!==null&&r.data.size<a.minSize.value&&(l(r,{code:i.too_small,minimum:a.minSize.value,type:`set`,inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),a.maxSize!==null&&r.data.size>a.maxSize.value&&(l(r,{code:i.too_big,maximum:a.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());let o=this._def.valueType;function s(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return d;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let c=[...r.data.values()].map((e,t)=>o._parse(new y(r,e,r.path,t)));return r.common.async?Promise.all(c).then(e=>s(e)):s(c)}min(t,n){return new e({...this._def,minSize:{value:t,message:g.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:g.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};V.create=(e,t)=>new V({valueType:e,minSize:null,maxSize:null,typeName:$.ZodSet,...b(t)});var Le=class e extends x{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==n.function)return l(t,{code:i.invalid_type,expected:n.function,received:t.parsedType}),d;function r(e,n){return ne({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,te(),s].filter(e=>!!e),issueData:{code:i.invalid_arguments,argumentsError:n}})}function a(e,n){return ne({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,te(),s].filter(e=>!!e),issueData:{code:i.invalid_return_type,returnTypeError:n}})}let c={errorMap:t.common.contextualErrorMap},ee=t.data;if(this._def.returns instanceof K){let e=this;return f(async function(...t){let n=new o([]),i=await e._def.args.parseAsync(t,c).catch(e=>{throw n.addIssue(r(t,e)),n}),s=await Reflect.apply(ee,this,i);return await e._def.returns._def.type.parseAsync(s,c).catch(e=>{throw n.addIssue(a(s,e)),n})})}else{let e=this;return f(function(...t){let n=e._def.args.safeParse(t,c);if(!n.success)throw new o([r(t,n.error)]);let i=Reflect.apply(ee,this,n.data),s=e._def.returns.safeParse(i,c);if(!s.success)throw new o([a(i,s.error)]);return s.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:z.create(t).rest(A.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||z.create([]).rest(A.create()),returns:n||A.create(),typeName:$.ZodFunction,...b(r)})}},H=class extends x{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};H.create=(e,t)=>new H({getter:e,typeName:$.ZodLazy,...b(t)});var U=class extends x{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return l(t,{received:t.data,code:i.invalid_literal,expected:this._def.value}),d}return{status:`valid`,value:e.data}}get value(){return this._def.value}};U.create=(e,t)=>new U({value:e,typeName:$.ZodLiteral,...b(t)});function Re(e,t){return new W({values:e,typeName:$.ZodEnum,...b(t)})}var W=class t extends x{constructor(){super(...arguments),_.set(this,void 0)}_parse(t){if(typeof t.data!=`string`){let n=this._getOrReturnCtx(t),r=this._def.values;return l(n,{expected:e.joinValues(r),received:n.parsedType,code:i.invalid_type}),d}if(h(this,_,`f`)||se(this,_,new Set(this._def.values),`f`),!h(this,_,`f`).has(t.data)){let e=this._getOrReturnCtx(t),n=this._def.values;return l(e,{received:e.data,code:i.invalid_enum_value,options:n}),d}return f(t.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(t=>!e.includes(t)),{...this._def,...n})}};_=new WeakMap,W.create=Re;var G=class extends x{constructor(){super(...arguments),v.set(this,void 0)}_parse(t){let r=e.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(t);if(a.parsedType!==n.string&&a.parsedType!==n.number){let t=e.objectValues(r);return l(a,{expected:e.joinValues(t),received:a.parsedType,code:i.invalid_type}),d}if(h(this,v,`f`)||se(this,v,new Set(e.getValidEnumValues(this._def.values)),`f`),!h(this,v,`f`).has(t.data)){let t=e.objectValues(r);return l(a,{received:a.data,code:i.invalid_enum_value,options:t}),d}return f(t.data)}get enum(){return this._def.values}};v=new WeakMap,G.create=(e,t)=>new G({values:e,typeName:$.ZodNativeEnum,...b(t)});var K=class extends x{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==n.promise&&t.common.async===!1?(l(t,{code:i.invalid_type,expected:n.promise,received:t.parsedType}),d):f((t.parsedType===n.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};K.create=(e,t)=>new K({type:e,typeName:$.ZodPromise,...b(t)});var q=class extends x{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===$.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:n,ctx:r}=this._processInputParams(t),i=this._def.effect||null,a={addIssue:e=>{l(r,e),e.fatal?n.abort():n.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),i.type===`preprocess`){let e=i.transform(r.data,a);if(r.common.async)return Promise.resolve(e).then(async e=>{if(n.value===`aborted`)return d;let t=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return t.status===`aborted`?d:t.status===`dirty`||n.value===`dirty`?ie(t.value):t});{if(n.value===`aborted`)return d;let t=this._def.schema._parseSync({data:e,path:r.path,parent:r});return t.status===`aborted`?d:t.status===`dirty`||n.value===`dirty`?ie(t.value):t}}if(i.type===`refinement`){let e=e=>{let t=i.refinement(e,a);if(r.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(r.common.async===!1){let t=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return t.status===`aborted`?d:(t.status===`dirty`&&n.dirty(),e(t.value),{status:n.value,value:t.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(t=>t.status===`aborted`?d:(t.status===`dirty`&&n.dirty(),e(t.value).then(()=>({status:n.value,value:t.value}))))}if(i.type===`transform`)if(r.common.async===!1){let e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!p(e))return e;let t=i.transform(e.value,a);if(t instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:n.value,value:t}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(e=>p(e)?Promise.resolve(i.transform(e.value,a)).then(e=>({status:n.value,value:e})):e);e.assertNever(i)}};q.create=(e,t,n)=>new q({schema:e,typeName:$.ZodEffects,effect:t,...b(n)}),q.createWithPreprocess=(e,t,n)=>new q({schema:t,effect:{type:`preprocess`,transform:e},typeName:$.ZodEffects,...b(n)});var J=class extends x{_parse(e){return this._getType(e)===n.undefined?f(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};J.create=(e,t)=>new J({innerType:e,typeName:$.ZodOptional,...b(t)});var Y=class extends x{_parse(e){return this._getType(e)===n.null?f(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Y.create=(e,t)=>new Y({innerType:e,typeName:$.ZodNullable,...b(t)});var X=class extends x{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return t.parsedType===n.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};X.create=(e,t)=>new X({innerType:e,typeName:$.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...b(t)});var Z=class extends x{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return m(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new o(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new o(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Z.create=(e,t)=>new Z({innerType:e,typeName:$.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...b(t)});var ze=class extends x{_parse(e){if(this._getType(e)!==n.nan){let t=this._getOrReturnCtx(e);return l(t,{code:i.invalid_type,expected:n.nan,received:t.parsedType}),d}return{status:`valid`,value:e.data}}};ze.create=e=>new ze({typeName:$.ZodNaN,...b(e)});const Be=Symbol(`zod_brand`);var Ve=class extends x{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},He=class e extends x{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?d:e.status===`dirty`?(t.dirty(),ie(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?d:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:$.ZodPipeline})}},Q=class extends x{_parse(e){let t=this._def.innerType._parse(e),n=e=>(p(e)&&(e.value=Object.freeze(e.value)),e);return m(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};Q.create=(e,t)=>new Q({innerType:e,typeName:$.ZodReadonly,...b(t)});function Ue(e,t){let n=typeof e==`function`?e(t):typeof e==`string`?{message:e}:e;return typeof n==`string`?{message:n}:n}function We(e,t={},n){return e?k.create().superRefine((r,i)=>{let a=e(r);if(a instanceof Promise)return a.then(e=>{if(!e){let e=Ue(t,r),a=e.fatal??n??!0;i.addIssue({code:`custom`,...e,fatal:a})}});if(!a){let e=Ue(t,r),a=e.fatal??n??!0;i.addIssue({code:`custom`,...e,fatal:a})}}):k.create()}const Ge={object:F.lazycreate};var $;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})($||={});const Ke=(e,t={message:`Input not instance of ${e.name}`})=>We(t=>t instanceof e,t),qe=S.create,Je=C.create,Ye=ze.create,Xe=w.create,Ze=T.create,Qe=E.create,$e=Ne.create,et=D.create,tt=O.create,nt=k.create,rt=A.create,it=j.create,at=M.create,ot=N.create,st=F.create,ct=F.strictCreate,lt=I.create,ut=Pe.create,dt=R.create,ft=z.create,pt=Ie.create,mt=B.create,ht=V.create,gt=Le.create,_t=H.create,vt=U.create,yt=W.create,bt=G.create,xt=K.create,St=q.create,Ct=J.create,wt=Y.create,Tt=q.createWithPreprocess,Et=He.create;var Dt=Object.freeze({__proto__:null,defaultErrorMap:s,setErrorMap:ee,getErrorMap:te,makeIssue:ne,EMPTY_PATH:re,addIssueToContext:l,ParseStatus:u,INVALID:d,DIRTY:ie,OK:f,isAborted:ae,isDirty:oe,isValid:p,isAsync:m,get util(){return e},get objectUtil(){return t},ZodParsedType:n,getParsedType:r,ZodType:x,datetimeRegex:Oe,ZodString:S,ZodNumber:C,ZodBigInt:w,ZodBoolean:T,ZodDate:E,ZodSymbol:Ne,ZodUndefined:D,ZodNull:O,ZodAny:k,ZodUnknown:A,ZodNever:j,ZodVoid:M,ZodArray:N,ZodObject:F,ZodUnion:I,ZodDiscriminatedUnion:Pe,ZodIntersection:R,ZodTuple:z,ZodRecord:Ie,ZodMap:B,ZodSet:V,ZodFunction:Le,ZodLazy:H,ZodLiteral:U,ZodEnum:W,ZodNativeEnum:G,ZodPromise:K,ZodEffects:q,ZodTransformer:q,ZodOptional:J,ZodNullable:Y,ZodDefault:X,ZodCatch:Z,ZodNaN:ze,BRAND:Be,ZodBranded:Ve,ZodPipeline:He,ZodReadonly:Q,custom:We,Schema:x,ZodSchema:x,late:Ge,get ZodFirstPartyTypeKind(){return $},coerce:{string:(e=>S.create({...e,coerce:!0})),number:(e=>C.create({...e,coerce:!0})),boolean:(e=>T.create({...e,coerce:!0})),bigint:(e=>w.create({...e,coerce:!0})),date:(e=>E.create({...e,coerce:!0}))},any:nt,array:ot,bigint:Xe,boolean:Ze,date:Qe,discriminatedUnion:ut,effect:St,enum:yt,function:gt,instanceof:Ke,intersection:dt,lazy:_t,literal:vt,map:mt,nan:Ye,nativeEnum:bt,never:it,null:tt,nullable:wt,number:Je,object:st,oboolean:()=>Ze().optional(),onumber:()=>Je().optional(),optional:Ct,ostring:()=>qe().optional(),pipeline:Et,preprocess:Tt,promise:xt,record:pt,set:ht,strictObject:ct,string:qe,symbol:$e,transformer:St,tuple:ft,undefined:et,union:lt,unknown:rt,void:at,NEVER:d,ZodIssueCode:i,quotelessJson:a,ZodError:o});const Ot=`2.0.0-beta.24`;export{Dt as n,Ot as t};
1
+ var e;(function(e){e.assertEqual=e=>e;function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(e||={});var t;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(t||={});const n=e.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),r=e=>{switch(typeof e){case`undefined`:return n.undefined;case`string`:return n.string;case`number`:return isNaN(e)?n.nan:n.number;case`boolean`:return n.boolean;case`function`:return n.function;case`bigint`:return n.bigint;case`symbol`:return n.symbol;case`object`:return Array.isArray(e)?n.array:e===null?n.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?n.promise:typeof Map<`u`&&e instanceof Map?n.map:typeof Set<`u`&&e instanceof Set?n.set:typeof Date<`u`&&e instanceof Date?n.date:n.object;default:return n.unknown}},i=e.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),a=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,`$1:`);var o=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(e){if(!(e instanceof t))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,e.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};o.create=e=>new o(e);const s=(t,r)=>{let a;switch(t.code){case i.invalid_type:a=t.received===n.undefined?`Required`:`Expected ${t.expected}, received ${t.received}`;break;case i.invalid_literal:a=`Invalid literal value, expected ${JSON.stringify(t.expected,e.jsonStringifyReplacer)}`;break;case i.unrecognized_keys:a=`Unrecognized key(s) in object: ${e.joinValues(t.keys,`, `)}`;break;case i.invalid_union:a=`Invalid input`;break;case i.invalid_union_discriminator:a=`Invalid discriminator value. Expected ${e.joinValues(t.options)}`;break;case i.invalid_enum_value:a=`Invalid enum value. Expected ${e.joinValues(t.options)}, received '${t.received}'`;break;case i.invalid_arguments:a=`Invalid function arguments`;break;case i.invalid_return_type:a=`Invalid function return type`;break;case i.invalid_date:a=`Invalid date`;break;case i.invalid_string:typeof t.validation==`object`?`includes`in t.validation?(a=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position==`number`&&(a=`${a} at one or more positions greater than or equal to ${t.validation.position}`)):`startsWith`in t.validation?a=`Invalid input: must start with "${t.validation.startsWith}"`:`endsWith`in t.validation?a=`Invalid input: must end with "${t.validation.endsWith}"`:e.assertNever(t.validation):a=t.validation===`regex`?`Invalid`:`Invalid ${t.validation}`;break;case i.too_small:a=t.type===`array`?`Array must contain ${t.exact?`exactly`:t.inclusive?`at least`:`more than`} ${t.minimum} element(s)`:t.type===`string`?`String must contain ${t.exact?`exactly`:t.inclusive?`at least`:`over`} ${t.minimum} character(s)`:t.type===`number`?`Number must be ${t.exact?`exactly equal to `:t.inclusive?`greater than or equal to `:`greater than `}${t.minimum}`:t.type===`date`?`Date must be ${t.exact?`exactly equal to `:t.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(t.minimum))}`:`Invalid input`;break;case i.too_big:a=t.type===`array`?`Array must contain ${t.exact?`exactly`:t.inclusive?`at most`:`less than`} ${t.maximum} element(s)`:t.type===`string`?`String must contain ${t.exact?`exactly`:t.inclusive?`at most`:`under`} ${t.maximum} character(s)`:t.type===`number`?`Number must be ${t.exact?`exactly`:t.inclusive?`less than or equal to`:`less than`} ${t.maximum}`:t.type===`bigint`?`BigInt must be ${t.exact?`exactly`:t.inclusive?`less than or equal to`:`less than`} ${t.maximum}`:t.type===`date`?`Date must be ${t.exact?`exactly`:t.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(t.maximum))}`:`Invalid input`;break;case i.custom:a=`Invalid input`;break;case i.invalid_intersection_types:a=`Intersection results could not be merged`;break;case i.not_multiple_of:a=`Number must be a multiple of ${t.multipleOf}`;break;case i.not_finite:a=`Number must be finite`;break;default:a=r.defaultError,e.assertNever(t)}return{message:a}};let c=s;function ee(e){c=e}function te(){return c}const ne=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}},re=[];function l(e,t){let n=te(),r=ne({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===s?void 0:s].filter(e=>!!e)});e.common.issues.push(r)}var u=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return d;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return d;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}};const d=Object.freeze({status:`aborted`}),ie=e=>({status:`dirty`,value:e}),f=e=>({status:`valid`,value:e}),ae=e=>e.status===`aborted`,oe=e=>e.status===`dirty`,p=e=>e.status===`valid`,m=e=>typeof Promise<`u`&&e instanceof Promise;function h(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function se(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}var g;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(g||={});var _,v,y=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};const ce=(e,t)=>{if(p(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new o(e.common.issues);return this._error=t,this._error}}};function b(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var x=class{get description(){return this._def.description}_getType(e){return r(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:r(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new u,ctx:{common:e.parent.common,data:e.data,parsedType:r(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(m(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:r(e)};return ce(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:r(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return p(n)?{value:n.value}:{issues:t.common.issues}}catch(e){((e?.message)?.toLowerCase())?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>p(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:r(e)},i=this._parse({data:e,path:n.path,parent:n});return ce(n,await(m(i)?i:Promise.resolve(i)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let a=e(t),o=()=>r.addIssue({code:i.custom,...n(t)});return typeof Promise<`u`&&a instanceof Promise?a.then(e=>e?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new q({schema:this,typeName:$.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return J.create(this,this._def)}nullable(){return Y.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return N.create(this)}promise(){return K.create(this,this._def)}or(e){return I.create([this,e],this._def)}and(e){return R.create(this,e,this._def)}transform(e){return new q({...b(this._def),schema:this,typeName:$.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new X({...b(this._def),innerType:this,defaultValue:t,typeName:$.ZodDefault})}brand(){return new Ve({typeName:$.ZodBranded,type:this,...b(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new Z({...b(this._def),innerType:this,catchValue:t,typeName:$.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return He.create(this,e)}readonly(){return Q.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const le=/^c[^\s-]{8,}$/i,ue=/^[0-9a-z]+$/,de=/^[0-9A-HJKMNP-TV-Z]{26}$/i,fe=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,pe=/^[a-z0-9_-]{21}$/i,me=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,he=/^[-+]?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)?)??$/,ge=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let _e;const ve=/^(?:(?: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])$/,ye=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,be=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,xe=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Se=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ce=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,we=`((\\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])))`,Te=RegExp(`^${we}$`);function Ee(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function De(e){return RegExp(`^${Ee(e)}$`)}function Oe(e){let t=`${we}T${Ee(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function ke(e,t){return!!((t===`v4`||!t)&&ve.test(e)||(t===`v6`||!t)&&be.test(e))}function Ae(e,t){if(!me.test(e))return!1;try{let[n]=e.split(`.`),r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||!i.typ||!i.alg||t&&i.alg!==t)}catch{return!1}}function je(e,t){return!!((t===`v4`||!t)&&ye.test(e)||(t===`v6`||!t)&&xe.test(e))}var S=class t extends x{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==n.string){let e=this._getOrReturnCtx(t);return l(e,{code:i.invalid_type,expected:n.string,received:e.parsedType}),d}let r=new u,a;for(let n of this._def.checks)if(n.kind===`min`)t.data.length<n.value&&(a=this._getOrReturnCtx(t,a),l(a,{code:i.too_small,minimum:n.value,type:`string`,inclusive:!0,exact:!1,message:n.message}),r.dirty());else if(n.kind===`max`)t.data.length>n.value&&(a=this._getOrReturnCtx(t,a),l(a,{code:i.too_big,maximum:n.value,type:`string`,inclusive:!0,exact:!1,message:n.message}),r.dirty());else if(n.kind===`length`){let e=t.data.length>n.value,o=t.data.length<n.value;(e||o)&&(a=this._getOrReturnCtx(t,a),e?l(a,{code:i.too_big,maximum:n.value,type:`string`,inclusive:!0,exact:!0,message:n.message}):o&&l(a,{code:i.too_small,minimum:n.value,type:`string`,inclusive:!0,exact:!0,message:n.message}),r.dirty())}else if(n.kind===`email`)ge.test(t.data)||(a=this._getOrReturnCtx(t,a),l(a,{validation:`email`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`emoji`)_e||=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`),_e.test(t.data)||(a=this._getOrReturnCtx(t,a),l(a,{validation:`emoji`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`uuid`)fe.test(t.data)||(a=this._getOrReturnCtx(t,a),l(a,{validation:`uuid`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`nanoid`)pe.test(t.data)||(a=this._getOrReturnCtx(t,a),l(a,{validation:`nanoid`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`cuid`)le.test(t.data)||(a=this._getOrReturnCtx(t,a),l(a,{validation:`cuid`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`cuid2`)ue.test(t.data)||(a=this._getOrReturnCtx(t,a),l(a,{validation:`cuid2`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`ulid`)de.test(t.data)||(a=this._getOrReturnCtx(t,a),l(a,{validation:`ulid`,code:i.invalid_string,message:n.message}),r.dirty());else if(n.kind===`url`)try{new URL(t.data)}catch{a=this._getOrReturnCtx(t,a),l(a,{validation:`url`,code:i.invalid_string,message:n.message}),r.dirty()}else n.kind===`regex`?(n.regex.lastIndex=0,n.regex.test(t.data)||(a=this._getOrReturnCtx(t,a),l(a,{validation:`regex`,code:i.invalid_string,message:n.message}),r.dirty())):n.kind===`trim`?t.data=t.data.trim():n.kind===`includes`?t.data.includes(n.value,n.position)||(a=this._getOrReturnCtx(t,a),l(a,{code:i.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),r.dirty()):n.kind===`toLowerCase`?t.data=t.data.toLowerCase():n.kind===`toUpperCase`?t.data=t.data.toUpperCase():n.kind===`startsWith`?t.data.startsWith(n.value)||(a=this._getOrReturnCtx(t,a),l(a,{code:i.invalid_string,validation:{startsWith:n.value},message:n.message}),r.dirty()):n.kind===`endsWith`?t.data.endsWith(n.value)||(a=this._getOrReturnCtx(t,a),l(a,{code:i.invalid_string,validation:{endsWith:n.value},message:n.message}),r.dirty()):n.kind===`datetime`?Oe(n).test(t.data)||(a=this._getOrReturnCtx(t,a),l(a,{code:i.invalid_string,validation:`datetime`,message:n.message}),r.dirty()):n.kind===`date`?Te.test(t.data)||(a=this._getOrReturnCtx(t,a),l(a,{code:i.invalid_string,validation:`date`,message:n.message}),r.dirty()):n.kind===`time`?De(n).test(t.data)||(a=this._getOrReturnCtx(t,a),l(a,{code:i.invalid_string,validation:`time`,message:n.message}),r.dirty()):n.kind===`duration`?he.test(t.data)||(a=this._getOrReturnCtx(t,a),l(a,{validation:`duration`,code:i.invalid_string,message:n.message}),r.dirty()):n.kind===`ip`?ke(t.data,n.version)||(a=this._getOrReturnCtx(t,a),l(a,{validation:`ip`,code:i.invalid_string,message:n.message}),r.dirty()):n.kind===`jwt`?Ae(t.data,n.alg)||(a=this._getOrReturnCtx(t,a),l(a,{validation:`jwt`,code:i.invalid_string,message:n.message}),r.dirty()):n.kind===`cidr`?je(t.data,n.version)||(a=this._getOrReturnCtx(t,a),l(a,{validation:`cidr`,code:i.invalid_string,message:n.message}),r.dirty()):n.kind===`base64`?Se.test(t.data)||(a=this._getOrReturnCtx(t,a),l(a,{validation:`base64`,code:i.invalid_string,message:n.message}),r.dirty()):n.kind===`base64url`?Ce.test(t.data)||(a=this._getOrReturnCtx(t,a),l(a,{validation:`base64url`,code:i.invalid_string,message:n.message}),r.dirty()):e.assertNever(n);return{status:r.value,value:t.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:i.invalid_string,...g.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:`email`,...g.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...g.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...g.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...g.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...g.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...g.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...g.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...g.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...g.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...g.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...g.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...g.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...g.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...g.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...g.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...g.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...g.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...g.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...g.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...g.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...g.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...g.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...g.errToObj(t)})}nonempty(e){return this.min(1,g.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};S.create=e=>new S({checks:[],typeName:$.ZodString,coerce:e?.coerce??!1,...b(e)});function Me(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return parseInt(e.toFixed(i).replace(`.`,``))%parseInt(t.toFixed(i).replace(`.`,``))/10**i}var C=class t extends x{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==n.number){let e=this._getOrReturnCtx(t);return l(e,{code:i.invalid_type,expected:n.number,received:e.parsedType}),d}let r,a=new u;for(let n of this._def.checks)n.kind===`int`?e.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),l(r,{code:i.invalid_type,expected:`integer`,received:`float`,message:n.message}),a.dirty()):n.kind===`min`?(n.inclusive?t.data<n.value:t.data<=n.value)&&(r=this._getOrReturnCtx(t,r),l(r,{code:i.too_small,minimum:n.value,type:`number`,inclusive:n.inclusive,exact:!1,message:n.message}),a.dirty()):n.kind===`max`?(n.inclusive?t.data>n.value:t.data>=n.value)&&(r=this._getOrReturnCtx(t,r),l(r,{code:i.too_big,maximum:n.value,type:`number`,inclusive:n.inclusive,exact:!1,message:n.message}),a.dirty()):n.kind===`multipleOf`?Me(t.data,n.value)!==0&&(r=this._getOrReturnCtx(t,r),l(r,{code:i.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):n.kind===`finite`?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),l(r,{code:i.not_finite,message:n.message}),a.dirty()):e.assertNever(n);return{status:a.value,value:t.data}}gte(e,t){return this.setLimit(`min`,e,!0,g.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,g.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,g.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,g.toString(t))}setLimit(e,n,r,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:g.toString(i)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:`int`,message:g.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:g.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:g.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:g.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:g.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:g.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(t=>t.kind===`int`||t.kind===`multipleOf`&&e.isInteger(t.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};C.create=e=>new C({checks:[],typeName:$.ZodNumber,coerce:e?.coerce||!1,...b(e)});var w=class t extends x{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==n.bigint)return this._getInvalidInput(t);let r,a=new u;for(let n of this._def.checks)n.kind===`min`?(n.inclusive?t.data<n.value:t.data<=n.value)&&(r=this._getOrReturnCtx(t,r),l(r,{code:i.too_small,type:`bigint`,minimum:n.value,inclusive:n.inclusive,message:n.message}),a.dirty()):n.kind===`max`?(n.inclusive?t.data>n.value:t.data>=n.value)&&(r=this._getOrReturnCtx(t,r),l(r,{code:i.too_big,type:`bigint`,maximum:n.value,inclusive:n.inclusive,message:n.message}),a.dirty()):n.kind===`multipleOf`?t.data%n.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),l(r,{code:i.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):e.assertNever(n);return{status:a.value,value:t.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return l(t,{code:i.invalid_type,expected:n.bigint,received:t.parsedType}),d}gte(e,t){return this.setLimit(`min`,e,!0,g.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,g.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,g.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,g.toString(t))}setLimit(e,n,r,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:g.toString(i)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:g.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:g.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};w.create=e=>new w({checks:[],typeName:$.ZodBigInt,coerce:e?.coerce??!1,...b(e)});var T=class extends x{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==n.boolean){let t=this._getOrReturnCtx(e);return l(t,{code:i.invalid_type,expected:n.boolean,received:t.parsedType}),d}return f(e.data)}};T.create=e=>new T({typeName:$.ZodBoolean,coerce:e?.coerce||!1,...b(e)});var E=class t extends x{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==n.date){let e=this._getOrReturnCtx(t);return l(e,{code:i.invalid_type,expected:n.date,received:e.parsedType}),d}if(isNaN(t.data.getTime()))return l(this._getOrReturnCtx(t),{code:i.invalid_date}),d;let r=new u,a;for(let n of this._def.checks)n.kind===`min`?t.data.getTime()<n.value&&(a=this._getOrReturnCtx(t,a),l(a,{code:i.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:`date`}),r.dirty()):n.kind===`max`?t.data.getTime()>n.value&&(a=this._getOrReturnCtx(t,a),l(a,{code:i.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:`date`}),r.dirty()):e.assertNever(n);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:g.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:g.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};E.create=e=>new E({checks:[],coerce:e?.coerce||!1,typeName:$.ZodDate,...b(e)});var Ne=class extends x{_parse(e){if(this._getType(e)!==n.symbol){let t=this._getOrReturnCtx(e);return l(t,{code:i.invalid_type,expected:n.symbol,received:t.parsedType}),d}return f(e.data)}};Ne.create=e=>new Ne({typeName:$.ZodSymbol,...b(e)});var D=class extends x{_parse(e){if(this._getType(e)!==n.undefined){let t=this._getOrReturnCtx(e);return l(t,{code:i.invalid_type,expected:n.undefined,received:t.parsedType}),d}return f(e.data)}};D.create=e=>new D({typeName:$.ZodUndefined,...b(e)});var O=class extends x{_parse(e){if(this._getType(e)!==n.null){let t=this._getOrReturnCtx(e);return l(t,{code:i.invalid_type,expected:n.null,received:t.parsedType}),d}return f(e.data)}};O.create=e=>new O({typeName:$.ZodNull,...b(e)});var k=class extends x{constructor(){super(...arguments),this._any=!0}_parse(e){return f(e.data)}};k.create=e=>new k({typeName:$.ZodAny,...b(e)});var A=class extends x{constructor(){super(...arguments),this._unknown=!0}_parse(e){return f(e.data)}};A.create=e=>new A({typeName:$.ZodUnknown,...b(e)});var j=class extends x{_parse(e){let t=this._getOrReturnCtx(e);return l(t,{code:i.invalid_type,expected:n.never,received:t.parsedType}),d}};j.create=e=>new j({typeName:$.ZodNever,...b(e)});var M=class extends x{_parse(e){if(this._getType(e)!==n.undefined){let t=this._getOrReturnCtx(e);return l(t,{code:i.invalid_type,expected:n.void,received:t.parsedType}),d}return f(e.data)}};M.create=e=>new M({typeName:$.ZodVoid,...b(e)});var N=class e extends x{_parse(e){let{ctx:t,status:r}=this._processInputParams(e),a=this._def;if(t.parsedType!==n.array)return l(t,{code:i.invalid_type,expected:n.array,received:t.parsedType}),d;if(a.exactLength!==null){let e=t.data.length>a.exactLength.value,n=t.data.length<a.exactLength.value;(e||n)&&(l(t,{code:e?i.too_big:i.too_small,minimum:n?a.exactLength.value:void 0,maximum:e?a.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:a.exactLength.message}),r.dirty())}if(a.minLength!==null&&t.data.length<a.minLength.value&&(l(t,{code:i.too_small,minimum:a.minLength.value,type:`array`,inclusive:!0,exact:!1,message:a.minLength.message}),r.dirty()),a.maxLength!==null&&t.data.length>a.maxLength.value&&(l(t,{code:i.too_big,maximum:a.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:a.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>a.type._parseAsync(new y(t,e,t.path,n)))).then(e=>u.mergeArray(r,e));let o=[...t.data].map((e,n)=>a.type._parseSync(new y(t,e,t.path,n)));return u.mergeArray(r,o)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:g.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:g.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:g.toString(n)}})}nonempty(e){return this.min(1,e)}};N.create=(e,t)=>new N({type:e,minLength:null,maxLength:null,exactLength:null,typeName:$.ZodArray,...b(t)});function P(e){if(e instanceof F){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=J.create(P(r))}return new F({...e._def,shape:()=>t})}else if(e instanceof N)return new N({...e._def,type:P(e.element)});else if(e instanceof J)return J.create(P(e.unwrap()));else if(e instanceof Y)return Y.create(P(e.unwrap()));else if(e instanceof z)return z.create(e.items.map(e=>P(e)));else return e}var F=class t extends x{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),n=e.objectKeys(t);return this._cached={shape:t,keys:n}}_parse(e){if(this._getType(e)!==n.object){let t=this._getOrReturnCtx(e);return l(t,{code:i.invalid_type,expected:n.object,received:t.parsedType}),d}let{status:t,ctx:r}=this._processInputParams(e),{shape:a,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof j&&this._def.unknownKeys===`strip`))for(let e in r.data)o.includes(e)||s.push(e);let c=[];for(let e of o){let t=a[e],n=r.data[e];c.push({key:{status:`valid`,value:e},value:t._parse(new y(r,n,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof j){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of s)c.push({key:{status:`valid`,value:e},value:{status:`valid`,value:r.data[e]}});else if(e===`strict`)s.length>0&&(l(r,{code:i.unrecognized_keys,keys:s}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of s){let n=r.data[t];c.push({key:{status:`valid`,value:t},value:e._parse(new y(r,n,r.path,t)),alwaysSet:t in r.data})}}return r.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of c){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>u.mergeObjectSync(t,e)):u.mergeObjectSync(t,c)}get shape(){return this._def.shape()}strict(e){return g.errToObj,new t({...this._def,unknownKeys:`strict`,...e===void 0?{}:{errorMap:(t,n)=>{var r;let i=(r=this._def).errorMap?.call(r,t,n).message??n.defaultError;return t.code===`unrecognized_keys`?{message:g.errToObj(e).message??i}:{message:i}}}})}strip(){return new t({...this._def,unknownKeys:`strip`})}passthrough(){return new t({...this._def,unknownKeys:`passthrough`})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:$.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new t({...this._def,catchall:e})}pick(n){let r={};return e.objectKeys(n).forEach(e=>{n[e]&&this.shape[e]&&(r[e]=this.shape[e])}),new t({...this._def,shape:()=>r})}omit(n){let r={};return e.objectKeys(this.shape).forEach(e=>{n[e]||(r[e]=this.shape[e])}),new t({...this._def,shape:()=>r})}deepPartial(){return P(this)}partial(n){let r={};return e.objectKeys(this.shape).forEach(e=>{let t=this.shape[e];n&&!n[e]?r[e]=t:r[e]=t.optional()}),new t({...this._def,shape:()=>r})}required(n){let r={};return e.objectKeys(this.shape).forEach(e=>{if(n&&!n[e])r[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof J;)t=t._def.innerType;r[e]=t}}),new t({...this._def,shape:()=>r})}keyof(){return Re(e.objectKeys(this.shape))}};F.create=(e,t)=>new F({shape:()=>e,unknownKeys:`strip`,catchall:j.create(),typeName:$.ZodObject,...b(t)}),F.strictCreate=(e,t)=>new F({shape:()=>e,unknownKeys:`strict`,catchall:j.create(),typeName:$.ZodObject,...b(t)}),F.lazycreate=(e,t)=>new F({shape:e,unknownKeys:`strip`,catchall:j.create(),typeName:$.ZodObject,...b(t)});var I=class extends x{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new o(e.ctx.common.issues));return l(t,{code:i.invalid_union,unionErrors:n}),d}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let a=r.map(e=>new o(e));return l(t,{code:i.invalid_union,unionErrors:a}),d}}get options(){return this._def.options}};I.create=(e,t)=>new I({options:e,typeName:$.ZodUnion,...b(t)});const L=t=>t instanceof H?L(t.schema):t instanceof q?L(t.innerType()):t instanceof U?[t.value]:t instanceof W?t.options:t instanceof G?e.objectValues(t.enum):t instanceof X?L(t._def.innerType):t instanceof D?[void 0]:t instanceof O?[null]:t instanceof J?[void 0,...L(t.unwrap())]:t instanceof Y?[null,...L(t.unwrap())]:t instanceof Ve||t instanceof Q?L(t.unwrap()):t instanceof Z?L(t._def.innerType):[];var Pe=class e extends x{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==n.object)return l(t,{code:i.invalid_type,expected:n.object,received:t.parsedType}),d;let r=this.discriminator,a=t.data[r],o=this.optionsMap.get(a);return o?t.common.async?o._parseAsync({data:t.data,path:t.path,parent:t}):o._parseSync({data:t.data,path:t.path,parent:t}):(l(t,{code:i.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),d)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=L(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:$.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...b(r)})}};function Fe(t,i){let a=r(t),o=r(i);if(t===i)return{valid:!0,data:t};if(a===n.object&&o===n.object){let n=e.objectKeys(i),r=e.objectKeys(t).filter(e=>n.indexOf(e)!==-1),a={...t,...i};for(let e of r){let n=Fe(t[e],i[e]);if(!n.valid)return{valid:!1};a[e]=n.data}return{valid:!0,data:a}}else if(a===n.array&&o===n.array){if(t.length!==i.length)return{valid:!1};let e=[];for(let n=0;n<t.length;n++){let r=t[n],a=i[n],o=Fe(r,a);if(!o.valid)return{valid:!1};e.push(o.data)}return{valid:!0,data:e}}else if(a===n.date&&o===n.date&&+t==+i)return{valid:!0,data:t};else return{valid:!1}}var R=class extends x{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(ae(e)||ae(r))return d;let a=Fe(e.value,r.value);return a.valid?((oe(e)||oe(r))&&t.dirty(),{status:t.value,value:a.data}):(l(n,{code:i.invalid_intersection_types}),d)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};R.create=(e,t,n)=>new R({left:e,right:t,typeName:$.ZodIntersection,...b(n)});var z=class e extends x{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==n.array)return l(r,{code:i.invalid_type,expected:n.array,received:r.parsedType}),d;if(r.data.length<this._def.items.length)return l(r,{code:i.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),d;!this._def.rest&&r.data.length>this._def.items.length&&(l(r,{code:i.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let a=[...r.data].map((e,t)=>{let n=this._def.items[t]||this._def.rest;return n?n._parse(new y(r,e,r.path,t)):null}).filter(e=>!!e);return r.common.async?Promise.all(a).then(e=>u.mergeArray(t,e)):u.mergeArray(t,a)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};z.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new z({items:e,typeName:$.ZodTuple,rest:null,...b(t)})};var Ie=class e extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==n.object)return l(r,{code:i.invalid_type,expected:n.object,received:r.parsedType}),d;let a=[],o=this._def.keyType,s=this._def.valueType;for(let e in r.data)a.push({key:o._parse(new y(r,e,r.path,e)),value:s._parse(new y(r,r.data[e],r.path,e)),alwaysSet:e in r.data});return r.common.async?u.mergeObjectAsync(t,a):u.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof x?new e({keyType:t,valueType:n,typeName:$.ZodRecord,...b(r)}):new e({keyType:S.create(),valueType:t,typeName:$.ZodRecord,...b(n)})}},B=class extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==n.map)return l(r,{code:i.invalid_type,expected:n.map,received:r.parsedType}),d;let a=this._def.keyType,o=this._def.valueType,s=[...r.data.entries()].map(([e,t],n)=>({key:a._parse(new y(r,e,r.path,[n,`key`])),value:o._parse(new y(r,t,r.path,[n,`value`]))}));if(r.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of s){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return d;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of s){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return d;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};B.create=(e,t,n)=>new B({valueType:t,keyType:e,typeName:$.ZodMap,...b(n)});var V=class e extends x{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==n.set)return l(r,{code:i.invalid_type,expected:n.set,received:r.parsedType}),d;let a=this._def;a.minSize!==null&&r.data.size<a.minSize.value&&(l(r,{code:i.too_small,minimum:a.minSize.value,type:`set`,inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),a.maxSize!==null&&r.data.size>a.maxSize.value&&(l(r,{code:i.too_big,maximum:a.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());let o=this._def.valueType;function s(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return d;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let c=[...r.data.values()].map((e,t)=>o._parse(new y(r,e,r.path,t)));return r.common.async?Promise.all(c).then(e=>s(e)):s(c)}min(t,n){return new e({...this._def,minSize:{value:t,message:g.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:g.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};V.create=(e,t)=>new V({valueType:e,minSize:null,maxSize:null,typeName:$.ZodSet,...b(t)});var Le=class e extends x{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==n.function)return l(t,{code:i.invalid_type,expected:n.function,received:t.parsedType}),d;function r(e,n){return ne({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,te(),s].filter(e=>!!e),issueData:{code:i.invalid_arguments,argumentsError:n}})}function a(e,n){return ne({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,te(),s].filter(e=>!!e),issueData:{code:i.invalid_return_type,returnTypeError:n}})}let c={errorMap:t.common.contextualErrorMap},ee=t.data;if(this._def.returns instanceof K){let e=this;return f(async function(...t){let n=new o([]),i=await e._def.args.parseAsync(t,c).catch(e=>{throw n.addIssue(r(t,e)),n}),s=await Reflect.apply(ee,this,i);return await e._def.returns._def.type.parseAsync(s,c).catch(e=>{throw n.addIssue(a(s,e)),n})})}else{let e=this;return f(function(...t){let n=e._def.args.safeParse(t,c);if(!n.success)throw new o([r(t,n.error)]);let i=Reflect.apply(ee,this,n.data),s=e._def.returns.safeParse(i,c);if(!s.success)throw new o([a(i,s.error)]);return s.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:z.create(t).rest(A.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||z.create([]).rest(A.create()),returns:n||A.create(),typeName:$.ZodFunction,...b(r)})}},H=class extends x{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};H.create=(e,t)=>new H({getter:e,typeName:$.ZodLazy,...b(t)});var U=class extends x{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return l(t,{received:t.data,code:i.invalid_literal,expected:this._def.value}),d}return{status:`valid`,value:e.data}}get value(){return this._def.value}};U.create=(e,t)=>new U({value:e,typeName:$.ZodLiteral,...b(t)});function Re(e,t){return new W({values:e,typeName:$.ZodEnum,...b(t)})}var W=class t extends x{constructor(){super(...arguments),_.set(this,void 0)}_parse(t){if(typeof t.data!=`string`){let n=this._getOrReturnCtx(t),r=this._def.values;return l(n,{expected:e.joinValues(r),received:n.parsedType,code:i.invalid_type}),d}if(h(this,_,`f`)||se(this,_,new Set(this._def.values),`f`),!h(this,_,`f`).has(t.data)){let e=this._getOrReturnCtx(t),n=this._def.values;return l(e,{received:e.data,code:i.invalid_enum_value,options:n}),d}return f(t.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(t=>!e.includes(t)),{...this._def,...n})}};_=new WeakMap,W.create=Re;var G=class extends x{constructor(){super(...arguments),v.set(this,void 0)}_parse(t){let r=e.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(t);if(a.parsedType!==n.string&&a.parsedType!==n.number){let t=e.objectValues(r);return l(a,{expected:e.joinValues(t),received:a.parsedType,code:i.invalid_type}),d}if(h(this,v,`f`)||se(this,v,new Set(e.getValidEnumValues(this._def.values)),`f`),!h(this,v,`f`).has(t.data)){let t=e.objectValues(r);return l(a,{received:a.data,code:i.invalid_enum_value,options:t}),d}return f(t.data)}get enum(){return this._def.values}};v=new WeakMap,G.create=(e,t)=>new G({values:e,typeName:$.ZodNativeEnum,...b(t)});var K=class extends x{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==n.promise&&t.common.async===!1?(l(t,{code:i.invalid_type,expected:n.promise,received:t.parsedType}),d):f((t.parsedType===n.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};K.create=(e,t)=>new K({type:e,typeName:$.ZodPromise,...b(t)});var q=class extends x{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===$.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:n,ctx:r}=this._processInputParams(t),i=this._def.effect||null,a={addIssue:e=>{l(r,e),e.fatal?n.abort():n.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),i.type===`preprocess`){let e=i.transform(r.data,a);if(r.common.async)return Promise.resolve(e).then(async e=>{if(n.value===`aborted`)return d;let t=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return t.status===`aborted`?d:t.status===`dirty`||n.value===`dirty`?ie(t.value):t});{if(n.value===`aborted`)return d;let t=this._def.schema._parseSync({data:e,path:r.path,parent:r});return t.status===`aborted`?d:t.status===`dirty`||n.value===`dirty`?ie(t.value):t}}if(i.type===`refinement`){let e=e=>{let t=i.refinement(e,a);if(r.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(r.common.async===!1){let t=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return t.status===`aborted`?d:(t.status===`dirty`&&n.dirty(),e(t.value),{status:n.value,value:t.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(t=>t.status===`aborted`?d:(t.status===`dirty`&&n.dirty(),e(t.value).then(()=>({status:n.value,value:t.value}))))}if(i.type===`transform`)if(r.common.async===!1){let e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!p(e))return e;let t=i.transform(e.value,a);if(t instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:n.value,value:t}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(e=>p(e)?Promise.resolve(i.transform(e.value,a)).then(e=>({status:n.value,value:e})):e);e.assertNever(i)}};q.create=(e,t,n)=>new q({schema:e,typeName:$.ZodEffects,effect:t,...b(n)}),q.createWithPreprocess=(e,t,n)=>new q({schema:t,effect:{type:`preprocess`,transform:e},typeName:$.ZodEffects,...b(n)});var J=class extends x{_parse(e){return this._getType(e)===n.undefined?f(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};J.create=(e,t)=>new J({innerType:e,typeName:$.ZodOptional,...b(t)});var Y=class extends x{_parse(e){return this._getType(e)===n.null?f(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Y.create=(e,t)=>new Y({innerType:e,typeName:$.ZodNullable,...b(t)});var X=class extends x{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return t.parsedType===n.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};X.create=(e,t)=>new X({innerType:e,typeName:$.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...b(t)});var Z=class extends x{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return m(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new o(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new o(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Z.create=(e,t)=>new Z({innerType:e,typeName:$.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...b(t)});var ze=class extends x{_parse(e){if(this._getType(e)!==n.nan){let t=this._getOrReturnCtx(e);return l(t,{code:i.invalid_type,expected:n.nan,received:t.parsedType}),d}return{status:`valid`,value:e.data}}};ze.create=e=>new ze({typeName:$.ZodNaN,...b(e)});const Be=Symbol(`zod_brand`);var Ve=class extends x{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},He=class e extends x{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?d:e.status===`dirty`?(t.dirty(),ie(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?d:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:$.ZodPipeline})}},Q=class extends x{_parse(e){let t=this._def.innerType._parse(e),n=e=>(p(e)&&(e.value=Object.freeze(e.value)),e);return m(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};Q.create=(e,t)=>new Q({innerType:e,typeName:$.ZodReadonly,...b(t)});function Ue(e,t){let n=typeof e==`function`?e(t):typeof e==`string`?{message:e}:e;return typeof n==`string`?{message:n}:n}function We(e,t={},n){return e?k.create().superRefine((r,i)=>{let a=e(r);if(a instanceof Promise)return a.then(e=>{if(!e){let e=Ue(t,r),a=e.fatal??n??!0;i.addIssue({code:`custom`,...e,fatal:a})}});if(!a){let e=Ue(t,r),a=e.fatal??n??!0;i.addIssue({code:`custom`,...e,fatal:a})}}):k.create()}const Ge={object:F.lazycreate};var $;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})($||={});const Ke=(e,t={message:`Input not instance of ${e.name}`})=>We(t=>t instanceof e,t),qe=S.create,Je=C.create,Ye=ze.create,Xe=w.create,Ze=T.create,Qe=E.create,$e=Ne.create,et=D.create,tt=O.create,nt=k.create,rt=A.create,it=j.create,at=M.create,ot=N.create,st=F.create,ct=F.strictCreate,lt=I.create,ut=Pe.create,dt=R.create,ft=z.create,pt=Ie.create,mt=B.create,ht=V.create,gt=Le.create,_t=H.create,vt=U.create,yt=W.create,bt=G.create,xt=K.create,St=q.create,Ct=J.create,wt=Y.create,Tt=q.createWithPreprocess,Et=He.create;var Dt=Object.freeze({__proto__:null,defaultErrorMap:s,setErrorMap:ee,getErrorMap:te,makeIssue:ne,EMPTY_PATH:re,addIssueToContext:l,ParseStatus:u,INVALID:d,DIRTY:ie,OK:f,isAborted:ae,isDirty:oe,isValid:p,isAsync:m,get util(){return e},get objectUtil(){return t},ZodParsedType:n,getParsedType:r,ZodType:x,datetimeRegex:Oe,ZodString:S,ZodNumber:C,ZodBigInt:w,ZodBoolean:T,ZodDate:E,ZodSymbol:Ne,ZodUndefined:D,ZodNull:O,ZodAny:k,ZodUnknown:A,ZodNever:j,ZodVoid:M,ZodArray:N,ZodObject:F,ZodUnion:I,ZodDiscriminatedUnion:Pe,ZodIntersection:R,ZodTuple:z,ZodRecord:Ie,ZodMap:B,ZodSet:V,ZodFunction:Le,ZodLazy:H,ZodLiteral:U,ZodEnum:W,ZodNativeEnum:G,ZodPromise:K,ZodEffects:q,ZodTransformer:q,ZodOptional:J,ZodNullable:Y,ZodDefault:X,ZodCatch:Z,ZodNaN:ze,BRAND:Be,ZodBranded:Ve,ZodPipeline:He,ZodReadonly:Q,custom:We,Schema:x,ZodSchema:x,late:Ge,get ZodFirstPartyTypeKind(){return $},coerce:{string:(e=>S.create({...e,coerce:!0})),number:(e=>C.create({...e,coerce:!0})),boolean:(e=>T.create({...e,coerce:!0})),bigint:(e=>w.create({...e,coerce:!0})),date:(e=>E.create({...e,coerce:!0}))},any:nt,array:ot,bigint:Xe,boolean:Ze,date:Qe,discriminatedUnion:ut,effect:St,enum:yt,function:gt,instanceof:Ke,intersection:dt,lazy:_t,literal:vt,map:mt,nan:Ye,nativeEnum:bt,never:it,null:tt,nullable:wt,number:Je,object:st,oboolean:()=>Ze().optional(),onumber:()=>Je().optional(),optional:Ct,ostring:()=>qe().optional(),pipeline:Et,preprocess:Tt,promise:xt,record:pt,set:ht,strictObject:ct,string:qe,symbol:$e,transformer:St,tuple:ft,undefined:et,union:lt,unknown:rt,void:at,NEVER:d,ZodIssueCode:i,quotelessJson:a,ZodError:o});const Ot=`2.0.1`;export{Dt as n,Ot as t};
@@ -6,7 +6,7 @@ type VercelSandboxModule = typeof VercelSandboxSdk;
6
6
  /**
7
7
  * User-controllable subset of `Sandbox.create` parameters.
8
8
  */
9
- export type VercelSandboxCreateOptions = Omit<NonNullable<Parameters<typeof SdkSandbox.create>[0]>, "name" | "persistent" | "signal">;
9
+ export type VercelSandboxCreateOptions = Omit<NonNullable<Parameters<typeof SdkSandbox.create>[0]>, "name" | "onResume" | "persistent" | "signal">;
10
10
  /**
11
11
  * Construction input for {@link createVercelSandboxBackend}. Internal —
12
12
  * the public surface is the `vercelBackend()` factory under
@@ -1,3 +1,3 @@
1
- import{bufferToStream,streamToBuffer}from"./stream-utils.js";function buildSandboxSession(n){let r={value:!1};async function run(e){let t=await n.spawn(e),[r,i,{exitCode:a}]=await Promise.all([collectStreamToString(t.stdout),collectStreamToString(t.stderr),t.wait()]);return{exitCode:a,stderr:i,stdout:r}}return{id:n.id,resolvePath(e){return n.resolvePath(e)},run,async spawn(e){return await n.spawn(e)},async runCommand(e){return r.value||(r.value=!0,console.warn(`[experimental-ash] SandboxSession.runCommand is deprecated and will be removed in a future release. Use SandboxSession.run instead.`)),await run(e)},async readFile(e){return await n.readFile({abortSignal:e.abortSignal,path:n.resolvePath(e.path)})},async readBinaryFile(e){let r=await n.readFile({abortSignal:e.abortSignal,path:n.resolvePath(e.path)});return r===null?null:await streamToBuffer(r)},async readTextFile(e){validateReadTextFileOptions(e);let r=await n.readFile({abortSignal:e.abortSignal,path:n.resolvePath(e.path)});return r===null?null:applyLineRange(decodeBytes(await streamToBuffer(r),e.encoding??`utf-8`),e)},async writeFile(e){await n.writeFile({abortSignal:e.abortSignal,content:e.content,path:n.resolvePath(e.path)})},async writeBinaryFile(t){await n.writeFile({abortSignal:t.abortSignal,content:bufferToStream(t.content),path:n.resolvePath(t.path)})},async writeTextFile(t){let r=encodeString(t.content,t.encoding??`utf-8`);await n.writeFile({abortSignal:t.abortSignal,content:bufferToStream(r),path:n.resolvePath(t.path)})}}}async function collectStreamToString(e){let n=await streamToBuffer(e);return new TextDecoder().decode(n)}function validateReadTextFileOptions(e){let{startLine:t,endLine:n}=e;if(t!==void 0&&(!Number.isInteger(t)||t<1))throw Error(`startLine must be a positive integer (1-based).`);if(n!==void 0&&(!Number.isInteger(n)||n<1))throw Error(`endLine must be a positive integer (1-based).`);if(t!==void 0&&n!==void 0&&t>n)throw Error(`startLine must not be greater than endLine.`)}function splitLinesPreservingEndings(e){let t=[],n=0;for(let r=0;r<e.length;r++)e[r]===`\r`?r+1<e.length&&e[r+1]===`
1
+ import{bufferToStream,streamToBuffer}from"./stream-utils.js";function buildSandboxSession(n){async function run(e){let t=await n.spawn(e),[r,i,{exitCode:a}]=await Promise.all([collectStreamToString(t.stdout),collectStreamToString(t.stderr),t.wait()]);return{exitCode:a,stderr:i,stdout:r}}return{id:n.id,resolvePath(e){return n.resolvePath(e)},run,async spawn(e){return await n.spawn(e)},async readFile(e){return await n.readFile({abortSignal:e.abortSignal,path:n.resolvePath(e.path)})},async readBinaryFile(e){let r=await n.readFile({abortSignal:e.abortSignal,path:n.resolvePath(e.path)});return r===null?null:await streamToBuffer(r)},async readTextFile(e){validateReadTextFileOptions(e);let r=await n.readFile({abortSignal:e.abortSignal,path:n.resolvePath(e.path)});return r===null?null:applyLineRange(decodeBytes(await streamToBuffer(r),e.encoding??`utf-8`),e)},async writeFile(e){await n.writeFile({abortSignal:e.abortSignal,content:e.content,path:n.resolvePath(e.path)})},async writeBinaryFile(t){await n.writeFile({abortSignal:t.abortSignal,content:bufferToStream(t.content),path:n.resolvePath(t.path)})},async writeTextFile(t){let r=encodeString(t.content,t.encoding??`utf-8`);await n.writeFile({abortSignal:t.abortSignal,content:bufferToStream(r),path:n.resolvePath(t.path)})}}}async function collectStreamToString(e){let n=await streamToBuffer(e);return new TextDecoder().decode(n)}function validateReadTextFileOptions(e){let{startLine:t,endLine:n}=e;if(t!==void 0&&(!Number.isInteger(t)||t<1))throw Error(`startLine must be a positive integer (1-based).`);if(n!==void 0&&(!Number.isInteger(n)||n<1))throw Error(`endLine must be a positive integer (1-based).`);if(t!==void 0&&n!==void 0&&t>n)throw Error(`startLine must not be greater than endLine.`)}function splitLinesPreservingEndings(e){let t=[],n=0;for(let r=0;r<e.length;r++)e[r]===`\r`?r+1<e.length&&e[r+1]===`
2
2
  `?(t.push(e.slice(n,r+2)),n=r+2,r++):(t.push(e.slice(n,r+1)),n=r+1):e[r]===`
3
3
  `&&(t.push(e.slice(n,r+1)),n=r+1);return n<e.length&&t.push(e.slice(n)),t}function applyLineRange(e,t){if(t.startLine===void 0&&t.endLine===void 0)return e;let n=splitLinesPreservingEndings(e),r=n.length,i=t.startLine??1,a=Math.min(t.endLine??r,r);return i>r?``:n.slice(i-1,a).join(``)}function decodeBytes(e,t){return t===`utf-8`||t===`utf8`?new TextDecoder(`utf-8`,{fatal:!0}).decode(e):Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(t)}function encodeString(e,t){return t===`utf-8`||t===`utf8`?new TextEncoder().encode(e):Buffer.from(e,t)}export{buildSandboxSession};
@@ -1 +1 @@
1
- import{createRequire}from"node:module";import{basename,dirname,join}from"node:path";import{existsSync,readFileSync,realpathSync}from"node:fs";import{ASH_PACKAGE_NAME}from"#internal/package-name.js";import{fileURLToPath}from"node:url";let cachedPackageInfo;const WORKFLOW_MODULE_ALIASES={"workflow/api":`src/compiled/@workflow/core/runtime.js`,"workflow/errors":`src/compiled/@workflow/errors/index.js`,"workflow/internal/private":`src/compiled/@workflow/core/private.js`,"workflow/runtime":`src/compiled/@workflow/core/runtime.js`};function resolveFallbackPackageVersion(){return`0.34.0`}const FALLBACK_PACKAGE_INFO={name:ASH_PACKAGE_NAME,version:resolveFallbackPackageVersion()};function resolveCurrentModulePath(){return typeof __filename==`string`?__filename:resolveCurrentModulePathFromStack()}function resolveCurrentModulePathFromStack(){let e=Error.prepareStackTrace;try{Error.prepareStackTrace=(e,t)=>t;let e=Error().stack?.[0]?.getFileName();if(typeof e!=`string`||e.length===0)throw Error(`Failed to resolve the current module path from the stack trace.`);return e.startsWith(`file:`)?fileURLToPath(e):e}finally{Error.prepareStackTrace=e}}const require=createRequire(resolveCurrentModulePath());function isBuildOutputPackageRoot(e){return basename(e)===`dist`&&existsSync(join(dirname(e),`package.json`))}function resolvePackageBuildRoot(){let e=dirname(realpathSync(resolveCurrentModulePath()));for(;;){if(isBuildOutputPackageRoot(e))return e;let t=dirname(e);if(t===e)return null;e=t}}function findNearestPackageRoot(e){let t=e;for(;;){if(existsSync(join(t,`package.json`))&&!isBuildOutputPackageRoot(t))return t;let r=dirname(t);if(r===t)throw Error(`Failed to resolve package root from "${e}".`);t=r}}function resolvePackageRoot(){return findNearestPackageRoot(dirname(realpathSync(resolveCurrentModulePath())))}function tryResolvePackageRoot(){try{return resolvePackageRoot()}catch{return}}function rewriteSourceFilePathForBuild(e){return e.replace(/\.[cm]?tsx?$/,`.js`)}function resolvePackageSourceFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),e):join(t,rewriteSourceFilePathForBuild(e))}function resolvePackageSourceDirectoryPath(e){let t=resolvePackageBuildRoot();return join(t===null?resolvePackageRoot():t,e)}function resolvePackageCompiledFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),`.generated`,`compiled`,e.replace(/^src\/compiled\//,``)):join(t,e)}function normalizeInstalledPackageInfo(e){let t=e;if(!(typeof t.name!=`string`||typeof t.version!=`string`))return{name:t.name,version:t.version}}function tryReadInstalledPackageInfo(e,t){let n=normalizeInstalledPackageInfo(JSON.parse(readFileSync(e,`utf8`)));if(n?.name===t)return n}function resolveInstalledPackageInfo(){if(cachedPackageInfo)return cachedPackageInfo;let e=tryResolvePackageRoot(),t=e===void 0?void 0:tryReadInstalledPackageInfo(join(e,`package.json`),ASH_PACKAGE_NAME);if(t)return cachedPackageInfo=t,cachedPackageInfo;try{let e=tryReadInstalledPackageInfo(require.resolve(`${ASH_PACKAGE_NAME}/package.json`),ASH_PACKAGE_NAME);if(e)return cachedPackageInfo=e,cachedPackageInfo}catch{}return cachedPackageInfo={...FALLBACK_PACKAGE_INFO},cachedPackageInfo}function resolveWorkflowModulePath(e){if(e===`workflow`)return resolvePackageSourceFilePath(`src/internal/workflow/index.ts`);if(e===`workflow/internal/builtins`)return resolvePackageSourceFilePath(`src/internal/workflow/builtins.ts`);let t=WORKFLOW_MODULE_ALIASES[e];return t===void 0?require.resolve(e):resolvePackageCompiledFilePath(t)}export{resolveInstalledPackageInfo,resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath};
1
+ import{createRequire}from"node:module";import{basename,dirname,join}from"node:path";import{existsSync,readFileSync,realpathSync}from"node:fs";import{ASH_PACKAGE_NAME}from"#internal/package-name.js";import{fileURLToPath}from"node:url";let cachedPackageInfo;const WORKFLOW_MODULE_ALIASES={"workflow/api":`src/compiled/@workflow/core/runtime.js`,"workflow/errors":`src/compiled/@workflow/errors/index.js`,"workflow/internal/private":`src/compiled/@workflow/core/private.js`,"workflow/runtime":`src/compiled/@workflow/core/runtime.js`};function resolveFallbackPackageVersion(){return`0.35.0`}const FALLBACK_PACKAGE_INFO={name:ASH_PACKAGE_NAME,version:resolveFallbackPackageVersion()};function resolveCurrentModulePath(){return typeof __filename==`string`?__filename:resolveCurrentModulePathFromStack()}function resolveCurrentModulePathFromStack(){let e=Error.prepareStackTrace;try{Error.prepareStackTrace=(e,t)=>t;let e=Error().stack?.[0]?.getFileName();if(typeof e!=`string`||e.length===0)throw Error(`Failed to resolve the current module path from the stack trace.`);return e.startsWith(`file:`)?fileURLToPath(e):e}finally{Error.prepareStackTrace=e}}const require=createRequire(resolveCurrentModulePath());function isBuildOutputPackageRoot(e){return basename(e)===`dist`&&existsSync(join(dirname(e),`package.json`))}function resolvePackageBuildRoot(){let e=dirname(realpathSync(resolveCurrentModulePath()));for(;;){if(isBuildOutputPackageRoot(e))return e;let t=dirname(e);if(t===e)return null;e=t}}function findNearestPackageRoot(e){let t=e;for(;;){if(existsSync(join(t,`package.json`))&&!isBuildOutputPackageRoot(t))return t;let r=dirname(t);if(r===t)throw Error(`Failed to resolve package root from "${e}".`);t=r}}function resolvePackageRoot(){return findNearestPackageRoot(dirname(realpathSync(resolveCurrentModulePath())))}function tryResolvePackageRoot(){try{return resolvePackageRoot()}catch{return}}function rewriteSourceFilePathForBuild(e){return e.replace(/\.[cm]?tsx?$/,`.js`)}function resolvePackageSourceFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),e):join(t,rewriteSourceFilePathForBuild(e))}function resolvePackageSourceDirectoryPath(e){let t=resolvePackageBuildRoot();return join(t===null?resolvePackageRoot():t,e)}function resolvePackageCompiledFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),`.generated`,`compiled`,e.replace(/^src\/compiled\//,``)):join(t,e)}function normalizeInstalledPackageInfo(e){let t=e;if(!(typeof t.name!=`string`||typeof t.version!=`string`))return{name:t.name,version:t.version}}function tryReadInstalledPackageInfo(e,t){let n=normalizeInstalledPackageInfo(JSON.parse(readFileSync(e,`utf8`)));if(n?.name===t)return n}function resolveInstalledPackageInfo(){if(cachedPackageInfo)return cachedPackageInfo;let e=tryResolvePackageRoot(),t=e===void 0?void 0:tryReadInstalledPackageInfo(join(e,`package.json`),ASH_PACKAGE_NAME);if(t)return cachedPackageInfo=t,cachedPackageInfo;try{let e=tryReadInstalledPackageInfo(require.resolve(`${ASH_PACKAGE_NAME}/package.json`),ASH_PACKAGE_NAME);if(e)return cachedPackageInfo=e,cachedPackageInfo}catch{}return cachedPackageInfo={...FALLBACK_PACKAGE_INFO},cachedPackageInfo}function resolveWorkflowModulePath(e){if(e===`workflow`)return resolvePackageSourceFilePath(`src/internal/workflow/index.ts`);if(e===`workflow/internal/builtins`)return resolvePackageSourceFilePath(`src/internal/workflow/builtins.ts`);let t=WORKFLOW_MODULE_ALIASES[e];return t===void 0?require.resolve(e):resolvePackageCompiledFilePath(t)}export{resolveInstalledPackageInfo,resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath};
@@ -1 +1 @@
1
- import{inspect}from"node:util";import{isNonEmptyString,isObject}from"#shared/guards.js";import{SpanStatusCode,trace}from"#compiled/@opentelemetry/api/index.js";import{getErrorMessage}from"#compiled/@ai-sdk/provider/index.js";const LEVEL_SEVERITY={debug:10,info:20,warn:30,error:40};function createLogger(e){return{debug(t,n){write(`debug`,e,t,n)},info(t,n){write(`info`,e,t,n)},warn(t,n){write(`warn`,e,t,n)},error(t,n){write(`error`,e,t,n),recordOnActiveSpan(t,n)}}}function logError(e,t,n,r){let i=formatError(n);return e.error(t,{...r,error:i}),typeof i.errorId==`string`?i.errorId:createErrorId()}function createErrorId(){return crypto.randomUUID()}function formatError(e,t){let n={errorId:t??createErrorId(),message:extractErrorMessage(e)},r=extractErrorName(e);return r!==void 0&&(n.name=r),n.detail=inspectError(e),n}function extractErrorName(e){if(e instanceof Error)return e.name===`Error`?void 0:e.name;if(isObject(e)&&isNonEmptyString(e.name)&&e.name!==`Error`)return e.name}function extractErrorMessage(e){return isObject(e)&&!(e instanceof Error)&&typeof e.message==`string`?e.message:getErrorMessage(e)}function extractErrorId(e){if(isObject(e))return isNonEmptyString(e.errorId)?e.errorId:void 0}function formatErrorHint(e){let r=isObject(e.details)?e.details.name:void 0,i=isNonEmptyString(r)?r:void 0,a=typeof e.message==`string`?e.message.trim():``;return i&&a.length>0?` (${i}: ${truncateForDisplay(a)})`:i?` (${i})`:a.length>0?` (${truncateForDisplay(a)})`:``}function truncateForDisplay(e,t=160){return e.length<=t?e:`${e.slice(0,t-1).trimEnd()}…`}function recordErrorOnSpan(e,t){let n=t instanceof Error?t.message:getErrorMessage(t),i=t instanceof Error?t.name:`Error`;e.setStatus({code:SpanStatusCode.ERROR,message:n}),e.recordException({message:n,name:i,stack:inspectError(t)})}function resolveThreshold(){let e=process.env.ASH_LOG_LEVEL?.toLowerCase();return e===`debug`||e===`info`||e===`warn`||e===`error`?LEVEL_SEVERITY[e]:process.env.NODE_ENV===`production`?LEVEL_SEVERITY.info:LEVEL_SEVERITY.debug}function write(e,t,n,r){if(LEVEL_SEVERITY[e]<resolveThreshold())return;let i=e===`error`?console.error:e===`warn`?console.warn:console.log,a=`[ash:${t}] ${n}`;if(r===void 0){i(a);return}i(a,renderFields(r))}function renderFields(e){let t={};for(let[n,r]of Object.entries(e))if(r!==void 0){if(r instanceof Error){t[n]=formatError(r);continue}t[n]=r}return t}function recordOnActiveSpan(e,t){let n=trace.getActiveSpan();if(n===void 0)return;let a=t?.error;if(a instanceof Error){recordErrorOnSpan(n,a);return}if(isFormattedError(a)){n.setStatus({code:SpanStatusCode.ERROR,message:a.message}),n.recordException({message:a.message,name:typeof a.name==`string`?a.name:`Error`,stack:typeof a.detail==`string`?a.detail:void 0});return}n.addEvent(e,t?renderFields(t):void 0)}function isFormattedError(e){return isObject(e)&&typeof e.errorId==`string`&&typeof e.message==`string`}function inspectError(t){return truncate(inspect(t,{breakLength:1/0,compact:!1,depth:10,maxStringLength:8192}),16384)}function truncate(e,t){if(Buffer.byteLength(e,`utf8`)<=t)return e;let n=e.slice(0,t);for(;Buffer.byteLength(n,`utf8`)>t&&n.length>0;)n=n.slice(0,-1);return`${n}<…truncated>`}export{createErrorId,createLogger,extractErrorId,formatError,formatErrorHint,logError,recordErrorOnSpan};
1
+ import{inspect}from"node:util";import{isNonEmptyString,isObject}from"#shared/guards.js";import{SpanStatusCode,trace}from"#compiled/@opentelemetry/api/index.js";import{getErrorMessage}from"#compiled/@ai-sdk/provider/index.js";const LEVEL_SEVERITY={debug:10,info:20,warn:30,error:40};function createLogger(e){return{debug(t,n){write(`debug`,e,t,n)},info(t,n){write(`info`,e,t,n)},warn(t,n){write(`warn`,e,t,n)},error(t,n){write(`error`,e,t,n),recordOnActiveSpan(t,n)}}}function logError(e,t,n,r){let i=formatError(n);return e.error(t,{...r,error:i}),typeof i.errorId==`string`?i.errorId:createErrorId()}function createErrorId(){return crypto.randomUUID()}function formatError(e,t){let n={errorId:t??createErrorId(),message:extractErrorMessage(e)},r=extractErrorName(e);return r!==void 0&&(n.name=r),n.detail=inspectError(e),n}function extractErrorName(e){if(e instanceof Error)return e.name===`Error`?void 0:e.name;if(isObject(e)&&isNonEmptyString(e.name)&&e.name!==`Error`)return e.name}function extractErrorMessage(e){return isObject(e)&&!(e instanceof Error)&&typeof e.message==`string`?e.message:getErrorMessage(e)}function extractErrorId(e){if(isObject(e))return isNonEmptyString(e.errorId)?e.errorId:void 0}function formatErrorHint(e){let r=isObject(e.details)?e.details.name:void 0,i=isNonEmptyString(r)?r:void 0,a=typeof e.message==`string`?e.message.trim():``;return i&&a.length>0?` (${i}: ${truncateForDisplay(a)})`:i?` (${i})`:a.length>0?` (${truncateForDisplay(a)})`:``}function truncateForDisplay(e,t=160){return e.length<=t?e:`${e.slice(0,t-1).trimEnd()}…`}function recordErrorOnSpan(e,t){let n=t instanceof Error?t.message:getErrorMessage(t),i=t instanceof Error?t.name:`Error`;e.setStatus({code:SpanStatusCode.ERROR,message:n}),e.recordException({message:n,name:i,stack:inspectError(t)})}function resolveThreshold(){let e=process.env.ASH_LOG_LEVEL?.toLowerCase();return e===`debug`||e===`info`||e===`warn`||e===`error`?LEVEL_SEVERITY[e]:LEVEL_SEVERITY.info}function write(e,t,n,r){if(LEVEL_SEVERITY[e]<resolveThreshold())return;let i=e===`error`?console.error:e===`warn`?console.warn:console.log,a=`[ash:${t}] ${n}`;if(r===void 0){i(a);return}i(a,renderFields(r))}function renderFields(e){let t={};for(let[n,r]of Object.entries(e))if(r!==void 0){if(r instanceof Error){t[n]=formatError(r);continue}t[n]=r}return t}function recordOnActiveSpan(e,t){let n=trace.getActiveSpan();if(n===void 0)return;let a=t?.error;if(a instanceof Error){recordErrorOnSpan(n,a);return}if(isFormattedError(a)){n.setStatus({code:SpanStatusCode.ERROR,message:a.message}),n.recordException({message:a.message,name:typeof a.name==`string`?a.name:`Error`,stack:typeof a.detail==`string`?a.detail:void 0});return}n.addEvent(e,t?renderFields(t):void 0)}function isFormattedError(e){return isObject(e)&&typeof e.errorId==`string`&&typeof e.message==`string`}function inspectError(t){return truncate(inspect(t,{breakLength:1/0,compact:!1,depth:10,maxStringLength:8192}),16384)}function truncate(e,t){if(Buffer.byteLength(e,`utf8`)<=t)return e;let n=e.slice(0,t);for(;Buffer.byteLength(n,`utf8`)>t&&n.length>0;)n=n.slice(0,-1);return`${n}<…truncated>`}export{createErrorId,createLogger,extractErrorId,formatError,formatErrorHint,logError,recordErrorOnSpan};
@@ -1,4 +1,4 @@
1
- import{getSupportedModuleBaseName,matchesSupportedModuleBaseName}from"./module-files.js";import{pathExists,writeTextFile}from"./files.js";import{WEB_APP_TEMPLATE_FILES,WEB_APP_TEMPLATE_PACKAGE_JSON}from"./web-template.js";import"./project.js";import{patchPackageJson}from"./package-json.js";import{basename,join,resolve}from"node:path";import{readFile,readdir,writeFile}from"node:fs/promises";const SLACK_CHANNEL_DEFAULT_ROUTE=`/ash/v1/slack`,DEFAULT_SLACK_CONNECTOR_SLUG=`my-agent`,PACKAGE_DEPENDENCY_FIELDS=[`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`],WEB_ASH_RELEASE_AGE_EXCLUSION=` - experimental-ash`,WEB_SHARP_BUILD_POLICY=` sharp: false`,WEB_VERCEL_JSON_PATH=`vercel.json`,WEB_VERCEL_JSON_SCHEMA=`https://openapi.vercel.sh/vercel.json`,WEB_DEFAULT_VERCEL_SERVICES={web:{entrypoint:`.`,framework:`nextjs`,routePrefix:`/`},ash:{buildCommand:`ash build`,entrypoint:`.`,framework:`ash`,routePrefix:`/_ash_internal/ash`}};function toSlackConnectorSlug(e){return e}function isJsonObject(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function readDependencyVersion(e,t){let n=JSON.parse(await readFile(e,`utf8`));if(!isJsonObject(n)||!isJsonObject(n.dependencies))return;let r=n.dependencies[t];return typeof r==`string`?r:void 0}function packageJsonHasDependency(e,t){for(let n of PACKAGE_DEPENDENCY_FIELDS){let r=e[n];if(isJsonObject(r)&&typeof r[t]==`string`)return!0}return!1}async function hasPackageDependency(e,t){if(!await pathExists(e))return!1;let r=JSON.parse(await readFile(e,`utf8`));return isJsonObject(r)&&packageJsonHasDependency(r,t)}async function ensurePackageDependency(e,t,r){return!await pathExists(e)||await readDependencyVersion(e,t)===r?[]:(await patchPackageJson(e,{dependencies:{[t]:r}}),[{path:e,dependencies:[t],devDependencies:[],scripts:[]}])}function resolveWebPackageVersions(e){return{ashPackageVersion:e?.ashPackageVersion??`0.34.0`,aiPackageVersion:e?.aiPackageVersion??`7.0.0-canary.154`,nextPackageVersion:e?.nextPackageVersion??`16.2.6`,reactPackageVersion:e?.reactPackageVersion??`19.2.6`,reactDomPackageVersion:e?.reactDomPackageVersion??`19.2.6`,streamdownPackageVersion:e?.streamdownPackageVersion??`2.5.0`,zodPackageVersion:e?.zodPackageVersion??`4.4.3`,tsgoPackageVersion:e?.tsgoPackageVersion??`7.0.0-dev.20260523.1`,typesNodePackageVersion:e?.typesNodePackageVersion??`25.9.1`,typesReactPackageVersion:e?.typesReactPackageVersion??`19.2.15`,typesReactDomPackageVersion:e?.typesReactDomPackageVersion??`19.2.3`}}function formatAshDependencySpecifier(e){return/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z-.]+)?$/.test(e)?`^${e}`:e}async function patchWebPackageJson(e,t){if(!await pathExists(e))return[];assertStampedVersion(`ashPackageVersion`,t.ashPackageVersion),assertStampedVersion(`aiPackageVersion`,t.aiPackageVersion),assertStampedVersion(`nextPackageVersion`,t.nextPackageVersion),assertStampedVersion(`reactPackageVersion`,t.reactPackageVersion),assertStampedVersion(`reactDomPackageVersion`,t.reactDomPackageVersion),assertStampedVersion(`streamdownPackageVersion`,t.streamdownPackageVersion),assertStampedVersion(`zodPackageVersion`,t.zodPackageVersion),assertStampedVersion(`tsgoPackageVersion`,t.tsgoPackageVersion),assertStampedVersion(`typesNodePackageVersion`,t.typesNodePackageVersion),assertStampedVersion(`typesReactPackageVersion`,t.typesReactPackageVersion),assertStampedVersion(`typesReactDomPackageVersion`,t.typesReactDomPackageVersion);let r={...WEB_APP_TEMPLATE_PACKAGE_JSON.dependencies,ai:t.aiPackageVersion,"experimental-ash":formatAshDependencySpecifier(t.ashPackageVersion),next:t.nextPackageVersion,react:t.reactPackageVersion,"react-dom":t.reactDomPackageVersion,streamdown:t.streamdownPackageVersion,zod:t.zodPackageVersion},i={...WEB_APP_TEMPLATE_PACKAGE_JSON.devDependencies,"@types/node":t.typesNodePackageVersion,"@types/react":t.typesReactPackageVersion,"@types/react-dom":t.typesReactDomPackageVersion,"@typescript/native-preview":t.tsgoPackageVersion},s=WEB_APP_TEMPLATE_PACKAGE_JSON.scripts;return await patchPackageJson(e,{dependencies:r,devDependencies:i,scripts:s}),[{path:e,dependencies:Object.keys(r),devDependencies:Object.keys(i),scripts:Object.keys(s)}]}function normalizeSlackConnectorSlug(e){return toSlackConnectorSlug((e.trim().replace(/^@/,``).split(`/`).at(-1)??``).toLowerCase().replace(/[^a-z0-9_-]+/g,`-`).replace(/^[^a-z0-9]+/,``).replace(/[^a-z0-9]+$/,``).slice(0,100).replace(/[^a-z0-9]+$/,``)||`my-agent`)}async function deriveSlackConnectorSlug(e,t){if(t!==void 0&&t.length>0&&t!==`.`)return normalizeSlackConnectorSlug(t);try{let t=await readFile(join(e,`package.json`),`utf8`),n=JSON.parse(t);if(typeof n.name==`string`&&n.name.length>0)return normalizeSlackConnectorSlug(n.name)}catch{}return normalizeSlackConnectorSlug(basename(resolve(e))||`my-agent`)}function buildSlackTemplate(e){return`import { connectSlackCredentials } from "@vercel/connect/ash";
1
+ import{getSupportedModuleBaseName,matchesSupportedModuleBaseName}from"./module-files.js";import{pathExists,writeTextFile}from"./files.js";import{WEB_APP_TEMPLATE_FILES,WEB_APP_TEMPLATE_PACKAGE_JSON}from"./web-template.js";import"./project.js";import{patchPackageJson}from"./package-json.js";import{basename,join,resolve}from"node:path";import{readFile,readdir,writeFile}from"node:fs/promises";const SLACK_CHANNEL_DEFAULT_ROUTE=`/ash/v1/slack`,DEFAULT_SLACK_CONNECTOR_SLUG=`my-agent`,PACKAGE_DEPENDENCY_FIELDS=[`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`],WEB_ASH_RELEASE_AGE_EXCLUSION=` - experimental-ash`,WEB_SHARP_BUILD_POLICY=` sharp: false`,WEB_VERCEL_JSON_PATH=`vercel.json`,WEB_VERCEL_JSON_SCHEMA=`https://openapi.vercel.sh/vercel.json`,WEB_DEFAULT_VERCEL_SERVICES={web:{entrypoint:`.`,framework:`nextjs`,routePrefix:`/`},ash:{buildCommand:`ash build`,entrypoint:`.`,framework:`ash`,routePrefix:`/_ash_internal/ash`}};function toSlackConnectorSlug(e){return e}function isJsonObject(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function readDependencyVersion(e,t){let n=JSON.parse(await readFile(e,`utf8`));if(!isJsonObject(n)||!isJsonObject(n.dependencies))return;let r=n.dependencies[t];return typeof r==`string`?r:void 0}function packageJsonHasDependency(e,t){for(let n of PACKAGE_DEPENDENCY_FIELDS){let r=e[n];if(isJsonObject(r)&&typeof r[t]==`string`)return!0}return!1}async function hasPackageDependency(e,t){if(!await pathExists(e))return!1;let r=JSON.parse(await readFile(e,`utf8`));return isJsonObject(r)&&packageJsonHasDependency(r,t)}async function ensurePackageDependency(e,t,r){return!await pathExists(e)||await readDependencyVersion(e,t)===r?[]:(await patchPackageJson(e,{dependencies:{[t]:r}}),[{path:e,dependencies:[t],devDependencies:[],scripts:[]}])}function resolveWebPackageVersions(e){return{ashPackageVersion:e?.ashPackageVersion??`0.35.0`,aiPackageVersion:e?.aiPackageVersion??`7.0.0-canary.154`,nextPackageVersion:e?.nextPackageVersion??`16.2.6`,reactPackageVersion:e?.reactPackageVersion??`19.2.6`,reactDomPackageVersion:e?.reactDomPackageVersion??`19.2.6`,streamdownPackageVersion:e?.streamdownPackageVersion??`2.5.0`,zodPackageVersion:e?.zodPackageVersion??`4.4.3`,tsgoPackageVersion:e?.tsgoPackageVersion??`7.0.0-dev.20260523.1`,typesNodePackageVersion:e?.typesNodePackageVersion??`25.9.1`,typesReactPackageVersion:e?.typesReactPackageVersion??`19.2.15`,typesReactDomPackageVersion:e?.typesReactDomPackageVersion??`19.2.3`}}function formatAshDependencySpecifier(e){return/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z-.]+)?$/.test(e)?`^${e}`:e}async function patchWebPackageJson(e,t){if(!await pathExists(e))return[];assertStampedVersion(`ashPackageVersion`,t.ashPackageVersion),assertStampedVersion(`aiPackageVersion`,t.aiPackageVersion),assertStampedVersion(`nextPackageVersion`,t.nextPackageVersion),assertStampedVersion(`reactPackageVersion`,t.reactPackageVersion),assertStampedVersion(`reactDomPackageVersion`,t.reactDomPackageVersion),assertStampedVersion(`streamdownPackageVersion`,t.streamdownPackageVersion),assertStampedVersion(`zodPackageVersion`,t.zodPackageVersion),assertStampedVersion(`tsgoPackageVersion`,t.tsgoPackageVersion),assertStampedVersion(`typesNodePackageVersion`,t.typesNodePackageVersion),assertStampedVersion(`typesReactPackageVersion`,t.typesReactPackageVersion),assertStampedVersion(`typesReactDomPackageVersion`,t.typesReactDomPackageVersion);let r={...WEB_APP_TEMPLATE_PACKAGE_JSON.dependencies,ai:t.aiPackageVersion,"experimental-ash":formatAshDependencySpecifier(t.ashPackageVersion),next:t.nextPackageVersion,react:t.reactPackageVersion,"react-dom":t.reactDomPackageVersion,streamdown:t.streamdownPackageVersion,zod:t.zodPackageVersion},i={...WEB_APP_TEMPLATE_PACKAGE_JSON.devDependencies,"@types/node":t.typesNodePackageVersion,"@types/react":t.typesReactPackageVersion,"@types/react-dom":t.typesReactDomPackageVersion,"@typescript/native-preview":t.tsgoPackageVersion},s=WEB_APP_TEMPLATE_PACKAGE_JSON.scripts;return await patchPackageJson(e,{dependencies:r,devDependencies:i,scripts:s}),[{path:e,dependencies:Object.keys(r),devDependencies:Object.keys(i),scripts:Object.keys(s)}]}function normalizeSlackConnectorSlug(e){return toSlackConnectorSlug((e.trim().replace(/^@/,``).split(`/`).at(-1)??``).toLowerCase().replace(/[^a-z0-9_-]+/g,`-`).replace(/^[^a-z0-9]+/,``).replace(/[^a-z0-9]+$/,``).slice(0,100).replace(/[^a-z0-9]+$/,``)||`my-agent`)}async function deriveSlackConnectorSlug(e,t){if(t!==void 0&&t.length>0&&t!==`.`)return normalizeSlackConnectorSlug(t);try{let t=await readFile(join(e,`package.json`),`utf8`),n=JSON.parse(t);if(typeof n.name==`string`&&n.name.length>0)return normalizeSlackConnectorSlug(n.name)}catch{}return normalizeSlackConnectorSlug(basename(resolve(e))||`my-agent`)}function buildSlackTemplate(e){return`import { connectSlackCredentials } from "@vercel/connect/ash";
2
2
  import { slackChannel } from "experimental-ash/channels/slack";
3
3
 
4
4
  export default slackChannel({
@@ -16,10 +16,10 @@ function exampleProductionAuth(): AuthFn<Request> {
16
16
 
17
17
  export default ashChannel({
18
18
  auth: [
19
- // Lets the Ash TUI and your Vercel deployments reach the deployed agent.
20
- vercelOidc(),
21
19
  // Open on localhost for \`ash dev\` and the REPL; ignored in production.
22
20
  localDev(),
21
+ // Lets the Ash TUI and your Vercel deployments reach the deployed agent.
22
+ vercelOidc(),
23
23
  // Your end-user auth — replace the placeholder above.
24
24
  exampleProductionAuth(),
25
25
  ],
@@ -198,11 +198,12 @@ export declare function routeAuth(request: Request, auth: AuthFn<Request> | read
198
198
  */
199
199
  export declare function none<TEvent = unknown>(): AuthFn<TEvent>;
200
200
  /**
201
- * Returns an {@link AuthFn} that authenticates requests **only when the
202
- * inbound request was addressed to a loopback hostname**.
201
+ * Returns an {@link AuthFn} that authenticates requests during local
202
+ * development — either when the inbound request was addressed to a
203
+ * loopback hostname, or when the process is running under `vercel dev`.
203
204
  *
204
- * The check is on the request URL's hostname, not the host process. A
205
- * hostname is treated as loopback when it is one of:
205
+ * The primary check is on the request URL's hostname, not the host
206
+ * process. A hostname is treated as loopback when it is one of:
206
207
  *
207
208
  * - `localhost` or any `*.localhost` subdomain (per RFC 6761, browsers
208
209
  * and DNS resolvers route the whole `.localhost` TLD to loopback);
@@ -216,13 +217,16 @@ export declare function none<TEvent = unknown>(): AuthFn<TEvent>;
216
217
  * `[localDev(), vercelOidc()]` the canonical "open on localhost,
217
218
  * Vercel OIDC in prod" pattern.
218
219
  *
219
- * This is intentionally based on the request's destination hostname
220
- * rather than `process.env.VERCEL`. Sniffing the host process is
221
- * unsafe: a deployment outside Vercel (Fly, Railway, raw container,
222
- * etc.) would leave `VERCEL` unset and accept every request from the
223
- * public internet. Inspecting the request hostname is correct across
224
- * `ash dev`, `vercel dev`, smoke tests, Vitest workers, and any
225
- * deployment targetVercel or otherwise.
220
+ * The hostname check is intentionally not based on bare
221
+ * `process.env.VERCEL`: sniffing only that flag is unsafe because a
222
+ * deployment outside Vercel (Fly, Railway, raw container, etc.) leaves
223
+ * `VERCEL` unset and would accept every request from the public
224
+ * internet. The one process-level exception is `vercel dev`, detected
225
+ * by `VERCEL=1` **and** `VERCEL_ENV=development` together. That pair is
226
+ * only ever set by the local `vercel dev` server preview and
227
+ * production deployments report `VERCEL_ENV=preview`/`production` — so
228
+ * it opens the local dev server (which may serve over a non-loopback
229
+ * host) without ever opening a real deployment.
226
230
  *
227
231
  * Caveat: this helper assumes a sane edge in front of public origins.
228
232
  * If you publish an origin that trusts an attacker-controlled `Host`
@@ -256,6 +260,13 @@ export interface VerifyVercelOidcOptions {
256
260
  * accepted regardless of `subjects`. This guarantees the deployment's
257
261
  * own runtime callers (subagent, internal fetches, etc.) authenticate
258
262
  * without authors having to enumerate them.
263
+ * - Vercel OIDC tokens with an `external_sub` claim authenticate as
264
+ * `principalType: "user"` when they match the current
265
+ * `VERCEL_PROJECT_ID` (if set) and current `VERCEL_TARGET_ENV` /
266
+ * `VERCEL_ENV` (if set). Their `external_sub` becomes the Ash subject,
267
+ * `external_iss` or `connector_id` becomes the Ash issuer when present,
268
+ * and string-valued OIDC profile claims such as `name`, `picture`, and
269
+ * `email` are exposed as auth attributes.
259
270
  * - Tokens from other Vercel projects are accepted **only** when their
260
271
  * `sub` matches one of the supplied {@link VerifyVercelOidcOptions.subjects}
261
272
  * patterns.
@@ -1 +1 @@
1
- import{createLogger}from"#internal/logging.js";import{decodeJwt}from"#compiled/jose/index.js";import{authenticateHttpBasicStrategy}from"#runtime/governance/auth/http-basic.js";import{authenticateJwtEcdsaStrategy}from"#runtime/governance/auth/jwt-ecdsa.js";import{authenticateJwtHmacStrategy}from"#runtime/governance/auth/jwt-hmac.js";import{authenticateOidcStrategy}from"#runtime/governance/auth/oidc.js";import{createRuntimeSessionAuthContext}from"#runtime/governance/auth/types.js";import{createRuntimeIpAllowList,isRuntimeIpAllowed}from"#runtime/governance/network/ip-allow-list.js";const vercelOidcLog=createLogger(`auth.vercel-oidc`);function verifyHttpBasic(e,t){if(e===null)return{ok:!1};let r=authenticateHttpBasicStrategy({authorization:e,strategy:{kind:`http-basic`,password:t.password,username:t.username}});return r.kind===`authenticated`?{ok:!0,sessionAuth:createRuntimeSessionAuthContext(r.principal)}:{ok:!1}}async function verifyJwtHmac(e,t){if(e===null||e.length===0)return{ok:!1};let n=await authenticateJwtHmacStrategy({strategy:{algorithm:t.algorithm,audiences:[...t.audiences],clockSkewSeconds:t.clockSkewSeconds??30,issuer:t.issuer,kind:`jwt-hmac`,secret:t.secret,...t.claims===void 0?{}:{claims:t.claims},...t.subjects===void 0?{}:{subjects:t.subjects}},token:e});return n.kind===`authenticated`?{ok:!0,sessionAuth:createRuntimeSessionAuthContext(n.principal)}:{ok:!1}}async function verifyJwtEcdsa(e,t){if(e===null||e.length===0)return{ok:!1};let n=await authenticateJwtEcdsaStrategy({strategy:{algorithm:t.algorithm,audiences:[...t.audiences],clockSkewSeconds:t.clockSkewSeconds??30,issuer:t.issuer,kind:`jwt-ecdsa`,publicKey:t.publicKey,...t.claims===void 0?{}:{claims:t.claims},...t.subjects===void 0?{}:{subjects:t.subjects}},token:e});return n.kind===`authenticated`?{ok:!0,sessionAuth:createRuntimeSessionAuthContext(n.principal)}:{ok:!1}}async function verifyOidc(e,t){let n=await runOidcVerification(e,{...t,acceptCurrentVercelProject:!1});return n.kind===`authenticated`?{ok:!0,sessionAuth:createRuntimeSessionAuthContext(n.principal)}:{ok:!1}}async function runOidcVerification(e,t){return e===null||e.length===0?{kind:`not-authenticated`}:await authenticateOidcStrategy({strategy:{acceptCurrentVercelProject:t.acceptCurrentVercelProject,audiences:[...t.audiences],clockSkewSeconds:t.clockSkewSeconds??30,discoveryUrl:t.discoveryUrl??`${t.issuer.replace(/\/$/,``)}/.well-known/openid-configuration`,issuer:t.issuer,kind:`oidc`,...t.claims===void 0?{}:{claims:t.claims},...t.subjects===void 0?{}:{subjects:t.subjects}},token:e})}function extractBearerToken(e){if(e===null)return null;let t=/^Bearer\s+(.+)$/i.exec(e)?.[1]?.trim();return t===void 0||t.length===0?null:t}function createIpAllowList(e){return createRuntimeIpAllowList(e)}function isIpAllowed(e,t){return e===null?!1:isRuntimeIpAllowed(e,t)}function createUnauthorizedResponse(e={}){let t=e.status??401,n=e.code??(t===403?`forbidden`:`unauthorized`),r=e.message??(t===403?`Forbidden.`:`Authorization is required for this route.`),i=e.challenges??[],a=new Headers({"cache-control":`no-store`});for(let e of i)a.append(`www-authenticate`,formatChallenge(e));return Response.json({code:n,error:r,ok:!1},{headers:a,status:t})}function formatChallenge(e){if(e.parameters===void 0||Object.keys(e.parameters).length===0)return e.scheme;let t=Object.entries(e.parameters).map(([e,t])=>`${e}="${escapeChallengeValue(t)}"`).join(`, `);return`${e.scheme} ${t}`}function escapeChallengeValue(e){return e.replaceAll(`\\`,`\\\\`).replaceAll(`"`,`\\"`)}async function routeAuth(e,t){let n=Array.isArray(t)?t:[t];for(let t of n){let n=await t(e);if(n)return n}return createUnauthorizedResponse({challenges:[{scheme:`Bearer`}]})}function none(){return()=>ANONYMOUS_SESSION_AUTH_CONTEXT}function localDev(){return e=>isLoopbackRequest(e)?LOCAL_DEV_SESSION_AUTH_CONTEXT:null}const LOOPBACK_HOSTNAMES=new Set([`localhost`,`[::1]`]),LOOPBACK_IPV4_PREFIX=/^127\./;function isLoopbackRequest(e){let t;try{t=new URL(e.url).hostname}catch{return!1}return!!(LOOPBACK_HOSTNAMES.has(t)||LOOPBACK_IPV4_PREFIX.test(t)||t.endsWith(`.localhost`))}const ANONYMOUS_SESSION_AUTH_CONTEXT={attributes:{},authenticator:`none`,principalId:`anonymous`,principalType:`anonymous`},LOCAL_DEV_SESSION_AUTH_CONTEXT={attributes:{},authenticator:`local-dev`,principalId:`local-dev`,principalType:`local-dev`};async function verifyVercelOidc(e,t={}){if(e===null||e.length===0)return vercelOidcLog.debug(`Rejected request without a bearer token.`),{ok:!1};let n=decodeUnverifiedJwtClaims(e);if(n===null)return vercelOidcLog.debug(`Rejected token that failed to decode as a JWT.`),{ok:!1};if(!n.issuer.startsWith(`https://oidc.vercel.com/`))return vercelOidcLog.debug(`Rejected token whose issuer is not a Vercel OIDC issuer.`,{issuer:n.issuer}),{ok:!1};if(n.audiences.length===0)return vercelOidcLog.debug(`Rejected token with no audience claim.`,{issuer:n.issuer}),{ok:!1};let r=await runOidcVerification(e,{acceptCurrentVercelProject:!0,audiences:n.audiences,issuer:n.issuer,subjects:t.subjects??[]});return r.kind===`authenticated`?(vercelOidcLog.debug(`Accepted Vercel OIDC token.`,{issuer:n.issuer,principalType:r.principal.principalType,subject:r.principal.subject}),{ok:!0,sessionAuth:createRuntimeSessionAuthContext(r.principal)}):(vercelOidcLog.debug(`Rejected Vercel OIDC token after verification.`,{audiences:n.audiences,issuer:n.issuer,reason:r.kind,subjectsConfigured:(t.subjects??[]).length>0,...r.kind===`misconfigured`?{detail:r.message}:{}}),{ok:!1})}function vercelSubject(e){assertVercelSubjectSegment(`teamSlug`,e.teamSlug),assertVercelSubjectSegment(`projectName`,e.projectName);let t=e.environment??`production`;if(t!==`production`&&t!==`preview`&&t!==`development`&&t!==`*`)throw Error(`vercelSubject: invalid environment ${JSON.stringify(t)}; expected "production", "preview", "development", or "*".`);return`owner:${e.teamSlug}:project:${e.projectName}:environment:${t}`}function assertVercelSubjectSegment(e,t){if(t.length===0)throw Error(`vercelSubject: ${e} must be a non-empty string.`);if(t.includes(`*`)||t.includes(`:`))throw Error(`vercelSubject: ${e} ${JSON.stringify(t)} may not contain ${t.includes(`:`)?`':'`:`'*'`}. Hand-write the subject string when wildcards are intentional.`)}function vercelOidc(e={}){return async t=>{let n=await verifyVercelOidc(extractBearerToken(t.headers.get(`authorization`)),e);return n.ok?n.sessionAuth:null}}function httpBasic(e){return t=>{let n=verifyHttpBasic(t.headers.get(`authorization`),e);return n.ok?n.sessionAuth:null}}function jwtHmac(e){return async t=>{let n=await verifyJwtHmac(extractBearerToken(t.headers.get(`authorization`)),e);return n.ok?n.sessionAuth:null}}function jwtEcdsa(e){return async t=>{let n=await verifyJwtEcdsa(extractBearerToken(t.headers.get(`authorization`)),e);return n.ok?n.sessionAuth:null}}function oidc(e){return async t=>{let n=await verifyOidc(extractBearerToken(t.headers.get(`authorization`)),e);return n.ok?n.sessionAuth:null}}function decodeUnverifiedJwtClaims(e){let n;try{n=decodeJwt(e)}catch{return null}return typeof n.iss!=`string`||n.iss.length===0?null:{audiences:typeof n.aud==`string`?[n.aud]:Array.isArray(n.aud)?n.aud.filter(e=>typeof e==`string`):[],issuer:n.iss}}export{createIpAllowList,createUnauthorizedResponse,extractBearerToken,httpBasic,isIpAllowed,jwtEcdsa,jwtHmac,localDev,none,oidc,routeAuth,vercelOidc,vercelSubject,verifyHttpBasic,verifyJwtEcdsa,verifyJwtHmac,verifyOidc,verifyVercelOidc};
1
+ import{createLogger}from"#internal/logging.js";import{decodeJwt}from"#compiled/jose/index.js";import{authenticateHttpBasicStrategy}from"#runtime/governance/auth/http-basic.js";import{authenticateJwtEcdsaStrategy}from"#runtime/governance/auth/jwt-ecdsa.js";import{authenticateJwtHmacStrategy}from"#runtime/governance/auth/jwt-hmac.js";import{authenticateOidcStrategy}from"#runtime/governance/auth/oidc.js";import{createRuntimeSessionAuthContext}from"#runtime/governance/auth/types.js";import{createRuntimeIpAllowList,isRuntimeIpAllowed}from"#runtime/governance/network/ip-allow-list.js";const vercelOidcLog=createLogger(`auth.vercel-oidc`);function verifyHttpBasic(e,t){if(e===null)return{ok:!1};let r=authenticateHttpBasicStrategy({authorization:e,strategy:{kind:`http-basic`,password:t.password,username:t.username}});return r.kind===`authenticated`?{ok:!0,sessionAuth:createRuntimeSessionAuthContext(r.principal)}:{ok:!1}}async function verifyJwtHmac(e,t){if(e===null||e.length===0)return{ok:!1};let n=await authenticateJwtHmacStrategy({strategy:{algorithm:t.algorithm,audiences:[...t.audiences],clockSkewSeconds:t.clockSkewSeconds??30,issuer:t.issuer,kind:`jwt-hmac`,secret:t.secret,...t.claims===void 0?{}:{claims:t.claims},...t.subjects===void 0?{}:{subjects:t.subjects}},token:e});return n.kind===`authenticated`?{ok:!0,sessionAuth:createRuntimeSessionAuthContext(n.principal)}:{ok:!1}}async function verifyJwtEcdsa(e,t){if(e===null||e.length===0)return{ok:!1};let n=await authenticateJwtEcdsaStrategy({strategy:{algorithm:t.algorithm,audiences:[...t.audiences],clockSkewSeconds:t.clockSkewSeconds??30,issuer:t.issuer,kind:`jwt-ecdsa`,publicKey:t.publicKey,...t.claims===void 0?{}:{claims:t.claims},...t.subjects===void 0?{}:{subjects:t.subjects}},token:e});return n.kind===`authenticated`?{ok:!0,sessionAuth:createRuntimeSessionAuthContext(n.principal)}:{ok:!1}}async function verifyOidc(e,t){let n=await runOidcVerification(e,{...t,acceptCurrentVercelProject:!1});return n.kind===`authenticated`?{ok:!0,sessionAuth:createRuntimeSessionAuthContext(n.principal)}:{ok:!1}}async function runOidcVerification(e,t){return e===null||e.length===0?{kind:`not-authenticated`}:await authenticateOidcStrategy({strategy:{acceptCurrentVercelProject:t.acceptCurrentVercelProject,audiences:[...t.audiences],clockSkewSeconds:t.clockSkewSeconds??30,discoveryUrl:t.discoveryUrl??`${t.issuer.replace(/\/$/,``)}/.well-known/openid-configuration`,issuer:t.issuer,kind:`oidc`,...t.claims===void 0?{}:{claims:t.claims},...t.subjects===void 0?{}:{subjects:t.subjects}},token:e})}function extractBearerToken(e){if(e===null)return null;let t=/^Bearer\s+(.+)$/i.exec(e)?.[1]?.trim();return t===void 0||t.length===0?null:t}function createIpAllowList(e){return createRuntimeIpAllowList(e)}function isIpAllowed(e,t){return e===null?!1:isRuntimeIpAllowed(e,t)}function createUnauthorizedResponse(e={}){let t=e.status??401,n=e.code??(t===403?`forbidden`:`unauthorized`),r=e.message??(t===403?`Forbidden.`:`Authorization is required for this route.`),i=e.challenges??[],a=new Headers({"cache-control":`no-store`});for(let e of i)a.append(`www-authenticate`,formatChallenge(e));return Response.json({code:n,error:r,ok:!1},{headers:a,status:t})}function formatChallenge(e){if(e.parameters===void 0||Object.keys(e.parameters).length===0)return e.scheme;let t=Object.entries(e.parameters).map(([e,t])=>`${e}="${escapeChallengeValue(t)}"`).join(`, `);return`${e.scheme} ${t}`}function escapeChallengeValue(e){return e.replaceAll(`\\`,`\\\\`).replaceAll(`"`,`\\"`)}async function routeAuth(e,t){let n=Array.isArray(t)?t:[t];for(let t of n){let n=await t(e);if(n)return n}return createUnauthorizedResponse({challenges:[{scheme:`Bearer`}]})}function none(){return()=>ANONYMOUS_SESSION_AUTH_CONTEXT}function localDev(){return e=>process.env.VERCEL&&process.env.VERCEL_ENV===`development`||isLoopbackRequest(e)?LOCAL_DEV_SESSION_AUTH_CONTEXT:null}const LOOPBACK_HOSTNAMES=new Set([`localhost`,`[::1]`]),LOOPBACK_IPV4_PREFIX=/^127\./;function isLoopbackRequest(e){let t;try{t=new URL(e.url).hostname}catch{return!1}return!!(LOOPBACK_HOSTNAMES.has(t)||LOOPBACK_IPV4_PREFIX.test(t)||t.endsWith(`.localhost`))}const ANONYMOUS_SESSION_AUTH_CONTEXT={attributes:{},authenticator:`none`,principalId:`anonymous`,principalType:`anonymous`},LOCAL_DEV_SESSION_AUTH_CONTEXT={attributes:{},authenticator:`local-dev`,principalId:`local-dev`,principalType:`local-dev`};async function verifyVercelOidc(e,t={}){if(e===null||e.length===0)return{ok:!1};let n=decodeUnverifiedJwtClaims(e);if(n===null)return vercelOidcLog.debug(`Rejected token that failed to decode as a JWT.`),{ok:!1};if(!n.issuer.startsWith(`https://oidc.vercel.com/`))return vercelOidcLog.debug(`Rejected token whose issuer is not a Vercel OIDC issuer.`,{issuer:n.issuer}),{ok:!1};if(n.audiences.length===0)return vercelOidcLog.debug(`Rejected token with no audience claim.`,{issuer:n.issuer}),{ok:!1};let r=await runOidcVerification(e,{acceptCurrentVercelProject:!0,audiences:n.audiences,issuer:n.issuer,subjects:t.subjects??[]});return r.kind===`authenticated`?(vercelOidcLog.debug(`Accepted Vercel OIDC token.`,{issuer:n.issuer,principalType:r.principal.principalType,subject:r.principal.subject}),{ok:!0,sessionAuth:createRuntimeSessionAuthContext(r.principal)}):(vercelOidcLog.debug(`Rejected Vercel OIDC token after verification.`,{audiences:n.audiences,issuer:n.issuer,reason:r.kind,subjectsConfigured:(t.subjects??[]).length>0,...r.kind===`misconfigured`?{detail:r.message}:{}}),{ok:!1})}function vercelSubject(e){assertVercelSubjectSegment(`teamSlug`,e.teamSlug),assertVercelSubjectSegment(`projectName`,e.projectName);let t=e.environment??`production`;if(t!==`production`&&t!==`preview`&&t!==`development`&&t!==`*`)throw Error(`vercelSubject: invalid environment ${JSON.stringify(t)}; expected "production", "preview", "development", or "*".`);return`owner:${e.teamSlug}:project:${e.projectName}:environment:${t}`}function assertVercelSubjectSegment(e,t){if(t.length===0)throw Error(`vercelSubject: ${e} must be a non-empty string.`);if(t.includes(`*`)||t.includes(`:`))throw Error(`vercelSubject: ${e} ${JSON.stringify(t)} may not contain ${t.includes(`:`)?`':'`:`'*'`}. Hand-write the subject string when wildcards are intentional.`)}function vercelOidc(e={}){return async t=>{let n=await verifyVercelOidc(extractBearerToken(t.headers.get(`authorization`)),e);return n.ok?n.sessionAuth:null}}function httpBasic(e){return t=>{let n=verifyHttpBasic(t.headers.get(`authorization`),e);return n.ok?n.sessionAuth:null}}function jwtHmac(e){return async t=>{let n=await verifyJwtHmac(extractBearerToken(t.headers.get(`authorization`)),e);return n.ok?n.sessionAuth:null}}function jwtEcdsa(e){return async t=>{let n=await verifyJwtEcdsa(extractBearerToken(t.headers.get(`authorization`)),e);return n.ok?n.sessionAuth:null}}function oidc(e){return async t=>{let n=await verifyOidc(extractBearerToken(t.headers.get(`authorization`)),e);return n.ok?n.sessionAuth:null}}function decodeUnverifiedJwtClaims(e){let n;try{n=decodeJwt(e)}catch{return null}return typeof n.iss!=`string`||n.iss.length===0?null:{audiences:typeof n.aud==`string`?[n.aud]:Array.isArray(n.aud)?n.aud.filter(e=>typeof e==`string`):[],issuer:n.iss}}export{createIpAllowList,createUnauthorizedResponse,extractBearerToken,httpBasic,isIpAllowed,jwtEcdsa,jwtHmac,localDev,none,oidc,routeAuth,vercelOidc,vercelSubject,verifyHttpBasic,verifyJwtEcdsa,verifyJwtHmac,verifyOidc,verifyVercelOidc};
@@ -1,6 +1,6 @@
1
1
  import type { Optional } from "#shared/optional.js";
2
2
  import type { SandboxDefinition as SharedSandboxDefinition } from "#shared/sandbox-definition.js";
3
- export type { SandboxCommandResult, SandboxProcess, SandboxReadBinaryFileOptions, SandboxReadFileOptions, SandboxReadTextFileOptions, SandboxRunCommandOptions, SandboxRunOptions, SandboxSession, SandboxSpawnOptions, SandboxWriteBinaryFileOptions, SandboxWriteFileOptions, SandboxWriteTextFileOptions, } from "#shared/sandbox-session.js";
3
+ export type { SandboxCommandResult, SandboxProcess, SandboxReadBinaryFileOptions, SandboxReadFileOptions, SandboxReadTextFileOptions, SandboxRunOptions, SandboxSession, SandboxSpawnOptions, SandboxWriteBinaryFileOptions, SandboxWriteFileOptions, SandboxWriteTextFileOptions, } from "#shared/sandbox-session.js";
4
4
  export type { SandboxBootstrapUseFn, SandboxSessionUseFn, SandboxBootstrapContext, SandboxSessionContext, } from "#shared/sandbox-definition.js";
5
5
  export type SandboxDefinition<BO = Record<string, never>, SO = Record<string, never>> = Optional<SharedSandboxDefinition<BO, SO>, "backend">;
6
6
  /**
@@ -3,7 +3,7 @@
3
3
  * `agent/sandbox/sandbox.ts` when paired with a `workspace/` folder).
4
4
  */
5
5
  export { getSandbox } from "#context/accessors.js";
6
- export { defineSandbox, type SandboxBootstrapContext, type SandboxBootstrapUseFn, type SandboxCommandResult, type SandboxDefinition, type SandboxProcess, type SandboxReadBinaryFileOptions, type SandboxReadFileOptions, type SandboxReadTextFileOptions, type SandboxRunCommandOptions, type SandboxRunOptions, type SandboxSession, type SandboxSpawnOptions, type SandboxSessionContext, type SandboxSessionUseFn, type SandboxWriteBinaryFileOptions, type SandboxWriteFileOptions, type SandboxWriteTextFileOptions, } from "#public/definitions/sandbox.js";
6
+ export { defineSandbox, type SandboxBootstrapContext, type SandboxBootstrapUseFn, type SandboxCommandResult, type SandboxDefinition, type SandboxProcess, type SandboxReadBinaryFileOptions, type SandboxReadFileOptions, type SandboxReadTextFileOptions, type SandboxRunOptions, type SandboxSession, type SandboxSpawnOptions, type SandboxSessionContext, type SandboxSessionUseFn, type SandboxWriteBinaryFileOptions, type SandboxWriteFileOptions, type SandboxWriteTextFileOptions, } from "#public/definitions/sandbox.js";
7
7
  export type { SandboxBackend, SandboxBackendCreateInput, SandboxBackendHandle, SandboxBackendPrewarmInput, SandboxBackendRuntimeContext, SandboxBackendSessionState, SandboxSeedFile, } from "#public/definitions/sandbox-backend.js";
8
8
  export { SandboxTemplateNotProvisionedError } from "#public/definitions/sandbox-backend.js";
9
9
  export { defaultBackend } from "#public/sandbox/backends/default.js";