eve 0.23.0 → 0.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/src/channel/types.d.ts +1 -1
  3. package/dist/src/cli/run.d.ts +2 -2
  4. package/dist/src/cli/run.js +1 -1
  5. package/dist/src/compiled/.vendor-stamp.json +11 -11
  6. package/dist/src/compiled/@ai-sdk/anthropic/index.d.ts +1 -1
  7. package/dist/src/compiled/@ai-sdk/anthropic/index.js +2 -2
  8. package/dist/src/compiled/@ai-sdk/google/index.d.ts +7 -0
  9. package/dist/src/compiled/@ai-sdk/google/index.js +6 -6
  10. package/dist/src/compiled/@ai-sdk/mcp/index.d.ts +42 -1
  11. package/dist/src/compiled/@ai-sdk/mcp/index.js +1 -1
  12. package/dist/src/compiled/@ai-sdk/openai/index.d.ts +34 -6
  13. package/dist/src/compiled/@ai-sdk/openai/index.js +2 -2
  14. package/dist/src/compiled/@ai-sdk/otel/index.js +1 -1
  15. package/dist/src/compiled/@ai-sdk/provider/index.d.ts +245 -3
  16. package/dist/src/compiled/@ai-sdk/provider-utils/index.d.ts +273 -15
  17. package/dist/src/compiled/@workflow/core/index.js +1 -1
  18. package/dist/src/compiled/@workflow/core/runtime/start.d.ts +12 -0
  19. package/dist/src/compiled/@workflow/core/runtime.js +1 -1
  20. package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
  21. package/dist/src/compiled/@workflow/core/workflow.js +1 -1
  22. package/dist/src/compiled/@workflow/world/analytics.d.ts +56 -21
  23. package/dist/src/compiled/@workflow/world/index.d.ts +1 -1
  24. package/dist/src/compiled/@workflow/world/interfaces.d.ts +46 -0
  25. package/dist/src/compiled/@workflow/world/queue.d.ts +12 -0
  26. package/dist/src/compiled/@workflow/world-local/index.js +3 -3
  27. package/dist/src/compiled/@workflow/world-vercel/index.js +16 -16
  28. package/dist/src/compiled/_chunks/workflow/attribute-changes-MGTOG_uX.js +20 -0
  29. package/dist/src/compiled/_chunks/workflow/{dist-CQenixFf.js → dist-Blxnyb7-.js} +2 -2
  30. package/dist/src/compiled/_chunks/workflow/dist-zLevmMyU.js +77 -0
  31. package/dist/src/compiled/_chunks/workflow/{resume-hook-BH01MfRF.js → resume-hook-DHP5ql3-.js} +1 -1
  32. package/dist/src/compiled/_chunks/workflow/run-D8hv1ptT.js +1 -0
  33. package/dist/src/compiled/_chunks/workflow/{sleep-BkAHCD_s.js → sleep-uA9pS-PT.js} +1 -1
  34. package/dist/src/compiler/artifacts.d.ts +7 -6
  35. package/dist/src/compiler/artifacts.js +1 -1
  36. package/dist/src/compiler/compile-agent.d.ts +15 -2
  37. package/dist/src/compiler/compile-agent.js +3 -3
  38. package/dist/src/compiler/manifest.d.ts +12 -6
  39. package/dist/src/compiler/manifest.js +1 -1
  40. package/dist/src/compiler/normalize-agent-config.js +1 -1
  41. package/dist/src/compiler/normalize-extension.js +1 -1
  42. package/dist/src/compiler/normalize-manifest.js +2 -2
  43. package/dist/src/compiler/normalize-tool.d.ts +2 -1
  44. package/dist/src/compiler/normalize-tool.js +1 -1
  45. package/dist/src/context/build-base-tool-context.d.ts +5 -1
  46. package/dist/src/context/build-base-tool-context.js +1 -1
  47. package/dist/src/context/build-dynamic-tools.js +1 -1
  48. package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
  49. package/dist/src/execution/create-session-step.js +1 -1
  50. package/dist/src/execution/node-step.d.ts +2 -3
  51. package/dist/src/execution/node-step.js +1 -1
  52. package/dist/src/execution/run-session-limits.d.ts +0 -9
  53. package/dist/src/execution/run-session-limits.js +1 -1
  54. package/dist/src/execution/sandbox/prewarm.d.ts +1 -0
  55. package/dist/src/execution/sandbox/prewarm.js +1 -1
  56. package/dist/src/execution/subagent-tool.js +1 -1
  57. package/dist/src/execution/tool-auth.js +1 -1
  58. package/dist/src/harness/instrumentation-runtime-context.d.ts +1 -1
  59. package/dist/src/harness/tool-loop.js +3 -1
  60. package/dist/src/harness/types.d.ts +5 -7
  61. package/dist/src/harness/workflow-subagent-limit.d.ts +2 -2
  62. package/dist/src/internal/application/build-workspace.d.ts +36 -0
  63. package/dist/src/internal/application/build-workspace.js +1 -0
  64. package/dist/src/internal/application/compiled-artifacts.d.ts +12 -1
  65. package/dist/src/internal/application/compiled-artifacts.js +5 -4
  66. package/dist/src/internal/application/output-publication-artifacts.d.ts +7 -0
  67. package/dist/src/internal/application/output-publication-artifacts.js +1 -0
  68. package/dist/src/internal/application/output-publication-journal.d.ts +30 -0
  69. package/dist/src/internal/application/output-publication-journal.js +1 -0
  70. package/dist/src/internal/application/output-publication-lock.d.ts +10 -0
  71. package/dist/src/internal/application/output-publication-lock.js +1 -0
  72. package/dist/src/internal/application/output-publication.d.ts +33 -0
  73. package/dist/src/internal/application/output-publication.js +1 -0
  74. package/dist/src/internal/application/package.js +1 -1
  75. package/dist/src/internal/application/production-compiler-artifacts.d.ts +4 -0
  76. package/dist/src/internal/application/production-compiler-artifacts.js +1 -0
  77. package/dist/src/internal/application/tsconfig-dependencies.js +1 -1
  78. package/dist/src/internal/authored-definition/core.js +1 -1
  79. package/dist/src/internal/authored-definition/schema-backed.d.ts +3 -2
  80. package/dist/src/internal/authored-definition/schema-backed.js +1 -1
  81. package/dist/src/internal/authored-directive-prologue.d.ts +4 -0
  82. package/dist/src/internal/authored-directive-prologue.js +1 -0
  83. package/dist/src/internal/authored-module-loader.d.ts +15 -5
  84. package/dist/src/internal/authored-module-loader.js +4 -2
  85. package/dist/src/internal/authored-module-map-loader.js +1 -1
  86. package/dist/src/internal/authored-module.d.ts +4 -0
  87. package/dist/src/internal/authored-module.js +1 -1
  88. package/dist/src/internal/authored-package-boundary.d.ts +25 -0
  89. package/dist/src/internal/authored-package-boundary.js +1 -0
  90. package/dist/src/internal/authored-package-tsconfig-paths.js +1 -1
  91. package/dist/src/internal/bundler/nitro-node-file-trace.d.ts +10 -0
  92. package/dist/src/internal/bundler/nitro-node-file-trace.js +1 -0
  93. package/dist/src/internal/materialize-authored-external-dependencies.d.ts +10 -0
  94. package/dist/src/internal/materialize-authored-external-dependencies.js +2 -0
  95. package/dist/src/internal/materialized-authored-modules.d.ts +15 -0
  96. package/dist/src/internal/materialized-authored-modules.js +1 -0
  97. package/dist/src/internal/nitro/dev-runtime-artifacts.d.ts +1 -9
  98. package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
  99. package/dist/src/internal/nitro/development-generation.d.ts +12 -0
  100. package/dist/src/internal/nitro/development-generation.js +1 -0
  101. package/dist/src/internal/nitro/host/artifacts-config.d.ts +9 -11
  102. package/dist/src/internal/nitro/host/artifacts-config.js +1 -1
  103. package/dist/src/internal/nitro/host/build-application.d.ts +2 -1
  104. package/dist/src/internal/nitro/host/build-application.js +1 -1
  105. package/dist/src/internal/nitro/host/build-vercel-agent-summary.d.ts +1 -7
  106. package/dist/src/internal/nitro/host/build-vercel-agent-summary.js +1 -1
  107. package/dist/src/internal/nitro/host/channel-routes.d.ts +3 -3
  108. package/dist/src/internal/nitro/host/configure-nitro-routes.d.ts +9 -5
  109. package/dist/src/internal/nitro/host/configure-nitro-routes.js +3 -3
  110. package/dist/src/internal/nitro/host/create-application-nitro.d.ts +18 -10
  111. package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
  112. package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
  113. package/dist/src/internal/nitro/host/dispatch-schedule-in-dev.d.ts +6 -1
  114. package/dist/src/internal/nitro/host/dispatch-schedule-in-dev.js +1 -1
  115. package/dist/src/internal/nitro/host/prepare-application-host.d.ts +13 -5
  116. package/dist/src/internal/nitro/host/prepare-application-host.js +1 -1
  117. package/dist/src/internal/nitro/host/schedule-task-routes.d.ts +3 -3
  118. package/dist/src/internal/nitro/host/start-development-server.js +2 -2
  119. package/dist/src/internal/nitro/host/types.d.ts +4 -0
  120. package/dist/src/internal/nitro/host/vercel-build-prewarm.d.ts +2 -9
  121. package/dist/src/internal/nitro/host/vercel-build-prewarm.js +1 -1
  122. package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response-from-manifest.js +1 -1
  123. package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.js +1 -1
  124. package/dist/src/internal/nitro/routes/agent-info/load-agent-info-data.d.ts +3 -6
  125. package/dist/src/internal/nitro/routes/agent-info/load-agent-info-data.js +1 -1
  126. package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
  127. package/dist/src/internal/nitro/routes/dev-schedule-dispatch.d.ts +2 -3
  128. package/dist/src/internal/nitro/routes/dev-schedule-dispatch.js +1 -1
  129. package/dist/src/internal/nitro/routes/info.d.ts +1 -6
  130. package/dist/src/internal/nitro/routes/info.js +1 -1
  131. package/dist/src/internal/nitro/routes/runtime-artifacts.d.ts +9 -5
  132. package/dist/src/internal/nitro/routes/runtime-artifacts.js +1 -1
  133. package/dist/src/internal/workflow-bundle/build-queue.d.ts +1 -0
  134. package/dist/src/internal/workflow-bundle/build-queue.js +1 -0
  135. package/dist/src/internal/workflow-bundle/builder-support.d.ts +0 -1
  136. package/dist/src/internal/workflow-bundle/builder-support.js +2 -2
  137. package/dist/src/internal/workflow-bundle/builder.js +2 -2
  138. package/dist/src/internal/workflow-bundle/nitro-step-entry.d.ts +1 -0
  139. package/dist/src/internal/workflow-bundle/nitro-step-entry.js +2 -2
  140. package/dist/src/public/channels/teams/api.d.ts +8 -0
  141. package/dist/src/public/channels/teams/api.js +2 -2
  142. package/dist/src/public/channels/teams/defaults.d.ts +2 -2
  143. package/dist/src/public/channels/teams/defaults.js +1 -1
  144. package/dist/src/public/channels/teams/hitl.d.ts +4 -0
  145. package/dist/src/public/channels/teams/hitl.js +1 -1
  146. package/dist/src/public/channels/teams/index.d.ts +1 -1
  147. package/dist/src/public/channels/teams/teamsChannel.d.ts +6 -0
  148. package/dist/src/public/channels/teams/teamsChannel.js +1 -1
  149. package/dist/src/public/definitions/tool.d.ts +40 -24
  150. package/dist/src/public/definitions/tool.js +1 -1
  151. package/dist/src/public/instrumentation/index.d.ts +3 -3
  152. package/dist/src/public/tools/index.d.ts +1 -1
  153. package/dist/src/public/tools/index.js +1 -1
  154. package/dist/src/runtime/resolve-agent.js +1 -1
  155. package/dist/src/runtime/types.d.ts +6 -6
  156. package/dist/src/setup/scaffold/create/add-to-project.js +1 -1
  157. package/dist/src/setup/scaffold/create/project.js +2 -2
  158. package/dist/src/setup/scaffold/update/channels.js +1 -1
  159. package/dist/src/shared/agent-definition.d.ts +0 -16
  160. package/dist/src/shared/atomic-write-file.d.ts +11 -0
  161. package/dist/src/shared/atomic-write-file.js +1 -0
  162. package/dist/src/shared/dynamic-tool-definition.d.ts +2 -0
  163. package/dist/src/shared/guards.d.ts +7 -0
  164. package/dist/src/shared/guards.js +1 -1
  165. package/dist/src/shared/path-exists.d.ts +9 -0
  166. package/dist/src/shared/path-exists.js +1 -0
  167. package/docs/agent-config.md +8 -8
  168. package/docs/channels/teams.mdx +5 -1
  169. package/docs/concepts/default-harness.md +5 -3
  170. package/docs/guides/deployment.md +3 -3
  171. package/docs/guides/dynamic-workflows.md +9 -10
  172. package/docs/reference/cli.md +4 -2
  173. package/docs/reference/typescript-api.md +27 -27
  174. package/docs/subagents.mdx +1 -1
  175. package/docs/tools/overview.mdx +1 -0
  176. package/package.json +14 -14
  177. package/dist/src/compiled/_chunks/workflow/attribute-changes-Dmf_myUv.js +0 -20
  178. package/dist/src/compiled/_chunks/workflow/dist-D7CzPkf8.js +0 -77
  179. package/dist/src/compiled/_chunks/workflow/run-CL3mguvM.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{C as r,T as i,h as a,l as o,m as s,o as c,r as l}from"../../_chunks/workflow/dist-DpDDcpTl.js";import{$ as u,C as d,D as f,F as p,H as m,L as h,M as g,N as _,P as v,Q as y,S as b,T as x,U as S,X as C,Y as w,Z as T,b as ee,et as E,f as te,k as ne,l as D,m as re,nt as ie,p as ae,q as oe,r as se,rt as ce,tt as le,w as ue,x as de,y as fe}from"../../_chunks/workflow/dist-CQenixFf.js";import{t as pe}from"../../_chunks/workflow/undici-fb54XL8i.js";import{webcrypto as me}from"node:crypto";import{inspect as he}from"node:util";import{AsyncLocalStorage as ge}from"node:async_hooks";import _e from"node:os";import*as ve from"path";import*as ye from"fs";import{createRequire as be}from"module";import*as xe from"net";var Se=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})})),Ce=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})})),we=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=Se(),f=Ce();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(ke())),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})})),Te=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})})),Ee=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`)),_=Ce();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})})),De=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=ke();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})})),Oe=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})})),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,{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=Ce(),_=Ee(),v=De(),y=Oe(),b=Te();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})})),Ae=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=we(),d=Se(),f=Te(),p=ke();0&&(t.exports={AccessTokenMissingError,RefreshAccessTokenFailedError,getContext,getVercelOidcToken,getVercelOidcTokenSync,getVercelToken})}))();let je;try{je=new TextDecoder}catch{}let O,Me,k=0;const Ne=[],Pe=57337,Fe={};let Ie=11281e4,Le=1681e4,Re=Ne,ze=0,A={},j,Be,Ve=0,He=0,M,N,P=[],Ue=[],F,I,We,Ge={useRecords:!1,mapsAsObjects:!0},Ke=!1,qe=2;try{Function(``)}catch{qe=1/0}var Je=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 bt(()=>(xt(),this?this.decode(t,n):e.prototype.decode.call(Ge,t,n)));Me=n>-1?n:t.length,k=0,ze=0,He=0,Be=null,Re=Ne,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,Ye();(!j||j.length>0)&&(j=[])}else A=Ge,(!j||j.length>0)&&(j=[]),F=null;return Ye()}decodeMultiple(e,t){let n,r=0;try{let i=e.length;Ke=!0;let a=this?this.decode(e,i):Ct.decode(e,i);if(t){if(t(a)===!1)return;for(;k<i;)if(r=k,t(Ye())===!1)return}else{for(n=[a];k<i;)r=k,n.push(Ye());return n}}catch(e){throw e.lastPosition=r,e.values=n,e}finally{Ke=!1,xt()}}};function Ye(){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==Me)j=null,O=null,N&&=null;else if(k>Me){let e=Error(`Unexpected end of CBOR data`);throw e.incomplete=!0,e}else if(!Ke)throw Error(`Data read, but end of buffer not reached`);return e}catch(e){throw xt(),(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 ot();e=I.getUint16(k),k+=2;break;case 26:if(t==7){let e=I.getFloat32(k);if(A.useFloat32>2){let t=St[(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())!=Fe;){if(r>=Ie)throw Error(`Array length exceeds ${Ie}`);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())!=Fe;){if(t++>=Le)throw Error(`Property count exceeds ${Le}`);e[R(A.decodeKey(i))]=L()}else for(;(i=L())!=Fe;){if(t++>=Le)throw Error(`Property count exceeds ${Le}`);e[R(i)]=L()}return e}else{We&&=(A.mapsAsObjects=!0,!1);let e=new Map;if(A.keyMap){let t=0;for(;(i=L())!=Fe;){if(t++>=Le)throw Error(`Map size exceeds ${Le}`);e.set(A.decodeKey(i),L())}}else{let t=0;for(;(i=L())!=Fe;){if(t++>=Le)throw Error(`Map size exceeds ${Le}`);e.set(i,L())}}return e}case 7:return Fe;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 rt(e);case 3:if(He>=k)return Be.slice(k-Ve,(k+=e)-Ve);if(He==0&&Me<140&&e<32){let t=e<16?nt(e):tt(e);if(t!=null)return t}return Qe(e);case 4:if(e>=Ie)throw Error(`Array length exceeds ${Ie}`);let t=Array(e);for(let n=0;n<e;n++)t[n]=L();return t;case 5:if(e>=Le)throw Error(`Map size exceeds ${Ie}`);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{We&&=(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>=Pe){let t=j[e&8191];if(t)return t.read||=Ze(t),t.read();if(e<65536){if(e==57343){let e=vt(),t=L(),n=L();ct(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=vt(),t=L();for(let n=2;n<e;n++)ct(t++,L());return L()}else if(e==Pe)return _t();if(A.getShared&&(yt(),t=j[e&8191],t))return t.read||=Ze(t),t.read()}}let n=P[e];if(n)return n.handlesRead?n(L):n(L());{let t=L();for(let n=0;n<Ue.length;n++){let r=Ue[n](e,t);if(r!==void 0)return r}return new st(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||ft())[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 Xe=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Ze(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++>=qe){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=>Xe.test(e)?R(e)+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`}`):Function(`r`,`return {`+n.map(e=>Xe.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 Qe=et;function $e(e){Qe=t(1);function t(t){return function(t){let n=Re[ze++];if(n==null){if(M)return et(t);let r=e(k,Me,t,O);if(typeof r==`string`)n=r,Re=Ne;else if(Re=r,ze=1,He=1,n=Re[0],n===void 0)throw Error(`Unexpected end of buffer`)}let r=n.length;return r<=t?(k+=t,n):(Be=n,Ve=k,He=k+r,k+=t,n.slice(0,t))}}}function et(e){let t;if(e<16&&(t=nt(e)))return t;if(e>64&&je)return je.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 tt(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 nt(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 rt(e){return A.copyBuffers?Uint8Array.prototype.slice.call(O,k,k+=e):O.subarray(k,k+=e)}let it=new Float32Array(1),at=new Uint8Array(it.buffer,0,4);function ot(){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 at[3]=e&128|(n>>1)+56,at[2]=(e&7)<<5|t>>3,at[1]=t<<5,at[0]=0,it[0]}Array(4096);var st=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 ct=(e,t)=>{e-=57344;let n=j[e];n&&n.isShared&&((j.restoreStructures||=[])[e]=n),j[e]=t,t.read=Ze(t)};P[105]=e=>{let t=e.length,n=e[1];ct(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 st(e,14),P[15]=e=>M?M[1].slice(M.position1,M.position1+=e):new st(e,15);let lt={Error,RegExp};P[27]=e=>(lt[e[0]]||Error)(e[1],e[2]);const ut=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()};ut.handlesRead=!0,P[51]=ut,P[6]=e=>{if(!F)if(A.getShared)yt();else return new st(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,We=!0),e())).handlesRead=!0;function dt(e,t){return typeof e==`string`?e+t:e instanceof Array?e.concat(t):Object.assign({},e,t)}function ft(){if(!F)if(A.getShared)yt();else throw Error(`No packed values available`);return F}Ue.push((e,t)=>{if(e>=225&&e<=255)return dt(ft().prefixes[e-224],t);if(e>=28704&&e<=32767)return dt(ft().prefixes[e-28672],t);if(e>=1879052288&&e<=2147483647)return dt(ft().prefixes[e-1879048192],t);if(e>=216&&e<=223)return dt(t,ft().suffixes[e-216]);if(e>=27647&&e<=28671)return dt(t,ft().suffixes[e-27639]);if(e>=1811940352&&e<=1879048191)return dt(t,ft().suffixes[e-1811939328]);if(e==1399353956)return{packedValues:F,structures:j.slice(0),version:t};if(e==55799)return t});const pt=new Uint8Array(new Uint16Array([1]).buffer)[0]==1,mt=[Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,typeof BigUint64Array>`u`?{name:`BigUint64Array`}:BigUint64Array,Int8Array,Int16Array,Int32Array,typeof BigInt64Array>`u`?{name:`BigInt64Array`}:BigInt64Array,Float32Array,Float64Array],ht=[64,68,69,70,71,72,77,78,79,85,86];for(let e=0;e<mt.length;e++)gt(mt[e],ht[e]);function gt(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==pt?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 _t(){let e=vt(),t=k+L();for(let t=2;t<e;t++){let e=vt();k+=e}let n=k;return k=t,M=[et(vt()),et(vt())],M.position0=0,M.position1=0,M.postBundlePosition=k,k=n,L()}function vt(){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 yt(){if(A.getShared){let e=bt(()=>(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 bt(e){let t=Me,n=k,r=ze,i=Ve,a=He,o=Be,s=Re,c=N,l=M,u=new Uint8Array(O.slice(0,Me)),d=j,f=A,p=Ke,m=e();return Me=t,k=n,ze=r,Ve=i,He=a,Be=o,Re=s,N=c,M=l,O=u,Ke=p,j=d,A=f,I=new DataView(O.buffer,O.byteOffset,O.byteLength),m}function xt(){O=null,N=null,j=null}const St=Array(147);for(let e=0;e<256;e++)St[e]=+(`1e`+Math.floor(45.15-e*.30103));let Ct=new Je({useRecords:!1});const wt=Ct.decode;Ct.decodeMultiple;const Tt={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4};let Et;try{Et=new TextEncoder}catch{}let Dt,Ot;const kt=typeof globalThis==`object`&&globalThis.Buffer,At=kt!==void 0,jt=At?kt.allocUnsafeSlow:Uint8Array,Mt=At?kt:Uint8Array,Nt=At?4294967296:2144337920;let Pt,B,V,H=0,Ft,U=null;const It=/[\u0080-\uFFFF]/,W=Symbol(`record-id`);var Lt=class extends Je{constructor(e){super(e),this.offset=0;let t,n,r,i,a;e||={};let o=Mt.prototype.utf8Write?function(e,t,n){return B.utf8Write(e,t,n)}:Et&&Et.encodeInto?function(e,t){return Et.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 jt(8192),V=new DataView(B.buffer,0,8192),H=0),Ft=B.length-10,Ft-H<2048?(B=new jt(B.length),V=new DataView(B.buffer,0,B.length),Ft=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,Ut(o,t),t.values.length>0){B[H++]=216,B[H++]=51,Bt(4);let e=t.values;v(e),Bt(0),Bt(0),f=Object.create(m||null);for(let t=0,n=e.length;t<n;t++)f[e[t]]=t}}Pt=c&tn;try{if(Pt)return;if(v(o),U&&Jt(t,v),s.offset=H,a&&a.idsToInsert){H+=a.idsToInsert.length*2,H>Ft&&b(H),s.offset=H;let e=qt(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>Ft&&(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>Ft&&(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&&Jt(t,v),U=[``,``],U.size=0,U.position=e}let e=It.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>Ft&&(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*St[(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:Bt(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=Dt.length;e<t;e++){let t=Ot[e];if(n instanceof t){let t=Dt[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(Pt){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]||Ht(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);Kt(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),Bt(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:Bt(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>Nt)throw Error(`Encoded buffer would be larger than maximum buffer size`);n=Math.min(Nt,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 jt(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,Ft=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):Rt(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;Bt(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 Ht(e)?(Rt(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,tn)}function ee(e,t,n){return x=t&&t.chunkThreshold?S=t.chunkThreshold:100,e&&typeof e==`object`?(s.encode(null,tn),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===Mt||e===Uint8Array)yield n;else if(Ht(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 zt(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 Rt(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 zt=class{constructor(e,t,n){this.structures=e,this.packedValues=t,this.version=n}};function Bt(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 Vt=typeof Blob>`u`?function(){}:Blob;function Ht(e){if(e instanceof Vt)return!0;let t=e[Symbol.toStringTag];return t===`Blob`||t===`File`}function Ut(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++)Ut(e[n],t);else{let r=!t.encoder.useRecords;for(var n in e)e.hasOwnProperty(n)&&(r&&Ut(n,t),Ut(e[n],t))}break;case`function`:console.log(e)}}const Wt=new Uint8Array(new Uint16Array([1]).buffer)[0]==1;Ot=[Date,Set,Error,RegExp,st,ArrayBuffer,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,typeof BigUint64Array>`u`?function(){}:BigUint64Array,Int8Array,Int16Array,Int32Array,typeof BigInt64Array>`u`?function(){}:BigInt64Array,Float32Array,Float64Array,zt],Dt=[{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){Kt(e,n)}},{getTag(e){if(e.constructor===Uint8Array&&(this.tagUint8Array||At&&this.tagUint8Array!==!1))return 64},encode(e,t,n){Kt(e,n)}},Gt(68,1),Gt(69,2),Gt(70,4),Gt(71,8),Gt(72,1),Gt(77,2),Gt(78,4),Gt(79,8),Gt(85,4),Gt(86,8),{encode(e,t){let n=e.packedValues||[],r=e.structures||[];if(n.values.length>0){B[H++]=216,B[H++]=51,Bt(4);let e=n.values;t(e),Bt(0),Bt(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 st(e.version,1399353956)),t(n)}else t(new st(e.version,1399353956))}}];function Gt(e,t){return!Wt&&t>1&&(e-=4),{tag:e,encode:function(e,t){let n=e.byteLength,r=e.byteOffset||0,i=e.buffer||e;t(At?kt.from(i,r,n):new Uint8Array(i,r,n))}}}function Kt(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 qt(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 Jt(e,t){V.setUint32(U.position+e,H-U.position-e+1);let n=U;U=null,t(n[0]),t(n[1])}let Yt=new Lt({useRecords:!1});const Xt=Yt.encode;Yt.encodeAsIterable,Yt.encodeAsAsyncIterable;const{NEVER:Zt,ALWAYS:Qt,DECIMAL_ROUND:$t,DECIMAL_FIT:en}=Tt,tn=2048;var nn=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}}})),rn=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,()=>{})})}})})}})),an=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}}})),on=n(((e,n)=>{let r=t(`child_process`),{isLinux:i,getReport:a}=nn(),{LDD_PATH:o,SELF_PATH:s,readFile:c,readFileSync:l}=rn(),{interpreterPath:u}=an(),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},D=async()=>{let e=null;return i()&&(e=await te(),e||(e=await ee(),e||=S(),e||=C(await g()))),e},re=()=>{let e=null;return i()&&(e=ne(),e||(e=E(),e||=S(),e||=C(_()))),e},ie=async()=>i()&&await D()!==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:D,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}}})),sn=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 D(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 D(i.join(e,`prebuilds`,t.name))}function D(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}=on();return t()===n}g.parseTags=C,g.matchTags=w,g.compareTags=ee,g.parseTuple=b,g.matchTuple=x,g.compareTuples=S})),cn=n(((e,t)=>{t.exports=sn()(__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`?cn():be(import.meta.url)(`cbor-extract`),e&&$e(e.extractStrings)}catch{}}var ln=pe();let un,dn,fn;const pn={connections:8,keepAliveTimeout:1e4,pipelining:1},mn={...pn,allowH2:!1},hn={...pn,allowH2:!0},gn={retryAfter:!0,statusCodes:[500,502,503,504]},_n={retryAfter:!0,methods:[`PUT`],statusCodes:[429]};function vn(e){return e?.dispatcher??Sn()}function yn(e){return e?.dispatcher??Cn()}function bn(e){return e?.dispatcher??wn()}function xn(e,t){return new ln.RetryAgent(new ln.Agent(e),t)}function Sn(){return un??=xn(mn,gn),un}function Cn(){return dn??=xn(hn,gn),dn}function wn(){return fn??=xn(hn,_n),fn}let Tn=null;async function En(){return Tn||=import(`../../_chunks/workflow/src-CQuMexnO.js`).then(t=>e(t.t(),1)).catch(()=>null),Tn}let Dn=null;async function On(){return Dn||=En().then(e=>e?e.trace.getTracer(`workflow`):null),Dn}async function kn(e,...t){let[n,r]=await Promise.all([On(),En()]),{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 An(e){let t=await En();if(t)return t.SpanKind[e]}async function jn(e){let t=await En();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 Mn=G(`http.request.method`),Nn=G(`url.full`),Pn=G(`server.address`),Fn=G(`server.port`),In=G(`http.response.status_code`),Ln=G(`error.type`),Rn=G(`workflow.world.parse.format`),zn=G(`peer.service`),Bn=G(`rpc.system`),Vn=G(`rpc.service`),Hn=G(`rpc.method`),Un=G(`workflow.run.id`),Wn=G(`step.id`),Gn=G(`workflow.stream.name`),Kn=G(`workflow.stream.operation`),qn=G(`workflow.stream.start_index`),Jn=()=>ee(`WORKFLOW_REQUEST_TIMEOUT_MS`,6e4,{integer:!0,min:1}),Yn=typeof process<`u`&&typeof process.env.DEBUG==`string`&&(process.env.DEBUG.includes(`workflow:`)||process.env.DEBUG===`*`),Xn=[`x-vercel-id`,`x-vercel-error`,`x-vercel-mitigated`];function Zn(e){return Xn.flatMap(t=>{let n=e.get(t);return n?[`${t}=${n}`]:[]})}function Qn(e){let t=Zn(e);return t.length>0?` (${t.join(`; `)})`:``}function $n(e,t,n,r){if(!Yn)return;let i=Zn(n.headers),a=i.length>0?`; ${i.join(`; `)}`:``;console.debug(`[workflow:world-vercel:http] ${e} ${t} -> ${n.status} (${r}ms${a})`)}function er(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 tr(e){if(!e)return;let t=parseInt(e,10);return Number.isNaN(t)?void 0:t}function nr(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?rr(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 rr(e,t){return e===429&&t===`challenge`}async function ir(e){return e?.token??process.env.VERCEL_TOKEN??await(0,Ae.getVercelOidcToken)().catch(()=>null)}function ar(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 or(e){let{method:t,url:n,peerService:r}=e,{serverAddress:i,serverPort:a}=ar(n);return{...Mn(t),...Nn(n),...i?Pn(i):{},...a?Fn(a):{},...zn(r),...Bn(`http`),...Vn(r)}}async function sr(e){let{method:t,url:n,headers:r,body:a,dispatcher:o,peerService:s=`workflow-server`,timeoutMs:c=Jn(),signal:l,injectTraceContext:u=!0,cacheBust:d=!0,logLabel:f,buildError:p,spanName:m,attributes:h,durationAttribute:g}=e,_=f??n;return kn(m??`http ${t}`,{kind:await An(`CLIENT`)},async e=>{e?.setAttributes(or({method:t,url:n,peerService:s})),h&&e?.setAttributes(h),u&&await jn(r),d&&r.set(`X-Request-Time`,Date.now().toString());let f=c==null?void 0:AbortSignal.timeout(c),m=l&&f?AbortSignal.any([l,f]):l??f,v=Date.now(),y;try{y=await fetch(n,{method:t,headers:r,body:a,signal:m,dispatcher:o})}catch(r){let a=Date.now()-v;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({...Ln(`TIMEOUT`)}),e?.recordException?.(o),o}throw r}let b=Date.now()-v;if($n(t,_,y,b),e?.setAttributes({...In(y.status)}),g&&e?.setAttributes({[g]:b}),!y.ok){if(e?.setAttributes({...Ln(`HTTP ${y.status}`)}),er(t,n,r),p){let t=await p(y);throw e?.recordException?.(t),t}let i=await y.text().catch(()=>``),a=nr(y.status,`${t} ${_} -> HTTP ${y.status}: ${y.statusText}${i?` ${i}`:``}${Qn(y.headers)}`,{url:n,retryAfter:tr(y.headers.get(`Retry-After`))});throw e?.recordException?.(a),a}return y})}const cr=`5.0.0-beta.27`,lr=new Set([`GET`,`HEAD`]),ur=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 dr(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`&&ur.has(e))return e}t=t?.cause}}const fr=()=>process.env.VERCEL_WORKFLOW_SERVER_URL||``,pr=()=>process.env.WORKFLOW_TEST_LIMIT_OVERRIDES?.trim()||``;function mr(e){return e}const hr=()=>{let e=process.env.VERCEL_DEPLOYMENT_ID;return e?`@workflow/world-vercel/${cr} node-${process.version} ${_e.platform()} (${_e.arch()}) ${e}`:`@workflow/world-vercel/${cr} node-${process.version} ${_e.platform()} (${_e.arch()})`},gr=e=>{let t=e?.projectConfig,n=fr()||`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}},_r=(e,t)=>{let n=e?.projectConfig,r=new Headers(e?.headers);r.set(`User-Agent`,hr());let i=pr();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=fr();return a&&t.usingProxy&&r.set(`x-vercel-workflow-api-url`,a),r};async function vr(e){let{baseUrl:t,usingProxy:n}=gr(e),r=_r(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,Ae.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 vr(n),u=`${c}${e}`;return kn(`http ${s}`,{kind:await An(`CLIENT`)},async c=>{c?.setAttributes(or({method:s,url:u,peerService:`workflow-server`})),l.set(`Accept`,`application/cbor`),await jn(l);let d;a!==void 0&&(l.set(`Content-Type`,`application/cbor`),d=Xt(a));let f=lr.has(s.toUpperCase()),p,m=``;for(let r=0;;r++){l.set(`X-Request-Time`,Date.now().toString());let a=AbortSignal.timeout(Jn()),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:vn(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({...Ln(`TIMEOUT`)}),c?.recordException?.(r),r}let r=dr(t);if(r){let a=new i(`${s} ${e} transport failure after ${n}ms (${r})`,{url:u,code:`TRANSPORT`,cause:t});throw c?.setAttributes({...Ln(`TRANSPORT`)}),c?.recordException?.(a),a}throw t}let y=Date.now()-_;if(m=Qn(v.headers),$n(s,e,v,y),c?.setAttributes({...In(v.status)}),!v.ok){let t=await br(v).then(e=>e.data).catch(()=>({})),n=t.code??t.error;er(g.method,u,l);let r=tr(v.headers.get(`Retry-After`)),i=(t.message||`${g.method} ${e} -> HTTP ${v.status}: ${v.statusText}`)+m,a=nr(v.status,i,{url:u,code:n,retryAfter:r,mitigated:v.headers.get(`x-vercel-mitigated`)});throw c?.setAttributes({...Ln(n||`HTTP ${v.status}`)}),c?.recordException?.(a),a}o?.(v);try{p=await kn(`world.parse`,async e=>{let t=await br(v),n=(v.headers.get(`Content-Type`)||``).includes(`application/cbor`);return e?.setAttributes({...Rn(n?`cbor`:`json`)}),t});break}catch(t){if(f&&r<2){let n=100*2**r;c?.setAttributes({...Ln(`PARSE_ERROR_RETRYING`)}),Yn&&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 kn(`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 yr(e){let t=he(e,{depth:3,maxArrayLength:10,breakLength:120});return t.length>500?`${t.slice(0,500)}...`:t}async function br(e){let t=e.headers.get(`Content-Type`)||``;if(t.includes(`application/cbor`)){let n=await e.arrayBuffer(),r=wt(new Uint8Array(n));return{data:r,getDebugContext:()=>`Content-Type: ${t}, ${n.byteLength} bytes (CBOR), preview: ${yr(r)}`}}let n=await e.text(),r=JSON.parse(n);return{data:r,getDebugContext:()=>`Content-Type: ${t}, ${n.length} bytes, preview: ${yr(r)}`}}function xr(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 Sr(e){let t=e.toString();return t?`?${t}`:``}function Cr(e){return{runs:{get(t){return K({endpoint:`/v2/analytics/runs/${encodeURIComponent(t)}`,config:e,schema:d})},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)),xr(n,t.pagination),K({endpoint:`/v2/analytics/runs${Sr(n)}`,config:e,schema:D(d)})}},steps:{get(t,n){return K({endpoint:`/v2/analytics/runs/${encodeURIComponent(t)}/steps/${encodeURIComponent(n)}`,config:e,schema:ue})},list(t){let n=new URLSearchParams;return xr(n,t.pagination),K({endpoint:`/v2/analytics/runs/${encodeURIComponent(t.runId)}/steps${Sr(n)}`,config:e,schema:D(ue)})}},events:{get(t,n){return K({endpoint:`/v2/analytics/runs/${encodeURIComponent(t)}/events/${encodeURIComponent(n)}`,config:e,schema:de})},list(t){let n=new URLSearchParams;return t.eventType&&n.set(`eventType`,t.eventType),t.correlationId&&n.set(`correlationId`,t.correlationId),xr(n,t.pagination),K({endpoint:`/v2/analytics/runs/${encodeURIComponent(t.runId)}/events${Sr(n)}`,config:e,schema:D(de)})},listByCorrelationId(t){let n=new URLSearchParams;return n.set(`correlationId`,t.correlationId),xr(n,t.pagination),K({endpoint:`/v2/analytics/events${Sr(n)}`,config:e,schema:D(de)})}},hooks:{get(t,n){let r=new URLSearchParams;return n?.runId&&r.set(`runId`,n.runId),K({endpoint:`/v2/analytics/hooks/${encodeURIComponent(t)}${Sr(r)}`,config:e,schema:b})},list(t){let n=new URLSearchParams;return n.set(`runId`,t.runId),xr(n,t.pagination),K({endpoint:`/v2/analytics/hooks${Sr(n)}`,config:e,schema:D(b)})}},waits:{get(t,n){return K({endpoint:`/v2/analytics/runs/${encodeURIComponent(t)}/waits/${encodeURIComponent(n)}`,config:e,schema:x})},list(t){let n=new URLSearchParams;return t.status&&n.set(`status`,t.status),xr(n,t.pagination),K({endpoint:`/v2/analytics/runs/${encodeURIComponent(t.runId)}/waits${Sr(n)}`,config:e,schema:D(x)})}}}}async function wr(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 me.subtle.importKey(`raw`,e,`HKDF`,!1,[`deriveBits`]),i=new TextEncoder().encode(`${t}|${n}`),a=await me.subtle.deriveBits({name:`HKDF`,hash:`SHA-256`,salt:new Uint8Array(32),info:i},r,256);return new Uint8Array(a)}async function Tr(e,t,n,r){let i=await ir({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 sr({method:`GET`,url:`https://api.vercel.com/v1/workflow/run-key/${e}?${a}`,headers:new Headers({Authorization:`Bearer ${i}`}),dispatcher:vn({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=E({key:ie().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 Er(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?wr(t,e,c):void 0}if(l)return Tr(l,e,c,{token:n,teamId:t,dispatcher:r})}}const Dr={peerService:`workflow-server`,rpcSystem:`http`,rpcService:`workflow-server`},Or={"world.runs.get":0,"world.runs.experimentalSetAttributes":0,"world.steps.get":0,"world.events.create":0,"world.events.get":0},kr=new Set([`world.steps.list`,`world.events.list`,`world.hooks.list`]);function Ar(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 jr(e,t){return typeof e[t]==`string`?e[t]:void 0}function Mr(e){if(typeof e!=`object`||!e)return;let t=e.runId;return typeof t==`string`?t:void 0}function Nr(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 Pr(e,t,n){let r=`${e}.${t}`,i={},a=Or[r],o=a===void 0?kr.has(r)?Mr(n[0]):void 0:jr(n,a);if(o&&Object.assign(i,Un(o)),r===`world.steps.get`){let e=jr(n,1);e&&Object.assign(i,Wn(e))}return i}function Fr(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=Ar(t);r&&(n=`${e}.${a} ${r}`)}return kn(n,{kind:await An(`CLIENT`)},async r=>{r?.setAttributes({...zn(Dr.peerService),...Bn(Dr.rpcSystem),...Vn(Dr.rpcService),...Hn(n),...Pr(e,a,t)});let o=await i(...t),s=Nr(o);return s&&r?.setAttributes(Un(s)),o})}}return n}var q=class extends Error{constructor(e){super(e),this.name=`MultipartParseError`}};function Ir(e){let t=new TextEncoder().encode(e);return(e,n=0)=>Buffer.prototype.indexOf.call(e,t,n)}function Lr(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 Rr(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 zr(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 Br=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*Vr(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 Hr(zr(n),t).parseStream(e.body)}var Hr=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=Ir(`--${e}`),this.openingBoundaryLength=2+e.length,this.findBoundary=Ir(`\r
6
- --${e}`),this.findPartialTailBoundary=Lr(`\r
7
- --${e}`),this.boundaryLength=4+e.length,this.findDoubleNewline=Ir(`\r
1
+ import{a as e,i as t,t as n}from"../../_chunks/workflow/chunk-BHKSVoKr.js";import{C as r,T as i,h as a,l as o,m as s,o as c,r as l}from"../../_chunks/workflow/dist-DpDDcpTl.js";import{$ as u,A as d,C as f,E as p,F as m,I as h,J 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 E,Z as D,b as ee,et as te,f as ne,it as re,l as ie,m as ae,nt as oe,o as se,p as ce,r as le,rt as ue,tt as de,w as fe,x as pe,y as me}from"../../_chunks/workflow/dist-Blxnyb7-.js";import{t as he}from"../../_chunks/workflow/undici-fb54XL8i.js";import{webcrypto as ge}from"node:crypto";import{inspect as _e}from"node:util";import{AsyncLocalStorage as ve}from"node:async_hooks";import ye from"node:os";import*as be from"path";import*as xe from"fs";import{createRequire as Se}from"module";import*as Ce from"net";var we=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})})),Te=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})})),Ee=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=we(),f=Te();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(je())),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})})),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: `+D+`
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=ci(`\r
7
+ --${e}`),this.boundaryLength=4+e.length,this.findDoubleNewline=si(`\r
8
8
  \r
9
- `),this.maxHeaderSize=t.maxHeaderSize??65536,this.maxBoundaryBuffer=t.maxBoundaryBuffer??8192}async*parseStream(e){let t=e.getReader(),n=new Br,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=Ir(`
9
+ `),this.maxHeaderSize=t.maxHeaderSize??65536,this.maxBoundaryBuffer=t.maxBoundaryBuffer??8192}async*parseStream(e){let t=e.getReader(),n=new di,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=si(`
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=Rr(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 Ur=(e,t,n)=>{let r=e instanceof RegExp?Wr(e,n):e,i=t instanceof RegExp?Wr(t,n):t,a=r!==null&&i!=null&&Gr(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)}},Wr=(e,t)=>{let n=t.match(e);return n?n[0]:null},Gr=(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},Kr=`\0SLASH`+Math.random()+`\0`,qr=`\0OPEN`+Math.random()+`\0`,Jr=`\0CLOSE`+Math.random()+`\0`,Yr=`\0COMMA`+Math.random()+`\0`,Xr=`\0PERIOD`+Math.random()+`\0`,Zr=new RegExp(Kr,`g`),Qr=new RegExp(qr,`g`),$r=new RegExp(Jr,`g`),ei=new RegExp(Yr,`g`),ti=new RegExp(Xr,`g`),ni=/\\\\/g,ri=/\\{/g,ii=/\\}/g,ai=/\\,/g,oi=/\\\./g;function si(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function ci(e){return e.replace(ni,Kr).replace(ri,qr).replace(ii,Jr).replace(ai,Yr).replace(oi,Xr)}function li(e){return e.replace(Zr,`\\`).replace(Qr,`{`).replace($r,`}`).replace(ei,`,`).replace(ti,`.`)}function ui(e){if(!e)return[``];let t=[],n=Ur(`{`,`}`,e);if(!n)return e.split(`,`);let{pre:r,body:i,post:a}=n,o=r.split(`,`);o[o.length-1]+=`{`+i+`}`;let s=ui(a);return a.length&&(o[o.length-1]+=s.shift(),o.push.apply(o,s)),t.push.apply(t,o),t}function di(e,t={}){if(!e)return[];let{max:n=1e5}=t;return e.slice(0,2)===`{}`&&(e=`\\{\\}`+e.slice(2)),gi(ci(e),n,!0).map(li)}function fi(e){return`{`+e+`}`}function pi(e){return/^-?0\d/.test(e)}function mi(e,t){return e<=t}function hi(e,t){return e>=t}function gi(e,t,n){let r=[];for(;;){let i=Ur(`{`,`}`,e);if(!i)return[e];let a=i.pre;if(/\$$/.test(i.pre)){let e=i.post.length?gi(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+Jr+i.post,n=!0;continue}return[e]}let u=i.post.length?gi(i.post,t,!1):[``],d;if(c)d=i.body.split(/\.\./);else if(d=ui(i.body),d.length===1&&d[0]!==void 0&&(d=gi(d[0],t,!1).map(fi),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=si(d[0]),n=si(d[1]),r=Math.max(d[0].length,d[1].length),i=d.length===3&&d[2]!==void 0?Math.max(Math.abs(si(d[2])),1):1,a=mi;n<e&&(i*=-1,a=hi);let o=d.some(pi);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,gi(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 _i=e=>{if(typeof e!=`string`)throw TypeError(`invalid pattern`);if(e.length>65536)throw TypeError(`pattern is too long`)},vi={"[: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]},yi=e=>e.replace(/[[\]\\-]/g,`\\$&`),bi=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),xi=e=>e.join(``),Si=(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(vi))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(yi(d)+`-`+yi(t)):t===d&&r.push(yi(t)),d=``,a++;continue}if(e.startsWith(`-]`,a+1)){r.push(yi(t+`-`)),a+=2;continue}if(e.startsWith(`-`,a+1)){d=t,a+=2;continue}r.push(yi(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[bi(r[0].length===2?r[0].slice(-1):r[0]),!1,u-n,!1];let f=`[`+(l?`^`:``)+xi(r)+`]`,p=`[`+(l?``:`^`)+xi(i)+`]`;return[r.length&&i.length?`(`+f+`|`+p+`)`:r.length?f:p,s,u-n,!0]},Ci=(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 wi=new Set([`!`,`?`,`+`,`*`,`@`]),Ti=e=>wi.has(e),Ei=e=>Ti(e.type),Di=new Map([[`!`,[`@`]],[`?`,[`?`,`@`]],[`@`,[`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`]]]),Oi=new Map([[`!`,[`?`]],[`@`,[`?`]],[`+`,[`?`,`*`]]]),ki=new Map([[`!`,[`?`,`@`]],[`?`,[`?`,`@`]],[`@`,[`?`,`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`,`?`,`*`]]]),Ai=new Map([[`!`,new Map([[`!`,`@`]])],[`?`,new Map([[`*`,`*`],[`+`,`*`]])],[`@`,new Map([[`!`,`!`],[`?`,`?`],[`@`,`@`],[`*`,`*`],[`+`,`+`]])],[`+`,new Map([[`?`,`*`],[`*`,`*`]])]]),ji=`(?!\\.)`,Mi=new Set([`[`,`.`]),Ni=new Set([`..`,`.`]),Pi=new Set(`().*{}+?[]^$\\!`),Fi=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),Ii=`[^/]+?`;let Li=0;var Ri=class{type;#e;#t;#n=!1;#r=[];#i;#a;#o;#s=!1;#c;#l;#u=!1;id=++Li;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&&Ti(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&&Ti(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,Oi)}#m(e,t=Di){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=ki){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!!Ai.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=Ai.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()),!Ei(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&&Ni.has(this.#r[0]))){let n=Mi,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?ji:``}let a=``;return this.isEnd()&&this.#e.#s&&this.#i?.type===`!`&&(a=`(?:$|\\/)`),[i+r+a,Ci(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,Ci(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?ji:``)+Ii;else{let n=this.type===`!`?`))`+(this.isStart()&&!t&&!e?ji:``)+`[^/]*?)`:this.type===`@`?`)`:this.type===`?`?`)?`:this.type===`+`&&a?`)`:this.type===`*`&&a?`)?`:`)${this.type}`;o=r+i+n}return[o,Ci(i),this.#t=!!this.#t,this.#n]}#x(){if(Ei(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+=(Pi.has(c)?`\\`:``)+c;continue}if(c===`*`){if(o)continue;o=!0,i+=n&&/^[*]+$/.test(e)?Ii:`[^/]*?`,t=!0;continue}else o=!1;if(c===`\\`){s===e.length-1?i+=`\\\\`:r=!0;continue}if(c===`[`){let[n,r,o,c]=Si(e,s);if(o){i+=n,a||=r,s+=o-1,t||=c;continue}}if(c===`?`){i+=`[^/]`,t=!0;continue}i+=Fi(c)}return[i,Ci(e),!!t,a]}};J=Ri;const zi=(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={})=>(_i(t),!n.nocomment&&t.charAt(0)===`#`?!1:new da(t,n).match(e)),Bi=/^\*+([^+@!?*[(]*)$/,Vi=e=>t=>!t.startsWith(`.`)&&t.endsWith(e),Hi=e=>t=>t.endsWith(e),Ui=e=>(e=e.toLowerCase(),t=>!t.startsWith(`.`)&&t.toLowerCase().endsWith(e)),Wi=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Gi=/^\*+\.\*+$/,Ki=e=>!e.startsWith(`.`)&&e.includes(`.`),qi=e=>e!==`.`&&e!==`..`&&e.includes(`.`),Ji=/^\.\*+$/,Yi=e=>e!==`.`&&e!==`..`&&e.startsWith(`.`),Xi=/^\*+$/,Zi=e=>e.length!==0&&!e.startsWith(`.`),Qi=e=>e.length!==0&&e!==`.`&&e!==`..`,$i=/^\?+([^+@!?*[(]*)?$/,ea=([e,t=``])=>{let n=ia([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},ta=([e,t=``])=>{let n=aa([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},na=([e,t=``])=>{let n=aa([e]);return t?e=>n(e)&&e.endsWith(t):n},ra=([e,t=``])=>{let n=ia([e]);return t?e=>n(e)&&e.endsWith(t):n},ia=([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!==`..`},oa=typeof process==`object`&&process?typeof process.env==`object`&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:`posix`,sa={win32:{sep:`\\`},posix:{sep:`/`}};Y.sep=oa===`win32`?sa.win32.sep:sa.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 ca=(e,t={})=>(_i(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:di(e,{max:t.braceExpandMax}));Y.braceExpand=ca,Y.makeRe=(e,t={})=>new da(e,t).makeRe(),Y.match=(e,t,n={})=>{let r=new da(t,n);return e=e.filter(e=>r.match(e)),r.options.nonull&&!e.length&&e.push(t),e};const la=/[?*]|[+@!]\(.*?\)|\[|\]/,ua=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`);var da=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,t={}){_i(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]===`?`||!la.test(e[2]))&&!la.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 ca(this.pattern,this.options)}parse(e){_i(e);let t=this.options;if(e===`**`)return X;if(e===``)return``;let n,r=null;(n=e.match(Xi))?r=t.dot?Qi:Zi:(n=e.match(Bi))?r=(t.nocase?t.dot?Wi:Ui:t.dot?Hi:Vi)(n[1]):(n=e.match($i))?r=(t.nocase?t.dot?ta:ea:t.dot?na:ra)(n):(n=e.match(Gi))?r=t.dot?qi:Ki:(n=e.match(Ji))&&(r=Yi);let i=Ri.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`?ua(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=Ri,Y.Minimatch=da,Y.escape=zi,Y.unescape=Ci;var fa=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})),pa=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})})),ma=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=pa();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})})),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,{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})})),ga=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=ma(),f=ha();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(xa())),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})})),_a=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})})),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,{findRootDir:()=>v,getUserDataDir:()=>y}),n.exports=f(p);var m=d(t(`path`)),h=d(t(`fs`)),g=d(t(`os`)),_=ha();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})})),ya=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=xa();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})})),ba=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})})),xa=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=ha(),_=va(),v=ya(),y=ba(),b=_a();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})})),Sa=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=ga(),d=ma(),f=pa(),p=_a(),m=xa();0&&(t.exports={AccessTokenMissingError,RefreshAccessTokenFailedError,getContext,getVercelOidcToken,getVercelOidcTokenSync,getVercelToken})})),Ca=e(fa(),1),wa=Sa();async function Ta(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 Ea=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 Ta(e);return JSON.parse(t.toString(`utf8`),this.reviver)}},Da=class extends Error{constructor(e){super(`Message ${e} not found`),this.name=`MessageNotFoundError`}},Oa=class extends Error{constructor(e,t){super(`Message ${e} not available for processing${t?`: ${t}`:``}`),this.name=`MessageNotAvailableError`}},ka=class extends Error{constructor(e,t){super(`Message ${e} is corrupted: ${t}`),this.name=`MessageCorruptedError`}},Aa=class extends Error{retryAfter;constructor(e=`Too many requests`,t){super(e),this.name=`TooManyRequestsError`,this.retryAfter=t}},ja=class extends Error{constructor(e=`Missing or invalid authentication token`){super(e),this.name=`UnauthorizedError`}},Ma=class extends Error{constructor(e=`Queue environment doesn't match token environment`){super(e),this.name=`ForbiddenError`}},Na=class extends Error{constructor(e){super(e),this.name=`BadRequestError`}},Pa=class extends Error{constructor(e=`Unexpected server error`){super(e),this.name=`InternalServerError`}},Fa=class extends Error{constructor(e,t=1,n=10){super(`Invalid limit: ${e}. Limit must be between ${t} and ${n}.`),this.name=`InvalidLimitError`}},Ia=class extends Error{constructor(e){super(`Message ${e} has already been processed`),this.name=`MessageAlreadyProcessedError`}},La=class extends Error{idempotencyKey;constructor(e,t){super(e),this.name=`DuplicateMessageError`,this.idempotencyKey=t}},Ra=class extends Error{deploymentId;constructor(e,t){super(e),this.name=`ConsumerDiscoveryError`,this.deploymentId=t}},za=class extends Error{constructor(e=`Consumer registry not configured`){super(e),this.name=`ConsumerRegistryNotConfiguredError`}},Ba=300,Va=30,Ha=60,Ua=10,Wa=3e3,Ga=3,Ka=250;function qa(e){return Math.min(Ha,Math.max(Ua,e/5))}var Ja=class{client;topicName;consumerGroupName;visibilityTimeout;constructor(e,t,n,r={}){this.client=e,this.topicName=t,this.consumerGroupName=n,this.visibilityTimeout=Math.max(Va,r.visibilityTimeoutSeconds??Ba)}isClientError(e){return e instanceof Oa||e instanceof Da||e instanceof Na||e instanceof ja||e instanceof Ma}isNetworkError(e){return e instanceof TypeError}async directiveCallWithRetries(e){let t;for(let n=1;n<=Ga;n++)try{return await e()}catch(e){if(t=e,n===Ga)throw e;if(e instanceof Aa){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=Ka*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=qa(this.visibilityTimeout)*1e3,s=o;if(t?.visibilityDeadline){let e=t.visibilityDeadline.getTime()-Date.now();s=e>0?qa(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 ${Wa/1e3}s):`,t),n?a=setTimeout(()=>u(),Wa):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}},Ya=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&&co()&&Yo(this.topicName,n.messageId,this.client.getRegion(),t?.delaySeconds,t?.retentionSeconds),{messageId:n.messageId}}consumerGroup(e,t){return new Ja(this.client,this.topicName,e,t)}get name(){return this.topicName}},Xa=`com.vercel.queue.v1beta`,Za=`com.vercel.queue.v2beta`;function Qa(e,t){let n=t.slice(0,-1);return e.startsWith(n)}function $a(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(!$a(e)||!e.type||!e.source||!e.id||!$a(e.data))throw Error(`Invalid CloudEvent: missing required fields`);if(e.type!==`com.vercel.queue.v1beta`)throw Error(`Invalid CloudEvent type: expected '${Xa}', 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 to(e){let t=Q(e,`ce-type`);if(t!==`com.vercel.queue.v2beta`)throw Error(`Invalid CloudEvent type: expected '${Za}', 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 no(e,t){if(Q(t,`ce-type`)===`com.vercel.queue.v2beta`){let n=to(t);return`receiptHandle`in n&&(n.parsedPayload=e),n}return eo(e,Q(t,`content-type`))}async function ro(e){if(e.headers.get(`ce-type`)===`com.vercel.queue.v2beta`){let t=to(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}),no(t,n)}async function io(e,t,n){let{queueName:r,consumerGroup:i,messageId:a}=t;if(!n?.client)throw Error(`HandleCallbackOptions.client is required`);let o=Os(n.client);t.region&&(o=o.withRegion(t.region));let s=new Ya(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 $=Ca.default.cyan(`[queue]`),ao=Ca.default.green(`✓`),oo=Ca.default.red(`✗`),so=Ca.default.yellow(`↻`);function co(){return process.env.NODE_ENV===`development`&&process.env.VERCEL_DEPLOYMENT_ID===void 0}var lo=Symbol.for(`@vercel/queue.devRouteMappings`);function uo(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 fo(){let e=globalThis;if(lo in e)return e[lo]??null;try{let t=ve.join(process.cwd(),`vercel.json`);if(!ye.existsSync(t))return e[lo]=null,null;let n=JSON.parse(ye.readFileSync(t,`utf-8`));if(!n.functions)return e[lo]=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:uo(e),retryAfterSeconds:n.retryAfterSeconds})}}return e[lo]=r.length>0?r:null,e[lo]}catch(t){return console.warn(`${$} Failed to read vercel.json:`,t),e[lo]=null,null}}function po(e){let t=fo();return t?t.filter(t=>t.topic.includes(`*`)?Qa(e,t.topic):t.topic===e):[]}function mo(e,t){return po(e).find(e=>e.consumer===t)?.retryAfterSeconds}function ho(e){return/^src\/(app|pages|server)\//.test(e)?e.slice(4):null}function go(e,t){return e===t||Y(e,t)}function _o(e){let t=fo();if(!t)return[];let n=process.cwd(),r;try{r=ve.relative(n,e)}catch{return[]}let i=r.replace(/\\/g,`/`),a=ho(i);return t.filter(e=>go(i,e.filePath)||a!==null&&go(a,e.filePath))}function vo(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 yo;function bo(){if(yo)return yo;try{let e=typeof __dirname<`u`?__dirname:ve.dirname(new URL(import.meta.url).pathname);yo=ve.resolve(e,`..`)}catch{yo=``}return yo}function xo(){let e=Error().stack;if(!e)return null;let t=e.split(`
13
- `).slice(1),n=bo();for(let e of t){let t=vo(e);if(!t)continue;let r=ve.isAbsolute(t)?t:ve.resolve(process.cwd(),t),i;try{i=ye.realpathSync(r)}catch{i=r}if(!(n&&i.startsWith(n)))return i}return null}var So=Symbol.for(`@vercel/queue.devHandlerRegistry`);function Co(){let e=globalThis;return e[So]||(e[So]=new Map),e[So]}function wo(e,t,n,r){let i=_o(ve.isAbsolute(e)?e:ve.resolve(process.cwd(),e));if(i.length===0)return!1;let a=Co();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 To(e,t,n,r){let i=r??xo();if(!i){console.warn(`${$} Could not determine caller file path for handler registration.`);return}if(!wo(i,e,t,n)){let e=fo();if(e&&e.length>0)return;let t=process.cwd(),n;try{n=ve.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.
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=Go();for(let e of t){let t=Uo(e);if(!t)continue;let r=be.isAbsolute(t)?t:be.resolve(process.cwd(),t),i;try{i=xe.realpathSync(r)}catch{i=r}if(!(n&&i.startsWith(n)))return i}return null}var qo=Symbol.for(`@vercel/queue.devHandlerRegistry`);function Jo(){let e=globalThis;return e[qo]||(e[qo]=new Map),e[qo]}function Yo(e,t,n,r){let i=Ho(be.isAbsolute(e)?e:be.resolve(process.cwd(),e));if(i.length===0)return!1;let a=Jo();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 Xo(e,t,n,r){let i=r??Ko();if(!i){console.warn(`${$} Could not determine caller file path for handler registration.`);return}if(!Yo(i,e,t,n)){let e=Lo();if(e&&e.length>0)return;let t=process.cwd(),n;try{n=be.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 Eo(e){let t=Co(),n=[];for(let[r,i]of t)(r.includes(`*`)?Qa(e,r):r===e)&&n.push(...i);return n}var Do=50,Oo=5e3,ko=2,Ao=250,jo=[`PORT`,`NEXT_PORT`,`NEXTJS_PORT`,`NUXT_PORT`,`NITRO_PORT`,`SVELTEKIT_PORT`,`VITE_PORT`,`DEV_PORT`,`npm_config_port`],Mo=[`__NEXT_PRIVATE_ORIGIN`,`NUXT_PUBLIC_SITE_URL`,`URL`];function No(e){return e instanceof Error?e.message:String(e)}function Po(e){return e instanceof Da||e instanceof Error&&e.name===`MessageNotFoundError`}function Fo(e){if(!e)return null;let t=Number.parseInt(e,10);return!Number.isFinite(t)||t<1||t>65535?null:t}function Io(e){if(!e)return null;try{let t=new URL(e).port;return Fo(t)}catch{return null}}function Lo(){let e=[],t=new Set,n=n=>{n&&!t.has(n)&&(t.add(n),e.push(n))};for(let e of jo)n(Fo(process.env[e]));for(let e of Mo)n(Io(process.env[e]));return e}function Ro(e){return new Promise(t=>{let n=xe.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(Ao,()=>i(!1))})}async function zo(e,t,n){let r=0,i=Do;for(;;)try{await io(e,t,n);return}catch(e){if(Po(e)&&r<Oo){await new Promise(e=>setTimeout(e,i)),r+=i,i=Math.min(i*ko,Oo-r);continue}throw e}}function Bo(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 Vo(e,t={}){let n={triedPorts:Lo(),listeningPorts:[],unavailablePorts:[],importFailures:[],primeFailures:[]},r=po(e);if(r.length===0)return n;let i=t.refreshRegistered===!0;for(let e of n.triedPorts)await Ro(e)?n.listeningPorts.push(e):n.unavailablePorts.push(e);for(let t of r){let r=Uo(e,t.consumer);if(!(r&&!i)){if(!r){let r=ve.resolve(process.cwd(),t.filePath);try{await import(r)}catch(e){n.importFailures.push({filePath:t.filePath,reason:No(e)})}if(Uo(e,t.consumer))continue}for(let r of n.listeningPorts){let i=`http://localhost:${r}${Bo(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(Uo(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:No(e)})}}}}return n}function Ho(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}${Bo(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?`
18
+ }`)}}function Zo(e){let t=Jo(),n=[];for(let[r,i]of t)(r.includes(`*`)?wo(e,r):r===e)&&n.push(...i);return n}var Qo=50,$o=5e3,es=2,ts=250,ns=[`PORT`,`NEXT_PORT`,`NEXTJS_PORT`,`NUXT_PORT`,`NITRO_PORT`,`SVELTEKIT_PORT`,`VITE_PORT`,`DEV_PORT`,`npm_config_port`],rs=[`__NEXT_PRIVATE_ORIGIN`,`NUXT_PUBLIC_SITE_URL`,`URL`];function is(e){return e instanceof Error?e.message:String(e)}function as(e){return e instanceof Qa||e instanceof Error&&e.name===`MessageNotFoundError`}function os(e){if(!e)return null;let t=Number.parseInt(e,10);return!Number.isFinite(t)||t<1||t>65535?null:t}function ss(e){if(!e)return null;try{let t=new URL(e).port;return os(t)}catch{return null}}function cs(){let e=[],t=new Set,n=n=>{n&&!t.has(n)&&(t.add(n),e.push(n))};for(let e of ns)n(os(process.env[e]));for(let e of rs)n(ss(process.env[e]));return e}function ls(e){return new Promise(t=>{let n=Ce.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(ts,()=>i(!1))})}async function us(e,t,n){let r=0,i=Qo;for(;;)try{await Ao(e,t,n);return}catch(e){if(as(e)&&r<$o){await new Promise(e=>setTimeout(e,i)),r+=i,i=Math.min(i*es,$o-r);continue}throw e}}function ds(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 fs(e,t={}){let n={triedPorts:cs(),listeningPorts:[],unavailablePorts:[],importFailures:[],primeFailures:[]},r=Ro(e);if(r.length===0)return n;let i=t.refreshRegistered===!0;for(let e of n.triedPorts)await ls(e)?n.listeningPorts.push(e):n.unavailablePorts.push(e);for(let t of r){let r=ms(e,t.consumer);if(!(r&&!i)){if(!r){let r=be.resolve(process.cwd(),t.filePath);try{await import(r)}catch(e){n.importFailures.push({filePath:t.filePath,reason:is(e)})}if(ms(e,t.consumer))continue}for(let r of n.listeningPorts){let i=`http://localhost:${r}${ds(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(ms(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:is(e)})}}}}return n}function ps(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}${ds(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 Uo(e,t){return Eo(e).some(e=>e.consumerGroup===t)}var Wo=10,Go=2,Ko=10,qo=86400;function Jo(e,t){let n=Math.min(Math.max(t,0),Wo);console.log(`${$} ${so} 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>Ko){console.log(`${$} Max re-deliveries (${Ko}) 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(`${$} ${oo} Handler error on re-delivery: topic="${e.topicName}" messageId="${e.messageId}"`,t)}if(i)console.log(`${$} ${ao} Message processed on re-delivery: topic="${e.topicName}" consumer="${e.consumerGroup}" messageId="${e.messageId}"`);else if(o)console.log(`${$} ${ao} Message acknowledged (will not retry): topic="${e.topicName}" consumer="${e.consumerGroup}" messageId="${e.messageId}"`);else{let n=a??e.defaultRetryDelayS;Jo({...e,deliveryCount:t},n)}},n*1e3)}function Yo(e,t,n,r,i){if(r&&r>0){console.log(`${$} Message sent with delay: topic="${e}" messageId="${t}" delay=${r}s`),setTimeout(()=>{Yo(e,t,n,void 0,i)},r*1e3);return}console.log(`${$} Message sent: topic="${e}" messageId="${t}"`),(async()=>{let r=Eo(e),a=null;if(r.length>0?(await Vo(e,{refreshRegistered:!0}),r=Eo(e)):(a=await Vo(e),r=Eo(e)),r.length===0){let t=po(e);if(t.length>0){let n=a??{triedPorts:Lo(),listeningPorts:[],unavailablePorts:[],importFailures:[],primeFailures:[]};console.warn(Ho(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??qo;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(mo(e,i.consumerGroup)??Go,Wo),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 zo(d,p,m),c)console.log(`${$} ${ao} Message processed: topic="${e}" consumer="${i.consumerGroup}" messageId="${t}"`);else if(u)console.log(`${$} ${ao} Message acknowledged (will not retry): topic="${e}" consumer="${i.consumerGroup}" messageId="${t}"`);else if(l!==null){let e=Math.min(l,Wo);Jo(g(),e)}}catch(n){console.error(`${$} ${oo} Handler failed: topic="${e}" consumer="${i.consumerGroup}" messageId="${t}"`,n),c||Jo(g(),h)}}})()}function Xo(){let e=globalThis;delete e[lo],delete e[So]}(process.env.NODE_ENV===`test`||process.env.VITEST)&&(globalThis.__clearDevState=Xo,globalThis.__filePathToConsumerGroup=uo,globalThis.__filePathToUrlPath=Bo,globalThis.__matchesFunctionsPattern=go,globalThis.__stripSrcPrefix=ho);function Zo(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 Qo;function $o(){return Qo||=import(`../../_chunks/workflow/src-CQuMexnO.js`).then(t=>e(t.t(),1)).then(e=>e,()=>null),Qo}function es(){let e=process.env.VERCEL_QUEUE_TRACE_PROPAGATION?.toLowerCase();return e===`off`||e===`0`||e===`false`}var ts=[`traceparent`,`tracestate`,`baggage`];async function ns(e,t){if(es()||t&&!t.isEnabled)return;let n=await $o();if(n)try{let t={};n.propagation.inject(n.context.active(),t);for(let n of ts){let r=t[n];r!==void 0&&e.set(n,r)}}catch{}}function rs(e,t,n){try{t.setStatus({code:e.SpanStatusCode.ERROR,message:n instanceof Error?n.message:String(n)})}catch{}}function is(e){try{e.end()}catch{}}async function as(e,t,n){if(es()||n&&!n.isEnabled)return t(null);let r=await $o();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 rs(r,a,e),e}finally{is(a)}}var os=`x-vercel-queue-traceparent`,ss=`x-vercel-queue-tracestate`,cs=`x-vercel-queue-baggage`;async function ls(e,t,n){if(es()||n&&!n.isEnabled)return t();let r=await $o();if(!r)return t();let i=null;try{let t=us(r,ds(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 rs(r,a,e),e}finally{is(a)}}function us(e,t){let n=t[os];if(!n)return[];let r={traceparent:n},i=t[ss];i&&(r.tracestate=i);let a=t[cs];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 ds(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 fs(){return process.env.VERCEL_QUEUE_DEBUG===`1`||process.env.VERCEL_QUEUE_DEBUG===`true`}async function ps(e){let t=e.getReader();try{for(;;){let{done:e}=await t.read();if(e)break}}finally{t.releaseLock()}}function ms(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 hs(e,t,n,r,i=`Invalid parameters`,a){throw e===400?new Na(n||i):e===429?new Aa(n||`Too many requests: ${r}`,ms(a)):e===401?new ja(n||void 0):e===403?new Ma(n||void 0):e>=500?new Pa(n||`Server error: ${e} ${t}`):Error(`Failed to ${r}: ${e} ${t}`)}function gs(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 _s=/^[a-z]{2,5}[0-9]{1,2}$/;function vs(e){if(!_s.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 ys=e=>new URL(`https://${e}.vercel-queue.com`);function bs(e,t){return(t??ys)(e)}var xs=`/api/v3/topic`,Ss=class e{baseUrl;customHeaders;providedToken;resolvedDeploymentId;pinSends;explicitlyUnpinned;transport;region;baseUrlResolver;dispatcher;telemetry;constructor(e){vs(e.region),this.region=e.region,this.baseUrlResolver=e.resolveBaseUrl,this.baseUrl=bs(this.region,this.baseUrlResolver),this.customHeaders=e.headers||{},this.providedToken=e.token,this.transport=e.transport||new Ea,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(!(co()||this.explicitlyUnpinned||this.resolvedDeploymentId))throw Error(`No deployment ID available. VERCEL_DEPLOYMENT_ID is not set.
23
+ `+(a.length>0?`Try opening: ${a.join(` or `)}`:`Set PORT (or NEXT_PORT/NUXT_PORT/VITE_PORT) and try sending again.`)}function ms(e,t){return Zo(e).some(e=>e.consumerGroup===t)}var hs=10,gs=2,_s=10,vs=86400;function ys(e,t){let n=Math.min(Math.max(t,0),hs);console.log(`${$} ${No} 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>_s){console.log(`${$} Max re-deliveries (${_s}) 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(`${$} ${Mo} Handler error on re-delivery: topic="${e.topicName}" messageId="${e.messageId}"`,t)}if(i)console.log(`${$} ${jo} Message processed on re-delivery: topic="${e.topicName}" consumer="${e.consumerGroup}" messageId="${e.messageId}"`);else if(o)console.log(`${$} ${jo} Message acknowledged (will not retry): topic="${e.topicName}" consumer="${e.consumerGroup}" messageId="${e.messageId}"`);else{let n=a??e.defaultRetryDelayS;ys({...e,deliveryCount:t},n)}},n*1e3)}function bs(e,t,n,r,i){if(r&&r>0){console.log(`${$} Message sent with delay: topic="${e}" messageId="${t}" delay=${r}s`),setTimeout(()=>{bs(e,t,n,void 0,i)},r*1e3);return}console.log(`${$} Message sent: topic="${e}" messageId="${t}"`),(async()=>{let r=Zo(e),a=null;if(r.length>0?(await fs(e,{refreshRegistered:!0}),r=Zo(e)):(a=await fs(e),r=Zo(e)),r.length===0){let t=Ro(e);if(t.length>0){let n=a??{triedPorts:cs(),listeningPorts:[],unavailablePorts:[],importFailures:[],primeFailures:[]};console.warn(ps(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??vs;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(zo(e,i.consumerGroup)??gs,hs),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 us(d,p,m),c)console.log(`${$} ${jo} Message processed: topic="${e}" consumer="${i.consumerGroup}" messageId="${t}"`);else if(u)console.log(`${$} ${jo} Message acknowledged (will not retry): topic="${e}" consumer="${i.consumerGroup}" messageId="${t}"`);else if(l!==null){let e=Math.min(l,hs);ys(g(),e)}}catch(n){console.error(`${$} ${Mo} Handler failed: topic="${e}" consumer="${i.consumerGroup}" messageId="${t}"`,n),c||ys(g(),h)}}})()}function xs(){let e=globalThis;delete e[Fo],delete e[qo]}(process.env.NODE_ENV===`test`||process.env.VITEST)&&(globalThis.__clearDevState=xs,globalThis.__filePathToConsumerGroup=Io,globalThis.__filePathToUrlPath=ds,globalThis.__matchesFunctionsPattern=Vo,globalThis.__stripSrcPrefix=Bo);function Ss(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 Cs;function ws(){return Cs||=import(`../../_chunks/workflow/src-CQuMexnO.js`).then(t=>e(t.t(),1)).then(e=>e,()=>null),Cs}function Ts(){let e=process.env.VERCEL_QUEUE_TRACE_PROPAGATION?.toLowerCase();return e===`off`||e===`0`||e===`false`}var Es=[`traceparent`,`tracestate`,`baggage`];async function Ds(e,t){if(Ts()||t&&!t.isEnabled)return;let n=await ws();if(n)try{let t={};n.propagation.inject(n.context.active(),t);for(let n of Es){let r=t[n];r!==void 0&&e.set(n,r)}}catch{}}function Os(e,t,n){try{t.setStatus({code:e.SpanStatusCode.ERROR,message:n instanceof Error?n.message:String(n)})}catch{}}function ks(e){try{e.end()}catch{}}async function As(e,t,n){if(Ts()||n&&!n.isEnabled)return t(null);let r=await ws();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 Os(r,a,e),e}finally{ks(a)}}var js=`x-vercel-queue-traceparent`,Ms=`x-vercel-queue-tracestate`,Ns=`x-vercel-queue-baggage`;async function Ps(e,t,n){if(Ts()||n&&!n.isEnabled)return t();let r=await ws();if(!r)return t();let i=null;try{let t=Fs(r,Is(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 Os(r,a,e),e}finally{ks(a)}}function Fs(e,t){let n=t[js];if(!n)return[];let r={traceparent:n},i=t[Ms];i&&(r.tracestate=i);let a=t[Ns];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 Is(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 Ls(){return process.env.VERCEL_QUEUE_DEBUG===`1`||process.env.VERCEL_QUEUE_DEBUG===`true`}async function Rs(e){let t=e.getReader();try{for(;;){let{done:e}=await t.read();if(e)break}}finally{t.releaseLock()}}function zs(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 Bs(e,t,n,r,i=`Invalid parameters`,a){throw e===400?new io(n||i):e===429?new to(n||`Too many requests: ${r}`,zs(a)):e===401?new no(n||void 0):e===403?new ro(n||void 0):e>=500?new ao(n||`Server error: ${e} ${t}`):Error(`Failed to ${r}: ${e} ${t}`)}function Vs(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 Hs=/^[a-z]{2,5}[0-9]{1,2}$/;function Us(e){if(!Hs.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 Ws=e=>new URL(`https://${e}.vercel-queue.com`);function Gs(e,t){return(t??Ws)(e)}var Ks=`/api/v3/topic`,qs=class e{baseUrl;customHeaders;providedToken;resolvedDeploymentId;pinSends;explicitlyUnpinned;transport;region;baseUrlResolver;dispatcher;telemetry;constructor(e){Us(e.region),this.region=e.region,this.baseUrlResolver=e.resolveBaseUrl,this.baseUrl=Gs(this.region,this.baseUrlResolver),this.customHeaders=e.headers||{},this.providedToken=e.token,this.transport=e.transport||new Za,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(!(Po()||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(!co())return this.requireDeploymentId(),this.pinSends?this.resolvedDeploymentId:void 0}getConsumeDeploymentId(){if(!co())return this.requireDeploymentId(),this.resolvedDeploymentId}async getToken(){if(this.providedToken)return this.providedToken;try{return await(0,wa.getVercelOidcToken)()}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(co()?`Failed to get OIDC token for local development.
31
+ new QueueClient({ deploymentId: null })`)}getSendDeploymentId(){if(!Po())return this.requireDeploymentId(),this.pinSends?this.resolvedDeploymentId:void 0}getConsumeDeploymentId(){if(!Po())return this.requireDeploymentId(),this.resolvedDeploymentId}async getToken(){if(this.providedToken)return this.providedToken;try{return await(0,Ya.getVercelOidcToken)()}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(Po()?`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}${xs}/${n}${i}`}async fetch(e,t){let n=t.method||`GET`;if(fs()){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(fs()){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=Zo(this.telemetry,c);return as(n,async e=>{await ns(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 La(e||`Duplicate idempotency key detected`,i);if(t.status===502)throw new Ra(e||`Consumer discovery failed`,u);if(t.status===503)throw new za(e||`Consumer registry not configured`);hs(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 Fa(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();hs(c.status,c.statusText,e,`receive messages`)}for await(let e of Vr(c))try{let n=gs(e.headers);if(!n){console.warn(`Missing required queue headers in multipart part`),await ps(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 ps(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 Da(i);if(c.status===409){let t={};try{t=JSON.parse(e)}catch{}throw t.originalMessageId?new Oa(i,`This message was a duplicate - use originalMessageId: ${t.originalMessageId}`):new Oa(i)}if(c.status===410)throw new Ia(i);hs(c.status,c.statusText,e,`receive message by ID`)}for await(let e of Vr(c)){let n=gs(e.headers);if(!n)throw await ps(e.payload),new ka(i,`Missing required queue headers in response`);let r=await t.deserialize(e.payload);return{message:{...n,payload:r}}}throw new Da(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 Da(r);if(o.status===409)throw new Oa(r,e||`Invalid receipt handle, message not in correct state, or already processed`);hs(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 Da(r);if(s.status===409)throw new Oa(r,e||`Invalid receipt handle, message not in correct state, or already processed`);hs(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}}},Cs=new WeakMap,ws=Symbol.for(`@vercel/queue.apiClient`);function Ts(e,t){Cs.set(e,t),Object.defineProperty(e,ws,{value:t,writable:!1,enumerable:!1,configurable:!1})}function Es(e){let t=Cs.get(e);if(t)return t;let n=e[ws];if(typeof n==`object`&&n){let t=n;return Cs.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 Ds(e){return`request`in e?e.request:e}function Os(e){return Es(e)}var ks=`iad1`;function As(e){return e||process.env.VERCEL_REGION||(co()||console.warn(`[QueueClient] Region not detected \u2014 defaulting to "${ks}". On Vercel this is set automatically via VERCEL_REGION. To silence this warning, pass region explicitly: new QueueClient({ region: "iad1" })`),ks)}var js=class{constructor(e={}){let t=As(e.region);Ts(this,new Ss({...e,region:t}))}send=async(e,t,n)=>{let r=Es(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&&co()&&Yo(e,i.messageId,r.getRegion(),n?.delaySeconds,n?.retentionSeconds),{messageId:i.messageId}};handleCallback=(e,t)=>{co()&&To(e,this,t);let n=Zo(Es(this).getTelemetry?.());return async r=>{let i=Ds(r);if(co()&&i.headers.get(`x-vercel-queue-prime`)===`1`){let n=i.headers.get(`x-vercel-queue-prime-file`);return n&&To(e,this,t,n),Response.json({status:`primed`})}try{let r=await ro(i);return await ls(i.headers,()=>io(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)=>{co()&&To(e,this,t);let n=Zo(Es(this).getTelemetry?.());return async(r,i)=>{if(r.method!==`POST`){i.status(200).end();return}let a=r.headers[`x-vercel-queue-prime`];if(co()&&a===`1`){let n=r.headers[`x-vercel-queue-prime-file`],a=Array.isArray(n)?n[0]:n;a&&To(e,this,t,a),i.status(200).json({status:`primed`});return}try{let a=no(r.body,r.headers);await ls(r.headers,()=>io(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`})}}}},Ms=class{contentType=`application/cbor`;serialize(e){return Buffer.from(Xt(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 wt(Buffer.concat(t))}},Ns=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())}},Ps=class{contentType=`application/cbor`;serialize(e){return Buffer.from(Xt(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 wt(r)}catch{return JSON.parse(r.toString())}}};const Fs=new ge,Is=E({payload:ae,queueName:re,deploymentId:ie().optional()}),Ls=Number(process.env.VERCEL_QUEUE_MAX_DELAY_SECONDS||82800);function Rs(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 zs(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}function Bs(e){let{baseUrl:t,usingProxy:n}=gr(e),r=_r(e,{usingProxy:n}),i=`iad1`,a=new Ms,o=new Ns,s=new Ps,c={region:i,dispatcher:vn(e),transport:s,...n&&{resolveBaseUrl:()=>new URL(`${t}/queues-proxy`),token:e?.token},headers:{...Object.fromEntries(r.entries()),...n&&{"x-vercel-queue-region":i}}},l=async(e,t,n)=>{let r=n?.deploymentId??process.env.VERCEL_DEPLOYMENT_ID;if(!r)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 i=(n?.specVersion??5)>=3?a:o,s=new js({...c,deploymentId:r,transport:i}),l={payload:t,queueName:e,deploymentId:n?.deploymentId},u=e.replace(/[^A-Za-z0-9-_]/g,`-`);try{let{messageId:e}=await s.send(u,l,{idempotencyKey:n?.idempotencyKey,delaySeconds:n?.delaySeconds,headers:{...zs(t),...n?.headers}});return{messageId:e?te.parse(e):null}}catch(e){if(e instanceof La)return{messageId:te.parse(`msg_duplicate_${e.idempotencyKey??n?.idempotencyKey??`unknown`}`)};throw e}};return{queue:l,createQueueHandler:(e,t)=>{let n=new js(c).handleCallback(async(e,n)=>{if(!e||!n)return;let r=Fs.getStore(),{payload:i,queueName:a,deploymentId:o}=Is.parse(e),s=await t(i,{queueName:a,messageId:te.parse(n.messageId),attempt:n.deliveryCount,requestId:r});typeof s?.timeoutSeconds==`number`&&await l(a,i,{deploymentId:o,delaySeconds:s.timeoutSeconds>0?Math.min(s.timeoutSeconds,Ls):void 0})},{retry:(e,{deliveryCount:t})=>({afterSeconds:Rs(t)})});return async e=>{let t=e.headers.get(`x-vercel-id`)?.trim()||void 0;return Fs.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 Vs=E({id:ie()});function Hs(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 ir(e);if(!n)throw Error(`Cannot resolve latest deployment: no OIDC token or VERCEL_TOKEN available`);let r=await(await sr({method:`GET`,url:`https://api.vercel.com/v1/workflow/resolve-latest-deployment/${encodeURIComponent(t)}`,headers:new Headers({Authorization:`Bearer ${n}`}),dispatcher:vn(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=Vs.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 Us={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`}},Ws=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 Gs(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(...Gs(r.cause,t+1)),n}function Ks(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 Gs(e).some(e=>Ws.has(e))}const qs=e=>new Promise(t=>setTimeout(t,e)),Js=typeof process<`u`&&typeof process.env.DEBUG==`string`&&(process.env.DEBUG.includes(`workflow:`)||process.env.DEBUG===`*`);function Ys(e,t){if(!Js)return;let n=Object.entries(t).map(([e,t])=>`${e}=${t}`).join(` `);console.debug(`[workflow:world-vercel:event-retry] ${e} ${n}`)}function Xs(e){return i.is(e)?e.code??(e.status==null?e.name:`status_${e.status}`):Gs(e)[0]??(e instanceof Error?e.name:`unknown`)}async function Zs(e,t){let n=Us[t]?.retryable??!1;for(let r=0;;r++)try{return await e()}catch(e){let i=n&&Ks(e);if(i&&r<2){let n=100*2**r+Math.floor(Math.random()*50);Ys(`retrying event POST after transient failure`,{eventType:t,attempt:r+1,backoffMs:n,error:Xs(e)}),await qs(n);continue}throw i&&Ys(`exhausted in-process retries; surfacing for queue redelivery`,{eventType:t,attempts:r+1,error:Xs(e)}),e}}const Qs=`application/vnd.workflow.v4-frames`;function $s(e,t){let n=new Uint8Array(Xt(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*ec(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():nc(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=wt(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{tc(()=>t.return?.())}}function tc(e){try{Promise.resolve(e()).catch(()=>{})}catch{}}async function*nc(e){try{for(;;){let{done:t,value:n}=await e.read();if(t)return;n&&(yield n)}}finally{tc(()=>e.cancel())}}async function rc(e,t,n,r){return sr({method:t.method,url:e,headers:t.headers,body:t.body,dispatcher:yn(n),timeoutMs:null,logLabel:r,buildError:async t=>sc(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 ac={eventId:`x-wf-event-id`,runId:`x-wf-run-id`,createdAt:`x-wf-created-at`};function oc(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 sc(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=tr(lc(t,`retry-after`));return nr(e,a,{retryAfter:s,code:o,url:i,mitigated:lc(t,`x-vercel-mitigated`)})}async function cc(e,t){let{baseUrl:n,headers:r}=await vr(t),i=new Headers(r);i.set(`Content-Type`,`application/octet-stream`);let a=$s(oc(e),e.payload??new Uint8Array),o=await rc(`${n}/v4/runs/${encodeURIComponent(e.runId)}/events/${encodeURIComponent(e.eventType)}`,{method:`POST`,headers:i,body:a},t,`createEvent`),s=o.headers.get(ac.eventId),c=o.headers.get(ac.runId),l=o.headers.get(ac.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?wt(u):{}}}function lc(e,t){let n=e[t];if(typeof n==`string`)return n;if(Array.isArray(n)&&n.length>0)return n[0]}async function uc(e,t,n){let{baseUrl:r,headers:i}=await vr(n),a=await rc(`${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 ${Qs}, got ${o??`(none)`}`);let s=a.body;for await(let e of ec(s))return{event:e.meta,body:e.body};throw Error(`v4 getEvent: empty frame stream for ${t}`)}async function dc(e,t,n,r){let i=await rc(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 ${Qs}, got ${a??`(none)`}`);let o=i.body,s=[],c,l,u=!1;for await(let e of ec(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 fc(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 pc(e){let t=new URLSearchParams;fc(t,e);let n=t.toString();return n?`?${n}`:``}async function mc(e,t={},n){let{baseUrl:r,headers:i}=await vr(n);return dc(`${r}/v4/runs/${encodeURIComponent(e)}/events`+pc(t),i,n,`listEvents`)}async function hc(e,t={},n){let{baseUrl:r,headers:i}=await vr(n),a=new URLSearchParams;return a.set(`correlationId`,e),fc(a,t),dc(`${r}/v4/events?${a.toString()}`,i,n,`listEventsByCorrelationId`)}const gc=`zstd`,_c=new TextDecoder;function vc(){try{return globalThis.process?.getBuiltinModule?.(`node:zlib`)}catch{return}}function yc(e){return!(e instanceof Uint8Array)||e.byteLength<4?null:_c.decode(e.subarray(0,4))}function bc(e,t){let n=vc(),r=e===gc?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 xc(e){let t=yc(e);return t!==gc&&t!==`gzip`?e:bc(t,e.subarray(4))}function Sc(e){return{...e,input:xc(e.input),output:xc(e.output),error:xc(e.error)}}function Cc(e){return{...e,input:xc(e.input),output:xc(e.output),error:xc(e.error)}}function wc(e){return{...e,metadata:xc(e.metadata)}}function Tc(e){let t=e.eventData;if(!t||typeof t!=`object`)return e;let n=p(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 Ec=ne.omit({error:!0,errorCode:!0}).extend({error:ce([S,C()]).optional(),errorCode:ie().optional(),blobStorageBytes:u().optional(),streamStorageBytes:u().optional()}),Dc=Ec,Oc=Ec.omit({input:!0,output:!0}).extend({inputRef:C().optional(),outputRef:C().optional(),input:ce([w(Uint8Array),C()]).optional(),output:ce([w(Uint8Array),C()]).optional()});function kc(e,t){if(t===`none`){let{inputRef:t,outputRef:n,...r}=e;return{...Sc(mr(r)),input:void 0,output:void 0}}return Sc(mr(e))}async function Ac(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`?Oc:Dc)});return{...l,data:l.data.map(e=>kc(e,a))}}async function jc(e,t){return mr(await K({endpoint:`/v1/runs/create`,options:{method:`POST`},data:e,config:t,schema:Dc}))}async function Mc(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 kc(await K({endpoint:l,options:{method:`GET`},config:n,schema:o===`lazy`?Oc:Dc}),a)}catch(t){throw t instanceof i&&t.status===404?new r(e):t}}async function Nc(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 kc(await K({endpoint:l,options:{method:`PUT`},config:n,schema:o===`lazy`?Oc:Dc}),a)}catch(t){throw t instanceof i&&t.status===404?new r(e):t}}const Pc=E({attributes:le(ie(),ie())});async function Fc(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:Pc})).attributes}}catch(t){throw t instanceof i&&t.status===404?new r(e):t}}const Ic=f.omit({error:!0}).extend({error:ce([S,C()]).optional(),errorRef:C().optional()}),Lc=Ic.omit({input:!0,output:!0}).extend({inputRef:C().optional(),outputRef:C().optional(),input:w(Uint8Array).optional(),output:w(Uint8Array).optional()});function Rc(e){let{error:t,errorRef:n,...r}=e,i={...r},a=t??n;return a!=null&&(i.error=a),i}function zc(e,t){if(t===`none`){let{inputRef:t,outputRef:n,...r}=e;return{...Cc(Rc(r)),input:void 0,output:void 0}}return Cc(Rc(e))}async function Bc(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`?Lc:Ic)});return{...c,data:c.data.map(e=>zc(e,i))}}async function Vc(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 zc(await K({endpoint:`/v2/runs/${encodeURIComponent(e)}/steps/${encodeURIComponent(t)}${s?`?${s}`:``}`,options:{method:`GET`},config:r,schema:a===`lazy`?Lc:Ic}),i)}const Hc=new Set([`run_created`,`run_started`,`step_started`]);function Uc(e){let t=e.eventData??{},n=v(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 Wc(e){let t=g.safeParse(e);return t.success?t.data:(_.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 Gc(e){return Wc(Tc(e))}function Kc(e,t,n){let r=e.eventData??{};if(t.byteLength>0){let n=v(e.eventType),i=xc(t);n&&i instanceof Uint8Array&&(r[n]=i)}let i=Gc({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`?m(i,`none`):i}async function qc(e,t,n,r){let i=n?.resolveData??`all`,{event:a,body:o}=await uc(e,t,r);return Kc(a,o,i)}async function Jc(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?hc(e.correlationId,i,t):mc(e.runId,i,t));return{data:a.events.map(e=>Kc(e.event,e.body,r)),cursor:a.next??null,hasMore:typeof a.hasMore==`boolean`?a.hasMore:!!a.next}}async function Yc(e,t,n,r){try{return await Zs(()=>Xc(e,t,n,r),t.eventType)}catch(e){throw h(t.eventType)&&i.is(e)&&e.status===404&&t.correlationId?new c(t.correlationId):e}}async function Xc(e,t,n,r){if(n?.v1Compat){if(t.eventType===`run_cancelled`&&e)return{run:await Nc(e,n,r)};if(t.eventType===`run_created`)return{run:await jc(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:g})}}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=se(e,`wrun_`);if(t)throw new i(t,{status:400})}let a=Hc.has(t.eventType)?`resolve`:`lazy`,{payload:o,meta:s}=Uc(t),c=await cc({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?m(Wc(u.event),l):void 0,run:u.run?mr(u.run):void 0,step:u.step?Rc(u.step):void 0,hook:u.hook,wait:u.wait,events:u.events?u.events.map(Wc):void 0,cursor:u.cursor??void 0,hasMore:u.hasMore,...u.stepCreated?{stepCreated:!0}:{}}}function Zc(e,t){if(t===`none`){let{metadataRef:t,...n}=e;return n}return wc(e)}const Qc=fe.omit({metadata:!0}).extend({metadataRef:oe.any().optional()});async function $c(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`?Qc:fe)});return{...c,data:c.data.map(e=>Zc(e,i))}}async function el(e,t,n){let r=t?.resolveData||`all`;return Zc(await K({endpoint:`/v2/hooks/${encodeURIComponent(e)}`,options:{method:`GET`},config:n,schema:fe}),r)}async function tl(e,t){try{return await K({endpoint:`/v2/hooks/by-token?token=${encodeURIComponent(e)}`,options:{method:`GET`},config:t,schema:fe})}catch(t){throw i.is(t)&&t.status===404?new c(e):t}}function nl(e){let t={runs:{get:((t,n)=>Mc(t,n,e)),list:(t=>Ac(t,e)),experimentalSetAttributes:(t,n,r)=>Fc(t,n,r,e)},steps:{get:((t,n,r)=>Vc(t,n,r,e)),list:(t=>Bc(t,e))},events:{create:(t,n,r)=>Yc(t,n,r,e),get:(t,n,r)=>qc(t,n,r,e),list:t=>Jc(t,e),listByCorrelationId:t=>Jc(t,e)},hooks:{get:(t,n)=>el(t,n,e),getByToken:t=>tl(t,e),list:t=>$c(t,e)}};return{runs:Fr(`world.runs`,t.runs),steps:Fr(`world.steps`,t.steps),events:Fr(`world.events`,t.events),hooks:Fr(`world.hooks`,t.hooks)}}const rl=()=>ee(`WORKFLOW_MAX_CHUNKS_PER_REQUEST`,1e3,{integer:!0,min:1});function il(e,t,n){return new URL(`${n.baseUrl}/v2/runs/${encodeURIComponent(t)}/stream/${encodeURIComponent(e)}`)}function al(e,t,n){return new URL(`${n.baseUrl}/v3/runs/${encodeURIComponent(t)}/stream/${encodeURIComponent(e)}`)}function ol(e){return{...Un(e.runId),...Gn(e.name),...Kn(e.operation),...typeof e.startIndex==`number`?qn(e.startIndex):{}}}function sl(e,t,n,r){let i=[`PUT ${t.origin}${t.pathname}`,...Zn(n.headers)];return Error(`Stream ${e} failed: HTTP ${n.status} (${i.join(`; `)}): ${r}`)}function cl(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 ll=E({tailIndex:u(),done:y()}),ul=E({data:T(E({index:u(),data:w(Uint8Array)})),cursor:ie().nullable(),hasMore:y(),done:y()});function dl(e){return{streams:{async write(t,n,r){let i=await t,a=await vr(e),o=il(n,i,a);await(await sr({method:`PUT`,url:o.toString(),body:r,headers:a.headers,dispatcher:bn(e),timeoutMs:null,logLabel:o.pathname,spanName:`workflow.stream.write`,durationAttribute:`workflow.stream.write.chunk_rtt`,attributes:ol({runId:i,name:n,operation:`write`}),buildError:async e=>sl(`write`,o,e,await e.text())})).text()},async writeMulti(t,n,r){if(r.length===0)return;let i=await t,a=await vr(e);a.headers.set(`X-Stream-Multi`,`true`);let o=rl();for(let t=0;t<r.length;t+=o){let s=cl(r.slice(t,t+o)),c=il(n,i,a);await(await sr({method:`PUT`,url:c.toString(),body:s,headers:a.headers,dispatcher:bn(e),timeoutMs:null,logLabel:c.pathname,spanName:`workflow.stream.write`,durationAttribute:`workflow.stream.write.chunk_rtt`,attributes:ol({runId:i,name:n,operation:`write_multi`}),buildError:async e=>sl(`write`,c,e,await e.text())})).text()}},async close(t,n){let r=await t,i=await vr(e);i.headers.set(`X-Stream-Done`,`true`);let a=il(n,r,i);await(await sr({method:`PUT`,url:a.toString(),headers:i.headers,dispatcher:bn(e),timeoutMs:null,logLabel:a.pathname,spanName:`workflow.stream.write`,durationAttribute:`workflow.stream.write.chunk_rtt`,attributes:ol({runId:r,name:n,operation:`close`}),buildError:async e=>sl(`close`,a,e,await e.text())})).text()},async get(t,n,r){let i=await vr(e),a=al(n,t,i);typeof r==`number`&&a.searchParams.set(`startIndex`,String(r));let o=await sr({method:`GET`,url:a.toString(),headers:i.headers,dispatcher:void 0,timeoutMs:null,logLabel:a.pathname,spanName:`workflow.stream.read.connect`,attributes:ol({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:ll})},async list(t){let n=await vr(e),r=new URL(`${n.baseUrl}/v2/runs/${encodeURIComponent(t)}/streams`);return await(await sr({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 fl(e){let t=e?.projectConfig?.projectId||process.env.VERCEL_PROJECT_ID;return{specVersion:5,processExitTriggersQueueRedelivery:!0,...Bs(e),...nl(e),analytics:Cr(e),...Fr(`world.streams`,dl(e)),getEncryptionKeyForRun:Er(t,e?.projectConfig?.teamId,e?.token,e?.dispatcher),resolveLatestDeploymentId:Hs(e)}}function pl(e){return fl(e)}export{Cr as createAnalytics,Er as createGetEncryptionKeyForRun,Bs as createQueue,nl as createStorage,dl as createStreamer,pl as createVercelWorld,fl as createWorld,wr as deriveRunKey,Tr as fetchRunKey,Ce as i,ha as n,ke as r,xa 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}${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};