eve 0.24.4 → 0.24.6
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.
- package/CHANGELOG.md +31 -0
- package/dist/src/channel/cancel.d.ts +8 -0
- package/dist/src/channel/cancel.js +1 -0
- package/dist/src/channel/routes.d.ts +25 -4
- package/dist/src/channel/session.d.ts +10 -1
- package/dist/src/channel/session.js +1 -1
- package/dist/src/channel/types.d.ts +21 -0
- package/dist/src/chunks/{use-eve-agent-Dwa2j1wE.js → use-eve-agent-6BO9gFVq.js} +61 -6
- package/dist/src/chunks/{use-eve-agent-BP9FpQsJ.js → use-eve-agent-B1MJNRE-.js} +61 -6
- package/dist/src/cli/commands/build.d.ts +14 -0
- package/dist/src/cli/commands/build.js +1 -0
- package/dist/src/cli/commands/channels.js +1 -1
- package/dist/src/cli/commands/link.d.ts +6 -5
- package/dist/src/cli/commands/link.js +1 -1
- package/dist/src/cli/run.d.ts +3 -2
- package/dist/src/cli/run.js +1 -1
- package/dist/src/client/index.d.ts +1 -1
- package/dist/src/client/ndjson.js +1 -1
- package/dist/src/client/open-stream.d.ts +3 -2
- package/dist/src/client/open-stream.js +1 -1
- package/dist/src/client/session.d.ts +19 -3
- package/dist/src/client/session.js +1 -1
- package/dist/src/client/types.d.ts +8 -0
- package/dist/src/compiled/.vendor-stamp.json +5 -5
- package/dist/src/compiled/@workflow/core/index.js +2 -2
- package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +55 -0
- package/dist/src/compiled/@workflow/core/runtime/run-id-time.d.ts +9 -0
- package/dist/src/compiled/@workflow/core/runtime/step-executor.d.ts +2 -0
- package/dist/src/compiled/@workflow/core/runtime/step-latency.d.ts +70 -4
- package/dist/src/compiled/@workflow/core/runtime/suspension-handler.d.ts +10 -1
- package/dist/src/compiled/@workflow/core/runtime.js +3 -3
- package/dist/src/compiled/@workflow/core/step/context-storage.d.ts +6 -0
- package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +25 -0
- package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/errors/index.d.ts +16 -0
- package/dist/src/compiled/@workflow/errors/index.js +1 -1
- package/dist/src/compiled/@workflow/world/attributes.d.ts +7 -0
- package/dist/src/compiled/@workflow/world/events.d.ts +16 -0
- package/dist/src/compiled/@workflow/world/index.d.ts +1 -1
- package/dist/src/compiled/@workflow/world-local/index.js +3 -3
- package/dist/src/compiled/@workflow/world-vercel/index.js +16 -16
- package/dist/src/compiled/_chunks/workflow/attribute-changes-DXbmITuI.js +20 -0
- package/dist/src/compiled/_chunks/workflow/{dist-DpDDcpTl.js → dist-BYo8Gno2.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{dist-Blxnyb7-.js → dist-CSfKNxQW.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/resume-hook-DvvgYsRt.js +1 -0
- package/dist/src/compiled/_chunks/workflow/run-BdvQmV5a.js +1 -0
- package/dist/src/compiled/_chunks/workflow/run-id-BdE0MZz9.js +1 -0
- package/dist/src/compiled/_chunks/workflow/sleep-DzxrwWTs.js +1 -0
- package/dist/src/evals/assertions/run.d.ts +3 -3
- package/dist/src/evals/context.js +1 -1
- package/dist/src/evals/index.d.ts +2 -1
- package/dist/src/evals/match.d.ts +4 -0
- package/dist/src/evals/match.js +1 -1
- package/dist/src/evals/runner/derive-run-facts.js +1 -1
- package/dist/src/evals/session.d.ts +10 -2
- package/dist/src/evals/session.js +1 -1
- package/dist/src/evals/target.js +1 -1
- package/dist/src/evals/types.d.ts +52 -2
- package/dist/src/execution/cancel-descendant-turns-step.d.ts +6 -0
- package/dist/src/execution/cancel-descendant-turns-step.js +1 -0
- package/dist/src/execution/create-session-step.js +1 -1
- package/dist/src/execution/dispatch-runtime-actions-step.js +1 -1
- package/dist/src/execution/dispatch-workflow-runtime-actions-step.js +1 -1
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/remote-agent-dispatch.d.ts +6 -0
- package/dist/src/execution/remote-agent-dispatch.js +1 -1
- package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
- package/dist/src/execution/subagent-event-proxy-step.js +1 -1
- package/dist/src/execution/turn-cancellation-control.d.ts +0 -13
- package/dist/src/execution/turn-cancellation-control.js +1 -1
- package/dist/src/execution/turn-cancellation-token.d.ts +9 -0
- package/dist/src/execution/turn-cancellation-token.js +1 -0
- package/dist/src/execution/turn-workflow.js +1 -1
- package/dist/src/execution/workflow-runtime.d.ts +3 -1
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/execution/workflow-steps.js +1 -1
- package/dist/src/harness/advertised-tools.js +1 -1
- package/dist/src/harness/execute-tool.d.ts +0 -1
- package/dist/src/harness/runtime-actions.d.ts +16 -12
- package/dist/src/harness/runtime-actions.js +1 -1
- package/dist/src/internal/application/build-profile.d.ts +64 -0
- package/dist/src/internal/application/build-profile.js +1 -0
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-module-loader.d.ts +10 -0
- package/dist/src/internal/authored-module-loader.js +2 -2
- package/dist/src/internal/authored-module-map-loader.js +1 -1
- package/dist/src/internal/materialized-authored-modules.d.ts +2 -4
- package/dist/src/internal/materialized-authored-modules.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
- package/dist/src/internal/nitro/host/build-application.js +1 -1
- package/dist/src/internal/nitro/host/types.d.ts +2 -0
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response-from-manifest.js +1 -1
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.d.ts +7 -1
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.js +1 -1
- package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
- package/dist/src/internal/nitro/routes/channel-route-context.d.ts +3 -0
- package/dist/src/internal/nitro/routes/channel-route-context.js +1 -1
- package/dist/src/internal/nitro/routes/runtime-stack.js +1 -1
- package/dist/src/internal/nitro/routes/schedule-task.js +1 -1
- package/dist/src/protocol/cancel-turn.d.ts +11 -0
- package/dist/src/protocol/cancel-turn.js +1 -0
- package/dist/src/protocol/routes.d.ts +10 -0
- package/dist/src/protocol/routes.js +1 -1
- package/dist/src/public/channels/eve.d.ts +2 -1
- package/dist/src/public/channels/eve.js +1 -1
- package/dist/src/public/channels/index.d.ts +1 -1
- package/dist/src/public/channels/linear/api.d.ts +0 -1
- package/dist/src/public/channels/linear/api.js +17 -22
- package/dist/src/public/channels/linear/linearChannel.js +1 -1
- package/dist/src/public/definitions/channel.d.ts +21 -11
- package/dist/src/public/next/index.js +1 -1
- package/dist/src/public/next/resolve-eve-binary.d.ts +12 -0
- package/dist/src/public/next/resolve-eve-binary.js +1 -0
- package/dist/src/runtime/agent/mock-model-adapter.js +1 -1
- package/dist/src/runtime/framework-tools/agent.d.ts +13 -0
- package/dist/src/runtime/framework-tools/agent.js +1 -0
- package/dist/src/runtime/framework-tools/index.d.ts +7 -2
- package/dist/src/runtime/framework-tools/index.js +1 -1
- package/dist/src/runtime/resolve-agent-graph.js +1 -1
- package/dist/src/runtime/types.d.ts +2 -1
- package/dist/src/setup/boxes/reconcile-host-framework-preset.d.ts +26 -0
- package/dist/src/setup/boxes/reconcile-host-framework-preset.js +1 -0
- package/dist/src/setup/boxes/resolve-provisioning.js +1 -1
- package/dist/src/setup/index.js +1 -1
- package/dist/src/setup/scaffold/create/add-to-project.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +2 -2
- package/dist/src/setup/scaffold/create/web-template.d.ts +1 -1
- package/dist/src/setup/scaffold/create/web-template.js +1 -0
- package/dist/src/setup/scaffold/index.d.ts +1 -1
- package/dist/src/setup/scaffold/index.js +1 -1
- package/dist/src/setup/scaffold/update/channels.d.ts +7 -1
- package/dist/src/setup/scaffold/update/channels.js +2 -2
- package/dist/src/setup/scaffold/update/connections.js +3 -3
- package/dist/src/setup/vercel-project-framework.d.ts +12 -0
- package/dist/src/setup/vercel-project-framework.js +1 -1
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/channels/custom.mdx +32 -2
- package/docs/channels/eve.mdx +11 -1
- package/docs/concepts/default-harness.md +2 -0
- package/docs/concepts/sessions-runs-and-streaming.md +13 -0
- package/docs/evals/assertions.mdx +2 -2
- package/docs/evals/cases.mdx +31 -0
- package/docs/evals/overview.mdx +1 -1
- package/docs/evals/targets.mdx +2 -1
- package/docs/guides/client/continuations.mdx +2 -0
- package/docs/guides/client/streaming.mdx +17 -1
- package/docs/guides/frontend/overview.mdx +4 -2
- package/docs/guides/frontend/use-eve-agent-svelte.mdx +2 -2
- package/docs/guides/frontend/use-eve-agent-vue.mdx +2 -2
- package/docs/guides/remote-agents.md +2 -0
- package/docs/reference/cli.md +15 -2
- package/docs/subagents.mdx +10 -0
- package/package.json +7 -7
- package/dist/src/compiled/_chunks/workflow/attribute-changes-MGTOG_uX.js +0 -20
- package/dist/src/compiled/_chunks/workflow/resume-hook-DHP5ql3-.js +0 -1
- package/dist/src/compiled/_chunks/workflow/run-D8hv1ptT.js +0 -1
- package/dist/src/compiled/_chunks/workflow/sleep-uA9pS-PT.js +0 -1
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import{a as e,i as t,t as n}from"../../_chunks/workflow/chunk-BHKSVoKr.js";import{
|
|
2
|
-
${e.message}`),t?new f.VercelOidcTokenError(t):e}return n}function m(){let e=(0,d.getContext)().headers?.[`x-vercel-oidc-token`]??process.env.VERCEL_OIDC_TOKEN;if(!e)throw Error(`The 'x-vercel-oidc-token' header is missing from the request. Do you have the OIDC option enabled in the Vercel project settings?`);return e}0&&(n.exports={getVercelOidcToken:p,getVercelOidcTokenSync:m})})),De=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{AccessTokenMissingError:()=>u,RefreshAccessTokenFailedError:()=>d}),t.exports=c(l);var u=class extends Error{constructor(){super(`No authentication found. Please log in with the Vercel CLI (vercel login).`),this.name=`AccessTokenMissingError`}},d=class extends Error{constructor(e){super(`Failed to refresh authentication token.`,{cause:e}),this.name=`RefreshAccessTokenFailedError`}};0&&(t.exports={AccessTokenMissingError:u,RefreshAccessTokenFailedError:d})})),Oe=n(((e,n)=>{var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},u=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let s of o(t))!c.call(e,s)&&s!==n&&i(e,s,{get:()=>t[s],enumerable:!(r=a(t,s))||r.enumerable});return e},d=(e,t,n)=>(n=e==null?{}:r(s(e)),u(t||!e||!e.__esModule?i(n,`default`,{value:e,enumerable:!0}):n,e)),f=e=>u(i({},`__esModule`,{value:!0}),e),p={};l(p,{findRootDir:()=>v,getUserDataDir:()=>y}),n.exports=f(p);var m=d(t(`path`)),h=d(t(`fs`)),g=d(t(`os`)),_=Te();function v(){try{let e=process.cwd();for(;e!==m.default.dirname(e);){let t=m.default.join(e,`.vercel`);if(h.default.existsSync(t))return e;e=m.default.dirname(e)}}catch{throw new _.VercelOidcTokenError(`Token refresh only supported in node server environments`)}return null}function y(){if(process.env.XDG_DATA_HOME)return process.env.XDG_DATA_HOME;switch(g.default.platform()){case`darwin`:return m.default.join(g.default.homedir(),`Library/Application Support`);case`linux`:return m.default.join(g.default.homedir(),`.local/share`);case`win32`:return process.env.LOCALAPPDATA?process.env.LOCALAPPDATA:null;default:return null}}0&&(n.exports={findRootDir:v,getUserDataDir:y})})),ke=n(((e,n)=>{var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},u=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let s of o(t))!c.call(e,s)&&s!==n&&i(e,s,{get:()=>t[s],enumerable:!(r=a(t,s))||r.enumerable});return e},d=(e,t,n)=>(n=e==null?{}:r(s(e)),u(t||!e||!e.__esModule?i(n,`default`,{value:e,enumerable:!0}):n,e)),f=e=>u(i({},`__esModule`,{value:!0}),e),p={};l(p,{isValidAccessToken:()=>b,readAuthConfig:()=>v,writeAuthConfig:()=>y}),n.exports=f(p);var m=d(t(`fs`)),h=d(t(`path`)),g=je();function _(){let e=(0,g.getVercelDataDir)();if(!e)throw Error(`Unable to find Vercel CLI data directory. Your platform: ${process.platform}. Supported: darwin, linux, win32.`);return h.join(e,`auth.json`)}function v(){try{let e=_();if(!m.existsSync(e))return null;let t=m.readFileSync(e,`utf8`);return t?JSON.parse(t):null}catch{return null}}function y(e){let t=_(),n=h.dirname(t);m.existsSync(n)||m.mkdirSync(n,{mode:504,recursive:!0}),m.writeFileSync(t,JSON.stringify(e,null,2),{mode:384})}function b(e,t=0){if(!e.token)return!1;if(typeof e.expiresAt!=`number`)return!0;let n=Math.floor(Date.now()/1e3),r=t/1e3;return e.expiresAt>=n+r}0&&(n.exports={isValidAccessToken:b,readAuthConfig:v,writeAuthConfig:y})})),Ae=n(((e,n)=>{var r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})},c=(e,t,n,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==n&&r(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(r({},`__esModule`,{value:!0}),e),u={};s(u,{processTokenResponse:()=>g,refreshTokenRequest:()=>h}),n.exports=l(u);var d=t(`os`);let f=`@vercel/oidc node-${process.version} ${(0,d.platform)()} (${(0,d.arch)()}) ${(0,d.hostname)()}`,p=null;async function m(){if(p)return p;let e=await fetch(`https://vercel.com/.well-known/openid-configuration`,{headers:{"user-agent":f}});if(!e.ok)throw Error(`Failed to discover OAuth endpoints`);let t=await e.json();if(!t||typeof t.token_endpoint!=`string`)throw Error(`Invalid OAuth discovery response`);let n=t.token_endpoint;return p=n,n}async function h(e){let t=await m();return await fetch(t,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`,"user-agent":f},body:new URLSearchParams({client_id:`cl_HYyOPBNtFMfHhaUn9L4QPfTZz6TP47bp`,grant_type:`refresh_token`,...e})})}async function g(e){let t=await e.json();if(!e.ok){let e=typeof t==`object`&&t&&`error`in t?String(t.error):`Token refresh failed`;return[Error(e)]}return typeof t!=`object`||!t?[Error(`Invalid token response`)]:typeof t.access_token==`string`?t.token_type===`Bearer`?typeof t.expires_in==`number`?[null,t]:[Error(`Missing expires_in in response`)]:[Error(`Invalid token_type in response`)]:[Error(`Missing access_token in response`)]}0&&(n.exports={processTokenResponse:g,refreshTokenRequest:h})})),je=n(((e,n)=>{var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},u=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let s of o(t))!c.call(e,s)&&s!==n&&i(e,s,{get:()=>t[s],enumerable:!(r=a(t,s))||r.enumerable});return e},d=(e,t,n)=>(n=e==null?{}:r(s(e)),u(t||!e||!e.__esModule?i(n,`default`,{value:e,enumerable:!0}):n,e)),f=e=>u(i({},`__esModule`,{value:!0}),e),p={};l(p,{assertVercelOidcTokenResponse:()=>w,findProjectInfo:()=>T,getTokenPayload:()=>ee,getVercelDataDir:()=>x,getVercelOidcToken:()=>C,getVercelToken:()=>S,isExpired:()=>te,loadToken:()=>D,saveToken:()=>E}),n.exports=f(p);var m=d(t(`path`)),h=d(t(`fs`)),g=Te(),_=Oe(),v=ke(),y=Ae(),b=De();function x(){let e=(0,_.getUserDataDir)();return e?m.join(e,`com.vercel.cli`):null}async function S(e){let t=(0,v.readAuthConfig)();if(!t?.token)throw new b.AccessTokenMissingError;if((0,v.isValidAccessToken)(t,e?.expirationBufferMs))return t.token;if(!t.refreshToken)throw(0,v.writeAuthConfig)({}),new b.RefreshAccessTokenFailedError(`No refresh token available`);try{let e=await(0,y.refreshTokenRequest)({refresh_token:t.refreshToken}),[n,r]=await(0,y.processTokenResponse)(e);if(n||!r)throw(0,v.writeAuthConfig)({}),new b.RefreshAccessTokenFailedError(n);let i={token:r.access_token,expiresAt:Math.floor(Date.now()/1e3)+r.expires_in};return r.refresh_token&&(i.refreshToken=r.refresh_token),(0,v.writeAuthConfig)(i),i.token}catch(e){throw(0,v.writeAuthConfig)({}),e instanceof b.AccessTokenMissingError||e instanceof b.RefreshAccessTokenFailedError?e:new b.RefreshAccessTokenFailedError(e)}}async function C(e,t,n){let r=`https://api.vercel.com/v1/projects/${t}/token?source=vercel-oidc-refresh${n?`&teamId=${n}`:``}`,i=await fetch(r,{method:`POST`,headers:{Authorization:`Bearer ${e}`}});if(!i.ok)throw new g.VercelOidcTokenError(`Failed to refresh OIDC token: ${i.statusText}`);let a=await i.json();return w(a),a}function w(e){if(!e||typeof e!=`object`)throw TypeError("Vercel OIDC token is malformed. Expected an object. Please run `vc env pull` and try again");if(!(`token`in e)||typeof e.token!=`string`)throw TypeError("Vercel OIDC token is malformed. Expected a string-valued token property. Please run `vc env pull` and try again")}function T(){let e=(0,_.findRootDir)();if(!e)throw new g.VercelOidcTokenError("Unable to find project root directory. Have you linked your project with `vc link?`");let t=m.join(e,`.vercel`,`project.json`);if(!h.existsSync(t))throw new g.VercelOidcTokenError("project.json not found, have you linked your project with `vc link?`");let n=JSON.parse(h.readFileSync(t,`utf8`));if(typeof n.projectId!=`string`&&typeof n.orgId!=`string`)throw TypeError("Expected a string-valued projectId property. Try running `vc link` to re-link your project.");return{projectId:n.projectId,teamId:n.orgId}}function E(e,t){let n=(0,_.getUserDataDir)();if(!n)throw new g.VercelOidcTokenError(`Unable to find user data directory. Please reach out to Vercel support.`);let r=m.join(n,`com.vercel.token`,`${t}.json`),i=JSON.stringify(e);h.mkdirSync(m.dirname(r),{mode:504,recursive:!0}),h.writeFileSync(r,i),h.chmodSync(r,432)}function D(e){let t=(0,_.getUserDataDir)();if(!t)throw new g.VercelOidcTokenError(`Unable to find user data directory. Please reach out to Vercel support.`);let n=m.join(t,`com.vercel.token`,`${e}.json`);if(!h.existsSync(n))return null;let r=JSON.parse(h.readFileSync(n,`utf8`));return w(r),r}function ee(e){let t=e.split(`.`);if(t.length!==3)throw new g.VercelOidcTokenError("Invalid token. Please run `vc env pull` and try again");let n=t[1].replace(/-/g,`+`).replace(/_/g,`/`),r=n.padEnd(n.length+(4-n.length%4)%4,`=`);return JSON.parse(Buffer.from(r,`base64`).toString(`utf8`))}function te(e,t=0){return e.exp*1e3<Date.now()+t}0&&(n.exports={assertVercelOidcTokenResponse:w,findProjectInfo:T,getTokenPayload:ee,getVercelDataDir:x,getVercelOidcToken:C,getVercelToken:S,isExpired:te,loadToken:D,saveToken:E})})),Me=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{AccessTokenMissingError:()=>f.AccessTokenMissingError,RefreshAccessTokenFailedError:()=>f.RefreshAccessTokenFailedError,getContext:()=>d.getContext,getVercelOidcToken:()=>u.getVercelOidcToken,getVercelOidcTokenSync:()=>u.getVercelOidcTokenSync,getVercelToken:()=>p.getVercelToken}),t.exports=c(l);var u=Ee(),d=we(),f=De(),p=je();0&&(t.exports={AccessTokenMissingError,RefreshAccessTokenFailedError,getContext,getVercelOidcToken,getVercelOidcTokenSync,getVercelToken})}))();let Ne;try{Ne=new TextDecoder}catch{}let O,Pe,k=0;const Fe=[],Ie=57337,Le={};let Re=11281e4,ze=1681e4,Be=Fe,Ve=0,A={},j,He,Ue=0,We=0,M,N,P=[],Ge=[],F,I,Ke,qe={useRecords:!1,mapsAsObjects:!0},Je=!1,Ye=2;try{Function(``)}catch{Ye=1/0}var Xe=class e{constructor(e){if(e&&((e.keyMap||e._keyMap)&&!e.useRecords&&(e.useRecords=!1,e.mapsAsObjects=!0),e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.getStructures&&(e.getShared=e.getStructures),e.getShared&&!e.structures&&((e.structures=[]).uninitialized=!0),e.keyMap)){this.mapKey=new Map;for(let[t,n]of Object.entries(e.keyMap))this.mapKey.set(n,t)}Object.assign(this,e)}decodeKey(e){return this.keyMap&&this.mapKey.get(e)||e}encodeKey(e){return this.keyMap&&this.keyMap.hasOwnProperty(e)?this.keyMap[e]:e}encodeKeys(e){if(!this._keyMap)return e;let t=new Map;for(let[n,r]of Object.entries(e))t.set(this._keyMap.hasOwnProperty(n)?this._keyMap[n]:n,r);return t}decodeKeys(e){if(!this._keyMap||e.constructor.name!=`Map`)return e;if(!this._mapKey){this._mapKey=new Map;for(let[e,t]of Object.entries(this._keyMap))this._mapKey.set(t,e)}let t={};return e.forEach((e,n)=>t[R(this._mapKey.has(n)?this._mapKey.get(n):n)]=e),t}mapDecode(e,t){let n=this.decode(e);if(this._keyMap)switch(n.constructor.name){case`Array`:return n.map(e=>this.decodeKeys(e))}return n}decode(t,n){if(O)return St(()=>(Ct(),this?this.decode(t,n):e.prototype.decode.call(qe,t,n)));Pe=n>-1?n:t.length,k=0,Ve=0,We=0,He=null,Be=Fe,M=null,O=t;try{I=t.dataView||=new DataView(t.buffer,t.byteOffset,t.byteLength)}catch(e){throw O=null,t instanceof Uint8Array?e:Error(`Source must be a Uint8Array or Buffer but was a `+(t&&typeof t==`object`?t.constructor.name:typeof t))}if(this instanceof e){if(A=this,F=this.sharedValues&&(this.pack?Array(this.maxPrivatePackedValues||16).concat(this.sharedValues):this.sharedValues),this.structures)return j=this.structures,Ze();(!j||j.length>0)&&(j=[])}else A=qe,(!j||j.length>0)&&(j=[]),F=null;return Ze()}decodeMultiple(e,t){let n,r=0;try{let i=e.length;Je=!0;let a=this?this.decode(e,i):Tt.decode(e,i);if(t){if(t(a)===!1)return;for(;k<i;)if(r=k,t(Ze())===!1)return}else{for(n=[a];k<i;)r=k,n.push(Ze());return n}}catch(e){throw e.lastPosition=r,e.values=n,e}finally{Je=!1,Ct()}}};function Ze(){try{let e=L();if(M){if(k>=M.postBundlePosition){let e=Error(`Unexpected bundle position`);throw e.incomplete=!0,e}k=M.postBundlePosition,M=null}if(k==Pe)j=null,O=null,N&&=null;else if(k>Pe){let e=Error(`Unexpected end of CBOR data`);throw e.incomplete=!0,e}else if(!Je)throw Error(`Data read, but end of buffer not reached`);return e}catch(e){throw Ct(),(e instanceof RangeError||e.message.startsWith(`Unexpected end of buffer`))&&(e.incomplete=!0),e}}function L(){let e=O[k++],t=e>>5;if(e&=31,e>23)switch(e){case 24:e=O[k++];break;case 25:if(t==7)return ct();e=I.getUint16(k),k+=2;break;case 26:if(t==7){let e=I.getFloat32(k);if(A.useFloat32>2){let t=wt[(O[k]&127)<<1|O[k+1]>>7];return k+=4,(t*e+(e>0?.5:-.5)>>0)/t}return k+=4,e}e=I.getUint32(k),k+=4;break;case 27:if(t==7){let e=I.getFloat64(k);return k+=8,e}if(t>1){if(I.getUint32(k)>0)throw Error(`JavaScript does not support arrays, maps, or strings with length over 4294967295`);e=I.getUint32(k+4)}else A.int64AsNumber?(e=I.getUint32(k)*4294967296,e+=I.getUint32(k+4)):e=I.getBigUint64(k);k+=8;break;case 31:switch(t){case 2:case 3:throw Error(`Indefinite length not supported for byte or text strings`);case 4:let e=[],n,r=0;for(;(n=L())!=Le;){if(r>=Re)throw Error(`Array length exceeds ${Re}`);e[r++]=n}return t==4?e:t==3?e.join(``):Buffer.concat(e);case 5:let i;if(A.mapsAsObjects){let e={},t=0;if(A.keyMap)for(;(i=L())!=Le;){if(t++>=ze)throw Error(`Property count exceeds ${ze}`);e[R(A.decodeKey(i))]=L()}else for(;(i=L())!=Le;){if(t++>=ze)throw Error(`Property count exceeds ${ze}`);e[R(i)]=L()}return e}else{Ke&&=(A.mapsAsObjects=!0,!1);let e=new Map;if(A.keyMap){let t=0;for(;(i=L())!=Le;){if(t++>=ze)throw Error(`Map size exceeds ${ze}`);e.set(A.decodeKey(i),L())}}else{let t=0;for(;(i=L())!=Le;){if(t++>=ze)throw Error(`Map size exceeds ${ze}`);e.set(i,L())}}return e}case 7:return Le;default:throw Error(`Invalid major type for indefinite length `+t)}default:throw Error(`Unknown token `+e)}switch(t){case 0:return e;case 1:return~e;case 2:return at(e);case 3:if(We>=k)return He.slice(k-Ue,(k+=e)-Ue);if(We==0&&Pe<140&&e<32){let t=e<16?it(e):rt(e);if(t!=null)return t}return et(e);case 4:if(e>=Re)throw Error(`Array length exceeds ${Re}`);let t=Array(e);for(let n=0;n<e;n++)t[n]=L();return t;case 5:if(e>=ze)throw Error(`Map size exceeds ${Re}`);if(A.mapsAsObjects){let t={};if(A.keyMap)for(let n=0;n<e;n++)t[R(A.decodeKey(L()))]=L();else for(let n=0;n<e;n++)t[R(L())]=L();return t}else{Ke&&=(A.mapsAsObjects=!0,!1);let t=new Map;if(A.keyMap)for(let n=0;n<e;n++)t.set(A.decodeKey(L()),L());else for(let n=0;n<e;n++)t.set(L(),L());return t}case 6:if(e>=Ie){let t=j[e&8191];if(t)return t.read||=$e(t),t.read();if(e<65536){if(e==57343){let e=bt(),t=L(),n=L();ut(t,n);let r={};if(A.keyMap)for(let t=2;t<e;t++){let e=A.decodeKey(n[t-2]);r[R(e)]=L()}else for(let t=2;t<e;t++){let e=n[t-2];r[R(e)]=L()}return r}else if(e==57342){let e=bt(),t=L();for(let n=2;n<e;n++)ut(t++,L());return L()}else if(e==Ie)return yt();if(A.getShared&&(xt(),t=j[e&8191],t))return t.read||=$e(t),t.read()}}let n=P[e];if(n)return n.handlesRead?n(L):n(L());{let t=L();for(let n=0;n<Ge.length;n++){let r=Ge[n](e,t);if(r!==void 0)return r}return new lt(t,e)}case 7:switch(e){case 20:return!1;case 21:return!0;case 22:return null;case 23:return;default:let t=(F||mt())[e];if(t!==void 0)return t;throw Error(`Unknown token `+e)}default:if(isNaN(e)){let e=Error(`Unexpected end of CBOR data`);throw e.incomplete=!0,e}throw Error(`Unknown CBOR token `+e)}}const Qe=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function $e(e){if(!e)throw Error(`Structure is required in record definition`);function t(){let e=O[k++];if(e&=31,e>23)switch(e){case 24:e=O[k++];break;case 25:e=I.getUint16(k),k+=2;break;case 26:e=I.getUint32(k),k+=4;break;default:throw Error(`Expected array header, but got `+O[k-1])}let t=this.compiledReader;for(;t;){if(t.propertyCount===e)return t(L);t=t.next}if(this.slowReads++>=Ye){let n=this.length==e?this:this.slice(0,e);return t=A.keyMap?Function(`r`,`return {`+n.map(e=>A.decodeKey(e)).map(e=>Qe.test(e)?R(e)+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`}`):Function(`r`,`return {`+n.map(e=>Qe.test(e)?R(e)+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`}`),this.compiledReader&&(t.next=this.compiledReader),t.propertyCount=e,this.compiledReader=t,t(L)}let n={};if(A.keyMap)for(let t=0;t<e;t++)n[R(A.decodeKey(this[t]))]=L();else for(let t=0;t<e;t++)n[R(this[t])]=L();return n}return e.slowReads=0,t}function R(e){if(typeof e==`string`)return e===`__proto__`?`__proto_`:e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return e.toString();if(e==null)return e+``;throw Error(`Invalid property name type `+typeof e)}let et=nt;function tt(e){et=t(1);function t(t){return function(t){let n=Be[Ve++];if(n==null){if(M)return nt(t);let r=e(k,Pe,t,O);if(typeof r==`string`)n=r,Be=Fe;else if(Be=r,Ve=1,We=1,n=Be[0],n===void 0)throw Error(`Unexpected end of buffer`)}let r=n.length;return r<=t?(k+=t,n):(He=n,Ue=k,We=k+r,k+=t,n.slice(0,t))}}}function nt(e){let t;if(e<16&&(t=it(e)))return t;if(e>64&&Ne)return Ne.decode(O.subarray(k,k+=e));let n=k+e,r=[];for(t=``;k<n;){let e=O[k++];if(!(e&128))r.push(e);else if((e&224)==192){let t=O[k++]&63;r.push((e&31)<<6|t)}else if((e&240)==224){let t=O[k++]&63,n=O[k++]&63;r.push((e&31)<<12|t<<6|n)}else if((e&248)==240){let t=O[k++]&63,n=O[k++]&63,i=O[k++]&63,a=(e&7)<<18|t<<12|n<<6|i;a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a)}else r.push(e);r.length>=4096&&(t+=z.apply(String,r),r.length=0)}return r.length>0&&(t+=z.apply(String,r)),t}let z=String.fromCharCode;function rt(e){let t=k,n=Array(e);for(let r=0;r<e;r++){let e=O[k++];if((e&128)>0){k=t;return}n[r]=e}return z.apply(String,n)}function it(e){if(e<4)if(e<2){if(e===0)return``;{let e=O[k++];if((e&128)>1){--k;return}return z(e)}}else{let t=O[k++],n=O[k++];if((t&128)>0||(n&128)>0){k-=2;return}if(e<3)return z(t,n);let r=O[k++];if((r&128)>0){k-=3;return}return z(t,n,r)}else{let t=O[k++],n=O[k++],r=O[k++],i=O[k++];if((t&128)>0||(n&128)>0||(r&128)>0||(i&128)>0){k-=4;return}if(e<6){if(e===4)return z(t,n,r,i);{let e=O[k++];if((e&128)>0){k-=5;return}return z(t,n,r,i,e)}}else if(e<8){let a=O[k++],o=O[k++];if((a&128)>0||(o&128)>0){k-=6;return}if(e<7)return z(t,n,r,i,a,o);let s=O[k++];if((s&128)>0){k-=7;return}return z(t,n,r,i,a,o,s)}else{let a=O[k++],o=O[k++],s=O[k++],c=O[k++];if((a&128)>0||(o&128)>0||(s&128)>0||(c&128)>0){k-=8;return}if(e<10){if(e===8)return z(t,n,r,i,a,o,s,c);{let e=O[k++];if((e&128)>0){k-=9;return}return z(t,n,r,i,a,o,s,c,e)}}else if(e<12){let l=O[k++],u=O[k++];if((l&128)>0||(u&128)>0){k-=10;return}if(e<11)return z(t,n,r,i,a,o,s,c,l,u);let d=O[k++];if((d&128)>0){k-=11;return}return z(t,n,r,i,a,o,s,c,l,u,d)}else{let l=O[k++],u=O[k++],d=O[k++],f=O[k++];if((l&128)>0||(u&128)>0||(d&128)>0||(f&128)>0){k-=12;return}if(e<14){if(e===12)return z(t,n,r,i,a,o,s,c,l,u,d,f);{let e=O[k++];if((e&128)>0){k-=13;return}return z(t,n,r,i,a,o,s,c,l,u,d,f,e)}}else{let p=O[k++],m=O[k++];if((p&128)>0||(m&128)>0){k-=14;return}if(e<15)return z(t,n,r,i,a,o,s,c,l,u,d,f,p,m);let h=O[k++];if((h&128)>0){k-=15;return}return z(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}}}}}function at(e){return A.copyBuffers?Uint8Array.prototype.slice.call(O,k,k+=e):O.subarray(k,k+=e)}let ot=new Float32Array(1),st=new Uint8Array(ot.buffer,0,4);function ct(){let e=O[k++],t=O[k++],n=(e&127)>>2;if(n===31)return t||e&3?NaN:e&128?-1/0:1/0;if(n===0){let n=((e&3)<<8|t)/(1<<24);return e&128?-n:n}return st[3]=e&128|(n>>1)+56,st[2]=(e&7)<<5|t>>3,st[1]=t<<5,st[0]=0,ot[0]}Array(4096);var lt=class{constructor(e,t){this.value=e,this.tag=t}};P[0]=e=>new Date(e),P[1]=e=>new Date(Math.round(e*1e3)),P[2]=e=>{let t=BigInt(0);for(let n=0,r=e.byteLength;n<r;n++)t=BigInt(e[n])+(t<<BigInt(8));return t},P[3]=e=>BigInt(-1)-P[2](e),P[4]=e=>+(e[1]+`e`+e[0]),P[5]=e=>e[1]*Math.exp(e[0]*Math.log(2));const ut=(e,t)=>{e-=57344;let n=j[e];n&&n.isShared&&((j.restoreStructures||=[])[e]=n),j[e]=t,t.read=$e(t)};P[105]=e=>{let t=e.length,n=e[1];ut(e[0],n);let r={};for(let i=2;i<t;i++){let t=n[i-2];r[R(t)]=e[i]}return r},P[14]=e=>M?M[0].slice(M.position0,M.position0+=e):new lt(e,14),P[15]=e=>M?M[1].slice(M.position1,M.position1+=e):new lt(e,15);let dt={Error,RegExp};P[27]=e=>(dt[e[0]]||Error)(e[1],e[2]);const ft=e=>{if(O[k++]!=132){let e=Error(`Packed values structure must be followed by a 4 element array`);throw O.length<k&&(e.incomplete=!0),e}let t=e();if(!t||!t.length){let e=Error(`Packed values structure must be followed by a 4 element array`);throw e.incomplete=!0,e}return F=F?t.concat(F.slice(t.length)):t,F.prefixes=e(),F.suffixes=e(),e()};ft.handlesRead=!0,P[51]=ft,P[6]=e=>{if(!F)if(A.getShared)xt();else return new lt(e,6);if(typeof e==`number`)return F[16+(e>=0?2*e:-2*e-1)];let t=Error(`No support for non-integer packed references yet`);throw e===void 0&&(t.incomplete=!0),t},P[28]=e=>{N||(N=new Map,N.id=0);let t=N.id++,n=k,r=O[k],i;i=r>>5==4?[]:{};let a={target:i};N.set(t,a);let o=e();return a.used?(Object.getPrototypeOf(i)!==Object.getPrototypeOf(o)&&(k=n,i=o,N.set(t,{target:i}),o=e()),Object.assign(i,o)):(a.target=o,o)},P[28].handlesRead=!0,P[29]=e=>{let t=N.get(e);return t.used=!0,t.target},P[258]=e=>new Set(e),(P[259]=e=>(A.mapsAsObjects&&(A.mapsAsObjects=!1,Ke=!0),e())).handlesRead=!0;function pt(e,t){return typeof e==`string`?e+t:e instanceof Array?e.concat(t):Object.assign({},e,t)}function mt(){if(!F)if(A.getShared)xt();else throw Error(`No packed values available`);return F}Ge.push((e,t)=>{if(e>=225&&e<=255)return pt(mt().prefixes[e-224],t);if(e>=28704&&e<=32767)return pt(mt().prefixes[e-28672],t);if(e>=1879052288&&e<=2147483647)return pt(mt().prefixes[e-1879048192],t);if(e>=216&&e<=223)return pt(t,mt().suffixes[e-216]);if(e>=27647&&e<=28671)return pt(t,mt().suffixes[e-27639]);if(e>=1811940352&&e<=1879048191)return pt(t,mt().suffixes[e-1811939328]);if(e==1399353956)return{packedValues:F,structures:j.slice(0),version:t};if(e==55799)return t});const ht=new Uint8Array(new Uint16Array([1]).buffer)[0]==1,gt=[Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,typeof BigUint64Array>`u`?{name:`BigUint64Array`}:BigUint64Array,Int8Array,Int16Array,Int32Array,typeof BigInt64Array>`u`?{name:`BigInt64Array`}:BigInt64Array,Float32Array,Float64Array],_t=[64,68,69,70,71,72,77,78,79,85,86];for(let e=0;e<gt.length;e++)vt(gt[e],_t[e]);function vt(e,t){let n=`get`+e.name.slice(0,-5),r;typeof e==`function`?r=e.BYTES_PER_ELEMENT:e=null;for(let i=0;i<2;i++){if(!i&&r==1)continue;let a=r==2?1:r==4?2:r==8?3:0;P[i?t:t-4]=r==1||i==ht?n=>{if(!e)throw Error(`Could not find typed array for code `+t);return!A.copyBuffers&&(r===1||r===2&&!(n.byteOffset&1)||r===4&&!(n.byteOffset&3)||r===8&&!(n.byteOffset&7))?new e(n.buffer,n.byteOffset,n.byteLength>>a):new e(Uint8Array.prototype.slice.call(n,0).buffer)}:r=>{if(!e)throw Error(`Could not find typed array for code `+t);let o=new DataView(r.buffer,r.byteOffset,r.byteLength),s=r.length>>a,c=new e(s),l=o[n];for(let e=0;e<s;e++)c[e]=l.call(o,e<<a,i);return c}}}function yt(){let e=bt(),t=k+L();for(let t=2;t<e;t++){let e=bt();k+=e}let n=k;return k=t,M=[nt(bt()),nt(bt())],M.position0=0,M.position1=0,M.postBundlePosition=k,k=n,L()}function bt(){let e=O[k++]&31;if(e>23)switch(e){case 24:e=O[k++];break;case 25:e=I.getUint16(k),k+=2;break;case 26:e=I.getUint32(k),k+=4;break}return e}function xt(){if(A.getShared){let e=St(()=>(O=null,A.getShared()))||{},t=e.structures||[];A.sharedVersion=e.version,F=A.sharedValues=e.packedValues,j===!0?A.structures=j=t:j.splice.apply(j,[0,t.length].concat(t))}}function St(e){let t=Pe,n=k,r=Ve,i=Ue,a=We,o=He,s=Be,c=N,l=M,u=new Uint8Array(O.slice(0,Pe)),d=j,f=A,p=Je,m=e();return Pe=t,k=n,Ve=r,Ue=i,We=a,He=o,Be=s,N=c,M=l,O=u,Je=p,j=d,A=f,I=new DataView(O.buffer,O.byteOffset,O.byteLength),m}function Ct(){O=null,N=null,j=null}const wt=Array(147);for(let e=0;e<256;e++)wt[e]=+(`1e`+Math.floor(45.15-e*.30103));let Tt=new Xe({useRecords:!1});const Et=Tt.decode;Tt.decodeMultiple;const Dt={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4};let Ot;try{Ot=new TextEncoder}catch{}let kt,At;const jt=typeof globalThis==`object`&&globalThis.Buffer,Mt=jt!==void 0,Nt=Mt?jt.allocUnsafeSlow:Uint8Array,Pt=Mt?jt:Uint8Array,Ft=Mt?4294967296:2144337920;let It,B,V,H=0,Lt,U=null;const Rt=/[\u0080-\uFFFF]/,W=Symbol(`record-id`);var zt=class extends Xe{constructor(e){super(e),this.offset=0;let t,n,r,i,a;e||={};let o=Pt.prototype.utf8Write?function(e,t,n){return B.utf8Write(e,t,n)}:Ot&&Ot.encodeInto?function(e,t){return Ot.encodeInto(e,B.subarray(t)).written}:!1,s=this,c=e.structures||e.saveStructures,l=e.maxSharedStructures;if(l??=c?128:0,l>8190)throw Error(`Maximum maxSharedStructure is 8190`);let u=e.sequential;u&&(l=0),this.structures||=[],this.saveStructures&&(this.saveShared=this.saveStructures);let d,f,p=e.sharedValues,m;if(p){m=Object.create(null);for(let e=0,t=p.length;e<t;e++)m[p[e]]=e}let h=[],g=0,_=0;this.mapEncode=function(e,t){if(this._keyMap&&!this._mapped)switch(e.constructor.name){case`Array`:e=e.map(e=>this.encodeKeys(e));break}return this.encode(e,t)},this.encode=function(o,c){if(B||(B=new Nt(8192),V=new DataView(B.buffer,0,8192),H=0),Lt=B.length-10,Lt-H<2048?(B=new Nt(B.length),V=new DataView(B.buffer,0,B.length),Lt=B.length-10,H=0):c===512&&(H=H+7&2147483640),t=H,s.useSelfDescribedHeader&&(V.setUint32(H,3654940416),H+=3),a=s.structuredClone?new Map:null,s.bundleStrings&&typeof o!=`string`?(U=[],U.size=1/0):U=null,n=s.structures,n){if(n.uninitialized){let e=s.getShared()||{};s.structures=n=e.structures||[],s.sharedVersion=e.version;let t=s.sharedValues=e.packedValues;if(t){m={};for(let e=0,n=t.length;e<n;e++)m[t[e]]=e}}let e=n.length;if(e>l&&!u&&(e=l),!n.transitions){n.transitions=Object.create(null);for(let t=0;t<e;t++){let e=n[t];if(!e)continue;let r,i=n.transitions;for(let n=0,a=e.length;n<a;n++){i[W]===void 0&&(i[W]=t);let a=e[n];r=i[a],r||=i[a]=Object.create(null),i=r}i[W]=t|1048576}}u||(n.nextId=e)}if(r&&=!1,i=n||[],f=m,e.pack){let t=new Map;if(t.values=[],t.encoder=s,t.maxValues=e.maxPrivatePackedValues||(m?16:1/0),t.objectMap=m||!1,t.samplingPackedValues=d,Gt(o,t),t.values.length>0){B[H++]=216,B[H++]=51,Ht(4);let e=t.values;v(e),Ht(0),Ht(0),f=Object.create(m||null);for(let t=0,n=e.length;t<n;t++)f[e[t]]=t}}It=c&rn;try{if(It)return;if(v(o),U&&Xt(t,v),s.offset=H,a&&a.idsToInsert){H+=a.idsToInsert.length*2,H>Lt&&b(H),s.offset=H;let e=Yt(B.subarray(t,H),a.idsToInsert);return a=null,e}return c&512?(B.start=t,B.end=H,B):B.subarray(t,H)}finally{if(n){if(_<10&&_++,n.length>l&&(n.length=l),g>1e4)n.transitions=null,_=0,g=0,h.length>0&&(h=[]);else if(h.length>0&&!u){for(let e=0,t=h.length;e<t;e++)h[e][W]=void 0;h=[]}}if(r&&s.saveShared){s.structures.length>l&&(s.structures=s.structures.slice(0,l));let e=B.subarray(t,H);return s.updateSharedData()===!1?s.encode(o):e}c&1024&&(H=t)}},this.findCommonStringsToPack=()=>(d=new Map,m||=Object.create(null),e=>{let t=e&&e.threshold||4,n=this.pack?e.maxPrivatePackedValues||16:0;p||=this.sharedValues=[];for(let[e,i]of d)i.count>t&&(m[e]=n++,p.push(e),r=!0);for(;this.saveShared&&this.updateSharedData()===!1;);d=null});let v=n=>{H>Lt&&(B=b(H));var r=typeof n,i;if(r===`string`){if(f){let t=f[n];if(t>=0){t<16?B[H++]=t+224:(B[H++]=198,t&1?v(15-t>>1):v(t-16>>1));return}else if(d&&!e.pack){let e=d.get(n);e?e.count++:d.set(n,{count:1})}}let r=n.length;if(U&&r>=4&&r<1024){if((U.size+=r)>61440){let e,n=(U[0]?U[0].length*3+U[1].length:0)+10;H+n>Lt&&(B=b(H+n)),B[H++]=217,B[H++]=223,B[H++]=249,B[H++]=U.position?132:130,B[H++]=26,e=H-t,H+=4,U.position&&Xt(t,v),U=[``,``],U.size=0,U.position=e}let e=Rt.test(n);U[+!e]+=n,B[H++]=e?206:207,v(r);return}let a;a=r<32?1:r<256?2:r<65536?3:5;let s=r*3;if(H+s>Lt&&(B=b(H+s)),r<64||!o){let e,t,o,s=H+a;for(e=0;e<r;e++)t=n.charCodeAt(e),t<128?B[s++]=t:t<2048?(B[s++]=t>>6|192,B[s++]=t&63|128):(t&64512)==55296&&((o=n.charCodeAt(e+1))&64512)==56320?(t=65536+((t&1023)<<10)+(o&1023),e++,B[s++]=t>>18|240,B[s++]=t>>12&63|128,B[s++]=t>>6&63|128,B[s++]=t&63|128):(B[s++]=t>>12|224,B[s++]=t>>6&63|128,B[s++]=t&63|128);i=s-H-a}else i=o(n,H+a,s);i<24?B[H++]=96|i:i<256?(a<2&&B.copyWithin(H+2,H+1,H+1+i),B[H++]=120,B[H++]=i):i<65536?(a<3&&B.copyWithin(H+3,H+2,H+2+i),B[H++]=121,B[H++]=i>>8,B[H++]=i&255):(a<5&&B.copyWithin(H+5,H+3,H+3+i),B[H++]=122,V.setUint32(H,i),H+=4),H+=i}else if(r===`number`)if(!this.alwaysUseFloat&&n>>>0===n)n<24?B[H++]=n:n<256?(B[H++]=24,B[H++]=n):n<65536?(B[H++]=25,B[H++]=n>>8,B[H++]=n&255):(B[H++]=26,V.setUint32(H,n),H+=4);else if(!this.alwaysUseFloat&&n>>0===n)n>=-24?B[H++]=31-n:n>=-256?(B[H++]=56,B[H++]=~n):n>=-65536?(B[H++]=57,V.setUint16(H,~n),H+=2):(B[H++]=58,V.setUint32(H,~n),H+=4);else{let e;if((e=this.useFloat32)>0&&n<4294967296&&n>=-2147483648){B[H++]=250,V.setFloat32(H,n);let t;if(e<4||(t=n*wt[(B[H]&127)<<1|B[H+1]>>7])>>0===t){H+=4;return}else H--}B[H++]=251,V.setFloat64(H,n),H+=8}else if(r===`object`)if(!n)B[H++]=246;else{if(a){let e=a.get(n);if(e){if(B[H++]=216,B[H++]=29,B[H++]=25,!e.references){let t=a.idsToInsert||=[];e.references=[],t.push(e)}e.references.push(H-t),H+=2;return}else a.set(n,{offset:H-t})}let e=n.constructor;if(e===Object)y(n);else if(e===Array){i=n.length,i<24?B[H++]=128|i:Ht(i);for(let e=0;e<i;e++)v(n[e])}else if(e===Map)if((this.mapsAsObjects?this.useTag259ForMaps!==!1:this.useTag259ForMaps)&&(B[H++]=217,B[H++]=1,B[H++]=3),i=n.size,i<24?B[H++]=160|i:i<256?(B[H++]=184,B[H++]=i):i<65536?(B[H++]=185,B[H++]=i>>8,B[H++]=i&255):(B[H++]=186,V.setUint32(H,i),H+=4),s.keyMap)for(let[e,t]of n)v(s.encodeKey(e)),v(t);else for(let[e,t]of n)v(e),v(t);else{for(let e=0,t=kt.length;e<t;e++){let t=At[e];if(n instanceof t){let t=kt[e],r=t.tag;r??=t.getTag&&t.getTag.call(this,n),r<24?B[H++]=192|r:r<256?(B[H++]=216,B[H++]=r):r<65536?(B[H++]=217,B[H++]=r>>8,B[H++]=r&255):r>-1&&(B[H++]=218,V.setUint32(H,r),H+=4),t.encode.call(this,n,v,b);return}}if(n[Symbol.iterator]){if(It){let e=Error(`Iterable should be serialized as iterator`);throw e.iteratorNotHandled=!0,e}B[H++]=159;for(let e of n)v(e);B[H++]=255;return}if(n[Symbol.asyncIterator]||Wt(n)){let e=Error(`Iterable/blob should be serialized as iterator`);throw e.iteratorNotHandled=!0,e}if(this.useToJSON&&n.toJSON){let e=n.toJSON();if(e!==n)return v(e)}y(n)}}else if(r===`boolean`)B[H++]=n?245:244;else if(r===`bigint`){if(n<BigInt(1)<<BigInt(64)&&n>=0)B[H++]=27,V.setBigUint64(H,n);else if(n>-(BigInt(1)<<BigInt(64))&&n<0)B[H++]=59,V.setBigUint64(H,-n-BigInt(1));else if(this.largeBigIntToFloat)B[H++]=251,V.setFloat64(H,Number(n));else{n>=BigInt(0)?B[H++]=194:(B[H++]=195,n=BigInt(-1)-n);let e=[];for(;n;)e.push(Number(n&BigInt(255))),n>>=BigInt(8);Jt(new Uint8Array(e.reverse()),b);return}H+=8}else if(r===`undefined`)B[H++]=247;else throw Error(`Unknown type: `+r)},y=this.useRecords===!1?this.variableMapSize?e=>{let t=Object.keys(e),n=Object.values(e),r=t.length;if(r<24?B[H++]=160|r:r<256?(B[H++]=184,B[H++]=r):r<65536?(B[H++]=185,B[H++]=r>>8,B[H++]=r&255):(B[H++]=186,V.setUint32(H,r),H+=4),s.keyMap)for(let e=0;e<r;e++)v(s.encodeKey(t[e])),v(n[e]);else for(let e=0;e<r;e++)v(t[e]),v(n[e])}:e=>{B[H++]=185;let n=H-t;H+=2;let r=0;if(s.keyMap)for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(v(s.encodeKey(t)),v(e[t]),r++);else for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(v(t),v(e[t]),r++);B[n+++t]=r>>8,B[n+t]=r&255}:(e,t)=>{let n,a=i.transitions||=Object.create(null),o=0,s=0,c,u;if(this.keyMap){u=Object.keys(e).map(e=>this.encodeKey(e)),s=u.length;for(let e=0;e<s;e++){let t=u[e];n=a[t],n||(n=a[t]=Object.create(null),o++),a=n}}else for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(n=a[t],n||(a[W]&1048576&&(c=a[W]&65535),n=a[t]=Object.create(null),o++),a=n,s++);let d=a[W];if(d!==void 0)d&=65535,B[H++]=217,B[H++]=d>>8|224,B[H++]=d&255;else if(u||=a.__keys__||=Object.keys(e),c===void 0?(d=i.nextId++,d||(d=0,i.nextId=1),d>=256&&(i.nextId=(d=l)+1)):d=c,i[d]=u,d<l){B[H++]=217,B[H++]=d>>8|224,B[H++]=d&255,a=i.transitions;for(let e=0;e<s;e++)(a[W]===void 0||a[W]&1048576)&&(a[W]=d),a=a[u[e]];a[W]=d|1048576,r=!0}else{if(a[W]=d,V.setUint32(H,3655335680),H+=3,o&&(g+=_*o),h.length>=256-l&&(h.shift()[W]=void 0),h.push(a),Ht(s+2),v(57344+d),v(u),t)return;for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&v(e[t]);return}if(s<24?B[H++]=128|s:Ht(s),!t)for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&v(e[t])},b=e=>{let n;if(e>16777216){if(e-t>Ft)throw Error(`Encoded buffer would be larger than maximum buffer size`);n=Math.min(Ft,Math.round(Math.max((e-t)*(e>67108864?1.25:2),4194304)/4096)*4096)}else n=(Math.max(e-t<<2,B.length-1)>>12)+1<<12;let r=new Nt(n);return V=new DataView(r.buffer,0,n),B.copy?B.copy(r,0,t,e):r.set(B.slice(t,e)),H-=t,t=0,Lt=r.length-10,B=r},x=100,S=1e3;this.encodeAsIterable=function(e,t){return E(e,t,C)},this.encodeAsAsyncIterable=function(e,t){return E(e,t,D)};function*C(e,n,r){let i=e.constructor;if(i===Object){let t=s.useRecords!==!1;t?y(e,!0):Bt(Object.keys(e).length,160);for(let r in e){let i=e[r];t||v(r),i&&typeof i==`object`?n[r]?yield*C(i,n[r]):yield*w(i,n,r):v(i)}}else if(i===Array){let r=e.length;Ht(r);for(let i=0;i<r;i++){let r=e[i];r&&(typeof r==`object`||H-t>x)?n.element?yield*C(r,n.element):yield*w(r,n,`element`):v(r)}}else if(e[Symbol.iterator]&&!e.buffer){B[H++]=159;for(let r of e)r&&(typeof r==`object`||H-t>x)?n.element?yield*C(r,n.element):yield*w(r,n,`element`):v(r);B[H++]=255}else Wt(e)?(Bt(e.size,64),yield B.subarray(t,H),yield e,T()):e[Symbol.asyncIterator]?(B[H++]=159,yield B.subarray(t,H),yield e,T(),B[H++]=255):v(e);r&&H>t?yield B.subarray(t,H):H-t>x&&(yield B.subarray(t,H),T())}function*w(e,n,r){let i=H-t;try{v(e),H-t>x&&(yield B.subarray(t,H),T())}catch(a){if(a.iteratorNotHandled)n[r]={},H=t+i,yield*C.call(this,e,n[r]);else throw a}}function T(){x=S,s.encode(null,rn)}function E(e,t,n){return x=t&&t.chunkThreshold?S=t.chunkThreshold:100,e&&typeof e==`object`?(s.encode(null,rn),n(e,s.iterateProperties||={},!0)):[s.encode(e)]}async function*D(e,t){for(let n of C(e,t,!0)){let e=n.constructor;if(e===Pt||e===Uint8Array)yield n;else if(Wt(n)){let e=n.stream().getReader(),t;for(;!(t=await e.read()).done;)yield t.value}else if(n[Symbol.asyncIterator])for await(let e of n)T(),e?yield*D(e,t.async||={}):yield s.encode(e);else yield n}}}useBuffer(e){B=e,V=new DataView(B.buffer,B.byteOffset,B.byteLength),H=0}clearSharedData(){this.structures&&=[],this.sharedValues&&=void 0}updateSharedData(){let e=this.sharedVersion||0;this.sharedVersion=e+1;let t=this.structures.slice(0),n=new Vt(t,this.sharedValues,this.sharedVersion),r=this.saveShared(n,t=>(t&&t.version||0)==e);return r===!1?(n=this.getShared()||{},this.structures=n.structures||[],this.sharedValues=n.packedValues,this.sharedVersion=n.version,this.structures.nextId=this.structures.length):t.forEach((e,t)=>this.structures[t]=e),r}};function Bt(e,t){e<24?B[H++]=t|e:e<256?(B[H++]=t|24,B[H++]=e):e<65536?(B[H++]=t|25,B[H++]=e>>8,B[H++]=e&255):(B[H++]=t|26,V.setUint32(H,e),H+=4)}var Vt=class{constructor(e,t,n){this.structures=e,this.packedValues=t,this.version=n}};function Ht(e){e<24?B[H++]=128|e:e<256?(B[H++]=152,B[H++]=e):e<65536?(B[H++]=153,B[H++]=e>>8,B[H++]=e&255):(B[H++]=154,V.setUint32(H,e),H+=4)}const Ut=typeof Blob>`u`?function(){}:Blob;function Wt(e){if(e instanceof Ut)return!0;let t=e[Symbol.toStringTag];return t===`Blob`||t===`File`}function Gt(e,t){switch(typeof e){case`string`:if(e.length>3){if(t.objectMap[e]>-1||t.values.length>=t.maxValues)return;let n=t.get(e);if(n)++n.count==2&&t.values.push(e);else if(t.set(e,{count:1}),t.samplingPackedValues){let n=t.samplingPackedValues.get(e);n?n.count++:t.samplingPackedValues.set(e,{count:1})}}break;case`object`:if(e)if(e instanceof Array)for(let n=0,r=e.length;n<r;n++)Gt(e[n],t);else{let r=!t.encoder.useRecords;for(var n in e)e.hasOwnProperty(n)&&(r&&Gt(n,t),Gt(e[n],t))}break;case`function`:console.log(e)}}const Kt=new Uint8Array(new Uint16Array([1]).buffer)[0]==1;At=[Date,Set,Error,RegExp,lt,ArrayBuffer,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,typeof BigUint64Array>`u`?function(){}:BigUint64Array,Int8Array,Int16Array,Int32Array,typeof BigInt64Array>`u`?function(){}:BigInt64Array,Float32Array,Float64Array,Vt],kt=[{tag:1,encode(e,t){let n=e.getTime()/1e3;(this.useTimestamp32||e.getMilliseconds()===0)&&n>=0&&n<4294967296?(B[H++]=26,V.setUint32(H,n),H+=4):(B[H++]=251,V.setFloat64(H,n),H+=8)}},{tag:258,encode(e,t){t(Array.from(e))}},{tag:27,encode(e,t){t([e.name,e.message])}},{tag:27,encode(e,t){t([`RegExp`,e.source,e.flags])}},{getTag(e){return e.tag},encode(e,t){t(e.value)}},{encode(e,t,n){Jt(e,n)}},{getTag(e){if(e.constructor===Uint8Array&&(this.tagUint8Array||Mt&&this.tagUint8Array!==!1))return 64},encode(e,t,n){Jt(e,n)}},qt(68,1),qt(69,2),qt(70,4),qt(71,8),qt(72,1),qt(77,2),qt(78,4),qt(79,8),qt(85,4),qt(86,8),{encode(e,t){let n=e.packedValues||[],r=e.structures||[];if(n.values.length>0){B[H++]=216,B[H++]=51,Ht(4);let e=n.values;t(e),Ht(0),Ht(0),packedObjectMap=Object.create(sharedPackedObjectMap||null);for(let t=0,n=e.length;t<n;t++)packedObjectMap[e[t]]=t}if(r){V.setUint32(H,3655335424),H+=3;let n=r.slice(0);n.unshift(57344),n.push(new lt(e.version,1399353956)),t(n)}else t(new lt(e.version,1399353956))}}];function qt(e,t){return!Kt&&t>1&&(e-=4),{tag:e,encode:function(e,t){let n=e.byteLength,r=e.byteOffset||0,i=e.buffer||e;t(Mt?jt.from(i,r,n):new Uint8Array(i,r,n))}}}function Jt(e,t){let n=e.byteLength;n<24?B[H++]=64+n:n<256?(B[H++]=88,B[H++]=n):n<65536?(B[H++]=89,B[H++]=n>>8,B[H++]=n&255):(B[H++]=90,V.setUint32(H,n),H+=4),H+n>=B.length&&t(H+n),B.set(e.buffer?e:new Uint8Array(e),H),H+=n}function Yt(e,t){let n,r=t.length*2,i=e.length-r;t.sort((e,t)=>e.offset>t.offset?1:-1);for(let n=0;n<t.length;n++){let r=t[n];r.id=n;for(let t of r.references)e[t++]=n>>8,e[t]=n&255}for(;n=t.pop();){let t=n.offset;e.copyWithin(t+r,t,i),r-=2;let a=t+r;e[a++]=216,e[a++]=28,i=t}return e}function Xt(e,t){V.setUint32(U.position+e,H-U.position-e+1);let n=U;U=null,t(n[0]),t(n[1])}let Zt=new zt({useRecords:!1});const Qt=Zt.encode;Zt.encodeAsIterable,Zt.encodeAsAsyncIterable;const{NEVER:$t,ALWAYS:en,DECIMAL_ROUND:tn,DECIMAL_FIT:nn}=Dt,rn=2048;var an=n(((e,t)=>{let n=()=>process.platform===`linux`,r=null;t.exports={isLinux:n,getReport:()=>{if(!r)if(n()&&process.report){let e=process.report.excludeNetwork;process.report.excludeNetwork=!0,r=process.report.getReport(),process.report.excludeNetwork=e}else r={};return r}}})),on=n(((e,n)=>{let r=t(`fs`),i=2048;n.exports={LDD_PATH:`/usr/bin/ldd`,SELF_PATH:`/proc/self/exe`,readFileSync:e=>{let t=r.openSync(e,`r`),n=Buffer.alloc(i),a=r.readSync(t,n,0,i,0);return r.close(t,()=>{}),n.subarray(0,a)},readFile:e=>new Promise((t,n)=>{r.open(e,`r`,(e,a)=>{if(e)n(e);else{let e=Buffer.alloc(i);r.read(a,e,0,i,0,(n,i)=>{t(e.subarray(0,i)),r.close(a,()=>{})})}})})}})),sn=n(((e,t)=>{t.exports={interpreterPath:e=>{if(e.length<64||e.readUInt32BE(0)!==2135247942||e.readUInt8(4)!==2||e.readUInt8(5)!==1)return null;let t=e.readUInt32LE(32),n=e.readUInt16LE(54),r=e.readUInt16LE(56);for(let i=0;i<r;i++){let r=t+i*n;if(e.readUInt32LE(r)===3){let t=e.readUInt32LE(r+8),n=e.readUInt32LE(r+32);return e.subarray(t,t+n).toString().replace(/\0.*$/g,``)}}return null}}})),cn=n(((e,n)=>{let r=t(`child_process`),{isLinux:i,getReport:a}=an(),{LDD_PATH:o,SELF_PATH:s,readFile:c,readFileSync:l}=on(),{interpreterPath:u}=sn(),d,f,p,m=`getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true`,h=``,g=()=>h||new Promise(e=>{r.exec(m,(t,n)=>{h=t?` `:n,e(h)})}),_=()=>{if(!h)try{h=r.execSync(m,{encoding:`utf8`})}catch{h=` `}return h},v=`glibc`,y=/LIBC[a-z0-9 \-).]*?(\d+\.\d+)/i,b=`musl`,x=e=>e.includes(`libc.musl-`)||e.includes(`ld-musl-`),S=()=>{let e=a();return e.header&&e.header.glibcVersionRuntime?v:Array.isArray(e.sharedObjects)&&e.sharedObjects.some(x)?b:null},C=e=>{let[t,n]=e.split(/[\r\n]+/);return t&&t.includes(v)?v:n&&n.includes(b)?b:null},w=e=>{if(e){if(e.includes(`/ld-musl-`))return b;if(e.includes(`/ld-linux-`))return v}return null},T=e=>(e=e.toString(),e.includes(`musl`)?b:e.includes(`GNU C Library`)?v:null),E=async()=>{if(f!==void 0)return f;f=null;try{f=T(await c(o))}catch{}return f},D=()=>{if(f!==void 0)return f;f=null;try{f=T(l(o))}catch{}return f},ee=async()=>{if(d!==void 0)return d;d=null;try{d=w(u(await c(s)))}catch{}return d},te=()=>{if(d!==void 0)return d;d=null;try{d=w(u(l(s)))}catch{}return d},ne=async()=>{let e=null;return i()&&(e=await ee(),e||(e=await E(),e||=S(),e||=C(await g()))),e},re=()=>{let e=null;return i()&&(e=te(),e||(e=D(),e||=S(),e||=C(_()))),e},ie=async()=>i()&&await ne()!==v,ae=()=>i()&&re()!==v,oe=async()=>{if(p!==void 0)return p;p=null;try{let e=(await c(o)).match(y);e&&(p=e[1])}catch{}return p},se=()=>{if(p!==void 0)return p;p=null;try{let e=l(o).match(y);e&&(p=e[1])}catch{}return p},ce=()=>{let e=a();return e.header&&e.header.glibcVersionRuntime?e.header.glibcVersionRuntime:null},le=e=>e.trim().split(/\s+/)[1],ue=e=>{let[t,n,r]=e.split(/[\r\n]+/);return t&&t.includes(v)?le(t):n&&r&&n.includes(b)?le(r):null};n.exports={GLIBC:v,MUSL:b,family:ne,familySync:re,isNonGlibcLinux:ie,isNonGlibcLinuxSync:ae,version:async()=>{let e=null;return i()&&(e=await oe(),e||=ce(),e||=ue(await g())),e},versionSync:()=>{let e=null;return i()&&(e=se(),e||=ce(),e||=ue(_())),e}}})),ln=n(((e,n)=>{var r=t(`fs`),i=t(`path`),a=t(`url`),o=process.config&&process.config.variables||{},s=!!process.env.PREBUILDS_ONLY,c=process.versions,l=c.modules;(c.deno||process.isBun)&&(l=`unsupported`);var u=D()?`electron`:`node`,d=process.arch,f=process.platform,p=process.env.LIBC||(ee(f)?`musl`:`glibc`),m=process.env.ARM_VERSION||(d===`arm64`?`8`:o.arm_version)||``,h=(c.uv||``).split(`.`)[0];n.exports=g;function g(e){return typeof __webpack_require__==`function`?__non_webpack_require__(g.path(e)):t(g.path(e))}g.path=function(e){e=i.resolve(e||`.`);var n=``;try{n=typeof __webpack_require__==`function`?__non_webpack_require__(i.join(e,`package.json`)).name:t(i.join(e,`package.json`)).name;var r=n.toUpperCase().replace(/-/g,`_`)+`_PREBUILD`;process.env[r]&&(e=process.env[r])}catch{}if(!s){var o=v(i.join(e,`build/Release`),y);if(o)return o;var c=v(i.join(e,`build/Debug`),y);if(c)return c}var g=te(e);if(g)return g;var T=te(i.dirname(process.execPath));if(T)return T;var D=(n[0]==`@`?``:`@`+n+`/`)+n+`-`+f+`-`+d;try{return ne(i.dirname(t(`module`).createRequire(a.pathToFileURL(i.join(e,`package.json`))).resolve(D)))}catch{}var ee=[`platform=`+f,`arch=`+d,`runtime=`+u,`abi=`+l,`uv=`+h,m?`armv=`+m:``,`libc=`+p,`node=`+process.versions.node,process.versions.electron?`electron=`+process.versions.electron:``,typeof __webpack_require__==`function`?`webpack=true`:``].filter(Boolean).join(` `);throw Error(`No native build was found for `+ee+`
|
|
3
|
-
attempted loading from: `+e+` and package: `+
|
|
4
|
-
`);function te(e){var t=_(i.join(e,`prebuilds`)).map(b).filter(x(f,d)).sort(S)[0];if(t)return ne(i.join(e,`prebuilds`,t.name))}function ne(e){var t=_(e).map(C).filter(w(u,l)).sort(E(u))[0];if(t)return i.join(e,t.file)}};function _(e){try{return r.readdirSync(e)}catch{return[]}}function v(e,t){var n=_(e).filter(t);return n[0]&&i.join(e,n[0])}function y(e){return/\.node$/.test(e)}function b(e){var t=e.split(`-`);if(t.length===2){var n=t[0],r=t[1].split(`+`);if(n&&r.length&&r.every(Boolean))return{name:e,platform:n,architectures:r}}}function x(e,t){return function(n){return n==null||n.platform!==e?!1:n.architectures.includes(t)}}function S(e,t){return e.architectures.length-t.architectures.length}function C(e){var t=e.split(`.`),n=t.pop(),r={file:e,specificity:0};if(n===`node`){for(var i=0;i<t.length;i++){var a=t[i];if(a===`node`||a===`electron`||a===`node-webkit`)r.runtime=a;else if(a===`napi`)r.napi=!0;else if(a.slice(0,3)===`abi`)r.abi=a.slice(3);else if(a.slice(0,2)===`uv`)r.uv=a.slice(2);else if(a.slice(0,4)===`armv`)r.armv=a.slice(4);else if(a===`glibc`||a===`musl`)r.libc=a;else continue;r.specificity++}return r}}function w(e,t){return function(n){return!(n==null||n.runtime!==e&&!T(n)||n.abi!==t&&!n.napi||n.uv&&n.uv!==h||n.armv&&n.armv!==m||n.libc&&n.libc!==p)}}function T(e){return e.runtime===`node`&&e.napi}function E(e){return function(t,n){return t.runtime===n.runtime?t.abi===n.abi?t.specificity===n.specificity?0:t.specificity>n.specificity?-1:1:t.abi?-1:1:t.runtime===e?-1:1}}function D(){return process.versions&&process.versions.electron||process.env.ELECTRON_RUN_AS_NODE?!0:typeof window<`u`&&window.process&&window.process.type===`renderer`}function ee(e){if(e!==`linux`)return!1;let{familySync:t,MUSL:n}=cn();return t()===n}g.parseTags=C,g.matchTags=w,g.compareTags=E,g.parseTuple=b,g.matchTuple=x,g.compareTuples=S})),un=n(((e,t)=>{t.exports=ln()(__dirname)}));if(!(process.env.CBOR_NATIVE_ACCELERATION_DISABLED!==void 0&&process.env.CBOR_NATIVE_ACCELERATION_DISABLED.toLowerCase()===`true`)){let e;try{e=typeof t==`function`?un():Se(import.meta.url)(`cbor-extract`),e&&tt(e.extractStrings)}catch{}}var dn=he();let fn,pn,mn;const hn={connections:8,keepAliveTimeout:1e4,pipelining:1},gn={...hn,allowH2:!1},_n={...hn,allowH2:!0},vn={retryAfter:!0,statusCodes:[500,502,503,504]},yn={retryAfter:!0,methods:[`PUT`],statusCodes:[429]};function bn(e){return e?.dispatcher??wn()}function xn(e){return e?.dispatcher??Tn()}function Sn(e){return e?.dispatcher??En()}function Cn(e,t){return new dn.RetryAgent(new dn.Agent(e),t)}function wn(){return fn??=Cn(gn,vn),fn}function Tn(){return pn??=Cn(_n,vn),pn}function En(){return mn??=Cn(_n,yn),mn}let Dn=null;async function On(){return Dn||=import(`../../_chunks/workflow/src-CQuMexnO.js`).then(t=>e(t.t(),1)).catch(e=>(typeof process<`u`&&typeof process.env.DEBUG==`string`&&(process.env.DEBUG.includes(`workflow:`)||process.env.DEBUG===`*`)&&console.warn(`[workflow] @opentelemetry/api unavailable — world-vercel spans disabled:`,e instanceof Error?e.message:e),null)),Dn}let kn=null;function An(){return typeof process<`u`&&typeof process.env.DEBUG==`string`&&(process.env.DEBUG.includes(`workflow:`)||process.env.DEBUG===`*`)}let jn=!1;function Mn(e,t){if(!(jn||!An())){jn=!0;try{let n=globalThis[Symbol.for(`opentelemetry.js.api.1`)],r=e.trace.getTracerProvider(),i=r.getDelegate?.()??r,a=t.startSpan(`workflow.otel.probe.world_vercel`);console.warn(`[workflow:otel-diag] world-vercel`,JSON.stringify({globalRegistrationVersion:n?.version??null,providerCtor:r?.constructor?.name??null,delegateCtor:i?.constructor?.name??null,tracerCtor:t?.constructor?.name??null,probeCtor:a?.constructor?.name??null,probeRecording:a.isRecording()})),a.end()}catch(e){console.warn(`[workflow:otel-diag] world-vercel failed:`,e instanceof Error?e.message:e)}}}async function Nn(){return kn||=On().then(e=>{if(!e)return null;let t=e.trace.getTracer(`workflow`);return Mn(e,t),t}),kn}async function Pn(e,...t){let[n,r]=await Promise.all([Nn(),On()]),{fn:i,opts:a}=typeof t[0]==`function`?{fn:t[0],opts:{}}:{fn:t[1],opts:t[0]};if(!i)throw Error(`Function to trace must be provided`);return!n||!r?await i():n.startActiveSpan(e,a,async e=>{try{let t=await i(e);return e.setStatus({code:r.SpanStatusCode.OK}),t}catch(t){throw e.setStatus({code:r.SpanStatusCode.ERROR,message:t.message}),t}finally{e.end()}})}async function Fn(e){let t=await On();if(t)return t.SpanKind[e]}async function In(e){let t=await On();if(!t)return;let n={};t.propagation.inject(t.context.active(),n);for(let[t,r]of Object.entries(n))e.set(t,r)}function G(...e){return t=>Object.fromEntries(e.map(e=>[e,t]))}const Ln=G(`http.request.method`),Rn=G(`url.full`),zn=G(`server.address`),Bn=G(`server.port`),Vn=G(`http.response.status_code`),Hn=G(`error.type`),Un=G(`workflow.world.parse.format`),Wn=G(`peer.service`),Gn=G(`rpc.system`),Kn=G(`rpc.service`),qn=G(`rpc.method`),Jn=G(`workflow.run.id`),Yn=G(`step.id`),Xn=G(`workflow.stream.name`),Zn=G(`workflow.stream.operation`),Qn=G(`workflow.stream.start_index`),$n=()=>ee(`WORKFLOW_REQUEST_TIMEOUT_MS`,6e4,{integer:!0,min:1}),er=typeof process<`u`&&typeof process.env.DEBUG==`string`&&(process.env.DEBUG.includes(`workflow:`)||process.env.DEBUG===`*`),tr=[`x-vercel-id`,`x-vercel-error`,`x-vercel-mitigated`];function nr(e){return tr.flatMap(t=>{let n=e.get(t);return n?[`${t}=${n}`]:[]})}function rr(e){let t=nr(e);return t.length>0?` (${t.join(`; `)})`:``}function ir(e,t,n,r){if(!er)return;let i=nr(n.headers),a=i.length>0?`; ${i.join(`; `)}`:``;console.debug(`[workflow:world-vercel:http] ${e} ${t} -> ${n.status} (${r}ms${a})`)}function ar(e,t,n){if(!process.env.DEBUG)return;let r=Array.from(n.entries()).filter(([e])=>e.toLowerCase()!==`authorization`).map(([e,t])=>`-H "${e}: ${t}"`).join(` `);console.error(`Failed to fetch, reproduce with:\ncurl -X ${e} ${r} "${t}"`)}function or(e){if(!e)return;let t=parseInt(e,10);return Number.isNaN(t)?void 0:t}function sr(e,t,n={}){let{retryAfter:r,code:c,url:u,mitigated:d}=n;return e===409?new l(t):e===410?new o(t):e===425?new a(t,{retryAfter:r}):e===429?cr(e,d)?new i(`${t} (x-vercel-mitigated=challenge)`,{url:u,status:e,code:`TRANSPORT`,retryAfter:r}):new s(t,{retryAfter:r}):new i(t,{url:u,status:e,code:c,retryAfter:r})}function cr(e,t){return e===429&&t===`challenge`}async function lr(e){return e?.token??process.env.VERCEL_TOKEN??await(0,Me.getVercelOidcToken)().catch(()=>null)}function ur(e){try{let t=new URL(e);return{serverAddress:t.hostname,serverPort:t.port?parseInt(t.port,10):t.protocol===`https:`?443:80}}catch{return{}}}function dr(e){let{method:t,url:n,peerService:r}=e,{serverAddress:i,serverPort:a}=ur(n);return{...Ln(t),...Rn(n),...i?zn(i):{},...a?Bn(a):{},...Wn(r),...Gn(`http`),...Kn(r)}}async function fr(e){let{method:t,url:n,headers:r,body:a,dispatcher:o,peerService:s=`workflow-server`,timeoutMs:c=$n(),signal:l,injectTraceContext:u=!0,cacheBust:d=!0,logLabel:f,buildError:p,spanName:m,attributes:h,durationAttribute:g}=e,_=f??n;return Pn(m??`http ${t}`,{kind:await Fn(`CLIENT`)},async e=>{if(m&&er&&e){let t=e.spanContext();console.warn(`[workflow:otel-diag] span-open`,JSON.stringify({spanName:m,traceId:t.traceId,spanId:t.spanId,recording:e.isRecording()}))}e?.setAttributes(dr({method:t,url:n,peerService:s})),h&&e?.setAttributes(h),u&&await In(r),d&&r.set(`X-Request-Time`,Date.now().toString());let f=c==null?void 0:AbortSignal.timeout(c),v=l&&f?AbortSignal.any([l,f]):l??f,y=Date.now(),b;try{b=await fetch(n,{method:t,headers:r,body:a,signal:v,dispatcher:o})}catch(r){let a=Date.now()-y;if(r instanceof Error&&(r.name===`TimeoutError`||r.name===`AbortError`)){let o=new i(`${t} ${_} timed out after ${a}ms`,{url:n,cause:r});throw e?.setAttributes({...Hn(`TIMEOUT`)}),e?.recordException?.(o),o}throw r}let x=Date.now()-y;if(ir(t,_,b,x),e?.setAttributes({...Vn(b.status)}),g&&e?.setAttributes({[g]:x}),!b.ok){if(e?.setAttributes({...Hn(`HTTP ${b.status}`)}),ar(t,n,r),p){let t=await p(b);throw e?.recordException?.(t),t}let i=await b.text().catch(()=>``),a=sr(b.status,`${t} ${_} -> HTTP ${b.status}: ${b.statusText}${i?` ${i}`:``}${rr(b.headers)}`,{url:n,retryAfter:or(b.headers.get(`Retry-After`))});throw e?.recordException?.(a),a}return b})}const pr=`5.0.0-beta.30`,mr=new Set([`GET`,`HEAD`]),hr=new Set([`UND_ERR_REQ_RETRY`,`UND_ERR_SOCKET`,`UND_ERR_CONNECT`,`UND_ERR_CONNECT_TIMEOUT`,`UND_ERR_HEADERS_TIMEOUT`,`UND_ERR_BODY_TIMEOUT`,`UND_ERR_CLOSED`,`ECONNRESET`,`ECONNREFUSED`,`ENOTFOUND`,`EAI_AGAIN`,`EPIPE`]);function gr(e){let t=e;for(let e=0;t!=null&&e<5;e++){if(typeof t==`object`&&`code`in t){let e=t.code;if(typeof e==`string`&&hr.has(e))return e}t=t?.cause}}const _r=()=>process.env.VERCEL_WORKFLOW_SERVER_URL||``,vr=()=>process.env.WORKFLOW_TEST_LIMIT_OVERRIDES?.trim()||``;function yr(e){return e}const br=()=>{let e=process.env.VERCEL_DEPLOYMENT_ID;return e?`@workflow/world-vercel/${pr} node-${process.version} ${ye.platform()} (${ye.arch()}) ${e}`:`@workflow/world-vercel/${pr} node-${process.version} ${ye.platform()} (${ye.arch()})`},xr=e=>{let t=e?.projectConfig,n=_r()||`https://vercel-workflow.com`,r=process.env.WORKFLOW_VERCEL_BACKEND_URL,i=!!(t?.projectId&&t?.teamId);return{baseUrl:i?r||`https://api.vercel.com/v1/workflow`:`${n}/api`,usingProxy:i}},Sr=(e,t)=>{let n=e?.projectConfig,r=new Headers(e?.headers);r.set(`User-Agent`,br());let i=vr();i&&r.set(`x-workflow-test-limit-overrides`,i),n&&(r.set(`x-vercel-environment`,n.environment||`production`),n.projectId&&r.set(`x-vercel-project-id`,n.projectId),n.teamId&&r.set(`x-vercel-team-id`,n.teamId));let a=_r();return a&&t.usingProxy&&r.set(`x-vercel-workflow-api-url`,a),r};async function Cr(e){let{baseUrl:t,usingProxy:n}=xr(e),r=Sr(e,{usingProxy:n});if(n){if(!e?.token)throw Error(`world-vercel: api-workflow proxy requested (${t}) but no Vercel auth token was provided. Pass one as \`config.token\` (the SDK reads it from \`WORKFLOW_VERCEL_AUTH_TOKEN\`).`);r.set(`Authorization`,`Bearer ${e.token}`)}else{let t;try{t=await(0,Me.getVercelOidcToken)()}catch{}let n=e?.token??t;n&&r.set(`Authorization`,`Bearer ${n}`),t&&r.set(`x-vercel-trusted-oidc-idp-token`,t)}return{baseUrl:t,headers:r,usingProxy:n}}async function K({endpoint:e,options:t={},config:n={},schema:r,data:a,onResponse:o}){let s=t.method||`GET`,{baseUrl:c,headers:l}=await Cr(n),u=`${c}${e}`;return Pn(`http ${s}`,{kind:await Fn(`CLIENT`)},async c=>{c?.setAttributes(dr({method:s,url:u,peerService:`workflow-server`})),l.set(`Accept`,`application/cbor`),await In(l);let d;a!==void 0&&(l.set(`Content-Type`,`application/cbor`),d=Qt(a));let f=mr.has(s.toUpperCase()),p,m=``;for(let r=0;;r++){l.set(`X-Request-Time`,Date.now().toString());let a=AbortSignal.timeout($n()),h=t.signal?AbortSignal.any([t.signal,a]):a,g=new Request(u,{...t,body:d,headers:l,signal:h}),_=Date.now(),v;try{v=await fetch(g,{dispatcher:bn(n)})}catch(t){let n=Date.now()-_;if(t instanceof Error&&(t.name===`TimeoutError`||t.name===`AbortError`)){let r=new i(`${s} ${e} timed out after ${n}ms`,{url:u,code:`TIMEOUT`,cause:t});throw c?.setAttributes({...Hn(`TIMEOUT`)}),c?.recordException?.(r),r}let r=gr(t);if(r){let a=new i(`${s} ${e} transport failure after ${n}ms (${r})`,{url:u,code:`TRANSPORT`,cause:t});throw c?.setAttributes({...Hn(`TRANSPORT`)}),c?.recordException?.(a),a}throw t}let y=Date.now()-_;if(m=rr(v.headers),ir(s,e,v,y),c?.setAttributes({...Vn(v.status)}),!v.ok){let t=await Tr(v).then(e=>e.data).catch(()=>({})),n=t.code??t.error;ar(g.method,u,l);let r=or(v.headers.get(`Retry-After`)),i=(t.message||`${g.method} ${e} -> HTTP ${v.status}: ${v.statusText}`)+m,a=sr(v.status,i,{url:u,code:n,retryAfter:r,mitigated:v.headers.get(`x-vercel-mitigated`)});throw c?.setAttributes({...Hn(n||`HTTP ${v.status}`)}),c?.recordException?.(a),a}o?.(v);try{p=await Pn(`world.parse`,async e=>{let t=await Tr(v),n=(v.headers.get(`Content-Type`)||``).includes(`application/cbor`);return e?.setAttributes({...Un(n?`cbor`:`json`)}),t});break}catch(t){if(f&&r<2){let n=100*2**r;c?.setAttributes({...Hn(`PARSE_ERROR_RETRYING`)}),er&&console.debug(`[workflow:world-vercel:http] ${s} ${e} body parse failed (attempt ${r+1}/3); retrying in ${n}ms: ${t}`),await new Promise(e=>setTimeout(e,n));continue}let n=v.headers.get(`Content-Type`)||`unknown`;throw new i(`Failed to parse response body for ${s} ${e}${m} (Content-Type: ${n}):\n\n${t}`,{url:u,code:`PARSE_ERROR`,cause:t})}}return await Pn(`world.validate`,async()=>{let t=r.safeParse(p.data);if(!t.success){let n=t.error.issues.map(e=>` ${e.path.length>0?e.path.join(`.`):`<root>`}: ${e.message}`).join(`
|
|
5
|
-
`),r=process.env.DEBUG?`\n\nResponse context: ${p.getDebugContext()}`:``;throw new i(`Schema validation failed for ${s} ${e}${m}:\n${n}${r}`,{url:u,code:`SCHEMA_VALIDATION`,cause:t.error})}return t.data})})}function wr(e){let t=_e(e,{depth:3,maxArrayLength:10,breakLength:120});return t.length>500?`${t.slice(0,500)}...`:t}async function Tr(e){let t=e.headers.get(`Content-Type`)||``;if(t.includes(`application/cbor`)){let n=await e.arrayBuffer(),r=Et(new Uint8Array(n));return{data:r,getDebugContext:()=>`Content-Type: ${t}, ${n.byteLength} bytes (CBOR), preview: ${wr(r)}`}}let n=await e.text(),r=JSON.parse(n);return{data:r,getDebugContext:()=>`Content-Type: ${t}, ${n.length} bytes, preview: ${wr(r)}`}}function Er(e,t){t?.limit&&e.set(`limit`,t.limit.toString()),t?.cursor&&e.set(`cursor`,t.cursor),t?.sortOrder&&e.set(`sortOrder`,t.sortOrder)}function Dr(e){let t=e.toString();return t?`?${t}`:``}function Or(e,t){t.workflowName&&e.set(`workflowName`,t.workflowName),t.startTime&&t.endTime&&(e.set(`startTime`,t.startTime),e.set(`endTime`,t.endTime)),Er(e,t.pagination)}function kr(e){return{runs:{get(t){return K({endpoint:`/v2/analytics/runs/${encodeURIComponent(t)}`,config:e,schema:fe})},list(t={}){let n=new URLSearchParams;return t.workflowName&&n.set(`workflowName`,t.workflowName),t.status&&n.set(`status`,t.status),t.startTime&&t.endTime&&(n.set(`startTime`,t.startTime),n.set(`endTime`,t.endTime)),t.attributes&&Object.keys(t.attributes).length>0&&n.set(`attributes`,JSON.stringify(t.attributes)),Er(n,t.pagination),K({endpoint:`/v2/analytics/runs${Dr(n)}`,config:e,schema:ie(fe)})}},attributes:{list(t={}){let n=new URLSearchParams;return Or(n,t),K({endpoint:`/v2/analytics/attributes${Dr(n)}`,config:e,schema:ie(pe)})}},steps:{get(t,n){return K({endpoint:`/v2/analytics/runs/${encodeURIComponent(t)}/steps/${encodeURIComponent(n)}`,config:e,schema:C})},list(t){let n=new URLSearchParams;return Er(n,t.pagination),K({endpoint:`/v2/analytics/runs/${encodeURIComponent(t.runId)}/steps${Dr(n)}`,config:e,schema:ie(C)})}},events:{get(t,n){return K({endpoint:`/v2/analytics/runs/${encodeURIComponent(t)}/events/${encodeURIComponent(n)}`,config:e,schema:S})},list(t){let n=new URLSearchParams;return t.eventType&&n.set(`eventType`,t.eventType),t.correlationId&&n.set(`correlationId`,t.correlationId),Er(n,t.pagination),K({endpoint:`/v2/analytics/runs/${encodeURIComponent(t.runId)}/events${Dr(n)}`,config:e,schema:ie(S)})},listByCorrelationId(t){let n=new URLSearchParams;return n.set(`correlationId`,t.correlationId),Er(n,t.pagination),K({endpoint:`/v2/analytics/events${Dr(n)}`,config:e,schema:ie(S)})}},hooks:{get(t,n){let r=new URLSearchParams;return n?.runId&&r.set(`runId`,n.runId),K({endpoint:`/v2/analytics/hooks/${encodeURIComponent(t)}${Dr(r)}`,config:e,schema:f})},list(t){let n=new URLSearchParams;return n.set(`runId`,t.runId),Er(n,t.pagination),K({endpoint:`/v2/analytics/hooks${Dr(n)}`,config:e,schema:ie(f)})}},waits:{get(t,n){return K({endpoint:`/v2/analytics/runs/${encodeURIComponent(t)}/waits/${encodeURIComponent(n)}`,config:e,schema:p})},list(t){let n=new URLSearchParams;return t.status&&n.set(`status`,t.status),Er(n,t.pagination),K({endpoint:`/v2/analytics/runs/${encodeURIComponent(t.runId)}/waits${Dr(n)}`,config:e,schema:ie(p)})}}}}const Ar=`0123456789ABCDEFGHJKMNPQRSTVWXYZ`,jr=(()=>{let e=new Int8Array(128).fill(-1);for(let t=0;t<32;t++)e[Ar.charCodeAt(t)]=t;for(let t=0;t<32;t++){let n=Ar[t].toLowerCase();n!==Ar[t]&&(e[n.charCodeAt(0)]=t)}return e})();function Mr(e){if(typeof e!=`string`)throw TypeError(`Expected ULID string, got ${typeof e}`);if(e.length!==26)throw Error(`Invalid ULID length: expected 26, got ${e.length}`);let t=new Uint8Array(26);for(let n=0;n<26;n++){let r=e.charCodeAt(n),i=r<128?jr[r]:-1;if(i<0)throw Error(`Invalid Crockford-Base32 character at index ${n}: ${JSON.stringify(e[n])}`);t[n]=i}if(t[0]&24)throw Error(`Invalid ULID: top 2 bits must be zero (first char > '7'): ${JSON.stringify(e[0])}`);let n=new Uint8Array(16),r=t[0]&7,i=3,a=0;for(let e=1;e<26;e++)for(r=r<<5|t[e],i+=5;i>=8;)i-=8,n[a++]=r>>i&255;if(a!==16||i!==0)throw Error(`Internal error: ULID bit packing did not consume cleanly`);return n}function Nr(e){if(e.length!==16)throw Error(`Invalid byte length: expected 16, got ${e.length}`);let t=0,n=0;t=0,n=2;let r=``;for(let i=0;i<16;i++)for(t=t<<8|e[i],n+=8;n>=5;)n-=5,r+=Ar[t>>n&31];if(r.length!==26||n!==0)throw Error(`Internal error: ULID bit packing did not flush cleanly`);return r}const Pr={unknown:0,iad1:1,sfo1:2,pdx1:3,cle1:4,yul1:5,gru1:6,dub1:7,lhr1:8,cdg1:9,fra1:10,bru1:11,arn1:12,hel1:13,zrh1:14,cpt1:15,dxb1:16,bom1:17,sin1:18,hkg1:19,hnd1:20,icn1:21,kix1:22,syd1:23},Fr=new Map(Object.entries(Pr).filter(e=>e[0]!==`unknown`).map(([e,t])=>[t,e]));function Ir(e){return Fr.get(e)??null}function Lr(e){return e!==void 0&&e!==`unknown`&&Object.hasOwn(Pr,e)}function Rr(e){return typeof e==`string`&&e!==`unknown`&&Object.hasOwn(Pr,e)}function zr(e,t,n={}){let r;if(typeof t==`number`){if(!Number.isInteger(t)||t<0||t>63)throw RangeError(`regionId must be an integer in [0, 63]; got ${t}`);r=t}else if(Rr(t))r=Pr[t];else throw Error(`Unknown region: ${String(t)}`);let i=n.version??1;if(!Number.isInteger(i)||i<0||i>31)throw RangeError(`version must be an integer in [0, 31]; got ${i}`);let a=Mr(e);a[0]|=128;let o=(r&63)<<2,s=i>>3&3,c=(i&7)<<5;return a[6]=a[6]&-256|o|s,a[7]=a[7]&-225|c,Nr(a)}function Br(e){let t=Mr(e),n=(t[0]&128)!=0;t[0]&=-129;let r=Nr(t);if(!n)return{tagged:!1,ulid:r,version:null,regionId:null,region:null};let i=(t[6]&252)>>2;return{tagged:!0,ulid:r,version:(t[6]&3)<<3|(t[7]&224)>>5,regionId:i,region:Ir(i)}}const Vr=se();let Hr;function Ur(e){let t=Mr(e),n=5,r=1;for(;n>=0&&r>0;){let e=t[n]+r;t[n]=e&255,r=e>>8,n--}if(r>0)throw Error(`ULID space exhausted`);return Nr(t)}function Wr(e){return typeof e!=`string`||e===``||e===`unknown`?null:Object.hasOwn(Pr,e)?e:null}function Gr(e){return Wr(e?.region)??Wr(process.env.VERCEL_REGION)??`iad1`}function Kr(e){let t=Pr[Gr(e)],n=zr(Vr(),t);if(Hr!==void 0)for(;n<=Hr;)n=zr(Ur(Hr),t);return Hr=n,n}function qr(e){let t=e.startsWith(`wrun_`)?e.slice(5):e;try{let e=Br(t);return e.tagged&&e.region?e.region:`iad1`}catch{return null}}function Jr(e){let t=e.runId;return typeof t!=`string`||t.length===0?null:{region:qr(t)}}async function Yr(e,t,n){if(e.length!==32)throw Error(`Invalid deployment key length: expected 32 bytes for AES-256, got ${e.length} bytes`);if(!t||typeof t!=`string`)throw Error(`projectId must be a non-empty string`);let r=await ge.subtle.importKey(`raw`,e,`HKDF`,!1,[`deriveBits`]),i=new TextEncoder().encode(`${t}|${n}`),a=await ge.subtle.deriveBits({name:`HKDF`,hash:`SHA-256`,salt:new Uint8Array(32),info:i},r,256);return new Uint8Array(a)}async function Xr(e,t,n,r){let i=await lr({token:r?.token});if(!i)throw Error(`Cannot fetch run key: no OIDC token or VERCEL_TOKEN available`);let a=new URLSearchParams({projectId:t,runId:n});r?.teamId&&a.set(`teamId`,r.teamId);let o=await(await fr({method:`GET`,url:`https://api.vercel.com/v1/workflow/run-key/${e}?${a}`,headers:new Headers({Authorization:`Bearer ${i}`}),dispatcher:bn({dispatcher:r?.dispatcher}),peerService:`vercel-api`,timeoutMs:null,buildError:async t=>{let r;try{r=await t.text()}catch{r=`<unable to read response body>`}return Error(`Failed to fetch run key for ${n} (deployment ${e}): HTTP ${t.status} ${t.statusText}${r?` — ${r}`:``}`)}})).json(),s=de({key:ue().nullable()}).safeParse(o);if(!s.success)throw Error(`Invalid response from Vercel API: expected { key: string | null }. Zod error: ${s.error.message}`);if(s.data.key!==null)return Buffer.from(s.data.key,`base64`)}function Zr(e,t,n,r){if(!e)return;let i=process.env.VERCEL===`1`,a;function o(){if(a)return a;let e=process.env.VERCEL_DEPLOYMENT_KEY;if(e)return a=Buffer.from(e,`base64`),a}return async function(a,s){let c=typeof a==`string`?a:a.runId,l=typeof a==`string`?s?.deploymentId:a.deploymentId;if(i&&(!l||l===process.env.VERCEL_DEPLOYMENT_ID)){let t=o();return t?Yr(t,e,c):void 0}if(l)return Xr(l,e,c,{token:n,teamId:t,dispatcher:r})}}const Qr={peerService:`workflow-server`,rpcSystem:`http`,rpcService:`workflow-server`},$r={"world.runs.get":0,"world.runs.experimentalSetAttributes":0,"world.steps.get":0,"world.events.create":0,"world.events.get":0},ei=new Set([`world.steps.list`,`world.events.list`,`world.hooks.list`]);function ti(e){if(e.length>=2&&typeof e[1]==`object`&&e[1]!==null){let t=e[1];if(typeof t.eventType==`string`)return t.eventType}}function ni(e,t){return typeof e[t]==`string`?e[t]:void 0}function ri(e){if(typeof e!=`object`||!e)return;let t=e.runId;return typeof t==`string`?t:void 0}function ii(e){if(typeof e!=`object`||!e)return;let t=e;if(typeof t.runId==`string`)return t.runId;for(let e of[`run`,`step`,`hook`,`wait`]){let n=t[e];if(typeof n==`object`&&n){let e=n.runId;if(typeof e==`string`)return e}}}function ai(e,t,n){let r=`${e}.${t}`,i={},a=$r[r],o=a===void 0?ei.has(r)?ri(n[0]):void 0:ni(n,a);if(o&&Object.assign(i,Jn(o)),r===`world.steps.get`){let e=ni(n,1);e&&Object.assign(i,Yn(e))}return i}function oi(e,t){let n={};for(let r of Object.keys(t))if(typeof t[r]!=`function`)n[r]=t[r];else{let i=t[r],a=String(r);n[r]=async(...t)=>{let n=`${e}.${a}`;if(e===`world.events`&&a===`create`){let r=ti(t);r&&(n=`${e}.${a} ${r}`)}return Pn(n,{kind:await Fn(`CLIENT`)},async r=>{r?.setAttributes({...Wn(Qr.peerService),...Gn(Qr.rpcSystem),...Kn(Qr.rpcService),...qn(n),...ai(e,a,t)});let o=await i(...t),s=ii(o);return s&&r?.setAttributes(Jn(s)),o})}}return n}var q=class extends Error{constructor(e){super(e),this.name=`MultipartParseError`}};function si(e){let t=new TextEncoder().encode(e);return(e,n=0)=>Buffer.prototype.indexOf.call(e,t,n)}function ci(e){let t=new TextEncoder().encode(e),n={};for(let e=0;e<t.length;++e){let r=t[e];n[r]===void 0&&(n[r]=[]),n[r].push(e)}return function(e){let r=e.length-1;if(e[r]in n){let i=n[e[r]];for(let n=i.length-1;n>=0;--n)for(let a=i[n],o=r;a>=0&&e[o]===t[a];--a,--o)if(a===0)return o}return-1}}function li(e){let t=new TextDecoder(`iso-8859-1`).decode(e).trim().split(/\r?\n/),n=[];for(let e of t){let t=e.indexOf(`:`);if(t>0){let r=e.slice(0,t).trim(),i=e.slice(t+1).trim();n.push([r,i])}}return new Headers(n)}function ui(e){let t=e.match(/boundary=(?:"([^"]+)"|([^;]+))/i);if(!t)throw new q(`No boundary found in Content-Type header`);return t[1]??t[2]}var di=class{queue=[];waiters=[];finished=!1;cancelled=!1;error=null;enqueue(e){this.finished||this.cancelled||(this.waiters.length>0?this.waiters.shift().resolve(e):this.queue.push(e))}finish(e){if(!this.finished)for(this.finished=!0,this.error=e||null;this.waiters.length>0;){let t=this.waiters.shift();e?t.reject(e):t.resolve(null)}}cancel(){if(!(this.cancelled||this.finished))for(this.cancelled=!0;this.waiters.length>0;)this.waiters.shift().resolve(null)}async dequeue(){if(this.queue.length>0)return this.queue.shift();if(this.finished||this.cancelled){if(this.error)throw this.error;return null}return new Promise((e,t)=>{this.waiters.push({resolve:e,reject:t})})}get isTerminal(){return this.finished||this.cancelled}};async function*fi(e,t){if(!e.body)throw new q(`Response body is null`);let n=e.headers.get(`content-type`);if(!n)throw new q(`Missing Content-Type header`);yield*new pi(ui(n),t).parseStream(e.body)}var pi=class{boundary;findOpeningBoundary;openingBoundaryLength;findBoundary;findPartialTailBoundary;boundaryLength;findDoubleNewline;maxHeaderSize;maxBoundaryBuffer;state=0;buffer=null;currentHeaders=new Headers;currentPayloadController=null;constructor(e,t={}){this.boundary=e,this.findOpeningBoundary=si(`--${e}`),this.openingBoundaryLength=2+e.length,this.findBoundary=si(`\r
|
|
6
|
-
--${e}`),this.findPartialTailBoundary=
|
|
7
|
-
--${e}`),this.boundaryLength=4+e.length,this.findDoubleNewline=
|
|
1
|
+
import{a as e,i as t,t as n}from"../../_chunks/workflow/chunk-BHKSVoKr.js";import{E as r,g as i,h as a,o,r as s,s as c,u as l,w as u}from"../../_chunks/workflow/dist-BYo8Gno2.js";import{$ as d,A as f,C as p,E as m,F as h,I as g,N as _,O as v,P as y,Q as b,R as x,S,T as C,U as w,W as T,X as ee,at as E,b as te,et as ne,f as re,it as ie,l as D,m as ae,nt as oe,o as se,ot as ce,p as le,r as ue,rt as de,tt as fe,w as pe,x as me,y as he}from"../../_chunks/workflow/dist-CSfKNxQW.js";import{a as ge,i as _e,n as ve,o as ye,r as be,s as xe,t as Se}from"../../_chunks/workflow/run-id-BdE0MZz9.js";import{t as Ce}from"../../_chunks/workflow/undici-fb54XL8i.js";import{webcrypto as we}from"node:crypto";import{inspect as Te}from"node:util";import{AsyncLocalStorage as Ee}from"node:async_hooks";import De from"node:os";import*as Oe from"path";import*as ke from"fs";import{createRequire as Ae}from"module";import*as je from"net";var Me=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{SYMBOL_FOR_REQ_CONTEXT:()=>u,getContext:()=>d}),t.exports=c(l);let u=Symbol.for(`@vercel/request-context`);function d(){return globalThis[u]?.get?.()??{}}0&&(t.exports={SYMBOL_FOR_REQ_CONTEXT:u,getContext:d})})),Ne=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{VercelOidcTokenError:()=>u}),t.exports=c(l);var u=class extends Error{constructor(e,t){super(e),this.name=`VercelOidcTokenError`,this.cause=t}toString(){return this.cause?`${this.name}: ${this.message}: ${this.cause}`:`${this.name}: ${this.message}`}};0&&(t.exports={VercelOidcTokenError:u})})),Pe=n(((t,n)=>{var r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})},c=(e,t,n,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==n&&r(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(r({},`__esModule`,{value:!0}),e),u={};s(u,{getVercelOidcToken:()=>p,getVercelOidcTokenSync:()=>m}),n.exports=l(u);var d=Me(),f=Ne();async function p(t){let n=``,r;try{n=m()}catch(e){r=e}try{let[{getTokenPayload:r,isExpired:i},{refreshToken:a}]=await Promise.all([await Promise.resolve().then(()=>e(ze())),await import(`../../_chunks/workflow/token-CaY0nA5J.js`).then(t=>e(t.default))]);(!n||i(r(n),t?.expirationBufferMs))&&(await a(t),n=m())}catch(e){let t=r instanceof Error?r.message:``;throw e instanceof Error&&(t=`${t}
|
|
2
|
+
${e.message}`),t?new f.VercelOidcTokenError(t):e}return n}function m(){let e=(0,d.getContext)().headers?.[`x-vercel-oidc-token`]??process.env.VERCEL_OIDC_TOKEN;if(!e)throw Error(`The 'x-vercel-oidc-token' header is missing from the request. Do you have the OIDC option enabled in the Vercel project settings?`);return e}0&&(n.exports={getVercelOidcToken:p,getVercelOidcTokenSync:m})})),Fe=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{AccessTokenMissingError:()=>u,RefreshAccessTokenFailedError:()=>d}),t.exports=c(l);var u=class extends Error{constructor(){super(`No authentication found. Please log in with the Vercel CLI (vercel login).`),this.name=`AccessTokenMissingError`}},d=class extends Error{constructor(e){super(`Failed to refresh authentication token.`,{cause:e}),this.name=`RefreshAccessTokenFailedError`}};0&&(t.exports={AccessTokenMissingError:u,RefreshAccessTokenFailedError:d})})),Ie=n(((e,n)=>{var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},u=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let s of o(t))!c.call(e,s)&&s!==n&&i(e,s,{get:()=>t[s],enumerable:!(r=a(t,s))||r.enumerable});return e},d=(e,t,n)=>(n=e==null?{}:r(s(e)),u(t||!e||!e.__esModule?i(n,`default`,{value:e,enumerable:!0}):n,e)),f=e=>u(i({},`__esModule`,{value:!0}),e),p={};l(p,{findRootDir:()=>v,getUserDataDir:()=>y}),n.exports=f(p);var m=d(t(`path`)),h=d(t(`fs`)),g=d(t(`os`)),_=Ne();function v(){try{let e=process.cwd();for(;e!==m.default.dirname(e);){let t=m.default.join(e,`.vercel`);if(h.default.existsSync(t))return e;e=m.default.dirname(e)}}catch{throw new _.VercelOidcTokenError(`Token refresh only supported in node server environments`)}return null}function y(){if(process.env.XDG_DATA_HOME)return process.env.XDG_DATA_HOME;switch(g.default.platform()){case`darwin`:return m.default.join(g.default.homedir(),`Library/Application Support`);case`linux`:return m.default.join(g.default.homedir(),`.local/share`);case`win32`:return process.env.LOCALAPPDATA?process.env.LOCALAPPDATA:null;default:return null}}0&&(n.exports={findRootDir:v,getUserDataDir:y})})),Le=n(((e,n)=>{var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},u=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let s of o(t))!c.call(e,s)&&s!==n&&i(e,s,{get:()=>t[s],enumerable:!(r=a(t,s))||r.enumerable});return e},d=(e,t,n)=>(n=e==null?{}:r(s(e)),u(t||!e||!e.__esModule?i(n,`default`,{value:e,enumerable:!0}):n,e)),f=e=>u(i({},`__esModule`,{value:!0}),e),p={};l(p,{isValidAccessToken:()=>b,readAuthConfig:()=>v,writeAuthConfig:()=>y}),n.exports=f(p);var m=d(t(`fs`)),h=d(t(`path`)),g=ze();function _(){let e=(0,g.getVercelDataDir)();if(!e)throw Error(`Unable to find Vercel CLI data directory. Your platform: ${process.platform}. Supported: darwin, linux, win32.`);return h.join(e,`auth.json`)}function v(){try{let e=_();if(!m.existsSync(e))return null;let t=m.readFileSync(e,`utf8`);return t?JSON.parse(t):null}catch{return null}}function y(e){let t=_(),n=h.dirname(t);m.existsSync(n)||m.mkdirSync(n,{mode:504,recursive:!0}),m.writeFileSync(t,JSON.stringify(e,null,2),{mode:384})}function b(e,t=0){if(!e.token)return!1;if(typeof e.expiresAt!=`number`)return!0;let n=Math.floor(Date.now()/1e3),r=t/1e3;return e.expiresAt>=n+r}0&&(n.exports={isValidAccessToken:b,readAuthConfig:v,writeAuthConfig:y})})),Re=n(((e,n)=>{var r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})},c=(e,t,n,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==n&&r(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(r({},`__esModule`,{value:!0}),e),u={};s(u,{processTokenResponse:()=>g,refreshTokenRequest:()=>h}),n.exports=l(u);var d=t(`os`);let f=`@vercel/oidc node-${process.version} ${(0,d.platform)()} (${(0,d.arch)()}) ${(0,d.hostname)()}`,p=null;async function m(){if(p)return p;let e=await fetch(`https://vercel.com/.well-known/openid-configuration`,{headers:{"user-agent":f}});if(!e.ok)throw Error(`Failed to discover OAuth endpoints`);let t=await e.json();if(!t||typeof t.token_endpoint!=`string`)throw Error(`Invalid OAuth discovery response`);let n=t.token_endpoint;return p=n,n}async function h(e){let t=await m();return await fetch(t,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`,"user-agent":f},body:new URLSearchParams({client_id:`cl_HYyOPBNtFMfHhaUn9L4QPfTZz6TP47bp`,grant_type:`refresh_token`,...e})})}async function g(e){let t=await e.json();if(!e.ok){let e=typeof t==`object`&&t&&`error`in t?String(t.error):`Token refresh failed`;return[Error(e)]}return typeof t!=`object`||!t?[Error(`Invalid token response`)]:typeof t.access_token==`string`?t.token_type===`Bearer`?typeof t.expires_in==`number`?[null,t]:[Error(`Missing expires_in in response`)]:[Error(`Invalid token_type in response`)]:[Error(`Missing access_token in response`)]}0&&(n.exports={processTokenResponse:g,refreshTokenRequest:h})})),ze=n(((e,n)=>{var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},u=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let s of o(t))!c.call(e,s)&&s!==n&&i(e,s,{get:()=>t[s],enumerable:!(r=a(t,s))||r.enumerable});return e},d=(e,t,n)=>(n=e==null?{}:r(s(e)),u(t||!e||!e.__esModule?i(n,`default`,{value:e,enumerable:!0}):n,e)),f=e=>u(i({},`__esModule`,{value:!0}),e),p={};l(p,{assertVercelOidcTokenResponse:()=>w,findProjectInfo:()=>T,getTokenPayload:()=>te,getVercelDataDir:()=>x,getVercelOidcToken:()=>C,getVercelToken:()=>S,isExpired:()=>ne,loadToken:()=>E,saveToken:()=>ee}),n.exports=f(p);var m=d(t(`path`)),h=d(t(`fs`)),g=Ne(),_=Ie(),v=Le(),y=Re(),b=Fe();function x(){let e=(0,_.getUserDataDir)();return e?m.join(e,`com.vercel.cli`):null}async function S(e){let t=(0,v.readAuthConfig)();if(!t?.token)throw new b.AccessTokenMissingError;if((0,v.isValidAccessToken)(t,e?.expirationBufferMs))return t.token;if(!t.refreshToken)throw(0,v.writeAuthConfig)({}),new b.RefreshAccessTokenFailedError(`No refresh token available`);try{let e=await(0,y.refreshTokenRequest)({refresh_token:t.refreshToken}),[n,r]=await(0,y.processTokenResponse)(e);if(n||!r)throw(0,v.writeAuthConfig)({}),new b.RefreshAccessTokenFailedError(n);let i={token:r.access_token,expiresAt:Math.floor(Date.now()/1e3)+r.expires_in};return r.refresh_token&&(i.refreshToken=r.refresh_token),(0,v.writeAuthConfig)(i),i.token}catch(e){throw(0,v.writeAuthConfig)({}),e instanceof b.AccessTokenMissingError||e instanceof b.RefreshAccessTokenFailedError?e:new b.RefreshAccessTokenFailedError(e)}}async function C(e,t,n){let r=`https://api.vercel.com/v1/projects/${t}/token?source=vercel-oidc-refresh${n?`&teamId=${n}`:``}`,i=await fetch(r,{method:`POST`,headers:{Authorization:`Bearer ${e}`}});if(!i.ok)throw new g.VercelOidcTokenError(`Failed to refresh OIDC token: ${i.statusText}`);let a=await i.json();return w(a),a}function w(e){if(!e||typeof e!=`object`)throw TypeError("Vercel OIDC token is malformed. Expected an object. Please run `vc env pull` and try again");if(!(`token`in e)||typeof e.token!=`string`)throw TypeError("Vercel OIDC token is malformed. Expected a string-valued token property. Please run `vc env pull` and try again")}function T(){let e=(0,_.findRootDir)();if(!e)throw new g.VercelOidcTokenError("Unable to find project root directory. Have you linked your project with `vc link?`");let t=m.join(e,`.vercel`,`project.json`);if(!h.existsSync(t))throw new g.VercelOidcTokenError("project.json not found, have you linked your project with `vc link?`");let n=JSON.parse(h.readFileSync(t,`utf8`));if(typeof n.projectId!=`string`&&typeof n.orgId!=`string`)throw TypeError("Expected a string-valued projectId property. Try running `vc link` to re-link your project.");return{projectId:n.projectId,teamId:n.orgId}}function ee(e,t){let n=(0,_.getUserDataDir)();if(!n)throw new g.VercelOidcTokenError(`Unable to find user data directory. Please reach out to Vercel support.`);let r=m.join(n,`com.vercel.token`,`${t}.json`),i=JSON.stringify(e);h.mkdirSync(m.dirname(r),{mode:504,recursive:!0}),h.writeFileSync(r,i),h.chmodSync(r,432)}function E(e){let t=(0,_.getUserDataDir)();if(!t)throw new g.VercelOidcTokenError(`Unable to find user data directory. Please reach out to Vercel support.`);let n=m.join(t,`com.vercel.token`,`${e}.json`);if(!h.existsSync(n))return null;let r=JSON.parse(h.readFileSync(n,`utf8`));return w(r),r}function te(e){let t=e.split(`.`);if(t.length!==3)throw new g.VercelOidcTokenError("Invalid token. Please run `vc env pull` and try again");let n=t[1].replace(/-/g,`+`).replace(/_/g,`/`),r=n.padEnd(n.length+(4-n.length%4)%4,`=`);return JSON.parse(Buffer.from(r,`base64`).toString(`utf8`))}function ne(e,t=0){return e.exp*1e3<Date.now()+t}0&&(n.exports={assertVercelOidcTokenResponse:w,findProjectInfo:T,getTokenPayload:te,getVercelDataDir:x,getVercelOidcToken:C,getVercelToken:S,isExpired:ne,loadToken:E,saveToken:ee})})),Be=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{AccessTokenMissingError:()=>f.AccessTokenMissingError,RefreshAccessTokenFailedError:()=>f.RefreshAccessTokenFailedError,getContext:()=>d.getContext,getVercelOidcToken:()=>u.getVercelOidcToken,getVercelOidcTokenSync:()=>u.getVercelOidcTokenSync,getVercelToken:()=>p.getVercelToken}),t.exports=c(l);var u=Pe(),d=Me(),f=Fe(),p=ze();0&&(t.exports={AccessTokenMissingError,RefreshAccessTokenFailedError,getContext,getVercelOidcToken,getVercelOidcTokenSync,getVercelToken})}))();let Ve;try{Ve=new TextDecoder}catch{}let O,He,k=0;const Ue=[],We=57337,Ge={};let Ke=11281e4,qe=1681e4,Je=Ue,Ye=0,A={},j,Xe,Ze=0,Qe=0,M,N,P=[],$e=[],F,I,et,tt={useRecords:!1,mapsAsObjects:!0},nt=!1,rt=2;try{Function(``)}catch{rt=1/0}var it=class e{constructor(e){if(e&&((e.keyMap||e._keyMap)&&!e.useRecords&&(e.useRecords=!1,e.mapsAsObjects=!0),e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.getStructures&&(e.getShared=e.getStructures),e.getShared&&!e.structures&&((e.structures=[]).uninitialized=!0),e.keyMap)){this.mapKey=new Map;for(let[t,n]of Object.entries(e.keyMap))this.mapKey.set(n,t)}Object.assign(this,e)}decodeKey(e){return this.keyMap&&this.mapKey.get(e)||e}encodeKey(e){return this.keyMap&&this.keyMap.hasOwnProperty(e)?this.keyMap[e]:e}encodeKeys(e){if(!this._keyMap)return e;let t=new Map;for(let[n,r]of Object.entries(e))t.set(this._keyMap.hasOwnProperty(n)?this._keyMap[n]:n,r);return t}decodeKeys(e){if(!this._keyMap||e.constructor.name!=`Map`)return e;if(!this._mapKey){this._mapKey=new Map;for(let[e,t]of Object.entries(this._keyMap))this._mapKey.set(t,e)}let t={};return e.forEach((e,n)=>t[R(this._mapKey.has(n)?this._mapKey.get(n):n)]=e),t}mapDecode(e,t){let n=this.decode(e);if(this._keyMap)switch(n.constructor.name){case`Array`:return n.map(e=>this.decodeKeys(e))}return n}decode(t,n){if(O)return At(()=>(jt(),this?this.decode(t,n):e.prototype.decode.call(tt,t,n)));He=n>-1?n:t.length,k=0,Ye=0,Qe=0,Xe=null,Je=Ue,M=null,O=t;try{I=t.dataView||=new DataView(t.buffer,t.byteOffset,t.byteLength)}catch(e){throw O=null,t instanceof Uint8Array?e:Error(`Source must be a Uint8Array or Buffer but was a `+(t&&typeof t==`object`?t.constructor.name:typeof t))}if(this instanceof e){if(A=this,F=this.sharedValues&&(this.pack?Array(this.maxPrivatePackedValues||16).concat(this.sharedValues):this.sharedValues),this.structures)return j=this.structures,at();(!j||j.length>0)&&(j=[])}else A=tt,(!j||j.length>0)&&(j=[]),F=null;return at()}decodeMultiple(e,t){let n,r=0;try{let i=e.length;nt=!0;let a=this?this.decode(e,i):Nt.decode(e,i);if(t){if(t(a)===!1)return;for(;k<i;)if(r=k,t(at())===!1)return}else{for(n=[a];k<i;)r=k,n.push(at());return n}}catch(e){throw e.lastPosition=r,e.values=n,e}finally{nt=!1,jt()}}};function at(){try{let e=L();if(M){if(k>=M.postBundlePosition){let e=Error(`Unexpected bundle position`);throw e.incomplete=!0,e}k=M.postBundlePosition,M=null}if(k==He)j=null,O=null,N&&=null;else if(k>He){let e=Error(`Unexpected end of CBOR data`);throw e.incomplete=!0,e}else if(!nt)throw Error(`Data read, but end of buffer not reached`);return e}catch(e){throw jt(),(e instanceof RangeError||e.message.startsWith(`Unexpected end of buffer`))&&(e.incomplete=!0),e}}function L(){let e=O[k++],t=e>>5;if(e&=31,e>23)switch(e){case 24:e=O[k++];break;case 25:if(t==7)return gt();e=I.getUint16(k),k+=2;break;case 26:if(t==7){let e=I.getFloat32(k);if(A.useFloat32>2){let t=Mt[(O[k]&127)<<1|O[k+1]>>7];return k+=4,(t*e+(e>0?.5:-.5)>>0)/t}return k+=4,e}e=I.getUint32(k),k+=4;break;case 27:if(t==7){let e=I.getFloat64(k);return k+=8,e}if(t>1){if(I.getUint32(k)>0)throw Error(`JavaScript does not support arrays, maps, or strings with length over 4294967295`);e=I.getUint32(k+4)}else A.int64AsNumber?(e=I.getUint32(k)*4294967296,e+=I.getUint32(k+4)):e=I.getBigUint64(k);k+=8;break;case 31:switch(t){case 2:case 3:throw Error(`Indefinite length not supported for byte or text strings`);case 4:let e=[],n,r=0;for(;(n=L())!=Ge;){if(r>=Ke)throw Error(`Array length exceeds ${Ke}`);e[r++]=n}return t==4?e:t==3?e.join(``):Buffer.concat(e);case 5:let i;if(A.mapsAsObjects){let e={},t=0;if(A.keyMap)for(;(i=L())!=Ge;){if(t++>=qe)throw Error(`Property count exceeds ${qe}`);e[R(A.decodeKey(i))]=L()}else for(;(i=L())!=Ge;){if(t++>=qe)throw Error(`Property count exceeds ${qe}`);e[R(i)]=L()}return e}else{et&&=(A.mapsAsObjects=!0,!1);let e=new Map;if(A.keyMap){let t=0;for(;(i=L())!=Ge;){if(t++>=qe)throw Error(`Map size exceeds ${qe}`);e.set(A.decodeKey(i),L())}}else{let t=0;for(;(i=L())!=Ge;){if(t++>=qe)throw Error(`Map size exceeds ${qe}`);e.set(i,L())}}return e}case 7:return Ge;default:throw Error(`Invalid major type for indefinite length `+t)}default:throw Error(`Unknown token `+e)}switch(t){case 0:return e;case 1:return~e;case 2:return pt(e);case 3:if(Qe>=k)return Xe.slice(k-Ze,(k+=e)-Ze);if(Qe==0&&He<140&&e<32){let t=e<16?ft(e):dt(e);if(t!=null)return t}return ct(e);case 4:if(e>=Ke)throw Error(`Array length exceeds ${Ke}`);let t=Array(e);for(let n=0;n<e;n++)t[n]=L();return t;case 5:if(e>=qe)throw Error(`Map size exceeds ${Ke}`);if(A.mapsAsObjects){let t={};if(A.keyMap)for(let n=0;n<e;n++)t[R(A.decodeKey(L()))]=L();else for(let n=0;n<e;n++)t[R(L())]=L();return t}else{et&&=(A.mapsAsObjects=!0,!1);let t=new Map;if(A.keyMap)for(let n=0;n<e;n++)t.set(A.decodeKey(L()),L());else for(let n=0;n<e;n++)t.set(L(),L());return t}case 6:if(e>=We){let t=j[e&8191];if(t)return t.read||=st(t),t.read();if(e<65536){if(e==57343){let e=Ot(),t=L(),n=L();vt(t,n);let r={};if(A.keyMap)for(let t=2;t<e;t++){let e=A.decodeKey(n[t-2]);r[R(e)]=L()}else for(let t=2;t<e;t++){let e=n[t-2];r[R(e)]=L()}return r}else if(e==57342){let e=Ot(),t=L();for(let n=2;n<e;n++)vt(t++,L());return L()}else if(e==We)return Dt();if(A.getShared&&(kt(),t=j[e&8191],t))return t.read||=st(t),t.read()}}let n=P[e];if(n)return n.handlesRead?n(L):n(L());{let t=L();for(let n=0;n<$e.length;n++){let r=$e[n](e,t);if(r!==void 0)return r}return new _t(t,e)}case 7:switch(e){case 20:return!1;case 21:return!0;case 22:return null;case 23:return;default:let t=(F||St())[e];if(t!==void 0)return t;throw Error(`Unknown token `+e)}default:if(isNaN(e)){let e=Error(`Unexpected end of CBOR data`);throw e.incomplete=!0,e}throw Error(`Unknown CBOR token `+e)}}const ot=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function st(e){if(!e)throw Error(`Structure is required in record definition`);function t(){let e=O[k++];if(e&=31,e>23)switch(e){case 24:e=O[k++];break;case 25:e=I.getUint16(k),k+=2;break;case 26:e=I.getUint32(k),k+=4;break;default:throw Error(`Expected array header, but got `+O[k-1])}let t=this.compiledReader;for(;t;){if(t.propertyCount===e)return t(L);t=t.next}if(this.slowReads++>=rt){let n=this.length==e?this:this.slice(0,e);return t=A.keyMap?Function(`r`,`return {`+n.map(e=>A.decodeKey(e)).map(e=>ot.test(e)?R(e)+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`}`):Function(`r`,`return {`+n.map(e=>ot.test(e)?R(e)+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`}`),this.compiledReader&&(t.next=this.compiledReader),t.propertyCount=e,this.compiledReader=t,t(L)}let n={};if(A.keyMap)for(let t=0;t<e;t++)n[R(A.decodeKey(this[t]))]=L();else for(let t=0;t<e;t++)n[R(this[t])]=L();return n}return e.slowReads=0,t}function R(e){if(typeof e==`string`)return e===`__proto__`?`__proto_`:e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return e.toString();if(e==null)return e+``;throw Error(`Invalid property name type `+typeof e)}let ct=ut;function lt(e){ct=t(1);function t(t){return function(t){let n=Je[Ye++];if(n==null){if(M)return ut(t);let r=e(k,He,t,O);if(typeof r==`string`)n=r,Je=Ue;else if(Je=r,Ye=1,Qe=1,n=Je[0],n===void 0)throw Error(`Unexpected end of buffer`)}let r=n.length;return r<=t?(k+=t,n):(Xe=n,Ze=k,Qe=k+r,k+=t,n.slice(0,t))}}}function ut(e){let t;if(e<16&&(t=ft(e)))return t;if(e>64&&Ve)return Ve.decode(O.subarray(k,k+=e));let n=k+e,r=[];for(t=``;k<n;){let e=O[k++];if(!(e&128))r.push(e);else if((e&224)==192){let t=O[k++]&63;r.push((e&31)<<6|t)}else if((e&240)==224){let t=O[k++]&63,n=O[k++]&63;r.push((e&31)<<12|t<<6|n)}else if((e&248)==240){let t=O[k++]&63,n=O[k++]&63,i=O[k++]&63,a=(e&7)<<18|t<<12|n<<6|i;a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a)}else r.push(e);r.length>=4096&&(t+=z.apply(String,r),r.length=0)}return r.length>0&&(t+=z.apply(String,r)),t}let z=String.fromCharCode;function dt(e){let t=k,n=Array(e);for(let r=0;r<e;r++){let e=O[k++];if((e&128)>0){k=t;return}n[r]=e}return z.apply(String,n)}function ft(e){if(e<4)if(e<2){if(e===0)return``;{let e=O[k++];if((e&128)>1){--k;return}return z(e)}}else{let t=O[k++],n=O[k++];if((t&128)>0||(n&128)>0){k-=2;return}if(e<3)return z(t,n);let r=O[k++];if((r&128)>0){k-=3;return}return z(t,n,r)}else{let t=O[k++],n=O[k++],r=O[k++],i=O[k++];if((t&128)>0||(n&128)>0||(r&128)>0||(i&128)>0){k-=4;return}if(e<6){if(e===4)return z(t,n,r,i);{let e=O[k++];if((e&128)>0){k-=5;return}return z(t,n,r,i,e)}}else if(e<8){let a=O[k++],o=O[k++];if((a&128)>0||(o&128)>0){k-=6;return}if(e<7)return z(t,n,r,i,a,o);let s=O[k++];if((s&128)>0){k-=7;return}return z(t,n,r,i,a,o,s)}else{let a=O[k++],o=O[k++],s=O[k++],c=O[k++];if((a&128)>0||(o&128)>0||(s&128)>0||(c&128)>0){k-=8;return}if(e<10){if(e===8)return z(t,n,r,i,a,o,s,c);{let e=O[k++];if((e&128)>0){k-=9;return}return z(t,n,r,i,a,o,s,c,e)}}else if(e<12){let l=O[k++],u=O[k++];if((l&128)>0||(u&128)>0){k-=10;return}if(e<11)return z(t,n,r,i,a,o,s,c,l,u);let d=O[k++];if((d&128)>0){k-=11;return}return z(t,n,r,i,a,o,s,c,l,u,d)}else{let l=O[k++],u=O[k++],d=O[k++],f=O[k++];if((l&128)>0||(u&128)>0||(d&128)>0||(f&128)>0){k-=12;return}if(e<14){if(e===12)return z(t,n,r,i,a,o,s,c,l,u,d,f);{let e=O[k++];if((e&128)>0){k-=13;return}return z(t,n,r,i,a,o,s,c,l,u,d,f,e)}}else{let p=O[k++],m=O[k++];if((p&128)>0||(m&128)>0){k-=14;return}if(e<15)return z(t,n,r,i,a,o,s,c,l,u,d,f,p,m);let h=O[k++];if((h&128)>0){k-=15;return}return z(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}}}}}function pt(e){return A.copyBuffers?Uint8Array.prototype.slice.call(O,k,k+=e):O.subarray(k,k+=e)}let mt=new Float32Array(1),ht=new Uint8Array(mt.buffer,0,4);function gt(){let e=O[k++],t=O[k++],n=(e&127)>>2;if(n===31)return t||e&3?NaN:e&128?-1/0:1/0;if(n===0){let n=((e&3)<<8|t)/(1<<24);return e&128?-n:n}return ht[3]=e&128|(n>>1)+56,ht[2]=(e&7)<<5|t>>3,ht[1]=t<<5,ht[0]=0,mt[0]}Array(4096);var _t=class{constructor(e,t){this.value=e,this.tag=t}};P[0]=e=>new Date(e),P[1]=e=>new Date(Math.round(e*1e3)),P[2]=e=>{let t=BigInt(0);for(let n=0,r=e.byteLength;n<r;n++)t=BigInt(e[n])+(t<<BigInt(8));return t},P[3]=e=>BigInt(-1)-P[2](e),P[4]=e=>+(e[1]+`e`+e[0]),P[5]=e=>e[1]*Math.exp(e[0]*Math.log(2));const vt=(e,t)=>{e-=57344;let n=j[e];n&&n.isShared&&((j.restoreStructures||=[])[e]=n),j[e]=t,t.read=st(t)};P[105]=e=>{let t=e.length,n=e[1];vt(e[0],n);let r={};for(let i=2;i<t;i++){let t=n[i-2];r[R(t)]=e[i]}return r},P[14]=e=>M?M[0].slice(M.position0,M.position0+=e):new _t(e,14),P[15]=e=>M?M[1].slice(M.position1,M.position1+=e):new _t(e,15);let yt={Error,RegExp};P[27]=e=>(yt[e[0]]||Error)(e[1],e[2]);const bt=e=>{if(O[k++]!=132){let e=Error(`Packed values structure must be followed by a 4 element array`);throw O.length<k&&(e.incomplete=!0),e}let t=e();if(!t||!t.length){let e=Error(`Packed values structure must be followed by a 4 element array`);throw e.incomplete=!0,e}return F=F?t.concat(F.slice(t.length)):t,F.prefixes=e(),F.suffixes=e(),e()};bt.handlesRead=!0,P[51]=bt,P[6]=e=>{if(!F)if(A.getShared)kt();else return new _t(e,6);if(typeof e==`number`)return F[16+(e>=0?2*e:-2*e-1)];let t=Error(`No support for non-integer packed references yet`);throw e===void 0&&(t.incomplete=!0),t},P[28]=e=>{N||(N=new Map,N.id=0);let t=N.id++,n=k,r=O[k],i;i=r>>5==4?[]:{};let a={target:i};N.set(t,a);let o=e();return a.used?(Object.getPrototypeOf(i)!==Object.getPrototypeOf(o)&&(k=n,i=o,N.set(t,{target:i}),o=e()),Object.assign(i,o)):(a.target=o,o)},P[28].handlesRead=!0,P[29]=e=>{let t=N.get(e);return t.used=!0,t.target},P[258]=e=>new Set(e),(P[259]=e=>(A.mapsAsObjects&&(A.mapsAsObjects=!1,et=!0),e())).handlesRead=!0;function xt(e,t){return typeof e==`string`?e+t:e instanceof Array?e.concat(t):Object.assign({},e,t)}function St(){if(!F)if(A.getShared)kt();else throw Error(`No packed values available`);return F}$e.push((e,t)=>{if(e>=225&&e<=255)return xt(St().prefixes[e-224],t);if(e>=28704&&e<=32767)return xt(St().prefixes[e-28672],t);if(e>=1879052288&&e<=2147483647)return xt(St().prefixes[e-1879048192],t);if(e>=216&&e<=223)return xt(t,St().suffixes[e-216]);if(e>=27647&&e<=28671)return xt(t,St().suffixes[e-27639]);if(e>=1811940352&&e<=1879048191)return xt(t,St().suffixes[e-1811939328]);if(e==1399353956)return{packedValues:F,structures:j.slice(0),version:t};if(e==55799)return t});const Ct=new Uint8Array(new Uint16Array([1]).buffer)[0]==1,wt=[Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,typeof BigUint64Array>`u`?{name:`BigUint64Array`}:BigUint64Array,Int8Array,Int16Array,Int32Array,typeof BigInt64Array>`u`?{name:`BigInt64Array`}:BigInt64Array,Float32Array,Float64Array],Tt=[64,68,69,70,71,72,77,78,79,85,86];for(let e=0;e<wt.length;e++)Et(wt[e],Tt[e]);function Et(e,t){let n=`get`+e.name.slice(0,-5),r;typeof e==`function`?r=e.BYTES_PER_ELEMENT:e=null;for(let i=0;i<2;i++){if(!i&&r==1)continue;let a=r==2?1:r==4?2:r==8?3:0;P[i?t:t-4]=r==1||i==Ct?n=>{if(!e)throw Error(`Could not find typed array for code `+t);return!A.copyBuffers&&(r===1||r===2&&!(n.byteOffset&1)||r===4&&!(n.byteOffset&3)||r===8&&!(n.byteOffset&7))?new e(n.buffer,n.byteOffset,n.byteLength>>a):new e(Uint8Array.prototype.slice.call(n,0).buffer)}:r=>{if(!e)throw Error(`Could not find typed array for code `+t);let o=new DataView(r.buffer,r.byteOffset,r.byteLength),s=r.length>>a,c=new e(s),l=o[n];for(let e=0;e<s;e++)c[e]=l.call(o,e<<a,i);return c}}}function Dt(){let e=Ot(),t=k+L();for(let t=2;t<e;t++){let e=Ot();k+=e}let n=k;return k=t,M=[ut(Ot()),ut(Ot())],M.position0=0,M.position1=0,M.postBundlePosition=k,k=n,L()}function Ot(){let e=O[k++]&31;if(e>23)switch(e){case 24:e=O[k++];break;case 25:e=I.getUint16(k),k+=2;break;case 26:e=I.getUint32(k),k+=4;break}return e}function kt(){if(A.getShared){let e=At(()=>(O=null,A.getShared()))||{},t=e.structures||[];A.sharedVersion=e.version,F=A.sharedValues=e.packedValues,j===!0?A.structures=j=t:j.splice.apply(j,[0,t.length].concat(t))}}function At(e){let t=He,n=k,r=Ye,i=Ze,a=Qe,o=Xe,s=Je,c=N,l=M,u=new Uint8Array(O.slice(0,He)),d=j,f=A,p=nt,m=e();return He=t,k=n,Ye=r,Ze=i,Qe=a,Xe=o,Je=s,N=c,M=l,O=u,nt=p,j=d,A=f,I=new DataView(O.buffer,O.byteOffset,O.byteLength),m}function jt(){O=null,N=null,j=null}const Mt=Array(147);for(let e=0;e<256;e++)Mt[e]=+(`1e`+Math.floor(45.15-e*.30103));let Nt=new it({useRecords:!1});const Pt=Nt.decode;Nt.decodeMultiple;const Ft={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4};let It;try{It=new TextEncoder}catch{}let Lt,Rt;const zt=typeof globalThis==`object`&&globalThis.Buffer,Bt=zt!==void 0,Vt=Bt?zt.allocUnsafeSlow:Uint8Array,Ht=Bt?zt:Uint8Array,Ut=Bt?4294967296:2144337920;let Wt,B,V,H=0,Gt,U=null;const Kt=/[\u0080-\uFFFF]/,W=Symbol(`record-id`);var qt=class extends it{constructor(e){super(e),this.offset=0;let t,n,r,i,a;e||={};let o=Ht.prototype.utf8Write?function(e,t,n){return B.utf8Write(e,t,n)}:It&&It.encodeInto?function(e,t){return It.encodeInto(e,B.subarray(t)).written}:!1,s=this,c=e.structures||e.saveStructures,l=e.maxSharedStructures;if(l??=c?128:0,l>8190)throw Error(`Maximum maxSharedStructure is 8190`);let u=e.sequential;u&&(l=0),this.structures||=[],this.saveStructures&&(this.saveShared=this.saveStructures);let d,f,p=e.sharedValues,m;if(p){m=Object.create(null);for(let e=0,t=p.length;e<t;e++)m[p[e]]=e}let h=[],g=0,_=0;this.mapEncode=function(e,t){if(this._keyMap&&!this._mapped)switch(e.constructor.name){case`Array`:e=e.map(e=>this.encodeKeys(e));break}return this.encode(e,t)},this.encode=function(o,c){if(B||(B=new Vt(8192),V=new DataView(B.buffer,0,8192),H=0),Gt=B.length-10,Gt-H<2048?(B=new Vt(B.length),V=new DataView(B.buffer,0,B.length),Gt=B.length-10,H=0):c===512&&(H=H+7&2147483640),t=H,s.useSelfDescribedHeader&&(V.setUint32(H,3654940416),H+=3),a=s.structuredClone?new Map:null,s.bundleStrings&&typeof o!=`string`?(U=[],U.size=1/0):U=null,n=s.structures,n){if(n.uninitialized){let e=s.getShared()||{};s.structures=n=e.structures||[],s.sharedVersion=e.version;let t=s.sharedValues=e.packedValues;if(t){m={};for(let e=0,n=t.length;e<n;e++)m[t[e]]=e}}let e=n.length;if(e>l&&!u&&(e=l),!n.transitions){n.transitions=Object.create(null);for(let t=0;t<e;t++){let e=n[t];if(!e)continue;let r,i=n.transitions;for(let n=0,a=e.length;n<a;n++){i[W]===void 0&&(i[W]=t);let a=e[n];r=i[a],r||=i[a]=Object.create(null),i=r}i[W]=t|1048576}}u||(n.nextId=e)}if(r&&=!1,i=n||[],f=m,e.pack){let t=new Map;if(t.values=[],t.encoder=s,t.maxValues=e.maxPrivatePackedValues||(m?16:1/0),t.objectMap=m||!1,t.samplingPackedValues=d,$t(o,t),t.values.length>0){B[H++]=216,B[H++]=51,Xt(4);let e=t.values;v(e),Xt(0),Xt(0),f=Object.create(m||null);for(let t=0,n=e.length;t<n;t++)f[e[t]]=t}}Wt=c&fn;try{if(Wt)return;if(v(o),U&&an(t,v),s.offset=H,a&&a.idsToInsert){H+=a.idsToInsert.length*2,H>Gt&&b(H),s.offset=H;let e=rn(B.subarray(t,H),a.idsToInsert);return a=null,e}return c&512?(B.start=t,B.end=H,B):B.subarray(t,H)}finally{if(n){if(_<10&&_++,n.length>l&&(n.length=l),g>1e4)n.transitions=null,_=0,g=0,h.length>0&&(h=[]);else if(h.length>0&&!u){for(let e=0,t=h.length;e<t;e++)h[e][W]=void 0;h=[]}}if(r&&s.saveShared){s.structures.length>l&&(s.structures=s.structures.slice(0,l));let e=B.subarray(t,H);return s.updateSharedData()===!1?s.encode(o):e}c&1024&&(H=t)}},this.findCommonStringsToPack=()=>(d=new Map,m||=Object.create(null),e=>{let t=e&&e.threshold||4,n=this.pack?e.maxPrivatePackedValues||16:0;p||=this.sharedValues=[];for(let[e,i]of d)i.count>t&&(m[e]=n++,p.push(e),r=!0);for(;this.saveShared&&this.updateSharedData()===!1;);d=null});let v=n=>{H>Gt&&(B=b(H));var r=typeof n,i;if(r===`string`){if(f){let t=f[n];if(t>=0){t<16?B[H++]=t+224:(B[H++]=198,t&1?v(15-t>>1):v(t-16>>1));return}else if(d&&!e.pack){let e=d.get(n);e?e.count++:d.set(n,{count:1})}}let r=n.length;if(U&&r>=4&&r<1024){if((U.size+=r)>61440){let e,n=(U[0]?U[0].length*3+U[1].length:0)+10;H+n>Gt&&(B=b(H+n)),B[H++]=217,B[H++]=223,B[H++]=249,B[H++]=U.position?132:130,B[H++]=26,e=H-t,H+=4,U.position&&an(t,v),U=[``,``],U.size=0,U.position=e}let e=Kt.test(n);U[+!e]+=n,B[H++]=e?206:207,v(r);return}let a;a=r<32?1:r<256?2:r<65536?3:5;let s=r*3;if(H+s>Gt&&(B=b(H+s)),r<64||!o){let e,t,o,s=H+a;for(e=0;e<r;e++)t=n.charCodeAt(e),t<128?B[s++]=t:t<2048?(B[s++]=t>>6|192,B[s++]=t&63|128):(t&64512)==55296&&((o=n.charCodeAt(e+1))&64512)==56320?(t=65536+((t&1023)<<10)+(o&1023),e++,B[s++]=t>>18|240,B[s++]=t>>12&63|128,B[s++]=t>>6&63|128,B[s++]=t&63|128):(B[s++]=t>>12|224,B[s++]=t>>6&63|128,B[s++]=t&63|128);i=s-H-a}else i=o(n,H+a,s);i<24?B[H++]=96|i:i<256?(a<2&&B.copyWithin(H+2,H+1,H+1+i),B[H++]=120,B[H++]=i):i<65536?(a<3&&B.copyWithin(H+3,H+2,H+2+i),B[H++]=121,B[H++]=i>>8,B[H++]=i&255):(a<5&&B.copyWithin(H+5,H+3,H+3+i),B[H++]=122,V.setUint32(H,i),H+=4),H+=i}else if(r===`number`)if(!this.alwaysUseFloat&&n>>>0===n)n<24?B[H++]=n:n<256?(B[H++]=24,B[H++]=n):n<65536?(B[H++]=25,B[H++]=n>>8,B[H++]=n&255):(B[H++]=26,V.setUint32(H,n),H+=4);else if(!this.alwaysUseFloat&&n>>0===n)n>=-24?B[H++]=31-n:n>=-256?(B[H++]=56,B[H++]=~n):n>=-65536?(B[H++]=57,V.setUint16(H,~n),H+=2):(B[H++]=58,V.setUint32(H,~n),H+=4);else{let e;if((e=this.useFloat32)>0&&n<4294967296&&n>=-2147483648){B[H++]=250,V.setFloat32(H,n);let t;if(e<4||(t=n*Mt[(B[H]&127)<<1|B[H+1]>>7])>>0===t){H+=4;return}else H--}B[H++]=251,V.setFloat64(H,n),H+=8}else if(r===`object`)if(!n)B[H++]=246;else{if(a){let e=a.get(n);if(e){if(B[H++]=216,B[H++]=29,B[H++]=25,!e.references){let t=a.idsToInsert||=[];e.references=[],t.push(e)}e.references.push(H-t),H+=2;return}else a.set(n,{offset:H-t})}let e=n.constructor;if(e===Object)y(n);else if(e===Array){i=n.length,i<24?B[H++]=128|i:Xt(i);for(let e=0;e<i;e++)v(n[e])}else if(e===Map)if((this.mapsAsObjects?this.useTag259ForMaps!==!1:this.useTag259ForMaps)&&(B[H++]=217,B[H++]=1,B[H++]=3),i=n.size,i<24?B[H++]=160|i:i<256?(B[H++]=184,B[H++]=i):i<65536?(B[H++]=185,B[H++]=i>>8,B[H++]=i&255):(B[H++]=186,V.setUint32(H,i),H+=4),s.keyMap)for(let[e,t]of n)v(s.encodeKey(e)),v(t);else for(let[e,t]of n)v(e),v(t);else{for(let e=0,t=Lt.length;e<t;e++){let t=Rt[e];if(n instanceof t){let t=Lt[e],r=t.tag;r??=t.getTag&&t.getTag.call(this,n),r<24?B[H++]=192|r:r<256?(B[H++]=216,B[H++]=r):r<65536?(B[H++]=217,B[H++]=r>>8,B[H++]=r&255):r>-1&&(B[H++]=218,V.setUint32(H,r),H+=4),t.encode.call(this,n,v,b);return}}if(n[Symbol.iterator]){if(Wt){let e=Error(`Iterable should be serialized as iterator`);throw e.iteratorNotHandled=!0,e}B[H++]=159;for(let e of n)v(e);B[H++]=255;return}if(n[Symbol.asyncIterator]||Qt(n)){let e=Error(`Iterable/blob should be serialized as iterator`);throw e.iteratorNotHandled=!0,e}if(this.useToJSON&&n.toJSON){let e=n.toJSON();if(e!==n)return v(e)}y(n)}}else if(r===`boolean`)B[H++]=n?245:244;else if(r===`bigint`){if(n<BigInt(1)<<BigInt(64)&&n>=0)B[H++]=27,V.setBigUint64(H,n);else if(n>-(BigInt(1)<<BigInt(64))&&n<0)B[H++]=59,V.setBigUint64(H,-n-BigInt(1));else if(this.largeBigIntToFloat)B[H++]=251,V.setFloat64(H,Number(n));else{n>=BigInt(0)?B[H++]=194:(B[H++]=195,n=BigInt(-1)-n);let e=[];for(;n;)e.push(Number(n&BigInt(255))),n>>=BigInt(8);nn(new Uint8Array(e.reverse()),b);return}H+=8}else if(r===`undefined`)B[H++]=247;else throw Error(`Unknown type: `+r)},y=this.useRecords===!1?this.variableMapSize?e=>{let t=Object.keys(e),n=Object.values(e),r=t.length;if(r<24?B[H++]=160|r:r<256?(B[H++]=184,B[H++]=r):r<65536?(B[H++]=185,B[H++]=r>>8,B[H++]=r&255):(B[H++]=186,V.setUint32(H,r),H+=4),s.keyMap)for(let e=0;e<r;e++)v(s.encodeKey(t[e])),v(n[e]);else for(let e=0;e<r;e++)v(t[e]),v(n[e])}:e=>{B[H++]=185;let n=H-t;H+=2;let r=0;if(s.keyMap)for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(v(s.encodeKey(t)),v(e[t]),r++);else for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(v(t),v(e[t]),r++);B[n+++t]=r>>8,B[n+t]=r&255}:(e,t)=>{let n,a=i.transitions||=Object.create(null),o=0,s=0,c,u;if(this.keyMap){u=Object.keys(e).map(e=>this.encodeKey(e)),s=u.length;for(let e=0;e<s;e++){let t=u[e];n=a[t],n||(n=a[t]=Object.create(null),o++),a=n}}else for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(n=a[t],n||(a[W]&1048576&&(c=a[W]&65535),n=a[t]=Object.create(null),o++),a=n,s++);let d=a[W];if(d!==void 0)d&=65535,B[H++]=217,B[H++]=d>>8|224,B[H++]=d&255;else if(u||=a.__keys__||=Object.keys(e),c===void 0?(d=i.nextId++,d||(d=0,i.nextId=1),d>=256&&(i.nextId=(d=l)+1)):d=c,i[d]=u,d<l){B[H++]=217,B[H++]=d>>8|224,B[H++]=d&255,a=i.transitions;for(let e=0;e<s;e++)(a[W]===void 0||a[W]&1048576)&&(a[W]=d),a=a[u[e]];a[W]=d|1048576,r=!0}else{if(a[W]=d,V.setUint32(H,3655335680),H+=3,o&&(g+=_*o),h.length>=256-l&&(h.shift()[W]=void 0),h.push(a),Xt(s+2),v(57344+d),v(u),t)return;for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&v(e[t]);return}if(s<24?B[H++]=128|s:Xt(s),!t)for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&v(e[t])},b=e=>{let n;if(e>16777216){if(e-t>Ut)throw Error(`Encoded buffer would be larger than maximum buffer size`);n=Math.min(Ut,Math.round(Math.max((e-t)*(e>67108864?1.25:2),4194304)/4096)*4096)}else n=(Math.max(e-t<<2,B.length-1)>>12)+1<<12;let r=new Vt(n);return V=new DataView(r.buffer,0,n),B.copy?B.copy(r,0,t,e):r.set(B.slice(t,e)),H-=t,t=0,Gt=r.length-10,B=r},x=100,S=1e3;this.encodeAsIterable=function(e,t){return ee(e,t,C)},this.encodeAsAsyncIterable=function(e,t){return ee(e,t,E)};function*C(e,n,r){let i=e.constructor;if(i===Object){let t=s.useRecords!==!1;t?y(e,!0):Jt(Object.keys(e).length,160);for(let r in e){let i=e[r];t||v(r),i&&typeof i==`object`?n[r]?yield*C(i,n[r]):yield*w(i,n,r):v(i)}}else if(i===Array){let r=e.length;Xt(r);for(let i=0;i<r;i++){let r=e[i];r&&(typeof r==`object`||H-t>x)?n.element?yield*C(r,n.element):yield*w(r,n,`element`):v(r)}}else if(e[Symbol.iterator]&&!e.buffer){B[H++]=159;for(let r of e)r&&(typeof r==`object`||H-t>x)?n.element?yield*C(r,n.element):yield*w(r,n,`element`):v(r);B[H++]=255}else Qt(e)?(Jt(e.size,64),yield B.subarray(t,H),yield e,T()):e[Symbol.asyncIterator]?(B[H++]=159,yield B.subarray(t,H),yield e,T(),B[H++]=255):v(e);r&&H>t?yield B.subarray(t,H):H-t>x&&(yield B.subarray(t,H),T())}function*w(e,n,r){let i=H-t;try{v(e),H-t>x&&(yield B.subarray(t,H),T())}catch(a){if(a.iteratorNotHandled)n[r]={},H=t+i,yield*C.call(this,e,n[r]);else throw a}}function T(){x=S,s.encode(null,fn)}function ee(e,t,n){return x=t&&t.chunkThreshold?S=t.chunkThreshold:100,e&&typeof e==`object`?(s.encode(null,fn),n(e,s.iterateProperties||={},!0)):[s.encode(e)]}async function*E(e,t){for(let n of C(e,t,!0)){let e=n.constructor;if(e===Ht||e===Uint8Array)yield n;else if(Qt(n)){let e=n.stream().getReader(),t;for(;!(t=await e.read()).done;)yield t.value}else if(n[Symbol.asyncIterator])for await(let e of n)T(),e?yield*E(e,t.async||={}):yield s.encode(e);else yield n}}}useBuffer(e){B=e,V=new DataView(B.buffer,B.byteOffset,B.byteLength),H=0}clearSharedData(){this.structures&&=[],this.sharedValues&&=void 0}updateSharedData(){let e=this.sharedVersion||0;this.sharedVersion=e+1;let t=this.structures.slice(0),n=new Yt(t,this.sharedValues,this.sharedVersion),r=this.saveShared(n,t=>(t&&t.version||0)==e);return r===!1?(n=this.getShared()||{},this.structures=n.structures||[],this.sharedValues=n.packedValues,this.sharedVersion=n.version,this.structures.nextId=this.structures.length):t.forEach((e,t)=>this.structures[t]=e),r}};function Jt(e,t){e<24?B[H++]=t|e:e<256?(B[H++]=t|24,B[H++]=e):e<65536?(B[H++]=t|25,B[H++]=e>>8,B[H++]=e&255):(B[H++]=t|26,V.setUint32(H,e),H+=4)}var Yt=class{constructor(e,t,n){this.structures=e,this.packedValues=t,this.version=n}};function Xt(e){e<24?B[H++]=128|e:e<256?(B[H++]=152,B[H++]=e):e<65536?(B[H++]=153,B[H++]=e>>8,B[H++]=e&255):(B[H++]=154,V.setUint32(H,e),H+=4)}const Zt=typeof Blob>`u`?function(){}:Blob;function Qt(e){if(e instanceof Zt)return!0;let t=e[Symbol.toStringTag];return t===`Blob`||t===`File`}function $t(e,t){switch(typeof e){case`string`:if(e.length>3){if(t.objectMap[e]>-1||t.values.length>=t.maxValues)return;let n=t.get(e);if(n)++n.count==2&&t.values.push(e);else if(t.set(e,{count:1}),t.samplingPackedValues){let n=t.samplingPackedValues.get(e);n?n.count++:t.samplingPackedValues.set(e,{count:1})}}break;case`object`:if(e)if(e instanceof Array)for(let n=0,r=e.length;n<r;n++)$t(e[n],t);else{let r=!t.encoder.useRecords;for(var n in e)e.hasOwnProperty(n)&&(r&&$t(n,t),$t(e[n],t))}break;case`function`:console.log(e)}}const en=new Uint8Array(new Uint16Array([1]).buffer)[0]==1;Rt=[Date,Set,Error,RegExp,_t,ArrayBuffer,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,typeof BigUint64Array>`u`?function(){}:BigUint64Array,Int8Array,Int16Array,Int32Array,typeof BigInt64Array>`u`?function(){}:BigInt64Array,Float32Array,Float64Array,Yt],Lt=[{tag:1,encode(e,t){let n=e.getTime()/1e3;(this.useTimestamp32||e.getMilliseconds()===0)&&n>=0&&n<4294967296?(B[H++]=26,V.setUint32(H,n),H+=4):(B[H++]=251,V.setFloat64(H,n),H+=8)}},{tag:258,encode(e,t){t(Array.from(e))}},{tag:27,encode(e,t){t([e.name,e.message])}},{tag:27,encode(e,t){t([`RegExp`,e.source,e.flags])}},{getTag(e){return e.tag},encode(e,t){t(e.value)}},{encode(e,t,n){nn(e,n)}},{getTag(e){if(e.constructor===Uint8Array&&(this.tagUint8Array||Bt&&this.tagUint8Array!==!1))return 64},encode(e,t,n){nn(e,n)}},tn(68,1),tn(69,2),tn(70,4),tn(71,8),tn(72,1),tn(77,2),tn(78,4),tn(79,8),tn(85,4),tn(86,8),{encode(e,t){let n=e.packedValues||[],r=e.structures||[];if(n.values.length>0){B[H++]=216,B[H++]=51,Xt(4);let e=n.values;t(e),Xt(0),Xt(0),packedObjectMap=Object.create(sharedPackedObjectMap||null);for(let t=0,n=e.length;t<n;t++)packedObjectMap[e[t]]=t}if(r){V.setUint32(H,3655335424),H+=3;let n=r.slice(0);n.unshift(57344),n.push(new _t(e.version,1399353956)),t(n)}else t(new _t(e.version,1399353956))}}];function tn(e,t){return!en&&t>1&&(e-=4),{tag:e,encode:function(e,t){let n=e.byteLength,r=e.byteOffset||0,i=e.buffer||e;t(Bt?zt.from(i,r,n):new Uint8Array(i,r,n))}}}function nn(e,t){let n=e.byteLength;n<24?B[H++]=64+n:n<256?(B[H++]=88,B[H++]=n):n<65536?(B[H++]=89,B[H++]=n>>8,B[H++]=n&255):(B[H++]=90,V.setUint32(H,n),H+=4),H+n>=B.length&&t(H+n),B.set(e.buffer?e:new Uint8Array(e),H),H+=n}function rn(e,t){let n,r=t.length*2,i=e.length-r;t.sort((e,t)=>e.offset>t.offset?1:-1);for(let n=0;n<t.length;n++){let r=t[n];r.id=n;for(let t of r.references)e[t++]=n>>8,e[t]=n&255}for(;n=t.pop();){let t=n.offset;e.copyWithin(t+r,t,i),r-=2;let a=t+r;e[a++]=216,e[a++]=28,i=t}return e}function an(e,t){V.setUint32(U.position+e,H-U.position-e+1);let n=U;U=null,t(n[0]),t(n[1])}let on=new qt({useRecords:!1});const sn=on.encode;on.encodeAsIterable,on.encodeAsAsyncIterable;const{NEVER:cn,ALWAYS:ln,DECIMAL_ROUND:un,DECIMAL_FIT:dn}=Ft,fn=2048;var pn=n(((e,t)=>{let n=()=>process.platform===`linux`,r=null;t.exports={isLinux:n,getReport:()=>{if(!r)if(n()&&process.report){let e=process.report.excludeNetwork;process.report.excludeNetwork=!0,r=process.report.getReport(),process.report.excludeNetwork=e}else r={};return r}}})),mn=n(((e,n)=>{let r=t(`fs`),i=2048;n.exports={LDD_PATH:`/usr/bin/ldd`,SELF_PATH:`/proc/self/exe`,readFileSync:e=>{let t=r.openSync(e,`r`),n=Buffer.alloc(i),a=r.readSync(t,n,0,i,0);return r.close(t,()=>{}),n.subarray(0,a)},readFile:e=>new Promise((t,n)=>{r.open(e,`r`,(e,a)=>{if(e)n(e);else{let e=Buffer.alloc(i);r.read(a,e,0,i,0,(n,i)=>{t(e.subarray(0,i)),r.close(a,()=>{})})}})})}})),hn=n(((e,t)=>{t.exports={interpreterPath:e=>{if(e.length<64||e.readUInt32BE(0)!==2135247942||e.readUInt8(4)!==2||e.readUInt8(5)!==1)return null;let t=e.readUInt32LE(32),n=e.readUInt16LE(54),r=e.readUInt16LE(56);for(let i=0;i<r;i++){let r=t+i*n;if(e.readUInt32LE(r)===3){let t=e.readUInt32LE(r+8),n=e.readUInt32LE(r+32);return e.subarray(t,t+n).toString().replace(/\0.*$/g,``)}}return null}}})),gn=n(((e,n)=>{let r=t(`child_process`),{isLinux:i,getReport:a}=pn(),{LDD_PATH:o,SELF_PATH:s,readFile:c,readFileSync:l}=mn(),{interpreterPath:u}=hn(),d,f,p,m=`getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true`,h=``,g=()=>h||new Promise(e=>{r.exec(m,(t,n)=>{h=t?` `:n,e(h)})}),_=()=>{if(!h)try{h=r.execSync(m,{encoding:`utf8`})}catch{h=` `}return h},v=`glibc`,y=/LIBC[a-z0-9 \-).]*?(\d+\.\d+)/i,b=`musl`,x=e=>e.includes(`libc.musl-`)||e.includes(`ld-musl-`),S=()=>{let e=a();return e.header&&e.header.glibcVersionRuntime?v:Array.isArray(e.sharedObjects)&&e.sharedObjects.some(x)?b:null},C=e=>{let[t,n]=e.split(/[\r\n]+/);return t&&t.includes(v)?v:n&&n.includes(b)?b:null},w=e=>{if(e){if(e.includes(`/ld-musl-`))return b;if(e.includes(`/ld-linux-`))return v}return null},T=e=>(e=e.toString(),e.includes(`musl`)?b:e.includes(`GNU C Library`)?v:null),ee=async()=>{if(f!==void 0)return f;f=null;try{f=T(await c(o))}catch{}return f},E=()=>{if(f!==void 0)return f;f=null;try{f=T(l(o))}catch{}return f},te=async()=>{if(d!==void 0)return d;d=null;try{d=w(u(await c(s)))}catch{}return d},ne=()=>{if(d!==void 0)return d;d=null;try{d=w(u(l(s)))}catch{}return d},re=async()=>{let e=null;return i()&&(e=await te(),e||(e=await ee(),e||=S(),e||=C(await g()))),e},ie=()=>{let e=null;return i()&&(e=ne(),e||(e=E(),e||=S(),e||=C(_()))),e},D=async()=>i()&&await re()!==v,ae=()=>i()&&ie()!==v,oe=async()=>{if(p!==void 0)return p;p=null;try{let e=(await c(o)).match(y);e&&(p=e[1])}catch{}return p},se=()=>{if(p!==void 0)return p;p=null;try{let e=l(o).match(y);e&&(p=e[1])}catch{}return p},ce=()=>{let e=a();return e.header&&e.header.glibcVersionRuntime?e.header.glibcVersionRuntime:null},le=e=>e.trim().split(/\s+/)[1],ue=e=>{let[t,n,r]=e.split(/[\r\n]+/);return t&&t.includes(v)?le(t):n&&r&&n.includes(b)?le(r):null};n.exports={GLIBC:v,MUSL:b,family:re,familySync:ie,isNonGlibcLinux:D,isNonGlibcLinuxSync:ae,version:async()=>{let e=null;return i()&&(e=await oe(),e||=ce(),e||=ue(await g())),e},versionSync:()=>{let e=null;return i()&&(e=se(),e||=ce(),e||=ue(_())),e}}})),_n=n(((e,n)=>{var r=t(`fs`),i=t(`path`),a=t(`url`),o=process.config&&process.config.variables||{},s=!!process.env.PREBUILDS_ONLY,c=process.versions,l=c.modules;(c.deno||process.isBun)&&(l=`unsupported`);var u=E()?`electron`:`node`,d=process.arch,f=process.platform,p=process.env.LIBC||(te(f)?`musl`:`glibc`),m=process.env.ARM_VERSION||(d===`arm64`?`8`:o.arm_version)||``,h=(c.uv||``).split(`.`)[0];n.exports=g;function g(e){return typeof __webpack_require__==`function`?__non_webpack_require__(g.path(e)):t(g.path(e))}g.path=function(e){e=i.resolve(e||`.`);var n=``;try{n=typeof __webpack_require__==`function`?__non_webpack_require__(i.join(e,`package.json`)).name:t(i.join(e,`package.json`)).name;var r=n.toUpperCase().replace(/-/g,`_`)+`_PREBUILD`;process.env[r]&&(e=process.env[r])}catch{}if(!s){var o=v(i.join(e,`build/Release`),y);if(o)return o;var c=v(i.join(e,`build/Debug`),y);if(c)return c}var g=ne(e);if(g)return g;var T=ne(i.dirname(process.execPath));if(T)return T;var E=(n[0]==`@`?``:`@`+n+`/`)+n+`-`+f+`-`+d;try{return re(i.dirname(t(`module`).createRequire(a.pathToFileURL(i.join(e,`package.json`))).resolve(E)))}catch{}var te=[`platform=`+f,`arch=`+d,`runtime=`+u,`abi=`+l,`uv=`+h,m?`armv=`+m:``,`libc=`+p,`node=`+process.versions.node,process.versions.electron?`electron=`+process.versions.electron:``,typeof __webpack_require__==`function`?`webpack=true`:``].filter(Boolean).join(` `);throw Error(`No native build was found for `+te+`
|
|
3
|
+
attempted loading from: `+e+` and package: `+E+`
|
|
4
|
+
`);function ne(e){var t=_(i.join(e,`prebuilds`)).map(b).filter(x(f,d)).sort(S)[0];if(t)return re(i.join(e,`prebuilds`,t.name))}function re(e){var t=_(e).map(C).filter(w(u,l)).sort(ee(u))[0];if(t)return i.join(e,t.file)}};function _(e){try{return r.readdirSync(e)}catch{return[]}}function v(e,t){var n=_(e).filter(t);return n[0]&&i.join(e,n[0])}function y(e){return/\.node$/.test(e)}function b(e){var t=e.split(`-`);if(t.length===2){var n=t[0],r=t[1].split(`+`);if(n&&r.length&&r.every(Boolean))return{name:e,platform:n,architectures:r}}}function x(e,t){return function(n){return n==null||n.platform!==e?!1:n.architectures.includes(t)}}function S(e,t){return e.architectures.length-t.architectures.length}function C(e){var t=e.split(`.`),n=t.pop(),r={file:e,specificity:0};if(n===`node`){for(var i=0;i<t.length;i++){var a=t[i];if(a===`node`||a===`electron`||a===`node-webkit`)r.runtime=a;else if(a===`napi`)r.napi=!0;else if(a.slice(0,3)===`abi`)r.abi=a.slice(3);else if(a.slice(0,2)===`uv`)r.uv=a.slice(2);else if(a.slice(0,4)===`armv`)r.armv=a.slice(4);else if(a===`glibc`||a===`musl`)r.libc=a;else continue;r.specificity++}return r}}function w(e,t){return function(n){return!(n==null||n.runtime!==e&&!T(n)||n.abi!==t&&!n.napi||n.uv&&n.uv!==h||n.armv&&n.armv!==m||n.libc&&n.libc!==p)}}function T(e){return e.runtime===`node`&&e.napi}function ee(e){return function(t,n){return t.runtime===n.runtime?t.abi===n.abi?t.specificity===n.specificity?0:t.specificity>n.specificity?-1:1:t.abi?-1:1:t.runtime===e?-1:1}}function E(){return process.versions&&process.versions.electron||process.env.ELECTRON_RUN_AS_NODE?!0:typeof window<`u`&&window.process&&window.process.type===`renderer`}function te(e){if(e!==`linux`)return!1;let{familySync:t,MUSL:n}=gn();return t()===n}g.parseTags=C,g.matchTags=w,g.compareTags=ee,g.parseTuple=b,g.matchTuple=x,g.compareTuples=S})),vn=n(((e,t)=>{t.exports=_n()(__dirname)}));if(!(process.env.CBOR_NATIVE_ACCELERATION_DISABLED!==void 0&&process.env.CBOR_NATIVE_ACCELERATION_DISABLED.toLowerCase()===`true`)){let e;try{e=typeof t==`function`?vn():Ae(import.meta.url)(`cbor-extract`),e&<(e.extractStrings)}catch{}}var yn=Ce();let bn,xn,Sn;const Cn={connections:8,keepAliveTimeout:1e4,pipelining:1},wn={...Cn,allowH2:!1},Tn={...Cn,allowH2:!0},En={retryAfter:!0,statusCodes:[500,502,503,504]},Dn={retryAfter:!0,methods:[`PUT`],statusCodes:[429]};function On(e){return e?.dispatcher??Mn()}function kn(e){return e?.dispatcher??Nn()}function An(e){return e?.dispatcher??Pn()}function jn(e,t){return new yn.RetryAgent(new yn.Agent(e),t)}function Mn(){return bn??=jn(wn,En),bn}function Nn(){return xn??=jn(Tn,En),xn}function Pn(){return Sn??=jn(Tn,Dn),Sn}let Fn=null;async function In(){return Fn||=import(`../../_chunks/workflow/src-CQuMexnO.js`).then(t=>e(t.t(),1)).catch(e=>(typeof process<`u`&&typeof process.env.DEBUG==`string`&&(process.env.DEBUG.includes(`workflow:`)||process.env.DEBUG===`*`)&&console.warn(`[workflow] @opentelemetry/api unavailable — world-vercel spans disabled:`,e instanceof Error?e.message:e),null)),Fn}let Ln=null;function Rn(){return typeof process<`u`&&typeof process.env.DEBUG==`string`&&(process.env.DEBUG.includes(`workflow:`)||process.env.DEBUG===`*`)}let zn=!1;function Bn(e,t){if(!(zn||!Rn())){zn=!0;try{let n=globalThis[Symbol.for(`opentelemetry.js.api.1`)],r=e.trace.getTracerProvider(),i=r.getDelegate?.()??r,a=t.startSpan(`workflow.otel.probe.world_vercel`);console.warn(`[workflow:otel-diag] world-vercel`,JSON.stringify({globalRegistrationVersion:n?.version??null,providerCtor:r?.constructor?.name??null,delegateCtor:i?.constructor?.name??null,tracerCtor:t?.constructor?.name??null,probeCtor:a?.constructor?.name??null,probeRecording:a.isRecording()})),a.end()}catch(e){console.warn(`[workflow:otel-diag] world-vercel failed:`,e instanceof Error?e.message:e)}}}async function Vn(){return Ln||=In().then(e=>{if(!e)return null;let t=e.trace.getTracer(`workflow`);return Bn(e,t),t}),Ln}async function Hn(e,...t){let[n,r]=await Promise.all([Vn(),In()]),{fn:i,opts:a}=typeof t[0]==`function`?{fn:t[0],opts:{}}:{fn:t[1],opts:t[0]};if(!i)throw Error(`Function to trace must be provided`);return!n||!r?await i():n.startActiveSpan(e,a,async e=>{try{let t=await i(e);return e.setStatus({code:r.SpanStatusCode.OK}),t}catch(t){throw e.setStatus({code:r.SpanStatusCode.ERROR,message:t.message}),t}finally{e.end()}})}async function Un(e){let t=await In();if(t)return t.SpanKind[e]}async function Wn(e){let t=await In();if(!t)return;let n={};t.propagation.inject(t.context.active(),n);for(let[t,r]of Object.entries(n))e.set(t,r)}function G(...e){return t=>Object.fromEntries(e.map(e=>[e,t]))}const Gn=G(`http.request.method`),Kn=G(`url.full`),qn=G(`server.address`),Jn=G(`server.port`),Yn=G(`http.response.status_code`),Xn=G(`error.type`),Zn=G(`workflow.world.parse.format`),Qn=G(`peer.service`),$n=G(`rpc.system`),er=G(`rpc.service`),tr=G(`rpc.method`),nr=G(`workflow.run.id`),rr=G(`step.id`),ir=G(`workflow.stream.name`),ar=G(`workflow.stream.operation`),or=G(`workflow.stream.start_index`),sr=()=>te(`WORKFLOW_REQUEST_TIMEOUT_MS`,6e4,{integer:!0,min:1}),cr=typeof process<`u`&&typeof process.env.DEBUG==`string`&&(process.env.DEBUG.includes(`workflow:`)||process.env.DEBUG===`*`),lr=[`x-vercel-id`,`x-vercel-error`,`x-vercel-mitigated`];function ur(e){return lr.flatMap(t=>{let n=e.get(t);return n?[`${t}=${n}`]:[]})}function dr(e){let t=ur(e);return t.length>0?` (${t.join(`; `)})`:``}function fr(e,t,n,r){if(!cr)return;let i=ur(n.headers),a=i.length>0?`; ${i.join(`; `)}`:``;console.debug(`[workflow:world-vercel:http] ${e} ${t} -> ${n.status} (${r}ms${a})`)}function pr(e,t,n){if(!process.env.DEBUG)return;let r=Array.from(n.entries()).filter(([e])=>e.toLowerCase()!==`authorization`).map(([e,t])=>`-H "${e}: ${t}"`).join(` `);console.error(`Failed to fetch, reproduce with:\ncurl -X ${e} ${r} "${t}"`)}function mr(e){if(!e)return;let t=parseInt(e,10);return Number.isNaN(t)?void 0:t}function hr(e,t,n={}){let{retryAfter:o,code:u,url:d,mitigated:f}=n;return e===409?new s(t):e===410?new l(t):e===412?new c(t,{retryAfter:o}):e===425?new i(t,{retryAfter:o}):e===429?gr(e,f)?new r(`${t} (x-vercel-mitigated=challenge)`,{url:d,status:e,code:`TRANSPORT`,retryAfter:o}):new a(t,{retryAfter:o}):new r(t,{url:d,status:e,code:u,retryAfter:o})}function gr(e,t){return e===429&&t===`challenge`}async function _r(e){return e?.token??process.env.VERCEL_TOKEN??await(0,Be.getVercelOidcToken)().catch(()=>null)}function vr(e){try{let t=new URL(e);return{serverAddress:t.hostname,serverPort:t.port?parseInt(t.port,10):t.protocol===`https:`?443:80}}catch{return{}}}function yr(e){let{method:t,url:n,peerService:r}=e,{serverAddress:i,serverPort:a}=vr(n);return{...Gn(t),...Kn(n),...i?qn(i):{},...a?Jn(a):{},...Qn(r),...$n(`http`),...er(r)}}async function br(e){let{method:t,url:n,headers:i,body:a,dispatcher:o,peerService:s=`workflow-server`,timeoutMs:c=sr(),signal:l,injectTraceContext:u=!0,cacheBust:d=!0,logLabel:f,buildError:p,spanName:m,attributes:h,durationAttribute:g}=e,_=f??n;return Hn(m??`http ${t}`,{kind:await Un(`CLIENT`)},async e=>{if(m&&cr&&e){let t=e.spanContext();console.warn(`[workflow:otel-diag] span-open`,JSON.stringify({spanName:m,traceId:t.traceId,spanId:t.spanId,recording:e.isRecording()}))}e?.setAttributes(yr({method:t,url:n,peerService:s})),h&&e?.setAttributes(h),u&&await Wn(i),d&&i.set(`X-Request-Time`,Date.now().toString());let f=c==null?void 0:AbortSignal.timeout(c),v=l&&f?AbortSignal.any([l,f]):l??f,y=Date.now(),b;try{b=await fetch(n,{method:t,headers:i,body:a,signal:v,dispatcher:o})}catch(i){let a=Date.now()-y;if(i instanceof Error&&(i.name===`TimeoutError`||i.name===`AbortError`)){let o=new r(`${t} ${_} timed out after ${a}ms`,{url:n,cause:i});throw e?.setAttributes({...Xn(`TIMEOUT`)}),e?.recordException?.(o),o}throw i}let x=Date.now()-y;if(fr(t,_,b,x),e?.setAttributes({...Yn(b.status)}),g&&e?.setAttributes({[g]:x}),!b.ok){if(e?.setAttributes({...Xn(`HTTP ${b.status}`)}),pr(t,n,i),p){let t=await p(b);throw e?.recordException?.(t),t}let r=await b.text().catch(()=>``),a=hr(b.status,`${t} ${_} -> HTTP ${b.status}: ${b.statusText}${r?` ${r}`:``}${dr(b.headers)}`,{url:n,retryAfter:mr(b.headers.get(`Retry-After`))});throw e?.recordException?.(a),a}return b})}const xr=`5.0.0-beta.31`,Sr=new Set([`GET`,`HEAD`]),Cr=new Set([`UND_ERR_REQ_RETRY`,`UND_ERR_SOCKET`,`UND_ERR_CONNECT`,`UND_ERR_CONNECT_TIMEOUT`,`UND_ERR_HEADERS_TIMEOUT`,`UND_ERR_BODY_TIMEOUT`,`UND_ERR_CLOSED`,`ECONNRESET`,`ECONNREFUSED`,`ENOTFOUND`,`EAI_AGAIN`,`EPIPE`]);function wr(e){let t=e;for(let e=0;t!=null&&e<5;e++){if(typeof t==`object`&&`code`in t){let e=t.code;if(typeof e==`string`&&Cr.has(e))return e}t=t?.cause}}const Tr=()=>process.env.VERCEL_WORKFLOW_SERVER_URL||``,Er=()=>process.env.WORKFLOW_TEST_LIMIT_OVERRIDES?.trim()||``;function Dr(e){return e}const Or=()=>{let e=process.env.VERCEL_DEPLOYMENT_ID;return e?`@workflow/world-vercel/${xr} node-${process.version} ${De.platform()} (${De.arch()}) ${e}`:`@workflow/world-vercel/${xr} node-${process.version} ${De.platform()} (${De.arch()})`},kr=e=>{let t=e?.projectConfig,n=Tr()||`https://vercel-workflow.com`,r=process.env.WORKFLOW_VERCEL_BACKEND_URL,i=!!(t?.projectId&&t?.teamId);return{baseUrl:i?r||`https://api.vercel.com/v1/workflow`:`${n}/api`,usingProxy:i}},Ar=(e,t)=>{let n=e?.projectConfig,r=new Headers(e?.headers);r.set(`User-Agent`,Or());let i=Er();i&&r.set(`x-workflow-test-limit-overrides`,i),n&&(r.set(`x-vercel-environment`,n.environment||`production`),n.projectId&&r.set(`x-vercel-project-id`,n.projectId),n.teamId&&r.set(`x-vercel-team-id`,n.teamId));let a=Tr();return a&&t.usingProxy&&r.set(`x-vercel-workflow-api-url`,a),r};async function jr(e){let{baseUrl:t,usingProxy:n}=kr(e),r=Ar(e,{usingProxy:n});if(n){if(!e?.token)throw Error(`world-vercel: api-workflow proxy requested (${t}) but no Vercel auth token was provided. Pass one as \`config.token\` (the SDK reads it from \`WORKFLOW_VERCEL_AUTH_TOKEN\`).`);r.set(`Authorization`,`Bearer ${e.token}`)}else{let t;try{t=await(0,Be.getVercelOidcToken)()}catch{}let n=e?.token??t;n&&r.set(`Authorization`,`Bearer ${n}`),t&&r.set(`x-vercel-trusted-oidc-idp-token`,t)}return{baseUrl:t,headers:r,usingProxy:n}}async function K({endpoint:e,options:t={},config:n={},schema:i,data:a,onResponse:o}){let s=t.method||`GET`,{baseUrl:c,headers:l}=await jr(n),u=`${c}${e}`;return Hn(`http ${s}`,{kind:await Un(`CLIENT`)},async c=>{c?.setAttributes(yr({method:s,url:u,peerService:`workflow-server`})),l.set(`Accept`,`application/cbor`),await Wn(l);let d;a!==void 0&&(l.set(`Content-Type`,`application/cbor`),d=sn(a));let f=Sr.has(s.toUpperCase()),p,m=``;for(let i=0;;i++){l.set(`X-Request-Time`,Date.now().toString());let a=AbortSignal.timeout(sr()),h=t.signal?AbortSignal.any([t.signal,a]):a,g=new Request(u,{...t,body:d,headers:l,signal:h}),_=Date.now(),v;try{v=await fetch(g,{dispatcher:On(n)})}catch(t){let n=Date.now()-_;if(t instanceof Error&&(t.name===`TimeoutError`||t.name===`AbortError`)){let i=new r(`${s} ${e} timed out after ${n}ms`,{url:u,code:`TIMEOUT`,cause:t});throw c?.setAttributes({...Xn(`TIMEOUT`)}),c?.recordException?.(i),i}let i=wr(t);if(i){let a=new r(`${s} ${e} transport failure after ${n}ms (${i})`,{url:u,code:`TRANSPORT`,cause:t});throw c?.setAttributes({...Xn(`TRANSPORT`)}),c?.recordException?.(a),a}throw t}let y=Date.now()-_;if(m=dr(v.headers),fr(s,e,v,y),c?.setAttributes({...Yn(v.status)}),!v.ok){let t=await Nr(v).then(e=>e.data).catch(()=>({})),n=t.code??t.error;pr(g.method,u,l);let r=mr(v.headers.get(`Retry-After`)),i=(t.message||`${g.method} ${e} -> HTTP ${v.status}: ${v.statusText}`)+m,a=hr(v.status,i,{url:u,code:n,retryAfter:r,mitigated:v.headers.get(`x-vercel-mitigated`)});throw c?.setAttributes({...Xn(n||`HTTP ${v.status}`)}),c?.recordException?.(a),a}o?.(v);try{p=await Hn(`world.parse`,async e=>{let t=await Nr(v),n=(v.headers.get(`Content-Type`)||``).includes(`application/cbor`);return e?.setAttributes({...Zn(n?`cbor`:`json`)}),t});break}catch(t){if(f&&i<2){let n=100*2**i;c?.setAttributes({...Xn(`PARSE_ERROR_RETRYING`)}),cr&&console.debug(`[workflow:world-vercel:http] ${s} ${e} body parse failed (attempt ${i+1}/3); retrying in ${n}ms: ${t}`),await new Promise(e=>setTimeout(e,n));continue}let n=v.headers.get(`Content-Type`)||`unknown`;throw new r(`Failed to parse response body for ${s} ${e}${m} (Content-Type: ${n}):\n\n${t}`,{url:u,code:`PARSE_ERROR`,cause:t})}}return await Hn(`world.validate`,async()=>{let t=i.safeParse(p.data);if(!t.success){let n=t.error.issues.map(e=>` ${e.path.length>0?e.path.join(`.`):`<root>`}: ${e.message}`).join(`
|
|
5
|
+
`),i=process.env.DEBUG?`\n\nResponse context: ${p.getDebugContext()}`:``;throw new r(`Schema validation failed for ${s} ${e}${m}:\n${n}${i}`,{url:u,code:`SCHEMA_VALIDATION`,cause:t.error})}return t.data})})}function Mr(e){let t=Te(e,{depth:3,maxArrayLength:10,breakLength:120});return t.length>500?`${t.slice(0,500)}...`:t}async function Nr(e){let t=e.headers.get(`Content-Type`)||``;if(t.includes(`application/cbor`)){let n=await e.arrayBuffer(),r=Pt(new Uint8Array(n));return{data:r,getDebugContext:()=>`Content-Type: ${t}, ${n.byteLength} bytes (CBOR), preview: ${Mr(r)}`}}let n=await e.text(),r=JSON.parse(n);return{data:r,getDebugContext:()=>`Content-Type: ${t}, ${n.length} bytes, preview: ${Mr(r)}`}}function Pr(e,t){t?.limit&&e.set(`limit`,t.limit.toString()),t?.cursor&&e.set(`cursor`,t.cursor),t?.sortOrder&&e.set(`sortOrder`,t.sortOrder)}function Fr(e){let t=e.toString();return t?`?${t}`:``}function Ir(e,t){t.workflowName&&e.set(`workflowName`,t.workflowName),t.startTime&&t.endTime&&(e.set(`startTime`,t.startTime),e.set(`endTime`,t.endTime)),Pr(e,t.pagination)}function Lr(e){return{runs:{get(t){return K({endpoint:`/v2/analytics/runs/${encodeURIComponent(t)}`,config:e,schema:pe})},list(t={}){let n=new URLSearchParams;return t.workflowName&&n.set(`workflowName`,t.workflowName),t.status&&n.set(`status`,t.status),t.startTime&&t.endTime&&(n.set(`startTime`,t.startTime),n.set(`endTime`,t.endTime)),t.attributes&&Object.keys(t.attributes).length>0&&n.set(`attributes`,JSON.stringify(t.attributes)),Pr(n,t.pagination),K({endpoint:`/v2/analytics/runs${Fr(n)}`,config:e,schema:D(pe)})}},attributes:{list(t={}){let n=new URLSearchParams;return Ir(n,t),K({endpoint:`/v2/analytics/attributes${Fr(n)}`,config:e,schema:D(me)})}},steps:{get(t,n){return K({endpoint:`/v2/analytics/runs/${encodeURIComponent(t)}/steps/${encodeURIComponent(n)}`,config:e,schema:C})},list(t){let n=new URLSearchParams;return Pr(n,t.pagination),K({endpoint:`/v2/analytics/runs/${encodeURIComponent(t.runId)}/steps${Fr(n)}`,config:e,schema:D(C)})}},events:{get(t,n){return K({endpoint:`/v2/analytics/runs/${encodeURIComponent(t)}/events/${encodeURIComponent(n)}`,config:e,schema:S})},list(t){let n=new URLSearchParams;return t.eventType&&n.set(`eventType`,t.eventType),t.correlationId&&n.set(`correlationId`,t.correlationId),Pr(n,t.pagination),K({endpoint:`/v2/analytics/runs/${encodeURIComponent(t.runId)}/events${Fr(n)}`,config:e,schema:D(S)})},listByCorrelationId(t){let n=new URLSearchParams;return n.set(`correlationId`,t.correlationId),Pr(n,t.pagination),K({endpoint:`/v2/analytics/events${Fr(n)}`,config:e,schema:D(S)})}},hooks:{get(t,n){let r=new URLSearchParams;return n?.runId&&r.set(`runId`,n.runId),K({endpoint:`/v2/analytics/hooks/${encodeURIComponent(t)}${Fr(r)}`,config:e,schema:p})},list(t){let n=new URLSearchParams;return n.set(`runId`,t.runId),Pr(n,t.pagination),K({endpoint:`/v2/analytics/hooks${Fr(n)}`,config:e,schema:D(p)})}},waits:{get(t,n){return K({endpoint:`/v2/analytics/runs/${encodeURIComponent(t)}/waits/${encodeURIComponent(n)}`,config:e,schema:m})},list(t){let n=new URLSearchParams;return t.status&&n.set(`status`,t.status),Pr(n,t.pagination),K({endpoint:`/v2/analytics/runs/${encodeURIComponent(t.runId)}/waits${Fr(n)}`,config:e,schema:D(m)})}}}}const Rr=se();let zr;function Br(e){let t=xe(e),n=5,r=1;for(;n>=0&&r>0;){let e=t[n]+r;t[n]=e&255,r=e>>8,n--}if(r>0)throw Error(`ULID space exhausted`);return ye(t)}function Vr(e){return typeof e!=`string`||e===``||e===`unknown`?null:Object.hasOwn(_e,e)?e:null}function Hr(e){return Vr(e?.region)??Vr(process.env.VERCEL_REGION)??`iad1`}function Ur(e){let t=_e[Hr(e)],n=ve(Rr(),t);if(zr!==void 0)for(;n<=zr;)n=ve(Br(zr),t);return zr=n,n}function Wr(e){let t=e.startsWith(`wrun_`)?e.slice(5):e;try{let e=Se(t);return e.tagged&&e.region?e.region:be}catch{return null}}function Gr(e){let t=e.runId;return typeof t!=`string`||t.length===0?null:{region:Wr(t)}}async function Kr(e,t,n){if(e.length!==32)throw Error(`Invalid deployment key length: expected 32 bytes for AES-256, got ${e.length} bytes`);if(!t||typeof t!=`string`)throw Error(`projectId must be a non-empty string`);let r=await we.subtle.importKey(`raw`,e,`HKDF`,!1,[`deriveBits`]),i=new TextEncoder().encode(`${t}|${n}`),a=await we.subtle.deriveBits({name:`HKDF`,hash:`SHA-256`,salt:new Uint8Array(32),info:i},r,256);return new Uint8Array(a)}async function qr(e,t,n,r){let i=await _r({token:r?.token});if(!i)throw Error(`Cannot fetch run key: no OIDC token or VERCEL_TOKEN available`);let a=new URLSearchParams({projectId:t,runId:n});r?.teamId&&a.set(`teamId`,r.teamId);let o=await(await br({method:`GET`,url:`https://api.vercel.com/v1/workflow/run-key/${e}?${a}`,headers:new Headers({Authorization:`Bearer ${i}`}),dispatcher:On({dispatcher:r?.dispatcher}),peerService:`vercel-api`,timeoutMs:null,buildError:async t=>{let r;try{r=await t.text()}catch{r=`<unable to read response body>`}return Error(`Failed to fetch run key for ${n} (deployment ${e}): HTTP ${t.status} ${t.statusText}${r?` — ${r}`:``}`)}})).json(),s=de({key:E().nullable()}).safeParse(o);if(!s.success)throw Error(`Invalid response from Vercel API: expected { key: string | null }. Zod error: ${s.error.message}`);if(s.data.key!==null)return Buffer.from(s.data.key,`base64`)}function Jr(e,t,n,r){if(!e)return;let i=process.env.VERCEL===`1`,a;function o(){if(a)return a;let e=process.env.VERCEL_DEPLOYMENT_KEY;if(e)return a=Buffer.from(e,`base64`),a}return async function(a,s){let c=typeof a==`string`?a:a.runId,l=typeof a==`string`?s?.deploymentId:a.deploymentId;if(i&&(!l||l===process.env.VERCEL_DEPLOYMENT_ID)){let t=o();return t?Kr(t,e,c):void 0}if(l)return qr(l,e,c,{token:n,teamId:t,dispatcher:r})}}const Yr={peerService:`workflow-server`,rpcSystem:`http`,rpcService:`workflow-server`},Xr={"world.runs.get":0,"world.runs.experimentalSetAttributes":0,"world.steps.get":0,"world.events.create":0,"world.events.get":0},Zr=new Set([`world.steps.list`,`world.events.list`,`world.hooks.list`]);function Qr(e){if(e.length>=2&&typeof e[1]==`object`&&e[1]!==null){let t=e[1];if(typeof t.eventType==`string`)return t.eventType}}function $r(e,t){return typeof e[t]==`string`?e[t]:void 0}function ei(e){if(typeof e!=`object`||!e)return;let t=e.runId;return typeof t==`string`?t:void 0}function ti(e){if(typeof e!=`object`||!e)return;let t=e;if(typeof t.runId==`string`)return t.runId;for(let e of[`run`,`step`,`hook`,`wait`]){let n=t[e];if(typeof n==`object`&&n){let e=n.runId;if(typeof e==`string`)return e}}}function ni(e,t,n){let r=`${e}.${t}`,i={},a=Xr[r],o=a===void 0?Zr.has(r)?ei(n[0]):void 0:$r(n,a);if(o&&Object.assign(i,nr(o)),r===`world.steps.get`){let e=$r(n,1);e&&Object.assign(i,rr(e))}return i}function ri(e,t){let n={};for(let r of Object.keys(t))if(typeof t[r]!=`function`)n[r]=t[r];else{let i=t[r],a=String(r);n[r]=async(...t)=>{let n=`${e}.${a}`;if(e===`world.events`&&a===`create`){let r=Qr(t);r&&(n=`${e}.${a} ${r}`)}return Hn(n,{kind:await Un(`CLIENT`)},async r=>{r?.setAttributes({...Qn(Yr.peerService),...$n(Yr.rpcSystem),...er(Yr.rpcService),...tr(n),...ni(e,a,t)});let o=await i(...t),s=ti(o);return s&&r?.setAttributes(nr(s)),o})}}return n}var q=class extends Error{constructor(e){super(e),this.name=`MultipartParseError`}};function ii(e){let t=new TextEncoder().encode(e);return(e,n=0)=>Buffer.prototype.indexOf.call(e,t,n)}function ai(e){let t=new TextEncoder().encode(e),n={};for(let e=0;e<t.length;++e){let r=t[e];n[r]===void 0&&(n[r]=[]),n[r].push(e)}return function(e){let r=e.length-1;if(e[r]in n){let i=n[e[r]];for(let n=i.length-1;n>=0;--n)for(let a=i[n],o=r;a>=0&&e[o]===t[a];--a,--o)if(a===0)return o}return-1}}function oi(e){let t=new TextDecoder(`iso-8859-1`).decode(e).trim().split(/\r?\n/),n=[];for(let e of t){let t=e.indexOf(`:`);if(t>0){let r=e.slice(0,t).trim(),i=e.slice(t+1).trim();n.push([r,i])}}return new Headers(n)}function si(e){let t=e.match(/boundary=(?:"([^"]+)"|([^;]+))/i);if(!t)throw new q(`No boundary found in Content-Type header`);return t[1]??t[2]}var ci=class{queue=[];waiters=[];finished=!1;cancelled=!1;error=null;enqueue(e){this.finished||this.cancelled||(this.waiters.length>0?this.waiters.shift().resolve(e):this.queue.push(e))}finish(e){if(!this.finished)for(this.finished=!0,this.error=e||null;this.waiters.length>0;){let t=this.waiters.shift();e?t.reject(e):t.resolve(null)}}cancel(){if(!(this.cancelled||this.finished))for(this.cancelled=!0;this.waiters.length>0;)this.waiters.shift().resolve(null)}async dequeue(){if(this.queue.length>0)return this.queue.shift();if(this.finished||this.cancelled){if(this.error)throw this.error;return null}return new Promise((e,t)=>{this.waiters.push({resolve:e,reject:t})})}get isTerminal(){return this.finished||this.cancelled}};async function*li(e,t){if(!e.body)throw new q(`Response body is null`);let n=e.headers.get(`content-type`);if(!n)throw new q(`Missing Content-Type header`);yield*new ui(si(n),t).parseStream(e.body)}var ui=class{boundary;findOpeningBoundary;openingBoundaryLength;findBoundary;findPartialTailBoundary;boundaryLength;findDoubleNewline;maxHeaderSize;maxBoundaryBuffer;state=0;buffer=null;currentHeaders=new Headers;currentPayloadController=null;constructor(e,t={}){this.boundary=e,this.findOpeningBoundary=ii(`--${e}`),this.openingBoundaryLength=2+e.length,this.findBoundary=ii(`\r
|
|
6
|
+
--${e}`),this.findPartialTailBoundary=ai(`\r
|
|
7
|
+
--${e}`),this.boundaryLength=4+e.length,this.findDoubleNewline=ii(`\r
|
|
8
8
|
\r
|
|
9
|
-
`),this.maxHeaderSize=t.maxHeaderSize??65536,this.maxBoundaryBuffer=t.maxBoundaryBuffer??8192}async*parseStream(e){let t=e.getReader(),n=new
|
|
9
|
+
`),this.maxHeaderSize=t.maxHeaderSize??65536,this.maxBoundaryBuffer=t.maxBoundaryBuffer??8192}async*parseStream(e){let t=e.getReader(),n=new ci,r=this.startProducer(t,n);try{yield*this.consumeMessages(n)}finally{n.cancel(),this.closeCurrentPayload();try{await t.cancel()}catch{}await r}}async startProducer(e,t){try{for(;!t.isTerminal;){let n;try{n=await e.read()}catch(e){if(e instanceof Error&&(e.name===`AbortError`||e.constructor.name===`AbortError`||e.name===`TimeoutError`||e.constructor.name===`TimeoutError`))break;throw e}let{done:r,value:i}=n;if(r){if(this.buffer!==null&&this.buffer.length>0){let e=this.write(new Uint8Array);for(let n of e){if(t.isTerminal)break;t.enqueue(n)}}if(this.state!==4)throw this.state===0?new q(`Invalid multipart stream: missing initial boundary`):new q(`Unexpected end of stream`);break}if(!(i instanceof Uint8Array))throw new q(`Invalid chunk type: expected Uint8Array, got ${typeof i}`);let a=this.write(i);for(let e of a){if(t.isTerminal)break;t.enqueue(e)}}t.isTerminal||t.finish()}catch(e){this.closeCurrentPayload(e),t.isTerminal||t.finish(e)}finally{try{e.releaseLock()}catch{}}}async*consumeMessages(e){for(;;){let t=await e.dequeue();if(t===null)break;yield t}}write(e){let t=[];if(this.state===4)throw new q(`Unexpected data after end of stream`);let n=0,r=e.length;if(this.buffer!==null){let t=this.buffer.length,n=t+r;if(this.state===2){if(n>this.maxHeaderSize)throw new q(`Buffer size limit exceeded: ${n} bytes > ${this.maxHeaderSize} bytes. This may indicate malformed multipart data with oversized headers.`)}else if(t>this.maxBoundaryBuffer)throw new q(`Boundary buffer limit exceeded: ${t} bytes > ${this.maxBoundaryBuffer} bytes. This may indicate malformed multipart data with invalid boundaries.`);let i=new Uint8Array(n);i.set(this.buffer,0),i.set(e,t),e=i,r=e.length,this.buffer=null}if(r===0&&this.state===0)throw new q(`Invalid multipart stream: missing initial boundary`);for(;;){if(this.state===3){if(r-n<this.boundaryLength){let t=e.subarray(n);if(t.length>this.maxBoundaryBuffer)throw new q(`Boundary buffer limit exceeded: ${t.length} > ${this.maxBoundaryBuffer}`);this.buffer=t;break}let t=this.findBoundary(e,n);if(t===-1){let t=this.findPartialTailBoundary(e);if(t===-1)this.writeBody(n===0?e:e.subarray(n));else{this.writeBody(e.subarray(n,t));let r=e.subarray(t);if(r.length>this.maxBoundaryBuffer)throw new q(`Partial boundary too large: ${r.length} > ${this.maxBoundaryBuffer}`);this.buffer=r}break}this.writeBody(e.subarray(n,t)),this.finishMessage(),n=t+this.boundaryLength,this.state=1}if(this.state===1){if(r-n<2){let t=e.subarray(n);if(t.length>this.maxBoundaryBuffer)throw new q(`After-boundary buffer limit exceeded: ${t.length} > ${this.maxBoundaryBuffer}`);this.buffer=t;break}if(e[n]===45&&e[n+1]===45){this.state=4;break}if(e[n]===13&&e[n+1]===10)n+=2;else if(e[n]===10)n+=1;else throw new q(`Invalid character after boundary: expected CRLF or LF, got 0x${e[n].toString(16)}`);this.state=2}if(this.state===2){if(r-n<4){let t=e.subarray(n);if(t.length>this.maxHeaderSize)throw new q(`Header buffer limit exceeded: ${t.length} > ${this.maxHeaderSize}`);this.buffer=t;break}let i=this.findDoubleNewline(e,n),a=4;if(i===-1&&(i=ii(`
|
|
10
10
|
|
|
11
|
-
`)(e,n),a=2),i===-1){let t=e.subarray(n);if(t.length>this.maxHeaderSize)throw new q(`Headers too large: ${t.length} > ${this.maxHeaderSize} bytes`);this.buffer=t;break}let o=e.subarray(n,i);this.currentHeaders=li(o);let s=this.createStreamingMessage();t.push(s),n=i+a,this.state=3;continue}if(this.state===0){if(r<this.openingBoundaryLength){if(e.length>this.maxBoundaryBuffer)throw new q(`Initial chunk too large for boundary detection: ${e.length} > ${this.maxBoundaryBuffer}`);this.buffer=e;break}if(this.findOpeningBoundary(e)!==0)throw new q(`Invalid multipart stream: missing initial boundary`);n=this.openingBoundaryLength,this.state=1}}return t}createStreamingMessage(){let e=new Headers(this.currentHeaders),t=new ReadableStream({start:e=>{this.currentPayloadController=e}});return this.currentHeaders=new Headers,{headers:e,payload:t}}writeBody(e){this.currentPayloadController&&this.currentPayloadController.enqueue(e)}finishMessage(){this.currentPayloadController&&=(this.currentPayloadController.close(),null)}closeCurrentPayload(e){if(this.currentPayloadController){try{e?this.currentPayloadController.error(e):this.currentPayloadController.close()}catch{}this.currentPayloadController=null}}};const mi=(e,t,n)=>{let r=e instanceof RegExp?hi(e,n):e,i=t instanceof RegExp?hi(t,n):t,a=r!==null&&i!=null&&gi(r,i,n);return a&&{start:a[0],end:a[1],pre:n.slice(0,a[0]),body:n.slice(a[0]+r.length,a[1]),post:n.slice(a[1]+i.length)}},hi=(e,t)=>{let n=t.match(e);return n?n[0]:null},gi=(e,t,n)=>{let r,i,a,o,s,c=n.indexOf(e),l=n.indexOf(t,c+1),u=c;if(c>=0&&l>0){if(e===t)return[c,l];for(r=[],a=n.length;u>=0&&!s;){if(u===c)r.push(u),c=n.indexOf(e,u+1);else if(r.length===1){let e=r.pop();e!==void 0&&(s=[e,l])}else i=r.pop(),i!==void 0&&i<a&&(a=i,o=l),l=n.indexOf(t,u+1);u=c<l&&c>=0?c:l}r.length&&o!==void 0&&(s=[a,o])}return s},_i=`\0SLASH`+Math.random()+`\0`,vi=`\0OPEN`+Math.random()+`\0`,yi=`\0CLOSE`+Math.random()+`\0`,bi=`\0COMMA`+Math.random()+`\0`,xi=`\0PERIOD`+Math.random()+`\0`,Si=new RegExp(_i,`g`),Ci=new RegExp(vi,`g`),wi=new RegExp(yi,`g`),Ti=new RegExp(bi,`g`),Ei=new RegExp(xi,`g`),Di=/\\\\/g,Oi=/\\{/g,ki=/\\}/g,Ai=/\\,/g,ji=/\\\./g;function Mi(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function Ni(e){return e.replace(Di,_i).replace(Oi,vi).replace(ki,yi).replace(Ai,bi).replace(ji,xi)}function Pi(e){return e.replace(Si,`\\`).replace(Ci,`{`).replace(wi,`}`).replace(Ti,`,`).replace(Ei,`.`)}function Fi(e){if(!e)return[``];let t=[],n=mi(`{`,`}`,e);if(!n)return e.split(`,`);let{pre:r,body:i,post:a}=n,o=r.split(`,`);o[o.length-1]+=`{`+i+`}`;let s=Fi(a);return a.length&&(o[o.length-1]+=s.shift(),o.push.apply(o,s)),t.push.apply(t,o),t}function Ii(e,t={}){if(!e)return[];let{max:n=1e5}=t;return e.slice(0,2)===`{}`&&(e=`\\{\\}`+e.slice(2)),Vi(Ni(e),n,!0).map(Pi)}function Li(e){return`{`+e+`}`}function Ri(e){return/^-?0\d/.test(e)}function zi(e,t){return e<=t}function Bi(e,t){return e>=t}function Vi(e,t,n){let r=[];for(;;){let i=mi(`{`,`}`,e);if(!i)return[e];let a=i.pre;if(/\$$/.test(i.pre)){let e=i.post.length?Vi(i.post,t,!1):[``];for(let n=0;n<e.length&&n<t;n++){let t=a+`{`+i.body+`}`+e[n];r.push(t)}return r}let o=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),s=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),c=o||s,l=i.body.indexOf(`,`)>=0;if(!c&&!l){if(i.post.match(/,(?!,).*\}/)){e=i.pre+`{`+i.body+yi+i.post,n=!0;continue}return[e]}let u=i.post.length?Vi(i.post,t,!1):[``],d;if(c)d=i.body.split(/\.\./);else if(d=Fi(i.body),d.length===1&&d[0]!==void 0&&(d=Vi(d[0],t,!1).map(Li),d.length===1))return u.map(e=>i.pre+d[0]+e);let f;if(c&&d[0]!==void 0&&d[1]!==void 0){let e=Mi(d[0]),n=Mi(d[1]),r=Math.max(d[0].length,d[1].length),i=d.length===3&&d[2]!==void 0?Math.max(Math.abs(Mi(d[2])),1):1,a=zi;n<e&&(i*=-1,a=Bi);let o=d.some(Ri);f=[];for(let c=e;a(c,n)&&f.length<t;c+=i){let e;if(s)e=String.fromCharCode(c),e===`\\`&&(e=``);else if(e=String(c),o){let t=r-e.length;if(t>0){let n=Array(t+1).join(`0`);e=c<0?`-`+n+e.slice(1):n+e}}f.push(e)}}else{f=[];for(let e=0;e<d.length;e++)f.push.apply(f,Vi(d[e],t,!1))}for(let e=0;e<f.length;e++)for(let i=0;i<u.length&&r.length<t;i++){let t=a+f[e]+u[i];(!n||c||t)&&r.push(t)}return r}}const Hi=e=>{if(typeof e!=`string`)throw TypeError(`invalid pattern`);if(e.length>65536)throw TypeError(`pattern is too long`)},Ui={"[:alnum:]":[`\\p{L}\\p{Nl}\\p{Nd}`,!0],"[:alpha:]":[`\\p{L}\\p{Nl}`,!0],"[:ascii:]":[`\\x00-\\x7f`,!1],"[:blank:]":[`\\p{Zs}\\t`,!0],"[:cntrl:]":[`\\p{Cc}`,!0],"[:digit:]":[`\\p{Nd}`,!0],"[:graph:]":[`\\p{Z}\\p{C}`,!0,!0],"[:lower:]":[`\\p{Ll}`,!0],"[:print:]":[`\\p{C}`,!0],"[:punct:]":[`\\p{P}`,!0],"[:space:]":[`\\p{Z}\\t\\r\\n\\v\\f`,!0],"[:upper:]":[`\\p{Lu}`,!0],"[:word:]":[`\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}`,!0],"[:xdigit:]":[`A-Fa-f0-9`,!1]},Wi=e=>e.replace(/[[\]\\-]/g,`\\$&`),Gi=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),Ki=e=>e.join(``),qi=(e,t)=>{let n=t;if(e.charAt(n)!==`[`)throw Error(`not in a brace expression`);let r=[],i=[],a=n+1,o=!1,s=!1,c=!1,l=!1,u=n,d=``;WHILE:for(;a<e.length;){let t=e.charAt(a);if((t===`!`||t===`^`)&&a===n+1){l=!0,a++;continue}if(t===`]`&&o&&!c){u=a+1;break}if(o=!0,t===`\\`&&!c){c=!0,a++;continue}if(t===`[`&&!c){for(let[t,[o,c,l]]of Object.entries(Ui))if(e.startsWith(t,a)){if(d)return[`$.`,!1,e.length-n,!0];a+=t.length,l?i.push(o):r.push(o),s||=c;continue WHILE}}if(c=!1,d){t>d?r.push(Wi(d)+`-`+Wi(t)):t===d&&r.push(Wi(t)),d=``,a++;continue}if(e.startsWith(`-]`,a+1)){r.push(Wi(t+`-`)),a+=2;continue}if(e.startsWith(`-`,a+1)){d=t,a+=2;continue}r.push(Wi(t)),a++}if(u<a)return[``,!1,0,!1];if(!r.length&&!i.length)return[`$.`,!1,e.length-n,!0];if(i.length===0&&r.length===1&&/^\\?.$/.test(r[0])&&!l)return[Gi(r[0].length===2?r[0].slice(-1):r[0]),!1,u-n,!1];let f=`[`+(l?`^`:``)+Ki(r)+`]`,p=`[`+(l?``:`^`)+Ki(i)+`]`;return[r.length&&i.length?`(`+f+`|`+p+`)`:r.length?f:p,s,u-n,!0]},Ji=(e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!0}={})=>n?t?e.replace(/\[([^/\\])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^/\\])\]/g,`$1$2`).replace(/\\([^/])/g,`$1`):t?e.replace(/\[([^/\\{}])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,`$1$2`).replace(/\\([^/{}])/g,`$1`);var J;const Yi=new Set([`!`,`?`,`+`,`*`,`@`]),Xi=e=>Yi.has(e),Zi=e=>Xi(e.type),Qi=new Map([[`!`,[`@`]],[`?`,[`?`,`@`]],[`@`,[`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`]]]),$i=new Map([[`!`,[`?`]],[`@`,[`?`]],[`+`,[`?`,`*`]]]),ea=new Map([[`!`,[`?`,`@`]],[`?`,[`?`,`@`]],[`@`,[`?`,`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`,`?`,`*`]]]),ta=new Map([[`!`,new Map([[`!`,`@`]])],[`?`,new Map([[`*`,`*`],[`+`,`*`]])],[`@`,new Map([[`!`,`!`],[`?`,`?`],[`@`,`@`],[`*`,`*`],[`+`,`+`]])],[`+`,new Map([[`?`,`*`],[`*`,`*`]])]]),na=`(?!\\.)`,ra=new Set([`[`,`.`]),ia=new Set([`..`,`.`]),aa=new Set(`().*{}+?[]^$\\!`),oa=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),sa=`[^/]+?`;let ca=0;var la=class{type;#e;#t;#n=!1;#r=[];#i;#a;#o;#s=!1;#c;#l;#u=!1;id=++ca;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for(`nodejs.util.inspect.custom`)](){return{"@@type":`AST`,id:this.id,type:this.type,root:this.#e.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(e,t,n={}){this.type=e,e&&(this.#t=!0),this.#i=t,this.#e=this.#i?this.#i.#e:this,this.#c=this.#e===this?n:this.#e.#c,this.#o=this.#e===this?[]:this.#e.#o,e===`!`&&!this.#e.#s&&this.#o.push(this),this.#a=this.#i?this.#i.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let e of this.#r)if(typeof e!=`string`&&(e.type||e.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#l===void 0?this.type?this.#l=this.type+`(`+this.#r.map(e=>String(e)).join(`|`)+`)`:this.#l=this.#r.map(e=>String(e)).join(``):this.#l}#d(){if(this!==this.#e)throw Error(`should only call on root`);if(this.#s)return this;this.toString(),this.#s=!0;let e;for(;e=this.#o.pop();){if(e.type!==`!`)continue;let t=e,n=t.#i;for(;n;){for(let r=t.#a+1;!n.type&&r<n.#r.length;r++)for(let t of e.#r){if(typeof t==`string`)throw Error(`string part in extglob AST??`);t.copyIn(n.#r[r])}t=n,n=t.#i}}return this}push(...e){for(let t of e)if(t!==``){if(typeof t!=`string`&&!(t instanceof J&&t.#i===this))throw Error(`invalid part: `+t);this.#r.push(t)}}toJSON(){let e=this.type===null?this.#r.slice().map(e=>typeof e==`string`?e:e.toJSON()):[this.type,...this.#r.map(e=>e.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#s&&this.#i?.type===`!`)&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#a===0)return!0;let e=this.#i;for(let t=0;t<this.#a;t++){let n=e.#r[t];if(!(n instanceof J&&n.type===`!`))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type===`!`)return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let e=this.#i?this.#i.#r.length:0;return this.#a===e-1}copyIn(e){typeof e==`string`?this.push(e):this.push(e.clone(this))}clone(e){let t=new J(this.type,e);for(let e of this.#r)t.copyIn(e);return t}static#f(e,t,n,r,i){let a=r.maxExtglobRecursion??2,o=!1,s=!1,c=-1,l=!1;if(t.type===null){let u=n,d=``;for(;u<e.length;){let n=e.charAt(u++);if(o||n===`\\`){o=!o,d+=n;continue}if(s){u===c+1?(n===`^`||n===`!`)&&(l=!0):n===`]`&&!(u===c+2&&l)&&(s=!1),d+=n;continue}else if(n===`[`){s=!0,c=u,l=!1,d+=n;continue}if(!r.noext&&Xi(n)&&e.charAt(u)===`(`&&i<=a){t.push(d),d=``;let a=new J(n,t);u=J.#f(e,a,u,r,i+1),t.push(a);continue}d+=n}return t.push(d),u}let u=n+1,d=new J(null,t),f=[],p=``;for(;u<e.length;){let n=e.charAt(u++);if(o||n===`\\`){o=!o,p+=n;continue}if(s){u===c+1?(n===`^`||n===`!`)&&(l=!0):n===`]`&&!(u===c+2&&l)&&(s=!1),p+=n;continue}else if(n===`[`){s=!0,c=u,l=!1,p+=n;continue}if(!r.noext&&Xi(n)&&e.charAt(u)===`(`&&(i<=a||t&&t.#h(n))){let a=t&&t.#h(n)?0:1;d.push(p),p=``;let o=new J(n,d);d.push(o),u=J.#f(e,o,u,r,i+a);continue}if(n===`|`){d.push(p),p=``,f.push(d),d=new J(null,t);continue}if(n===`)`)return p===``&&t.#r.length===0&&(t.#u=!0),d.push(p),p=``,t.push(...f,d),u;p+=n}return t.type=null,t.#t=void 0,t.#r=[e.substring(n-1)],u}#p(e){return this.#m(e,$i)}#m(e,t=Qi){if(!e||typeof e!=`object`||e.type!==null||e.#r.length!==1||this.type===null)return!1;let n=e.#r[0];return!n||typeof n!=`object`||n.type===null?!1:this.#h(n.type,t)}#h(e,t=ea){return!!t.get(this.type)?.includes(e)}#g(e,t){let n=e.#r[0],r=new J(null,n,this.options);r.#r.push(``),n.push(r),this.#_(e,t)}#_(e,t){let n=e.#r[0];this.#r.splice(t,1,...n.#r);for(let e of n.#r)typeof e==`object`&&(e.#i=this);this.#l=void 0}#v(e){return!!ta.get(this.type)?.has(e)}#y(e){if(!e||typeof e!=`object`||e.type!==null||e.#r.length!==1||this.type===null||this.#r.length!==1)return!1;let t=e.#r[0];return!t||typeof t!=`object`||t.type===null?!1:this.#v(t.type)}#b(e){let t=ta.get(this.type),n=e.#r[0],r=t?.get(n.type);if(!r)return!1;this.#r=n.#r;for(let e of this.#r)typeof e==`object`&&(e.#i=this);this.type=r,this.#l=void 0,this.#u=!1}static fromGlob(e,t={}){let n=new J(null,void 0,t);return J.#f(e,n,0,t,0),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let e=this.toString(),[t,n,r,i]=this.toRegExpSource();if(!(r||this.#t||this.#c.nocase&&!this.#c.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return n;let a=(this.#c.nocase?`i`:``)+(i?`u`:``);return Object.assign(RegExp(`^${t}$`,a),{_src:t,_glob:e})}get options(){return this.#c}toRegExpSource(e){let t=e??!!this.#c.dot;if(this.#e===this&&(this.#x(),this.#d()),!Zi(this)){let n=this.isStart()&&this.isEnd()&&!this.#r.some(e=>typeof e!=`string`),r=this.#r.map(t=>{let[r,i,a,o]=typeof t==`string`?J.#C(t,this.#t,n):t.toRegExpSource(e);return this.#t=this.#t||a,this.#n=this.#n||o,r}).join(``),i=``;if(this.isStart()&&typeof this.#r[0]==`string`&&!(this.#r.length===1&&ia.has(this.#r[0]))){let n=ra,a=t&&n.has(r.charAt(0))||r.startsWith(`\\.`)&&n.has(r.charAt(2))||r.startsWith(`\\.\\.`)&&n.has(r.charAt(4)),o=!t&&!e&&n.has(r.charAt(0));i=a?`(?!(?:^|/)\\.\\.?(?:$|/))`:o?na:``}let a=``;return this.isEnd()&&this.#e.#s&&this.#i?.type===`!`&&(a=`(?:$|\\/)`),[i+r+a,Ji(r),this.#t=!!this.#t,this.#n]}let n=this.type===`*`||this.type===`+`,r=this.type===`!`?`(?:(?!(?:`:`(?:`,i=this.#S(t);if(this.isStart()&&this.isEnd()&&!i&&this.type!==`!`){let e=this.toString(),t=this;return t.#r=[e],t.type=null,t.#t=void 0,[e,Ji(this.toString()),!1,!1]}let a=!n||e||t?``:this.#S(!0);a===i&&(a=``),a&&(i=`(?:${i})(?:${a})*?`);let o=``;if(this.type===`!`&&this.#u)o=(this.isStart()&&!t?na:``)+sa;else{let n=this.type===`!`?`))`+(this.isStart()&&!t&&!e?na:``)+`[^/]*?)`:this.type===`@`?`)`:this.type===`?`?`)?`:this.type===`+`&&a?`)`:this.type===`*`&&a?`)?`:`)${this.type}`;o=r+i+n}return[o,Ji(i),this.#t=!!this.#t,this.#n]}#x(){if(Zi(this)){let e=0,t=!1;do{t=!0;for(let e=0;e<this.#r.length;e++){let n=this.#r[e];typeof n==`object`&&(n.#x(),this.#m(n)?(t=!1,this.#_(n,e)):this.#p(n)?(t=!1,this.#g(n,e)):this.#y(n)&&(t=!1,this.#b(n)))}}while(!t&&++e<10)}else for(let e of this.#r)typeof e==`object`&&e.#x();this.#l=void 0}#S(e){return this.#r.map(t=>{if(typeof t==`string`)throw Error(`string type in extglob ast??`);let[n,r,i,a]=t.toRegExpSource(e);return this.#n=this.#n||a,n}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join(`|`)}static#C(e,t,n=!1){let r=!1,i=``,a=!1,o=!1;for(let s=0;s<e.length;s++){let c=e.charAt(s);if(r){r=!1,i+=(aa.has(c)?`\\`:``)+c;continue}if(c===`*`){if(o)continue;o=!0,i+=n&&/^[*]+$/.test(e)?sa:`[^/]*?`,t=!0;continue}else o=!1;if(c===`\\`){s===e.length-1?i+=`\\\\`:r=!0;continue}if(c===`[`){let[n,r,o,c]=qi(e,s);if(o){i+=n,a||=r,s+=o-1,t||=c;continue}}if(c===`?`){i+=`[^/]`,t=!0;continue}i+=oa(c)}return[i,Ji(e),!!t,a]}};J=la;const ua=(e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!1}={})=>n?t?e.replace(/[?*()[\]{}]/g,`[$&]`):e.replace(/[?*()[\]\\{}]/g,`\\$&`):t?e.replace(/[?*()[\]]/g,`[$&]`):e.replace(/[?*()[\]\\]/g,`\\$&`),Y=(e,t,n={})=>(Hi(t),!n.nocomment&&t.charAt(0)===`#`?!1:new Ia(t,n).match(e)),da=/^\*+([^+@!?*[(]*)$/,fa=e=>t=>!t.startsWith(`.`)&&t.endsWith(e),pa=e=>t=>t.endsWith(e),ma=e=>(e=e.toLowerCase(),t=>!t.startsWith(`.`)&&t.toLowerCase().endsWith(e)),ha=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),ga=/^\*+\.\*+$/,_a=e=>!e.startsWith(`.`)&&e.includes(`.`),va=e=>e!==`.`&&e!==`..`&&e.includes(`.`),ya=/^\.\*+$/,ba=e=>e!==`.`&&e!==`..`&&e.startsWith(`.`),xa=/^\*+$/,Sa=e=>e.length!==0&&!e.startsWith(`.`),Ca=e=>e.length!==0&&e!==`.`&&e!==`..`,wa=/^\?+([^+@!?*[(]*)?$/,Ta=([e,t=``])=>{let n=ka([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},Ea=([e,t=``])=>{let n=Aa([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},Da=([e,t=``])=>{let n=Aa([e]);return t?e=>n(e)&&e.endsWith(t):n},Oa=([e,t=``])=>{let n=ka([e]);return t?e=>n(e)&&e.endsWith(t):n},ka=([e])=>{let t=e.length;return e=>e.length===t&&!e.startsWith(`.`)},Aa=([e])=>{let t=e.length;return e=>e.length===t&&e!==`.`&&e!==`..`},ja=typeof process==`object`&&process?typeof process.env==`object`&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:`posix`,Ma={win32:{sep:`\\`},posix:{sep:`/`}};Y.sep=ja===`win32`?Ma.win32.sep:Ma.posix.sep;const X=Symbol(`globstar **`);Y.GLOBSTAR=X,Y.filter=(e,t={})=>n=>Y(n,e,t);const Z=(e,t={})=>Object.assign({},e,t);Y.defaults=e=>{if(!e||typeof e!=`object`||!Object.keys(e).length)return Y;let t=Y;return Object.assign((n,r,i={})=>t(n,r,Z(e,i)),{Minimatch:class extends t.Minimatch{constructor(t,n={}){super(t,Z(e,n))}static defaults(n){return t.defaults(Z(e,n)).Minimatch}},AST:class extends t.AST{constructor(t,n,r={}){super(t,n,Z(e,r))}static fromGlob(n,r={}){return t.AST.fromGlob(n,Z(e,r))}},unescape:(n,r={})=>t.unescape(n,Z(e,r)),escape:(n,r={})=>t.escape(n,Z(e,r)),filter:(n,r={})=>t.filter(n,Z(e,r)),defaults:n=>t.defaults(Z(e,n)),makeRe:(n,r={})=>t.makeRe(n,Z(e,r)),braceExpand:(n,r={})=>t.braceExpand(n,Z(e,r)),match:(n,r,i={})=>t.match(n,r,Z(e,i)),sep:t.sep,GLOBSTAR:X})};const Na=(e,t={})=>(Hi(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Ii(e,{max:t.braceExpandMax}));Y.braceExpand=Na,Y.makeRe=(e,t={})=>new Ia(e,t).makeRe(),Y.match=(e,t,n={})=>{let r=new Ia(t,n);return e=e.filter(e=>r.match(e)),r.options.nonull&&!e.length&&e.push(t),e};const Pa=/[?*]|[+@!]\(.*?\)|\[|\]/,Fa=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`);var Ia=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,t={}){Hi(e),t||={},this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion??200,this.pattern=e,this.platform=t.platform||ja,this.isWindows=this.platform===`win32`,this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,`/`)),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot===void 0?!!(this.isWindows&&this.nocase):t.windowsNoMagicRoot,this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let t of e)if(typeof t!=`string`)return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)===`#`){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...e)=>console.error(...e)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(e=>this.slashSplit(e));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let r=this.globParts.map((e,t,n)=>{if(this.isWindows&&this.windowsNoMagicRoot){let t=e[0]===``&&e[1]===``&&(e[2]===`?`||!Pa.test(e[2]))&&!Pa.test(e[3]),n=/^[a-z]:/i.test(e[0]);if(t)return[...e.slice(0,4),...e.slice(4).map(e=>this.parse(e))];if(n)return[e[0],...e.slice(1).map(e=>this.parse(e))]}return e.map(e=>this.parse(e))});if(this.debug(this.pattern,r),this.set=r.filter(e=>e.indexOf(!1)===-1),this.isWindows)for(let e=0;e<this.set.length;e++){let t=this.set[e];t[0]===``&&t[1]===``&&this.globParts[e][2]===`?`&&typeof t[3]==`string`&&/^[a-z]:$/i.test(t[3])&&(t[2]=`?`)}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let t of e)for(let e=0;e<t.length;e++)t[e]===`**`&&(t[e]=`*`);let{optimizationLevel:t=1}=this.options;return t>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):e=t>=1?this.levelOneOptimize(e):this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(e=>{let t=-1;for(;(t=e.indexOf(`**`,t+1))!==-1;){let n=t;for(;e[n+1]===`**`;)n++;n!==t&&e.splice(t,n-t)}return e})}levelOneOptimize(e){return e.map(e=>(e=e.reduce((e,t)=>{let n=e[e.length-1];return t===`**`&&n===`**`?e:t===`..`&&n&&n!==`..`&&n!==`.`&&n!==`**`?(e.pop(),e):(e.push(t),e)},[]),e.length===0?[``]:e))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let n=1;n<e.length-1;n++){let r=e[n];n===1&&r===``&&e[0]===``||(r===`.`||r===``)&&(t=!0,e.splice(n,1),n--)}e[0]===`.`&&e.length===2&&(e[1]===`.`||e[1]===``)&&(t=!0,e.pop())}let n=0;for(;(n=e.indexOf(`..`,n+1))!==-1;){let r=e[n-1];r&&r!==`.`&&r!==`..`&&r!==`**`&&!(this.isWindows&&/^[a-z]:$/i.test(r))&&(t=!0,e.splice(n-1,2),n-=2)}}while(t);return e.length===0?[``]:e}firstPhasePreProcess(e){let t=!1;do{t=!1;for(let n of e){let r=-1;for(;(r=n.indexOf(`**`,r+1))!==-1;){let i=r;for(;n[i+1]===`**`;)i++;i>r&&n.splice(r+1,i-r);let a=n[r+1],o=n[r+2],s=n[r+3];if(a!==`..`||!o||o===`.`||o===`..`||!s||s===`.`||s===`..`)continue;t=!0,n.splice(r,1);let c=n.slice(0);c[r]=`**`,e.push(c),r--}if(!this.preserveMultipleSlashes){for(let e=1;e<n.length-1;e++){let r=n[e];e===1&&r===``&&n[0]===``||(r===`.`||r===``)&&(t=!0,n.splice(e,1),e--)}n[0]===`.`&&n.length===2&&(n[1]===`.`||n[1]===``)&&(t=!0,n.pop())}let i=0;for(;(i=n.indexOf(`..`,i+1))!==-1;){let e=n[i-1];if(e&&e!==`.`&&e!==`..`&&e!==`**`){t=!0;let e=i===1&&n[i+1]===`**`?[`.`]:[];n.splice(i-1,2,...e),n.length===0&&n.push(``),i-=2}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let n=t+1;n<e.length;n++){let r=this.partsMatch(e[t],e[n],!this.preserveMultipleSlashes);if(r){e[t]=[],e[n]=r;break}}return e.filter(e=>e.length)}partsMatch(e,t,n=!1){let r=0,i=0,a=[],o=``;for(;r<e.length&&i<t.length;)if(e[r]===t[i])a.push(o===`b`?t[i]:e[r]),r++,i++;else if(n&&e[r]===`**`&&t[i]===e[r+1])a.push(e[r]),r++;else if(n&&t[i]===`**`&&e[r]===t[i+1])a.push(t[i]),i++;else if(e[r]===`*`&&t[i]&&(this.options.dot||!t[i].startsWith(`.`))&&t[i]!==`**`){if(o===`b`)return!1;o=`a`,a.push(e[r]),r++,i++}else if(t[i]===`*`&&e[r]&&(this.options.dot||!e[r].startsWith(`.`))&&e[r]!==`**`){if(o===`a`)return!1;o=`b`,a.push(t[i]),r++,i++}else return!1;return e.length===t.length&&a}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=!1,n=0;for(let r=0;r<e.length&&e.charAt(r)===`!`;r++)t=!t,n++;n&&(this.pattern=e.slice(n)),this.negate=t}matchOne(e,t,n=!1){let r=0,i=0;if(this.isWindows){let n=typeof e[0]==`string`&&/^[a-z]:$/i.test(e[0]),a=!n&&e[0]===``&&e[1]===``&&e[2]===`?`&&/^[a-z]:$/i.test(e[3]),o=typeof t[0]==`string`&&/^[a-z]:$/i.test(t[0]),s=!o&&t[0]===``&&t[1]===``&&t[2]===`?`&&typeof t[3]==`string`&&/^[a-z]:$/i.test(t[3]),c=a?3:n?0:void 0,l=s?3:o?0:void 0;if(typeof c==`number`&&typeof l==`number`){let[n,a]=[e[c],t[l]];n.toLowerCase()===a.toLowerCase()&&(t[l]=n,i=l,r=c)}}let{optimizationLevel:a=1}=this.options;return a>=2&&(e=this.levelTwoFileOptimize(e)),t.includes(X)?this.#e(e,t,n,r,i):this.#n(e,t,n,r,i)}#e(e,t,n,r,i){let a=t.indexOf(X,i),o=t.lastIndexOf(X),[s,c,l]=n?[t.slice(i,a),t.slice(a+1),[]]:[t.slice(i,a),t.slice(a+1,o),t.slice(o+1)];if(s.length){let t=e.slice(r,r+s.length);if(!this.#n(t,s,n,0,0))return!1;r+=s.length,i+=s.length}let u=0;if(l.length){if(l.length+r>e.length)return!1;let t=e.length-l.length;if(this.#n(e,l,n,t,0))u=l.length;else{if(e[e.length-1]!==``||r+l.length===e.length||(t--,!this.#n(e,l,n,t,0)))return!1;u=l.length+1}}if(!c.length){let t=!!u;for(let n=r;n<e.length-u;n++){let r=String(e[n]);if(t=!0,r===`.`||r===`..`||!this.options.dot&&r.startsWith(`.`))return!1}return n||t}let d=[[[],0]],f=d[0],p=0,m=[0];for(let e of c)e===X?(m.push(p),f=[[],0],d.push(f)):(f[0].push(e),p++);let h=d.length-1,g=e.length-u;for(let e of d)e[1]=g-(m[h--]+e[0].length);return!!this.#t(e,d,r,0,n,0,!!u)}#t(e,t,n,r,i,a,o){let s=t[r];if(!s){for(let t=n;t<e.length;t++){o=!0;let n=e[t];if(n===`.`||n===`..`||!this.options.dot&&n.startsWith(`.`))return!1}return o}let[c,l]=s;for(;n<=l;){if(this.#n(e.slice(0,n+c.length),c,i,n,0)&&a<this.maxGlobstarRecursion){let s=this.#t(e,t,n+c.length,r+1,i,a+1,o);if(s!==!1)return s}let s=e[n];if(s===`.`||s===`..`||!this.options.dot&&s.startsWith(`.`))return!1;n++}return i||null}#n(e,t,n,r,i){let a,o,s,c;for(a=r,o=i,c=e.length,s=t.length;a<c&&o<s;a++,o++){this.debug(`matchOne loop`);let n=t[o],r=e[a];if(this.debug(t,n,r),n===!1||n===X)return!1;let i;if(typeof n==`string`?(i=r===n,this.debug(`string match`,n,r,i)):(i=n.test(r),this.debug(`pattern match`,n,r,i)),!i)return!1}if(a===c&&o===s)return!0;if(a===c)return n;if(o===s)return a===c-1&&e[a]===``;throw Error(`wtf?`)}braceExpand(){return Na(this.pattern,this.options)}parse(e){Hi(e);let t=this.options;if(e===`**`)return X;if(e===``)return``;let n,r=null;(n=e.match(xa))?r=t.dot?Ca:Sa:(n=e.match(da))?r=(t.nocase?t.dot?ha:ma:t.dot?pa:fa)(n[1]):(n=e.match(wa))?r=(t.nocase?t.dot?Ea:Ta:t.dot?Da:Oa)(n):(n=e.match(ga))?r=t.dot?va:_a:(n=e.match(ya))&&(r=ba);let i=la.fromGlob(e,this.options).toMMPattern();return r&&typeof i==`object`&&Reflect.defineProperty(i,"test",{value:r}),i}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let t=this.options,n=t.noglobstar?`[^/]*?`:t.dot?`(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?`:`(?:(?!(?:\\/|^)\\.).)*?`,r=new Set(t.nocase?[`i`]:[]),i=e.map(e=>{let t=e.map(e=>{if(e instanceof RegExp)for(let t of e.flags.split(``))r.add(t);return typeof e==`string`?Fa(e):e===X?X:e._src});t.forEach((e,r)=>{let i=t[r+1],a=t[r-1];e!==X||a===X||(a===void 0?i!==void 0&&i!==X?t[r+1]=`(?:\\/|`+n+`\\/)?`+i:t[r]=n:i===void 0?t[r-1]=a+`(?:\\/|\\/`+n+`)?`:i!==X&&(t[r-1]=a+`(?:\\/|\\/`+n+`\\/)`+i,t[r+1]=X))});let i=t.filter(e=>e!==X);if(this.partial&&i.length>=1){let e=[];for(let t=1;t<=i.length;t++)e.push(i.slice(0,t).join(`/`));return`(?:`+e.join(`|`)+`)`}return i.join(`/`)}).join(`|`),[a,o]=e.length>1?[`(?:`,`)`]:[``,``];i=`^`+a+i+o+`$`,this.partial&&(i=`^(?:\\/|`+a+i.slice(1,-1)+o+`)$`),this.negate&&(i=`^(?!`+i+`).+$`);try{this.regexp=new RegExp(i,[...r].join(``))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split(`/`):this.isWindows&&/^\/\/[^/]+/.test(e)?[``,...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug(`match`,e,this.pattern),this.comment)return!1;if(this.empty)return e===``;if(e===`/`&&t)return!0;let n=this.options;this.isWindows&&(e=e.split(`\\`).join(`/`));let r=this.slashSplit(e);this.debug(this.pattern,`split`,r);let i=this.set;this.debug(this.pattern,`set`,i);let a=r[r.length-1];if(!a)for(let e=r.length-2;!a&&e>=0;e--)a=r[e];for(let e of i){let i=r;if(n.matchBase&&e.length===1&&(i=[a]),this.matchOne(i,e,t))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(e){return Y.defaults(e).Minimatch}};Y.AST=la,Y.Minimatch=Ia,Y.escape=ua,Y.unescape=Ji;var La=n(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c})),Ra=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{SYMBOL_FOR_REQ_CONTEXT:()=>u,getContext:()=>d}),t.exports=c(l);let u=Symbol.for(`@vercel/request-context`);function d(){return globalThis[u]?.get?.()??{}}0&&(t.exports={SYMBOL_FOR_REQ_CONTEXT:u,getContext:d})})),za=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{getVercelOidcTokenSync:()=>d}),t.exports=c(l);var u=Ra();function d(){let e=(0,u.getContext)().headers?.[`x-vercel-oidc-token`]??process.env.VERCEL_OIDC_TOKEN;if(!e)throw Error(`The 'x-vercel-oidc-token' header is missing from the request.`);return e}0&&(t.exports={getVercelOidcTokenSync:d})})),Ba=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{VercelOidcTokenError:()=>u}),t.exports=c(l);var u=class extends Error{constructor(e,t){super(e),this.name=`VercelOidcTokenError`,this.cause=t}toString(){return this.cause?`${this.name}: ${this.message}: ${this.cause}`:`${this.name}: ${this.message}`}};0&&(t.exports={VercelOidcTokenError:u})})),Va=n(((t,n)=>{var r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})},c=(e,t,n,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==n&&r(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(r({},`__esModule`,{value:!0}),e),u={};s(u,{getVercelOidcToken:()=>p}),n.exports=l(u);var d=za(),f=Ba();async function p(t){let n=``,r;try{n=(0,d.getVercelOidcTokenSync)()}catch(e){r=e}try{let[{getTokenPayload:r,isExpired:i},{refreshToken:a}]=await Promise.all([await Promise.resolve().then(()=>e(Ka())),await import(`../../_chunks/workflow/token-D4VIwGlD.js`).then(t=>e(t.default))]);(!n||i(r(n),t?.expirationBufferMs))&&(await a(t),n=(0,d.getVercelOidcTokenSync)())}catch(e){let t=r instanceof Error?r.message:``;throw e instanceof Error&&(t=`${t}
|
|
12
|
-
${e.message}`),t?new f.VercelOidcTokenError(t):e}return n}0&&(n.exports={getVercelOidcToken:p})})),Ha=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{AccessTokenMissingError:()=>u,RefreshAccessTokenFailedError:()=>d}),t.exports=c(l);var u=class extends Error{constructor(){super(`No authentication found. Please log in with the Vercel CLI (vercel login).`),this.name=`AccessTokenMissingError`}},d=class extends Error{constructor(e){super(`Failed to refresh authentication token.`,{cause:e}),this.name=`RefreshAccessTokenFailedError`}};0&&(t.exports={AccessTokenMissingError:u,RefreshAccessTokenFailedError:d})})),Ua=n(((e,n)=>{var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},u=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let s of o(t))!c.call(e,s)&&s!==n&&i(e,s,{get:()=>t[s],enumerable:!(r=a(t,s))||r.enumerable});return e},d=(e,t,n)=>(n=e==null?{}:r(s(e)),u(t||!e||!e.__esModule?i(n,`default`,{value:e,enumerable:!0}):n,e)),f=e=>u(i({},`__esModule`,{value:!0}),e),p={};l(p,{findRootDir:()=>v,getUserDataDir:()=>y}),n.exports=f(p);var m=d(t(`path`)),h=d(t(`fs`)),g=d(t(`os`)),_=Ba();function v(){try{let e=process.cwd();for(;e!==m.default.dirname(e);){let t=m.default.join(e,`.vercel`);if(h.default.existsSync(t))return e;e=m.default.dirname(e)}}catch{throw new _.VercelOidcTokenError(`Token refresh only supported in node server environments`)}return null}function y(){if(process.env.XDG_DATA_HOME)return process.env.XDG_DATA_HOME;switch(g.default.platform()){case`darwin`:return m.default.join(g.default.homedir(),`Library/Application Support`);case`linux`:return m.default.join(g.default.homedir(),`.local/share`);case`win32`:return process.env.LOCALAPPDATA?process.env.LOCALAPPDATA:null;default:return null}}0&&(n.exports={findRootDir:v,getUserDataDir:y})})),Wa=n(((e,n)=>{var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},u=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let s of o(t))!c.call(e,s)&&s!==n&&i(e,s,{get:()=>t[s],enumerable:!(r=a(t,s))||r.enumerable});return e},d=(e,t,n)=>(n=e==null?{}:r(s(e)),u(t||!e||!e.__esModule?i(n,`default`,{value:e,enumerable:!0}):n,e)),f=e=>u(i({},`__esModule`,{value:!0}),e),p={};l(p,{isValidAccessToken:()=>b,readAuthConfig:()=>v,writeAuthConfig:()=>y}),n.exports=f(p);var m=d(t(`fs`)),h=d(t(`path`)),g=Ka();function _(){let e=(0,g.getVercelDataDir)();if(!e)throw Error(`Unable to find Vercel CLI data directory. Your platform: ${process.platform}. Supported: darwin, linux, win32.`);return h.join(e,`auth.json`)}function v(){try{let e=_();if(!m.existsSync(e))return null;let t=m.readFileSync(e,`utf8`);return t?JSON.parse(t):null}catch{return null}}function y(e){let t=_(),n=h.dirname(t);m.existsSync(n)||m.mkdirSync(n,{mode:504,recursive:!0}),m.writeFileSync(t,JSON.stringify(e,null,2),{mode:384})}function b(e,t=0){if(!e.token)return!1;if(typeof e.expiresAt!=`number`)return!0;let n=Math.floor(Date.now()/1e3),r=t/1e3;return e.expiresAt>=n+r}0&&(n.exports={isValidAccessToken:b,readAuthConfig:v,writeAuthConfig:y})})),Ga=n(((e,n)=>{var r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})},c=(e,t,n,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==n&&r(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(r({},`__esModule`,{value:!0}),e),u={};s(u,{processTokenResponse:()=>g,refreshTokenRequest:()=>h}),n.exports=l(u);var d=t(`os`);let f=`@vercel/oidc node-${process.version} ${(0,d.platform)()} (${(0,d.arch)()}) ${(0,d.hostname)()}`,p=null;async function m(){if(p)return p;let e=await fetch(`https://vercel.com/.well-known/openid-configuration`,{headers:{"user-agent":f}});if(!e.ok)throw Error(`Failed to discover OAuth endpoints`);let t=await e.json();if(!t||typeof t.token_endpoint!=`string`)throw Error(`Invalid OAuth discovery response`);let n=t.token_endpoint;return p=n,n}async function h(e){let t=await m();return await fetch(t,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`,"user-agent":f},body:new URLSearchParams({client_id:`cl_HYyOPBNtFMfHhaUn9L4QPfTZz6TP47bp`,grant_type:`refresh_token`,...e})})}async function g(e){let t=await e.json();if(!e.ok){let e=typeof t==`object`&&t&&`error`in t?String(t.error):`Token refresh failed`;return[Error(e)]}return typeof t!=`object`||!t?[Error(`Invalid token response`)]:typeof t.access_token==`string`?t.token_type===`Bearer`?typeof t.expires_in==`number`?[null,t]:[Error(`Missing expires_in in response`)]:[Error(`Invalid token_type in response`)]:[Error(`Missing access_token in response`)]}0&&(n.exports={processTokenResponse:g,refreshTokenRequest:h})})),Ka=n(((e,n)=>{var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},u=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let s of o(t))!c.call(e,s)&&s!==n&&i(e,s,{get:()=>t[s],enumerable:!(r=a(t,s))||r.enumerable});return e},d=(e,t,n)=>(n=e==null?{}:r(s(e)),u(t||!e||!e.__esModule?i(n,`default`,{value:e,enumerable:!0}):n,e)),f=e=>u(i({},`__esModule`,{value:!0}),e),p={};l(p,{assertVercelOidcTokenResponse:()=>w,findProjectInfo:()=>T,getTokenPayload:()=>ee,getVercelDataDir:()=>x,getVercelOidcToken:()=>C,getVercelToken:()=>S,isExpired:()=>te,loadToken:()=>D,saveToken:()=>E}),n.exports=f(p);var m=d(t(`path`)),h=d(t(`fs`)),g=Ba(),_=Ua(),v=Wa(),y=Ga(),b=Ha();function x(){let e=(0,_.getUserDataDir)();return e?m.join(e,`com.vercel.cli`):null}async function S(e){let t=(0,v.readAuthConfig)();if(!t?.token)throw new b.AccessTokenMissingError;if((0,v.isValidAccessToken)(t,e?.expirationBufferMs))return t.token;if(!t.refreshToken)throw(0,v.writeAuthConfig)({}),new b.RefreshAccessTokenFailedError(`No refresh token available`);try{let e=await(0,y.refreshTokenRequest)({refresh_token:t.refreshToken}),[n,r]=await(0,y.processTokenResponse)(e);if(n||!r)throw(0,v.writeAuthConfig)({}),new b.RefreshAccessTokenFailedError(n);let i={token:r.access_token,expiresAt:Math.floor(Date.now()/1e3)+r.expires_in};return r.refresh_token&&(i.refreshToken=r.refresh_token),(0,v.writeAuthConfig)(i),i.token}catch(e){throw(0,v.writeAuthConfig)({}),e instanceof b.AccessTokenMissingError||e instanceof b.RefreshAccessTokenFailedError?e:new b.RefreshAccessTokenFailedError(e)}}async function C(e,t,n){let r=`https://api.vercel.com/v1/projects/${t}/token?source=vercel-oidc-refresh${n?`&teamId=${n}`:``}`,i=await fetch(r,{method:`POST`,headers:{Authorization:`Bearer ${e}`}});if(!i.ok)throw new g.VercelOidcTokenError(`Failed to refresh OIDC token: ${i.statusText}`);let a=await i.json();return w(a),a}function w(e){if(!e||typeof e!=`object`)throw TypeError("Vercel OIDC token is malformed. Expected an object. Please run `vc env pull` and try again");if(!(`token`in e)||typeof e.token!=`string`)throw TypeError("Vercel OIDC token is malformed. Expected a string-valued token property. Please run `vc env pull` and try again")}function T(){let e=(0,_.findRootDir)();if(!e)throw new g.VercelOidcTokenError("Unable to find project root directory. Have you linked your project with `vc link?`");let t=m.join(e,`.vercel`,`project.json`);if(!h.existsSync(t))throw new g.VercelOidcTokenError("project.json not found, have you linked your project with `vc link?`");let n=JSON.parse(h.readFileSync(t,`utf8`));if(typeof n.projectId!=`string`&&typeof n.orgId!=`string`)throw TypeError("Expected a string-valued projectId property. Try running `vc link` to re-link your project.");return{projectId:n.projectId,teamId:n.orgId}}function E(e,t){let n=(0,_.getUserDataDir)();if(!n)throw new g.VercelOidcTokenError(`Unable to find user data directory. Please reach out to Vercel support.`);let r=m.join(n,`com.vercel.token`,`${t}.json`),i=JSON.stringify(e);h.mkdirSync(m.dirname(r),{mode:504,recursive:!0}),h.writeFileSync(r,i),h.chmodSync(r,432)}function D(e){let t=(0,_.getUserDataDir)();if(!t)throw new g.VercelOidcTokenError(`Unable to find user data directory. Please reach out to Vercel support.`);let n=m.join(t,`com.vercel.token`,`${e}.json`);if(!h.existsSync(n))return null;let r=JSON.parse(h.readFileSync(n,`utf8`));return w(r),r}function ee(e){let t=e.split(`.`);if(t.length!==3)throw new g.VercelOidcTokenError("Invalid token. Please run `vc env pull` and try again");let n=t[1].replace(/-/g,`+`).replace(/_/g,`/`),r=n.padEnd(n.length+(4-n.length%4)%4,`=`);return JSON.parse(Buffer.from(r,`base64`).toString(`utf8`))}function te(e,t=0){return e.exp*1e3<Date.now()+t}0&&(n.exports={assertVercelOidcTokenResponse:w,findProjectInfo:T,getTokenPayload:ee,getVercelDataDir:x,getVercelOidcToken:C,getVercelToken:S,isExpired:te,loadToken:D,saveToken:E})})),qa=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{AccessTokenMissingError:()=>p.AccessTokenMissingError,RefreshAccessTokenFailedError:()=>p.RefreshAccessTokenFailedError,getContext:()=>f.getContext,getVercelOidcToken:()=>u.getVercelOidcToken,getVercelOidcTokenSync:()=>d.getVercelOidcTokenSync,getVercelToken:()=>m.getVercelToken}),t.exports=c(l);var u=Va(),d=za(),f=Ra(),p=Ha(),m=Ka();0&&(t.exports={AccessTokenMissingError,RefreshAccessTokenFailedError,getContext,getVercelOidcToken,getVercelOidcTokenSync,getVercelToken})})),Ja=e(La(),1),Ya=qa();async function Xa(e){let t=0,n=e.getReader(),r=[];try{for(;;){let{done:e,value:i}=await n.read();if(e)break;r.push(i),t+=i.length}}finally{n.releaseLock()}return Buffer.concat(r,t)}var Za=class{contentType=`application/json`;replacer;reviver;constructor(e={}){this.replacer=e.replacer,this.reviver=e.reviver}serialize(e){return Buffer.from(JSON.stringify(e,this.replacer),`utf8`)}async deserialize(e){let t=await Xa(e);return JSON.parse(t.toString(`utf8`),this.reviver)}},Qa=class extends Error{constructor(e){super(`Message ${e} not found`),this.name=`MessageNotFoundError`}},$a=class extends Error{constructor(e,t){super(`Message ${e} not available for processing${t?`: ${t}`:``}`),this.name=`MessageNotAvailableError`}},eo=class extends Error{constructor(e,t){super(`Message ${e} is corrupted: ${t}`),this.name=`MessageCorruptedError`}},to=class extends Error{retryAfter;constructor(e=`Too many requests`,t){super(e),this.name=`TooManyRequestsError`,this.retryAfter=t}},no=class extends Error{constructor(e=`Missing or invalid authentication token`){super(e),this.name=`UnauthorizedError`}},ro=class extends Error{constructor(e=`Queue environment doesn't match token environment`){super(e),this.name=`ForbiddenError`}},io=class extends Error{constructor(e){super(e),this.name=`BadRequestError`}},ao=class extends Error{constructor(e=`Unexpected server error`){super(e),this.name=`InternalServerError`}},oo=class extends Error{constructor(e,t=1,n=10){super(`Invalid limit: ${e}. Limit must be between ${t} and ${n}.`),this.name=`InvalidLimitError`}},so=class extends Error{constructor(e){super(`Message ${e} has already been processed`),this.name=`MessageAlreadyProcessedError`}},co=class extends Error{idempotencyKey;constructor(e,t){super(e),this.name=`DuplicateMessageError`,this.idempotencyKey=t}},lo=class extends Error{deploymentId;constructor(e,t){super(e),this.name=`ConsumerDiscoveryError`,this.deploymentId=t}},uo=class extends Error{constructor(e=`Consumer registry not configured`){super(e),this.name=`ConsumerRegistryNotConfiguredError`}},fo=300,po=30,mo=60,ho=10,go=3e3,_o=3,vo=250;function yo(e){return Math.min(mo,Math.max(ho,e/5))}var bo=class{client;topicName;consumerGroupName;visibilityTimeout;constructor(e,t,n,r={}){this.client=e,this.topicName=t,this.consumerGroupName=n,this.visibilityTimeout=Math.max(po,r.visibilityTimeoutSeconds??fo)}isClientError(e){return e instanceof $a||e instanceof Qa||e instanceof io||e instanceof no||e instanceof ro}isNetworkError(e){return e instanceof TypeError}async directiveCallWithRetries(e){let t;for(let n=1;n<=_o;n++)try{return await e()}catch(e){if(t=e,n===_o)throw e;if(e instanceof to){if(e.retryAfter===void 0)throw e;await new Promise(t=>setTimeout(t,e.retryAfter*1e3));continue}if(!this.isNetworkError(e))throw e;let r=vo*n,i=r/2+r/2*Math.random();await new Promise(e=>setTimeout(e,i))}throw t}startVisibilityExtension(e,t){let n=!0,r=!1,i,a=null,o=yo(this.visibilityTimeout)*1e3,s=o;if(t?.visibilityDeadline){let e=t.visibilityDeadline.getTime()-Date.now();s=e>0?yo(e/1e3)*1e3:0}let c=new Promise(e=>{i=e}),l=()=>{r||(r=!0,i())},u=async()=>{if(!n){l();return}try{await this.client.changeVisibility({queueName:this.topicName,consumerGroup:this.consumerGroupName,receiptHandle:e,visibilityTimeoutSeconds:this.visibilityTimeout}),n?a=setTimeout(()=>u(),o):l()}catch(t){if(this.isClientError(t)){console.error(`Visibility extension failed with client error for receipt handle ${e} (stopping retries):`,t),l();return}console.error(`Failed to extend visibility for receipt handle ${e} (will retry in ${go/1e3}s):`,t),n?a=setTimeout(()=>u(),go):l()}};return a=setTimeout(()=>u(),s),async(e=!1)=>{n=!1,a&&=(clearTimeout(a),null),e?await c:l()}}async finalizePayload(e){let t=this.client.getTransport();if(t.finalize&&e!=null)try{await t.finalize(e)}catch(e){console.warn(`Failed to finalize message payload:`,e)}}async processMessage(e,t,n){let r=this.startVisibilityExtension(e.receiptHandle,n),i={messageId:e.messageId,deliveryCount:e.deliveryCount,createdAt:e.createdAt,expiresAt:e.expiresAt??new Date(e.createdAt.getTime()+864e5),topicName:this.topicName,consumerGroup:this.consumerGroupName,region:this.client.getRegion()};try{await t(e.payload,i),await r(),await this.client.acknowledgeMessage({queueName:this.topicName,consumerGroup:this.consumerGroupName,receiptHandle:e.receiptHandle})}catch(t){if(await r(),n?.retry){let r;try{r=n.retry(t,i)}catch(e){console.warn(`retry handler threw:`,e)}if(r){if(`acknowledge`in r&&r.acknowledge){try{await this.directiveCallWithRetries(()=>this.client.acknowledgeMessage({queueName:this.topicName,consumerGroup:this.consumerGroupName,receiptHandle:e.receiptHandle}))}catch(e){console.warn(`Failed to acknowledge message:`,e)}await this.finalizePayload(e.payload);return}if(`afterSeconds`in r&&typeof r.afterSeconds==`number`){try{await this.directiveCallWithRetries(()=>this.client.changeVisibility({queueName:this.topicName,consumerGroup:this.consumerGroupName,receiptHandle:e.receiptHandle,visibilityTimeoutSeconds:r.afterSeconds}))}catch(e){console.warn(`Failed to reschedule message for retry:`,e)}await this.finalizePayload(e.payload);return}}}throw await this.finalizePayload(e.payload),t}}async consumeMessage(e,t,n){await this.processMessage(t,e,n)}async consume(e,t){let n=t?.retry;if(t&&`messageId`in t){let r=await this.client.receiveMessageById({queueName:this.topicName,consumerGroup:this.consumerGroupName,messageId:t.messageId,visibilityTimeoutSeconds:this.visibilityTimeout});return await this.processMessage(r.message,e,{retry:n}),1}else{let r=t&&`limit`in t?t.limit:1,i=0;for await(let t of this.client.receiveMessages({queueName:this.topicName,consumerGroup:this.consumerGroupName,visibilityTimeoutSeconds:this.visibilityTimeout,limit:r}))i++,await this.processMessage(t,e,{retry:n});return i}}get name(){return this.consumerGroupName}get topic(){return this.topicName}},xo=class{client;topicName;constructor(e,t){this.client=e,this.topicName=t}async publish(e,t){let n=await this.client.sendMessage({queueName:this.topicName,payload:e,idempotencyKey:t?.idempotencyKey,retentionSeconds:t?.retentionSeconds,delaySeconds:t?.delaySeconds,headers:t?.headers,telemetry:t?.telemetry});return n.messageId&&Po()&&bs(this.topicName,n.messageId,this.client.getRegion(),t?.delaySeconds,t?.retentionSeconds),{messageId:n.messageId}}consumerGroup(e,t){return new bo(this.client,this.topicName,e,t)}get name(){return this.topicName}},So=`com.vercel.queue.v1beta`,Co=`com.vercel.queue.v2beta`;function wo(e,t){let n=t.slice(0,-1);return e.startsWith(n)}function To(e){return typeof e==`object`&&!!e}function Eo(e,t){if(!t||!t.includes(`application/cloudevents+json`))throw Error(`Invalid content type: expected 'application/cloudevents+json'`);if(!To(e)||!e.type||!e.source||!e.id||!To(e.data))throw Error(`Invalid CloudEvent: missing required fields`);if(e.type!==`com.vercel.queue.v1beta`)throw Error(`Invalid CloudEvent type: expected '${So}', got '${String(e.type)}'`);let{data:n}=e,r=[];if(`queueName`in n||r.push(`queueName`),`consumerGroup`in n||r.push(`consumerGroup`),`messageId`in n||r.push(`messageId`),r.length>0)throw Error(`Missing required CloudEvent data fields: ${r.join(`, `)}`);return{queueName:String(n.queueName),consumerGroup:String(n.consumerGroup),messageId:String(n.messageId)}}function Q(e,t){if(e instanceof Headers)return e.get(t);let n=e[t];return Array.isArray(n)?n[0]??null:n??null}function Do(e){let t=Q(e,`ce-type`);if(t!==`com.vercel.queue.v2beta`)throw Error(`Invalid CloudEvent type: expected '${Co}', got '${t}'`);let n=Q(e,`ce-vqsqueuename`),r=Q(e,`ce-vqsconsumergroup`),i=Q(e,`ce-vqsmessageid`),a=[];if(n||a.push(`ce-vqsqueuename`),r||a.push(`ce-vqsconsumergroup`),i||a.push(`ce-vqsmessageid`),a.length>0)throw Error(`Missing required CloudEvent headers: ${a.join(`, `)}`);let o=Q(e,`ce-vqsregion`)??void 0;if(o!==void 0&&!/^[a-z]{2,5}[0-9]{1,2}$/.test(o))throw Error(`Invalid ce-vqsregion header: ${JSON.stringify(o)}. Region must match /^[a-z]{2,5}[0-9]{1,2}$/ (e.g. "iad1", "lhr1").`);let s={queueName:n,consumerGroup:r,messageId:i,region:o},c=Q(e,`ce-vqsreceipthandle`);if(!c)return s;let l={...s,receiptHandle:c},u=Q(e,`ce-vqsdeliverycount`);u&&(l.deliveryCount=parseInt(u,10));let d=Q(e,`ce-vqscreatedat`);d&&(l.createdAt=d);let f=Q(e,`ce-vqsexpiresat`);f&&(l.expiresAt=f);let p=Q(e,`content-type`);p&&(l.contentType=p);let m=Q(e,`ce-vqsvisibilitydeadline`);return m&&(l.visibilityDeadline=m),l}function Oo(e,t){if(Q(t,`ce-type`)===`com.vercel.queue.v2beta`){let n=Do(t);return`receiptHandle`in n&&(n.parsedPayload=e),n}return Eo(e,Q(t,`content-type`))}async function ko(e){if(e.headers.get(`ce-type`)===`com.vercel.queue.v2beta`){let t=Do(e.headers);return`receiptHandle`in t&&e.body&&(t.rawBody=e.body),t}let t;try{t=await e.json()}catch{throw Error(`Failed to parse CloudEvent from request body`)}let n={};return e.headers.forEach((e,t)=>{n[t]=e}),Oo(t,n)}async function Ao(e,t,n){let{queueName:r,consumerGroup:i,messageId:a}=t;if(!n?.client)throw Error(`HandleCallbackOptions.client is required`);let o=$s(n.client);t.region&&(o=o.withRegion(t.region));let s=new xo(o,r).consumerGroup(i,n?.visibilityTimeoutSeconds===void 0?void 0:{visibilityTimeoutSeconds:n.visibilityTimeoutSeconds});if(`receiptHandle`in t){let r=o.getTransport(),i;if(t.rawBody)i=await r.deserialize(t.rawBody);else if(t.parsedPayload!==void 0)i=t.parsedPayload;else throw Error(`Binary mode callback with receipt handle is missing payload`);let c={messageId:a,payload:i,deliveryCount:t.deliveryCount??1,createdAt:t.createdAt?new Date(t.createdAt):new Date,expiresAt:t.expiresAt?new Date(t.expiresAt):void 0,contentType:t.contentType??r.contentType,receiptHandle:t.receiptHandle},l=t.visibilityDeadline?new Date(t.visibilityDeadline):void 0;await s.consumeMessage(e,c,{visibilityDeadline:l,retry:n?.retry})}else await s.consume(e,{messageId:a,retry:n?.retry})}var $=Ja.default.cyan(`[queue]`),jo=Ja.default.green(`✓`),Mo=Ja.default.red(`✗`),No=Ja.default.yellow(`↻`);function Po(){return process.env.NODE_ENV===`development`&&process.env.VERCEL_DEPLOYMENT_ID===void 0}var Fo=Symbol.for(`@vercel/queue.devRouteMappings`);function Io(e){let t=``;for(let n of e)n===`_`?t+=`__`:n===`/`?t+=`_S`:n===`.`?t+=`_D`:/[A-Za-z0-9-]/.test(n)?t+=n:t+=`_`+n.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`);return t}function Lo(){let e=globalThis;if(Fo in e)return e[Fo]??null;try{let t=be.join(process.cwd(),`vercel.json`);if(!xe.existsSync(t))return e[Fo]=null,null;let n=JSON.parse(xe.readFileSync(t,`utf-8`));if(!n.functions)return e[Fo]=null,null;let r=[];for(let[e,t]of Object.entries(n.functions))if(t.experimentalTriggers){for(let n of t.experimentalTriggers)if(!(!n.type?.startsWith(`queue/`)||!n.topic)){if(n.type!==`queue/v2beta`){console.warn(`${$} Unsupported trigger type "${n.type}" for topic "${n.topic}" in ${e}. Use "queue/v2beta" instead.`);continue}r.push({filePath:e,topic:n.topic,consumer:Io(e),retryAfterSeconds:n.retryAfterSeconds})}}return e[Fo]=r.length>0?r:null,e[Fo]}catch(t){return console.warn(`${$} Failed to read vercel.json:`,t),e[Fo]=null,null}}function Ro(e){let t=Lo();return t?t.filter(t=>t.topic.includes(`*`)?wo(e,t.topic):t.topic===e):[]}function zo(e,t){return Ro(e).find(e=>e.consumer===t)?.retryAfterSeconds}function Bo(e){return/^src\/(app|pages|server)\//.test(e)?e.slice(4):null}function Vo(e,t){return e===t||Y(e,t)}function Ho(e){let t=Lo();if(!t)return[];let n=process.cwd(),r;try{r=be.relative(n,e)}catch{return[]}let i=r.replace(/\\/g,`/`),a=Bo(i);return t.filter(e=>Vo(i,e.filePath)||a!==null&&Vo(a,e.filePath))}function Uo(e){let t=e.match(/\((.+?):\d+:\d+\)/);if(t||=e.match(/at\s+(.+?):\d+:\d+/),!t)return null;let n=t[1].trim();if(n===`native`||n.startsWith(`node:`)||n.startsWith(`internal`))return null;if(n.startsWith(`file://`))try{n=new URL(n).pathname}catch{return null}return/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(n)?null:(n.startsWith(`./`)&&(n=n.slice(2)),n)}var Wo;function Go(){if(Wo)return Wo;try{let e=typeof __dirname<`u`?__dirname:be.dirname(new URL(import.meta.url).pathname);Wo=be.resolve(e,`..`)}catch{Wo=``}return Wo}function Ko(){let e=Error().stack;if(!e)return null;let t=e.split(`
|
|
13
|
-
`).slice(1),n=
|
|
11
|
+
`)(e,n),a=2),i===-1){let t=e.subarray(n);if(t.length>this.maxHeaderSize)throw new q(`Headers too large: ${t.length} > ${this.maxHeaderSize} bytes`);this.buffer=t;break}let o=e.subarray(n,i);this.currentHeaders=oi(o);let s=this.createStreamingMessage();t.push(s),n=i+a,this.state=3;continue}if(this.state===0){if(r<this.openingBoundaryLength){if(e.length>this.maxBoundaryBuffer)throw new q(`Initial chunk too large for boundary detection: ${e.length} > ${this.maxBoundaryBuffer}`);this.buffer=e;break}if(this.findOpeningBoundary(e)!==0)throw new q(`Invalid multipart stream: missing initial boundary`);n=this.openingBoundaryLength,this.state=1}}return t}createStreamingMessage(){let e=new Headers(this.currentHeaders),t=new ReadableStream({start:e=>{this.currentPayloadController=e}});return this.currentHeaders=new Headers,{headers:e,payload:t}}writeBody(e){this.currentPayloadController&&this.currentPayloadController.enqueue(e)}finishMessage(){this.currentPayloadController&&=(this.currentPayloadController.close(),null)}closeCurrentPayload(e){if(this.currentPayloadController){try{e?this.currentPayloadController.error(e):this.currentPayloadController.close()}catch{}this.currentPayloadController=null}}};const di=(e,t,n)=>{let r=e instanceof RegExp?fi(e,n):e,i=t instanceof RegExp?fi(t,n):t,a=r!==null&&i!=null&&pi(r,i,n);return a&&{start:a[0],end:a[1],pre:n.slice(0,a[0]),body:n.slice(a[0]+r.length,a[1]),post:n.slice(a[1]+i.length)}},fi=(e,t)=>{let n=t.match(e);return n?n[0]:null},pi=(e,t,n)=>{let r,i,a,o,s,c=n.indexOf(e),l=n.indexOf(t,c+1),u=c;if(c>=0&&l>0){if(e===t)return[c,l];for(r=[],a=n.length;u>=0&&!s;){if(u===c)r.push(u),c=n.indexOf(e,u+1);else if(r.length===1){let e=r.pop();e!==void 0&&(s=[e,l])}else i=r.pop(),i!==void 0&&i<a&&(a=i,o=l),l=n.indexOf(t,u+1);u=c<l&&c>=0?c:l}r.length&&o!==void 0&&(s=[a,o])}return s},mi=`\0SLASH`+Math.random()+`\0`,hi=`\0OPEN`+Math.random()+`\0`,gi=`\0CLOSE`+Math.random()+`\0`,_i=`\0COMMA`+Math.random()+`\0`,vi=`\0PERIOD`+Math.random()+`\0`,yi=new RegExp(mi,`g`),bi=new RegExp(hi,`g`),xi=new RegExp(gi,`g`),Si=new RegExp(_i,`g`),Ci=new RegExp(vi,`g`),wi=/\\\\/g,Ti=/\\{/g,Ei=/\\}/g,Di=/\\,/g,Oi=/\\\./g;function ki(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function Ai(e){return e.replace(wi,mi).replace(Ti,hi).replace(Ei,gi).replace(Di,_i).replace(Oi,vi)}function ji(e){return e.replace(yi,`\\`).replace(bi,`{`).replace(xi,`}`).replace(Si,`,`).replace(Ci,`.`)}function Mi(e){if(!e)return[``];let t=[],n=di(`{`,`}`,e);if(!n)return e.split(`,`);let{pre:r,body:i,post:a}=n,o=r.split(`,`);o[o.length-1]+=`{`+i+`}`;let s=Mi(a);return a.length&&(o[o.length-1]+=s.shift(),o.push.apply(o,s)),t.push.apply(t,o),t}function Ni(e,t={}){if(!e)return[];let{max:n=1e5}=t;return e.slice(0,2)===`{}`&&(e=`\\{\\}`+e.slice(2)),Ri(Ai(e),n,!0).map(ji)}function Pi(e){return`{`+e+`}`}function Fi(e){return/^-?0\d/.test(e)}function Ii(e,t){return e<=t}function Li(e,t){return e>=t}function Ri(e,t,n){let r=[];for(;;){let i=di(`{`,`}`,e);if(!i)return[e];let a=i.pre;if(/\$$/.test(i.pre)){let e=i.post.length?Ri(i.post,t,!1):[``];for(let n=0;n<e.length&&n<t;n++){let t=a+`{`+i.body+`}`+e[n];r.push(t)}return r}let o=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),s=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),c=o||s,l=i.body.indexOf(`,`)>=0;if(!c&&!l){if(i.post.match(/,(?!,).*\}/)){e=i.pre+`{`+i.body+gi+i.post,n=!0;continue}return[e]}let u=i.post.length?Ri(i.post,t,!1):[``],d;if(c)d=i.body.split(/\.\./);else if(d=Mi(i.body),d.length===1&&d[0]!==void 0&&(d=Ri(d[0],t,!1).map(Pi),d.length===1))return u.map(e=>i.pre+d[0]+e);let f;if(c&&d[0]!==void 0&&d[1]!==void 0){let e=ki(d[0]),n=ki(d[1]),r=Math.max(d[0].length,d[1].length),i=d.length===3&&d[2]!==void 0?Math.max(Math.abs(ki(d[2])),1):1,a=Ii;n<e&&(i*=-1,a=Li);let o=d.some(Fi);f=[];for(let c=e;a(c,n)&&f.length<t;c+=i){let e;if(s)e=String.fromCharCode(c),e===`\\`&&(e=``);else if(e=String(c),o){let t=r-e.length;if(t>0){let n=Array(t+1).join(`0`);e=c<0?`-`+n+e.slice(1):n+e}}f.push(e)}}else{f=[];for(let e=0;e<d.length;e++)f.push.apply(f,Ri(d[e],t,!1))}for(let e=0;e<f.length;e++)for(let i=0;i<u.length&&r.length<t;i++){let t=a+f[e]+u[i];(!n||c||t)&&r.push(t)}return r}}const zi=e=>{if(typeof e!=`string`)throw TypeError(`invalid pattern`);if(e.length>65536)throw TypeError(`pattern is too long`)},Bi={"[:alnum:]":[`\\p{L}\\p{Nl}\\p{Nd}`,!0],"[:alpha:]":[`\\p{L}\\p{Nl}`,!0],"[:ascii:]":[`\\x00-\\x7f`,!1],"[:blank:]":[`\\p{Zs}\\t`,!0],"[:cntrl:]":[`\\p{Cc}`,!0],"[:digit:]":[`\\p{Nd}`,!0],"[:graph:]":[`\\p{Z}\\p{C}`,!0,!0],"[:lower:]":[`\\p{Ll}`,!0],"[:print:]":[`\\p{C}`,!0],"[:punct:]":[`\\p{P}`,!0],"[:space:]":[`\\p{Z}\\t\\r\\n\\v\\f`,!0],"[:upper:]":[`\\p{Lu}`,!0],"[:word:]":[`\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}`,!0],"[:xdigit:]":[`A-Fa-f0-9`,!1]},Vi=e=>e.replace(/[[\]\\-]/g,`\\$&`),Hi=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),Ui=e=>e.join(``),Wi=(e,t)=>{let n=t;if(e.charAt(n)!==`[`)throw Error(`not in a brace expression`);let r=[],i=[],a=n+1,o=!1,s=!1,c=!1,l=!1,u=n,d=``;WHILE:for(;a<e.length;){let t=e.charAt(a);if((t===`!`||t===`^`)&&a===n+1){l=!0,a++;continue}if(t===`]`&&o&&!c){u=a+1;break}if(o=!0,t===`\\`&&!c){c=!0,a++;continue}if(t===`[`&&!c){for(let[t,[o,c,l]]of Object.entries(Bi))if(e.startsWith(t,a)){if(d)return[`$.`,!1,e.length-n,!0];a+=t.length,l?i.push(o):r.push(o),s||=c;continue WHILE}}if(c=!1,d){t>d?r.push(Vi(d)+`-`+Vi(t)):t===d&&r.push(Vi(t)),d=``,a++;continue}if(e.startsWith(`-]`,a+1)){r.push(Vi(t+`-`)),a+=2;continue}if(e.startsWith(`-`,a+1)){d=t,a+=2;continue}r.push(Vi(t)),a++}if(u<a)return[``,!1,0,!1];if(!r.length&&!i.length)return[`$.`,!1,e.length-n,!0];if(i.length===0&&r.length===1&&/^\\?.$/.test(r[0])&&!l)return[Hi(r[0].length===2?r[0].slice(-1):r[0]),!1,u-n,!1];let f=`[`+(l?`^`:``)+Ui(r)+`]`,p=`[`+(l?``:`^`)+Ui(i)+`]`;return[r.length&&i.length?`(`+f+`|`+p+`)`:r.length?f:p,s,u-n,!0]},Gi=(e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!0}={})=>n?t?e.replace(/\[([^/\\])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^/\\])\]/g,`$1$2`).replace(/\\([^/])/g,`$1`):t?e.replace(/\[([^/\\{}])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,`$1$2`).replace(/\\([^/{}])/g,`$1`);var J;const Ki=new Set([`!`,`?`,`+`,`*`,`@`]),qi=e=>Ki.has(e),Ji=e=>qi(e.type),Yi=new Map([[`!`,[`@`]],[`?`,[`?`,`@`]],[`@`,[`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`]]]),Xi=new Map([[`!`,[`?`]],[`@`,[`?`]],[`+`,[`?`,`*`]]]),Zi=new Map([[`!`,[`?`,`@`]],[`?`,[`?`,`@`]],[`@`,[`?`,`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`,`?`,`*`]]]),Qi=new Map([[`!`,new Map([[`!`,`@`]])],[`?`,new Map([[`*`,`*`],[`+`,`*`]])],[`@`,new Map([[`!`,`!`],[`?`,`?`],[`@`,`@`],[`*`,`*`],[`+`,`+`]])],[`+`,new Map([[`?`,`*`],[`*`,`*`]])]]),$i=`(?!\\.)`,ea=new Set([`[`,`.`]),ta=new Set([`..`,`.`]),na=new Set(`().*{}+?[]^$\\!`),ra=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),ia=`[^/]+?`;let aa=0;var oa=class{type;#e;#t;#n=!1;#r=[];#i;#a;#o;#s=!1;#c;#l;#u=!1;id=++aa;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for(`nodejs.util.inspect.custom`)](){return{"@@type":`AST`,id:this.id,type:this.type,root:this.#e.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(e,t,n={}){this.type=e,e&&(this.#t=!0),this.#i=t,this.#e=this.#i?this.#i.#e:this,this.#c=this.#e===this?n:this.#e.#c,this.#o=this.#e===this?[]:this.#e.#o,e===`!`&&!this.#e.#s&&this.#o.push(this),this.#a=this.#i?this.#i.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let e of this.#r)if(typeof e!=`string`&&(e.type||e.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#l===void 0?this.type?this.#l=this.type+`(`+this.#r.map(e=>String(e)).join(`|`)+`)`:this.#l=this.#r.map(e=>String(e)).join(``):this.#l}#d(){if(this!==this.#e)throw Error(`should only call on root`);if(this.#s)return this;this.toString(),this.#s=!0;let e;for(;e=this.#o.pop();){if(e.type!==`!`)continue;let t=e,n=t.#i;for(;n;){for(let r=t.#a+1;!n.type&&r<n.#r.length;r++)for(let t of e.#r){if(typeof t==`string`)throw Error(`string part in extglob AST??`);t.copyIn(n.#r[r])}t=n,n=t.#i}}return this}push(...e){for(let t of e)if(t!==``){if(typeof t!=`string`&&!(t instanceof J&&t.#i===this))throw Error(`invalid part: `+t);this.#r.push(t)}}toJSON(){let e=this.type===null?this.#r.slice().map(e=>typeof e==`string`?e:e.toJSON()):[this.type,...this.#r.map(e=>e.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#s&&this.#i?.type===`!`)&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#a===0)return!0;let e=this.#i;for(let t=0;t<this.#a;t++){let n=e.#r[t];if(!(n instanceof J&&n.type===`!`))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type===`!`)return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let e=this.#i?this.#i.#r.length:0;return this.#a===e-1}copyIn(e){typeof e==`string`?this.push(e):this.push(e.clone(this))}clone(e){let t=new J(this.type,e);for(let e of this.#r)t.copyIn(e);return t}static#f(e,t,n,r,i){let a=r.maxExtglobRecursion??2,o=!1,s=!1,c=-1,l=!1;if(t.type===null){let u=n,d=``;for(;u<e.length;){let n=e.charAt(u++);if(o||n===`\\`){o=!o,d+=n;continue}if(s){u===c+1?(n===`^`||n===`!`)&&(l=!0):n===`]`&&!(u===c+2&&l)&&(s=!1),d+=n;continue}else if(n===`[`){s=!0,c=u,l=!1,d+=n;continue}if(!r.noext&&qi(n)&&e.charAt(u)===`(`&&i<=a){t.push(d),d=``;let a=new J(n,t);u=J.#f(e,a,u,r,i+1),t.push(a);continue}d+=n}return t.push(d),u}let u=n+1,d=new J(null,t),f=[],p=``;for(;u<e.length;){let n=e.charAt(u++);if(o||n===`\\`){o=!o,p+=n;continue}if(s){u===c+1?(n===`^`||n===`!`)&&(l=!0):n===`]`&&!(u===c+2&&l)&&(s=!1),p+=n;continue}else if(n===`[`){s=!0,c=u,l=!1,p+=n;continue}if(!r.noext&&qi(n)&&e.charAt(u)===`(`&&(i<=a||t&&t.#h(n))){let a=t&&t.#h(n)?0:1;d.push(p),p=``;let o=new J(n,d);d.push(o),u=J.#f(e,o,u,r,i+a);continue}if(n===`|`){d.push(p),p=``,f.push(d),d=new J(null,t);continue}if(n===`)`)return p===``&&t.#r.length===0&&(t.#u=!0),d.push(p),p=``,t.push(...f,d),u;p+=n}return t.type=null,t.#t=void 0,t.#r=[e.substring(n-1)],u}#p(e){return this.#m(e,Xi)}#m(e,t=Yi){if(!e||typeof e!=`object`||e.type!==null||e.#r.length!==1||this.type===null)return!1;let n=e.#r[0];return!n||typeof n!=`object`||n.type===null?!1:this.#h(n.type,t)}#h(e,t=Zi){return!!t.get(this.type)?.includes(e)}#g(e,t){let n=e.#r[0],r=new J(null,n,this.options);r.#r.push(``),n.push(r),this.#_(e,t)}#_(e,t){let n=e.#r[0];this.#r.splice(t,1,...n.#r);for(let e of n.#r)typeof e==`object`&&(e.#i=this);this.#l=void 0}#v(e){return!!Qi.get(this.type)?.has(e)}#y(e){if(!e||typeof e!=`object`||e.type!==null||e.#r.length!==1||this.type===null||this.#r.length!==1)return!1;let t=e.#r[0];return!t||typeof t!=`object`||t.type===null?!1:this.#v(t.type)}#b(e){let t=Qi.get(this.type),n=e.#r[0],r=t?.get(n.type);if(!r)return!1;this.#r=n.#r;for(let e of this.#r)typeof e==`object`&&(e.#i=this);this.type=r,this.#l=void 0,this.#u=!1}static fromGlob(e,t={}){let n=new J(null,void 0,t);return J.#f(e,n,0,t,0),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let e=this.toString(),[t,n,r,i]=this.toRegExpSource();if(!(r||this.#t||this.#c.nocase&&!this.#c.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return n;let a=(this.#c.nocase?`i`:``)+(i?`u`:``);return Object.assign(RegExp(`^${t}$`,a),{_src:t,_glob:e})}get options(){return this.#c}toRegExpSource(e){let t=e??!!this.#c.dot;if(this.#e===this&&(this.#x(),this.#d()),!Ji(this)){let n=this.isStart()&&this.isEnd()&&!this.#r.some(e=>typeof e!=`string`),r=this.#r.map(t=>{let[r,i,a,o]=typeof t==`string`?J.#C(t,this.#t,n):t.toRegExpSource(e);return this.#t=this.#t||a,this.#n=this.#n||o,r}).join(``),i=``;if(this.isStart()&&typeof this.#r[0]==`string`&&!(this.#r.length===1&&ta.has(this.#r[0]))){let n=ea,a=t&&n.has(r.charAt(0))||r.startsWith(`\\.`)&&n.has(r.charAt(2))||r.startsWith(`\\.\\.`)&&n.has(r.charAt(4)),o=!t&&!e&&n.has(r.charAt(0));i=a?`(?!(?:^|/)\\.\\.?(?:$|/))`:o?$i:``}let a=``;return this.isEnd()&&this.#e.#s&&this.#i?.type===`!`&&(a=`(?:$|\\/)`),[i+r+a,Gi(r),this.#t=!!this.#t,this.#n]}let n=this.type===`*`||this.type===`+`,r=this.type===`!`?`(?:(?!(?:`:`(?:`,i=this.#S(t);if(this.isStart()&&this.isEnd()&&!i&&this.type!==`!`){let e=this.toString(),t=this;return t.#r=[e],t.type=null,t.#t=void 0,[e,Gi(this.toString()),!1,!1]}let a=!n||e||t?``:this.#S(!0);a===i&&(a=``),a&&(i=`(?:${i})(?:${a})*?`);let o=``;if(this.type===`!`&&this.#u)o=(this.isStart()&&!t?$i:``)+ia;else{let n=this.type===`!`?`))`+(this.isStart()&&!t&&!e?$i:``)+`[^/]*?)`:this.type===`@`?`)`:this.type===`?`?`)?`:this.type===`+`&&a?`)`:this.type===`*`&&a?`)?`:`)${this.type}`;o=r+i+n}return[o,Gi(i),this.#t=!!this.#t,this.#n]}#x(){if(Ji(this)){let e=0,t=!1;do{t=!0;for(let e=0;e<this.#r.length;e++){let n=this.#r[e];typeof n==`object`&&(n.#x(),this.#m(n)?(t=!1,this.#_(n,e)):this.#p(n)?(t=!1,this.#g(n,e)):this.#y(n)&&(t=!1,this.#b(n)))}}while(!t&&++e<10)}else for(let e of this.#r)typeof e==`object`&&e.#x();this.#l=void 0}#S(e){return this.#r.map(t=>{if(typeof t==`string`)throw Error(`string type in extglob ast??`);let[n,r,i,a]=t.toRegExpSource(e);return this.#n=this.#n||a,n}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join(`|`)}static#C(e,t,n=!1){let r=!1,i=``,a=!1,o=!1;for(let s=0;s<e.length;s++){let c=e.charAt(s);if(r){r=!1,i+=(na.has(c)?`\\`:``)+c;continue}if(c===`*`){if(o)continue;o=!0,i+=n&&/^[*]+$/.test(e)?ia:`[^/]*?`,t=!0;continue}else o=!1;if(c===`\\`){s===e.length-1?i+=`\\\\`:r=!0;continue}if(c===`[`){let[n,r,o,c]=Wi(e,s);if(o){i+=n,a||=r,s+=o-1,t||=c;continue}}if(c===`?`){i+=`[^/]`,t=!0;continue}i+=ra(c)}return[i,Gi(e),!!t,a]}};J=oa;const sa=(e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!1}={})=>n?t?e.replace(/[?*()[\]{}]/g,`[$&]`):e.replace(/[?*()[\]\\{}]/g,`\\$&`):t?e.replace(/[?*()[\]]/g,`[$&]`):e.replace(/[?*()[\]\\]/g,`\\$&`),Y=(e,t,n={})=>(zi(t),!n.nocomment&&t.charAt(0)===`#`?!1:new Na(t,n).match(e)),ca=/^\*+([^+@!?*[(]*)$/,la=e=>t=>!t.startsWith(`.`)&&t.endsWith(e),ua=e=>t=>t.endsWith(e),da=e=>(e=e.toLowerCase(),t=>!t.startsWith(`.`)&&t.toLowerCase().endsWith(e)),fa=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),pa=/^\*+\.\*+$/,ma=e=>!e.startsWith(`.`)&&e.includes(`.`),ha=e=>e!==`.`&&e!==`..`&&e.includes(`.`),ga=/^\.\*+$/,_a=e=>e!==`.`&&e!==`..`&&e.startsWith(`.`),va=/^\*+$/,ya=e=>e.length!==0&&!e.startsWith(`.`),ba=e=>e.length!==0&&e!==`.`&&e!==`..`,xa=/^\?+([^+@!?*[(]*)?$/,Sa=([e,t=``])=>{let n=Ea([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},Ca=([e,t=``])=>{let n=Da([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},wa=([e,t=``])=>{let n=Da([e]);return t?e=>n(e)&&e.endsWith(t):n},Ta=([e,t=``])=>{let n=Ea([e]);return t?e=>n(e)&&e.endsWith(t):n},Ea=([e])=>{let t=e.length;return e=>e.length===t&&!e.startsWith(`.`)},Da=([e])=>{let t=e.length;return e=>e.length===t&&e!==`.`&&e!==`..`},Oa=typeof process==`object`&&process?typeof process.env==`object`&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:`posix`,ka={win32:{sep:`\\`},posix:{sep:`/`}};Y.sep=Oa===`win32`?ka.win32.sep:ka.posix.sep;const X=Symbol(`globstar **`);Y.GLOBSTAR=X,Y.filter=(e,t={})=>n=>Y(n,e,t);const Z=(e,t={})=>Object.assign({},e,t);Y.defaults=e=>{if(!e||typeof e!=`object`||!Object.keys(e).length)return Y;let t=Y;return Object.assign((n,r,i={})=>t(n,r,Z(e,i)),{Minimatch:class extends t.Minimatch{constructor(t,n={}){super(t,Z(e,n))}static defaults(n){return t.defaults(Z(e,n)).Minimatch}},AST:class extends t.AST{constructor(t,n,r={}){super(t,n,Z(e,r))}static fromGlob(n,r={}){return t.AST.fromGlob(n,Z(e,r))}},unescape:(n,r={})=>t.unescape(n,Z(e,r)),escape:(n,r={})=>t.escape(n,Z(e,r)),filter:(n,r={})=>t.filter(n,Z(e,r)),defaults:n=>t.defaults(Z(e,n)),makeRe:(n,r={})=>t.makeRe(n,Z(e,r)),braceExpand:(n,r={})=>t.braceExpand(n,Z(e,r)),match:(n,r,i={})=>t.match(n,r,Z(e,i)),sep:t.sep,GLOBSTAR:X})};const Aa=(e,t={})=>(zi(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Ni(e,{max:t.braceExpandMax}));Y.braceExpand=Aa,Y.makeRe=(e,t={})=>new Na(e,t).makeRe(),Y.match=(e,t,n={})=>{let r=new Na(t,n);return e=e.filter(e=>r.match(e)),r.options.nonull&&!e.length&&e.push(t),e};const ja=/[?*]|[+@!]\(.*?\)|\[|\]/,Ma=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`);var Na=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,t={}){zi(e),t||={},this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion??200,this.pattern=e,this.platform=t.platform||Oa,this.isWindows=this.platform===`win32`,this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,`/`)),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot===void 0?!!(this.isWindows&&this.nocase):t.windowsNoMagicRoot,this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let t of e)if(typeof t!=`string`)return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)===`#`){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...e)=>console.error(...e)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(e=>this.slashSplit(e));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let r=this.globParts.map((e,t,n)=>{if(this.isWindows&&this.windowsNoMagicRoot){let t=e[0]===``&&e[1]===``&&(e[2]===`?`||!ja.test(e[2]))&&!ja.test(e[3]),n=/^[a-z]:/i.test(e[0]);if(t)return[...e.slice(0,4),...e.slice(4).map(e=>this.parse(e))];if(n)return[e[0],...e.slice(1).map(e=>this.parse(e))]}return e.map(e=>this.parse(e))});if(this.debug(this.pattern,r),this.set=r.filter(e=>e.indexOf(!1)===-1),this.isWindows)for(let e=0;e<this.set.length;e++){let t=this.set[e];t[0]===``&&t[1]===``&&this.globParts[e][2]===`?`&&typeof t[3]==`string`&&/^[a-z]:$/i.test(t[3])&&(t[2]=`?`)}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let t of e)for(let e=0;e<t.length;e++)t[e]===`**`&&(t[e]=`*`);let{optimizationLevel:t=1}=this.options;return t>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):e=t>=1?this.levelOneOptimize(e):this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(e=>{let t=-1;for(;(t=e.indexOf(`**`,t+1))!==-1;){let n=t;for(;e[n+1]===`**`;)n++;n!==t&&e.splice(t,n-t)}return e})}levelOneOptimize(e){return e.map(e=>(e=e.reduce((e,t)=>{let n=e[e.length-1];return t===`**`&&n===`**`?e:t===`..`&&n&&n!==`..`&&n!==`.`&&n!==`**`?(e.pop(),e):(e.push(t),e)},[]),e.length===0?[``]:e))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let n=1;n<e.length-1;n++){let r=e[n];n===1&&r===``&&e[0]===``||(r===`.`||r===``)&&(t=!0,e.splice(n,1),n--)}e[0]===`.`&&e.length===2&&(e[1]===`.`||e[1]===``)&&(t=!0,e.pop())}let n=0;for(;(n=e.indexOf(`..`,n+1))!==-1;){let r=e[n-1];r&&r!==`.`&&r!==`..`&&r!==`**`&&!(this.isWindows&&/^[a-z]:$/i.test(r))&&(t=!0,e.splice(n-1,2),n-=2)}}while(t);return e.length===0?[``]:e}firstPhasePreProcess(e){let t=!1;do{t=!1;for(let n of e){let r=-1;for(;(r=n.indexOf(`**`,r+1))!==-1;){let i=r;for(;n[i+1]===`**`;)i++;i>r&&n.splice(r+1,i-r);let a=n[r+1],o=n[r+2],s=n[r+3];if(a!==`..`||!o||o===`.`||o===`..`||!s||s===`.`||s===`..`)continue;t=!0,n.splice(r,1);let c=n.slice(0);c[r]=`**`,e.push(c),r--}if(!this.preserveMultipleSlashes){for(let e=1;e<n.length-1;e++){let r=n[e];e===1&&r===``&&n[0]===``||(r===`.`||r===``)&&(t=!0,n.splice(e,1),e--)}n[0]===`.`&&n.length===2&&(n[1]===`.`||n[1]===``)&&(t=!0,n.pop())}let i=0;for(;(i=n.indexOf(`..`,i+1))!==-1;){let e=n[i-1];if(e&&e!==`.`&&e!==`..`&&e!==`**`){t=!0;let e=i===1&&n[i+1]===`**`?[`.`]:[];n.splice(i-1,2,...e),n.length===0&&n.push(``),i-=2}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let n=t+1;n<e.length;n++){let r=this.partsMatch(e[t],e[n],!this.preserveMultipleSlashes);if(r){e[t]=[],e[n]=r;break}}return e.filter(e=>e.length)}partsMatch(e,t,n=!1){let r=0,i=0,a=[],o=``;for(;r<e.length&&i<t.length;)if(e[r]===t[i])a.push(o===`b`?t[i]:e[r]),r++,i++;else if(n&&e[r]===`**`&&t[i]===e[r+1])a.push(e[r]),r++;else if(n&&t[i]===`**`&&e[r]===t[i+1])a.push(t[i]),i++;else if(e[r]===`*`&&t[i]&&(this.options.dot||!t[i].startsWith(`.`))&&t[i]!==`**`){if(o===`b`)return!1;o=`a`,a.push(e[r]),r++,i++}else if(t[i]===`*`&&e[r]&&(this.options.dot||!e[r].startsWith(`.`))&&e[r]!==`**`){if(o===`a`)return!1;o=`b`,a.push(t[i]),r++,i++}else return!1;return e.length===t.length&&a}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=!1,n=0;for(let r=0;r<e.length&&e.charAt(r)===`!`;r++)t=!t,n++;n&&(this.pattern=e.slice(n)),this.negate=t}matchOne(e,t,n=!1){let r=0,i=0;if(this.isWindows){let n=typeof e[0]==`string`&&/^[a-z]:$/i.test(e[0]),a=!n&&e[0]===``&&e[1]===``&&e[2]===`?`&&/^[a-z]:$/i.test(e[3]),o=typeof t[0]==`string`&&/^[a-z]:$/i.test(t[0]),s=!o&&t[0]===``&&t[1]===``&&t[2]===`?`&&typeof t[3]==`string`&&/^[a-z]:$/i.test(t[3]),c=a?3:n?0:void 0,l=s?3:o?0:void 0;if(typeof c==`number`&&typeof l==`number`){let[n,a]=[e[c],t[l]];n.toLowerCase()===a.toLowerCase()&&(t[l]=n,i=l,r=c)}}let{optimizationLevel:a=1}=this.options;return a>=2&&(e=this.levelTwoFileOptimize(e)),t.includes(X)?this.#e(e,t,n,r,i):this.#n(e,t,n,r,i)}#e(e,t,n,r,i){let a=t.indexOf(X,i),o=t.lastIndexOf(X),[s,c,l]=n?[t.slice(i,a),t.slice(a+1),[]]:[t.slice(i,a),t.slice(a+1,o),t.slice(o+1)];if(s.length){let t=e.slice(r,r+s.length);if(!this.#n(t,s,n,0,0))return!1;r+=s.length,i+=s.length}let u=0;if(l.length){if(l.length+r>e.length)return!1;let t=e.length-l.length;if(this.#n(e,l,n,t,0))u=l.length;else{if(e[e.length-1]!==``||r+l.length===e.length||(t--,!this.#n(e,l,n,t,0)))return!1;u=l.length+1}}if(!c.length){let t=!!u;for(let n=r;n<e.length-u;n++){let r=String(e[n]);if(t=!0,r===`.`||r===`..`||!this.options.dot&&r.startsWith(`.`))return!1}return n||t}let d=[[[],0]],f=d[0],p=0,m=[0];for(let e of c)e===X?(m.push(p),f=[[],0],d.push(f)):(f[0].push(e),p++);let h=d.length-1,g=e.length-u;for(let e of d)e[1]=g-(m[h--]+e[0].length);return!!this.#t(e,d,r,0,n,0,!!u)}#t(e,t,n,r,i,a,o){let s=t[r];if(!s){for(let t=n;t<e.length;t++){o=!0;let n=e[t];if(n===`.`||n===`..`||!this.options.dot&&n.startsWith(`.`))return!1}return o}let[c,l]=s;for(;n<=l;){if(this.#n(e.slice(0,n+c.length),c,i,n,0)&&a<this.maxGlobstarRecursion){let s=this.#t(e,t,n+c.length,r+1,i,a+1,o);if(s!==!1)return s}let s=e[n];if(s===`.`||s===`..`||!this.options.dot&&s.startsWith(`.`))return!1;n++}return i||null}#n(e,t,n,r,i){let a,o,s,c;for(a=r,o=i,c=e.length,s=t.length;a<c&&o<s;a++,o++){this.debug(`matchOne loop`);let n=t[o],r=e[a];if(this.debug(t,n,r),n===!1||n===X)return!1;let i;if(typeof n==`string`?(i=r===n,this.debug(`string match`,n,r,i)):(i=n.test(r),this.debug(`pattern match`,n,r,i)),!i)return!1}if(a===c&&o===s)return!0;if(a===c)return n;if(o===s)return a===c-1&&e[a]===``;throw Error(`wtf?`)}braceExpand(){return Aa(this.pattern,this.options)}parse(e){zi(e);let t=this.options;if(e===`**`)return X;if(e===``)return``;let n,r=null;(n=e.match(va))?r=t.dot?ba:ya:(n=e.match(ca))?r=(t.nocase?t.dot?fa:da:t.dot?ua:la)(n[1]):(n=e.match(xa))?r=(t.nocase?t.dot?Ca:Sa:t.dot?wa:Ta)(n):(n=e.match(pa))?r=t.dot?ha:ma:(n=e.match(ga))&&(r=_a);let i=oa.fromGlob(e,this.options).toMMPattern();return r&&typeof i==`object`&&Reflect.defineProperty(i,"test",{value:r}),i}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let t=this.options,n=t.noglobstar?`[^/]*?`:t.dot?`(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?`:`(?:(?!(?:\\/|^)\\.).)*?`,r=new Set(t.nocase?[`i`]:[]),i=e.map(e=>{let t=e.map(e=>{if(e instanceof RegExp)for(let t of e.flags.split(``))r.add(t);return typeof e==`string`?Ma(e):e===X?X:e._src});t.forEach((e,r)=>{let i=t[r+1],a=t[r-1];e!==X||a===X||(a===void 0?i!==void 0&&i!==X?t[r+1]=`(?:\\/|`+n+`\\/)?`+i:t[r]=n:i===void 0?t[r-1]=a+`(?:\\/|\\/`+n+`)?`:i!==X&&(t[r-1]=a+`(?:\\/|\\/`+n+`\\/)`+i,t[r+1]=X))});let i=t.filter(e=>e!==X);if(this.partial&&i.length>=1){let e=[];for(let t=1;t<=i.length;t++)e.push(i.slice(0,t).join(`/`));return`(?:`+e.join(`|`)+`)`}return i.join(`/`)}).join(`|`),[a,o]=e.length>1?[`(?:`,`)`]:[``,``];i=`^`+a+i+o+`$`,this.partial&&(i=`^(?:\\/|`+a+i.slice(1,-1)+o+`)$`),this.negate&&(i=`^(?!`+i+`).+$`);try{this.regexp=new RegExp(i,[...r].join(``))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split(`/`):this.isWindows&&/^\/\/[^/]+/.test(e)?[``,...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug(`match`,e,this.pattern),this.comment)return!1;if(this.empty)return e===``;if(e===`/`&&t)return!0;let n=this.options;this.isWindows&&(e=e.split(`\\`).join(`/`));let r=this.slashSplit(e);this.debug(this.pattern,`split`,r);let i=this.set;this.debug(this.pattern,`set`,i);let a=r[r.length-1];if(!a)for(let e=r.length-2;!a&&e>=0;e--)a=r[e];for(let e of i){let i=r;if(n.matchBase&&e.length===1&&(i=[a]),this.matchOne(i,e,t))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(e){return Y.defaults(e).Minimatch}};Y.AST=oa,Y.Minimatch=Na,Y.escape=sa,Y.unescape=Gi;var Pa=n(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c})),Fa=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{SYMBOL_FOR_REQ_CONTEXT:()=>u,getContext:()=>d}),t.exports=c(l);let u=Symbol.for(`@vercel/request-context`);function d(){return globalThis[u]?.get?.()??{}}0&&(t.exports={SYMBOL_FOR_REQ_CONTEXT:u,getContext:d})})),Ia=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{getVercelOidcTokenSync:()=>d}),t.exports=c(l);var u=Fa();function d(){let e=(0,u.getContext)().headers?.[`x-vercel-oidc-token`]??process.env.VERCEL_OIDC_TOKEN;if(!e)throw Error(`The 'x-vercel-oidc-token' header is missing from the request.`);return e}0&&(t.exports={getVercelOidcTokenSync:d})})),La=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{VercelOidcTokenError:()=>u}),t.exports=c(l);var u=class extends Error{constructor(e,t){super(e),this.name=`VercelOidcTokenError`,this.cause=t}toString(){return this.cause?`${this.name}: ${this.message}: ${this.cause}`:`${this.name}: ${this.message}`}};0&&(t.exports={VercelOidcTokenError:u})})),Ra=n(((t,n)=>{var r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})},c=(e,t,n,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==n&&r(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(r({},`__esModule`,{value:!0}),e),u={};s(u,{getVercelOidcToken:()=>p}),n.exports=l(u);var d=Ia(),f=La();async function p(t){let n=``,r;try{n=(0,d.getVercelOidcTokenSync)()}catch(e){r=e}try{let[{getTokenPayload:r,isExpired:i},{refreshToken:a}]=await Promise.all([await Promise.resolve().then(()=>e(Ua())),await import(`../../_chunks/workflow/token-D4VIwGlD.js`).then(t=>e(t.default))]);(!n||i(r(n),t?.expirationBufferMs))&&(await a(t),n=(0,d.getVercelOidcTokenSync)())}catch(e){let t=r instanceof Error?r.message:``;throw e instanceof Error&&(t=`${t}
|
|
12
|
+
${e.message}`),t?new f.VercelOidcTokenError(t):e}return n}0&&(n.exports={getVercelOidcToken:p})})),za=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{AccessTokenMissingError:()=>u,RefreshAccessTokenFailedError:()=>d}),t.exports=c(l);var u=class extends Error{constructor(){super(`No authentication found. Please log in with the Vercel CLI (vercel login).`),this.name=`AccessTokenMissingError`}},d=class extends Error{constructor(e){super(`Failed to refresh authentication token.`,{cause:e}),this.name=`RefreshAccessTokenFailedError`}};0&&(t.exports={AccessTokenMissingError:u,RefreshAccessTokenFailedError:d})})),Ba=n(((e,n)=>{var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},u=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let s of o(t))!c.call(e,s)&&s!==n&&i(e,s,{get:()=>t[s],enumerable:!(r=a(t,s))||r.enumerable});return e},d=(e,t,n)=>(n=e==null?{}:r(s(e)),u(t||!e||!e.__esModule?i(n,`default`,{value:e,enumerable:!0}):n,e)),f=e=>u(i({},`__esModule`,{value:!0}),e),p={};l(p,{findRootDir:()=>v,getUserDataDir:()=>y}),n.exports=f(p);var m=d(t(`path`)),h=d(t(`fs`)),g=d(t(`os`)),_=La();function v(){try{let e=process.cwd();for(;e!==m.default.dirname(e);){let t=m.default.join(e,`.vercel`);if(h.default.existsSync(t))return e;e=m.default.dirname(e)}}catch{throw new _.VercelOidcTokenError(`Token refresh only supported in node server environments`)}return null}function y(){if(process.env.XDG_DATA_HOME)return process.env.XDG_DATA_HOME;switch(g.default.platform()){case`darwin`:return m.default.join(g.default.homedir(),`Library/Application Support`);case`linux`:return m.default.join(g.default.homedir(),`.local/share`);case`win32`:return process.env.LOCALAPPDATA?process.env.LOCALAPPDATA:null;default:return null}}0&&(n.exports={findRootDir:v,getUserDataDir:y})})),Va=n(((e,n)=>{var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},u=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let s of o(t))!c.call(e,s)&&s!==n&&i(e,s,{get:()=>t[s],enumerable:!(r=a(t,s))||r.enumerable});return e},d=(e,t,n)=>(n=e==null?{}:r(s(e)),u(t||!e||!e.__esModule?i(n,`default`,{value:e,enumerable:!0}):n,e)),f=e=>u(i({},`__esModule`,{value:!0}),e),p={};l(p,{isValidAccessToken:()=>b,readAuthConfig:()=>v,writeAuthConfig:()=>y}),n.exports=f(p);var m=d(t(`fs`)),h=d(t(`path`)),g=Ua();function _(){let e=(0,g.getVercelDataDir)();if(!e)throw Error(`Unable to find Vercel CLI data directory. Your platform: ${process.platform}. Supported: darwin, linux, win32.`);return h.join(e,`auth.json`)}function v(){try{let e=_();if(!m.existsSync(e))return null;let t=m.readFileSync(e,`utf8`);return t?JSON.parse(t):null}catch{return null}}function y(e){let t=_(),n=h.dirname(t);m.existsSync(n)||m.mkdirSync(n,{mode:504,recursive:!0}),m.writeFileSync(t,JSON.stringify(e,null,2),{mode:384})}function b(e,t=0){if(!e.token)return!1;if(typeof e.expiresAt!=`number`)return!0;let n=Math.floor(Date.now()/1e3),r=t/1e3;return e.expiresAt>=n+r}0&&(n.exports={isValidAccessToken:b,readAuthConfig:v,writeAuthConfig:y})})),Ha=n(((e,n)=>{var r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})},c=(e,t,n,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==n&&r(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(r({},`__esModule`,{value:!0}),e),u={};s(u,{processTokenResponse:()=>g,refreshTokenRequest:()=>h}),n.exports=l(u);var d=t(`os`);let f=`@vercel/oidc node-${process.version} ${(0,d.platform)()} (${(0,d.arch)()}) ${(0,d.hostname)()}`,p=null;async function m(){if(p)return p;let e=await fetch(`https://vercel.com/.well-known/openid-configuration`,{headers:{"user-agent":f}});if(!e.ok)throw Error(`Failed to discover OAuth endpoints`);let t=await e.json();if(!t||typeof t.token_endpoint!=`string`)throw Error(`Invalid OAuth discovery response`);let n=t.token_endpoint;return p=n,n}async function h(e){let t=await m();return await fetch(t,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`,"user-agent":f},body:new URLSearchParams({client_id:`cl_HYyOPBNtFMfHhaUn9L4QPfTZz6TP47bp`,grant_type:`refresh_token`,...e})})}async function g(e){let t=await e.json();if(!e.ok){let e=typeof t==`object`&&t&&`error`in t?String(t.error):`Token refresh failed`;return[Error(e)]}return typeof t!=`object`||!t?[Error(`Invalid token response`)]:typeof t.access_token==`string`?t.token_type===`Bearer`?typeof t.expires_in==`number`?[null,t]:[Error(`Missing expires_in in response`)]:[Error(`Invalid token_type in response`)]:[Error(`Missing access_token in response`)]}0&&(n.exports={processTokenResponse:g,refreshTokenRequest:h})})),Ua=n(((e,n)=>{var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},u=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let s of o(t))!c.call(e,s)&&s!==n&&i(e,s,{get:()=>t[s],enumerable:!(r=a(t,s))||r.enumerable});return e},d=(e,t,n)=>(n=e==null?{}:r(s(e)),u(t||!e||!e.__esModule?i(n,`default`,{value:e,enumerable:!0}):n,e)),f=e=>u(i({},`__esModule`,{value:!0}),e),p={};l(p,{assertVercelOidcTokenResponse:()=>w,findProjectInfo:()=>T,getTokenPayload:()=>te,getVercelDataDir:()=>x,getVercelOidcToken:()=>C,getVercelToken:()=>S,isExpired:()=>ne,loadToken:()=>E,saveToken:()=>ee}),n.exports=f(p);var m=d(t(`path`)),h=d(t(`fs`)),g=La(),_=Ba(),v=Va(),y=Ha(),b=za();function x(){let e=(0,_.getUserDataDir)();return e?m.join(e,`com.vercel.cli`):null}async function S(e){let t=(0,v.readAuthConfig)();if(!t?.token)throw new b.AccessTokenMissingError;if((0,v.isValidAccessToken)(t,e?.expirationBufferMs))return t.token;if(!t.refreshToken)throw(0,v.writeAuthConfig)({}),new b.RefreshAccessTokenFailedError(`No refresh token available`);try{let e=await(0,y.refreshTokenRequest)({refresh_token:t.refreshToken}),[n,r]=await(0,y.processTokenResponse)(e);if(n||!r)throw(0,v.writeAuthConfig)({}),new b.RefreshAccessTokenFailedError(n);let i={token:r.access_token,expiresAt:Math.floor(Date.now()/1e3)+r.expires_in};return r.refresh_token&&(i.refreshToken=r.refresh_token),(0,v.writeAuthConfig)(i),i.token}catch(e){throw(0,v.writeAuthConfig)({}),e instanceof b.AccessTokenMissingError||e instanceof b.RefreshAccessTokenFailedError?e:new b.RefreshAccessTokenFailedError(e)}}async function C(e,t,n){let r=`https://api.vercel.com/v1/projects/${t}/token?source=vercel-oidc-refresh${n?`&teamId=${n}`:``}`,i=await fetch(r,{method:`POST`,headers:{Authorization:`Bearer ${e}`}});if(!i.ok)throw new g.VercelOidcTokenError(`Failed to refresh OIDC token: ${i.statusText}`);let a=await i.json();return w(a),a}function w(e){if(!e||typeof e!=`object`)throw TypeError("Vercel OIDC token is malformed. Expected an object. Please run `vc env pull` and try again");if(!(`token`in e)||typeof e.token!=`string`)throw TypeError("Vercel OIDC token is malformed. Expected a string-valued token property. Please run `vc env pull` and try again")}function T(){let e=(0,_.findRootDir)();if(!e)throw new g.VercelOidcTokenError("Unable to find project root directory. Have you linked your project with `vc link?`");let t=m.join(e,`.vercel`,`project.json`);if(!h.existsSync(t))throw new g.VercelOidcTokenError("project.json not found, have you linked your project with `vc link?`");let n=JSON.parse(h.readFileSync(t,`utf8`));if(typeof n.projectId!=`string`&&typeof n.orgId!=`string`)throw TypeError("Expected a string-valued projectId property. Try running `vc link` to re-link your project.");return{projectId:n.projectId,teamId:n.orgId}}function ee(e,t){let n=(0,_.getUserDataDir)();if(!n)throw new g.VercelOidcTokenError(`Unable to find user data directory. Please reach out to Vercel support.`);let r=m.join(n,`com.vercel.token`,`${t}.json`),i=JSON.stringify(e);h.mkdirSync(m.dirname(r),{mode:504,recursive:!0}),h.writeFileSync(r,i),h.chmodSync(r,432)}function E(e){let t=(0,_.getUserDataDir)();if(!t)throw new g.VercelOidcTokenError(`Unable to find user data directory. Please reach out to Vercel support.`);let n=m.join(t,`com.vercel.token`,`${e}.json`);if(!h.existsSync(n))return null;let r=JSON.parse(h.readFileSync(n,`utf8`));return w(r),r}function te(e){let t=e.split(`.`);if(t.length!==3)throw new g.VercelOidcTokenError("Invalid token. Please run `vc env pull` and try again");let n=t[1].replace(/-/g,`+`).replace(/_/g,`/`),r=n.padEnd(n.length+(4-n.length%4)%4,`=`);return JSON.parse(Buffer.from(r,`base64`).toString(`utf8`))}function ne(e,t=0){return e.exp*1e3<Date.now()+t}0&&(n.exports={assertVercelOidcTokenResponse:w,findProjectInfo:T,getTokenPayload:te,getVercelDataDir:x,getVercelOidcToken:C,getVercelToken:S,isExpired:ne,loadToken:E,saveToken:ee})})),Wa=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{AccessTokenMissingError:()=>p.AccessTokenMissingError,RefreshAccessTokenFailedError:()=>p.RefreshAccessTokenFailedError,getContext:()=>f.getContext,getVercelOidcToken:()=>u.getVercelOidcToken,getVercelOidcTokenSync:()=>d.getVercelOidcTokenSync,getVercelToken:()=>m.getVercelToken}),t.exports=c(l);var u=Ra(),d=Ia(),f=Fa(),p=za(),m=Ua();0&&(t.exports={AccessTokenMissingError,RefreshAccessTokenFailedError,getContext,getVercelOidcToken,getVercelOidcTokenSync,getVercelToken})})),Ga=e(Pa(),1),Ka=Wa();async function qa(e){let t=0,n=e.getReader(),r=[];try{for(;;){let{done:e,value:i}=await n.read();if(e)break;r.push(i),t+=i.length}}finally{n.releaseLock()}return Buffer.concat(r,t)}var Ja=class{contentType=`application/json`;replacer;reviver;constructor(e={}){this.replacer=e.replacer,this.reviver=e.reviver}serialize(e){return Buffer.from(JSON.stringify(e,this.replacer),`utf8`)}async deserialize(e){let t=await qa(e);return JSON.parse(t.toString(`utf8`),this.reviver)}},Ya=class extends Error{constructor(e){super(`Message ${e} not found`),this.name=`MessageNotFoundError`}},Xa=class extends Error{constructor(e,t){super(`Message ${e} not available for processing${t?`: ${t}`:``}`),this.name=`MessageNotAvailableError`}},Za=class extends Error{constructor(e,t){super(`Message ${e} is corrupted: ${t}`),this.name=`MessageCorruptedError`}},Qa=class extends Error{retryAfter;constructor(e=`Too many requests`,t){super(e),this.name=`TooManyRequestsError`,this.retryAfter=t}},$a=class extends Error{constructor(e=`Missing or invalid authentication token`){super(e),this.name=`UnauthorizedError`}},eo=class extends Error{constructor(e=`Queue environment doesn't match token environment`){super(e),this.name=`ForbiddenError`}},to=class extends Error{constructor(e){super(e),this.name=`BadRequestError`}},no=class extends Error{constructor(e=`Unexpected server error`){super(e),this.name=`InternalServerError`}},ro=class extends Error{constructor(e,t=1,n=10){super(`Invalid limit: ${e}. Limit must be between ${t} and ${n}.`),this.name=`InvalidLimitError`}},io=class extends Error{constructor(e){super(`Message ${e} has already been processed`),this.name=`MessageAlreadyProcessedError`}},ao=class extends Error{idempotencyKey;constructor(e,t){super(e),this.name=`DuplicateMessageError`,this.idempotencyKey=t}},oo=class extends Error{deploymentId;constructor(e,t){super(e),this.name=`ConsumerDiscoveryError`,this.deploymentId=t}},so=class extends Error{constructor(e=`Consumer registry not configured`){super(e),this.name=`ConsumerRegistryNotConfiguredError`}},co=300,lo=30,uo=60,fo=10,po=3e3,mo=3,ho=250;function go(e){return Math.min(uo,Math.max(fo,e/5))}var _o=class{client;topicName;consumerGroupName;visibilityTimeout;constructor(e,t,n,r={}){this.client=e,this.topicName=t,this.consumerGroupName=n,this.visibilityTimeout=Math.max(lo,r.visibilityTimeoutSeconds??co)}isClientError(e){return e instanceof Xa||e instanceof Ya||e instanceof to||e instanceof $a||e instanceof eo}isNetworkError(e){return e instanceof TypeError}async directiveCallWithRetries(e){let t;for(let n=1;n<=mo;n++)try{return await e()}catch(e){if(t=e,n===mo)throw e;if(e instanceof Qa){if(e.retryAfter===void 0)throw e;await new Promise(t=>setTimeout(t,e.retryAfter*1e3));continue}if(!this.isNetworkError(e))throw e;let r=ho*n,i=r/2+r/2*Math.random();await new Promise(e=>setTimeout(e,i))}throw t}startVisibilityExtension(e,t){let n=!0,r=!1,i,a=null,o=go(this.visibilityTimeout)*1e3,s=o;if(t?.visibilityDeadline){let e=t.visibilityDeadline.getTime()-Date.now();s=e>0?go(e/1e3)*1e3:0}let c=new Promise(e=>{i=e}),l=()=>{r||(r=!0,i())},u=async()=>{if(!n){l();return}try{await this.client.changeVisibility({queueName:this.topicName,consumerGroup:this.consumerGroupName,receiptHandle:e,visibilityTimeoutSeconds:this.visibilityTimeout}),n?a=setTimeout(()=>u(),o):l()}catch(t){if(this.isClientError(t)){console.error(`Visibility extension failed with client error for receipt handle ${e} (stopping retries):`,t),l();return}console.error(`Failed to extend visibility for receipt handle ${e} (will retry in ${po/1e3}s):`,t),n?a=setTimeout(()=>u(),po):l()}};return a=setTimeout(()=>u(),s),async(e=!1)=>{n=!1,a&&=(clearTimeout(a),null),e?await c:l()}}async finalizePayload(e){let t=this.client.getTransport();if(t.finalize&&e!=null)try{await t.finalize(e)}catch(e){console.warn(`Failed to finalize message payload:`,e)}}async processMessage(e,t,n){let r=this.startVisibilityExtension(e.receiptHandle,n),i={messageId:e.messageId,deliveryCount:e.deliveryCount,createdAt:e.createdAt,expiresAt:e.expiresAt??new Date(e.createdAt.getTime()+864e5),topicName:this.topicName,consumerGroup:this.consumerGroupName,region:this.client.getRegion()};try{await t(e.payload,i),await r(),await this.client.acknowledgeMessage({queueName:this.topicName,consumerGroup:this.consumerGroupName,receiptHandle:e.receiptHandle})}catch(t){if(await r(),n?.retry){let r;try{r=n.retry(t,i)}catch(e){console.warn(`retry handler threw:`,e)}if(r){if(`acknowledge`in r&&r.acknowledge){try{await this.directiveCallWithRetries(()=>this.client.acknowledgeMessage({queueName:this.topicName,consumerGroup:this.consumerGroupName,receiptHandle:e.receiptHandle}))}catch(e){console.warn(`Failed to acknowledge message:`,e)}await this.finalizePayload(e.payload);return}if(`afterSeconds`in r&&typeof r.afterSeconds==`number`){try{await this.directiveCallWithRetries(()=>this.client.changeVisibility({queueName:this.topicName,consumerGroup:this.consumerGroupName,receiptHandle:e.receiptHandle,visibilityTimeoutSeconds:r.afterSeconds}))}catch(e){console.warn(`Failed to reschedule message for retry:`,e)}await this.finalizePayload(e.payload);return}}}throw await this.finalizePayload(e.payload),t}}async consumeMessage(e,t,n){await this.processMessage(t,e,n)}async consume(e,t){let n=t?.retry;if(t&&`messageId`in t){let r=await this.client.receiveMessageById({queueName:this.topicName,consumerGroup:this.consumerGroupName,messageId:t.messageId,visibilityTimeoutSeconds:this.visibilityTimeout});return await this.processMessage(r.message,e,{retry:n}),1}else{let r=t&&`limit`in t?t.limit:1,i=0;for await(let t of this.client.receiveMessages({queueName:this.topicName,consumerGroup:this.consumerGroupName,visibilityTimeoutSeconds:this.visibilityTimeout,limit:r}))i++,await this.processMessage(t,e,{retry:n});return i}}get name(){return this.consumerGroupName}get topic(){return this.topicName}},vo=class{client;topicName;constructor(e,t){this.client=e,this.topicName=t}async publish(e,t){let n=await this.client.sendMessage({queueName:this.topicName,payload:e,idempotencyKey:t?.idempotencyKey,retentionSeconds:t?.retentionSeconds,delaySeconds:t?.delaySeconds,headers:t?.headers,telemetry:t?.telemetry});return n.messageId&&jo()&&_s(this.topicName,n.messageId,this.client.getRegion(),t?.delaySeconds,t?.retentionSeconds),{messageId:n.messageId}}consumerGroup(e,t){return new _o(this.client,this.topicName,e,t)}get name(){return this.topicName}},yo=`com.vercel.queue.v1beta`,bo=`com.vercel.queue.v2beta`;function xo(e,t){let n=t.slice(0,-1);return e.startsWith(n)}function So(e){return typeof e==`object`&&!!e}function Co(e,t){if(!t||!t.includes(`application/cloudevents+json`))throw Error(`Invalid content type: expected 'application/cloudevents+json'`);if(!So(e)||!e.type||!e.source||!e.id||!So(e.data))throw Error(`Invalid CloudEvent: missing required fields`);if(e.type!==`com.vercel.queue.v1beta`)throw Error(`Invalid CloudEvent type: expected '${yo}', got '${String(e.type)}'`);let{data:n}=e,r=[];if(`queueName`in n||r.push(`queueName`),`consumerGroup`in n||r.push(`consumerGroup`),`messageId`in n||r.push(`messageId`),r.length>0)throw Error(`Missing required CloudEvent data fields: ${r.join(`, `)}`);return{queueName:String(n.queueName),consumerGroup:String(n.consumerGroup),messageId:String(n.messageId)}}function Q(e,t){if(e instanceof Headers)return e.get(t);let n=e[t];return Array.isArray(n)?n[0]??null:n??null}function wo(e){let t=Q(e,`ce-type`);if(t!==`com.vercel.queue.v2beta`)throw Error(`Invalid CloudEvent type: expected '${bo}', got '${t}'`);let n=Q(e,`ce-vqsqueuename`),r=Q(e,`ce-vqsconsumergroup`),i=Q(e,`ce-vqsmessageid`),a=[];if(n||a.push(`ce-vqsqueuename`),r||a.push(`ce-vqsconsumergroup`),i||a.push(`ce-vqsmessageid`),a.length>0)throw Error(`Missing required CloudEvent headers: ${a.join(`, `)}`);let o=Q(e,`ce-vqsregion`)??void 0;if(o!==void 0&&!/^[a-z]{2,5}[0-9]{1,2}$/.test(o))throw Error(`Invalid ce-vqsregion header: ${JSON.stringify(o)}. Region must match /^[a-z]{2,5}[0-9]{1,2}$/ (e.g. "iad1", "lhr1").`);let s={queueName:n,consumerGroup:r,messageId:i,region:o},c=Q(e,`ce-vqsreceipthandle`);if(!c)return s;let l={...s,receiptHandle:c},u=Q(e,`ce-vqsdeliverycount`);u&&(l.deliveryCount=parseInt(u,10));let d=Q(e,`ce-vqscreatedat`);d&&(l.createdAt=d);let f=Q(e,`ce-vqsexpiresat`);f&&(l.expiresAt=f);let p=Q(e,`content-type`);p&&(l.contentType=p);let m=Q(e,`ce-vqsvisibilitydeadline`);return m&&(l.visibilityDeadline=m),l}function To(e,t){if(Q(t,`ce-type`)===`com.vercel.queue.v2beta`){let n=wo(t);return`receiptHandle`in n&&(n.parsedPayload=e),n}return Co(e,Q(t,`content-type`))}async function Eo(e){if(e.headers.get(`ce-type`)===`com.vercel.queue.v2beta`){let t=wo(e.headers);return`receiptHandle`in t&&e.body&&(t.rawBody=e.body),t}let t;try{t=await e.json()}catch{throw Error(`Failed to parse CloudEvent from request body`)}let n={};return e.headers.forEach((e,t)=>{n[t]=e}),To(t,n)}async function Do(e,t,n){let{queueName:r,consumerGroup:i,messageId:a}=t;if(!n?.client)throw Error(`HandleCallbackOptions.client is required`);let o=Xs(n.client);t.region&&(o=o.withRegion(t.region));let s=new vo(o,r).consumerGroup(i,n?.visibilityTimeoutSeconds===void 0?void 0:{visibilityTimeoutSeconds:n.visibilityTimeoutSeconds});if(`receiptHandle`in t){let r=o.getTransport(),i;if(t.rawBody)i=await r.deserialize(t.rawBody);else if(t.parsedPayload!==void 0)i=t.parsedPayload;else throw Error(`Binary mode callback with receipt handle is missing payload`);let c={messageId:a,payload:i,deliveryCount:t.deliveryCount??1,createdAt:t.createdAt?new Date(t.createdAt):new Date,expiresAt:t.expiresAt?new Date(t.expiresAt):void 0,contentType:t.contentType??r.contentType,receiptHandle:t.receiptHandle},l=t.visibilityDeadline?new Date(t.visibilityDeadline):void 0;await s.consumeMessage(e,c,{visibilityDeadline:l,retry:n?.retry})}else await s.consume(e,{messageId:a,retry:n?.retry})}var $=Ga.default.cyan(`[queue]`),Oo=Ga.default.green(`✓`),ko=Ga.default.red(`✗`),Ao=Ga.default.yellow(`↻`);function jo(){return process.env.NODE_ENV===`development`&&process.env.VERCEL_DEPLOYMENT_ID===void 0}var Mo=Symbol.for(`@vercel/queue.devRouteMappings`);function No(e){let t=``;for(let n of e)n===`_`?t+=`__`:n===`/`?t+=`_S`:n===`.`?t+=`_D`:/[A-Za-z0-9-]/.test(n)?t+=n:t+=`_`+n.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`);return t}function Po(){let e=globalThis;if(Mo in e)return e[Mo]??null;try{let t=Oe.join(process.cwd(),`vercel.json`);if(!ke.existsSync(t))return e[Mo]=null,null;let n=JSON.parse(ke.readFileSync(t,`utf-8`));if(!n.functions)return e[Mo]=null,null;let r=[];for(let[e,t]of Object.entries(n.functions))if(t.experimentalTriggers){for(let n of t.experimentalTriggers)if(!(!n.type?.startsWith(`queue/`)||!n.topic)){if(n.type!==`queue/v2beta`){console.warn(`${$} Unsupported trigger type "${n.type}" for topic "${n.topic}" in ${e}. Use "queue/v2beta" instead.`);continue}r.push({filePath:e,topic:n.topic,consumer:No(e),retryAfterSeconds:n.retryAfterSeconds})}}return e[Mo]=r.length>0?r:null,e[Mo]}catch(t){return console.warn(`${$} Failed to read vercel.json:`,t),e[Mo]=null,null}}function Fo(e){let t=Po();return t?t.filter(t=>t.topic.includes(`*`)?xo(e,t.topic):t.topic===e):[]}function Io(e,t){return Fo(e).find(e=>e.consumer===t)?.retryAfterSeconds}function Lo(e){return/^src\/(app|pages|server)\//.test(e)?e.slice(4):null}function Ro(e,t){return e===t||Y(e,t)}function zo(e){let t=Po();if(!t)return[];let n=process.cwd(),r;try{r=Oe.relative(n,e)}catch{return[]}let i=r.replace(/\\/g,`/`),a=Lo(i);return t.filter(e=>Ro(i,e.filePath)||a!==null&&Ro(a,e.filePath))}function Bo(e){let t=e.match(/\((.+?):\d+:\d+\)/);if(t||=e.match(/at\s+(.+?):\d+:\d+/),!t)return null;let n=t[1].trim();if(n===`native`||n.startsWith(`node:`)||n.startsWith(`internal`))return null;if(n.startsWith(`file://`))try{n=new URL(n).pathname}catch{return null}return/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(n)?null:(n.startsWith(`./`)&&(n=n.slice(2)),n)}var Vo;function Ho(){if(Vo)return Vo;try{let e=typeof __dirname<`u`?__dirname:Oe.dirname(new URL(import.meta.url).pathname);Vo=Oe.resolve(e,`..`)}catch{Vo=``}return Vo}function Uo(){let e=Error().stack;if(!e)return null;let t=e.split(`
|
|
13
|
+
`).slice(1),n=Ho();for(let e of t){let t=Bo(e);if(!t)continue;let r=Oe.isAbsolute(t)?t:Oe.resolve(process.cwd(),t),i;try{i=ke.realpathSync(r)}catch{i=r}if(!(n&&i.startsWith(n)))return i}return null}var Wo=Symbol.for(`@vercel/queue.devHandlerRegistry`);function Go(){let e=globalThis;return e[Wo]||(e[Wo]=new Map),e[Wo]}function Ko(e,t,n,r){let i=zo(Oe.isAbsolute(e)?e:Oe.resolve(process.cwd(),e));if(i.length===0)return!1;let a=Go();for(let e of i){let i=e.topic,o=a.get(i)??[],s={consumerGroup:e.consumer,handler:t,client:n,options:r},c=o.findIndex(t=>t.consumerGroup===e.consumer);c>=0?o[c]=s:o.push(s),a.set(i,o)}return!0}function qo(e,t,n,r){let i=r??Uo();if(!i){console.warn(`${$} Could not determine caller file path for handler registration.`);return}if(!Ko(i,e,t,n)){let e=Po();if(e&&e.length>0)return;let t=process.cwd(),n;try{n=Oe.relative(t,i).replace(/\\/g,`/`)}catch{n=i}console.warn(`${$} handleCallback() in ${n} has no matching experimentalTriggers in vercel.json. This handler won't receive messages.
|
|
14
14
|
|
|
15
15
|
Add a trigger to vercel.json:
|
|
16
16
|
"${n}": {
|
|
17
17
|
"experimentalTriggers": [{ "type": "queue/v2beta", "topic": "your-topic" }]
|
|
18
|
-
}`)}}function
|
|
18
|
+
}`)}}function Jo(e){let t=Go(),n=[];for(let[r,i]of t)(r.includes(`*`)?xo(e,r):r===e)&&n.push(...i);return n}var Yo=50,Xo=5e3,Zo=2,Qo=250,$o=[`PORT`,`NEXT_PORT`,`NEXTJS_PORT`,`NUXT_PORT`,`NITRO_PORT`,`SVELTEKIT_PORT`,`VITE_PORT`,`DEV_PORT`,`npm_config_port`],es=[`__NEXT_PRIVATE_ORIGIN`,`NUXT_PUBLIC_SITE_URL`,`URL`];function ts(e){return e instanceof Error?e.message:String(e)}function ns(e){return e instanceof Ya||e instanceof Error&&e.name===`MessageNotFoundError`}function rs(e){if(!e)return null;let t=Number.parseInt(e,10);return!Number.isFinite(t)||t<1||t>65535?null:t}function is(e){if(!e)return null;try{let t=new URL(e).port;return rs(t)}catch{return null}}function as(){let e=[],t=new Set,n=n=>{n&&!t.has(n)&&(t.add(n),e.push(n))};for(let e of $o)n(rs(process.env[e]));for(let e of es)n(is(process.env[e]));return e}function os(e){return new Promise(t=>{let n=je.connect({host:`localhost`,port:e}),r=!1,i=e=>{r||(r=!0,n.destroy(),t(e))};n.once(`connect`,()=>i(!0)),n.once(`error`,()=>i(!1)),n.setTimeout(Qo,()=>i(!1))})}async function ss(e,t,n){let r=0,i=Yo;for(;;)try{await Do(e,t,n);return}catch(e){if(ns(e)&&r<Xo){await new Promise(e=>setTimeout(e,i)),r+=i,i=Math.min(i*Zo,Xo-r);continue}throw e}}function cs(e){let t=e.replace(/^src\/app\//,`/`).replace(/^src\/pages\//,`/`).replace(/^src\/server\//,`/`).replace(/^src\/routes\//,`/`).replace(/^app\//,`/`).replace(/^pages\//,`/`).replace(/^server\//,`/`).replace(/\/route\.(ts|mts|js|mjs|tsx|jsx)$/,``).replace(/\/\+server\.(ts|mts|js|mjs|tsx|jsx)$/,``).replace(/\.(ts|mts|js|mjs|tsx|jsx)$/,``);return t.startsWith(`/`)||(t=`/`+t),t}async function ls(e,t={}){let n={triedPorts:as(),listeningPorts:[],unavailablePorts:[],importFailures:[],primeFailures:[]},r=Fo(e);if(r.length===0)return n;let i=t.refreshRegistered===!0;for(let e of n.triedPorts)await os(e)?n.listeningPorts.push(e):n.unavailablePorts.push(e);for(let t of r){let r=ds(e,t.consumer);if(!(r&&!i)){if(!r){let r=Oe.resolve(process.cwd(),t.filePath);try{await import(r)}catch(e){n.importFailures.push({filePath:t.filePath,reason:ts(e)})}if(ds(e,t.consumer))continue}for(let r of n.listeningPorts){let i=`http://localhost:${r}${cs(t.filePath)}`;try{let r=await fetch(i,{method:`POST`,headers:{"x-vercel-queue-prime":`1`,"x-vercel-queue-prime-file":t.filePath}});try{await r.text()}catch{}if(ds(e,t.consumer))break;n.primeFailures.push({filePath:t.filePath,url:i,reason:`HTTP ${r.status}${r.statusText?` ${r.statusText}`:``}`.trim()})}catch(e){n.primeFailures.push({filePath:t.filePath,url:i,reason:ts(e)})}}}}return n}function us(e,t,n){let r=t.map(e=>e.filePath),i=n.listeningPorts[0]??n.triedPorts[0],a=i?t.map(e=>`http://localhost:${i}${cs(e.filePath)}`):[],o;if(n.triedPorts.length===0)o=`No local dev port detected from env. Set PORT (or NEXT_PORT/NUXT_PORT/VITE_PORT).`;else if(n.listeningPorts.length===0)o=`Detected env ports: [${n.triedPorts.join(`, `)}], but none are listening.`;else{let e=n.unavailablePorts.length>0?` Not listening: [${n.unavailablePorts.join(`, `)}].`:``;o=`Detected env ports: [${n.triedPorts.join(`, `)}]. Listening: [${n.listeningPorts.join(`, `)}].`+e}let s=n.importFailures.length>0?`
|
|
19
19
|
Import failures: `+n.importFailures.slice(0,2).map(e=>`${e.filePath} (${e.reason})`).join(`; `):``,c=n.primeFailures.length>0?`
|
|
20
20
|
Prime failures: `+n.primeFailures.slice(0,3).map(e=>`${e.url} (${e.reason})`).join(`; `):``;return`${$} No registered handler for topic "${e}". vercel.json maps this topic to [${r.join(`, `)}] but auto-loading failed.
|
|
21
21
|
${o}${s}${c}
|
|
22
22
|
Ensure your dev server is running, set PORT if needed, and confirm mapped route files call handleCallback()/handleNodeCallback() at module scope.
|
|
23
|
-
`+(a.length>0?`Try opening: ${a.join(` or `)}`:`Set PORT (or NEXT_PORT/NUXT_PORT/VITE_PORT) and try sending again.`)}function
|
|
24
|
-
Ensure vercel.json has a matching experimentalTriggers entry and the route file calls handleCallback().`);return}let o=r.map(e=>e.consumerGroup);console.log(`${$} Invoking handlers for topic="${e}" messageId="${t}" \u2192 consumers: [${o.join(`, `)}]`);let s=i??
|
|
23
|
+
`+(a.length>0?`Try opening: ${a.join(` or `)}`:`Set PORT (or NEXT_PORT/NUXT_PORT/VITE_PORT) and try sending again.`)}function ds(e,t){return Jo(e).some(e=>e.consumerGroup===t)}var fs=10,ps=2,ms=10,hs=86400;function gs(e,t){let n=Math.min(Math.max(t,0),fs);console.log(`${$} ${Ao} Scheduling re-delivery in ${n}s: topic="${e.topicName}" consumer="${e.consumerGroup}" messageId="${e.messageId}"`),setTimeout(async()=>{let t=e.deliveryCount+1,n=new Date(e.createdAt.getTime()+e.retentionSeconds*1e3);if(Date.now()>=n.getTime()){console.log(`${$} Message expired, stopping retries: topic="${e.topicName}" messageId="${e.messageId}"`);return}if(t>ms){console.log(`${$} Max re-deliveries (${ms}) reached: topic="${e.topicName}" messageId="${e.messageId}"`);return}let r={messageId:e.messageId,deliveryCount:t,createdAt:e.createdAt,expiresAt:n,topicName:e.topicName,consumerGroup:e.consumerGroup,region:e.region};console.log(`${$} Re-delivering: topic="${e.topicName}" consumer="${e.consumerGroup}" messageId="${e.messageId}" deliveryCount=${t}`);let i=!0,a=null,o=!1;try{await e.handler(e.payload,r)}catch(t){if(i=!1,e.retry){let n;try{n=e.retry(t,r)}catch(e){console.warn(`${$} retry handler threw:`,e)}n&&`afterSeconds`in n?a=n.afterSeconds:n&&`acknowledge`in n&&(o=!0)}o||console.error(`${$} ${ko} Handler error on re-delivery: topic="${e.topicName}" messageId="${e.messageId}"`,t)}if(i)console.log(`${$} ${Oo} Message processed on re-delivery: topic="${e.topicName}" consumer="${e.consumerGroup}" messageId="${e.messageId}"`);else if(o)console.log(`${$} ${Oo} Message acknowledged (will not retry): topic="${e.topicName}" consumer="${e.consumerGroup}" messageId="${e.messageId}"`);else{let n=a??e.defaultRetryDelayS;gs({...e,deliveryCount:t},n)}},n*1e3)}function _s(e,t,n,r,i){if(r&&r>0){console.log(`${$} Message sent with delay: topic="${e}" messageId="${t}" delay=${r}s`),setTimeout(()=>{_s(e,t,n,void 0,i)},r*1e3);return}console.log(`${$} Message sent: topic="${e}" messageId="${t}"`),(async()=>{let r=Jo(e),a=null;if(r.length>0?(await ls(e,{refreshRegistered:!0}),r=Jo(e)):(a=await ls(e),r=Jo(e)),r.length===0){let t=Fo(e);if(t.length>0){let n=a??{triedPorts:as(),listeningPorts:[],unavailablePorts:[],importFailures:[],primeFailures:[]};console.warn(us(e,t,n))}else console.warn(`${$} No registered handler for topic "${e}".
|
|
24
|
+
Ensure vercel.json has a matching experimentalTriggers entry and the route file calls handleCallback().`);return}let o=r.map(e=>e.consumerGroup);console.log(`${$} Invoking handlers for topic="${e}" messageId="${t}" \u2192 consumers: [${o.join(`, `)}]`);let s=i??hs;for(let i of r){let r,a=new Date,o=1,c=!0,l=null,u=!1,d=async(e,t)=>{r=e,a=t.createdAt,o=t.deliveryCount;try{await i.handler(e,t)}catch(e){throw c=!1,e}},f=i.options?.retry?(e,t)=>{let n=i.options.retry(e,t);return n&&`afterSeconds`in n?l=n.afterSeconds:n&&`acknowledge`in n&&(u=!0),n}:void 0,p={queueName:e,consumerGroup:i.consumerGroup,messageId:t,region:n},m={client:i.client,visibilityTimeoutSeconds:i.options?.visibilityTimeoutSeconds,retry:f},h=Math.min(Io(e,i.consumerGroup)??ps,fs),g=()=>({handler:i.handler,retry:i.options?.retry,payload:r,topicName:e,consumerGroup:i.consumerGroup,messageId:t,region:n,createdAt:a,retentionSeconds:s,deliveryCount:o,defaultRetryDelayS:h});try{if(await ss(d,p,m),c)console.log(`${$} ${Oo} Message processed: topic="${e}" consumer="${i.consumerGroup}" messageId="${t}"`);else if(u)console.log(`${$} ${Oo} Message acknowledged (will not retry): topic="${e}" consumer="${i.consumerGroup}" messageId="${t}"`);else if(l!==null){let e=Math.min(l,fs);gs(g(),e)}}catch(n){console.error(`${$} ${ko} Handler failed: topic="${e}" consumer="${i.consumerGroup}" messageId="${t}"`,n),c||gs(g(),h)}}})()}function vs(){let e=globalThis;delete e[Mo],delete e[Wo]}(process.env.NODE_ENV===`test`||process.env.VITEST)&&(globalThis.__clearDevState=vs,globalThis.__filePathToConsumerGroup=No,globalThis.__filePathToUrlPath=cs,globalThis.__matchesFunctionsPattern=Ro,globalThis.__stripSrcPrefix=Lo);function ys(e,t){let n={...e?.metadata,...t?.metadata};return{isEnabled:t?.isEnabled??e?.isEnabled??!0,tracer:e?.tracer,metadata:Object.keys(n).length>0?n:void 0}}var bs;function xs(){return bs||=import(`../../_chunks/workflow/src-CQuMexnO.js`).then(t=>e(t.t(),1)).then(e=>e,()=>null),bs}function Ss(){let e=process.env.VERCEL_QUEUE_TRACE_PROPAGATION?.toLowerCase();return e===`off`||e===`0`||e===`false`}var Cs=[`traceparent`,`tracestate`,`baggage`];async function ws(e,t){if(Ss()||t&&!t.isEnabled)return;let n=await xs();if(n)try{let t={};n.propagation.inject(n.context.active(),t);for(let n of Cs){let r=t[n];r!==void 0&&e.set(n,r)}}catch{}}function Ts(e,t,n){try{t.setStatus({code:e.SpanStatusCode.ERROR,message:n instanceof Error?n.message:String(n)})}catch{}}function Es(e){try{e.end()}catch{}}async function Ds(e,t,n){if(Ss()||n&&!n.isEnabled)return t(null);let r=await xs();if(!r)return t(null);let i=null;try{let t=n?.tracer??r.trace.getTracer(`@vercel/queue`),a={"messaging.system":`vercel-queue`,"messaging.destination.name":e};if(n?.metadata)for(let[e,t]of Object.entries(n.metadata))a[`vqs.metadata.${e}`]=t;let o=t.startSpan(`vqs.send`,{kind:r.SpanKind.PRODUCER,attributes:a});i={span:o,ctx:r.trace.setSpan(r.context.active(),o)}}catch{}if(!i)return t(null);let{span:a,ctx:o}=i;try{return await r.context.with(o,()=>t({setMessageId(e){try{a.setAttribute(`messaging.message.id`,e)}catch{}}}))}catch(e){throw Ts(r,a,e),e}finally{Es(a)}}var Os=`x-vercel-queue-traceparent`,ks=`x-vercel-queue-tracestate`,As=`x-vercel-queue-baggage`;async function js(e,t,n){if(Ss()||n&&!n.isEnabled)return t();let r=await xs();if(!r)return t();let i=null;try{let t=Ms(r,Ns(e)),a=n?.tracer??r.trace.getTracer(`@vercel/queue`),o={"messaging.system":`vercel-queue`,"messaging.operation":`process`};if(n?.metadata)for(let[e,t]of Object.entries(n.metadata))o[`vqs.metadata.${e}`]=t;let s=a.startSpan(`vqs.process`,{kind:r.SpanKind.CONSUMER,attributes:o,links:t});i={span:s,ctx:r.trace.setSpan(r.context.active(),s)}}catch{}if(!i)return t();let{span:a,ctx:o}=i;try{return await r.context.with(o,t)}catch(e){throw Ts(r,a,e),e}finally{Es(a)}}function Ms(e,t){let n=t[Os];if(!n)return[];let r={traceparent:n},i=t[ks];i&&(r.tracestate=i);let a=t[As];a&&(r.baggage=a);let o=e.propagation.extract(e.ROOT_CONTEXT,r),s=e.trace.getSpanContext(o);return!s||!e.trace.isSpanContextValid(s)?[]:[{context:s}]}function Ns(e){let t={};if(e instanceof Headers)return e.forEach((e,n)=>{t[n.toLowerCase()]=e}),t;for(let[n,r]of Object.entries(e)){let e=Array.isArray(r)?r[0]:r;e!==void 0&&(t[n.toLowerCase()]=e)}return t}function Ps(){return process.env.VERCEL_QUEUE_DEBUG===`1`||process.env.VERCEL_QUEUE_DEBUG===`true`}async function Fs(e){let t=e.getReader();try{for(;;){let{done:e}=await t.read();if(e)break}}finally{t.releaseLock()}}function Is(e){if(!e)return;let t=Number(e);if(Number.isFinite(t)&&t>=0)return t;let n=Date.parse(e);if(!Number.isNaN(n))return Math.max(0,(n-Date.now())/1e3)}function Ls(e,t,n,r,i=`Invalid parameters`,a){throw e===400?new to(n||i):e===429?new Qa(n||`Too many requests: ${r}`,Is(a)):e===401?new $a(n||void 0):e===403?new eo(n||void 0):e>=500?new no(n||`Server error: ${e} ${t}`):Error(`Failed to ${r}: ${e} ${t}`)}function Rs(e){let t=e.get(`Vqs-Message-Id`),n=e.get(`Vqs-Delivery-Count`)||`0`,r=e.get(`Vqs-Timestamp`),i=e.get(`Content-Type`)||`application/octet-stream`,a=e.get(`Vqs-Receipt-Handle`),o=e.get(`Vqs-Expires-At`);if(!t||!r||!a)return null;let s=parseInt(n,10);return Number.isNaN(s)?null:{messageId:t,deliveryCount:s,createdAt:new Date(r),expiresAt:o?new Date(o):void 0,contentType:i,receiptHandle:a}}var zs=/^[a-z]{2,5}[0-9]{1,2}$/;function Bs(e){if(!zs.test(e))throw Error(`Invalid region code: ${JSON.stringify(e)}. Region must match the pattern /^[a-z]{2,5}[0-9]{1,2}$/ (e.g. "iad1", "lhr1").`)}var Vs=e=>new URL(`https://${e}.vercel-queue.com`);function Hs(e,t){return(t??Vs)(e)}var Us=`/api/v3/topic`,Ws=class e{baseUrl;customHeaders;providedToken;resolvedDeploymentId;pinSends;explicitlyUnpinned;transport;region;baseUrlResolver;dispatcher;telemetry;constructor(e){Bs(e.region),this.region=e.region,this.baseUrlResolver=e.resolveBaseUrl,this.baseUrl=Hs(this.region,this.baseUrlResolver),this.customHeaders=e.headers||{},this.providedToken=e.token,this.transport=e.transport||new Ja,this.dispatcher=e.dispatcher,this.telemetry=e.telemetry,e.deploymentId===null?(this.pinSends=!1,this.explicitlyUnpinned=!0):(this.resolvedDeploymentId=e.deploymentId||process.env.VERCEL_DEPLOYMENT_ID,this.pinSends=!0,this.explicitlyUnpinned=!1)}withRegion(t){return new e({region:t,resolveBaseUrl:this.baseUrlResolver,token:this.providedToken,headers:{...this.customHeaders},deploymentId:this.explicitlyUnpinned?null:this.resolvedDeploymentId,transport:this.transport,dispatcher:this.dispatcher,telemetry:this.telemetry})}getRegion(){return this.region}getTransport(){return this.transport}getTelemetry(){return this.telemetry}requireDeploymentId(){if(!(jo()||this.explicitlyUnpinned||this.resolvedDeploymentId))throw Error(`No deployment ID available. VERCEL_DEPLOYMENT_ID is not set.
|
|
25
25
|
|
|
26
26
|
This usually means the code is running outside a Vercel deployment (e.g. during build or in a non-Vercel environment).
|
|
27
27
|
|
|
28
28
|
To fix this, create a client with an explicit deploymentId:
|
|
29
29
|
new QueueClient({ deploymentId: "dpl_xxx" })
|
|
30
30
|
Or explicitly opt out of deployment pinning:
|
|
31
|
-
new QueueClient({ deploymentId: null })`)}getSendDeploymentId(){if(!
|
|
31
|
+
new QueueClient({ deploymentId: null })`)}getSendDeploymentId(){if(!jo())return this.requireDeploymentId(),this.pinSends?this.resolvedDeploymentId:void 0}getConsumeDeploymentId(){if(!jo())return this.requireDeploymentId(),this.resolvedDeploymentId}async getToken(){if(this.providedToken)return this.providedToken;try{return await(0,Ka.getVercelOidcToken)()}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(jo()?`Failed to get OIDC token for local development.
|
|
32
32
|
|
|
33
33
|
To fix this, pull your environment variables with Vercel CLI:
|
|
34
34
|
\`vercel env pull\`
|
|
@@ -39,4 +39,4 @@ To fix this, either:
|
|
|
39
39
|
- Deploy to Vercel (OIDC tokens are provisioned automatically)
|
|
40
40
|
- Provide a token explicitly: \`new QueueClient({ token: '...' })\`
|
|
41
41
|
|
|
42
|
-
Cause: ${t}`)}}buildUrl(e,...t){let n=encodeURIComponent(e),r=t.map(e=>encodeURIComponent(e)),i=r.length>0?`/`+r.join(`/`):``,a=this.baseUrl.pathname.replace(/\/+$/,``);return`${this.baseUrl.origin}${a}${Ks}/${n}${i}`}async fetch(e,t){let n=t.method||`GET`;if(Ls()){let r={method:n,url:e,headers:t.headers},i=t.body;i!=null&&(i instanceof ArrayBuffer||i instanceof Uint8Array?r.bodySize=i.byteLength:typeof i==`string`?r.bodySize=i.length:r.bodyType=typeof i),console.debug(`[VQS Debug] Request:`,JSON.stringify(r,null,2))}t.headers.set(`User-Agent`,`@vercel/queue/0.4.0`),t.headers.set(`Vqs-Client-Ts`,new Date().toISOString());let r=this.dispatcher?{...t,dispatcher:this.dispatcher}:t,i=await fetch(e,r);if(Ls()){let t={method:n,url:e,status:i.status,statusText:i.statusText,headers:i.headers};console.debug(`[VQS Debug] Response:`,JSON.stringify(t,null,2))}return i}async sendMessage(e){let t=this.transport,{queueName:n,payload:r,idempotencyKey:i,retentionSeconds:a,delaySeconds:o,headers:s,telemetry:c}=e,l=new Headers;if(this.customHeaders)for(let[e,t]of Object.entries(this.customHeaders))l.append(e,t);if(s){let e=new Set([`authorization`,`content-type`]),t=t=>{let n=t.toLowerCase();return e.has(n)?!0:n.startsWith(`vqs-`)};for(let[e,n]of Object.entries(s))!t(e)&&n!==void 0&&l.append(e,n)}l.set(`Authorization`,`Bearer ${await this.getToken()}`),l.set(`Content-Type`,t.contentType);let u=this.getSendDeploymentId();u&&l.set(`Vqs-Deployment-Id`,u),i&&l.set(`Vqs-Idempotency-Key`,i),a!==void 0&&l.set(`Vqs-Retention-Seconds`,a.toString()),o!==void 0&&l.set(`Vqs-Delay-Seconds`,o.toString());let d=t.serialize(r),f=Buffer.isBuffer(d)?new Uint8Array(d):d,p=Ss(this.telemetry,c);return As(n,async e=>{await Ds(l,p);let t=await this.fetch(this.buildUrl(n),{method:`POST`,body:f,headers:l});if(!t.ok){let e=await t.text();if(t.status===409)throw new co(e||`Duplicate idempotency key detected`,i);if(t.status===502)throw new lo(e||`Consumer discovery failed`,u);if(t.status===503)throw new uo(e||`Consumer registry not configured`);Bs(t.status,t.statusText,e,`send message`)}if(t.status===202)return await t.text(),{messageId:null};let r=await t.json();return e&&r.messageId&&e.setMessageId(r.messageId),r},p)}async*receiveMessages(e){let t=this.transport,{queueName:n,consumerGroup:r,visibilityTimeoutSeconds:i,limit:a}=e;if(a!==void 0&&(a<1||a>10))throw new oo(a);let o=new Headers({Authorization:`Bearer ${await this.getToken()}`,Accept:`multipart/mixed`,...this.customHeaders});i!==void 0&&o.set(`Vqs-Visibility-Timeout-Seconds`,i.toString()),a!==void 0&&o.set(`Vqs-Max-Messages`,a.toString());let s=this.getConsumeDeploymentId();s&&o.set(`Vqs-Deployment-Id`,s);let c=await this.fetch(this.buildUrl(n,`consumer`,r),{method:`POST`,headers:o});if(c.status===204){await c.text();return}if(!c.ok){let e=await c.text();Bs(c.status,c.statusText,e,`receive messages`)}for await(let e of fi(c))try{let n=Vs(e.headers);if(!n){console.warn(`Missing required queue headers in multipart part`),await Rs(e.payload);continue}let r=await t.deserialize(e.payload);yield{...n,payload:r}}catch(t){console.warn(`Failed to process multipart message:`,t),await Rs(e.payload)}}async receiveMessageById(e){let t=this.transport,{queueName:n,consumerGroup:r,messageId:i,visibilityTimeoutSeconds:a}=e,o=new Headers({Authorization:`Bearer ${await this.getToken()}`,Accept:`multipart/mixed`,...this.customHeaders});a!==void 0&&o.set(`Vqs-Visibility-Timeout-Seconds`,a.toString());let s=this.getConsumeDeploymentId();s&&o.set(`Vqs-Deployment-Id`,s);let c=await this.fetch(this.buildUrl(n,`consumer`,r,`id`,i),{method:`POST`,headers:o});if(!c.ok){let e=await c.text();if(c.status===404)throw new Qa(i);if(c.status===409){let t={};try{t=JSON.parse(e)}catch{}throw t.originalMessageId?new $a(i,`This message was a duplicate - use originalMessageId: ${t.originalMessageId}`):new $a(i)}if(c.status===410)throw new so(i);Bs(c.status,c.statusText,e,`receive message by ID`)}for await(let e of fi(c)){let n=Vs(e.headers);if(!n)throw await Rs(e.payload),new eo(i,`Missing required queue headers in response`);let r=await t.deserialize(e.payload);return{message:{...n,payload:r}}}throw new Qa(i)}async acknowledgeMessage(e){let{queueName:t,consumerGroup:n,receiptHandle:r}=e,i=new Headers({Authorization:`Bearer ${await this.getToken()}`,...this.customHeaders}),a=this.getConsumeDeploymentId();a&&i.set(`Vqs-Deployment-Id`,a);let o=await this.fetch(this.buildUrl(t,`consumer`,n,`lease`,r),{method:`DELETE`,headers:i});if(!o.ok){let e=await o.text();if(o.status===404)throw new Qa(r);if(o.status===409)throw new $a(r,e||`Invalid receipt handle, message not in correct state, or already processed`);Bs(o.status,o.statusText,e,`acknowledge message`,`Missing or invalid receipt handle`,o.headers?.get(`Retry-After`)??null)}return await o.text(),{acknowledged:!0}}async changeVisibility(e){let{queueName:t,consumerGroup:n,receiptHandle:r,visibilityTimeoutSeconds:i}=e,a=new Headers({Authorization:`Bearer ${await this.getToken()}`,"Content-Type":`application/json`,...this.customHeaders}),o=this.getConsumeDeploymentId();o&&a.set(`Vqs-Deployment-Id`,o);let s=await this.fetch(this.buildUrl(t,`consumer`,n,`lease`,r),{method:`PATCH`,headers:a,body:JSON.stringify({visibilityTimeoutSeconds:i})});if(!s.ok){let e=await s.text();if(s.status===404)throw new Qa(r);if(s.status===409)throw new $a(r,e||`Invalid receipt handle, message not in correct state, or already processed`);Bs(s.status,s.statusText,e,`change visibility`,`Missing receipt handle or invalid visibility timeout`,s.headers?.get(`Retry-After`)??null)}return await s.text(),{success:!0}}},Js=new WeakMap,Ys=Symbol.for(`@vercel/queue.apiClient`);function Xs(e,t){Js.set(e,t),Object.defineProperty(e,Ys,{value:t,writable:!1,enumerable:!1,configurable:!1})}function Zs(e){let t=Js.get(e);if(t)return t;let n=e[Ys];if(typeof n==`object`&&n){let t=n;return Js.set(e,t),t}throw Error(`QueueClient not initialized. This may happen when multiple bundled copies of @vercel/queue are loaded in local dev.`)}function Qs(e){return`request`in e?e.request:e}function $s(e){return Zs(e)}var ec=`iad1`;function tc(e){return e||process.env.VERCEL_REGION||(Po()||console.warn(`[QueueClient] Region not detected \u2014 defaulting to "${ec}". On Vercel this is set automatically via VERCEL_REGION. To silence this warning, pass region explicitly: new QueueClient({ region: "iad1" })`),ec)}var nc=class{constructor(e={}){let t=tc(e.region);Xs(this,new qs({...e,region:t}))}send=async(e,t,n)=>{let r=Zs(this),i=await r.sendMessage({queueName:e,payload:t,idempotencyKey:n?.idempotencyKey,retentionSeconds:n?.retentionSeconds,delaySeconds:n?.delaySeconds,headers:n?.headers,telemetry:n?.telemetry});return i.messageId&&Po()&&bs(e,i.messageId,r.getRegion(),n?.delaySeconds,n?.retentionSeconds),{messageId:i.messageId}};handleCallback=(e,t)=>{Po()&&Xo(e,this,t);let n=Ss(Zs(this).getTelemetry?.());return async r=>{let i=Qs(r);if(Po()&&i.headers.get(`x-vercel-queue-prime`)===`1`){let n=i.headers.get(`x-vercel-queue-prime-file`);return n&&Xo(e,this,t,n),Response.json({status:`primed`})}try{let r=await ko(i);return await Ps(i.headers,()=>Ao(e,r,{client:this,visibilityTimeoutSeconds:t?.visibilityTimeoutSeconds,retry:t?.retry}),n),Response.json({status:`success`})}catch(e){return console.error(`Queue callback error:`,e),e instanceof Error&&(e.message.includes(`Invalid content type`)||e.message.includes(`Invalid CloudEvent`)||e.message.includes(`Missing required CloudEvent`)||e.message.includes(`Failed to parse CloudEvent`)||e.message.includes(`Binary mode callback`))?Response.json({error:e.message},{status:400}):Response.json({error:`Failed to process queue message`},{status:500})}}};handleNodeCallback=(e,t)=>{Po()&&Xo(e,this,t);let n=Ss(Zs(this).getTelemetry?.());return async(r,i)=>{if(r.method!==`POST`){i.status(200).end();return}let a=r.headers[`x-vercel-queue-prime`];if(Po()&&a===`1`){let n=r.headers[`x-vercel-queue-prime-file`],a=Array.isArray(n)?n[0]:n;a&&Xo(e,this,t,a),i.status(200).json({status:`primed`});return}try{let a=Oo(r.body,r.headers);await Ps(r.headers,()=>Ao(e,a,{client:this,visibilityTimeoutSeconds:t?.visibilityTimeoutSeconds,retry:t?.retry}),n),i.status(200).json({status:`success`})}catch(e){if(console.error(`Queue callback error:`,e),e instanceof Error&&(e.message.includes(`Invalid content type`)||e.message.includes(`Invalid CloudEvent`)||e.message.includes(`Missing required CloudEvent`)||e.message.includes(`Failed to parse CloudEvent`)||e.message.includes(`Binary mode callback`))){i.status(400).json({error:e.message});return}i.status(500).json({error:`Failed to process queue message`})}}}},rc=class{contentType=`application/cbor`;serialize(e){return Buffer.from(Qt(e))}async deserialize(e){let t=[],n=e.getReader();for(;;){let{done:e,value:r}=await n.read();if(e)break;r&&t.push(r)}return Et(Buffer.concat(t))}},ic=class{contentType=`application/json`;serialize(e){return Buffer.from(JSON.stringify(e))}async deserialize(e){let t=[],n=e.getReader();for(;;){let{done:e,value:r}=await n.read();if(e)break;r&&t.push(r)}return JSON.parse(Buffer.concat(t).toString())}},ac=class{contentType=`application/cbor`;serialize(e){return Buffer.from(Qt(e))}async deserialize(e){let t=[],n=e.getReader();for(;;){let{done:e,value:r}=await n.read();if(e)break;r&&t.push(r)}let r=Buffer.concat(t);try{return Et(r)}catch{return JSON.parse(r.toString())}}};const oc=new ve,sc=de({payload:ce,queueName:ae,deploymentId:ue().optional()}),cc=Number(process.env.VERCEL_QUEUE_MAX_DELAY_SECONDS||82800);function lc(e){let t=Math.min(Math.max(1,2**(e-1)),900),n=Math.floor(Math.random()*(Math.ceil(t*.25)+1));return Math.max(1,t-n)}function uc(e){if(`runId`in e&&typeof e.runId==`string`)return e.runId;if(`workflowRunId`in e&&typeof e.workflowRunId==`string`)return e.workflowRunId}function dc(e){if(!e)return;let t=e.startsWith(`wrun_`)?e.slice(5):e;try{let e=Br(t);return!e.tagged||e.regionId===Pr.unknown?void 0:e.region??void 0}catch{return}}function fc(e,t){if(Lr(t?.region))return t.region;let n=dc(uc(e));if(n)return n;let r=process.env.VERCEL_REGION;return Lr(r)?r:`iad1`}function pc(e){let t={};return`runId`in e&&typeof e.runId==`string`&&(t[`x-vercel-workflow-run-id`]=e.runId),`workflowRunId`in e&&typeof e.workflowRunId==`string`&&(t[`x-vercel-workflow-run-id`]=e.workflowRunId),`stepId`in e&&typeof e.stepId==`string`&&(t[`x-vercel-workflow-step-id`]=e.stepId),Object.keys(t).length>0?t:void 0}const mc=/^__([a-z][a-z0-9]*_)?wkf_workflow_/;let hc=!1;function gc(){let e=process.env.WORKFLOW_SEQUENTIAL_REPLAYS;return e!==void 0&&e!==``?e===`1`:process.env.WORKFLOW_SAFE_MODE===`1`}function _c(e,t){return!gc()||!mc.test(e)?e:(hc||(hc=!0,console.warn(`[workflow] WORKFLOW_SEQUENTIAL_REPLAYS=1: routing flow messages to per-run queue topics`)),`runId`in t&&typeof t.runId==`string`?`stepId`in t&&typeof t.stepId==`string`?`${e}_${t.runId}_${t.stepId}`:`${e}_${t.runId}`:`__healthCheck`in t&&typeof t.correlationId==`string`?`${e}_${t.correlationId}`:e)}function vc(e){let{baseUrl:t,usingProxy:n}=xr(e),r=Sr(e,{usingProxy:n}),i=new rc,a=new ic,o=new ac,s={dispatcher:bn(e),transport:o,...n&&{resolveBaseUrl:()=>new URL(`${t}/queues-proxy`),token:e?.token},headers:Object.fromEntries(r.entries())},c=async(e,t,r)=>{let o=r?.deploymentId??process.env.VERCEL_DEPLOYMENT_ID;if(!o)throw Error(`No deploymentId provided and VERCEL_DEPLOYMENT_ID environment variable is not set. Queue messages require a deployment ID to route correctly. Either set VERCEL_DEPLOYMENT_ID or provide deploymentId in options.`);let c=(r?.specVersion??5)>=3?i:a,l=fc(t,r),u=new nc({...s,...n&&{headers:{...s.headers,"x-vercel-queue-region":l}},region:l,deploymentId:o,transport:c}),d={payload:t,queueName:e,deploymentId:r?.deploymentId},f=_c(e,t).replace(/[^A-Za-z0-9-_]/g,`-`);try{let{messageId:e}=await u.send(f,d,{idempotencyKey:r?.idempotencyKey,delaySeconds:r?.delaySeconds,headers:{...pc(t),...r?.headers}});return{messageId:e?ne.parse(e):null}}catch(e){if(e instanceof co)return{messageId:ne.parse(`msg_duplicate_${e.idempotencyKey??r?.idempotencyKey??`unknown`}`)};throw e}};return{queue:c,createQueueHandler:(e,t)=>{let n=new nc(s).handleCallback(async(e,n)=>{if(!e||!n)return;let r=oc.getStore(),{payload:i,queueName:a,deploymentId:o}=sc.parse(e),s=await t(i,{queueName:a,messageId:ne.parse(n.messageId),attempt:n.deliveryCount,requestId:r});typeof s?.timeoutSeconds==`number`&&await c(a,i,{deploymentId:o,delaySeconds:s.timeoutSeconds>0?Math.min(s.timeoutSeconds,cc):void 0})},{retry:(e,{deliveryCount:t})=>({afterSeconds:lc(t)})});return async e=>{let t=e.headers.get(`x-vercel-id`)?.trim()||void 0;return oc.run(t,()=>n(e))}},getDeploymentId:async()=>{let e=process.env.VERCEL_DEPLOYMENT_ID;if(!e)throw Error(`VERCEL_DEPLOYMENT_ID environment variable is not set`);return e}}}const yc=de({id:ue()});function bc(e){return async function(){let t=process.env.VERCEL_DEPLOYMENT_ID;if(!t)throw Error(`Cannot resolve latest deployment: VERCEL_DEPLOYMENT_ID environment variable is not set`);let n=await lr(e);if(!n)throw Error(`Cannot resolve latest deployment: no OIDC token or VERCEL_TOKEN available`);let r=await(await fr({method:`GET`,url:`https://api.vercel.com/v1/workflow/resolve-latest-deployment/${encodeURIComponent(t)}`,headers:new Headers({Authorization:`Bearer ${n}`}),dispatcher:bn(e),peerService:`vercel-api`,timeoutMs:null,buildError:async e=>{let n;try{n=await e.text()}catch{n=`<unable to read response body>`}return Error(`Failed to resolve latest deployment for ${t}: HTTP ${e.status} ${e.statusText}${n?` — ${n}`:``}`)}})).json(),i=yc.safeParse(r);if(!i.success)throw Error(`Invalid response from Vercel API: expected { id: string }. Zod error: ${i.error.message}`);return i.data.id}}const xc={run_created:{retryable:!0,reason:`conditional create → 409 if exists`},step_created:{retryable:!0,reason:`conditional create → 409 if exists`},wait_created:{retryable:!0,reason:`conditional create → 409 if exists`},hook_created:{retryable:!0,reason:`transactional token uniqueness → 409 if exists`},run_started:{retryable:!0,reason:`early-returns if already running, no duplicate row`},run_completed:{retryable:!0,reason:`terminal-state guard → 409, no duplicate row`},run_failed:{retryable:!0,reason:`terminal-state guard → 409, no duplicate row`},run_cancelled:{retryable:!0,reason:`terminal-state guard → 409, no duplicate row`},step_completed:{retryable:!0,reason:`terminal-state guard → 409, no duplicate row`},step_failed:{retryable:!0,reason:`terminal-state guard → 409, no duplicate row`},wait_completed:{retryable:!0,reason:`waiting-state guard → 409, no duplicate row`},hook_disposed:{retryable:!0,reason:`conditional delete (exists) → 409, no duplicate row`},attr_set:{retryable:!0,reason:`correlationId constraint reuses eventId (idempotent replay)`},step_started:{retryable:!1,reason:`unconditional attempt increment → a retry double-counts attempts`},step_retrying:{retryable:!1,reason:`no duplicate guard → a retry appends a second event row`},hook_received:{retryable:!1,reason:`no server guard → a retry duplicates the row / re-delivers payload`},hook_conflict:{retryable:!1,reason:`server-originated; never POSTed by the SDK`}},Sc=new Set([`ECONNRESET`,`ECONNREFUSED`,`ENOTFOUND`,`ENETDOWN`,`ENETUNREACH`,`EHOSTDOWN`,`EHOSTUNREACH`,`EPIPE`,`ETIMEDOUT`,`UND_ERR_SOCKET`,`UND_ERR_REQ_RETRY`,`UND_ERR_CONNECT_TIMEOUT`,`UND_ERR_HEADERS_TIMEOUT`,`UND_ERR_BODY_TIMEOUT`,`TimeoutError`,`RequestRetryError`]);function Cc(e,t=0){if(t>5||typeof e!=`object`||!e)return[];let n=[],r=e;return typeof r.code==`string`&&n.push(r.code),typeof r.name==`string`&&n.push(r.name),r.cause&&n.push(...Cc(r.cause,t+1)),n}function wc(e){if(l.is(e)||o.is(e)||a.is(e)||s.is(e))return!1;if(i.is(e)){if(e.code===`PARSE_ERROR`)return!0;if(typeof e.status==`number`)return e.status>=500&&e.status<=599}return Cc(e).some(e=>Sc.has(e))}const Tc=e=>new Promise(t=>setTimeout(t,e)),Ec=typeof process<`u`&&typeof process.env.DEBUG==`string`&&(process.env.DEBUG.includes(`workflow:`)||process.env.DEBUG===`*`);function Dc(e,t){if(!Ec)return;let n=Object.entries(t).map(([e,t])=>`${e}=${t}`).join(` `);console.debug(`[workflow:world-vercel:event-retry] ${e} ${n}`)}function Oc(e){return i.is(e)?e.code??(e.status==null?e.name:`status_${e.status}`):Cc(e)[0]??(e instanceof Error?e.name:`unknown`)}async function kc(e,t){let n=xc[t]?.retryable??!1;for(let r=0;;r++)try{return await e()}catch(e){let i=n&&wc(e);if(i&&r<2){let n=100*2**r+Math.floor(Math.random()*50);Dc(`retrying event POST after transient failure`,{eventType:t,attempt:r+1,backoffMs:n,error:Oc(e)}),await Tc(n);continue}throw i&&Dc(`exhausted in-process retries; surfacing for queue redelivery`,{eventType:t,attempts:r+1,error:Oc(e)}),e}}const Ac=`application/vnd.workflow.v4-frames`;function jc(e,t){let n=new Uint8Array(Qt(e)),r=new Uint8Array(4+n.byteLength+4+t.byteLength),i=new DataView(r.buffer);return i.setUint32(0,n.byteLength,!1),r.set(n,4),i.setUint32(4+n.byteLength,t.byteLength,!1),r.set(t,4+n.byteLength+4),r}async function*Mc(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():Pc(e.getReader()),n=new Uint8Array,r=async e=>{for(;n.byteLength<e;){let{done:e,value:r}=await t.next();if(e)return!1;if(!r||r.byteLength===0)continue;let i=new Uint8Array(n.byteLength+r.byteLength);i.set(n,0),i.set(r,n.byteLength),n=i}return!0},i=e=>{let t=n.subarray(0,e);return n=n.subarray(e),t};try{for(;;){if(!await r(4))return;let e=new DataView(n.buffer,n.byteOffset,4).getUint32(0,!1);if(i(4),!await r(e))throw Error(`decodeFrames: truncated meta block`);let t=Et(i(e));if(!await r(4))throw Error(`decodeFrames: truncated body length`);let a=new DataView(n.buffer,n.byteOffset,4).getUint32(0,!1);if(i(4),a>0&&!await r(a))throw Error(`decodeFrames: truncated body bytes`);if(yield{meta:t,body:n.slice(0,a)},i(a),t._end===1)return}}finally{Nc(()=>t.return?.())}}function Nc(e){try{Promise.resolve(e()).catch(()=>{})}catch{}}async function*Pc(e){try{for(;;){let{done:t,value:n}=await e.read();if(t)return;n&&(yield n)}}finally{Nc(()=>e.cancel())}}async function Fc(e,t,n,r){return fr({method:t.method,url:e,headers:t.headers,body:t.body,dispatcher:xn(n),timeoutMs:null,logLabel:r,buildError:async t=>zc(t.status,Ic(t.headers),await t.text(),r,e)})}function Ic(e){let t={};return e.forEach((e,n)=>{t[n]=e}),t}const Lc={eventId:`x-wf-event-id`,runId:`x-wf-run-id`,createdAt:`x-wf-created-at`};function Rc(e){let t={eventType:e.eventType,specVersion:e.specVersion};return e.correlationId!==void 0&&(t.correlationId=e.correlationId),e.vercelId!==void 0&&(t.vercelId=e.vercelId),e.occurredAt!==void 0&&(t.occurredAt=e.occurredAt),e.remoteRefBehavior!==void 0&&(t.remoteRefBehavior=e.remoteRefBehavior),e.deploymentId!==void 0&&(t.deploymentId=e.deploymentId),e.workflowName!==void 0&&(t.workflowName=e.workflowName),e.stepName!==void 0&&(t.stepName=e.stepName),e.attempt!==void 0&&(t.attempt=e.attempt),e.resumeAt!==void 0&&(t.resumeAt=e.resumeAt),e.retryAfter!==void 0&&(t.retryAfter=e.retryAfter),e.hookToken!==void 0&&(t.hookToken=e.hookToken),e.hookIsWebhook!==void 0&&(t.hookIsWebhook=e.hookIsWebhook),e.hookIsSystem!==void 0&&(t.hookIsSystem=e.hookIsSystem),e.errorCode!==void 0&&(t.errorCode=e.errorCode),e.cancelReason!==void 0&&(t.cancelReason=e.cancelReason),e.ownerMessageId!==void 0&&(t.ownerMessageId=e.ownerMessageId),e.executionContext!==void 0&&(t.executionContext=e.executionContext),e.attributes!==void 0&&(t.attributes=e.attributes),e.changes!==void 0&&(t.changes=e.changes),e.writer!==void 0&&(t.writer=e.writer),e.allowReservedAttributes!==void 0&&(t.allowReservedAttributes=e.allowReservedAttributes),e.ttfs!==void 0&&(t.ttfs=e.ttfs),e.stso!==void 0&&(t.stso=e.stso),e.stepCount!==void 0&&(t.stepCount=e.stepCount),e.eventCount!==void 0&&(t.eventCount=e.eventCount),e.optimizations!==void 0&&(t.optimizations=e.optimizations),e.sinceCursor!==void 0&&(t.sinceCursor=e.sinceCursor),e.skipPreload!==void 0&&(t.skipPreload=e.skipPreload),t}function zc(e,t,n,r,i){let a=`v4 ${r} failed: HTTP ${e}`,o;try{let e=JSON.parse(n);typeof e.message==`string`&&(a=e.message),typeof e.code==`string`&&(o=e.code)}catch{n&&(a+=` ${n}`)}let s=or(Vc(t,`retry-after`));return sr(e,a,{retryAfter:s,code:o,url:i,mitigated:Vc(t,`x-vercel-mitigated`)})}async function Bc(e,t){let{baseUrl:n,headers:r}=await Cr(t),i=new Headers(r);i.set(`Content-Type`,`application/octet-stream`);let a=jc(Rc(e),e.payload??new Uint8Array),o=await Fc(`${n}/v4/runs/${encodeURIComponent(e.runId)}/events/${encodeURIComponent(e.eventType)}`,{method:`POST`,headers:i,body:a},t,`createEvent`),s=o.headers.get(Lc.eventId),c=o.headers.get(Lc.runId),l=o.headers.get(Lc.createdAt);if(typeof s!=`string`||typeof c!=`string`||typeof l!=`string`)throw Error(`v4 createEvent: response missing required x-wf-* headers`);let u=new Uint8Array(await o.arrayBuffer());return{eventId:s,runId:c,createdAt:l,body:u.byteLength>0?Et(u):{}}}function Vc(e,t){let n=e[t];if(typeof n==`string`)return n;if(Array.isArray(n)&&n.length>0)return n[0]}async function Hc(e,t,n){let{baseUrl:r,headers:i}=await Cr(n),a=await Fc(`${r}/v4/runs/${encodeURIComponent(e)}/events/${encodeURIComponent(t)}`,{method:`GET`,headers:i},n,`getEvent`),o=a.headers.get(`content-type`);if(!o?.startsWith(`application/vnd.workflow.v4-frames`))throw Error(`v4 getEvent: expected ${Ac}, got ${o??`(none)`}`);let s=a.body;for await(let e of Mc(s))return{event:e.meta,body:e.body};throw Error(`v4 getEvent: empty frame stream for ${t}`)}async function Uc(e,t,n,r){let i=await Fc(e,{method:`GET`,headers:t},n,r),a=i.headers.get(`content-type`);if(!a?.startsWith(`application/vnd.workflow.v4-frames`))throw Error(`v4 ${r}: expected ${Ac}, got ${a??`(none)`}`);let o=i.body,s=[],c,l,u=!1;for await(let e of Mc(o)){if(e.meta._end===1){typeof e.meta.next==`string`&&(c=e.meta.next),typeof e.meta.hasMore==`boolean`&&(l=e.meta.hasMore),u=!0;break}s.push({event:e.meta,body:e.body})}if(!u)throw Error(`v4 ${r}: frame stream ended without the end-of-stream sentinel (${s.length} events read) — truncated response?`);return{events:s,...c?{next:c}:{},...l===void 0?{}:{hasMore:l}}}function Wc(e,t){t.cursor&&e.set(`cursor`,t.cursor),t.limit!==void 0&&e.set(`limit`,String(t.limit)),t.sortOrder&&e.set(`sortOrder`,t.sortOrder),t.remoteRefBehavior&&e.set(`remoteRefBehavior`,t.remoteRefBehavior)}function Gc(e){let t=new URLSearchParams;Wc(t,e);let n=t.toString();return n?`?${n}`:``}async function Kc(e,t={},n){let{baseUrl:r,headers:i}=await Cr(n);return Uc(`${r}/v4/runs/${encodeURIComponent(e)}/events`+Gc(t),i,n,`listEvents`)}async function qc(e,t={},n){let{baseUrl:r,headers:i}=await Cr(n),a=new URLSearchParams;return a.set(`correlationId`,e),Wc(a,t),Uc(`${r}/v4/events?${a.toString()}`,i,n,`listEventsByCorrelationId`)}const Jc=`zstd`,Yc=new TextDecoder;function Xc(){try{return globalThis.process?.getBuiltinModule?.(`node:zlib`)}catch{return}}function Zc(e){return!(e instanceof Uint8Array)||e.byteLength<4?null:Yc.decode(e.subarray(0,4))}function Qc(e,t){let n=Xc(),r=e===Jc?n?.zstdDecompressSync:n?.gunzipSync;if(!r)throw new i(`Received ${e}-compressed workflow data, but this Node.js runtime does not support ${e} decompression. Use a compatible Node.js runtime or request unresolved data.`);return new Uint8Array(r(t))}function $c(e){let t=Zc(e);return t!==Jc&&t!==`gzip`?e:Qc(t,e.subarray(4))}function el(e){return{...e,input:$c(e.input),output:$c(e.output),error:$c(e.error)}}function tl(e){return{...e,input:$c(e.input),output:$c(e.output),error:$c(e.error)}}function nl(e){return{...e,metadata:$c(e.metadata)}}function rl(e){let t=e.eventData;if(!t||typeof t!=`object`)return e;let n=h(typeof e.eventType==`string`?e.eventType:``);if(n.length===0)return e;let r={...t},i=!1;for(let e of n){if(!(e in r))continue;let t=r[e],n=$c(t);n!==t&&(r[e]=n,i=!0)}return i?{...e,eventData:r}:e}const il=d.omit({error:!0,errorCode:!0}).extend({error:re([T,D()]).optional(),errorCode:ue().optional(),blobStorageBytes:te().optional(),streamStorageBytes:te().optional()}),al=il,ol=il.omit({input:!0,output:!0}).extend({inputRef:D().optional(),outputRef:D().optional(),input:re([E(Uint8Array),D()]).optional(),output:re([E(Uint8Array),D()]).optional()});function sl(e,t){if(t===`none`){let{inputRef:t,outputRef:n,...r}=e;return{...el(yr(r)),input:void 0,output:void 0}}return el(yr(e))}async function cl(e={},t){let{workflowName:n,status:r,pagination:i,resolveData:a=`all`}=e,o=new URLSearchParams;n&&o.set(`workflowName`,n),r&&o.set(`status`,r),i?.limit&&o.set(`limit`,i.limit.toString()),i?.cursor&&o.set(`cursor`,i.cursor),i?.sortOrder&&o.set(`sortOrder`,i.sortOrder);let s=a===`none`?`lazy`:`resolve`;o.set(`remoteRefBehavior`,s);let c=o.toString(),l=await K({endpoint:`/v2/runs${c?`?${c}`:``}`,options:{method:`GET`},config:t,schema:ie(s===`lazy`?ol:al)});return{...l,data:l.data.map(e=>sl(e,a))}}async function ll(e,t){return yr(await K({endpoint:`/v1/runs/create`,options:{method:`POST`},data:e,config:t,schema:al}))}async function ul(e,t,n){let a=t?.resolveData??`all`,o=a===`none`?`lazy`:`resolve`,s=new URLSearchParams;s.set(`remoteRefBehavior`,o);let c=s.toString(),l=`/v2/runs/${encodeURIComponent(e)}${c?`?${c}`:``}`;try{return sl(await K({endpoint:l,options:{method:`GET`},config:n,schema:o===`lazy`?ol:al}),a)}catch(t){throw t instanceof i&&t.status===404?new r(e):t}}async function dl(e,t,n){let a=t?.resolveData??`all`,o=a===`none`?`lazy`:`resolve`,s=new URLSearchParams;s.set(`remoteRefBehavior`,o);let c=s.toString(),l=`/v1/runs/${encodeURIComponent(e)}/cancel${c?`?${c}`:``}`;try{return sl(await K({endpoint:l,options:{method:`PUT`},config:n,schema:o===`lazy`?ol:al}),a)}catch(t){throw t instanceof i&&t.status===404?new r(e):t}}const fl=de({attributes:oe(ue(),ue())});async function pl(e,t,n,a){try{return{attributes:(await K({endpoint:`/v2/runs/${encodeURIComponent(e)}/attributes`,options:{method:`POST`},data:n?.allowReservedAttributes?{changes:t,allowReservedAttributes:!0}:{changes:t},config:a,schema:fl})).attributes}}catch(t){throw t instanceof i&&t.status===404?new r(e):t}}const ml=v.omit({error:!0}).extend({error:re([T,D()]).optional(),errorRef:D().optional()}),hl=ml.omit({input:!0,output:!0}).extend({inputRef:D().optional(),outputRef:D().optional(),input:E(Uint8Array).optional(),output:E(Uint8Array).optional()});function gl(e){let{error:t,errorRef:n,...r}=e,i={...r},a=t??n;return a!=null&&(i.error=a),i}function _l(e,t){if(t===`none`){let{inputRef:t,outputRef:n,...r}=e;return{...tl(gl(r)),input:void 0,output:void 0}}return tl(gl(e))}async function vl(e,t){let{runId:n,pagination:r,resolveData:i=`all`}=e,a=new URLSearchParams;r?.cursor&&a.set(`cursor`,r.cursor),r?.limit&&a.set(`limit`,r.limit.toString()),r?.sortOrder&&a.set(`sortOrder`,r.sortOrder);let o=i===`none`?`lazy`:`resolve`;a.set(`remoteRefBehavior`,o);let s=a.toString(),c=await K({endpoint:`/v2/runs/${encodeURIComponent(n)}/steps${s?`?${s}`:``}`,options:{method:`GET`},config:t,schema:ie(o===`lazy`?hl:ml)});return{...c,data:c.data.map(e=>_l(e,i))}}async function yl(e,t,n,r){let i=n?.resolveData??`all`,a=i===`none`?`lazy`:`resolve`,o=new URLSearchParams;o.set(`remoteRefBehavior`,a);let s=o.toString();return _l(await K({endpoint:`/v2/runs/${encodeURIComponent(e)}/steps/${encodeURIComponent(t)}${s?`?${s}`:``}`,options:{method:`GET`},config:r,schema:a===`lazy`?hl:ml}),i)}function bl(e){let t=e.startsWith(`wrun_`)?e.slice(5):e;try{return le(`wrun_${Br(t).ulid}`,`wrun_`)}catch{return le(e,`wrun_`)}}const xl=new Set([`run_created`,`run_started`,`step_started`]);function Sl(e){let t=e.eventData??{},n=m(e.eventType),r={};if(typeof t.deploymentId==`string`&&(r.deploymentId=t.deploymentId),typeof t.workflowName==`string`&&(r.workflowName=t.workflowName),typeof t.stepName==`string`&&(r.stepName=t.stepName),typeof t.attempt==`number`&&(r.attempt=t.attempt),t.resumeAt instanceof Date)r.resumeAt=t.resumeAt;else if(typeof t.resumeAt==`string`){let e=new Date(t.resumeAt);Number.isNaN(e.getTime())||(r.resumeAt=e)}if(t.retryAfter instanceof Date)r.retryAfter=t.retryAfter;else if(typeof t.retryAfter==`string`){let e=new Date(t.retryAfter);Number.isNaN(e.getTime())||(r.retryAfter=e)}typeof t.token==`string`&&(r.hookToken=t.token),typeof t.isWebhook==`boolean`&&(r.hookIsWebhook=t.isWebhook),typeof t.isSystem==`boolean`&&(r.hookIsSystem=t.isSystem),typeof t.errorCode==`string`&&(r.errorCode=t.errorCode),typeof t.cancelReason==`string`&&(r.cancelReason=t.cancelReason),typeof t.ownerMessageId==`string`&&(r.ownerMessageId=t.ownerMessageId),t.executionContext!==void 0&&t.executionContext!==null&&typeof t.executionContext==`object`&&(r.executionContext=t.executionContext),t.attributes!==void 0&&t.attributes!==null&&typeof t.attributes==`object`&&(r.attributes=t.attributes),Array.isArray(t.changes)&&(r.changes=t.changes),t.writer!==void 0&&t.writer!==null&&typeof t.writer==`object`&&(r.writer=t.writer),typeof t.allowReservedAttributes==`boolean`&&(r.allowReservedAttributes=t.allowReservedAttributes),typeof t.ttfs==`number`&&(r.ttfs=t.ttfs),typeof t.stso==`number`&&(r.stso=t.stso),typeof t.stepCount==`number`&&Number.isSafeInteger(t.stepCount)&&t.stepCount>0&&(r.stepCount=t.stepCount),typeof t.eventCount==`number`&&Number.isSafeInteger(t.eventCount)&&t.eventCount>0&&(r.eventCount=t.eventCount),Array.isArray(t.optimizations)&&t.optimizations.every(e=>typeof e==`string`)&&(r.optimizations=t.optimizations);let i;if(n&&n in t){let r=t[n];if(r!==void 0){if(!(r instanceof Uint8Array))throw TypeError(`world-vercel v4: eventData.${n} for ${e.eventType} must be a Uint8Array (the runtime's dehydrated wire form); got ${typeof r==`object`?r===null?`null`:r.constructor?.name??typeof r:typeof r}.`);i=r}}return{payload:i,meta:r}}function Cl(e){let t=_.safeParse(e);return t.success?t.data:(y.safeParse(e.eventType).success&&console.debug(`[workflow:world-vercel] v4 event ${e.eventId} failed EventSchema parse for known eventType '${e.eventType}'; passing through unparsed: ${t.error.message}`),e)}function wl(e){return Cl(rl(e))}function Tl(e,t,n){let r=e.eventData??{};if(t.byteLength>0){let n=m(e.eventType),i=$c(t);n&&i instanceof Uint8Array&&(r[n]=i)}let i=wl({eventId:e.eventId,runId:e.runId,eventType:e.eventType,createdAt:e.createdAt instanceof Date?e.createdAt:new Date(e.createdAt),...e.occurredAt===void 0?{}:{occurredAt:e.occurredAt instanceof Date?e.occurredAt:new Date(e.occurredAt)},...e.correlationId?{correlationId:e.correlationId}:{},eventData:r,...e.specVersion===void 0?{}:{specVersion:e.specVersion}});return n===`none`?w(i,`none`):i}async function El(e,t,n,r){let i=n?.resolveData??`all`,{event:a,body:o}=await Hc(e,t,r);return Tl(a,o,i)}async function Dl(e,t){let{pagination:n,resolveData:r=`all`}=e,i={cursor:n?.cursor??void 0,limit:n?.limit,sortOrder:n?.sortOrder,remoteRefBehavior:r===`none`?`lazy`:`resolve`},a=await(`correlationId`in e?qc(e.correlationId,i,t):Kc(e.runId,i,t));return{data:a.events.map(e=>Tl(e.event,e.body,r)),cursor:a.next??null,hasMore:typeof a.hasMore==`boolean`?a.hasMore:!!a.next}}async function Ol(e,t,n,r){try{return await kc(()=>kl(e,t,n,r),t.eventType)}catch(e){throw x(t.eventType)&&i.is(e)&&e.status===404&&t.correlationId?new c(t.correlationId):e}}async function kl(e,t,n,r){if(n?.v1Compat){if(t.eventType===`run_cancelled`&&e)return{run:await dl(e,n,r)};if(t.eventType===`run_created`)return{run:await ll(t.eventData,r)};if(e===null)throw new i(`world-vercel: v1Compat=true requires a runId for ${t.eventType}`,{status:400});return{event:await K({endpoint:`/v1/runs/${encodeURIComponent(e)}/events`,options:{method:`POST`},data:t,config:r,schema:_})}}if(e===null)throw new i(`world-vercel v4: createWorkflowRunEvent requires a client-generated runId for run_created (the runId is part of the payload storage ref key). Generate a wrun_ ULID before calling.`,{status:400});if(t.eventType===`run_created`){let t=bl(e);if(t)throw new i(t,{status:400})}let a=xl.has(t.eventType)?`resolve`:`lazy`,{payload:o,meta:s}=Sl(t),c=await Bc({runId:e,eventType:t.eventType,specVersion:t.specVersion??2,...t.correlationId?{correlationId:t.correlationId}:{},...n?.requestId?{vercelId:n.requestId}:{},occurredAt:n?.occurredAt??new Date,...n?.sinceCursor?{sinceCursor:n.sinceCursor}:{},...n?.skipPreload?{skipPreload:!0}:{},remoteRefBehavior:a,payload:o,...s},r),l=n?.resolveData??`all`,u=c.body;return{event:u.event?w(Cl(u.event),l):void 0,run:u.run?yr(u.run):void 0,step:u.step?gl(u.step):void 0,hook:u.hook,wait:u.wait,events:u.events?u.events.map(Cl):void 0,cursor:u.cursor??void 0,hasMore:u.hasMore,...u.stepCreated?{stepCreated:!0}:{}}}function Al(e,t){if(t===`none`){let{metadataRef:t,...n}=e;return n}return nl(e)}const jl=me.omit({metadata:!0}).extend({metadataRef:g.any().optional()});async function Ml(e,t){let{runId:n,pagination:r,resolveData:i=`all`}=e,a=new URLSearchParams;r?.limit&&a.set(`limit`,r.limit.toString()),r?.cursor&&a.set(`cursor`,r.cursor),r?.sortOrder&&a.set(`sortOrder`,r.sortOrder);let o=i===`none`?`lazy`:`resolve`;a.set(`remoteRefBehavior`,o),n&&a.set(`runId`,n);let s=a.toString(),c=await K({endpoint:`/v2/hooks${s?`?${s}`:``}`,options:{method:`GET`},config:t,schema:ie(o===`lazy`?jl:me)});return{...c,data:c.data.map(e=>Al(e,i))}}async function Nl(e,t,n){let r=t?.resolveData||`all`;return Al(await K({endpoint:`/v2/hooks/${encodeURIComponent(e)}`,options:{method:`GET`},config:n,schema:me}),r)}async function Pl(e,t){try{return await K({endpoint:`/v2/hooks/by-token?token=${encodeURIComponent(e)}`,options:{method:`GET`},config:t,schema:me})}catch(t){throw i.is(t)&&t.status===404?new c(e):t}}function Fl(e){let t={runs:{get:((t,n)=>ul(t,n,e)),list:(t=>cl(t,e)),experimentalSetAttributes:(t,n,r)=>pl(t,n,r,e)},steps:{get:((t,n,r)=>yl(t,n,r,e)),list:(t=>vl(t,e))},events:{create:(t,n,r)=>Ol(t,n,r,e),get:(t,n,r)=>El(t,n,r,e),list:t=>Dl(t,e),listByCorrelationId:t=>Dl(t,e)},hooks:{get:(t,n)=>Nl(t,n,e),getByToken:t=>Pl(t,e),list:t=>Ml(t,e)}};return{runs:oi(`world.runs`,t.runs),steps:oi(`world.steps`,t.steps),events:oi(`world.events`,t.events),hooks:oi(`world.hooks`,t.hooks)}}const Il=()=>ee(`WORKFLOW_MAX_CHUNKS_PER_REQUEST`,1e3,{integer:!0,min:1});function Ll(e,t,n){return new URL(`${n.baseUrl}/v2/runs/${encodeURIComponent(t)}/stream/${encodeURIComponent(e)}`)}function Rl(e,t,n){return new URL(`${n.baseUrl}/v3/runs/${encodeURIComponent(t)}/stream/${encodeURIComponent(e)}`)}function zl(e){return{...Jn(e.runId),...Xn(e.name),...Zn(e.operation),...typeof e.startIndex==`number`?Qn(e.startIndex):{}}}function Bl(e,t,n,r){let i=[`PUT ${t.origin}${t.pathname}`,...nr(n.headers)];return Error(`Stream ${e} failed: HTTP ${n.status} (${i.join(`; `)}): ${r}`)}function Vl(e){let t=new TextEncoder,n=[],r=0;for(let i of e){let e=typeof i==`string`?t.encode(i):i;n.push(e),r+=4+e.length}let i=new Uint8Array(r),a=new DataView(i.buffer),o=0;for(let e of n)a.setUint32(o,e.length,!1),o+=4,i.set(e,o),o+=e.length;return i}const Hl=de({tailIndex:te(),done:u()}),Ul=de({data:b(de({index:te(),data:E(Uint8Array)})),cursor:ue().nullable(),hasMore:u(),done:u()});function Wl(e){return{streams:{async write(t,n,r){let i=await t,a=await Cr(e),o=Ll(n,i,a);await(await fr({method:`PUT`,url:o.toString(),body:r,headers:a.headers,dispatcher:Sn(e),timeoutMs:null,logLabel:o.pathname,spanName:`workflow.stream.write`,durationAttribute:`workflow.stream.write.chunk_rtt`,attributes:zl({runId:i,name:n,operation:`write`}),buildError:async e=>Bl(`write`,o,e,await e.text())})).text()},async writeMulti(t,n,r){if(r.length===0)return;let i=await t,a=await Cr(e);a.headers.set(`X-Stream-Multi`,`true`);let o=Il();for(let t=0;t<r.length;t+=o){let s=Vl(r.slice(t,t+o)),c=Ll(n,i,a);await(await fr({method:`PUT`,url:c.toString(),body:s,headers:a.headers,dispatcher:Sn(e),timeoutMs:null,logLabel:c.pathname,spanName:`workflow.stream.write`,durationAttribute:`workflow.stream.write.chunk_rtt`,attributes:zl({runId:i,name:n,operation:`write_multi`}),buildError:async e=>Bl(`write`,c,e,await e.text())})).text()}},async close(t,n){let r=await t,i=await Cr(e);i.headers.set(`X-Stream-Done`,`true`);let a=Ll(n,r,i);await(await fr({method:`PUT`,url:a.toString(),headers:i.headers,dispatcher:Sn(e),timeoutMs:null,logLabel:a.pathname,spanName:`workflow.stream.write`,durationAttribute:`workflow.stream.write.chunk_rtt`,attributes:zl({runId:r,name:n,operation:`close`}),buildError:async e=>Bl(`close`,a,e,await e.text())})).text()},async get(t,n,r){let i=await Cr(e),a=Rl(n,t,i);typeof r==`number`&&a.searchParams.set(`startIndex`,String(r));let o=await fr({method:`GET`,url:a.toString(),headers:i.headers,dispatcher:void 0,timeoutMs:null,logLabel:a.pathname,spanName:`workflow.stream.read.connect`,attributes:zl({runId:t,name:n,operation:`read`,startIndex:r}),buildError:e=>Error(`Failed to fetch stream: ${e.status}`)});if(!o.body)throw Error(`No response body for stream`);return o.body},async getChunks(t,n,r){let i=new URLSearchParams;r?.limit!=null&&i.set(`limit`,String(r.limit)),r?.cursor&&i.set(`cursor`,r.cursor);let a=i.toString();return K({endpoint:`/v2/runs/${encodeURIComponent(t)}/streams/${encodeURIComponent(n)}/chunks${a?`?${a}`:``}`,config:e,schema:Ul})},async getInfo(t,n){return K({endpoint:`/v2/runs/${encodeURIComponent(t)}/streams/${encodeURIComponent(n)}/info`,config:e,schema:Hl})},async list(t){let n=await Cr(e),r=new URL(`${n.baseUrl}/v2/runs/${encodeURIComponent(t)}/streams`);return await(await fr({method:`GET`,url:r.toString(),headers:n.headers,dispatcher:void 0,timeoutMs:null,logLabel:r.pathname,buildError:e=>Error(`Failed to list streams: ${e.status}`)})).json()}}}}function Gl(e){let t=e?.projectConfig?.projectId||process.env.VERCEL_PROJECT_ID;return{specVersion:5,processExitTriggersQueueRedelivery:!0,...vc(e),...Fl(e),analytics:kr(e),...oi(`world.streams`,Wl(e)),createRunId:Kr,describeRun:Jr,getEncryptionKeyForRun:Zr(t,e?.projectConfig?.teamId,e?.token,e?.dispatcher),resolveLatestDeploymentId:bc(e)}}function Kl(e){return Gl(e)}export{kr as createAnalytics,Zr as createGetEncryptionKeyForRun,vc as createQueue,Kr as createRunId,Fl as createStorage,Wl as createStreamer,Kl as createVercelWorld,Gl as createWorld,Yr as deriveRunKey,Jr as describeRun,Xr as fetchRunKey,Te as i,Ba as n,je as r,qr as regionForRunId,Ka as t};
|
|
42
|
+
Cause: ${t}`)}}buildUrl(e,...t){let n=encodeURIComponent(e),r=t.map(e=>encodeURIComponent(e)),i=r.length>0?`/`+r.join(`/`):``,a=this.baseUrl.pathname.replace(/\/+$/,``);return`${this.baseUrl.origin}${a}${Us}/${n}${i}`}async fetch(e,t){let n=t.method||`GET`;if(Ps()){let r={method:n,url:e,headers:t.headers},i=t.body;i!=null&&(i instanceof ArrayBuffer||i instanceof Uint8Array?r.bodySize=i.byteLength:typeof i==`string`?r.bodySize=i.length:r.bodyType=typeof i),console.debug(`[VQS Debug] Request:`,JSON.stringify(r,null,2))}t.headers.set(`User-Agent`,`@vercel/queue/0.4.0`),t.headers.set(`Vqs-Client-Ts`,new Date().toISOString());let r=this.dispatcher?{...t,dispatcher:this.dispatcher}:t,i=await fetch(e,r);if(Ps()){let t={method:n,url:e,status:i.status,statusText:i.statusText,headers:i.headers};console.debug(`[VQS Debug] Response:`,JSON.stringify(t,null,2))}return i}async sendMessage(e){let t=this.transport,{queueName:n,payload:r,idempotencyKey:i,retentionSeconds:a,delaySeconds:o,headers:s,telemetry:c}=e,l=new Headers;if(this.customHeaders)for(let[e,t]of Object.entries(this.customHeaders))l.append(e,t);if(s){let e=new Set([`authorization`,`content-type`]),t=t=>{let n=t.toLowerCase();return e.has(n)?!0:n.startsWith(`vqs-`)};for(let[e,n]of Object.entries(s))!t(e)&&n!==void 0&&l.append(e,n)}l.set(`Authorization`,`Bearer ${await this.getToken()}`),l.set(`Content-Type`,t.contentType);let u=this.getSendDeploymentId();u&&l.set(`Vqs-Deployment-Id`,u),i&&l.set(`Vqs-Idempotency-Key`,i),a!==void 0&&l.set(`Vqs-Retention-Seconds`,a.toString()),o!==void 0&&l.set(`Vqs-Delay-Seconds`,o.toString());let d=t.serialize(r),f=Buffer.isBuffer(d)?new Uint8Array(d):d,p=ys(this.telemetry,c);return Ds(n,async e=>{await ws(l,p);let t=await this.fetch(this.buildUrl(n),{method:`POST`,body:f,headers:l});if(!t.ok){let e=await t.text();if(t.status===409)throw new ao(e||`Duplicate idempotency key detected`,i);if(t.status===502)throw new oo(e||`Consumer discovery failed`,u);if(t.status===503)throw new so(e||`Consumer registry not configured`);Ls(t.status,t.statusText,e,`send message`)}if(t.status===202)return await t.text(),{messageId:null};let r=await t.json();return e&&r.messageId&&e.setMessageId(r.messageId),r},p)}async*receiveMessages(e){let t=this.transport,{queueName:n,consumerGroup:r,visibilityTimeoutSeconds:i,limit:a}=e;if(a!==void 0&&(a<1||a>10))throw new ro(a);let o=new Headers({Authorization:`Bearer ${await this.getToken()}`,Accept:`multipart/mixed`,...this.customHeaders});i!==void 0&&o.set(`Vqs-Visibility-Timeout-Seconds`,i.toString()),a!==void 0&&o.set(`Vqs-Max-Messages`,a.toString());let s=this.getConsumeDeploymentId();s&&o.set(`Vqs-Deployment-Id`,s);let c=await this.fetch(this.buildUrl(n,`consumer`,r),{method:`POST`,headers:o});if(c.status===204){await c.text();return}if(!c.ok){let e=await c.text();Ls(c.status,c.statusText,e,`receive messages`)}for await(let e of li(c))try{let n=Rs(e.headers);if(!n){console.warn(`Missing required queue headers in multipart part`),await Fs(e.payload);continue}let r=await t.deserialize(e.payload);yield{...n,payload:r}}catch(t){console.warn(`Failed to process multipart message:`,t),await Fs(e.payload)}}async receiveMessageById(e){let t=this.transport,{queueName:n,consumerGroup:r,messageId:i,visibilityTimeoutSeconds:a}=e,o=new Headers({Authorization:`Bearer ${await this.getToken()}`,Accept:`multipart/mixed`,...this.customHeaders});a!==void 0&&o.set(`Vqs-Visibility-Timeout-Seconds`,a.toString());let s=this.getConsumeDeploymentId();s&&o.set(`Vqs-Deployment-Id`,s);let c=await this.fetch(this.buildUrl(n,`consumer`,r,`id`,i),{method:`POST`,headers:o});if(!c.ok){let e=await c.text();if(c.status===404)throw new Ya(i);if(c.status===409){let t={};try{t=JSON.parse(e)}catch{}throw t.originalMessageId?new Xa(i,`This message was a duplicate - use originalMessageId: ${t.originalMessageId}`):new Xa(i)}if(c.status===410)throw new io(i);Ls(c.status,c.statusText,e,`receive message by ID`)}for await(let e of li(c)){let n=Rs(e.headers);if(!n)throw await Fs(e.payload),new Za(i,`Missing required queue headers in response`);let r=await t.deserialize(e.payload);return{message:{...n,payload:r}}}throw new Ya(i)}async acknowledgeMessage(e){let{queueName:t,consumerGroup:n,receiptHandle:r}=e,i=new Headers({Authorization:`Bearer ${await this.getToken()}`,...this.customHeaders}),a=this.getConsumeDeploymentId();a&&i.set(`Vqs-Deployment-Id`,a);let o=await this.fetch(this.buildUrl(t,`consumer`,n,`lease`,r),{method:`DELETE`,headers:i});if(!o.ok){let e=await o.text();if(o.status===404)throw new Ya(r);if(o.status===409)throw new Xa(r,e||`Invalid receipt handle, message not in correct state, or already processed`);Ls(o.status,o.statusText,e,`acknowledge message`,`Missing or invalid receipt handle`,o.headers?.get(`Retry-After`)??null)}return await o.text(),{acknowledged:!0}}async changeVisibility(e){let{queueName:t,consumerGroup:n,receiptHandle:r,visibilityTimeoutSeconds:i}=e,a=new Headers({Authorization:`Bearer ${await this.getToken()}`,"Content-Type":`application/json`,...this.customHeaders}),o=this.getConsumeDeploymentId();o&&a.set(`Vqs-Deployment-Id`,o);let s=await this.fetch(this.buildUrl(t,`consumer`,n,`lease`,r),{method:`PATCH`,headers:a,body:JSON.stringify({visibilityTimeoutSeconds:i})});if(!s.ok){let e=await s.text();if(s.status===404)throw new Ya(r);if(s.status===409)throw new Xa(r,e||`Invalid receipt handle, message not in correct state, or already processed`);Ls(s.status,s.statusText,e,`change visibility`,`Missing receipt handle or invalid visibility timeout`,s.headers?.get(`Retry-After`)??null)}return await s.text(),{success:!0}}},Gs=new WeakMap,Ks=Symbol.for(`@vercel/queue.apiClient`);function qs(e,t){Gs.set(e,t),Object.defineProperty(e,Ks,{value:t,writable:!1,enumerable:!1,configurable:!1})}function Js(e){let t=Gs.get(e);if(t)return t;let n=e[Ks];if(typeof n==`object`&&n){let t=n;return Gs.set(e,t),t}throw Error(`QueueClient not initialized. This may happen when multiple bundled copies of @vercel/queue are loaded in local dev.`)}function Ys(e){return`request`in e?e.request:e}function Xs(e){return Js(e)}var Zs=`iad1`;function Qs(e){return e||process.env.VERCEL_REGION||(jo()||console.warn(`[QueueClient] Region not detected \u2014 defaulting to "${Zs}". On Vercel this is set automatically via VERCEL_REGION. To silence this warning, pass region explicitly: new QueueClient({ region: "iad1" })`),Zs)}var $s=class{constructor(e={}){let t=Qs(e.region);qs(this,new Ws({...e,region:t}))}send=async(e,t,n)=>{let r=Js(this),i=await r.sendMessage({queueName:e,payload:t,idempotencyKey:n?.idempotencyKey,retentionSeconds:n?.retentionSeconds,delaySeconds:n?.delaySeconds,headers:n?.headers,telemetry:n?.telemetry});return i.messageId&&jo()&&_s(e,i.messageId,r.getRegion(),n?.delaySeconds,n?.retentionSeconds),{messageId:i.messageId}};handleCallback=(e,t)=>{jo()&&qo(e,this,t);let n=ys(Js(this).getTelemetry?.());return async r=>{let i=Ys(r);if(jo()&&i.headers.get(`x-vercel-queue-prime`)===`1`){let n=i.headers.get(`x-vercel-queue-prime-file`);return n&&qo(e,this,t,n),Response.json({status:`primed`})}try{let r=await Eo(i);return await js(i.headers,()=>Do(e,r,{client:this,visibilityTimeoutSeconds:t?.visibilityTimeoutSeconds,retry:t?.retry}),n),Response.json({status:`success`})}catch(e){return console.error(`Queue callback error:`,e),e instanceof Error&&(e.message.includes(`Invalid content type`)||e.message.includes(`Invalid CloudEvent`)||e.message.includes(`Missing required CloudEvent`)||e.message.includes(`Failed to parse CloudEvent`)||e.message.includes(`Binary mode callback`))?Response.json({error:e.message},{status:400}):Response.json({error:`Failed to process queue message`},{status:500})}}};handleNodeCallback=(e,t)=>{jo()&&qo(e,this,t);let n=ys(Js(this).getTelemetry?.());return async(r,i)=>{if(r.method!==`POST`){i.status(200).end();return}let a=r.headers[`x-vercel-queue-prime`];if(jo()&&a===`1`){let n=r.headers[`x-vercel-queue-prime-file`],a=Array.isArray(n)?n[0]:n;a&&qo(e,this,t,a),i.status(200).json({status:`primed`});return}try{let a=To(r.body,r.headers);await js(r.headers,()=>Do(e,a,{client:this,visibilityTimeoutSeconds:t?.visibilityTimeoutSeconds,retry:t?.retry}),n),i.status(200).json({status:`success`})}catch(e){if(console.error(`Queue callback error:`,e),e instanceof Error&&(e.message.includes(`Invalid content type`)||e.message.includes(`Invalid CloudEvent`)||e.message.includes(`Missing required CloudEvent`)||e.message.includes(`Failed to parse CloudEvent`)||e.message.includes(`Binary mode callback`))){i.status(400).json({error:e.message});return}i.status(500).json({error:`Failed to process queue message`})}}}},ec=class{contentType=`application/cbor`;serialize(e){return Buffer.from(sn(e))}async deserialize(e){let t=[],n=e.getReader();for(;;){let{done:e,value:r}=await n.read();if(e)break;r&&t.push(r)}return Pt(Buffer.concat(t))}},tc=class{contentType=`application/json`;serialize(e){return Buffer.from(JSON.stringify(e))}async deserialize(e){let t=[],n=e.getReader();for(;;){let{done:e,value:r}=await n.read();if(e)break;r&&t.push(r)}return JSON.parse(Buffer.concat(t).toString())}},nc=class{contentType=`application/cbor`;serialize(e){return Buffer.from(sn(e))}async deserialize(e){let t=[],n=e.getReader();for(;;){let{done:e,value:r}=await n.read();if(e)break;r&&t.push(r)}let r=Buffer.concat(t);try{return Pt(r)}catch{return JSON.parse(r.toString())}}};const rc=new Ee,ic=de({payload:le,queueName:ae,deploymentId:E().optional()}),ac=Number(process.env.VERCEL_QUEUE_MAX_DELAY_SECONDS||82800);function oc(e){let t=Math.min(Math.max(1,2**(e-1)),900),n=Math.floor(Math.random()*(Math.ceil(t*.25)+1));return Math.max(1,t-n)}function sc(e){if(`runId`in e&&typeof e.runId==`string`)return e.runId;if(`workflowRunId`in e&&typeof e.workflowRunId==`string`)return e.workflowRunId}function cc(e){if(!e)return;let t=e.startsWith(`wrun_`)?e.slice(5):e;try{let e=Se(t);return!e.tagged||e.regionId===_e.unknown?void 0:e.region??void 0}catch{return}}function lc(e,t){if(ge(t?.region))return t.region;let n=cc(sc(e));if(n)return n;let r=process.env.VERCEL_REGION;return ge(r)?r:`iad1`}function uc(e){let t={};return`runId`in e&&typeof e.runId==`string`&&(t[`x-vercel-workflow-run-id`]=e.runId),`workflowRunId`in e&&typeof e.workflowRunId==`string`&&(t[`x-vercel-workflow-run-id`]=e.workflowRunId),`stepId`in e&&typeof e.stepId==`string`&&(t[`x-vercel-workflow-step-id`]=e.stepId),Object.keys(t).length>0?t:void 0}const dc=/^__([a-z][a-z0-9]*_)?wkf_workflow_/;let fc=!1;function pc(){return process.env.WORKFLOW_SEQUENTIAL_REPLAYS===`1`}function mc(e,t){return!pc()||!dc.test(e)?e:(fc||(fc=!0,console.warn(`[workflow] WORKFLOW_SEQUENTIAL_REPLAYS=1: routing flow messages to per-run queue topics`)),`runId`in t&&typeof t.runId==`string`?`stepId`in t&&typeof t.stepId==`string`?`${e}_${t.runId}_${t.stepId}`:`${e}_${t.runId}`:`__healthCheck`in t&&typeof t.correlationId==`string`?`${e}_${t.correlationId}`:e)}function hc(e){let{baseUrl:t,usingProxy:n}=kr(e),r=Ar(e,{usingProxy:n}),i=new ec,a=new tc,o=new nc,s={dispatcher:On(e),transport:o,...n&&{resolveBaseUrl:()=>new URL(`${t}/queues-proxy`),token:e?.token},headers:Object.fromEntries(r.entries())},c=async(e,t,r)=>{let o=r?.deploymentId??process.env.VERCEL_DEPLOYMENT_ID;if(!o)throw Error(`No deploymentId provided and VERCEL_DEPLOYMENT_ID environment variable is not set. Queue messages require a deployment ID to route correctly. Either set VERCEL_DEPLOYMENT_ID or provide deploymentId in options.`);let c=(r?.specVersion??5)>=3?i:a,l=lc(t,r),u=new $s({...s,...n&&{headers:{...s.headers,"x-vercel-queue-region":l}},region:l,deploymentId:o,transport:c}),d={payload:t,queueName:e,deploymentId:r?.deploymentId},f=mc(e,t).replace(/[^A-Za-z0-9-_]/g,`-`);try{let{messageId:e}=await u.send(f,d,{idempotencyKey:r?.idempotencyKey,delaySeconds:r?.delaySeconds,headers:{...uc(t),...r?.headers}});return{messageId:e?re.parse(e):null}}catch(e){if(e instanceof ao)return{messageId:re.parse(`msg_duplicate_${e.idempotencyKey??r?.idempotencyKey??`unknown`}`)};throw e}};return{queue:c,createQueueHandler:(e,t)=>{let n=new $s(s).handleCallback(async(e,n)=>{if(!e||!n)return;let r=rc.getStore(),{payload:i,queueName:a,deploymentId:o}=ic.parse(e),s=await t(i,{queueName:a,messageId:re.parse(n.messageId),attempt:n.deliveryCount,requestId:r});typeof s?.timeoutSeconds==`number`&&await c(a,i,{deploymentId:o,delaySeconds:s.timeoutSeconds>0?Math.min(s.timeoutSeconds,ac):void 0})},{retry:(e,{deliveryCount:t})=>({afterSeconds:oc(t)})});return async e=>{let t=e.headers.get(`x-vercel-id`)?.trim()||void 0;return rc.run(t,()=>n(e))}},getDeploymentId:async()=>{let e=process.env.VERCEL_DEPLOYMENT_ID;if(!e)throw Error(`VERCEL_DEPLOYMENT_ID environment variable is not set`);return e}}}const gc=de({id:E()});function _c(e){return async function(){let t=process.env.VERCEL_DEPLOYMENT_ID;if(!t)throw Error(`Cannot resolve latest deployment: VERCEL_DEPLOYMENT_ID environment variable is not set`);let n=await _r(e);if(!n)throw Error(`Cannot resolve latest deployment: no OIDC token or VERCEL_TOKEN available`);let r=await(await br({method:`GET`,url:`https://api.vercel.com/v1/workflow/resolve-latest-deployment/${encodeURIComponent(t)}`,headers:new Headers({Authorization:`Bearer ${n}`}),dispatcher:On(e),peerService:`vercel-api`,timeoutMs:null,buildError:async e=>{let n;try{n=await e.text()}catch{n=`<unable to read response body>`}return Error(`Failed to resolve latest deployment for ${t}: HTTP ${e.status} ${e.statusText}${n?` — ${n}`:``}`)}})).json(),i=gc.safeParse(r);if(!i.success)throw Error(`Invalid response from Vercel API: expected { id: string }. Zod error: ${i.error.message}`);return i.data.id}}const vc={run_created:{retryable:!0,reason:`conditional create → 409 if exists`},step_created:{retryable:!0,reason:`conditional create → 409 if exists`},wait_created:{retryable:!0,reason:`conditional create → 409 if exists`},hook_created:{retryable:!0,reason:`transactional token uniqueness → 409 if exists`},run_started:{retryable:!0,reason:`early-returns if already running, no duplicate row`},run_completed:{retryable:!0,reason:`terminal-state guard → 409, no duplicate row`},run_failed:{retryable:!0,reason:`terminal-state guard → 409, no duplicate row`},run_cancelled:{retryable:!0,reason:`terminal-state guard → 409, no duplicate row`},step_completed:{retryable:!0,reason:`terminal-state guard → 409, no duplicate row`},step_failed:{retryable:!0,reason:`terminal-state guard → 409, no duplicate row`},wait_completed:{retryable:!0,reason:`waiting-state guard → 409, no duplicate row`},hook_disposed:{retryable:!0,reason:`conditional delete (exists) → 409, no duplicate row`},attr_set:{retryable:!0,reason:`correlationId constraint reuses eventId (idempotent replay)`},step_started:{retryable:!1,reason:`unconditional attempt increment → a retry double-counts attempts`},step_retrying:{retryable:!1,reason:`no duplicate guard → a retry appends a second event row`},hook_received:{retryable:!1,reason:`no server guard → a retry duplicates the row / re-delivers payload`},hook_conflict:{retryable:!1,reason:`server-originated; never POSTed by the SDK`}},yc=new Set([`ECONNRESET`,`ECONNREFUSED`,`ENOTFOUND`,`ENETDOWN`,`ENETUNREACH`,`EHOSTDOWN`,`EHOSTUNREACH`,`EPIPE`,`ETIMEDOUT`,`UND_ERR_SOCKET`,`UND_ERR_REQ_RETRY`,`UND_ERR_CONNECT_TIMEOUT`,`UND_ERR_HEADERS_TIMEOUT`,`UND_ERR_BODY_TIMEOUT`,`TimeoutError`,`RequestRetryError`]);function bc(e,t=0){if(t>5||typeof e!=`object`||!e)return[];let n=[],r=e;return typeof r.code==`string`&&n.push(r.code),typeof r.name==`string`&&n.push(r.name),r.cause&&n.push(...bc(r.cause,t+1)),n}function xc(e){if(s.is(e)||l.is(e)||i.is(e)||a.is(e))return!1;if(r.is(e)){if(e.code===`PARSE_ERROR`)return!0;if(typeof e.status==`number`)return e.status>=500&&e.status<=599}return bc(e).some(e=>yc.has(e))}const Sc=e=>new Promise(t=>setTimeout(t,e)),Cc=typeof process<`u`&&typeof process.env.DEBUG==`string`&&(process.env.DEBUG.includes(`workflow:`)||process.env.DEBUG===`*`);function wc(e,t){if(!Cc)return;let n=Object.entries(t).map(([e,t])=>`${e}=${t}`).join(` `);console.debug(`[workflow:world-vercel:event-retry] ${e} ${n}`)}function Tc(e){return r.is(e)?e.code??(e.status==null?e.name:`status_${e.status}`):bc(e)[0]??(e instanceof Error?e.name:`unknown`)}async function Ec(e,t){let n=vc[t]?.retryable??!1;for(let r=0;;r++)try{return await e()}catch(e){let i=n&&xc(e);if(i&&r<2){let n=100*2**r+Math.floor(Math.random()*50);wc(`retrying event POST after transient failure`,{eventType:t,attempt:r+1,backoffMs:n,error:Tc(e)}),await Sc(n);continue}throw i&&wc(`exhausted in-process retries; surfacing for queue redelivery`,{eventType:t,attempts:r+1,error:Tc(e)}),e}}const Dc=`application/vnd.workflow.v4-frames`;function Oc(e,t){let n=new Uint8Array(sn(e)),r=new Uint8Array(4+n.byteLength+4+t.byteLength),i=new DataView(r.buffer);return i.setUint32(0,n.byteLength,!1),r.set(n,4),i.setUint32(4+n.byteLength,t.byteLength,!1),r.set(t,4+n.byteLength+4),r}async function*kc(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():jc(e.getReader()),n=new Uint8Array,r=async e=>{for(;n.byteLength<e;){let{done:e,value:r}=await t.next();if(e)return!1;if(!r||r.byteLength===0)continue;let i=new Uint8Array(n.byteLength+r.byteLength);i.set(n,0),i.set(r,n.byteLength),n=i}return!0},i=e=>{let t=n.subarray(0,e);return n=n.subarray(e),t};try{for(;;){if(!await r(4))return;let e=new DataView(n.buffer,n.byteOffset,4).getUint32(0,!1);if(i(4),!await r(e))throw Error(`decodeFrames: truncated meta block`);let t=Pt(i(e));if(!await r(4))throw Error(`decodeFrames: truncated body length`);let a=new DataView(n.buffer,n.byteOffset,4).getUint32(0,!1);if(i(4),a>0&&!await r(a))throw Error(`decodeFrames: truncated body bytes`);if(yield{meta:t,body:n.slice(0,a)},i(a),t._end===1)return}}finally{Ac(()=>t.return?.())}}function Ac(e){try{Promise.resolve(e()).catch(()=>{})}catch{}}async function*jc(e){try{for(;;){let{done:t,value:n}=await e.read();if(t)return;n&&(yield n)}}finally{Ac(()=>e.cancel())}}async function Mc(e,t,n,r){return br({method:t.method,url:e,headers:t.headers,body:t.body,dispatcher:kn(n),timeoutMs:null,logLabel:r,buildError:async t=>Ic(t.status,Nc(t.headers),await t.text(),r,e)})}function Nc(e){let t={};return e.forEach((e,n)=>{t[n]=e}),t}const Pc={eventId:`x-wf-event-id`,runId:`x-wf-run-id`,createdAt:`x-wf-created-at`};function Fc(e){let t={eventType:e.eventType,specVersion:e.specVersion};return e.correlationId!==void 0&&(t.correlationId=e.correlationId),e.vercelId!==void 0&&(t.vercelId=e.vercelId),e.occurredAt!==void 0&&(t.occurredAt=e.occurredAt),e.remoteRefBehavior!==void 0&&(t.remoteRefBehavior=e.remoteRefBehavior),e.deploymentId!==void 0&&(t.deploymentId=e.deploymentId),e.workflowName!==void 0&&(t.workflowName=e.workflowName),e.stepName!==void 0&&(t.stepName=e.stepName),e.attempt!==void 0&&(t.attempt=e.attempt),e.resumeAt!==void 0&&(t.resumeAt=e.resumeAt),e.retryAfter!==void 0&&(t.retryAfter=e.retryAfter),e.hookToken!==void 0&&(t.hookToken=e.hookToken),e.hookIsWebhook!==void 0&&(t.hookIsWebhook=e.hookIsWebhook),e.hookIsSystem!==void 0&&(t.hookIsSystem=e.hookIsSystem),e.errorCode!==void 0&&(t.errorCode=e.errorCode),e.cancelReason!==void 0&&(t.cancelReason=e.cancelReason),e.ownerMessageId!==void 0&&(t.ownerMessageId=e.ownerMessageId),e.executionContext!==void 0&&(t.executionContext=e.executionContext),e.attributes!==void 0&&(t.attributes=e.attributes),e.changes!==void 0&&(t.changes=e.changes),e.writer!==void 0&&(t.writer=e.writer),e.allowReservedAttributes!==void 0&&(t.allowReservedAttributes=e.allowReservedAttributes),e.ttfs!==void 0&&(t.ttfs=e.ttfs),e.stso!==void 0&&(t.stso=e.stso),e.stepCount!==void 0&&(t.stepCount=e.stepCount),e.eventCount!==void 0&&(t.eventCount=e.eventCount),e.rsfs!==void 0&&(t.rsfs=e.rsfs),e.finalSchedulingReplay!==void 0&&(t.finalSchedulingReplay=e.finalSchedulingReplay),e.optimizations!==void 0&&(t.optimizations=e.optimizations),e.sinceCursor!==void 0&&(t.sinceCursor=e.sinceCursor),e.skipPreload!==void 0&&(t.skipPreload=e.skipPreload),e.stateUpdatedAt!==void 0&&(t.stateUpdatedAt=e.stateUpdatedAt),t}function Ic(e,t,n,r,i){let a=`v4 ${r} failed: HTTP ${e}`,o;try{let e=JSON.parse(n);typeof e.message==`string`&&(a=e.message),typeof e.code==`string`&&(o=e.code)}catch{n&&(a+=` ${n}`)}let s=mr(Rc(t,`retry-after`));return hr(e,a,{retryAfter:s,code:o,url:i,mitigated:Rc(t,`x-vercel-mitigated`)})}async function Lc(e,t){let{baseUrl:n,headers:r}=await jr(t),i=new Headers(r);i.set(`Content-Type`,`application/octet-stream`);let a=Oc(Fc(e),e.payload??new Uint8Array),o=await Mc(`${n}/v4/runs/${encodeURIComponent(e.runId)}/events/${encodeURIComponent(e.eventType)}`,{method:`POST`,headers:i,body:a},t,`createEvent`),s=o.headers.get(Pc.eventId),c=o.headers.get(Pc.runId),l=o.headers.get(Pc.createdAt);if(typeof s!=`string`||typeof c!=`string`||typeof l!=`string`)throw Error(`v4 createEvent: response missing required x-wf-* headers`);let u=new Uint8Array(await o.arrayBuffer());return{eventId:s,runId:c,createdAt:l,body:u.byteLength>0?Pt(u):{}}}function Rc(e,t){let n=e[t];if(typeof n==`string`)return n;if(Array.isArray(n)&&n.length>0)return n[0]}async function zc(e,t,n){let{baseUrl:r,headers:i}=await jr(n),a=await Mc(`${r}/v4/runs/${encodeURIComponent(e)}/events/${encodeURIComponent(t)}`,{method:`GET`,headers:i},n,`getEvent`),o=a.headers.get(`content-type`);if(!o?.startsWith(`application/vnd.workflow.v4-frames`))throw Error(`v4 getEvent: expected ${Dc}, got ${o??`(none)`}`);let s=a.body;for await(let e of kc(s))return{event:e.meta,body:e.body};throw Error(`v4 getEvent: empty frame stream for ${t}`)}async function Bc(e,t,n,r){let i=await Mc(e,{method:`GET`,headers:t},n,r),a=i.headers.get(`content-type`);if(!a?.startsWith(`application/vnd.workflow.v4-frames`))throw Error(`v4 ${r}: expected ${Dc}, got ${a??`(none)`}`);let o=i.body,s=[],c,l,u=!1;for await(let e of kc(o)){if(e.meta._end===1){typeof e.meta.next==`string`&&(c=e.meta.next),typeof e.meta.hasMore==`boolean`&&(l=e.meta.hasMore),u=!0;break}s.push({event:e.meta,body:e.body})}if(!u)throw Error(`v4 ${r}: frame stream ended without the end-of-stream sentinel (${s.length} events read) — truncated response?`);return{events:s,...c?{next:c}:{},...l===void 0?{}:{hasMore:l}}}function Vc(e,t){t.cursor&&e.set(`cursor`,t.cursor),t.limit!==void 0&&e.set(`limit`,String(t.limit)),t.sortOrder&&e.set(`sortOrder`,t.sortOrder),t.remoteRefBehavior&&e.set(`remoteRefBehavior`,t.remoteRefBehavior)}function Hc(e){let t=new URLSearchParams;Vc(t,e);let n=t.toString();return n?`?${n}`:``}async function Uc(e,t={},n){let{baseUrl:r,headers:i}=await jr(n);return Bc(`${r}/v4/runs/${encodeURIComponent(e)}/events`+Hc(t),i,n,`listEvents`)}async function Wc(e,t={},n){let{baseUrl:r,headers:i}=await jr(n),a=new URLSearchParams;return a.set(`correlationId`,e),Vc(a,t),Bc(`${r}/v4/events?${a.toString()}`,i,n,`listEventsByCorrelationId`)}const Gc=`zstd`,Kc=new TextDecoder;function qc(){try{return globalThis.process?.getBuiltinModule?.(`node:zlib`)}catch{return}}function Jc(e){return!(e instanceof Uint8Array)||e.byteLength<4?null:Kc.decode(e.subarray(0,4))}function Yc(e,t){let n=qc(),i=e===Gc?n?.zstdDecompressSync:n?.gunzipSync;if(!i)throw new r(`Received ${e}-compressed workflow data, but this Node.js runtime does not support ${e} decompression. Use a compatible Node.js runtime or request unresolved data.`);return new Uint8Array(i(t))}function Xc(e){let t=Jc(e);return t!==Gc&&t!==`gzip`?e:Yc(t,e.subarray(4))}function Zc(e){return{...e,input:Xc(e.input),output:Xc(e.output),error:Xc(e.error)}}function Qc(e){return{...e,input:Xc(e.input),output:Xc(e.output),error:Xc(e.error)}}function $c(e){return{...e,metadata:Xc(e.metadata)}}function el(e){let t=e.eventData;if(!t||typeof t!=`object`)return e;let n=g(typeof e.eventType==`string`?e.eventType:``);if(n.length===0)return e;let r={...t},i=!1;for(let e of n){if(!(e in r))continue;let t=r[e],n=Xc(t);n!==t&&(r[e]=n,i=!0)}return i?{...e,eventData:r}:e}const tl=f.omit({error:!0,errorCode:!0}).extend({error:ce([T,d()]).optional(),errorCode:E().optional(),blobStorageBytes:oe().optional(),streamStorageBytes:oe().optional()}),nl=tl,rl=tl.omit({input:!0,output:!0}).extend({inputRef:d().optional(),outputRef:d().optional(),input:ce([b(Uint8Array),d()]).optional(),output:ce([b(Uint8Array),d()]).optional()});function il(e,t){if(t===`none`){let{inputRef:t,outputRef:n,...r}=e;return{...Zc(Dr(r)),input:void 0,output:void 0}}return Zc(Dr(e))}async function al(e={},t){let{workflowName:n,status:r,pagination:i,resolveData:a=`all`}=e,o=new URLSearchParams;n&&o.set(`workflowName`,n),r&&o.set(`status`,r),i?.limit&&o.set(`limit`,i.limit.toString()),i?.cursor&&o.set(`cursor`,i.cursor),i?.sortOrder&&o.set(`sortOrder`,i.sortOrder);let s=a===`none`?`lazy`:`resolve`;o.set(`remoteRefBehavior`,s);let c=o.toString(),l=await K({endpoint:`/v2/runs${c?`?${c}`:``}`,options:{method:`GET`},config:t,schema:D(s===`lazy`?rl:nl)});return{...l,data:l.data.map(e=>il(e,a))}}async function ol(e,t){return Dr(await K({endpoint:`/v1/runs/create`,options:{method:`POST`},data:e,config:t,schema:nl}))}async function sl(e,t,n){let i=t?.resolveData??`all`,a=i===`none`?`lazy`:`resolve`,o=new URLSearchParams;o.set(`remoteRefBehavior`,a);let s=o.toString(),c=`/v2/runs/${encodeURIComponent(e)}${s?`?${s}`:``}`;try{return il(await K({endpoint:c,options:{method:`GET`},config:n,schema:a===`lazy`?rl:nl}),i)}catch(t){throw t instanceof r&&t.status===404?new u(e):t}}async function cl(e,t,n){let i=t?.resolveData??`all`,a=i===`none`?`lazy`:`resolve`,o=new URLSearchParams;o.set(`remoteRefBehavior`,a);let s=o.toString(),c=`/v1/runs/${encodeURIComponent(e)}/cancel${s?`?${s}`:``}`;try{return il(await K({endpoint:c,options:{method:`PUT`},config:n,schema:a===`lazy`?rl:nl}),i)}catch(t){throw t instanceof r&&t.status===404?new u(e):t}}const ll=de({attributes:ie(E(),E())});async function ul(e,t,n,i){try{return{attributes:(await K({endpoint:`/v2/runs/${encodeURIComponent(e)}/attributes`,options:{method:`POST`},data:n?.allowReservedAttributes?{changes:t,allowReservedAttributes:!0}:{changes:t},config:i,schema:ll})).attributes}}catch(t){throw t instanceof r&&t.status===404?new u(e):t}}const dl=v.omit({error:!0}).extend({error:ce([T,d()]).optional(),errorRef:d().optional()}),fl=dl.omit({input:!0,output:!0}).extend({inputRef:d().optional(),outputRef:d().optional(),input:b(Uint8Array).optional(),output:b(Uint8Array).optional()});function pl(e){let{error:t,errorRef:n,...r}=e,i={...r},a=t??n;return a!=null&&(i.error=a),i}function ml(e,t){if(t===`none`){let{inputRef:t,outputRef:n,...r}=e;return{...Qc(pl(r)),input:void 0,output:void 0}}return Qc(pl(e))}async function hl(e,t){let{runId:n,pagination:r,resolveData:i=`all`}=e,a=new URLSearchParams;r?.cursor&&a.set(`cursor`,r.cursor),r?.limit&&a.set(`limit`,r.limit.toString()),r?.sortOrder&&a.set(`sortOrder`,r.sortOrder);let o=i===`none`?`lazy`:`resolve`;a.set(`remoteRefBehavior`,o);let s=a.toString(),c=await K({endpoint:`/v2/runs/${encodeURIComponent(n)}/steps${s?`?${s}`:``}`,options:{method:`GET`},config:t,schema:D(o===`lazy`?fl:dl)});return{...c,data:c.data.map(e=>ml(e,i))}}async function gl(e,t,n,r){let i=n?.resolveData??`all`,a=i===`none`?`lazy`:`resolve`,o=new URLSearchParams;o.set(`remoteRefBehavior`,a);let s=o.toString();return ml(await K({endpoint:`/v2/runs/${encodeURIComponent(e)}/steps/${encodeURIComponent(t)}${s?`?${s}`:``}`,options:{method:`GET`},config:r,schema:a===`lazy`?fl:dl}),i)}function _l(e){let t=e.startsWith(`wrun_`)?e.slice(5):e;try{return ue(`wrun_${Se(t).ulid}`,`wrun_`)}catch{return ue(e,`wrun_`)}}const vl=new Set([`run_created`,`run_started`,`step_started`]);function yl(e){let t=e.eventData??{},n=h(e.eventType),r={};if(typeof t.deploymentId==`string`&&(r.deploymentId=t.deploymentId),typeof t.workflowName==`string`&&(r.workflowName=t.workflowName),typeof t.stepName==`string`&&(r.stepName=t.stepName),typeof t.attempt==`number`&&(r.attempt=t.attempt),t.resumeAt instanceof Date)r.resumeAt=t.resumeAt;else if(typeof t.resumeAt==`string`){let e=new Date(t.resumeAt);Number.isNaN(e.getTime())||(r.resumeAt=e)}if(t.retryAfter instanceof Date)r.retryAfter=t.retryAfter;else if(typeof t.retryAfter==`string`){let e=new Date(t.retryAfter);Number.isNaN(e.getTime())||(r.retryAfter=e)}typeof t.token==`string`&&(r.hookToken=t.token),typeof t.isWebhook==`boolean`&&(r.hookIsWebhook=t.isWebhook),typeof t.isSystem==`boolean`&&(r.hookIsSystem=t.isSystem),typeof t.errorCode==`string`&&(r.errorCode=t.errorCode),typeof t.cancelReason==`string`&&(r.cancelReason=t.cancelReason),typeof t.ownerMessageId==`string`&&(r.ownerMessageId=t.ownerMessageId),t.executionContext!==void 0&&t.executionContext!==null&&typeof t.executionContext==`object`&&(r.executionContext=t.executionContext),t.attributes!==void 0&&t.attributes!==null&&typeof t.attributes==`object`&&(r.attributes=t.attributes),Array.isArray(t.changes)&&(r.changes=t.changes),t.writer!==void 0&&t.writer!==null&&typeof t.writer==`object`&&(r.writer=t.writer),typeof t.allowReservedAttributes==`boolean`&&(r.allowReservedAttributes=t.allowReservedAttributes),typeof t.ttfs==`number`&&(r.ttfs=t.ttfs),typeof t.stso==`number`&&(r.stso=t.stso),typeof t.stepCount==`number`&&Number.isSafeInteger(t.stepCount)&&t.stepCount>0&&(r.stepCount=t.stepCount),typeof t.eventCount==`number`&&Number.isSafeInteger(t.eventCount)&&t.eventCount>0&&(r.eventCount=t.eventCount),typeof t.rsfs==`number`&&(r.rsfs=t.rsfs),typeof t.finalSchedulingReplay==`number`&&(r.finalSchedulingReplay=t.finalSchedulingReplay),Array.isArray(t.optimizations)&&t.optimizations.every(e=>typeof e==`string`)&&(r.optimizations=t.optimizations);let i;if(n&&n in t){let r=t[n];if(r!==void 0){if(!(r instanceof Uint8Array))throw TypeError(`world-vercel v4: eventData.${n} for ${e.eventType} must be a Uint8Array (the runtime's dehydrated wire form); got ${typeof r==`object`?r===null?`null`:r.constructor?.name??typeof r:typeof r}.`);i=r}}return{payload:i,meta:r}}function bl(e){let t=_.safeParse(e);return t.success?t.data:(y.safeParse(e.eventType).success&&console.debug(`[workflow:world-vercel] v4 event ${e.eventId} failed EventSchema parse for known eventType '${e.eventType}'; passing through unparsed: ${t.error.message}`),e)}function xl(e){return bl(el(e))}function Sl(e,t,n){let r=e.eventData??{};if(t.byteLength>0){let n=h(e.eventType),i=Xc(t);n&&i instanceof Uint8Array&&(r[n]=i)}let i=xl({eventId:e.eventId,runId:e.runId,eventType:e.eventType,createdAt:e.createdAt instanceof Date?e.createdAt:new Date(e.createdAt),...e.occurredAt===void 0?{}:{occurredAt:e.occurredAt instanceof Date?e.occurredAt:new Date(e.occurredAt)},...e.correlationId?{correlationId:e.correlationId}:{},eventData:r,...e.specVersion===void 0?{}:{specVersion:e.specVersion}});return n===`none`?w(i,`none`):i}async function Cl(e,t,n,r){let i=n?.resolveData??`all`,{event:a,body:o}=await zc(e,t,r);return Sl(a,o,i)}async function wl(e,t){let{pagination:n,resolveData:r=`all`}=e,i={cursor:n?.cursor??void 0,limit:n?.limit,sortOrder:n?.sortOrder,remoteRefBehavior:r===`none`?`lazy`:`resolve`},a=await(`correlationId`in e?Wc(e.correlationId,i,t):Uc(e.runId,i,t));return{data:a.events.map(e=>Sl(e.event,e.body,r)),cursor:a.next??null,hasMore:typeof a.hasMore==`boolean`?a.hasMore:!!a.next}}async function Tl(e,t,n,i){try{return await Ec(()=>El(e,t,n,i),t.eventType)}catch(e){throw x(t.eventType)&&r.is(e)&&e.status===404&&t.correlationId?new o(t.correlationId):e}}async function El(e,t,n,i){if(n?.v1Compat){if(t.eventType===`run_cancelled`&&e)return{run:await cl(e,n,i)};if(t.eventType===`run_created`)return{run:await ol(t.eventData,i)};if(e===null)throw new r(`world-vercel: v1Compat=true requires a runId for ${t.eventType}`,{status:400});return{event:await K({endpoint:`/v1/runs/${encodeURIComponent(e)}/events`,options:{method:`POST`},data:t,config:i,schema:_})}}if(e===null)throw new r(`world-vercel v4: createWorkflowRunEvent requires a client-generated runId for run_created (the runId is part of the payload storage ref key). Generate a wrun_ ULID before calling.`,{status:400});if(t.eventType===`run_created`){let t=_l(e);if(t)throw new r(t,{status:400})}let a=vl.has(t.eventType)?`resolve`:`lazy`,{payload:o,meta:s}=yl(t),c=await Lc({runId:e,eventType:t.eventType,specVersion:t.specVersion??2,...t.correlationId?{correlationId:t.correlationId}:{},...n?.requestId?{vercelId:n.requestId}:{},...n?.stateUpdatedAt===void 0?{}:{stateUpdatedAt:n.stateUpdatedAt},occurredAt:n?.occurredAt??new Date,...n?.sinceCursor?{sinceCursor:n.sinceCursor}:{},...n?.skipPreload?{skipPreload:!0}:{},remoteRefBehavior:a,payload:o,...s},i),l=n?.resolveData??`all`,u=c.body;return{event:u.event?w(bl(u.event),l):void 0,run:u.run?Dr(u.run):void 0,step:u.step?pl(u.step):void 0,hook:u.hook,wait:u.wait,events:u.events?u.events.map(bl):void 0,cursor:u.cursor??void 0,hasMore:u.hasMore,...u.stepCreated?{stepCreated:!0}:{}}}function Dl(e,t){if(t===`none`){let{metadataRef:t,...n}=e;return n}return $c(e)}const Ol=he.omit({metadata:!0}).extend({metadataRef:ee.any().optional()});async function kl(e,t){let{runId:n,pagination:r,resolveData:i=`all`}=e,a=new URLSearchParams;r?.limit&&a.set(`limit`,r.limit.toString()),r?.cursor&&a.set(`cursor`,r.cursor),r?.sortOrder&&a.set(`sortOrder`,r.sortOrder);let o=i===`none`?`lazy`:`resolve`;a.set(`remoteRefBehavior`,o),n&&a.set(`runId`,n);let s=a.toString(),c=await K({endpoint:`/v2/hooks${s?`?${s}`:``}`,options:{method:`GET`},config:t,schema:D(o===`lazy`?Ol:he)});return{...c,data:c.data.map(e=>Dl(e,i))}}async function Al(e,t,n){let r=t?.resolveData||`all`;return Dl(await K({endpoint:`/v2/hooks/${encodeURIComponent(e)}`,options:{method:`GET`},config:n,schema:he}),r)}async function jl(e,t){try{return await K({endpoint:`/v2/hooks/by-token?token=${encodeURIComponent(e)}`,options:{method:`GET`},config:t,schema:he})}catch(t){throw r.is(t)&&t.status===404?new o(e):t}}function Ml(e){let t={runs:{get:((t,n)=>sl(t,n,e)),list:(t=>al(t,e)),experimentalSetAttributes:(t,n,r)=>ul(t,n,r,e)},steps:{get:((t,n,r)=>gl(t,n,r,e)),list:(t=>hl(t,e))},events:{create:(t,n,r)=>Tl(t,n,r,e),get:(t,n,r)=>Cl(t,n,r,e),list:t=>wl(t,e),listByCorrelationId:t=>wl(t,e)},hooks:{get:(t,n)=>Al(t,n,e),getByToken:t=>jl(t,e),list:t=>kl(t,e)}};return{runs:ri(`world.runs`,t.runs),steps:ri(`world.steps`,t.steps),events:ri(`world.events`,t.events),hooks:ri(`world.hooks`,t.hooks)}}const Nl=()=>te(`WORKFLOW_MAX_CHUNKS_PER_REQUEST`,1e3,{integer:!0,min:1});function Pl(e,t,n){return new URL(`${n.baseUrl}/v2/runs/${encodeURIComponent(t)}/stream/${encodeURIComponent(e)}`)}function Fl(e,t,n){return new URL(`${n.baseUrl}/v3/runs/${encodeURIComponent(t)}/stream/${encodeURIComponent(e)}`)}function Il(e){return{...nr(e.runId),...ir(e.name),...ar(e.operation),...typeof e.startIndex==`number`?or(e.startIndex):{}}}function Ll(e,t,n,r){let i=[`PUT ${t.origin}${t.pathname}`,...ur(n.headers)];return Error(`Stream ${e} failed: HTTP ${n.status} (${i.join(`; `)}): ${r}`)}function Rl(e){let t=new TextEncoder,n=[],r=0;for(let i of e){let e=typeof i==`string`?t.encode(i):i;n.push(e),r+=4+e.length}let i=new Uint8Array(r),a=new DataView(i.buffer),o=0;for(let e of n)a.setUint32(o,e.length,!1),o+=4,i.set(e,o),o+=e.length;return i}const zl=de({tailIndex:oe(),done:fe()}),Bl=de({data:ne(de({index:oe(),data:b(Uint8Array)})),cursor:E().nullable(),hasMore:fe(),done:fe()});function Vl(e){return{streams:{async write(t,n,r){let i=await t,a=await jr(e),o=Pl(n,i,a);await(await br({method:`PUT`,url:o.toString(),body:r,headers:a.headers,dispatcher:An(e),timeoutMs:null,logLabel:o.pathname,spanName:`workflow.stream.write`,durationAttribute:`workflow.stream.write.chunk_rtt`,attributes:Il({runId:i,name:n,operation:`write`}),buildError:async e=>Ll(`write`,o,e,await e.text())})).text()},async writeMulti(t,n,r){if(r.length===0)return;let i=await t,a=await jr(e);a.headers.set(`X-Stream-Multi`,`true`);let o=Nl();for(let t=0;t<r.length;t+=o){let s=Rl(r.slice(t,t+o)),c=Pl(n,i,a);await(await br({method:`PUT`,url:c.toString(),body:s,headers:a.headers,dispatcher:An(e),timeoutMs:null,logLabel:c.pathname,spanName:`workflow.stream.write`,durationAttribute:`workflow.stream.write.chunk_rtt`,attributes:Il({runId:i,name:n,operation:`write_multi`}),buildError:async e=>Ll(`write`,c,e,await e.text())})).text()}},async close(t,n){let r=await t,i=await jr(e);i.headers.set(`X-Stream-Done`,`true`);let a=Pl(n,r,i);await(await br({method:`PUT`,url:a.toString(),headers:i.headers,dispatcher:An(e),timeoutMs:null,logLabel:a.pathname,spanName:`workflow.stream.write`,durationAttribute:`workflow.stream.write.chunk_rtt`,attributes:Il({runId:r,name:n,operation:`close`}),buildError:async e=>Ll(`close`,a,e,await e.text())})).text()},async get(t,n,r){let i=await jr(e),a=Fl(n,t,i);typeof r==`number`&&a.searchParams.set(`startIndex`,String(r));let o=await br({method:`GET`,url:a.toString(),headers:i.headers,dispatcher:void 0,timeoutMs:null,logLabel:a.pathname,spanName:`workflow.stream.read.connect`,attributes:Il({runId:t,name:n,operation:`read`,startIndex:r}),buildError:e=>Error(`Failed to fetch stream: ${e.status}`)});if(!o.body)throw Error(`No response body for stream`);return o.body},async getChunks(t,n,r){let i=new URLSearchParams;r?.limit!=null&&i.set(`limit`,String(r.limit)),r?.cursor&&i.set(`cursor`,r.cursor);let a=i.toString();return K({endpoint:`/v2/runs/${encodeURIComponent(t)}/streams/${encodeURIComponent(n)}/chunks${a?`?${a}`:``}`,config:e,schema:Bl})},async getInfo(t,n){return K({endpoint:`/v2/runs/${encodeURIComponent(t)}/streams/${encodeURIComponent(n)}/info`,config:e,schema:zl})},async list(t){let n=await jr(e),r=new URL(`${n.baseUrl}/v2/runs/${encodeURIComponent(t)}/streams`);return await(await br({method:`GET`,url:r.toString(),headers:n.headers,dispatcher:void 0,timeoutMs:null,logLabel:r.pathname,buildError:e=>Error(`Failed to list streams: ${e.status}`)})).json()}}}}function Hl(e){let t=e?.projectConfig?.projectId||process.env.VERCEL_PROJECT_ID;return{specVersion:5,processExitTriggersQueueRedelivery:!0,...hc(e),...Ml(e),analytics:Lr(e),...ri(`world.streams`,Vl(e)),createRunId:Ur,describeRun:Gr,getEncryptionKeyForRun:Jr(t,e?.projectConfig?.teamId,e?.token,e?.dispatcher),resolveLatestDeploymentId:_c(e)}}function Ul(e){return Hl(e)}export{Lr as createAnalytics,Jr as createGetEncryptionKeyForRun,hc as createQueue,Ur as createRunId,Ml as createStorage,Vl as createStreamer,Ul as createVercelWorld,Hl as createWorld,Kr as deriveRunKey,Gr as describeRun,qr as fetchRunKey,Ne as i,La as n,ze as r,Wr as regionForRunId,Ua as t};
|