eve 0.31.0 → 0.31.2

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 (93) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/src/channel/cross-channel-receive.d.ts +1 -1
  3. package/dist/src/compiled/.vendor-stamp.json +6 -6
  4. package/dist/src/compiled/@workflow/core/_quickjs-wasi.d.ts +8 -0
  5. package/dist/src/compiled/@workflow/core/correlation-id.d.ts +109 -0
  6. package/dist/src/compiled/@workflow/core/events-consumer.d.ts +1 -0
  7. package/dist/src/compiled/@workflow/core/index.js +2 -2
  8. package/dist/src/compiled/@workflow/core/private.d.ts +17 -1
  9. package/dist/src/compiled/@workflow/core/private.js +1 -1
  10. package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +19 -0
  11. package/dist/src/compiled/@workflow/core/runtime/deployment-guard.d.ts +99 -0
  12. package/dist/src/compiled/@workflow/core/runtime/quickjs-assets.generated.d.ts +14 -0
  13. package/dist/src/compiled/@workflow/core/runtime/quickjs-entrypoint.d.ts +124 -0
  14. package/dist/src/compiled/@workflow/core/runtime/quickjs-runtime.d.ts +193 -0
  15. package/dist/src/compiled/@workflow/core/runtime/run.d.ts +2 -0
  16. package/dist/src/compiled/@workflow/core/runtime/runs.d.ts +18 -1
  17. package/dist/src/compiled/@workflow/core/runtime/suspension-handler.d.ts +7 -0
  18. package/dist/src/compiled/@workflow/core/runtime/vm-mode.d.ts +44 -0
  19. package/dist/src/compiled/@workflow/core/runtime/vm-serde-bundle.generated.d.ts +14 -0
  20. package/dist/src/compiled/@workflow/core/runtime.d.ts +1 -1
  21. package/dist/src/compiled/@workflow/core/runtime.js +3 -3
  22. package/dist/src/compiled/@workflow/core/serialization/codec-devalue-vm.d.ts +9 -0
  23. package/dist/src/compiled/@workflow/core/serialization/reducers/class-vm.d.ts +20 -0
  24. package/dist/src/compiled/@workflow/core/serialization/reducers/common-vm.d.ts +15 -0
  25. package/dist/src/compiled/@workflow/core/serialization/reducers/step-function-vm.d.ts +44 -0
  26. package/dist/src/compiled/@workflow/core/serialization/vm-bundle-entry.d.ts +12 -0
  27. package/dist/src/compiled/@workflow/core/serialization/workflow-vm.d.ts +24 -0
  28. package/dist/src/compiled/@workflow/core/serialization.d.ts +2 -1
  29. package/dist/src/compiled/@workflow/core/source-map.d.ts +20 -0
  30. package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +78 -0
  31. package/dist/src/compiled/@workflow/core/telemetry.d.ts +5 -0
  32. package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
  33. package/dist/src/compiled/@workflow/core/workflow.js +1 -1
  34. package/dist/src/compiled/@workflow/errors/error-codes.d.ts +2 -0
  35. package/dist/src/compiled/@workflow/errors/index.d.ts +24 -0
  36. package/dist/src/compiled/@workflow/errors/index.js +1 -1
  37. package/dist/src/compiled/@workflow/world/analytics.d.ts +2 -0
  38. package/dist/src/compiled/@workflow/world/events.d.ts +51 -1
  39. package/dist/src/compiled/@workflow/world/hooks.d.ts +1 -0
  40. package/dist/src/compiled/@workflow/world/index.d.ts +1 -1
  41. package/dist/src/compiled/@workflow/world/interfaces.d.ts +28 -1
  42. package/dist/src/compiled/@workflow/world/queue.d.ts +8 -0
  43. package/dist/src/compiled/@workflow/world/runs.d.ts +83 -0
  44. package/dist/src/compiled/@workflow/world-local/index.js +5 -4
  45. package/dist/src/compiled/@workflow/world-vercel/index.js +15 -15
  46. package/dist/src/compiled/_chunks/workflow/_eve-core-quickjs-entrypoint-stub-qIV0OaFz.js +1 -0
  47. package/dist/src/compiled/_chunks/workflow/{attribute-changes-DROfGk6l.js → attribute-changes-Du5ztewf.js} +2 -2
  48. package/dist/src/compiled/_chunks/workflow/{dist-D5bR13zs.js → dist-CNXUKQCp.js} +1 -1
  49. package/dist/src/compiled/_chunks/workflow/dist-CRTn4Sg8.js +3 -0
  50. package/dist/src/compiled/_chunks/workflow/dist-tJoQXAF6.js +1 -0
  51. package/dist/src/compiled/_chunks/workflow/functions-ClJbpZhR.js +1 -0
  52. package/dist/src/compiled/_chunks/workflow/{private-BcwCGTV5.js → private-CiWVdS5v.js} +1 -1
  53. package/dist/src/compiled/_chunks/workflow/resume-hook-CT0keOww.js +1 -0
  54. package/dist/src/compiled/_chunks/workflow/run-DBheaFhH.js +1 -0
  55. package/dist/src/compiled/_chunks/workflow/signal-exit-C8vsI6zj.js +1 -0
  56. package/dist/src/compiled/_chunks/workflow/sleep-BeH4B0Cd.js +1 -0
  57. package/dist/src/compiled/_chunks/workflow/{token-hiUWkDKe.js → token-DtCUEpJs.js} +1 -1
  58. package/dist/src/compiled/_chunks/workflow/{token-util-DURSL1l8.js → token-util-DNwIAn_u.js} +9 -9
  59. package/dist/src/compiled/_chunks/workflow/undici-CUIybhQ2.js +95 -0
  60. package/dist/src/compiled/_chunks/workflow/wait-until-CMX5LUWJ.js +15 -0
  61. package/dist/src/compiler/extension-compatibility.d.ts +2 -2
  62. package/dist/src/compiler/extension-compatibility.js +1 -1
  63. package/dist/src/context/container.d.ts +3 -0
  64. package/dist/src/context/container.js +1 -1
  65. package/dist/src/discover/filesystem.js +1 -1
  66. package/dist/src/execution/parked-delivery-wait.js +1 -1
  67. package/dist/src/execution/session-command-inbox.d.ts +11 -3
  68. package/dist/src/execution/session-command-wire.d.ts +24 -0
  69. package/dist/src/execution/session-command-wire.js +1 -0
  70. package/dist/src/execution/turn-control-receiver.js +1 -1
  71. package/dist/src/execution/workflow-runtime.js +1 -1
  72. package/dist/src/execution/workflow-steps.js +1 -1
  73. package/dist/src/harness/authorization.d.ts +8 -0
  74. package/dist/src/harness/authorization.js +1 -1
  75. package/dist/src/internal/application/package.js +1 -1
  76. package/dist/src/internal/nitro/dev-runtime-source-snapshot-copy.js +1 -1
  77. package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
  78. package/dist/src/public/definitions/tool.d.ts +18 -14
  79. package/dist/src/runtime/connections/scoped-authorization.js +1 -1
  80. package/dist/src/runtime/framework-tools/connection-search-dynamic.js +2 -2
  81. package/dist/src/setup/scaffold/create/project.js +1 -1
  82. package/docs/guides/meta.json +2 -1
  83. package/docs/guides/remote-agents.md +6 -4
  84. package/docs/guides/ucp.mdx +181 -0
  85. package/package.json +6 -6
  86. package/dist/src/compiled/_chunks/workflow/dist-B-vbuNqP.js +0 -1
  87. package/dist/src/compiled/_chunks/workflow/dist-dNxTT6nO.js +0 -3
  88. package/dist/src/compiled/_chunks/workflow/functions-CiVUVDNB.js +0 -1
  89. package/dist/src/compiled/_chunks/workflow/resume-hook-bc-OQVI0.js +0 -1
  90. package/dist/src/compiled/_chunks/workflow/run-DM3ouA3U.js +0 -1
  91. package/dist/src/compiled/_chunks/workflow/sleep-D5iWly6-.js +0 -1
  92. package/dist/src/compiled/_chunks/workflow/undici-DWL_MYmT.js +0 -95
  93. package/dist/src/compiled/_chunks/workflow/wait-until-DoW76jdb.js +0 -15
@@ -0,0 +1 @@
1
+ async function e(){throw Error(`Unsupported in eve: QuickJS workflow VM. eve uses the Node.js workflow VM.`)}export{e as runWorkflowWithQuickJS};
@@ -1,6 +1,6 @@
1
- import{$n as e,Qn as t,Xn as n,Zn as r}from"./wait-until-DoW76jdb.js";import{i}from"./dist-dNxTT6nO.js";import{J as a,W as o}from"./dist-D5bR13zs.js";function s(e,t){let n=Error.captureStackTrace;n?.(e,t)}const c=Symbol.for(`nodejs.util.inspect.custom`);function l(e){return`code`in e?`\`${e.code}\``:`dim`in e?e.dim:e.text}function u(e){return`code`in e?n(e.code):`dim`in e?r(e.dim):e.text}function d(e){return e.type===`docs`?`docs: ${e.url}`:e.segments.map(l).join(``)}function f(e){return e.type===`docs`?t(e.url):e.segments.map(u).join(``)}function p(e){let t=[e.title.map(l).join(``)];return e.details.forEach((n,r)=>{let i=r===e.details.length-1,a=i?`╰▶ `:`├▶ `,o=i?` `:`│ `;d(n).split(`
1
+ import{ar as e,ir as t,nr as n,rr as r}from"./wait-until-CMX5LUWJ.js";import{i}from"./dist-CRTn4Sg8.js";import{J as a,Q as o}from"./dist-CNXUKQCp.js";function s(e,t){let n=Error.captureStackTrace;n?.(e,t)}const c=Symbol.for(`nodejs.util.inspect.custom`);function l(e){return`code`in e?`\`${e.code}\``:`dim`in e?e.dim:e.text}function u(e){return`code`in e?n(e.code):`dim`in e?r(e.dim):e.text}function d(e){return e.type===`docs`?`docs: ${e.url}`:e.segments.map(l).join(``)}function f(e){return e.type===`docs`?t(e.url):e.segments.map(u).join(``)}function p(e){let t=[e.title.map(l).join(``)];return e.details.forEach((n,r)=>{let i=r===e.details.length-1,a=i?`╰▶ `:`├▶ `,o=i?` `:`│ `;d(n).split(`
2
2
  `).forEach((e,n)=>{t.push(`${n===0?a:o}${e}`)})}),t.join(`
3
3
  `)}function m(t){return e(t.title.map(u).join(``),t.details.map(f))}var h=class extends Error{fatal=!0;#e;constructor(e){super(p(e)),this.#e=e}[c](){let e=m(this.#e),t=this.message.split(`
4
4
  `).length,n=(this.stack??``).split(`
5
5
  `).slice(t).join(`
6
- `);return n?`${this.name}: ${e}\n${n}`:`${this.name}: ${e}`}toString(){return`${this.name}: ${m(this.#e)}`}},g=class extends h{name=`NotInWorkflowContextError`;constructor(e,t){super({title:[{code:e},{text:` can only be called inside a workflow function`}],details:[{type:`docs`,url:t}]})}},_=class extends h{name=`NotInStepContextError`;constructor(e,t){super({title:[{code:e},{text:` can only be called inside a step function`}],details:[{type:`docs`,url:t}]})}},v=class extends h{name=`NotInWorkflowOrStepContextError`;constructor(e,t){super({title:[{code:e},{text:` can only be called inside a workflow or step function`}],details:[{type:`docs`,url:t}]})}};const y=Symbol.for(`WORKFLOW_CONTEXT`);function b(){let e=globalThis[y];if(!e){let e=new v(`getWorkflowMetadata()`,`https://workflow-sdk.dev/docs/api-reference/workflow/get-workflow-metadata`);throw s(e,b),e}return e}var x=class extends h{name=`UnavailableInWorkflowContextError`;constructor(e,t){let n=globalThis[y]?.workflowName,r=(()=>{if(!n)return null;let e=n.match(/^(workflow\/|step\/)(.*)$/);return e?[{dim:e[1]},{text:e[2]}]:[{text:n}]})(),i=r?{type:`plain`,segments:[{text:`this call was made from the `},...r,{text:` workflow context.`}]}:{type:`plain`,segments:[{text:`this call was made from a workflow context.`}]};super({title:[{code:e},{text:` cannot be called from a workflow context.`}],details:[{type:`plain`,segments:[{text:`calling this in a workflow context can cause determinism issues.`}]},i,{type:`docs`,url:t}]})}};function S(e,t,n){let r=new g(e,t);throw s(r,n),r}function C(e,t,n){let r=new _(e,t);throw s(r,n),r}function w(e,t,n){let r=new v(e,t);throw s(r,n),r}function T(e,t,n){let r=new x(e,t);throw s(r,n),r}function E(e,t={}){if(typeof e!=`object`||!e||Array.isArray(e))throw new i(`setAttributes requires a plain object, got ${e===null?`null`:Array.isArray(e)?`array`:typeof e}`);let n=Object.entries(e).map(([e,t])=>({key:e,value:t===void 0?null:t}));if(n.length===0)return n;let r=t.allowReservedAttributes===!0;try{a(n,{allowReservedAttributes:r})}catch(e){throw e instanceof o?new i(e.message):e}return n}export{w as a,b as c,v as d,S as i,_ as l,x as n,T as o,C as r,y as s,E as t,g as u};
6
+ `);return n?`${this.name}: ${e}\n${n}`:`${this.name}: ${e}`}toString(){return`${this.name}: ${m(this.#e)}`}},g=class extends h{name=`NotInWorkflowContextError`;constructor(e,t){super({title:[{code:e},{text:` can only be called inside a workflow function`}],details:[{type:`docs`,url:t}]})}},_=class extends h{name=`NotInStepContextError`;constructor(e,t){super({title:[{code:e},{text:` can only be called inside a step function`}],details:[{type:`docs`,url:t}]})}},v=class extends h{name=`NotInWorkflowOrStepContextError`;constructor(e,t){super({title:[{code:e},{text:` can only be called inside a workflow or step function`}],details:[{type:`docs`,url:t}]})}};const y=Symbol.for(`WORKFLOW_CONTEXT`);function b(){let e=globalThis[y];if(!e){let e=new v(`getWorkflowMetadata()`,`https://workflow-sdk.dev/docs/api-reference/workflow/get-workflow-metadata`);throw s(e,b),e}return e}var x=class extends h{name=`UnavailableInWorkflowContextError`;constructor(e,t){let n=globalThis[y]?.workflowName,r=(()=>{if(!n)return null;let e=n.match(/^(workflow\/|step\/)(.*)$/);return e?[{dim:e[1]},{text:e[2]}]:[{text:n}]})(),i=r?{type:`plain`,segments:[{text:`this call was made from the `},...r,{text:` workflow context.`}]}:{type:`plain`,segments:[{text:`this call was made from a workflow context.`}]};super({title:[{code:e},{text:` cannot be called from a workflow context.`}],details:[{type:`plain`,segments:[{text:`calling this in a workflow context can cause determinism issues.`}]},i,{type:`docs`,url:t}]})}};function S(e,t,n){let r=new g(e,t);throw s(r,n),r}function C(e,t,n){let r=new _(e,t);throw s(r,n),r}function w(e,t,n){let r=new v(e,t);throw s(r,n),r}function T(e,t,n){let r=new x(e,t);throw s(r,n),r}function E(e,t={}){if(typeof e!=`object`||!e||Array.isArray(e))throw new i(`setAttributes requires a plain object, got ${e===null?`null`:Array.isArray(e)?`array`:typeof e}`);let n=Object.entries(e).map(([e,t])=>({key:e,value:t===void 0?null:t}));if(n.length===0)return n;let r=t.allowReservedAttributes===!0;try{o(n,{allowReservedAttributes:r})}catch(e){throw e instanceof a?new i(e.message):e}return n}export{w as a,b as c,v as d,S as i,_ as l,x as n,T as o,C as r,y as s,E as t,g as u};
@@ -37,4 +37,4 @@ import{r as e}from"./rolldown-runtime-DaDcL9Zw.js";import t from"node:crypto";co
37
37
 
38
38
  `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=be,c=!s.jitless,l=c&&xe.value,u=t.catchall,ee;e._zod.parse=(s,te)=>{ee??=r.value;let ne=s.value;return o(ne)?c&&l&&te?.async===!1&&te.jitless!==!0?(a||=i(t.shape),s=a(s,te),u?ii([],ne,s,te,ee,e):s):n(s,te):(s.issues.push({expected:`object`,code:`invalid_type`,input:ne,inst:e}),s)}});function si(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Be(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>v(e,r,c())))}),t)}const ci=r(`$ZodUnion`,(e,t)=>{x.init(e,t),d(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),d(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),d(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),d(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>le(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>si(t,i,e,a)):si(s,i,e,a)}});function li(e,t,n,r){let i=e.filter(e=>e.issues.length===0);return i.length===1?(t.value=i[0].value,t):(i.length===0?t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>v(e,r,c())))}):t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:[],inclusive:!1}),t)}const ui=r(`$ZodXor`,(e,t)=>{ci.init(e,t),t.inclusive=!1;let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);t instanceof Promise?(s.push(t),o=!0):s.push(t)}return o?Promise.all(s).then(t=>li(t,i,e,a)):li(s,i,e,a)}}),di=r(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,ci.init(e,t);let n=e._zod.parse;d(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=se(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!be(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,input:o,path:[t.discriminator],inst:e}),i)}}),fi=r(`$ZodIntersection`,(e,t)=>{x.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>mi(e,t,n)):mi(e,i,a)}});function pi(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Se(e)&&Se(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=pi(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=pi(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function mi(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),Be(e))return e;let o=pi(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const hi=r(`$ZodTuple`,(e,t)=>{x.init(e,t);let n=t.items;e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({input:a,inst:e,expected:`tuple`,code:`invalid_type`}),r;r.value=[];let o=[],s=[...n].reverse().findIndex(e=>e._zod.optin!==`optional`),c=s===-1?0:n.length-s;if(!t.rest){let t=a.length>n.length,i=a.length<c-1;if(t||i)return r.issues.push({...t?{code:`too_big`,maximum:n.length,inclusive:!0}:{code:`too_small`,minimum:n.length},input:a,inst:e,origin:`array`}),r}let l=-1;for(let e of n){if(l++,l>=a.length&&l>=c)continue;let t=e._zod.run({value:a[l],issues:[]},i);t instanceof Promise?o.push(t.then(e=>gi(e,r,l))):gi(t,r,l)}if(t.rest){let e=a.slice(n.length);for(let n of e){l++;let e=t.rest._zod.run({value:n,issues:[]},i);e instanceof Promise?o.push(e.then(e=>gi(e,r,l))):gi(e,r,l)}}return o.length?Promise.all(o).then(()=>r):r}});function gi(e,t,n){e.issues.length&&t.issues.push(..._(n,e.issues)),t.value[n]=e.value}const _i=r(`$ZodRecord`,(e,t)=>{x.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Se(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){s.add(typeof e==`number`?e.toString():e);let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(..._(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(..._(e,o.issues)),n.value[e]=o.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&_n.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>v(e,r,c())),input:o,path:[o],inst:e});continue}let l=t.valueType._zod.run({value:i[o],issues:[]},r);l instanceof Promise?a.push(l.then(e=>{e.issues.length&&n.issues.push(..._(o,e.issues)),n.value[s.value]=e.value})):(l.issues.length&&n.issues.push(..._(o,l.issues)),n.value[s.value]=l.value)}}return a.length?Promise.all(a).then(()=>n):n}}),vi=r(`$ZodMap`,(e,t)=>{x.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!(i instanceof Map))return n.issues.push({expected:`map`,code:`invalid_type`,input:i,inst:e}),n;let a=[];n.value=new Map;for(let[o,s]of i){let c=t.keyType._zod.run({value:o,issues:[]},r),l=t.valueType._zod.run({value:s,issues:[]},r);c instanceof Promise||l instanceof Promise?a.push(Promise.all([c,l]).then(([t,a])=>{yi(t,a,n,o,i,e,r)})):yi(c,l,n,o,i,e,r)}return a.length?Promise.all(a).then(()=>n):n}});function yi(e,t,n,r,i,a,o){e.issues.length&&(Ee.has(typeof r)?n.issues.push(..._(r,e.issues)):n.issues.push({code:`invalid_key`,origin:`map`,input:i,inst:a,issues:e.issues.map(e=>v(e,o,c()))})),t.issues.length&&(Ee.has(typeof r)?n.issues.push(..._(r,t.issues)):n.issues.push({origin:`map`,code:`invalid_element`,input:i,inst:a,key:r,issues:t.issues.map(e=>v(e,o,c()))})),n.value.set(e.value,t.value)}const bi=r(`$ZodSet`,(e,t)=>{x.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!(i instanceof Set))return n.issues.push({input:i,inst:e,expected:`set`,code:`invalid_type`}),n;let a=[];n.value=new Set;for(let e of i){let i=t.valueType._zod.run({value:e,issues:[]},r);i instanceof Promise?a.push(i.then(e=>xi(e,n))):xi(i,n)}return a.length?Promise.all(a).then(()=>n):n}});function xi(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}const Si=r(`$ZodEnum`,(e,t)=>{x.init(e,t);let n=ie(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Ee.has(typeof e)).map(e=>typeof e==`string`?m(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Ci=r(`$ZodLiteral`,(e,t)=>{if(x.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?m(e):e?m(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),wi=r(`$ZodFile`,(e,t)=>{x.init(e,t),e._zod.parse=(t,n)=>{let r=t.value;return r instanceof File||t.issues.push({expected:`file`,code:`invalid_type`,input:r,inst:e}),t}}),Ti=r(`$ZodTransform`,(e,t)=>{x.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new o(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new a;return n.value=i,n}});function Ei(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Di=r(`$ZodOptional`,(e,t)=>{x.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,d(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),d(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${le(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>Ei(t,e.value)):Ei(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Oi=r(`$ZodExactOptional`,(e,t)=>{Di.init(e,t),d(e._zod,`values`,()=>t.innerType._zod.values),d(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),ki=r(`$ZodNullable`,(e,t)=>{x.init(e,t),d(e._zod,`optin`,()=>t.innerType._zod.optin),d(e._zod,`optout`,()=>t.innerType._zod.optout),d(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${le(e.source)}|null)$`):void 0}),d(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Ai=r(`$ZodDefault`,(e,t)=>{x.init(e,t),e._zod.optin=`optional`,d(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>ji(e,t)):ji(r,t)}});function ji(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Mi=r(`$ZodPrefault`,(e,t)=>{x.init(e,t),e._zod.optin=`optional`,d(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Ni=r(`$ZodNonOptional`,(e,t)=>{x.init(e,t),d(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Pi(t,e)):Pi(i,e)}});function Pi(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}const Fi=r(`$ZodSuccess`,(e,t)=>{x.init(e,t),e._zod.parse=(e,n)=>{if(n.direction===`backward`)throw new o(`ZodSuccess`);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>(e.value=t.issues.length===0,e)):(e.value=r.issues.length===0,e)}}),Ii=r(`$ZodCatch`,(e,t)=>{x.init(e,t),d(e._zod,`optin`,()=>t.innerType._zod.optin),d(e._zod,`optout`,()=>t.innerType._zod.optout),d(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>v(e,n,c()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>v(e,n,c()))},input:e.value}),e.issues=[]),e)}}),Li=r(`$ZodNaN`,(e,t)=>{x.init(e,t),e._zod.parse=(t,n)=>((typeof t.value!=`number`||!Number.isNaN(t.value))&&t.issues.push({input:t.value,inst:e,expected:`nan`,code:`invalid_type`}),t)}),Ri=r(`$ZodPipe`,(e,t)=>{x.init(e,t),d(e._zod,`values`,()=>t.in._zod.values),d(e._zod,`optin`,()=>t.in._zod.optin),d(e._zod,`optout`,()=>t.out._zod.optout),d(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>zi(e,t.in,n)):zi(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>zi(e,t.out,n)):zi(r,t.out,n)}});function zi(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Bi=r(`$ZodCodec`,(e,t)=>{x.init(e,t),d(e._zod,`values`,()=>t.in._zod.values),d(e._zod,`optin`,()=>t.in._zod.optin),d(e._zod,`optout`,()=>t.out._zod.optout),d(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if((n.direction||`forward`)===`forward`){let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Vi(e,t,n)):Vi(r,t,n)}else{let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Vi(e,t,n)):Vi(r,t,n)}}});function Vi(e,t,n){if(e.issues.length)return e.aborted=!0,e;if((n.direction||`forward`)===`forward`){let r=t.transform(e.value,e);return r instanceof Promise?r.then(r=>Hi(e,r,t.out,n)):Hi(e,r,t.out,n)}else{let r=t.reverseTransform(e.value,e);return r instanceof Promise?r.then(r=>Hi(e,r,t.in,n)):Hi(e,r,t.in,n)}}function Hi(e,t,n,r){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},r)}const Ui=r(`$ZodReadonly`,(e,t)=>{x.init(e,t),d(e._zod,`propValues`,()=>t.innerType._zod.propValues),d(e._zod,`values`,()=>t.innerType._zod.values),d(e._zod,`optin`,()=>t.innerType?._zod?.optin),d(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Wi):Wi(r)}});function Wi(e){return e.value=Object.freeze(e.value),e}const Gi=r(`$ZodTemplateLiteral`,(e,t)=>{x.init(e,t);let n=[];for(let e of t.parts)if(typeof e==`object`&&e){if(!e._zod.pattern)throw Error(`Invalid template literal part, no pattern found: ${[...e._zod.traits].shift()}`);let t=e._zod.pattern instanceof RegExp?e._zod.pattern.source:e._zod.pattern;if(!t)throw Error(`Invalid template literal part: ${e._zod.traits}`);let r=+!!t.startsWith(`^`),i=t.endsWith(`$`)?t.length-1:t.length;n.push(t.slice(r,i))}else if(e===null||De.has(typeof e))n.push(m(`${e}`));else throw Error(`Invalid template literal part: ${e}`);e._zod.pattern=RegExp(`^${n.join(``)}$`),e._zod.parse=(n,r)=>typeof n.value==`string`?(e._zod.pattern.lastIndex=0,e._zod.pattern.test(n.value)||n.issues.push({input:n.value,inst:e,code:`invalid_format`,format:t.format??`template_literal`,pattern:e._zod.pattern.source}),n):(n.issues.push({input:n.value,inst:e,expected:`string`,code:`invalid_type`}),n)}),Ki=r(`$ZodFunction`,(e,t)=>(x.init(e,t),e._def=t,e._zod.def=t,e.implement=t=>{if(typeof t!=`function`)throw Error(`implement() must be called with a function`);return function(...n){let r=e._def.input?ct(e._def.input,n):n,i=Reflect.apply(t,this,r);return e._def.output?ct(e._def.output,i):i}},e.implementAsync=t=>{if(typeof t!=`function`)throw Error(`implementAsync() must be called with a function`);return async function(...n){let r=e._def.input?await ut(e._def.input,n):n,i=await Reflect.apply(t,this,r);return e._def.output?await ut(e._def.output,i):i}},e._zod.parse=(t,n)=>typeof t.value==`function`?(e._def.output&&e._def.output._zod.def.type===`promise`?t.value=e.implementAsync(t.value):t.value=e.implement(t.value),t):(t.issues.push({code:`invalid_type`,expected:`function`,input:t.value,inst:e}),t),e.input=(...t)=>{let n=e.constructor;return Array.isArray(t[0])?new n({type:`function`,input:new hi({type:`tuple`,items:t[0],rest:t[1]}),output:e._def.output}):new n({type:`function`,input:t[0],output:e._def.output})},e.output=t=>{let n=e.constructor;return new n({type:`function`,input:e._def.input,output:t})},e)),qi=r(`$ZodPromise`,(e,t)=>{x.init(e,t),e._zod.parse=(e,n)=>Promise.resolve(e.value).then(e=>t.innerType._zod.run({value:e,issues:[]},n))}),Ji=r(`$ZodLazy`,(e,t)=>{x.init(e,t),d(e._zod,`innerType`,()=>t.getter()),d(e._zod,`pattern`,()=>e._zod.innerType?._zod?.pattern),d(e._zod,`propValues`,()=>e._zod.innerType?._zod?.propValues),d(e._zod,`optin`,()=>e._zod.innerType?._zod?.optin??void 0),d(e._zod,`optout`,()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),Yi=r(`$ZodCustom`,(e,t)=>{b.init(e,t),x.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Xi(t,n,r,e));Xi(i,n,r,e)}});function Xi(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Ge(e))}}var Zi;const Qi=Symbol(`ZodOutput`),$i=Symbol(`ZodInput`);var ea=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function ta(){return new ea}(Zi=globalThis).__zod_globalRegistry??(Zi.__zod_globalRegistry=ta());const C=globalThis.__zod_globalRegistry;function na(e,t){return new e({type:`string`,...g(t)})}function ra(e,t){return new e({type:`string`,coerce:!0,...g(t)})}function ia(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...g(t)})}function aa(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...g(t)})}function oa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...g(t)})}function sa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...g(t)})}function ca(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...g(t)})}function la(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...g(t)})}function ua(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...g(t)})}function da(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...g(t)})}function fa(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...g(t)})}function pa(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...g(t)})}function ma(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...g(t)})}function ha(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...g(t)})}function ga(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...g(t)})}function _a(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...g(t)})}function va(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...g(t)})}function ya(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...g(t)})}function ba(e,t){return new e({type:`string`,format:`mac`,check:`string_format`,abort:!1,...g(t)})}function xa(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...g(t)})}function Sa(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...g(t)})}function Ca(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...g(t)})}function wa(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...g(t)})}function Ta(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...g(t)})}function Ea(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...g(t)})}const Da={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function Oa(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...g(t)})}function ka(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...g(t)})}function Aa(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...g(t)})}function ja(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...g(t)})}function Ma(e,t){return new e({type:`number`,checks:[],...g(t)})}function Na(e,t){return new e({type:`number`,coerce:!0,checks:[],...g(t)})}function Pa(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...g(t)})}function Fa(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`float32`,...g(t)})}function Ia(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`float64`,...g(t)})}function La(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`int32`,...g(t)})}function Ra(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`uint32`,...g(t)})}function za(e,t){return new e({type:`boolean`,...g(t)})}function Ba(e,t){return new e({type:`boolean`,coerce:!0,...g(t)})}function Va(e,t){return new e({type:`bigint`,...g(t)})}function Ha(e,t){return new e({type:`bigint`,coerce:!0,...g(t)})}function Ua(e,t){return new e({type:`bigint`,check:`bigint_format`,abort:!1,format:`int64`,...g(t)})}function Wa(e,t){return new e({type:`bigint`,check:`bigint_format`,abort:!1,format:`uint64`,...g(t)})}function Ga(e,t){return new e({type:`symbol`,...g(t)})}function Ka(e,t){return new e({type:`undefined`,...g(t)})}function qa(e,t){return new e({type:`null`,...g(t)})}function Ja(e){return new e({type:`any`})}function Ya(e){return new e({type:`unknown`})}function Xa(e,t){return new e({type:`never`,...g(t)})}function Za(e,t){return new e({type:`void`,...g(t)})}function Qa(e,t){return new e({type:`date`,...g(t)})}function $a(e,t){return new e({type:`date`,coerce:!0,...g(t)})}function eo(e,t){return new e({type:`nan`,...g(t)})}function to(e,t){return new Hn({check:`less_than`,...g(t),value:e,inclusive:!1})}function w(e,t){return new Hn({check:`less_than`,...g(t),value:e,inclusive:!0})}function no(e,t){return new Un({check:`greater_than`,...g(t),value:e,inclusive:!1})}function T(e,t){return new Un({check:`greater_than`,...g(t),value:e,inclusive:!0})}function ro(e){return no(0,e)}function io(e){return to(0,e)}function ao(e){return w(0,e)}function oo(e){return T(0,e)}function so(e,t){return new Wn({check:`multiple_of`,...g(t),value:e})}function co(e,t){return new qn({check:`max_size`,...g(t),maximum:e})}function lo(e,t){return new Jn({check:`min_size`,...g(t),minimum:e})}function uo(e,t){return new Yn({check:`size_equals`,...g(t),size:e})}function fo(e,t){return new Xn({check:`max_length`,...g(t),maximum:e})}function po(e,t){return new Zn({check:`min_length`,...g(t),minimum:e})}function mo(e,t){return new Qn({check:`length_equals`,...g(t),length:e})}function ho(e,t){return new er({check:`string_format`,format:`regex`,...g(t),pattern:e})}function go(e){return new tr({check:`string_format`,format:`lowercase`,...g(e)})}function _o(e){return new nr({check:`string_format`,format:`uppercase`,...g(e)})}function vo(e,t){return new rr({check:`string_format`,format:`includes`,...g(t),includes:e})}function yo(e,t){return new ir({check:`string_format`,format:`starts_with`,...g(t),prefix:e})}function bo(e,t){return new ar({check:`string_format`,format:`ends_with`,...g(t),suffix:e})}function xo(e,t,n){return new sr({check:`property`,property:e,schema:t,...g(n)})}function So(e,t){return new cr({check:`mime_type`,mime:e,...g(t)})}function Co(e){return new lr({check:`overwrite`,tx:e})}function wo(e){return Co(t=>t.normalize(e))}function To(){return Co(e=>e.trim())}function Eo(){return Co(e=>e.toLowerCase())}function Do(){return Co(e=>e.toUpperCase())}function Oo(){return Co(e=>ve(e))}function ko(e,t,n){return new e({type:`array`,element:t,...g(n)})}function Ao(e,t,n){return new e({type:`union`,options:t,...g(n)})}function jo(e,t,n){return new e({type:`union`,options:t,inclusive:!1,...g(n)})}function Mo(e,t,n,r){return new e({type:`union`,options:n,discriminator:t,...g(r)})}function No(e,t,n){return new e({type:`intersection`,left:t,right:n})}function Po(e,t,n,r){let i=n instanceof x;return new e({type:`tuple`,items:t,rest:i?n:null,...g(i?r:n)})}function Fo(e,t,n,r){return new e({type:`record`,keyType:t,valueType:n,...g(r)})}function Io(e,t,n,r){return new e({type:`map`,keyType:t,valueType:n,...g(r)})}function Lo(e,t,n){return new e({type:`set`,valueType:t,...g(n)})}function Ro(e,t,n){return new e({type:`enum`,entries:Array.isArray(t)?Object.fromEntries(t.map(e=>[e,e])):t,...g(n)})}function zo(e,t,n){return new e({type:`enum`,entries:t,...g(n)})}function Bo(e,t,n){return new e({type:`literal`,values:Array.isArray(t)?t:[t],...g(n)})}function Vo(e,t){return new e({type:`file`,...g(t)})}function Ho(e,t){return new e({type:`transform`,transform:t})}function Uo(e,t){return new e({type:`optional`,innerType:t})}function Wo(e,t){return new e({type:`nullable`,innerType:t})}function Go(e,t,n){return new e({type:`default`,innerType:t,get defaultValue(){return typeof n==`function`?n():Ce(n)}})}function Ko(e,t,n){return new e({type:`nonoptional`,innerType:t,...g(n)})}function qo(e,t){return new e({type:`success`,innerType:t})}function Jo(e,t,n){return new e({type:`catch`,innerType:t,catchValue:typeof n==`function`?n:()=>n})}function Yo(e,t,n){return new e({type:`pipe`,in:t,out:n})}function Xo(e,t){return new e({type:`readonly`,innerType:t})}function Zo(e,t,n){return new e({type:`template_literal`,parts:t,...g(n)})}function Qo(e,t){return new e({type:`lazy`,getter:t})}function $o(e,t){return new e({type:`promise`,innerType:t})}function es(e,t,n){let r=g(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function ts(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...g(n)})}function ns(e){let t=rs(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(Ge(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(Ge(r))}},e(n.value,n)));return t}function rs(e,t){let n=new b({check:`custom`,...g(t)});return n._zod.check=e,n}function is(e){let t=new b({check:`describe`});return t._zod.onattach=[t=>{let n=C.get(t)??{};C.add(t,{...n,description:e})}],t._zod.check=()=>{},t}function as(e){let t=new b({check:`meta`});return t._zod.onattach=[t=>{let n=C.get(t)??{};C.add(t,{...n,...e})}],t._zod.check=()=>{},t}function os(e,t){let n=g(t),r=n.truthy??[`true`,`1`,`yes`,`on`,`y`,`enabled`],i=n.falsy??[`false`,`0`,`no`,`off`,`n`,`disabled`];n.case!==`sensitive`&&(r=r.map(e=>typeof e==`string`?e.toLowerCase():e),i=i.map(e=>typeof e==`string`?e.toLowerCase():e));let a=new Set(r),o=new Set(i),s=e.Codec??Bi,c=e.Boolean??Ur,l=new s({type:`pipe`,in:new(e.String??fr)({type:`string`,error:n.error}),out:new c({type:`boolean`,error:n.error}),transform:((e,t)=>{let r=e;return n.case!==`sensitive`&&(r=r.toLowerCase()),a.has(r)?!0:o.has(r)?!1:(t.issues.push({code:`invalid_value`,expected:`stringbool`,values:[...a,...o],input:t.value,inst:l,continue:!1}),{})}),reverseTransform:((e,t)=>e===!0?r[0]||`true`:i[0]||`false`),error:n.error});return l}function ss(e,t,n,r={}){let i=g(r),a={...g(r),check:`string_format`,type:`string`,format:t,fn:typeof n==`function`?n:e=>n.test(e),...i};return n instanceof RegExp&&(a.pattern=n),new e(a)}function cs(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??C,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function E(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,E(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&D(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function ls(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
39
39
 
40
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function us(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:fs(t,`input`,e.processors),output:fs(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function D(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return D(r.element,n);if(r.type===`set`)return D(r.valueType,n);if(r.type===`lazy`)return D(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return D(r.innerType,n);if(r.type===`intersection`)return D(r.left,n)||D(r.right,n);if(r.type===`record`||r.type===`map`)return D(r.keyType,n)||D(r.valueType,n);if(r.type===`pipe`)return D(r.in,n)||D(r.out,n);if(r.type===`object`){for(let e in r.shape)if(D(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(D(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(D(e,n))return!0;return!!(r.rest&&D(r.rest,n))}return!1}const ds=(e,t={})=>n=>{let r=cs({...n,processors:t});return E(e,r),ls(r,e),us(r,e)},fs=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=cs({...i??{},target:a,io:t,processors:n});return E(e,o),ls(o,e),us(o,e)},ps={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},ms=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=ps[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},hs=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},gs=(e,t,n,r)=>{n.type=`boolean`},_s=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`BigInt cannot be represented in JSON Schema`)},vs=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Symbols cannot be represented in JSON Schema`)},ys=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},bs=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},xs=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Void cannot be represented in JSON Schema`)},Ss=(e,t,n,r)=>{n.not={}},Cs=(e,t,n,r)=>{},ws=(e,t,n,r)=>{},Ts=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Date cannot be represented in JSON Schema`)},Es=(e,t,n,r)=>{let i=e._zod.def,a=ie(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Ds=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},Os=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`NaN cannot be represented in JSON Schema`)},ks=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},As=(e,t,n,r)=>{let i=n,a={type:`string`,format:`binary`,contentEncoding:`binary`},{minimum:o,maximum:s,mime:c}=e._zod.bag;o!==void 0&&(a.minLength=o),s!==void 0&&(a.maxLength=s),c?c.length===1?(a.contentMediaType=c[0],Object.assign(i,a)):(Object.assign(i,a),i.anyOf=c.map(e=>({contentMediaType:e}))):Object.assign(i,a)},js=(e,t,n,r)=>{n.type=`boolean`},Ms=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Ns=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Function types cannot be represented in JSON Schema`)},Ps=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Fs=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Map cannot be represented in JSON Schema`)},Is=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Set cannot be represented in JSON Schema`)},Ls=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=E(a.element,t,{...r,path:[...r.path,`items`]})},Rs=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=E(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=E(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},zs=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>E(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Bs=(e,t,n,r)=>{let i=e._zod.def,a=E(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=E(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Vs=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>E(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?E(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:ee}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof ee==`number`&&(i.maxItems=ee)},Hs=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=E(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=E(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=E(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Us=(e,t,n,r)=>{let i=e._zod.def,a=E(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Ws=(e,t,n,r)=>{let i=e._zod.def;E(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Gs=(e,t,n,r)=>{let i=e._zod.def;E(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Ks=(e,t,n,r)=>{let i=e._zod.def;E(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},qs=(e,t,n,r)=>{let i=e._zod.def;E(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Js=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;E(a,t,r);let o=t.seen.get(e);o.ref=a},Ys=(e,t,n,r)=>{let i=e._zod.def;E(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Xs=(e,t,n,r)=>{let i=e._zod.def;E(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Zs=(e,t,n,r)=>{let i=e._zod.def;E(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Qs=(e,t,n,r)=>{let i=e._zod.innerType;E(i,t,r);let a=t.seen.get(e);a.ref=i},$s={string:ms,number:hs,boolean:gs,bigint:_s,symbol:vs,null:ys,undefined:bs,void:xs,never:Ss,any:Cs,unknown:ws,date:Ts,enum:Es,literal:Ds,nan:Os,template_literal:ks,file:As,success:js,custom:Ms,function:Ns,transform:Ps,map:Fs,set:Is,array:Ls,object:Rs,union:zs,intersection:Bs,tuple:Vs,record:Hs,nullable:Us,nonoptional:Ws,default:Gs,prefault:Ks,catch:qs,pipe:Js,readonly:Ys,promise:Xs,optional:Zs,lazy:Qs};function ec(e,t){if(`_idmap`in e){let n=e,r=cs({...t,processors:$s}),i={};for(let e of n._idmap.entries()){let[t,n]=e;E(n,r)}let a={};r.external={registry:n,uri:t?.uri,defs:i};for(let e of n._idmap.entries()){let[t,n]=e;ls(r,n),a[t]=us(r,n)}return Object.keys(i).length>0&&(a.__shared={[r.target===`draft-2020-12`?`$defs`:`definitions`]:i}),{schemas:a}}let n=cs({...t,processors:$s});return E(e,n),ls(n,e),us(n,e)}var tc=e({ZodISODate:()=>ic,ZodISODateTime:()=>nc,ZodISODuration:()=>cc,ZodISOTime:()=>oc,date:()=>ac,datetime:()=>rc,duration:()=>lc,time:()=>sc});const nc=r(`ZodISODateTime`,(e,t)=>{wr.init(e,t),j.init(e,t)});function rc(e){return Oa(nc,e)}const ic=r(`ZodISODate`,(e,t)=>{Tr.init(e,t),j.init(e,t)});function ac(e){return ka(ic,e)}const oc=r(`ZodISOTime`,(e,t)=>{Er.init(e,t),j.init(e,t)});function sc(e){return Aa(oc,e)}const cc=r(`ZodISODuration`,(e,t)=>{Dr.init(e,t),j.init(e,t)});function lc(e){return ja(cc,e)}const uc=(e,t)=>{tt.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>rt(e,t)},flatten:{value:t=>nt(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,oe,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,oe,2)}},isEmpty:{get(){return e.issues.length===0}}})},dc=r(`ZodError`,uc),O=r(`ZodError`,uc,{Parent:Error}),fc=st(O),pc=lt(O),mc=dt(O),hc=pt(O),gc=ht(O),_c=_t(O),vc=yt(O),yc=xt(O),bc=Ct(O),xc=Tt(O),Sc=Dt(O),Cc=kt(O);var wc=e({ZodAny:()=>zl,ZodArray:()=>Jl,ZodBase64:()=>cl,ZodBase64URL:()=>ul,ZodBigInt:()=>kl,ZodBigIntFormat:()=>jl,ZodBoolean:()=>Ol,ZodCIDRv4:()=>il,ZodCIDRv6:()=>ol,ZodCUID:()=>Hc,ZodCUID2:()=>Wc,ZodCatch:()=>Lu,ZodCodec:()=>Uu,ZodCustom:()=>td,ZodCustomStringFormat:()=>gl,ZodDate:()=>Kl,ZodDefault:()=>ku,ZodDiscriminatedUnion:()=>nu,ZodE164:()=>fl,ZodEmail:()=>Dc,ZodEmoji:()=>Rc,ZodEnum:()=>hu,ZodExactOptional:()=>wu,ZodFile:()=>vu,ZodFunction:()=>$u,ZodGUID:()=>kc,ZodIPv4:()=>Qc,ZodIPv6:()=>nl,ZodIntersection:()=>iu,ZodJWT:()=>ml,ZodKSUID:()=>Xc,ZodLazy:()=>Yu,ZodLiteral:()=>_u,ZodMAC:()=>el,ZodMap:()=>du,ZodNaN:()=>zu,ZodNanoID:()=>Bc,ZodNever:()=>Hl,ZodNonOptional:()=>Nu,ZodNull:()=>Ll,ZodNullable:()=>Eu,ZodNumber:()=>xl,ZodNumberFormat:()=>Sl,ZodObject:()=>Xl,ZodOptional:()=>Su,ZodPipe:()=>Vu,ZodPrefault:()=>ju,ZodPromise:()=>Zu,ZodReadonly:()=>Gu,ZodRecord:()=>cu,ZodSet:()=>pu,ZodString:()=>Ec,ZodStringFormat:()=>j,ZodSuccess:()=>Fu,ZodSymbol:()=>Pl,ZodTemplateLiteral:()=>qu,ZodTransform:()=>bu,ZodTuple:()=>ou,ZodType:()=>k,ZodULID:()=>Kc,ZodURL:()=>Fc,ZodUUID:()=>M,ZodUndefined:()=>Il,ZodUnion:()=>$l,ZodUnknown:()=>Vl,ZodVoid:()=>Wl,ZodXID:()=>Jc,ZodXor:()=>eu,_ZodString:()=>Tc,_default:()=>Au,_function:()=>ed,any:()=>Bl,array:()=>L,base64:()=>ll,base64url:()=>dl,bigint:()=>Al,boolean:()=>P,catch:()=>Ru,check:()=>nd,cidrv4:()=>al,cidrv6:()=>sl,codec:()=>Wu,cuid:()=>Uc,cuid2:()=>Gc,custom:()=>rd,date:()=>ql,describe:()=>od,discriminatedUnion:()=>ru,e164:()=>pl,email:()=>Oc,emoji:()=>zc,enum:()=>V,exactOptional:()=>Tu,file:()=>yu,float32:()=>wl,float64:()=>Tl,function:()=>ed,guid:()=>Ac,hash:()=>bl,hex:()=>yl,hostname:()=>vl,httpUrl:()=>Lc,instanceof:()=>cd,int:()=>Cl,int32:()=>El,int64:()=>Ml,intersection:()=>au,ipv4:()=>$c,ipv6:()=>rl,json:()=>ud,jwt:()=>hl,keyof:()=>Yl,ksuid:()=>Zc,lazy:()=>Xu,literal:()=>H,looseObject:()=>Ql,looseRecord:()=>uu,mac:()=>tl,map:()=>fu,meta:()=>sd,nan:()=>Bu,nanoid:()=>Vc,nativeEnum:()=>gu,never:()=>Ul,nonoptional:()=>Pu,null:()=>Rl,nullable:()=>Du,nullish:()=>Ou,number:()=>N,object:()=>R,optional:()=>Cu,partialRecord:()=>lu,pipe:()=>Hu,prefault:()=>Mu,preprocess:()=>dd,promise:()=>Qu,readonly:()=>Ku,record:()=>B,refine:()=>id,set:()=>mu,strictObject:()=>Zl,string:()=>A,stringFormat:()=>_l,stringbool:()=>ld,success:()=>Iu,superRefine:()=>ad,symbol:()=>Fl,templateLiteral:()=>Ju,transform:()=>xu,tuple:()=>su,uint32:()=>Dl,uint64:()=>Nl,ulid:()=>qc,undefined:()=>F,union:()=>z,unknown:()=>I,url:()=>Ic,uuid:()=>jc,uuidv4:()=>Mc,uuidv6:()=>Nc,uuidv7:()=>Pc,void:()=>Gl,xid:()=>Yc,xor:()=>tu});const k=r(`ZodType`,(e,t)=>(x.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:fs(e,`input`),output:fs(e,`output`)}}),e.toJSONSchema=ds(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(p(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>h(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>fc(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>mc(e,t,n),e.parseAsync=async(t,n)=>pc(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>hc(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>gc(e,t,n),e.decode=(t,n)=>_c(e,t,n),e.encodeAsync=async(t,n)=>vc(e,t,n),e.decodeAsync=async(t,n)=>yc(e,t,n),e.safeEncode=(t,n)=>bc(e,t,n),e.safeDecode=(t,n)=>xc(e,t,n),e.safeEncodeAsync=async(t,n)=>Sc(e,t,n),e.safeDecodeAsync=async(t,n)=>Cc(e,t,n),e.refine=(t,n)=>e.check(id(t,n)),e.superRefine=t=>e.check(ad(t)),e.overwrite=t=>e.check(Co(t)),e.optional=()=>Cu(e),e.exactOptional=()=>Tu(e),e.nullable=()=>Du(e),e.nullish=()=>Cu(Du(e)),e.nonoptional=t=>Pu(e,t),e.array=()=>L(e),e.or=t=>z([e,t]),e.and=t=>au(e,t),e.transform=t=>Hu(e,xu(t)),e.default=t=>Au(e,t),e.prefault=t=>Mu(e,t),e.catch=t=>Ru(e,t),e.pipe=t=>Hu(e,t),e.readonly=()=>Ku(e),e.describe=t=>{let n=e.clone();return C.add(n,{description:t}),n},Object.defineProperty(e,"description",{get(){return C.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return C.get(e);let n=e.clone();return C.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),Tc=r(`_ZodString`,(e,t)=>{fr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(ho(...t)),e.includes=(...t)=>e.check(vo(...t)),e.startsWith=(...t)=>e.check(yo(...t)),e.endsWith=(...t)=>e.check(bo(...t)),e.min=(...t)=>e.check(po(...t)),e.max=(...t)=>e.check(fo(...t)),e.length=(...t)=>e.check(mo(...t)),e.nonempty=(...t)=>e.check(po(1,...t)),e.lowercase=t=>e.check(go(t)),e.uppercase=t=>e.check(_o(t)),e.trim=()=>e.check(To()),e.normalize=(...t)=>e.check(wo(...t)),e.toLowerCase=()=>e.check(Eo()),e.toUpperCase=()=>e.check(Do()),e.slugify=()=>e.check(Oo())}),Ec=r(`ZodString`,(e,t)=>{fr.init(e,t),Tc.init(e,t),e.email=t=>e.check(ia(Dc,t)),e.url=t=>e.check(ua(Fc,t)),e.jwt=t=>e.check(Ea(ml,t)),e.emoji=t=>e.check(da(Rc,t)),e.guid=t=>e.check(aa(kc,t)),e.uuid=t=>e.check(oa(M,t)),e.uuidv4=t=>e.check(sa(M,t)),e.uuidv6=t=>e.check(ca(M,t)),e.uuidv7=t=>e.check(la(M,t)),e.nanoid=t=>e.check(fa(Bc,t)),e.guid=t=>e.check(aa(kc,t)),e.cuid=t=>e.check(pa(Hc,t)),e.cuid2=t=>e.check(ma(Wc,t)),e.ulid=t=>e.check(ha(Kc,t)),e.base64=t=>e.check(Ca(cl,t)),e.base64url=t=>e.check(wa(ul,t)),e.xid=t=>e.check(ga(Jc,t)),e.ksuid=t=>e.check(_a(Xc,t)),e.ipv4=t=>e.check(va(Qc,t)),e.ipv6=t=>e.check(ya(nl,t)),e.cidrv4=t=>e.check(xa(il,t)),e.cidrv6=t=>e.check(Sa(ol,t)),e.e164=t=>e.check(Ta(fl,t)),e.datetime=t=>e.check(rc(t)),e.date=t=>e.check(ac(t)),e.time=t=>e.check(sc(t)),e.duration=t=>e.check(lc(t))});function A(e){return na(Ec,e)}const j=r(`ZodStringFormat`,(e,t)=>{S.init(e,t),Tc.init(e,t)}),Dc=r(`ZodEmail`,(e,t)=>{hr.init(e,t),j.init(e,t)});function Oc(e){return ia(Dc,e)}const kc=r(`ZodGUID`,(e,t)=>{pr.init(e,t),j.init(e,t)});function Ac(e){return aa(kc,e)}const M=r(`ZodUUID`,(e,t)=>{mr.init(e,t),j.init(e,t)});function jc(e){return oa(M,e)}function Mc(e){return sa(M,e)}function Nc(e){return ca(M,e)}function Pc(e){return la(M,e)}const Fc=r(`ZodURL`,(e,t)=>{gr.init(e,t),j.init(e,t)});function Ic(e){return ua(Fc,e)}function Lc(e){return ua(Fc,{protocol:/^https?$/,hostname:sn,...g(e)})}const Rc=r(`ZodEmoji`,(e,t)=>{_r.init(e,t),j.init(e,t)});function zc(e){return da(Rc,e)}const Bc=r(`ZodNanoID`,(e,t)=>{vr.init(e,t),j.init(e,t)});function Vc(e){return fa(Bc,e)}const Hc=r(`ZodCUID`,(e,t)=>{yr.init(e,t),j.init(e,t)});function Uc(e){return pa(Hc,e)}const Wc=r(`ZodCUID2`,(e,t)=>{br.init(e,t),j.init(e,t)});function Gc(e){return ma(Wc,e)}const Kc=r(`ZodULID`,(e,t)=>{xr.init(e,t),j.init(e,t)});function qc(e){return ha(Kc,e)}const Jc=r(`ZodXID`,(e,t)=>{Sr.init(e,t),j.init(e,t)});function Yc(e){return ga(Jc,e)}const Xc=r(`ZodKSUID`,(e,t)=>{Cr.init(e,t),j.init(e,t)});function Zc(e){return _a(Xc,e)}const Qc=r(`ZodIPv4`,(e,t)=>{Or.init(e,t),j.init(e,t)});function $c(e){return va(Qc,e)}const el=r(`ZodMAC`,(e,t)=>{Ar.init(e,t),j.init(e,t)});function tl(e){return ba(el,e)}const nl=r(`ZodIPv6`,(e,t)=>{kr.init(e,t),j.init(e,t)});function rl(e){return ya(nl,e)}const il=r(`ZodCIDRv4`,(e,t)=>{jr.init(e,t),j.init(e,t)});function al(e){return xa(il,e)}const ol=r(`ZodCIDRv6`,(e,t)=>{Mr.init(e,t),j.init(e,t)});function sl(e){return Sa(ol,e)}const cl=r(`ZodBase64`,(e,t)=>{Pr.init(e,t),j.init(e,t)});function ll(e){return Ca(cl,e)}const ul=r(`ZodBase64URL`,(e,t)=>{Ir.init(e,t),j.init(e,t)});function dl(e){return wa(ul,e)}const fl=r(`ZodE164`,(e,t)=>{Lr.init(e,t),j.init(e,t)});function pl(e){return Ta(fl,e)}const ml=r(`ZodJWT`,(e,t)=>{zr.init(e,t),j.init(e,t)});function hl(e){return Ea(ml,e)}const gl=r(`ZodCustomStringFormat`,(e,t)=>{Br.init(e,t),j.init(e,t)});function _l(e,t,n={}){return ss(gl,e,t,n)}function vl(e){return ss(gl,`hostname`,on,e)}function yl(e){return ss(gl,`hex`,Cn,e)}function bl(e,t){let n=`${e}_${t?.enc??`hex`}`,r=jt[n];if(!r)throw Error(`Unrecognized hash format: ${n}`);return ss(gl,n,r,t)}const xl=r(`ZodNumber`,(e,t)=>{Vr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r),e.gt=(t,n)=>e.check(no(t,n)),e.gte=(t,n)=>e.check(T(t,n)),e.min=(t,n)=>e.check(T(t,n)),e.lt=(t,n)=>e.check(to(t,n)),e.lte=(t,n)=>e.check(w(t,n)),e.max=(t,n)=>e.check(w(t,n)),e.int=t=>e.check(Cl(t)),e.safe=t=>e.check(Cl(t)),e.positive=t=>e.check(no(0,t)),e.nonnegative=t=>e.check(T(0,t)),e.negative=t=>e.check(to(0,t)),e.nonpositive=t=>e.check(w(0,t)),e.multipleOf=(t,n)=>e.check(so(t,n)),e.step=(t,n)=>e.check(so(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function N(e){return Ma(xl,e)}const Sl=r(`ZodNumberFormat`,(e,t)=>{Hr.init(e,t),xl.init(e,t)});function Cl(e){return Pa(Sl,e)}function wl(e){return Fa(Sl,e)}function Tl(e){return Ia(Sl,e)}function El(e){return La(Sl,e)}function Dl(e){return Ra(Sl,e)}const Ol=r(`ZodBoolean`,(e,t)=>{Ur.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gs(e,t,n,r)});function P(e){return za(Ol,e)}const kl=r(`ZodBigInt`,(e,t)=>{Wr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_s(e,t,n,r),e.gte=(t,n)=>e.check(T(t,n)),e.min=(t,n)=>e.check(T(t,n)),e.gt=(t,n)=>e.check(no(t,n)),e.gte=(t,n)=>e.check(T(t,n)),e.min=(t,n)=>e.check(T(t,n)),e.lt=(t,n)=>e.check(to(t,n)),e.lte=(t,n)=>e.check(w(t,n)),e.max=(t,n)=>e.check(w(t,n)),e.positive=t=>e.check(no(BigInt(0),t)),e.negative=t=>e.check(to(BigInt(0),t)),e.nonpositive=t=>e.check(w(BigInt(0),t)),e.nonnegative=t=>e.check(T(BigInt(0),t)),e.multipleOf=(t,n)=>e.check(so(t,n));let n=e._zod.bag;e.minValue=n.minimum??null,e.maxValue=n.maximum??null,e.format=n.format??null});function Al(e){return Va(kl,e)}const jl=r(`ZodBigIntFormat`,(e,t)=>{Gr.init(e,t),kl.init(e,t)});function Ml(e){return Ua(jl,e)}function Nl(e){return Wa(jl,e)}const Pl=r(`ZodSymbol`,(e,t)=>{Kr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vs(e,t,n,r)});function Fl(e){return Ga(Pl,e)}const Il=r(`ZodUndefined`,(e,t)=>{qr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r)});function F(e){return Ka(Il,e)}const Ll=r(`ZodNull`,(e,t)=>{Jr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(e,t,n,r)});function Rl(e){return qa(Ll,e)}const zl=r(`ZodAny`,(e,t)=>{Yr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Bl(){return Ja(zl)}const Vl=r(`ZodUnknown`,(e,t)=>{Xr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function I(){return Ya(Vl)}const Hl=r(`ZodNever`,(e,t)=>{Zr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ss(e,t,n,r)});function Ul(e){return Xa(Hl,e)}const Wl=r(`ZodVoid`,(e,t)=>{Qr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xs(e,t,n,r)});function Gl(e){return Za(Wl,e)}const Kl=r(`ZodDate`,(e,t)=>{$r.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ts(e,t,n,r),e.min=(t,n)=>e.check(T(t,n)),e.max=(t,n)=>e.check(w(t,n));let n=e._zod.bag;e.minDate=n.minimum?new Date(n.minimum):null,e.maxDate=n.maximum?new Date(n.maximum):null});function ql(e){return Qa(Kl,e)}const Jl=r(`ZodArray`,(e,t)=>{ti.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ls(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(po(t,n)),e.nonempty=t=>e.check(po(1,t)),e.max=(t,n)=>e.check(fo(t,n)),e.length=(t,n)=>e.check(mo(t,n)),e.unwrap=()=>e.element});function L(e,t){return ko(Jl,e,t)}function Yl(e){let t=e._zod.def.shape;return V(Object.keys(t))}const Xl=r(`ZodObject`,(e,t)=>{oi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rs(e,t,n,r),d(e,`shape`,()=>t.shape),e.keyof=()=>V(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:I()}),e.loose=()=>e.clone({...e._zod.def,catchall:I()}),e.strict=()=>e.clone({...e._zod.def,catchall:Ul()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Fe(e,t),e.safeExtend=t=>Ie(e,t),e.merge=t=>Le(e,t),e.pick=t=>Ne(e,t),e.omit=t=>Pe(e,t),e.partial=(...t)=>Re(Su,e,t[0]),e.required=(...t)=>ze(Nu,e,t[0])});function R(e,t){let n={type:`object`,shape:e??{},...g(t)};return new Xl(n)}function Zl(e,t){return new Xl({type:`object`,shape:e,catchall:Ul(),...g(t)})}function Ql(e,t){return new Xl({type:`object`,shape:e,catchall:I(),...g(t)})}const $l=r(`ZodUnion`,(e,t)=>{ci.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zs(e,t,n,r),e.options=t.options});function z(e,t){return new $l({type:`union`,options:e,...g(t)})}const eu=r(`ZodXor`,(e,t)=>{$l.init(e,t),ui.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zs(e,t,n,r),e.options=t.options});function tu(e,t){return new eu({type:`union`,options:e,inclusive:!1,...g(t)})}const nu=r(`ZodDiscriminatedUnion`,(e,t)=>{$l.init(e,t),di.init(e,t)});function ru(e,t,n){return new nu({type:`union`,options:t,discriminator:e,...g(n)})}const iu=r(`ZodIntersection`,(e,t)=>{fi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bs(e,t,n,r)});function au(e,t){return new iu({type:`intersection`,left:e,right:t})}const ou=r(`ZodTuple`,(e,t)=>{hi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vs(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})});function su(e,t,n){let r=t instanceof x;return new ou({type:`tuple`,items:e,rest:r?t:null,...g(r?n:t)})}const cu=r(`ZodRecord`,(e,t)=>{_i.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hs(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function B(e,t,n){return new cu({type:`record`,keyType:e,valueType:t,...g(n)})}function lu(e,t,n){let r=h(e);return r._zod.values=void 0,new cu({type:`record`,keyType:r,valueType:t,...g(n)})}function uu(e,t,n){return new cu({type:`record`,keyType:e,valueType:t,mode:`loose`,...g(n)})}const du=r(`ZodMap`,(e,t)=>{vi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fs(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...t)=>e.check(lo(...t)),e.nonempty=t=>e.check(lo(1,t)),e.max=(...t)=>e.check(co(...t)),e.size=(...t)=>e.check(uo(...t))});function fu(e,t,n){return new du({type:`map`,keyType:e,valueType:t,...g(n)})}const pu=r(`ZodSet`,(e,t)=>{bi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Is(e,t,n,r),e.min=(...t)=>e.check(lo(...t)),e.nonempty=t=>e.check(lo(1,t)),e.max=(...t)=>e.check(co(...t)),e.size=(...t)=>e.check(uo(...t))});function mu(e,t){return new pu({type:`set`,valueType:e,...g(t)})}const hu=r(`ZodEnum`,(e,t)=>{Si.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Es(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new hu({...t,checks:[],...g(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new hu({...t,checks:[],...g(r),entries:i})}});function V(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new hu({type:`enum`,entries:n,...g(t)})}function gu(e,t){return new hu({type:`enum`,entries:e,...g(t)})}const _u=r(`ZodLiteral`,(e,t)=>{Ci.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ds(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function H(e,t){return new _u({type:`literal`,values:Array.isArray(e)?e:[e],...g(t)})}const vu=r(`ZodFile`,(e,t)=>{wi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>As(e,t,n,r),e.min=(t,n)=>e.check(lo(t,n)),e.max=(t,n)=>e.check(co(t,n)),e.mime=(t,n)=>e.check(So(Array.isArray(t)?t:[t],n))});function yu(e){return Vo(vu,e)}const bu=r(`ZodTransform`,(e,t)=>{Ti.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ps(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new o(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Ge(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Ge(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function xu(e){return new bu({type:`transform`,transform:e})}const Su=r(`ZodOptional`,(e,t)=>{Di.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Cu(e){return new Su({type:`optional`,innerType:e})}const wu=r(`ZodExactOptional`,(e,t)=>{Oi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Tu(e){return new wu({type:`optional`,innerType:e})}const Eu=r(`ZodNullable`,(e,t)=>{ki.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Us(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Du(e){return new Eu({type:`nullable`,innerType:e})}function Ou(e){return Cu(Du(e))}const ku=r(`ZodDefault`,(e,t)=>{Ai.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Au(e,t){return new ku({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ce(t)}})}const ju=r(`ZodPrefault`,(e,t)=>{Mi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ks(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Mu(e,t){return new ju({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ce(t)}})}const Nu=r(`ZodNonOptional`,(e,t)=>{Ni.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ws(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Pu(e,t){return new Nu({type:`nonoptional`,innerType:e,...g(t)})}const Fu=r(`ZodSuccess`,(e,t)=>{Fi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>js(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Iu(e){return new Fu({type:`success`,innerType:e})}const Lu=r(`ZodCatch`,(e,t)=>{Ii.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ru(e,t){return new Lu({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const zu=r(`ZodNaN`,(e,t)=>{Li.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Os(e,t,n,r)});function Bu(e){return eo(zu,e)}const Vu=r(`ZodPipe`,(e,t)=>{Ri.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Js(e,t,n,r),e.in=t.in,e.out=t.out});function Hu(e,t){return new Vu({type:`pipe`,in:e,out:t})}const Uu=r(`ZodCodec`,(e,t)=>{Vu.init(e,t),Bi.init(e,t)});function Wu(e,t,n){return new Uu({type:`pipe`,in:e,out:t,transform:n.decode,reverseTransform:n.encode})}const Gu=r(`ZodReadonly`,(e,t)=>{Ui.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ys(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ku(e){return new Gu({type:`readonly`,innerType:e})}const qu=r(`ZodTemplateLiteral`,(e,t)=>{Gi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ks(e,t,n,r)});function Ju(e,t){return new qu({type:`template_literal`,parts:e,...g(t)})}const Yu=r(`ZodLazy`,(e,t)=>{Ji.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qs(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function Xu(e){return new Yu({type:`lazy`,getter:e})}const Zu=r(`ZodPromise`,(e,t)=>{qi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qu(e){return new Zu({type:`promise`,innerType:e})}const $u=r(`ZodFunction`,(e,t)=>{Ki.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ns(e,t,n,r)});function ed(e){return new $u({type:`function`,input:Array.isArray(e?.input)?su(e?.input):e?.input??L(I()),output:e?.output??I()})}const td=r(`ZodCustom`,(e,t)=>{Yi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ms(e,t,n,r)});function nd(e){let t=new b({check:`custom`});return t._zod.check=e,t}function rd(e,t){return es(td,e??(()=>!0),t)}function id(e,t={}){return ts(td,e,t)}function ad(e){return ns(e)}const od=is,sd=as;function cd(e,t={}){let n=new td({type:`custom`,check:`custom`,fn:t=>t instanceof e,abort:!0,...g(t)});return n._zod.bag.Class=e,n._zod.check=t=>{t.value instanceof e||t.issues.push({code:`invalid_type`,expected:e.name,input:t.value,inst:n,path:[...n._zod.def.path??[]]})},n}const ld=(...e)=>os({Codec:Uu,Boolean:Ol,String:Ec},...e);function ud(e){let t=Xu(()=>z([A(e),N(),P(),Rl(),L(t),B(A(),t)]));return t}function dd(e,t){return Hu(xu(e),t)}var fd=e({bigint:()=>gd,boolean:()=>hd,date:()=>U,number:()=>md,string:()=>pd});function pd(e){return ra(Ec,e)}function md(e){return Na(xl,e)}function hd(e){return Ba(Ol,e)}function gd(e){return Ha(kl,e)}function U(e){return $a(Kl,e)}const _d=`$rootRunId`,vd=`$parentRunId`,yd=L(R({key:A(),value:z([A(),Rl()])}));var W=class extends Error{constructor(e){super(e),this.name=`AttributeValidationError`}};const bd=e=>new TextEncoder().encode(e).length;function xd(e,t={}){return typeof e==`string`?e.length===0?new W(`Attribute key must not be empty`):e.length>256?new W(`Attribute key length ${e.length} exceeds limit 256: ${JSON.stringify(e.slice(0,32))}…`):!t.allowReservedAttributes&&e.startsWith(`$`)?new W(`Attribute key ${JSON.stringify(e)} starts with reserved prefix "\$" — that namespace is reserved for framework/library code. Set { allowReservedAttributes: true } only if your caller is framework-level.`):null:new W(`Attribute key must be a string, got ${typeof e}`)}function Sd(e){if(e===null)return null;if(typeof e!=`string`)return new W(`Attribute value must be a string or null, got ${typeof e}`);let t=bd(e);return t>256?new W(`Attribute value byte length ${t} exceeds limit 256`):null}function Cd(e,t={}){let n=new Set,r=t.existingKeys===void 0?void 0:t.existingKeys instanceof Set?t.existingKeys:new Set(t.existingKeys),i=0,a=0;for(let o of e){let e=xd(o.key,{allowReservedAttributes:t.allowReservedAttributes});if(e)throw e;let s=Sd(o.value);if(s)throw s;if(n.has(o.key))throw new W(`Attribute key ${JSON.stringify(o.key)} appears more than once in the same batch`);n.add(o.key),o.value===null?(r===void 0||r.has(o.key))&&(a+=1):(r===void 0||!r.has(o.key))&&(i+=1)}let o=(r===void 0?0:r.size)+i-a;if(o>64)throw new W(`Run attribute count would exceed limit 64 (post-merge ${o})`)}function wd(e,t){let n={...e??{}};for(let{key:e,value:r}of t)r===null?delete n[e]:n[e]=r;return n}const G=z([cd(Uint8Array),Bl()]),K=V([`run_created`,`run_started`,`run_completed`,`run_failed`,`run_cancelled`,`attr_set`,`step_created`,`step_completed`,`step_failed`,`step_retrying`,`step_started`,`hook_created`,`hook_received`,`hook_disposed`,`hook_conflict`,`wait_created`,`wait_completed`]);K.extract([`run_created`,`run_started`,`run_completed`,`run_failed`,`run_cancelled`]).options;const Td=K.extract([`run_completed`,`run_failed`,`run_cancelled`]).options;function Ed(e){return Td.includes(e)}const Dd=K.extract([`step_created`,`step_completed`,`step_failed`,`step_retrying`,`step_started`]).options;function Od(e){return Dd.includes(e)}const kd=K.extract([`step_completed`,`step_failed`]).options;function Ad(e){return kd.includes(e)}const jd=K.extract([`hook_created`,`hook_received`,`hook_disposed`]).options;function Md(e){return jd.includes(e)}const Nd=K.extract([`hook_disposed`,`hook_received`]).options;function Pd(e){return Nd.includes(e)}K.extract([`wait_created`,`wait_completed`]).options;const Fd=K.extract([`step_created`,`hook_created`,`wait_created`]).options;function Id(e){return Fd.includes(e)}const Ld={run_created:`input`,run_started:`input`,run_completed:`output`,run_failed:`error`,step_created:`input`,step_started:`input`,step_completed:`result`,step_failed:`error`,step_retrying:`error`,hook_created:`metadata`,hook_received:`payload`},Rd=Object.fromEntries(Object.entries(Ld).map(([e,t])=>[e,[t]]));function zd(e){return Rd[e]??[]}function Bd(e){return Ld[e]}function Vd(e,t){if(t!==`none`||!(`eventData`in e))return e;let n=e.eventData;if(!n||typeof n!=`object`){let{eventData:t,...n}=e;return n}let r=zd(e.eventType);if(r.length===0)return e;let i={...n};for(let e of r)delete i[e];let{eventData:a,...o}=e;return{...o,...Object.keys(i).length>0?{eventData:i}:{}}}const q=R({eventType:K,correlationId:A().optional(),specVersion:N().optional()}),Hd={ttfs:N().optional(),stso:N().optional(),stepCount:N().int().positive().optional(),eventCount:N().int().positive().optional(),rsfs:N().optional(),finalSchedulingReplay:N().optional(),optimizations:L(A()).optional()},Ud=q.extend({eventType:H(`step_completed`),correlationId:A(),eventData:R({stepName:A().optional(),workflowName:A().optional(),result:G,...Hd})}),Wd=q.extend({eventType:H(`step_failed`),correlationId:A(),eventData:R({stepName:A().optional(),error:G,...Hd})}),Gd=q.extend({eventType:H(`step_retrying`),correlationId:A(),eventData:R({stepName:A().optional(),error:G,retryAfter:U().optional()})}),Kd=q.extend({eventType:H(`step_started`),correlationId:A(),eventData:R({stepName:A().optional(),attempt:N().optional(),workflowName:A().optional(),input:G.optional(),ownerMessageId:A().optional()}).optional()}),qd=q.extend({eventType:H(`step_created`),correlationId:A(),eventData:R({stepName:A(),workflowName:A().optional(),input:G})}),Jd=q.extend({eventType:H(`hook_created`),correlationId:A(),eventData:R({token:A(),tokenRetentionUntil:U().optional(),metadata:G.optional(),isWebhook:P().optional(),isSystem:P().optional()})}),Yd=q.extend({eventType:H(`hook_received`),correlationId:A(),eventData:R({token:A().optional(),payload:G})}),Xd=q.extend({eventType:H(`hook_disposed`),correlationId:A(),eventData:R({token:A().optional()}).optional()}),Zd=q.extend({eventType:H(`hook_conflict`),correlationId:A(),eventData:R({token:A(),conflictingRunId:A().optional()})}),Qd=q.extend({eventType:H(`wait_created`),correlationId:A(),eventData:R({resumeAt:U()})}),$d=q.extend({eventType:H(`wait_completed`),correlationId:A(),eventData:R({resumeAt:U().optional()}).optional()}),ef=ru(`type`,[R({type:H(`workflow`)}),R({type:H(`step`),stepId:A(),attempt:N()})]),tf=q.extend({eventType:H(`attr_set`),correlationId:A().optional(),eventData:R({changes:yd,writer:ef,allowReservedAttributes:H(!0).optional()})}),nf=q.extend({eventType:H(`run_created`),eventData:R({deploymentId:A(),workflowName:A(),input:G,executionContext:B(A(),Bl()).optional(),attributes:B(A(),A()).optional(),allowReservedAttributes:H(!0).optional(),encryptionPublicKey:A().optional()})}),rf=q.extend({eventType:H(`run_started`),eventData:R({input:G.optional(),deploymentId:A().optional(),workflowName:A().optional(),executionContext:B(A(),Bl()).optional(),attributes:B(A(),A()).optional(),allowReservedAttributes:H(!0).optional(),encryptionPublicKey:A().optional()}).optional()}),af=q.extend({eventType:H(`run_completed`),eventData:R({output:G.optional()})}),of=q.extend({eventType:H(`run_failed`),eventData:R({error:G,errorCode:A().optional()})}),sf=q.extend({eventType:H(`run_cancelled`),eventData:R({cancelReason:A().max(512).optional()}).optional()});ru(`eventType`,[nf,rf,af,of,sf,tf,qd,Ud,Wd,Gd,Kd,Jd,Yd,Xd,Qd,$d]);const cf=ru(`eventType`,[nf,rf,af,of,sf,tf,qd,Ud,Wd,Gd,Kd,Jd,Yd,Xd,Zd,Qd,$d]).and(R({runId:A(),eventId:A(),createdAt:U(),occurredAt:U().optional(),specVersion:N().optional(),resumeId:A().optional()}));function lf(e){return Id(e.eventType)?!0:e.eventType===`step_started`&&typeof e.eventData?.stepName==`string`&&e.eventData.input!==void 0}const uf=V([`pending`,`running`,`completed`,`failed`,`cancelled`]),df=uf.extract([`completed`,`failed`,`cancelled`]).options;function ff(e){return df.includes(e)}const pf=R({runId:A(),status:uf,deploymentId:A(),workflowName:A(),specVersion:N().optional(),executionContext:B(A(),Bl()).optional(),input:G.optional(),output:G.optional(),error:G.optional(),errorCode:A().optional(),attributes:B(A(),A()).default({}),encryptionPublicKey:A().optional(),expiredAt:U().optional(),startedAt:U().optional(),completedAt:U().optional(),createdAt:U(),updatedAt:U()}),mf=ru(`status`,[pf.extend({status:V([`pending`,`running`]),output:F().optional(),error:F().optional(),completedAt:F().optional()}),pf.extend({status:H(`cancelled`),output:F().optional(),error:F().optional(),completedAt:U()}),pf.extend({status:H(`completed`),output:G,error:F().optional(),completedAt:U()}),pf.extend({status:H(`failed`),output:F().optional(),error:G,completedAt:U()})]),hf=V([`pending`,`running`,`completed`,`failed`,`cancelled`]),gf=R({runId:A(),stepId:A(),stepName:A(),status:hf,input:G.optional(),output:G.optional(),error:G.optional(),attempt:N(),startedAt:U().optional(),completedAt:U().optional(),createdAt:U(),updatedAt:U(),retryAfter:U().optional(),specVersion:N().optional()}),_f=hf.extract([`completed`,`failed`,`cancelled`]).options;function vf(e){return _f.includes(e)}const yf=V([`waiting`,`completed`]),bf=R({waitId:A(),runId:A(),status:yf,resumeAt:U().optional(),completedAt:U().optional(),createdAt:U(),updatedAt:U(),specVersion:N().optional()}),xf=/^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}(?:\.\d+)?$/,J=dd(e=>typeof e==`string`&&xf.test(e)?`${e.replace(` `,`T`)}Z`:e,U()),Y=J.nullable().optional(),X=A().nullable().optional(),Z=P().nullable().optional(),Sf=R({runId:A(),status:uf,deploymentId:A(),workflowName:A(),specVersion:md().optional(),attributes:B(A(),A()).default({}),createdAt:J,updatedAt:J,startedAt:Y,completedAt:Y,errorCode:X,workflowCoreVersion:X,workflowEncryptionEnabled:Z}),Cf=R({runId:A(),stepId:A(),stepName:X,status:hf,attempt:N().optional(),createdAt:J,updatedAt:J,startedAt:Y,completedAt:Y,retryAfter:Y,errorCode:X,workflowCoreVersion:X,workflowEncryptionEnabled:Z,computeInstanceId:X}),wf=R({runId:A(),eventId:A(),eventType:K,correlationId:X,entityId:X,stepName:X,workflowName:A(),deploymentId:A(),specVersion:md().optional(),runCreatedAt:J,createdAt:J,region:X,vercelId:X,requestId:X,computeInstanceId:X,resumeAt:Y,retryAfter:Y,errorCode:X,workflowCoreVersion:X,isWebhook:Z,isSystem:Z,workflowEncryptionEnabled:Z}),Tf=R({runId:A(),hookId:A(),status:V([`created`,`received`,`disposed`,`conflict`]),createdAt:J,updatedAt:J,receivedAt:Y,disposedAt:Y,isWebhook:Z,isSystem:Z,workflowCoreVersion:X,workflowEncryptionEnabled:Z}),Ef=R({runId:A(),waitId:A(),status:yf,resumeAt:Y,createdAt:J,updatedAt:J,completedAt:Y,workflowCoreVersion:X,workflowEncryptionEnabled:Z}),Df=R({key:A(),runCount:md(),firstSeenAt:U(),lastSeenAt:U()}),Of=A().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_workflow_$/,`Must match __wkf_workflow_ or __{namespace}_wkf_workflow_`),kf=A().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_workflow_.+$/,`Must be a valid queue name with a recognized prefix`),Af=A().regex(/^[a-z][a-z0-9]*$/,`Must be lowercase alphanumeric, starting with a letter`);function jf(e){return e??process.env.WORKFLOW_QUEUE_NAMESPACE??void 0}function Mf(e,t){if(e!==`workflow`)throw Error(`Unsupported queue kind: ${e}`);return t===void 0?`__wkf_workflow_`:(Af.parse(t),`__${t}_wkf_workflow_`)}function Nf(e){let t=e.match(/^(__(?:[a-z][a-z0-9]*_)?wkf_workflow_)(.+)$/);if(!t)throw Error(`Invalid queue name: ${e}`);return{prefix:Of.parse(t[1]),id:t[2]}}const Pf=A().brand().describe(`A stored queue message ID`),Ff=B(A(),A()),If=R({input:I(),deploymentId:A(),workflowName:A(),specVersion:N(),executionContext:B(A(),Bl()).optional(),attributes:B(A(),A()).optional(),allowReservedAttributes:H(!0).optional(),environment:A().optional()}),Lf=R({resumeId:A(),hookId:A(),token:A(),payload:I(),payloadDigest:A()}),Rf=R({runId:A(),traceCarrier:Ff.optional(),requestedAt:U().optional(),replayDivergence:R({eventId:A(),count:N().int().positive()}).optional(),preconditionReinvocations:N().int().positive().optional(),serverErrorRetryCount:N().int().optional(),stepId:A().optional(),stepName:A().optional(),runInput:If.optional(),hookInput:Lf.optional()}),zf=R({__healthCheck:H(!0),correlationId:A(),runId:A().optional()}),Bf=z([zf,Rf]),Vf=R({deploymentId:A(),workflowName:A(),runSpecVersion:N().optional(),workflowCoreVersion:A().optional(),traceCarrier:Ff.optional(),encryptionPublicKey:A().optional(),hookResumeInputVersion:N().optional()}),Hf=R({hookResumeDedupVersion:N()}),Uf=R({runId:A(),hookId:A(),token:A(),ownerId:A(),projectId:A(),environment:A(),metadata:G.optional(),createdAt:U(),specVersion:N().optional(),isWebhook:P().optional(),isSystem:P().optional(),resumeContext:Vf.optional(),resumeCapabilities:Hf.optional()});async function Wf(e,t,n,r){let i=Mf(`workflow`,jf(r)),a=0;for(let r of[`pending`,`running`]){let o,s=!0;for(;s;){let c=await e.list({status:r,resolveData:`none`,pagination:{cursor:o}});for(let e of c.data)try{await t(`${i}${e.workflowName}`,{runId:e.runId}),a++}catch(t){console.warn(`[${n}] Failed to re-enqueue run ${e.runId}: ${t}`)}s=c.hasMore,o=c.cursor??void 0}}a>0&&console.log(`[${n}] Re-enqueued ${a} active run(s) on startup`)}const Gf=Xu(()=>z([A(),N(),P(),Rl(),L(Gf),B(A(),Gf)])),Kf=R({currentLookbackDays:N(),maxLookbackDays:N(),currentWindowStart:U(),maxWindowStart:U(),upgradeAvailable:P()}),qf=e=>R({data:L(e),cursor:A().nullable(),hasMore:P(),pageInfo:Kf.optional()}),Jf=R({message:A(),stack:A().optional(),code:A().optional()}),Yf=`0123456789ABCDEFGHJKMNPQRSTVWXYZ`;var Q;(function(e){e.Base32IncorrectEncoding=`B32_ENC_INVALID`,e.DecodeTimeInvalidCharacter=`DEC_TIME_CHAR`,e.DecodeTimeValueMalformed=`DEC_TIME_MALFORMED`,e.EncodeTimeNegative=`ENC_TIME_NEG`,e.EncodeTimeSizeExceeded=`ENC_TIME_SIZE_EXCEED`,e.EncodeTimeValueMalformed=`ENC_TIME_MALFORMED`,e.PRNGDetectFailure=`PRNG_DETECT`,e.ULIDInvalid=`ULID_INVALID`,e.Unexpected=`UNEXPECTED`,e.UUIDInvalid=`UUID_INVALID`})(Q||={});var $=class extends Error{constructor(e,t){super(`${t} (${e})`),this.name=`ULIDError`,this.code=e}};function Xf(e){let t=Math.floor(e()*32)%32;return Yf.charAt(t)}function Zf(e,t,n){return t>e.length-1?e:e.substr(0,t)+n+e.substr(t+1)}function Qf(e){let t,n=e.length,r,i,a=e;for(;!t&&n-->=0;){if(r=a[n],i=Yf.indexOf(r),i===-1)throw new $(Q.Base32IncorrectEncoding,`Incorrectly encoded string`);if(i===31){a=Zf(a,n,Yf[0]);continue}t=Zf(a,n,Yf[i+1])}if(typeof t==`string`)return t;throw new $(Q.Base32IncorrectEncoding,`Failed incrementing string`)}function $f(e){if(e.length!==26)throw new $(Q.DecodeTimeValueMalformed,`Malformed ULID`);let t=e.substr(0,10).toUpperCase().split(``).reverse().reduce((e,t,n)=>{let r=Yf.indexOf(t);if(r===-1)throw new $(Q.DecodeTimeInvalidCharacter,`Time decode error: Invalid character: ${t}`);return e+=r*32**n},0);if(t>0xffffffffffff)throw new $(Q.DecodeTimeValueMalformed,`Malformed ULID: timestamp too large: ${t}`);return t}function ep(e){let n=tp(),r=n&&(n.crypto||n.msCrypto)||(t===void 0?null:t);if(typeof r?.getRandomValues==`function`)return()=>{let e=new Uint8Array(1);return r.getRandomValues(e),e[0]/256};if(typeof r?.randomBytes==`function`)return()=>r.randomBytes(1).readUInt8()/256;if(t?.randomBytes)return()=>t.randomBytes(1).readUInt8()/256;throw new $(Q.PRNGDetectFailure,`Failed to find a reliable PRNG`)}function tp(){return ip()?self:typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:null}function np(e,t){let n=``;for(;e>0;e--)n=Xf(t)+n;return n}function rp(e,t=10){if(isNaN(e))throw new $(Q.EncodeTimeValueMalformed,`Time must be a number: ${e}`);if(e>0xffffffffffff)throw new $(Q.EncodeTimeSizeExceeded,`Cannot encode a time larger than 281474976710655: ${e}`);if(e<0)throw new $(Q.EncodeTimeNegative,`Time must be positive: ${e}`);if(Number.isInteger(e)===!1)throw new $(Q.EncodeTimeValueMalformed,`Time must be an integer: ${e}`);let n,r=``;for(let i=t;i>0;i--)n=e%32,r=Yf.charAt(n)+r,e=(e-n)/32;return r}function ip(){return typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope}function ap(e){let t=e||ep(),n=0,r;return function(e){let i=!e||isNaN(e)?Date.now():e;if(i<=n){let e=r=Qf(r);return rp(n,10)+e}n=i;let a=r=np(16,t);return rp(i,10)+a}}function op(e,t){let n=t||ep();return rp(!e||isNaN(e)?Date.now():e,10)+np(16,n)}const sp=A().ulid(),cp=Ju([`wrun_`,qc()]),lp=1440*60*1e3,up=300*1e3;function dp(e){let t=sp.safeParse(e);return t.success?new Date($f(t.data)):null}function fp(e,t,n=lp,r=up){let i=dp(e.startsWith(t)?e.slice(t.length):e);if(!i)return`Invalid runId: "${e}" is not a valid ULID`;let a=new Date().getTime()-i.getTime();return a>0&&a<=n||a<=0&&-a<=r?null:`Invalid runId timestamp: embedded timestamp is ${Math.round(Math.abs(a)/1e3)}s in the ${a>0?`past`:`future`} (threshold: ${Math.round((a>0?n:r)/1e3)}s)`}var pp=e({ATTRIBUTE_KEY_MAX_LENGTH:()=>256,ATTRIBUTE_MAX_PER_RUN:()=>64,ATTRIBUTE_VALUE_MAX_BYTES:()=>256,DEFAULT_TIMESTAMP_THRESHOLD_FUTURE_MS:()=>up,DEFAULT_TIMESTAMP_THRESHOLD_MS:()=>DEFAULT_TIMESTAMP_THRESHOLD_MS,DEFAULT_TIMESTAMP_THRESHOLD_PAST_MS:()=>lp,HOOK_RESUME_DEDUP_VERSION:()=>1,HOOK_RESUME_INPUT_VERSION:()=>1,HookSchema:()=>Uf,RESERVED_ATTRIBUTE_KEY_PREFIX:()=>`$`,SPEC_VERSION_CURRENT:()=>5,SPEC_VERSION_LEGACY:()=>1,SPEC_VERSION_SUPPORTS_ATTRIBUTES:()=>4,SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT:()=>3,SPEC_VERSION_SUPPORTS_COMPRESSION:()=>5,SPEC_VERSION_SUPPORTS_EVENT_SOURCING:()=>2});export{cl as $,ho as $a,ft as $c,Vo as $i,rl as $n,$r as $o,_c as $r,Xr as $s,bu as $t,mf as A,lo as Aa,jt as Ac,wa as Ai,Uc as An,jo as Ao,mu as Ar,Hr as As,el as At,Ed as B,wo as Ba,Dt as Bc,Na as Bi,yu as Bn,Pr as Bo,su as Br,fr as Bs,Xl as Bt,Sf as C,w as Ca,lr as Cc,us as Ci,dl as Cn,ua as Co,Mu as Cr,Li as Cs,Qc as Ct,gf as D,co as Da,ir as Dc,Ja as Di,al as Dn,la as Do,B as Dr,Jr as Ds,Xc as Dt,bf as E,fo as Ea,Yn as Ec,Da as Ei,nd as En,ca as Eo,Ku as Er,Ni as Es,ml as Et,zd as F,io as Fa,st as Fc,xa as Fi,ru as Fn,Qi as Fo,Iu as Fr,Mi as Fs,Nu as Ft,vd as G,Co as Ga,gt as Gc,Qa as Gi,yl as Gn,jr as Go,I as Gr,Ti as Gs,Gu as Gt,Vd as H,Wo as Ha,pt as Hc,pa as Hi,Tl as Hn,Wr as Ho,Nl as Hr,Fi as Hs,Vu as Ht,lf as I,Xa as Ia,lt as Ic,Sa as Ii,pl as In,C as Io,ad as Ir,qi as Is,Ll as It,Cd as J,$o as Ja,ut as Jc,Ta as Ji,Cl as Jn,br as Jo,Mc as Jr,xr as Js,Ec as Jt,_d as K,Yo as Ka,bt as Kc,Go as Ki,vl as Kn,Mr as Ko,Ic as Kr,hi as Ks,cu as Kt,Pd as L,oo as La,Tt as Lc,Ha as Li,Oc as Ln,ta as Lo,Fl as Lr,Ui as Ls,Eu as Lt,cf as M,eo as Ma,xt as Mc,za as Mi,rd as Mn,as as Mo,A as Mr,oi as Ms,zu as Mt,K as N,fa as Na,ht as Nc,Jo as Ni,ql as Nn,ea as No,_l as Nr,Di as Ns,Bc as Nt,vf as O,So as Oa,$n as Oc,ko as Oi,sl as On,Za as Oo,id as Or,ki as Os,Yu as Ot,Bd as P,zo as Pa,yt as Pc,rs as Pi,od as Pn,$i as Po,ld as Pr,Ri as Ps,Hl as Pt,Jl as Q,ts as Qa,Ot as Qc,Ro as Qi,$c as Qn,Br as Qo,tu as Qr,ci as Qs,qu as Qt,Md as R,Ko as Ra,kt as Rc,Ba as Ri,zc as Rn,Yr as Ro,Ju as Rr,_i as Rs,xl as Rt,Tf as S,to as Sa,Gn as Sc,ls as Si,ll as Sn,_o as So,Hu as Sr,vi as Ss,kc as St,Ef as T,Io as Ta,er as Tc,E as Ti,P as Tn,sa as To,Qu as Tr,Zr as Ts,iu as Tt,G as U,Ma as Ua,vt as Uc,ma as Ui,Ac as Un,Gr as Uo,qc as Ur,Kr as Us,ju as Ut,Ad as V,qa as Va,dt as Vc,ra as Vi,wl as Vn,Ir as Vo,Dl as Vr,S as Vs,Su as Vt,W,Uo as Wa,St as Wc,es as Wi,bl as Wn,Ur as Wo,z as Wr,Gi as Ws,Zu as Wt,md as X,Xo as Xa,At as Xc,da as Xi,Ml as Xn,Bi as Xo,Pc as Xr,mr as Xs,Fu as Xt,fd as Y,xo as Ya,Et as Yc,ia as Yi,El as Yn,Ii as Yo,Nc as Yr,gr as Ys,j as Yt,zl as Z,Fo as Za,wt as Zc,bo as Zi,au as Zn,Yi as Zo,Yc as Zr,qr as Zs,Pl as Zt,Mf as _,_a,qn as _c,tc as _i,n as _l,Rl as _n,Wa as _o,Ou as _r,zr as _s,Rc as _t,$f as a,vo as aa,Rr as ac,xc as ai,ot as al,Il as an,ss as ao,H as ar,Si as as,ol as at,Df as b,Bo as ba,Jn as bc,fs as bi,Bl as bn,Ao as bo,Cu as br,Ci as bs,vu as bt,qf as c,Ua as ca,b as cc,Sc as ci,h as cl,Wl as cn,ns as co,tl as cr,Ki as cs,Lu as ct,Uf as d,ya as da,Un as dc,dc as di,ke as dl,Tc as dn,Eo as do,Bu as dr,kr as ds,gl as dt,Fa as ea,Qr as ec,yc as ei,mt as el,ou as en,Lo as eo,ud as er,Ai as es,ul as et,zf as f,ka as fa,rr as fc,O as fi,l as fl,Ru as fn,Do as fo,Vc as fr,Tr as fs,Kl as ft,Rf as g,Ea as ga,Xn as gc,oc as gi,r as gl,cd as gn,Ra as go,Du as gr,fi as gs,Dc as gt,kf as h,Aa as ha,tr as hc,cc as hi,i as hl,ed as hn,Po as ho,Pu as hr,Er as hs,fl as ht,cp as i,aa as ia,Fr as ic,pc as ii,rt as il,M as in,na as io,Xu as ir,_r as is,il as it,ff as j,so as ja,_t as jc,Va as ji,Gc as jn,is as jo,Zl as jr,ai as js,du as jt,pf as k,po as ka,nr as kc,Ca as ki,Wu as kn,ga as ko,wc as kr,Vr as ks,_u as kt,Jf as l,No as la,Kn as lc,mc as li,ae as ll,Jc as ln,Ga as lo,fu as lr,pr as ls,Uu as lt,Bf as m,ja as ma,Hn as mc,nc as mi,o as ml,V as mn,To as mo,Ul as mr,Dr as ms,nu as mt,dp as n,no as na,ui as nc,vc as ni,y as nl,Kc as nn,Oo as no,Yl as nr,Lr as ns,jl as nt,ap as o,Pa as oa,dr as oc,Cc as oi,at as ol,$l as on,os as oo,Ql as or,Oi as os,Hc as ot,Pf as p,Oa as pa,Qn as pc,ic as pi,a as pl,Au as pn,Ho as po,gu as pr,wr as ps,ku as pt,wd as q,ro as qa,ct as qc,Mo as qi,Lc as qn,yr as qo,jc as qr,x as qs,pu as qt,fp as r,T as ra,Nr as rc,fc as ri,nt as rl,Fc as rn,yo as ro,Zc as rr,hr as rs,Ol as rt,op as s,La as sa,ur as sc,bc as si,it as sl,Vl as sn,qo as so,uu as sr,wi as ss,Wc as st,pp as t,Ia as ta,Sr as tc,gc as ti,tt as tl,k as tn,uo as to,hl as tr,di as ts,kl as tt,Wf as u,va as ua,ar as uc,hc as ui,We as ul,eu as un,Zo as uo,sd as ur,Or as us,td as ut,Nf as v,Qo as va,cr as vc,$s as vi,c as vl,F as vn,ha as vo,N as vr,Cr as vs,hu as vt,Cf as w,ba as wa,sr as wc,cs as wi,Al as wn,oa as wo,dd as wr,vr as ws,nl as wt,wf as x,go as xa,Wn as xc,ds as xi,L as xn,Ya as xo,lu as xr,Ar as xs,$u as xt,jf as y,mo as ya,Zn as yc,ec as yi,s as yl,Gl as yn,Ka as yo,R as yr,Ji as ys,wu as yt,Od as z,ao as za,Ct as zc,$a as zi,Tu as zn,ti as zo,xu as zr,bi as zs,Sl as zt};
40
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function us(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:fs(t,`input`,e.processors),output:fs(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function D(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return D(r.element,n);if(r.type===`set`)return D(r.valueType,n);if(r.type===`lazy`)return D(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return D(r.innerType,n);if(r.type===`intersection`)return D(r.left,n)||D(r.right,n);if(r.type===`record`||r.type===`map`)return D(r.keyType,n)||D(r.valueType,n);if(r.type===`pipe`)return D(r.in,n)||D(r.out,n);if(r.type===`object`){for(let e in r.shape)if(D(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(D(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(D(e,n))return!0;return!!(r.rest&&D(r.rest,n))}return!1}const ds=(e,t={})=>n=>{let r=cs({...n,processors:t});return E(e,r),ls(r,e),us(r,e)},fs=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=cs({...i??{},target:a,io:t,processors:n});return E(e,o),ls(o,e),us(o,e)},ps={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},ms=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=ps[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},hs=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},gs=(e,t,n,r)=>{n.type=`boolean`},_s=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`BigInt cannot be represented in JSON Schema`)},vs=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Symbols cannot be represented in JSON Schema`)},ys=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},bs=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},xs=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Void cannot be represented in JSON Schema`)},Ss=(e,t,n,r)=>{n.not={}},Cs=(e,t,n,r)=>{},ws=(e,t,n,r)=>{},Ts=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Date cannot be represented in JSON Schema`)},Es=(e,t,n,r)=>{let i=e._zod.def,a=ie(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Ds=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},Os=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`NaN cannot be represented in JSON Schema`)},ks=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},As=(e,t,n,r)=>{let i=n,a={type:`string`,format:`binary`,contentEncoding:`binary`},{minimum:o,maximum:s,mime:c}=e._zod.bag;o!==void 0&&(a.minLength=o),s!==void 0&&(a.maxLength=s),c?c.length===1?(a.contentMediaType=c[0],Object.assign(i,a)):(Object.assign(i,a),i.anyOf=c.map(e=>({contentMediaType:e}))):Object.assign(i,a)},js=(e,t,n,r)=>{n.type=`boolean`},Ms=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Ns=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Function types cannot be represented in JSON Schema`)},Ps=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Fs=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Map cannot be represented in JSON Schema`)},Is=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Set cannot be represented in JSON Schema`)},Ls=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=E(a.element,t,{...r,path:[...r.path,`items`]})},Rs=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=E(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=E(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},zs=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>E(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Bs=(e,t,n,r)=>{let i=e._zod.def,a=E(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=E(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Vs=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>E(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?E(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:ee}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof ee==`number`&&(i.maxItems=ee)},Hs=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=E(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=E(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=E(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Us=(e,t,n,r)=>{let i=e._zod.def,a=E(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Ws=(e,t,n,r)=>{let i=e._zod.def;E(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Gs=(e,t,n,r)=>{let i=e._zod.def;E(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Ks=(e,t,n,r)=>{let i=e._zod.def;E(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},qs=(e,t,n,r)=>{let i=e._zod.def;E(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Js=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;E(a,t,r);let o=t.seen.get(e);o.ref=a},Ys=(e,t,n,r)=>{let i=e._zod.def;E(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Xs=(e,t,n,r)=>{let i=e._zod.def;E(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Zs=(e,t,n,r)=>{let i=e._zod.def;E(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Qs=(e,t,n,r)=>{let i=e._zod.innerType;E(i,t,r);let a=t.seen.get(e);a.ref=i},$s={string:ms,number:hs,boolean:gs,bigint:_s,symbol:vs,null:ys,undefined:bs,void:xs,never:Ss,any:Cs,unknown:ws,date:Ts,enum:Es,literal:Ds,nan:Os,template_literal:ks,file:As,success:js,custom:Ms,function:Ns,transform:Ps,map:Fs,set:Is,array:Ls,object:Rs,union:zs,intersection:Bs,tuple:Vs,record:Hs,nullable:Us,nonoptional:Ws,default:Gs,prefault:Ks,catch:qs,pipe:Js,readonly:Ys,promise:Xs,optional:Zs,lazy:Qs};function ec(e,t){if(`_idmap`in e){let n=e,r=cs({...t,processors:$s}),i={};for(let e of n._idmap.entries()){let[t,n]=e;E(n,r)}let a={};r.external={registry:n,uri:t?.uri,defs:i};for(let e of n._idmap.entries()){let[t,n]=e;ls(r,n),a[t]=us(r,n)}return Object.keys(i).length>0&&(a.__shared={[r.target===`draft-2020-12`?`$defs`:`definitions`]:i}),{schemas:a}}let n=cs({...t,processors:$s});return E(e,n),ls(n,e),us(n,e)}var tc=e({ZodISODate:()=>ic,ZodISODateTime:()=>nc,ZodISODuration:()=>cc,ZodISOTime:()=>oc,date:()=>ac,datetime:()=>rc,duration:()=>lc,time:()=>sc});const nc=r(`ZodISODateTime`,(e,t)=>{wr.init(e,t),j.init(e,t)});function rc(e){return Oa(nc,e)}const ic=r(`ZodISODate`,(e,t)=>{Tr.init(e,t),j.init(e,t)});function ac(e){return ka(ic,e)}const oc=r(`ZodISOTime`,(e,t)=>{Er.init(e,t),j.init(e,t)});function sc(e){return Aa(oc,e)}const cc=r(`ZodISODuration`,(e,t)=>{Dr.init(e,t),j.init(e,t)});function lc(e){return ja(cc,e)}const uc=(e,t)=>{tt.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>rt(e,t)},flatten:{value:t=>nt(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,oe,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,oe,2)}},isEmpty:{get(){return e.issues.length===0}}})},dc=r(`ZodError`,uc),O=r(`ZodError`,uc,{Parent:Error}),fc=st(O),pc=lt(O),mc=dt(O),hc=pt(O),gc=ht(O),_c=_t(O),vc=yt(O),yc=xt(O),bc=Ct(O),xc=Tt(O),Sc=Dt(O),Cc=kt(O);var wc=e({ZodAny:()=>zl,ZodArray:()=>Jl,ZodBase64:()=>cl,ZodBase64URL:()=>ul,ZodBigInt:()=>kl,ZodBigIntFormat:()=>jl,ZodBoolean:()=>Ol,ZodCIDRv4:()=>il,ZodCIDRv6:()=>ol,ZodCUID:()=>Hc,ZodCUID2:()=>Wc,ZodCatch:()=>Lu,ZodCodec:()=>Uu,ZodCustom:()=>td,ZodCustomStringFormat:()=>gl,ZodDate:()=>Kl,ZodDefault:()=>ku,ZodDiscriminatedUnion:()=>nu,ZodE164:()=>fl,ZodEmail:()=>Dc,ZodEmoji:()=>Rc,ZodEnum:()=>hu,ZodExactOptional:()=>wu,ZodFile:()=>vu,ZodFunction:()=>$u,ZodGUID:()=>kc,ZodIPv4:()=>Qc,ZodIPv6:()=>nl,ZodIntersection:()=>iu,ZodJWT:()=>ml,ZodKSUID:()=>Xc,ZodLazy:()=>Yu,ZodLiteral:()=>_u,ZodMAC:()=>el,ZodMap:()=>du,ZodNaN:()=>zu,ZodNanoID:()=>Bc,ZodNever:()=>Hl,ZodNonOptional:()=>Nu,ZodNull:()=>Ll,ZodNullable:()=>Eu,ZodNumber:()=>xl,ZodNumberFormat:()=>Sl,ZodObject:()=>Xl,ZodOptional:()=>Su,ZodPipe:()=>Vu,ZodPrefault:()=>ju,ZodPromise:()=>Zu,ZodReadonly:()=>Gu,ZodRecord:()=>cu,ZodSet:()=>pu,ZodString:()=>Ec,ZodStringFormat:()=>j,ZodSuccess:()=>Fu,ZodSymbol:()=>Pl,ZodTemplateLiteral:()=>qu,ZodTransform:()=>bu,ZodTuple:()=>ou,ZodType:()=>k,ZodULID:()=>Kc,ZodURL:()=>Fc,ZodUUID:()=>M,ZodUndefined:()=>Il,ZodUnion:()=>$l,ZodUnknown:()=>Vl,ZodVoid:()=>Wl,ZodXID:()=>Jc,ZodXor:()=>eu,_ZodString:()=>Tc,_default:()=>Au,_function:()=>ed,any:()=>Bl,array:()=>L,base64:()=>ll,base64url:()=>dl,bigint:()=>Al,boolean:()=>P,catch:()=>Ru,check:()=>nd,cidrv4:()=>al,cidrv6:()=>sl,codec:()=>Wu,cuid:()=>Uc,cuid2:()=>Gc,custom:()=>rd,date:()=>ql,describe:()=>od,discriminatedUnion:()=>ru,e164:()=>pl,email:()=>Oc,emoji:()=>zc,enum:()=>V,exactOptional:()=>Tu,file:()=>yu,float32:()=>wl,float64:()=>Tl,function:()=>ed,guid:()=>Ac,hash:()=>bl,hex:()=>yl,hostname:()=>vl,httpUrl:()=>Lc,instanceof:()=>cd,int:()=>Cl,int32:()=>El,int64:()=>Ml,intersection:()=>au,ipv4:()=>$c,ipv6:()=>rl,json:()=>ud,jwt:()=>hl,keyof:()=>Yl,ksuid:()=>Zc,lazy:()=>Xu,literal:()=>H,looseObject:()=>Ql,looseRecord:()=>uu,mac:()=>tl,map:()=>fu,meta:()=>sd,nan:()=>Bu,nanoid:()=>Vc,nativeEnum:()=>gu,never:()=>Ul,nonoptional:()=>Pu,null:()=>Rl,nullable:()=>Du,nullish:()=>Ou,number:()=>N,object:()=>R,optional:()=>Cu,partialRecord:()=>lu,pipe:()=>Hu,prefault:()=>Mu,preprocess:()=>dd,promise:()=>Qu,readonly:()=>Ku,record:()=>B,refine:()=>id,set:()=>mu,strictObject:()=>Zl,string:()=>A,stringFormat:()=>_l,stringbool:()=>ld,success:()=>Iu,superRefine:()=>ad,symbol:()=>Fl,templateLiteral:()=>Ju,transform:()=>xu,tuple:()=>su,uint32:()=>Dl,uint64:()=>Nl,ulid:()=>qc,undefined:()=>F,union:()=>z,unknown:()=>I,url:()=>Ic,uuid:()=>jc,uuidv4:()=>Mc,uuidv6:()=>Nc,uuidv7:()=>Pc,void:()=>Gl,xid:()=>Yc,xor:()=>tu});const k=r(`ZodType`,(e,t)=>(x.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:fs(e,`input`),output:fs(e,`output`)}}),e.toJSONSchema=ds(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(p(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>h(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>fc(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>mc(e,t,n),e.parseAsync=async(t,n)=>pc(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>hc(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>gc(e,t,n),e.decode=(t,n)=>_c(e,t,n),e.encodeAsync=async(t,n)=>vc(e,t,n),e.decodeAsync=async(t,n)=>yc(e,t,n),e.safeEncode=(t,n)=>bc(e,t,n),e.safeDecode=(t,n)=>xc(e,t,n),e.safeEncodeAsync=async(t,n)=>Sc(e,t,n),e.safeDecodeAsync=async(t,n)=>Cc(e,t,n),e.refine=(t,n)=>e.check(id(t,n)),e.superRefine=t=>e.check(ad(t)),e.overwrite=t=>e.check(Co(t)),e.optional=()=>Cu(e),e.exactOptional=()=>Tu(e),e.nullable=()=>Du(e),e.nullish=()=>Cu(Du(e)),e.nonoptional=t=>Pu(e,t),e.array=()=>L(e),e.or=t=>z([e,t]),e.and=t=>au(e,t),e.transform=t=>Hu(e,xu(t)),e.default=t=>Au(e,t),e.prefault=t=>Mu(e,t),e.catch=t=>Ru(e,t),e.pipe=t=>Hu(e,t),e.readonly=()=>Ku(e),e.describe=t=>{let n=e.clone();return C.add(n,{description:t}),n},Object.defineProperty(e,"description",{get(){return C.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return C.get(e);let n=e.clone();return C.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),Tc=r(`_ZodString`,(e,t)=>{fr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(ho(...t)),e.includes=(...t)=>e.check(vo(...t)),e.startsWith=(...t)=>e.check(yo(...t)),e.endsWith=(...t)=>e.check(bo(...t)),e.min=(...t)=>e.check(po(...t)),e.max=(...t)=>e.check(fo(...t)),e.length=(...t)=>e.check(mo(...t)),e.nonempty=(...t)=>e.check(po(1,...t)),e.lowercase=t=>e.check(go(t)),e.uppercase=t=>e.check(_o(t)),e.trim=()=>e.check(To()),e.normalize=(...t)=>e.check(wo(...t)),e.toLowerCase=()=>e.check(Eo()),e.toUpperCase=()=>e.check(Do()),e.slugify=()=>e.check(Oo())}),Ec=r(`ZodString`,(e,t)=>{fr.init(e,t),Tc.init(e,t),e.email=t=>e.check(ia(Dc,t)),e.url=t=>e.check(ua(Fc,t)),e.jwt=t=>e.check(Ea(ml,t)),e.emoji=t=>e.check(da(Rc,t)),e.guid=t=>e.check(aa(kc,t)),e.uuid=t=>e.check(oa(M,t)),e.uuidv4=t=>e.check(sa(M,t)),e.uuidv6=t=>e.check(ca(M,t)),e.uuidv7=t=>e.check(la(M,t)),e.nanoid=t=>e.check(fa(Bc,t)),e.guid=t=>e.check(aa(kc,t)),e.cuid=t=>e.check(pa(Hc,t)),e.cuid2=t=>e.check(ma(Wc,t)),e.ulid=t=>e.check(ha(Kc,t)),e.base64=t=>e.check(Ca(cl,t)),e.base64url=t=>e.check(wa(ul,t)),e.xid=t=>e.check(ga(Jc,t)),e.ksuid=t=>e.check(_a(Xc,t)),e.ipv4=t=>e.check(va(Qc,t)),e.ipv6=t=>e.check(ya(nl,t)),e.cidrv4=t=>e.check(xa(il,t)),e.cidrv6=t=>e.check(Sa(ol,t)),e.e164=t=>e.check(Ta(fl,t)),e.datetime=t=>e.check(rc(t)),e.date=t=>e.check(ac(t)),e.time=t=>e.check(sc(t)),e.duration=t=>e.check(lc(t))});function A(e){return na(Ec,e)}const j=r(`ZodStringFormat`,(e,t)=>{S.init(e,t),Tc.init(e,t)}),Dc=r(`ZodEmail`,(e,t)=>{hr.init(e,t),j.init(e,t)});function Oc(e){return ia(Dc,e)}const kc=r(`ZodGUID`,(e,t)=>{pr.init(e,t),j.init(e,t)});function Ac(e){return aa(kc,e)}const M=r(`ZodUUID`,(e,t)=>{mr.init(e,t),j.init(e,t)});function jc(e){return oa(M,e)}function Mc(e){return sa(M,e)}function Nc(e){return ca(M,e)}function Pc(e){return la(M,e)}const Fc=r(`ZodURL`,(e,t)=>{gr.init(e,t),j.init(e,t)});function Ic(e){return ua(Fc,e)}function Lc(e){return ua(Fc,{protocol:/^https?$/,hostname:sn,...g(e)})}const Rc=r(`ZodEmoji`,(e,t)=>{_r.init(e,t),j.init(e,t)});function zc(e){return da(Rc,e)}const Bc=r(`ZodNanoID`,(e,t)=>{vr.init(e,t),j.init(e,t)});function Vc(e){return fa(Bc,e)}const Hc=r(`ZodCUID`,(e,t)=>{yr.init(e,t),j.init(e,t)});function Uc(e){return pa(Hc,e)}const Wc=r(`ZodCUID2`,(e,t)=>{br.init(e,t),j.init(e,t)});function Gc(e){return ma(Wc,e)}const Kc=r(`ZodULID`,(e,t)=>{xr.init(e,t),j.init(e,t)});function qc(e){return ha(Kc,e)}const Jc=r(`ZodXID`,(e,t)=>{Sr.init(e,t),j.init(e,t)});function Yc(e){return ga(Jc,e)}const Xc=r(`ZodKSUID`,(e,t)=>{Cr.init(e,t),j.init(e,t)});function Zc(e){return _a(Xc,e)}const Qc=r(`ZodIPv4`,(e,t)=>{Or.init(e,t),j.init(e,t)});function $c(e){return va(Qc,e)}const el=r(`ZodMAC`,(e,t)=>{Ar.init(e,t),j.init(e,t)});function tl(e){return ba(el,e)}const nl=r(`ZodIPv6`,(e,t)=>{kr.init(e,t),j.init(e,t)});function rl(e){return ya(nl,e)}const il=r(`ZodCIDRv4`,(e,t)=>{jr.init(e,t),j.init(e,t)});function al(e){return xa(il,e)}const ol=r(`ZodCIDRv6`,(e,t)=>{Mr.init(e,t),j.init(e,t)});function sl(e){return Sa(ol,e)}const cl=r(`ZodBase64`,(e,t)=>{Pr.init(e,t),j.init(e,t)});function ll(e){return Ca(cl,e)}const ul=r(`ZodBase64URL`,(e,t)=>{Ir.init(e,t),j.init(e,t)});function dl(e){return wa(ul,e)}const fl=r(`ZodE164`,(e,t)=>{Lr.init(e,t),j.init(e,t)});function pl(e){return Ta(fl,e)}const ml=r(`ZodJWT`,(e,t)=>{zr.init(e,t),j.init(e,t)});function hl(e){return Ea(ml,e)}const gl=r(`ZodCustomStringFormat`,(e,t)=>{Br.init(e,t),j.init(e,t)});function _l(e,t,n={}){return ss(gl,e,t,n)}function vl(e){return ss(gl,`hostname`,on,e)}function yl(e){return ss(gl,`hex`,Cn,e)}function bl(e,t){let n=`${e}_${t?.enc??`hex`}`,r=jt[n];if(!r)throw Error(`Unrecognized hash format: ${n}`);return ss(gl,n,r,t)}const xl=r(`ZodNumber`,(e,t)=>{Vr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r),e.gt=(t,n)=>e.check(no(t,n)),e.gte=(t,n)=>e.check(T(t,n)),e.min=(t,n)=>e.check(T(t,n)),e.lt=(t,n)=>e.check(to(t,n)),e.lte=(t,n)=>e.check(w(t,n)),e.max=(t,n)=>e.check(w(t,n)),e.int=t=>e.check(Cl(t)),e.safe=t=>e.check(Cl(t)),e.positive=t=>e.check(no(0,t)),e.nonnegative=t=>e.check(T(0,t)),e.negative=t=>e.check(to(0,t)),e.nonpositive=t=>e.check(w(0,t)),e.multipleOf=(t,n)=>e.check(so(t,n)),e.step=(t,n)=>e.check(so(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function N(e){return Ma(xl,e)}const Sl=r(`ZodNumberFormat`,(e,t)=>{Hr.init(e,t),xl.init(e,t)});function Cl(e){return Pa(Sl,e)}function wl(e){return Fa(Sl,e)}function Tl(e){return Ia(Sl,e)}function El(e){return La(Sl,e)}function Dl(e){return Ra(Sl,e)}const Ol=r(`ZodBoolean`,(e,t)=>{Ur.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gs(e,t,n,r)});function P(e){return za(Ol,e)}const kl=r(`ZodBigInt`,(e,t)=>{Wr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_s(e,t,n,r),e.gte=(t,n)=>e.check(T(t,n)),e.min=(t,n)=>e.check(T(t,n)),e.gt=(t,n)=>e.check(no(t,n)),e.gte=(t,n)=>e.check(T(t,n)),e.min=(t,n)=>e.check(T(t,n)),e.lt=(t,n)=>e.check(to(t,n)),e.lte=(t,n)=>e.check(w(t,n)),e.max=(t,n)=>e.check(w(t,n)),e.positive=t=>e.check(no(BigInt(0),t)),e.negative=t=>e.check(to(BigInt(0),t)),e.nonpositive=t=>e.check(w(BigInt(0),t)),e.nonnegative=t=>e.check(T(BigInt(0),t)),e.multipleOf=(t,n)=>e.check(so(t,n));let n=e._zod.bag;e.minValue=n.minimum??null,e.maxValue=n.maximum??null,e.format=n.format??null});function Al(e){return Va(kl,e)}const jl=r(`ZodBigIntFormat`,(e,t)=>{Gr.init(e,t),kl.init(e,t)});function Ml(e){return Ua(jl,e)}function Nl(e){return Wa(jl,e)}const Pl=r(`ZodSymbol`,(e,t)=>{Kr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vs(e,t,n,r)});function Fl(e){return Ga(Pl,e)}const Il=r(`ZodUndefined`,(e,t)=>{qr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r)});function F(e){return Ka(Il,e)}const Ll=r(`ZodNull`,(e,t)=>{Jr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(e,t,n,r)});function Rl(e){return qa(Ll,e)}const zl=r(`ZodAny`,(e,t)=>{Yr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Bl(){return Ja(zl)}const Vl=r(`ZodUnknown`,(e,t)=>{Xr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function I(){return Ya(Vl)}const Hl=r(`ZodNever`,(e,t)=>{Zr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ss(e,t,n,r)});function Ul(e){return Xa(Hl,e)}const Wl=r(`ZodVoid`,(e,t)=>{Qr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xs(e,t,n,r)});function Gl(e){return Za(Wl,e)}const Kl=r(`ZodDate`,(e,t)=>{$r.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ts(e,t,n,r),e.min=(t,n)=>e.check(T(t,n)),e.max=(t,n)=>e.check(w(t,n));let n=e._zod.bag;e.minDate=n.minimum?new Date(n.minimum):null,e.maxDate=n.maximum?new Date(n.maximum):null});function ql(e){return Qa(Kl,e)}const Jl=r(`ZodArray`,(e,t)=>{ti.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ls(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(po(t,n)),e.nonempty=t=>e.check(po(1,t)),e.max=(t,n)=>e.check(fo(t,n)),e.length=(t,n)=>e.check(mo(t,n)),e.unwrap=()=>e.element});function L(e,t){return ko(Jl,e,t)}function Yl(e){let t=e._zod.def.shape;return V(Object.keys(t))}const Xl=r(`ZodObject`,(e,t)=>{oi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rs(e,t,n,r),d(e,`shape`,()=>t.shape),e.keyof=()=>V(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:I()}),e.loose=()=>e.clone({...e._zod.def,catchall:I()}),e.strict=()=>e.clone({...e._zod.def,catchall:Ul()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Fe(e,t),e.safeExtend=t=>Ie(e,t),e.merge=t=>Le(e,t),e.pick=t=>Ne(e,t),e.omit=t=>Pe(e,t),e.partial=(...t)=>Re(Su,e,t[0]),e.required=(...t)=>ze(Nu,e,t[0])});function R(e,t){let n={type:`object`,shape:e??{},...g(t)};return new Xl(n)}function Zl(e,t){return new Xl({type:`object`,shape:e,catchall:Ul(),...g(t)})}function Ql(e,t){return new Xl({type:`object`,shape:e,catchall:I(),...g(t)})}const $l=r(`ZodUnion`,(e,t)=>{ci.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zs(e,t,n,r),e.options=t.options});function z(e,t){return new $l({type:`union`,options:e,...g(t)})}const eu=r(`ZodXor`,(e,t)=>{$l.init(e,t),ui.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zs(e,t,n,r),e.options=t.options});function tu(e,t){return new eu({type:`union`,options:e,inclusive:!1,...g(t)})}const nu=r(`ZodDiscriminatedUnion`,(e,t)=>{$l.init(e,t),di.init(e,t)});function ru(e,t,n){return new nu({type:`union`,options:t,discriminator:e,...g(n)})}const iu=r(`ZodIntersection`,(e,t)=>{fi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bs(e,t,n,r)});function au(e,t){return new iu({type:`intersection`,left:e,right:t})}const ou=r(`ZodTuple`,(e,t)=>{hi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vs(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})});function su(e,t,n){let r=t instanceof x;return new ou({type:`tuple`,items:e,rest:r?t:null,...g(r?n:t)})}const cu=r(`ZodRecord`,(e,t)=>{_i.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hs(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function B(e,t,n){return new cu({type:`record`,keyType:e,valueType:t,...g(n)})}function lu(e,t,n){let r=h(e);return r._zod.values=void 0,new cu({type:`record`,keyType:r,valueType:t,...g(n)})}function uu(e,t,n){return new cu({type:`record`,keyType:e,valueType:t,mode:`loose`,...g(n)})}const du=r(`ZodMap`,(e,t)=>{vi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fs(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...t)=>e.check(lo(...t)),e.nonempty=t=>e.check(lo(1,t)),e.max=(...t)=>e.check(co(...t)),e.size=(...t)=>e.check(uo(...t))});function fu(e,t,n){return new du({type:`map`,keyType:e,valueType:t,...g(n)})}const pu=r(`ZodSet`,(e,t)=>{bi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Is(e,t,n,r),e.min=(...t)=>e.check(lo(...t)),e.nonempty=t=>e.check(lo(1,t)),e.max=(...t)=>e.check(co(...t)),e.size=(...t)=>e.check(uo(...t))});function mu(e,t){return new pu({type:`set`,valueType:e,...g(t)})}const hu=r(`ZodEnum`,(e,t)=>{Si.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Es(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new hu({...t,checks:[],...g(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new hu({...t,checks:[],...g(r),entries:i})}});function V(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new hu({type:`enum`,entries:n,...g(t)})}function gu(e,t){return new hu({type:`enum`,entries:e,...g(t)})}const _u=r(`ZodLiteral`,(e,t)=>{Ci.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ds(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function H(e,t){return new _u({type:`literal`,values:Array.isArray(e)?e:[e],...g(t)})}const vu=r(`ZodFile`,(e,t)=>{wi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>As(e,t,n,r),e.min=(t,n)=>e.check(lo(t,n)),e.max=(t,n)=>e.check(co(t,n)),e.mime=(t,n)=>e.check(So(Array.isArray(t)?t:[t],n))});function yu(e){return Vo(vu,e)}const bu=r(`ZodTransform`,(e,t)=>{Ti.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ps(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new o(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Ge(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Ge(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function xu(e){return new bu({type:`transform`,transform:e})}const Su=r(`ZodOptional`,(e,t)=>{Di.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Cu(e){return new Su({type:`optional`,innerType:e})}const wu=r(`ZodExactOptional`,(e,t)=>{Oi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Tu(e){return new wu({type:`optional`,innerType:e})}const Eu=r(`ZodNullable`,(e,t)=>{ki.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Us(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Du(e){return new Eu({type:`nullable`,innerType:e})}function Ou(e){return Cu(Du(e))}const ku=r(`ZodDefault`,(e,t)=>{Ai.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Au(e,t){return new ku({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ce(t)}})}const ju=r(`ZodPrefault`,(e,t)=>{Mi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ks(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Mu(e,t){return new ju({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ce(t)}})}const Nu=r(`ZodNonOptional`,(e,t)=>{Ni.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ws(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Pu(e,t){return new Nu({type:`nonoptional`,innerType:e,...g(t)})}const Fu=r(`ZodSuccess`,(e,t)=>{Fi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>js(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Iu(e){return new Fu({type:`success`,innerType:e})}const Lu=r(`ZodCatch`,(e,t)=>{Ii.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ru(e,t){return new Lu({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const zu=r(`ZodNaN`,(e,t)=>{Li.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Os(e,t,n,r)});function Bu(e){return eo(zu,e)}const Vu=r(`ZodPipe`,(e,t)=>{Ri.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Js(e,t,n,r),e.in=t.in,e.out=t.out});function Hu(e,t){return new Vu({type:`pipe`,in:e,out:t})}const Uu=r(`ZodCodec`,(e,t)=>{Vu.init(e,t),Bi.init(e,t)});function Wu(e,t,n){return new Uu({type:`pipe`,in:e,out:t,transform:n.decode,reverseTransform:n.encode})}const Gu=r(`ZodReadonly`,(e,t)=>{Ui.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ys(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ku(e){return new Gu({type:`readonly`,innerType:e})}const qu=r(`ZodTemplateLiteral`,(e,t)=>{Gi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ks(e,t,n,r)});function Ju(e,t){return new qu({type:`template_literal`,parts:e,...g(t)})}const Yu=r(`ZodLazy`,(e,t)=>{Ji.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qs(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function Xu(e){return new Yu({type:`lazy`,getter:e})}const Zu=r(`ZodPromise`,(e,t)=>{qi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qu(e){return new Zu({type:`promise`,innerType:e})}const $u=r(`ZodFunction`,(e,t)=>{Ki.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ns(e,t,n,r)});function ed(e){return new $u({type:`function`,input:Array.isArray(e?.input)?su(e?.input):e?.input??L(I()),output:e?.output??I()})}const td=r(`ZodCustom`,(e,t)=>{Yi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ms(e,t,n,r)});function nd(e){let t=new b({check:`custom`});return t._zod.check=e,t}function rd(e,t){return es(td,e??(()=>!0),t)}function id(e,t={}){return ts(td,e,t)}function ad(e){return ns(e)}const od=is,sd=as;function cd(e,t={}){let n=new td({type:`custom`,check:`custom`,fn:t=>t instanceof e,abort:!0,...g(t)});return n._zod.bag.Class=e,n._zod.check=t=>{t.value instanceof e||t.issues.push({code:`invalid_type`,expected:e.name,input:t.value,inst:n,path:[...n._zod.def.path??[]]})},n}const ld=(...e)=>os({Codec:Uu,Boolean:Ol,String:Ec},...e);function ud(e){let t=Xu(()=>z([A(e),N(),P(),Rl(),L(t),B(A(),t)]));return t}function dd(e,t){return Hu(xu(e),t)}var fd=e({bigint:()=>gd,boolean:()=>hd,date:()=>U,number:()=>md,string:()=>pd});function pd(e){return ra(Ec,e)}function md(e){return Na(xl,e)}function hd(e){return Ba(Ol,e)}function gd(e){return Ha(kl,e)}function U(e){return $a(Kl,e)}const _d=`$rootRunId`,vd=`$parentRunId`,yd=L(R({key:A(),value:z([A(),Rl()])}));var W=class extends Error{constructor(e){super(e),this.name=`AttributeValidationError`}};const bd=e=>new TextEncoder().encode(e).length;function xd(e,t={}){return typeof e==`string`?e.length===0?new W(`Attribute key must not be empty`):e.length>256?new W(`Attribute key length ${e.length} exceeds limit 256: ${JSON.stringify(e.slice(0,32))}…`):!t.allowReservedAttributes&&e.startsWith(`$`)?new W(`Attribute key ${JSON.stringify(e)} starts with reserved prefix "\$" — that namespace is reserved for framework/library code. Set { allowReservedAttributes: true } only if your caller is framework-level.`):null:new W(`Attribute key must be a string, got ${typeof e}`)}function Sd(e){if(e===null)return null;if(typeof e!=`string`)return new W(`Attribute value must be a string or null, got ${typeof e}`);let t=bd(e);return t>256?new W(`Attribute value byte length ${t} exceeds limit 256`):null}function Cd(e,t={}){let n=new Set,r=t.existingKeys===void 0?void 0:t.existingKeys instanceof Set?t.existingKeys:new Set(t.existingKeys),i=0,a=0;for(let o of e){let e=xd(o.key,{allowReservedAttributes:t.allowReservedAttributes});if(e)throw e;let s=Sd(o.value);if(s)throw s;if(n.has(o.key))throw new W(`Attribute key ${JSON.stringify(o.key)} appears more than once in the same batch`);n.add(o.key),o.value===null?(r===void 0||r.has(o.key))&&(a+=1):(r===void 0||!r.has(o.key))&&(i+=1)}let o=(r===void 0?0:r.size)+i-a;if(o>64)throw new W(`Run attribute count would exceed limit 64 (post-merge ${o})`)}function wd(e,t){let n={...e??{}};for(let{key:e,value:r}of t)r===null?delete n[e]:n[e]=r;return n}const G=z([cd(Uint8Array),Bl()]),K=V([`run_created`,`run_started`,`run_completed`,`run_failed`,`run_cancelled`,`attr_set`,`step_created`,`step_completed`,`step_failed`,`step_retrying`,`step_started`,`hook_created`,`hook_received`,`hook_disposed`,`hook_conflict`,`wait_created`,`wait_completed`]);K.extract([`run_created`,`run_started`,`run_completed`,`run_failed`,`run_cancelled`]).options;const Td=K.extract([`run_completed`,`run_failed`,`run_cancelled`]).options;function Ed(e){return Td.includes(e)}const Dd=K.extract([`step_created`,`step_completed`,`step_failed`,`step_retrying`,`step_started`]).options;function Od(e){return Dd.includes(e)}const kd=K.extract([`step_completed`,`step_failed`]).options;function Ad(e){return kd.includes(e)}const jd=K.extract([`hook_created`,`hook_received`,`hook_disposed`]).options;function Md(e){return jd.includes(e)}const Nd=K.extract([`hook_disposed`,`hook_received`]).options;function Pd(e){return Nd.includes(e)}K.extract([`wait_created`,`wait_completed`]).options;const Fd=K.extract([`step_created`,`hook_created`,`wait_created`]).options;function Id(e){return Fd.includes(e)}const Ld={run_created:`input`,run_started:`input`,run_completed:`output`,run_failed:`error`,step_created:`input`,step_started:`input`,step_completed:`result`,step_failed:`error`,step_retrying:`error`,hook_created:`metadata`,hook_received:`payload`},Rd=Object.fromEntries(Object.entries(Ld).map(([e,t])=>[e,[t]]));function zd(e){return Rd[e]??[]}function Bd(e){return Ld[e]}function Vd(e,t){if(t!==`none`||!(`eventData`in e))return e;let n=e.eventData;if(!n||typeof n!=`object`){let{eventData:t,...n}=e;return n}let r=zd(e.eventType);if(r.length===0)return e;let i={...n};for(let e of r)delete i[e];let{eventData:a,...o}=e;return{...o,...Object.keys(i).length>0?{eventData:i}:{}}}const q=R({eventType:K,correlationId:A().optional(),specVersion:N().optional()}),Hd={ttfs:N().optional(),stso:N().optional(),stepCount:N().int().positive().optional(),eventCount:N().int().positive().optional(),rsfs:N().optional(),finalSchedulingReplay:N().optional(),optimizations:L(A()).optional()},Ud=q.extend({eventType:H(`step_completed`),correlationId:A(),eventData:R({stepName:A().optional(),workflowName:A().optional(),result:G,...Hd})}),Wd=q.extend({eventType:H(`step_failed`),correlationId:A(),eventData:R({stepName:A().optional(),error:G,...Hd})}),Gd=q.extend({eventType:H(`step_retrying`),correlationId:A(),eventData:R({stepName:A().optional(),error:G,retryAfter:U().optional()})}),Kd=q.extend({eventType:H(`step_started`),correlationId:A(),eventData:R({stepName:A().optional(),attempt:N().optional(),workflowName:A().optional(),input:G.optional(),ownerMessageId:A().optional()}).optional()}),qd=q.extend({eventType:H(`step_created`),correlationId:A(),eventData:R({stepName:A(),workflowName:A().optional(),input:G})}),Jd=q.extend({eventType:H(`hook_created`),correlationId:A(),eventData:R({token:A(),tokenRetentionUntil:U().optional(),metadata:G.optional(),isWebhook:P().optional(),isSystem:P().optional()})}),Yd=q.extend({eventType:H(`hook_received`),correlationId:A(),eventData:R({token:A().optional(),payload:G})}),Xd=q.extend({eventType:H(`hook_disposed`),correlationId:A(),eventData:R({token:A().optional()}).optional()}),Zd=q.extend({eventType:H(`hook_conflict`),correlationId:A(),eventData:R({token:A(),conflictingRunId:A().optional()})}),Qd=q.extend({eventType:H(`wait_created`),correlationId:A(),eventData:R({resumeAt:U()})}),$d=q.extend({eventType:H(`wait_completed`),correlationId:A(),eventData:R({resumeAt:U().optional()}).optional()}),ef=ru(`type`,[R({type:H(`workflow`)}),R({type:H(`step`),stepId:A(),attempt:N()})]),tf=q.extend({eventType:H(`attr_set`),correlationId:A().optional(),eventData:R({changes:yd,writer:ef,allowReservedAttributes:H(!0).optional()})}),nf=q.extend({eventType:H(`run_created`),eventData:R({deploymentId:A(),workflowName:A(),input:G,executionContext:B(A(),Bl()).optional(),attributes:B(A(),A()).optional(),allowReservedAttributes:H(!0).optional(),encryptionPublicKey:A().optional()})}),rf=q.extend({eventType:H(`run_started`),eventData:R({input:G.optional(),deploymentId:A().optional(),workflowName:A().optional(),executionContext:B(A(),Bl()).optional(),attributes:B(A(),A()).optional(),allowReservedAttributes:H(!0).optional(),encryptionPublicKey:A().optional()}).optional()}),af=q.extend({eventType:H(`run_completed`),eventData:R({output:G.optional()})}),of=q.extend({eventType:H(`run_failed`),eventData:R({error:G,errorCode:A().optional()})}),sf=q.extend({eventType:H(`run_cancelled`),eventData:R({cancelReason:A().max(512).optional()}).optional()});ru(`eventType`,[nf,rf,af,of,sf,tf,qd,Ud,Wd,Gd,Kd,Jd,Yd,Xd,Qd,$d]);const cf=ru(`eventType`,[nf,rf,af,of,sf,tf,qd,Ud,Wd,Gd,Kd,Jd,Yd,Xd,Zd,Qd,$d]).and(R({runId:A(),eventId:A(),createdAt:U(),occurredAt:U().optional(),specVersion:N().optional(),resumeId:A().optional()}));function lf(e){return Id(e.eventType)?!0:e.eventType===`step_started`&&typeof e.eventData?.stepName==`string`&&e.eventData.input!==void 0}const uf=V([`pending`,`running`,`completed`,`failed`,`cancelled`]),df=uf.extract([`completed`,`failed`,`cancelled`]).options;function ff(e){return df.includes(e)}const pf=R({runId:A(),status:uf,deploymentId:A(),workflowName:A(),specVersion:N().optional(),executionContext:B(A(),Bl()).optional(),input:G.optional(),output:G.optional(),error:G.optional(),errorCode:A().optional(),attributes:B(A(),A()).default({}),encryptionPublicKey:A().optional(),expiredAt:U().optional(),startedAt:U().optional(),completedAt:U().optional(),createdAt:U(),updatedAt:U()}),mf=ru(`status`,[pf.extend({status:V([`pending`,`running`]),output:F().optional(),error:F().optional(),completedAt:F().optional()}),pf.extend({status:H(`cancelled`),output:F().optional(),error:F().optional(),completedAt:U()}),pf.extend({status:H(`completed`),output:G,error:F().optional(),completedAt:U()}),pf.extend({status:H(`failed`),output:F().optional(),error:G,completedAt:U()})]),hf=R({runIds:L(A()).min(1).max(500).refine(e=>new Set(e).size===e.length,{message:`runIds must not contain duplicates`}),cancelReason:A().max(512).optional()}),gf=ru(`outcome`,[R({runId:A(),outcome:H(`cancelled`)}),R({runId:A(),outcome:H(`already_cancelled`)}),R({runId:A(),outcome:H(`not_cancellable`),status:A()}),R({runId:A(),outcome:H(`not_found`)}),R({runId:A(),outcome:H(`failed`),code:A(),retryable:P()})]),_f=R({summary:R({requested:N(),cancelled:N(),alreadyCancelled:N(),notCancellable:N(),notFound:N(),failed:N()}),results:L(gf)}),vf=V([`pending`,`running`,`completed`,`failed`,`cancelled`]),yf=R({runId:A(),stepId:A(),stepName:A(),status:vf,input:G.optional(),output:G.optional(),error:G.optional(),attempt:N(),startedAt:U().optional(),completedAt:U().optional(),createdAt:U(),updatedAt:U(),retryAfter:U().optional(),specVersion:N().optional()}),bf=vf.extract([`completed`,`failed`,`cancelled`]).options;function xf(e){return bf.includes(e)}const Sf=V([`waiting`,`completed`]),Cf=R({waitId:A(),runId:A(),status:Sf,resumeAt:U().optional(),completedAt:U().optional(),createdAt:U(),updatedAt:U(),specVersion:N().optional()}),wf=/^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}(?:\.\d+)?$/,J=dd(e=>typeof e==`string`&&wf.test(e)?`${e.replace(` `,`T`)}Z`:e,U()),Y=J.nullable().optional(),X=A().nullable().optional(),Z=P().nullable().optional(),Tf=R({runId:A(),status:uf,deploymentId:A(),workflowName:A(),specVersion:md().optional(),attributes:B(A(),A()).default({}),createdAt:J,updatedAt:J,startedAt:Y,completedAt:Y,errorCode:X,workflowCoreVersion:X,workflowEncryptionEnabled:Z}),Ef=R({runId:A(),stepId:A(),stepName:X,status:vf,attempt:N().optional(),createdAt:J,updatedAt:J,startedAt:Y,completedAt:Y,retryAfter:Y,errorCode:X,workflowCoreVersion:X,workflowEncryptionEnabled:Z,computeInstanceId:X}),Df=R({runId:A(),eventId:A(),eventType:K,correlationId:X,entityId:X,stepName:X,workflowName:A(),deploymentId:A(),specVersion:md().optional(),runCreatedAt:J,createdAt:J,region:X,vercelId:X,requestId:X,computeInstanceId:X,resumeAt:Y,retryAfter:Y,errorCode:X,workflowCoreVersion:X,isWebhook:Z,isSystem:Z,workflowEncryptionEnabled:Z}),Of=R({runId:A(),hookId:A(),status:V([`created`,`received`,`disposed`,`conflict`]),createdAt:J,updatedAt:J,receivedAt:Y,disposedAt:Y,isWebhook:Z,isSystem:Z,workflowCoreVersion:X,workflowEncryptionEnabled:Z}),kf=R({runId:A(),waitId:A(),status:Sf,resumeAt:Y,createdAt:J,updatedAt:J,completedAt:Y,workflowCoreVersion:X,workflowEncryptionEnabled:Z}),Af=R({key:A(),runCount:md(),firstSeenAt:U(),lastSeenAt:U()}),jf=A().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_workflow_$/,`Must match __wkf_workflow_ or __{namespace}_wkf_workflow_`),Mf=A().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_workflow_.+$/,`Must be a valid queue name with a recognized prefix`),Nf=A().regex(/^[a-z][a-z0-9]*$/,`Must be lowercase alphanumeric, starting with a letter`);function Pf(e){return e??process.env.WORKFLOW_QUEUE_NAMESPACE??void 0}function Ff(e,t){if(e!==`workflow`)throw Error(`Unsupported queue kind: ${e}`);return t===void 0?`__wkf_workflow_`:(Nf.parse(t),`__${t}_wkf_workflow_`)}function If(e){let t=e.match(/^(__(?:[a-z][a-z0-9]*_)?wkf_workflow_)(.+)$/);if(!t)throw Error(`Invalid queue name: ${e}`);return{prefix:jf.parse(t[1]),id:t[2]}}const Lf=A().brand().describe(`A stored queue message ID`),Rf=B(A(),A()),zf=R({input:I(),deploymentId:A(),workflowName:A(),specVersion:N(),executionContext:B(A(),Bl()).optional(),attributes:B(A(),A()).optional(),allowReservedAttributes:H(!0).optional(),environment:A().optional()}),Bf=R({resumeId:A(),hookId:A(),token:A(),payload:I(),payloadDigest:A()}),Vf=R({runId:A(),traceCarrier:Rf.optional(),requestedAt:U().optional(),replayDivergence:R({eventId:A(),count:N().int().positive()}).optional(),preconditionReinvocations:N().int().positive().optional(),serverErrorRetryCount:N().int().optional(),deploymentMismatchRetryCount:N().int().nonnegative().optional(),stepId:A().optional(),stepName:A().optional(),runInput:zf.optional(),hookInput:Bf.optional()}),Hf=R({__healthCheck:H(!0),correlationId:A(),runId:A().optional()}),Uf=z([Hf,Vf]),Wf=R({deploymentId:A(),workflowName:A(),runSpecVersion:N().optional(),workflowCoreVersion:A().optional(),traceCarrier:Rf.optional(),encryptionPublicKey:A().optional(),hookResumeInputVersion:N().optional()}),Gf=R({hookResumeDedupVersion:N()}),Kf=R({runId:A(),hookId:A(),token:A(),ownerId:A(),projectId:A(),environment:A(),metadata:G.optional(),createdAt:U(),specVersion:N().optional(),isWebhook:P().optional(),isSystem:P().optional(),tokenRetentionUntil:U().optional(),resumeContext:Wf.optional(),resumeCapabilities:Gf.optional()});async function qf(e,t,n,r){let i=Ff(`workflow`,Pf(r)),a=0;for(let r of[`pending`,`running`]){let o,s=!0;for(;s;){let c=await e.list({status:r,resolveData:`none`,pagination:{cursor:o}});for(let e of c.data)try{await t(`${i}${e.workflowName}`,{runId:e.runId}),a++}catch(t){console.warn(`[${n}] Failed to re-enqueue run ${e.runId}: ${t}`)}s=c.hasMore,o=c.cursor??void 0}}a>0&&console.log(`[${n}] Re-enqueued ${a} active run(s) on startup`)}const Jf=Xu(()=>z([A(),N(),P(),Rl(),L(Jf),B(A(),Jf)])),Yf=R({currentLookbackDays:N(),maxLookbackDays:N(),currentWindowStart:U(),maxWindowStart:U(),upgradeAvailable:P()}),Xf=e=>R({data:L(e),cursor:A().nullable(),hasMore:P(),pageInfo:Yf.optional()}),Zf=R({message:A(),stack:A().optional(),code:A().optional()}),Qf=`0123456789ABCDEFGHJKMNPQRSTVWXYZ`;var Q;(function(e){e.Base32IncorrectEncoding=`B32_ENC_INVALID`,e.DecodeTimeInvalidCharacter=`DEC_TIME_CHAR`,e.DecodeTimeValueMalformed=`DEC_TIME_MALFORMED`,e.EncodeTimeNegative=`ENC_TIME_NEG`,e.EncodeTimeSizeExceeded=`ENC_TIME_SIZE_EXCEED`,e.EncodeTimeValueMalformed=`ENC_TIME_MALFORMED`,e.PRNGDetectFailure=`PRNG_DETECT`,e.ULIDInvalid=`ULID_INVALID`,e.Unexpected=`UNEXPECTED`,e.UUIDInvalid=`UUID_INVALID`})(Q||={});var $=class extends Error{constructor(e,t){super(`${t} (${e})`),this.name=`ULIDError`,this.code=e}};function $f(e){let t=Math.floor(e()*32)%32;return Qf.charAt(t)}function ep(e,t,n){return t>e.length-1?e:e.substr(0,t)+n+e.substr(t+1)}function tp(e){let t,n=e.length,r,i,a=e;for(;!t&&n-->=0;){if(r=a[n],i=Qf.indexOf(r),i===-1)throw new $(Q.Base32IncorrectEncoding,`Incorrectly encoded string`);if(i===31){a=ep(a,n,Qf[0]);continue}t=ep(a,n,Qf[i+1])}if(typeof t==`string`)return t;throw new $(Q.Base32IncorrectEncoding,`Failed incrementing string`)}function np(e){if(e.length!==26)throw new $(Q.DecodeTimeValueMalformed,`Malformed ULID`);let t=e.substr(0,10).toUpperCase().split(``).reverse().reduce((e,t,n)=>{let r=Qf.indexOf(t);if(r===-1)throw new $(Q.DecodeTimeInvalidCharacter,`Time decode error: Invalid character: ${t}`);return e+=r*32**n},0);if(t>0xffffffffffff)throw new $(Q.DecodeTimeValueMalformed,`Malformed ULID: timestamp too large: ${t}`);return t}function rp(e){let n=ip(),r=n&&(n.crypto||n.msCrypto)||(t===void 0?null:t);if(typeof r?.getRandomValues==`function`)return()=>{let e=new Uint8Array(1);return r.getRandomValues(e),e[0]/256};if(typeof r?.randomBytes==`function`)return()=>r.randomBytes(1).readUInt8()/256;if(t?.randomBytes)return()=>t.randomBytes(1).readUInt8()/256;throw new $(Q.PRNGDetectFailure,`Failed to find a reliable PRNG`)}function ip(){return sp()?self:typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:null}function ap(e,t){let n=``;for(;e>0;e--)n=$f(t)+n;return n}function op(e,t=10){if(isNaN(e))throw new $(Q.EncodeTimeValueMalformed,`Time must be a number: ${e}`);if(e>0xffffffffffff)throw new $(Q.EncodeTimeSizeExceeded,`Cannot encode a time larger than 281474976710655: ${e}`);if(e<0)throw new $(Q.EncodeTimeNegative,`Time must be positive: ${e}`);if(Number.isInteger(e)===!1)throw new $(Q.EncodeTimeValueMalformed,`Time must be an integer: ${e}`);let n,r=``;for(let i=t;i>0;i--)n=e%32,r=Qf.charAt(n)+r,e=(e-n)/32;return r}function sp(){return typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope}function cp(e){let t=e||rp(),n=0,r;return function(e){let i=!e||isNaN(e)?Date.now():e;if(i<=n){let e=r=tp(r);return op(n,10)+e}n=i;let a=r=ap(16,t);return op(i,10)+a}}function lp(e,t){let n=t||rp();return op(!e||isNaN(e)?Date.now():e,10)+ap(16,n)}const up=A().ulid(),dp=Ju([`wrun_`,qc()]),fp=1440*60*1e3,pp=300*1e3;function mp(e){let t=up.safeParse(e);return t.success?new Date(np(t.data)):null}function hp(e,t,n=fp,r=pp){let i=mp(e.startsWith(t)?e.slice(t.length):e);if(!i)return`Invalid runId: "${e}" is not a valid ULID`;let a=new Date().getTime()-i.getTime();return a>0&&a<=n||a<=0&&-a<=r?null:`Invalid runId timestamp: embedded timestamp is ${Math.round(Math.abs(a)/1e3)}s in the ${a>0?`past`:`future`} (threshold: ${Math.round((a>0?n:r)/1e3)}s)`}var gp=e({ATTRIBUTE_KEY_MAX_LENGTH:()=>256,ATTRIBUTE_MAX_PER_RUN:()=>64,ATTRIBUTE_VALUE_MAX_BYTES:()=>256,BULK_CANCEL_MAX_RUN_IDS:()=>500,DEFAULT_TIMESTAMP_THRESHOLD_FUTURE_MS:()=>pp,DEFAULT_TIMESTAMP_THRESHOLD_MS:()=>DEFAULT_TIMESTAMP_THRESHOLD_MS,DEFAULT_TIMESTAMP_THRESHOLD_PAST_MS:()=>fp,HOOK_RESUME_DEDUP_VERSION:()=>1,HOOK_RESUME_INPUT_VERSION:()=>1,HookSchema:()=>Kf,RESERVED_ATTRIBUTE_KEY_PREFIX:()=>`$`,SPEC_VERSION_CURRENT:()=>5,SPEC_VERSION_LEGACY:()=>1,SPEC_VERSION_SUPPORTS_ATTRIBUTES:()=>4,SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT:()=>3,SPEC_VERSION_SUPPORTS_COMPRESSION:()=>5,SPEC_VERSION_SUPPORTS_EVENT_SOURCING:()=>2});export{fd as $,$o as $a,ut as $c,Ta as $i,Cl as $n,br as $o,Mc as $r,xr as $s,Ec as $t,xf as A,Io as Aa,er as Ac,E as Ai,P as An,sa as Ao,Qu as Ar,Zr as As,iu as At,lf as B,io as Ba,st as Bc,xa as Bi,ru as Bn,Qi as Bo,Iu as Br,Mi as Bs,Nu as Bt,Df as C,Qo as Ca,cr as Cc,$s as Ci,c as Cl,F as Cn,ha as Co,N as Cr,Cr as Cs,hu as Ct,kf as D,to as Da,Gn as Dc,ls as Di,ll as Dn,_o as Do,Hu as Dr,vi as Ds,kc as Dt,Ef as E,go as Ea,Wn as Ec,ds as Ei,L as En,Ya as Eo,lu as Er,Ar as Es,$u as Et,ff as F,lo as Fa,jt as Fc,wa as Fi,Uc as Fn,jo as Fo,mu as Fr,Hr as Fs,el as Ft,Ad as G,wo as Ga,Dt as Gc,Na as Gi,yu as Gn,Pr as Go,su as Gr,fr as Gs,Xl as Gt,Md as H,oo as Ha,Tt as Hc,Ha as Hi,Oc as Hn,ta as Ho,Fl as Hr,Ui as Hs,Eu as Ht,cf as I,so as Ia,_t as Ic,Va as Ii,Gc as In,is as Io,Zl as Ir,ai as Is,du as It,W as J,Ma as Ja,vt as Jc,ma as Ji,Ac as Jn,Gr as Jo,qc as Jr,Kr as Js,ju as Jt,Vd as K,qa as Ka,dt as Kc,ra as Ki,wl as Kn,Ir as Ko,Dl as Kr,S as Ks,Su as Kt,K as L,eo as La,xt as Lc,za as Li,rd as Ln,as as Lo,A as Lr,oi as Ls,zu as Lt,_f as M,co as Ma,ir as Mc,Ja as Mi,al as Mn,la as Mo,B as Mr,Jr as Ms,Xc as Mt,pf as N,So as Na,$n as Nc,ko as Ni,sl as Nn,Za as No,id as Nr,ki as Ns,Yu as Nt,Cf as O,w as Oa,lr as Oc,us as Oi,dl as On,ua as Oo,Mu as Or,Li as Os,Qc as Ot,mf as P,po as Pa,nr as Pc,Ca as Pi,Wu as Pn,ga as Po,wc as Pr,Vr as Ps,_u as Pt,Cd as Q,ro as Qa,ct as Qc,Mo as Qi,Lc as Qn,yr as Qo,jc as Qr,x as Qs,pu as Qt,Bd as R,fa as Ra,ht as Rc,Jo as Ri,ql as Rn,ea as Ro,_l as Rr,Di as Rs,Bc as Rt,Af as S,_a as Sa,qn as Sc,tc as Si,n as Sl,Rl as Sn,Wa as So,Ou as Sr,zr as Ss,Rc as St,Tf as T,Bo as Ta,Jn as Tc,fs as Ti,Bl as Tn,Ao as To,Cu as Tr,Ci as Ts,vu as Tt,Od as U,Ko as Ua,kt as Uc,Ba as Ui,zc as Un,Yr as Uo,Ju as Ur,_i as Us,xl as Ut,Pd as V,Xa as Va,lt as Vc,Sa as Vi,pl as Vn,C as Vo,ad as Vr,qi as Vs,Ll as Vt,Ed as W,ao as Wa,Ct as Wc,$a as Wi,Tu as Wn,ti as Wo,xu as Wr,bi as Ws,Sl as Wt,_d as X,Co as Xa,gt as Xc,Qa as Xi,yl as Xn,jr as Xo,I as Xr,Ti as Xs,Gu as Xt,vd as Y,Uo as Ya,St as Yc,es as Yi,bl as Yn,Ur as Yo,z as Yr,Gi as Ys,Zu as Yt,wd as Z,Yo as Za,bt as Zc,Go as Zi,vl as Zn,Mr as Zo,Ic as Zr,hi as Zs,cu as Zt,Mf as _,ka as _a,rr as _c,O as _i,l as _l,Ru as _n,Do as _o,Vc as _r,Tr as _s,Kl as _t,np as a,Fa as aa,Qr as ac,yc as ai,mt as al,ou as an,Lo as ao,ud as ar,Ai as as,ul as at,If as b,Aa as ba,tr as bc,cc as bi,i as bl,ed as bn,Po as bo,Pu as br,Er as bs,fl as bt,cp as c,T as ca,Nr as cc,fc as ci,nt as cl,Fc as cn,yo as co,Zc as cr,hr as cs,Ol as ct,Zf as d,Pa as da,dr as dc,Cc as di,at as dl,$l as dn,os as do,Ql as dr,Oi as ds,Hc as dt,ia as ea,gr as ec,Nc as ei,Et as el,j as en,xo as eo,El as er,Ii as es,U as et,qf as f,La as fa,ur as fc,bc as fi,it as fl,Vl as fn,qo as fo,uu as fr,wi as fs,Wc as ft,Uf as g,ya as ga,Un as gc,dc as gi,ke as gl,Tc as gn,Eo as go,Bu as gr,kr as gs,gl as gt,Lf as h,va as ha,ar as hc,hc as hi,We as hl,eu as hn,Zo as ho,sd as hr,Or as hs,td as ht,dp as i,Vo as ia,Xr as ic,_c as ii,ft as il,bu as in,ho as io,rl as ir,$r as is,cl as it,hf as j,fo as ja,Yn as jc,Da as ji,nd as jn,ca as jo,Ku as jr,Ni as js,ml as jt,yf as k,ba as ka,sr as kc,cs as ki,Al as kn,oa as ko,dd as kr,vr as ks,nl as kt,lp as l,aa as la,Fr as lc,pc as li,rt as ll,M as ln,na as lo,Xu as lr,_r as ls,il as lt,Hf as m,No as ma,Kn as mc,mc as mi,ae as ml,Jc as mn,Ga as mo,fu as mr,pr as ms,Uu as mt,mp as n,bo as na,qr as nc,Yc as ni,wt as nl,Pl as nn,Fo as no,au as nr,Yi as ns,zl as nt,op as o,Ia as oa,Sr as oc,gc as oi,tt as ol,k as on,uo as oo,hl as or,di as os,kl as ot,Kf as p,Ua as pa,b as pc,Sc as pi,h as pl,Wl as pn,ns as po,tl as pr,Ki as ps,Lu as pt,G as q,Wo as qa,pt as qc,pa as qi,Tl as qn,Wr as qo,Nl as qr,Fi as qs,Vu as qt,hp as r,Ro as ra,ci as rc,tu as ri,Ot as rl,qu as rn,ts as ro,$c as rr,Br as rs,Jl as rt,tp as s,no as sa,ui as sc,vc as si,y as sl,Kc as sn,Oo as so,Yl as sr,Lr as ss,jl as st,gp as t,da as ta,mr as tc,Pc as ti,At as tl,Fu as tn,Xo as to,Ml as tr,Bi as ts,md as tt,Xf as u,vo as ua,Rr as uc,xc as ui,ot as ul,Il as un,ss as uo,H as ur,Si as us,ol as ut,Vf as v,Oa as va,Qn as vc,ic as vi,a as vl,Au as vn,Ho as vo,gu as vr,wr as vs,ku as vt,Of as w,mo as wa,Zn as wc,ec as wi,s as wl,Gl as wn,Ka as wo,R as wr,Ji as ws,wu as wt,Pf as x,Ea as xa,Xn as xc,oc as xi,r as xl,cd as xn,Ra as xo,Du as xr,fi as xs,Dc as xt,Ff as y,ja as ya,Hn as yc,nc as yi,o as yl,V as yn,To as yo,Ul as yr,Dr as ys,nu as yt,zd as z,zo as za,yt as zc,rs as zi,od as zn,$i as zo,ld as zr,Ri as zs,Hl as zt};
@@ -0,0 +1,3 @@
1
+ import{t as e}from"./dist-tJoQXAF6.js";function t(e,t,n){return n===1?e:t}const n={USER_ERROR:`USER_ERROR`,RUNTIME_ERROR:`RUNTIME_ERROR`,CORRUPTED_EVENT_LOG:`CORRUPTED_EVENT_LOG`,REPLAY_DIVERGENCE:`REPLAY_DIVERGENCE`,MAX_DELIVERIES_EXCEEDED:`MAX_DELIVERIES_EXCEEDED`,MAX_EVENTS_EXCEEDED:`MAX_EVENTS_EXCEEDED`,REPLAY_TIMEOUT:`REPLAY_TIMEOUT`,WORLD_CONTRACT_ERROR:`WORLD_CONTRACT_ERROR`,DEPLOYMENT_MISMATCH:`DEPLOYMENT_MISMATCH`};function r(e){return typeof e==`object`&&!!e&&`name`in e&&`message`in e}function i(e,t){if(t.length===0)return e;let n=[e];return t.forEach((e,r)=>{let i=r===t.length-1,a=i?`╰▶ `:`├▶ `,o=i?` `:`│ `;`${e.label}: ${e.value}`.split(`
2
+ `).forEach((e,t)=>{n.push(`${t===0?a:o}${e}`)})}),n.join(`
3
+ `)}function a(e,t){let n=[];return e&&n.push({label:`hint`,value:e}),t&&n.push({label:`docs`,value:`https://workflow-sdk.dev/err/${t}`}),n}const o={NODE_JS_MODULE_IN_WORKFLOW:`node-js-module-in-workflow`,START_INVALID_WORKFLOW_FUNCTION:`start-invalid-workflow-function`,SERIALIZATION_FAILED:`serialization-failed`,WEBHOOK_INVALID_RESPOND_WITH_VALUE:`webhook-invalid-respond-with-value`,WEBHOOK_RESPONSE_NOT_SENT:`webhook-response-not-sent`,FETCH_IN_WORKFLOW_FUNCTION:`fetch-in-workflow`,TIMEOUT_FUNCTIONS_IN_WORKFLOW:`timeout-in-workflow`,HOOK_CONFLICT:`hook-conflict`,CORRUPTED_EVENT_LOG:`corrupted-event-log`,REPLAY_DIVERGENCE:`replay-divergence`,STEP_NOT_REGISTERED:`step-not-registered`,WORKFLOW_NOT_REGISTERED:`workflow-not-registered`,RUNTIME_DECRYPTION_FAILED:`runtime-decryption-failed`,DEPLOYMENT_MISMATCH:`deployment-mismatch`};var s=class extends Error{cause;constructor(e,t){let n=i(e,a(void 0,t?.slug));super(n,{cause:t?.cause}),t?.cause!==void 0&&(this.cause=t.cause),t?.cause instanceof Error&&(this.stack=`${this.stack}\nCaused by: ${t.cause.stack}`)}static is(e){return r(e)&&e.name===`WorkflowError`}},c=class extends s{status;code;url;retryAfter;constructor(e,t){super(e,{cause:t?.cause}),this.name=`WorkflowWorldError`,this.status=t?.status,this.code=t?.code,this.url=t?.url,this.retryAfter=t?.retryAfter}static is(e){return r(e)&&e.name===`WorkflowWorldError`}},l=class extends s{runId;errorCode;constructor(e,t,n={}){let r=t instanceof Error?t.message:typeof t==`string`?t:t&&typeof t==`object`&&`message`in t?String(t.message):`Unknown error`;super(`Workflow run "${e}" failed: ${r}`,{cause:t}),this.name=`WorkflowRunFailedError`,this.runId=e,n.errorCode!==void 0&&(this.errorCode=n.errorCode)}static is(e){return r(e)&&e.name===`WorkflowRunFailedError`}},u=class extends s{runId;status;constructor(e,t){super(`Workflow run "${e}" has not completed`,{}),this.name=`WorkflowRunNotCompletedError`,this.runId=e,this.status=t}static is(e){return r(e)&&e.name===`WorkflowRunNotCompletedError`}},d=class extends s{constructor(e,t){super(e,{...t}),this.name=`WorkflowRuntimeError`}static is(e){return r(e)&&e.name===`WorkflowRuntimeError`}},f=class extends d{constructor(e,t){super(e,{...t,slug:o.CORRUPTED_EVENT_LOG}),this.name=`CorruptedEventLogError`}static is(e){return r(e)&&e.name===`CorruptedEventLogError`}},p=class extends d{eventId;constructor(e,t){super(e,{...t,slug:o.REPLAY_DIVERGENCE}),this.name=`ReplayDivergenceError`,this.eventId=t.eventId}static is(e){return r(e)&&e.name===`ReplayDivergenceError`&&typeof e.eventId==`string`}},m=class extends s{eventCount;limit;constructor(e,t,n){super(`Workflow exceeded the maximum of ${t} events per run`,n),this.name=`MaxEventsExceededError`,this.eventCount=e,this.limit=t}static is(e){return r(e)&&e.name===`MaxEventsExceededError`}},h=class extends d{constructor(e,t){super(e,{cause:t?.cause,slug:o.RUNTIME_DECRYPTION_FAILED}),this.name=`RuntimeDecryptionError`,t?.context!==void 0&&(this.context=t.context)}static is(e){return r(e)&&e.name===`RuntimeDecryptionError`}},g=class extends s{hint;constructor(e,t){let n=i(e,a(t?.hint,void 0));super(n,{cause:t?.cause}),this.name=`WorkflowBuildError`,this.hint=t?.hint}static is(e){return r(e)&&e.name===`WorkflowBuildError`}},_=class extends s{hint;fatal=!0;constructor(e,t){let n=i(e,a(t?.hint,void 0));super(n,{cause:t?.cause}),this.name=`SerializationError`,this.hint=t?.hint}static is(e){return r(e)&&e.name===`SerializationError`}},v=class extends d{stepName;constructor(e){super(`Step "${e}" is not registered in the current deployment. This usually indicates a build or bundling issue that caused the step to not be included in the deployment.`,{slug:o.STEP_NOT_REGISTERED}),this.name=`StepNotRegisteredError`,this.stepName=e}static is(e){return r(e)&&e.name===`StepNotRegisteredError`}},y=class extends d{workflowName;constructor(e){super(`Workflow "${e}" is not registered in the current deployment. This usually means a run was started against a deployment that does not have this workflow, or there was a build/bundling issue.`,{slug:o.WORKFLOW_NOT_REGISTERED}),this.name=`WorkflowNotRegisteredError`,this.workflowName=e}static is(e){return r(e)&&e.name===`WorkflowNotRegisteredError`}},b=class extends d{runId;expectedDeploymentId;actualDeploymentId;recoveryAttempts;constructor(e,n,r,i){let a=i?.recoveryAttempts??0,s=a>0?` The runtime re-routed the message to "${n}" ${a} ${t(`time`,`times`,a)} and it kept arriving elsewhere, so the run was stopped to protect against code-skew errors.`:` The run was stopped to protect against code-skew errors.`;super(`Workflow run "${e}" is pinned to deployment "${n}", but was received by deployment "${r}".${s} Verify that the run's deployment is still available and that queue callbacks are routed to it.`,{slug:o.DEPLOYMENT_MISMATCH,cause:i?.cause}),this.name=`WorkflowDeploymentMismatchError`,this.runId=e,this.expectedDeploymentId=n,this.actualDeploymentId=r,this.recoveryAttempts=a}static is(e){return r(e)&&e.name===`WorkflowDeploymentMismatchError`}},x=class extends s{runId;constructor(e){super(`Workflow run "${e}" not found`,{}),this.name=`WorkflowRunNotFoundError`,this.runId=e}static is(e){return r(e)&&e.name===`WorkflowRunNotFoundError`}},S=class extends s{token;conflictingRunId;constructor(e,t){super(`Hook token "${e}" is already in use by another workflow${t?` (run "${t}")`:``}`,{slug:o.HOOK_CONFLICT}),this.name=`HookConflictError`,this.token=e,t!==void 0&&(this.conflictingRunId=t)}static is(e){return r(e)&&e.name===`HookConflictError`}},C=class extends s{token;constructor(e){super(`Hook not found`,{}),this.name=`HookNotFoundError`,this.token=e}static is(e){return r(e)&&e.name===`HookNotFoundError`}},w=class extends c{constructor(e){super(e),this.name=`EntityConflictError`}static is(e){return r(e)&&e.name===`EntityConflictError`}},T=class extends c{constructor(e){super(e),this.name=`RunExpiredError`}static is(e){return r(e)&&e.name===`RunExpiredError`}},E=class extends c{constructor(e,t){super(e,{retryAfter:t?.retryAfter}),this.name=`TooEarlyError`}static is(e){return r(e)&&e.name===`TooEarlyError`}},D=class extends c{retryAfter;constructor(e,t){super(e),this.name=`ThrottleError`,this.retryAfter=t?.retryAfter}static is(e){return r(e)&&e.name===`ThrottleError`}},O=class extends c{details;constructor(e,t){super(e,{status:412,retryAfter:t?.retryAfter}),this.name=`PreconditionFailedError`,this.details=t?.details}static is(e){return r(e)&&e.name===`PreconditionFailedError`}},k=class extends s{runId;constructor(e){super(`Workflow run "${e}" cancelled`,{}),this.name=`WorkflowRunCancelledError`,this.runId=e}static is(e){return r(e)&&e.name===`WorkflowRunCancelledError`}},A=class extends s{runSpecVersion;worldSpecVersion;constructor(e,t){super(`Run requires spec version ${e}, but world supports version ${t}. Please upgrade 'workflow' package.`),this.name=`RunNotSupportedError`,this.runSpecVersion=e,this.worldSpecVersion=t}static is(e){return r(e)&&e.name===`RunNotSupportedError`}},j=class extends Error{fatal=!0;constructor(e){super(e),this.name=`FatalError`}static is(e){return r(e)?e.name===`FatalError`||e.fatal===!0:!1}},M=class extends Error{retryAfter;constructor(t,n={}){super(t),this.name=`RetryableError`,n.retryAfter===void 0?this.retryAfter=new Date(Date.now()+1e3):this.retryAfter=e(n.retryAfter)}static is(e){return r(e)&&e.name===`RetryableError`}};const N="Your current vercel account does not have access to this resource. Use `vercel login` or `vercel switch` to ensure you are linked to the right account.",P=Symbol.for(`@workflow/errors//FatalError`),F=Symbol.for(`@workflow/errors//RetryableError`),I=Symbol.for(`@workflow/errors//HookConflictError`),L=Symbol.for(`@workflow/errors//RuntimeDecryptionError`);typeof globalThis<`u`&&(Object.hasOwn(globalThis,P)||Object.defineProperty(globalThis,P,{value:j,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,F)||Object.defineProperty(globalThis,F,{value:M,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,I)||Object.defineProperty(globalThis,I,{value:S,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,L)||Object.defineProperty(globalThis,L,{value:h,writable:!1,enumerable:!1,configurable:!1}));export{t as A,k as C,d as D,x as E,c as O,y as S,u as T,E as _,S as a,b,O as c,T as d,A as f,D as g,v as h,j as i,n as k,p as l,_ as m,o as n,C as o,h as p,w as r,m as s,f as t,M as u,N as v,l as w,s as x,g as y};
@@ -0,0 +1 @@
1
+ import{o as e,t}from"./rolldown-runtime-DaDcL9Zw.js";var n=t(((e,t)=>{var n=1e3,r=n*60,i=r*60,a=i*24,o=a*7,s=a*365.25;t.exports=function(e,t){t||={};var n=typeof e;if(n===`string`&&e.length>0)return c(e);if(n===`number`&&isFinite(e))return t.long?u(e):l(e);throw Error(`val is not a non-empty string or a valid number. val=`+JSON.stringify(e))};function c(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var c=parseFloat(t[1]);switch((t[2]||`ms`).toLowerCase()){case`years`:case`year`:case`yrs`:case`yr`:case`y`:return c*s;case`weeks`:case`week`:case`w`:return c*o;case`days`:case`day`:case`d`:return c*a;case`hours`:case`hour`:case`hrs`:case`hr`:case`h`:return c*i;case`minutes`:case`minute`:case`mins`:case`min`:case`m`:return c*r;case`seconds`:case`second`:case`secs`:case`sec`:case`s`:return c*n;case`milliseconds`:case`millisecond`:case`msecs`:case`msec`:case`ms`:return c;default:return}}}}function l(e){var t=Math.abs(e);return t>=a?Math.round(e/a)+`d`:t>=i?Math.round(e/i)+`h`:t>=r?Math.round(e/r)+`m`:t>=n?Math.round(e/n)+`s`:e+`ms`}function u(e){var t=Math.abs(e);return t>=a?d(e,t,a,`day`):t>=i?d(e,t,i,`hour`):t>=r?d(e,t,r,`minute`):t>=n?d(e,t,n,`second`):e+` ms`}function d(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+` `+r+(i?`s`:``)}})),r=e(n(),1);function i(e){if(typeof e==`string`){let t=(0,r.default)(e);if(typeof t!=`number`||t<0)throw Error(`Invalid duration: "${e}". Expected a valid duration string like "1s", "1m", "1h", etc.`);return new Date(Date.now()+t)}else if(typeof e==`number`){if(e<0||!Number.isFinite(e))throw Error(`Invalid duration: ${e}. Expected a non-negative finite number of milliseconds.`);return new Date(Date.now()+e)}else if(e instanceof Date||e&&typeof e==`object`&&typeof e.getTime==`function`)return e instanceof Date?e:new Date(e.getTime());else throw Error(`Invalid duration parameter. Expected a duration string, number (milliseconds), or Date object.`)}export{n,i as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./rolldown-runtime-DaDcL9Zw.js";var t=e(((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,{CITY_HEADER_NAME:()=>u,COUNTRY_HEADER_NAME:()=>d,EMOJI_FLAG_UNICODE_STARTING_POSITION:()=>v,IP_HEADER_NAME:()=>f,LATITUDE_HEADER_NAME:()=>p,LONGITUDE_HEADER_NAME:()=>m,POSTAL_CODE_HEADER_NAME:()=>g,REGION_HEADER_NAME:()=>h,REQUEST_ID_HEADER_NAME:()=>_,geolocation:()=>w,ipAddress:()=>S}),t.exports=c(l);let u=`x-vercel-ip-city`,d=`x-vercel-ip-country`,f=`x-real-ip`,p=`x-vercel-ip-latitude`,m=`x-vercel-ip-longitude`,h=`x-vercel-ip-country-region`,g=`x-vercel-ip-postal-code`,_=`x-vercel-id`,v=127397;function y(e,t){return e.get(t)??void 0}function b(e,t){let n=y(e.headers,t);return n?decodeURIComponent(n):void 0}function x(e){let t=RegExp(`^[A-Z]{2}$`).test(e);if(!(!e||!t))return String.fromCodePoint(...e.split(``).map(e=>v+e.charCodeAt(0)))}function S(e){return y(`headers`in e?e.headers:e,f)}function C(e){return e?e.split(`:`)[0]:`dev1`}function w(e){return{city:b(e,u),country:y(e.headers,d),flag:x(y(e.headers,d)),countryRegion:y(e.headers,h),region:C(y(e.headers,_)),latitude:y(e.headers,p),longitude:y(e.headers,m),postalCode:y(e.headers,g)}}0&&(t.exports={CITY_HEADER_NAME:u,COUNTRY_HEADER_NAME:d,EMOJI_FLAG_UNICODE_STARTING_POSITION:v,IP_HEADER_NAME:f,LATITUDE_HEADER_NAME:p,LONGITUDE_HEADER_NAME:m,POSTAL_CODE_HEADER_NAME:g,REGION_HEADER_NAME:h,REQUEST_ID_HEADER_NAME:_,geolocation:w,ipAddress:S})})),n=e(((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,{getEnv:()=>u}),t.exports=c(l);let u=(e=process.env)=>({VERCEL:d(e,`VERCEL`),CI:d(e,`CI`),VERCEL_ENV:d(e,`VERCEL_ENV`),VERCEL_URL:d(e,`VERCEL_URL`),VERCEL_BRANCH_URL:d(e,`VERCEL_BRANCH_URL`),VERCEL_PROJECT_PRODUCTION_URL:d(e,`VERCEL_PROJECT_PRODUCTION_URL`),VERCEL_REGION:d(e,`VERCEL_REGION`),VERCEL_DEPLOYMENT_ID:d(e,`VERCEL_DEPLOYMENT_ID`),VERCEL_SKEW_PROTECTION_ENABLED:d(e,`VERCEL_SKEW_PROTECTION_ENABLED`),VERCEL_AUTOMATION_BYPASS_SECRET:d(e,`VERCEL_AUTOMATION_BYPASS_SECRET`),VERCEL_GIT_PROVIDER:d(e,`VERCEL_GIT_PROVIDER`),VERCEL_GIT_REPO_SLUG:d(e,`VERCEL_GIT_REPO_SLUG`),VERCEL_GIT_REPO_OWNER:d(e,`VERCEL_GIT_REPO_OWNER`),VERCEL_GIT_REPO_ID:d(e,`VERCEL_GIT_REPO_ID`),VERCEL_GIT_COMMIT_REF:d(e,`VERCEL_GIT_COMMIT_REF`),VERCEL_GIT_COMMIT_SHA:d(e,`VERCEL_GIT_COMMIT_SHA`),VERCEL_GIT_COMMIT_MESSAGE:d(e,`VERCEL_GIT_COMMIT_MESSAGE`),VERCEL_GIT_COMMIT_AUTHOR_LOGIN:d(e,`VERCEL_GIT_COMMIT_AUTHOR_LOGIN`),VERCEL_GIT_COMMIT_AUTHOR_NAME:d(e,`VERCEL_GIT_COMMIT_AUTHOR_NAME`),VERCEL_GIT_PREVIOUS_SHA:d(e,`VERCEL_GIT_PREVIOUS_SHA`),VERCEL_GIT_PULL_REQUEST_ID:d(e,`VERCEL_GIT_PULL_REQUEST_ID`)}),d=(e,t)=>{let n=e[t];return n===``?void 0:n};0&&(t.exports={getEnv:u})})),r=e(((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})})),i=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==r&&n(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{getDeadline:()=>f}),t.exports=l(u);var d=r();function f(){let e=(0,d.getContext)().deadline;if(e===void 0)return;let t=new Date(e);if(!isNaN(t.getTime()))return t}0&&(t.exports={getDeadline:f})})),a=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==r&&n(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{waitUntil:()=>f}),t.exports=l(u);var d=r();let f=e=>{if(typeof e!=`object`||!e||typeof e.then!=`function`)throw TypeError(`waitUntil can only be called with a Promise, got ${typeof e}`);return(0,d.getContext)().waitUntil?.(e)};0&&(t.exports={waitUntil:f})})),o=e(((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,{next:()=>f,rewrite:()=>d}),t.exports=c(l);function u(e,t){if(e?.request?.headers){if(!(e.request.headers instanceof Headers))throw Error(`request.headers must be an instance of Headers`);let n=[];for(let[r,i]of e.request.headers)t.set(`x-middleware-request-`+r,i),n.push(r);t.set(`x-middleware-override-headers`,n.join(`,`))}}function d(e,t){let n=new Headers(t?.headers??{});return n.set(`x-middleware-rewrite`,String(e)),u(t,n),new Response(null,{...t,headers:n})}function f(e){let t=new Headers(e?.headers??{});return t.set(`x-middleware-next`,`1`),u(e,t),new Response(null,{...e,headers:t})}0&&(t.exports={next:f,rewrite:d})})),s=e(((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,{InMemoryCache:()=>u}),t.exports=c(l);var u=class{constructor(){this.cache={}}async get(e){let t=this.cache[e];return t?t.ttl&&t.lastModified+t.ttl*1e3<Date.now()?(await this.delete(e),null):JSON.parse(t.value):null}async set(e,t,n){let r=JSON.stringify(t??null);this.cache[e]={value:r,lastModified:Date.now(),ttl:n?.ttl,tags:new Set(n?.tags||[])}}async delete(e){delete this.cache[e]}async expireTag(e){let t=Array.isArray(e)?e:[e];for(let e in this.cache)if(Object.prototype.hasOwnProperty.call(this.cache,e)){let n=this.cache[e];t.some(e=>n.tags.has(e))&&delete this.cache[e]}}};0&&(t.exports={InMemoryCache:u})})),c=e(((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),u={};o(u,{BuildCache:()=>f}),t.exports=c(u);var d=l(),f=class{constructor({endpoint:e,headers:t,onError:n,timeout:r=500}){this.get=async e=>{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout);try{let r=await fetch(`${this.endpoint}${e}`,{headers:this.headers,method:`GET`,signal:t.signal});if(r.status===404)return clearTimeout(n),null;if(r.status===200){if(r.headers.get(d.HEADERS_VERCEL_CACHE_STATE)!==d.PkgCacheState.Fresh)return r.body?.cancel?.(),clearTimeout(n),null;let e=await r.json();return clearTimeout(n),e}else throw clearTimeout(n),Error(`Failed to get cache: ${r.statusText}`)}catch(e){if(clearTimeout(n),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e);return null}},this.set=async(e,t,n)=>{let r=new AbortController,i=setTimeout(()=>r.abort(),this.timeout);try{let a={};n?.ttl&&(a[d.HEADERS_VERCEL_REVALIDATE]=n.ttl.toString()),n?.tags&&n.tags.length>0&&(a[d.HEADERS_VERCEL_CACHE_TAGS]=n.tags.join(`,`)),n?.name&&(a[d.HEADERS_VERCEL_CACHE_ITEM_NAME]=n.name);let o=await fetch(`${this.endpoint}${e}`,{method:`POST`,headers:{...this.headers,...a},body:JSON.stringify(t),signal:r.signal});if(clearTimeout(i),o.status!==200)throw Error(`Failed to set cache: ${o.status} ${o.statusText}`)}catch(e){if(clearTimeout(i),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e)}},this.delete=async e=>{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout);try{let r=await fetch(`${this.endpoint}${e}`,{method:`DELETE`,headers:this.headers,signal:t.signal});if(clearTimeout(n),r.status!==200)throw Error(`Failed to delete cache: ${r.statusText}`)}catch(e){if(clearTimeout(n),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e)}},this.expireTag=async e=>{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout);try{Array.isArray(e)&&(e=e.join(`,`));let r=await fetch(`${this.endpoint}revalidate?tags=${e}`,{method:`POST`,headers:this.headers,signal:t.signal});if(clearTimeout(n),r.status!==200)throw Error(`Failed to revalidate tag: ${r.statusText}`)}catch(e){if(clearTimeout(n),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e)}},this.endpoint=e,this.headers=t,this.onError=n,this.timeout=r}};0&&(t.exports={BuildCache:f})})),l=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,l=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},u=(e,t,r,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==r&&n(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},d=e=>u(n({},`__esModule`,{value:!0}),e),f={};l(f,{HEADERS_VERCEL_CACHE_ITEM_NAME:()=>O,HEADERS_VERCEL_CACHE_STATE:()=>T,HEADERS_VERCEL_CACHE_TAGS:()=>D,HEADERS_VERCEL_REVALIDATE:()=>E,PkgCacheState:()=>w,getCache:()=>y}),t.exports=d(f);var p=r(),m=s(),h=c();let g=e=>{let t=5381;for(let n=0;n<e.length;n++)t=t*33^e.charCodeAt(n);return(t>>>0).toString(16)},_=null,v=null,y=e=>x(()=>{let e;return e=(0,p.getContext)().cache?(0,p.getContext)().cache:C(process.env.SUSPENSE_CACHE_DEBUG===`true`),e},b(e));function b(e){let t=e?.keyHashFunction||g;return n=>{if(!e?.namespace)return t(n);let r=e.namespaceSeparator||`$`;return`${e.namespace}${r}${t(n)}`}}function x(e,t){return{get:n=>e().get(t(n)),set:(n,r,i)=>e().set(t(n),r,{...i,name:i?.name??n}),delete:n=>e().delete(t(n)),expireTag:t=>e().expireTag(t)}}let S=!1;function C(e){if(_||=new m.InMemoryCache,process.env.RUNTIME_CACHE_DISABLE_BUILD_CACHE===`true`)return e&&console.log(`Using InMemoryCache as build cache is disabled`),_;let{RUNTIME_CACHE_ENDPOINT:t,RUNTIME_CACHE_HEADERS:n}=process.env;if(e&&console.log(`Runtime cache environment variables:`,{RUNTIME_CACHE_ENDPOINT:t,RUNTIME_CACHE_HEADERS:n}),!t||!n)return S||=(console.warn(`Runtime Cache unavailable in this environment. Falling back to in-memory cache.`),!0),_;if(!v){let e={};try{e=JSON.parse(n)}catch(e){return console.error(`Failed to parse RUNTIME_CACHE_HEADERS:`,e),_}let r=500;if(process.env.RUNTIME_CACHE_TIMEOUT){let e=parseInt(process.env.RUNTIME_CACHE_TIMEOUT,10);!isNaN(e)&&e>0?r=e:console.warn(`Invalid RUNTIME_CACHE_TIMEOUT value: "${process.env.RUNTIME_CACHE_TIMEOUT}". Using default: ${r}ms`)}v=new h.BuildCache({endpoint:t,headers:e,onError:e=>console.error(e),timeout:r})}return v}var w=(e=>(e.Fresh=`fresh`,e.Stale=`stale`,e.Expired=`expired`,e.NotFound=`notFound`,e.Error=`error`,e))(w||{});let T=`x-vercel-cache-state`,E=`x-vercel-revalidate`,D=`x-vercel-cache-tags`,O=`x-vercel-cache-item-name`;0&&(t.exports={HEADERS_VERCEL_CACHE_ITEM_NAME:O,HEADERS_VERCEL_CACHE_STATE:T,HEADERS_VERCEL_CACHE_TAGS:D,HEADERS_VERCEL_REVALIDATE:E,PkgCacheState:w,getCache:y})})),u=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==r&&n(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{attachDatabasePool:()=>v,experimental_attachDatabasePool:()=>y}),t.exports=l(u);var d=r();let f=!!process.env.DEBUG;function p(e){if(`options`in e&&e.options){if(`idleTimeoutMillis`in e.options)return typeof e.options.idleTimeoutMillis==`number`?e.options.idleTimeoutMillis:1e4;if(`maxIdleTimeMS`in e.options)return typeof e.options.maxIdleTimeMS==`number`?e.options.maxIdleTimeMS:0;if(`status`in e)return 5e3;if(`connect`in e&&`execute`in e)return 3e4}if(`config`in e&&e.config){if(`connectionConfig`in e.config&&e.config.connectionConfig)return e.config.connectionConfig.idleTimeout||6e4;if(`idleTimeout`in e.config)return typeof e.config.idleTimeout==`number`?e.config.idleTimeout:6e4}return`poolTimeout`in e?typeof e.poolTimeout==`number`?e.poolTimeout:6e4:`idleTimeout`in e?typeof e.idleTimeout==`number`?e.idleTimeout:0:1e4}let m=null,h=()=>{},g=Date.now();function _(e){if(!process.env.VERCEL_URL||!process.env.VERCEL_REGION)return;m&&(clearTimeout(m),h());let t=new Promise(e=>{h=e}),n=Math.min(p(e)+100,Math.max(100,899e3-(Date.now()-g)));m=setTimeout(()=>{h?.(),f&&console.log(`Database pool idle timeout reached. Releasing connections.`)},n);let r=(0,d.getContext)();r?.waitUntil?r.waitUntil(t):console.warn(`Pool release event triggered outside of request scope.`)}function v(e){if(m&&(h?.(),clearTimeout(m)),`on`in e&&e.on&&`options`in e&&`idleTimeoutMillis`in e.options){e.on(`release`,()=>{f&&console.log(`Client released from pool`),_(e)});return}else if(`on`in e&&e.on&&`config`in e&&e.config&&`connectionConfig`in e.config){e.on(`release`,()=>{f&&console.log(`MySQL client released from pool`),_(e)});return}else if(`on`in e&&e.on&&`config`in e&&e.config&&`idleTimeout`in e.config){e.on(`release`,()=>{f&&console.log(`MySQL2/MariaDB client released from pool`),_(e)});return}if(`on`in e&&e.on&&`options`in e&&e.options&&`maxIdleTimeMS`in e.options){e.on(`connectionCheckedOut`,()=>{f&&console.log(`MongoDB connection checked out`),_(e)});return}if(`on`in e&&e.on&&`options`in e&&e.options&&`socket`in e.options){e.on(`end`,()=>{f&&console.log(`Redis connection ended`),_(e)});return}throw Error(`Unsupported database pool type`)}let y=v;0&&(t.exports={attachDatabasePool:v,experimental_attachDatabasePool:y})})),d=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==r&&n(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{dangerouslyDeleteBySrcImage:()=>h,dangerouslyDeleteByTag:()=>p,invalidateBySrcImage:()=>m,invalidateByTag:()=>f}),t.exports=l(u);var d=r();let f=e=>{let t=(0,d.getContext)().purge;return t?t.invalidateByTag(e):Promise.resolve()},p=(e,t)=>{let n=(0,d.getContext)().purge;return n?n.dangerouslyDeleteByTag(e,t):Promise.resolve()},m=e=>{let t=(0,d.getContext)().purge;return t?t.invalidateBySrcImage(e):Promise.resolve()},h=(e,t)=>{let n=(0,d.getContext)().purge;return n?n.dangerouslyDeleteBySrcImage(e,t):Promise.resolve()};0&&(t.exports={dangerouslyDeleteBySrcImage:h,dangerouslyDeleteByTag:p,invalidateBySrcImage:m,invalidateByTag:f})})),f=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==r&&n(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{addCacheTag:()=>f}),t.exports=l(u);var d=r();let f=e=>{let t=(0,d.getContext)().addCacheTag;return t?t(e):Promise.resolve()};0&&(t.exports={addCacheTag:f})})),p=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==r&&n(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{experimental_upgradeWebSocket:()=>p}),t.exports=l(u);var d=r();async function f(){try{return(await import(`./wrapper-6mlyNCCb.js`)).WebSocketServer}catch{throw Error(`The "ws" package is required for experimental_upgradeWebSocket(). Install it with: npm install ws`)}}async function p(e,t={}){let n=(0,d.getContext)();if(typeof n.upgradeWebSocket!=`function`)throw Error(`experimental_upgradeWebSocket is not available in the current runtime environment. This feature requires a Vercel runtime that supports WebSocket upgrades.`);let r=await f(),{req:i,socket:a,head:o}=n.upgradeWebSocket(),s=new r({noServer:!0,maxPayload:t.maxPayload??262144}),c=await new Promise((e,t)=>{let n=()=>{a.removeListener(`error`,l),a.removeListener(`close`,u)},r=e=>{if(n(),e instanceof Error){t(e);return}let r=Error(`WebSocket upgrade failed`);r.cause=e,t(r)},c=t=>{n(),e(t)},l=e=>r(e),u=()=>r(Error(`socket closed before the WebSocket upgrade completed`));a.once(`error`,l),a.once(`close`,u);try{s.handleUpgrade(i,a,o,c)}catch(e){r(e)}});try{await e(c)}catch(e){throw c.close(1011,`WebSocket handler failed`),e}return new Response(null,{status:204})}0&&(t.exports={experimental_upgradeWebSocket:p})})),m=e(((e,r)=>{var s=Object.defineProperty,c=Object.getOwnPropertyDescriptor,m=Object.getOwnPropertyNames,h=Object.prototype.hasOwnProperty,g=(e,t)=>{for(var n in t)s(e,n,{get:t[n],enumerable:!0})},_=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of m(t))!h.call(e,i)&&i!==n&&s(e,i,{get:()=>t[i],enumerable:!(r=c(t,i))||r.enumerable});return e},v=e=>_(s({},`__esModule`,{value:!0}),e),y={};g(y,{addCacheTag:()=>O.addCacheTag,attachDatabasePool:()=>E.attachDatabasePool,dangerouslyDeleteBySrcImage:()=>D.dangerouslyDeleteBySrcImage,dangerouslyDeleteByTag:()=>D.dangerouslyDeleteByTag,experimental_attachDatabasePool:()=>E.experimental_attachDatabasePool,experimental_upgradeWebSocket:()=>k.experimental_upgradeWebSocket,geolocation:()=>b.geolocation,getCache:()=>T.getCache,getDeadline:()=>S.getDeadline,getEnv:()=>x.getEnv,invalidateBySrcImage:()=>D.invalidateBySrcImage,invalidateByTag:()=>D.invalidateByTag,ipAddress:()=>b.ipAddress,next:()=>w.next,rewrite:()=>w.rewrite,waitUntil:()=>C.waitUntil}),r.exports=v(y);var b=t(),x=n(),S=i(),C=a(),w=o(),T=l(),E=u(),D=d(),O=f(),k=p();0&&(r.exports={addCacheTag,attachDatabasePool,dangerouslyDeleteBySrcImage,dangerouslyDeleteByTag,experimental_attachDatabasePool,experimental_upgradeWebSocket,geolocation,getCache,getDeadline,getEnv,invalidateBySrcImage,invalidateByTag,ipAddress,next,rewrite,waitUntil})}));export default m();export{};
@@ -1 +1 @@
1
- import"./dist-B-vbuNqP.js";function e(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function t(e){let t={get value(){let n=e();return Object.defineProperty(t,"value",{value:n}),n}};return t}const n=Symbol.for(`@workflow/core//registeredSteps`),r=globalThis,i=r[n]??=new Map,a=new Set([`__builtin_response_array_buffer`,`__builtin_response_json`,`__builtin_response_text`]);function o(e){let t=e.split(`//`);if(t.length!==3||t[0]!==`step`)return[];let n=t[1],r=t[2],i=new Set,a=e=>{e!==n&&i.add(e)};if(n.startsWith(`./workflows/`)){let e=n.slice(2);a(`./example/${e}`),a(`./src/${e}`)}else if(n.startsWith(`./example/workflows/`)){let e=n.slice(10);a(`./${e}`),a(`./src/${e}`)}else if(n.startsWith(`./src/workflows/`)){let e=n.slice(6);a(`./${e}`),a(`./example/${e}`)}return Array.from(i,e=>`step//${e}//${r}`)}function s(e){if(a.has(e)){for(let[t,n]of i.entries())if(t.endsWith(`//${e}`))return n}}function c(e,t){i.set(e,t),t.stepId=e}function l(e){let t=i.get(e);if(t)return t;for(let t of o(e)){let e=i.get(t);if(e)return e}let n=s(e);if(n)return n}const u={hook:[`wait`,`step`],wait:[`hook`,`step`],step:[`wait`,`hook`,`step`]};function d(e,t,n,r){let i=r.get(t);if(i!==void 0)return i;let a=f(e,t,n,r);return r.set(t,a),a}function f(e,t,n,r){if(!n.armed)return!1;if(n.kind===`step`)return!0;let i=u[n.kind];for(let[n,a]of e)if(n<t&&i.includes(a.kind)&&!d(e,n,a,r))return!1;return!0}async function p(e,t,n){if(t===void 0||!e.pendingDeliveryBarriers||e.pendingDeliveryBarriers.size===0)return;let r=e.pendingDeliveryBarriers,i=u[n],a=[],o=new Map;for(let[e,s]of r)e>=t||!i.includes(s.kind)||n===`step`&&!d(r,e,s,o)||a.push(s.delivered);a.length>0&&(await Promise.all(a),await new Promise(e=>setTimeout(e,0)))}function m(t,n,r,i={}){let a=t.pendingDeliveryBarriers;if(!a||n===void 0)return{markDelivered:()=>{},arm:()=>{}};let o=!1,{promise:s,resolve:c}=e(),l={kind:r,delivered:s,armed:i.armed??!0};a.set(n,l);let u=()=>{o||(o=!0,a.get(n)===l&&a.delete(n),c())};return g(t,u),{markDelivered:u,arm:()=>{l.armed=!0}}}function h(e){let t=e.pendingDeliveryBarriers;if(!t||t.size===0)return!1;let n=new Map;for(let[e,r]of t)if(d(t,e,r,n))return!0;return!1}function g(e,t){let n=()=>{e.pendingDeliveries>0||h(e)?e.promiseQueue.then(()=>{setTimeout(n,0)}):t()};setTimeout(n,0)}export{g as a,c as i,l as n,t as o,m as r,e as s,p as t};
1
+ import"./dist-tJoQXAF6.js";function e(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function t(e){let t={get value(){let n=e();return Object.defineProperty(t,"value",{value:n}),n}};return t}const n=Symbol.for(`@workflow/core//registeredSteps`),r=globalThis,i=r[n]??=new Map,a=new Set([`__builtin_response_array_buffer`,`__builtin_response_json`,`__builtin_response_text`]);function o(e){let t=e.split(`//`);if(t.length!==3||t[0]!==`step`)return[];let n=t[1],r=t[2],i=new Set,a=e=>{e!==n&&i.add(e)};if(n.startsWith(`./workflows/`)){let e=n.slice(2);a(`./example/${e}`),a(`./src/${e}`)}else if(n.startsWith(`./example/workflows/`)){let e=n.slice(10);a(`./${e}`),a(`./src/${e}`)}else if(n.startsWith(`./src/workflows/`)){let e=n.slice(6);a(`./${e}`),a(`./example/${e}`)}return Array.from(i,e=>`step//${e}//${r}`)}function s(e){if(a.has(e)){for(let[t,n]of i.entries())if(t.endsWith(`//${e}`))return n}}function c(e,t){i.set(e,t),t.stepId=e}function l(e){let t=i.get(e);if(t)return t;for(let t of o(e)){let e=i.get(t);if(e)return e}let n=s(e);if(n)return n}const u={hook:[`wait`,`step`],wait:[`hook`,`step`],step:[`wait`,`hook`,`step`]};function d(e,t,n,r){let i=r.get(t);if(i!==void 0)return i;let a=f(e,t,n,r);return r.set(t,a),a}function f(e,t,n,r){if(!n.armed)return!1;if(n.kind===`step`)return!0;let i=u[n.kind];for(let[n,a]of e)if(n<t&&i.includes(a.kind)&&!d(e,n,a,r))return!1;return!0}async function p(e,t,n){if(t===void 0||!e.pendingDeliveryBarriers||e.pendingDeliveryBarriers.size===0)return;let r=e.pendingDeliveryBarriers,i=u[n],a=[],o=new Map;for(let[e,s]of r)e>=t||!i.includes(s.kind)||n===`step`&&!d(r,e,s,o)||a.push(s.delivered);a.length>0&&(await Promise.all(a),await new Promise(e=>setTimeout(e,0)))}function m(t,n,r,i={}){let a=t.pendingDeliveryBarriers;if(!a||n===void 0)return{markDelivered:()=>{},arm:()=>{}};let o=!1,{promise:s,resolve:c}=e(),l={kind:r,delivered:s,armed:i.armed??!0};a.set(n,l);let u=()=>{o||(o=!0,a.get(n)===l&&a.delete(n),c())};return g(t,u),{markDelivered:u,arm:()=>{l.armed=!0}}}function h(e){let t=e.pendingDeliveryBarriers;if(!t||t.size===0)return!1;let n=new Map;for(let[e,r]of t)if(d(t,e,r,n))return!0;return!1}function g(e,t){let n=()=>{e.pendingDeliveries>0||h(e)?e.promiseQueue.then(()=>{setTimeout(n,0)}):t()};setTimeout(n,0)}export{g as a,c as i,l as n,t as o,m as r,e as s,p as t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-DaDcL9Zw.js";import{D as t,Dn as n,In as r,J as i,On as a,P as o,Rn as s,Tn as c,Yn as l,a as u,an as ee,at as d,ht as f,mn as p,mt as m,n as h,pt as g,rt as _,t as v,tr as y,vt as b,x,y as S}from"./wait-until-CMX5LUWJ.js";import{D as C,d as w,n as T,o as E,r as D}from"./dist-CRTn4Sg8.js";import{F as O,c as k}from"./dist-CNXUKQCp.js";import{t as A}from"./spec-version-C0hBsfu-.js";var j=e({getHookByToken:()=>R,resumeHook:()=>z,resumeWebhook:()=>V});const M=k();async function N(e){let t=await crypto.subtle.digest(`SHA-256`,e),n=new Uint8Array(t),r=``;for(let e of n)r+=e.toString(16).padStart(2,`0`);return r}function P(e){let t=e.executionContext?.workflowCoreVersion,n=e.executionContext?.traceCarrier,r=e.executionContext?.hookResumeInputVersion;return{deploymentId:e.deploymentId,workflowName:e.workflowName,runSpecVersion:e.specVersion,workflowCoreVersion:typeof t==`string`?t:void 0,traceCarrier:n&&typeof n==`object`?n:void 0,encryptionPublicKey:e.encryptionPublicKey,hookResumeInputVersion:typeof r==`number`?r:void 0}}async function F(e){if(e.resumeContext)return{resumeContext:e.resumeContext,source:`hook`};let t=await(await s()).runs.get(e.runId);return{resumeContext:P(t),source:`run_fallback`,run:t}}async function I(e,t){let n=await s(),r=t.run?await n.getEncryptionKeyForRun?.(t.run):await n.getEncryptionKeyForRun?.(e.runId,{deploymentId:t.resumeContext.deploymentId});return r?await y(r):void 0}async function L(e){let t=await s(),n=await t.hooks.getByToken(e),r;if(n.metadata!==void 0){let e=await F(n),i=e.run?await t.getEncryptionKeyForRun?.(e.run):await t.getEncryptionKeyForRun?.(n.runId,{deploymentId:e.resumeContext.deploymentId});r=i?await c(i):void 0,n.metadata=await o(n.metadata,n.runId,r)}return{hook:n,encryptionKey:r}}async function R(e){let{hook:t}=await L(e);return t}async function z(e,t,n){return B(e,t,n,!1)}async function B(e,o,c,l){return await h(()=>d(`hook.resume`,async d=>{let h=await s();try{let s=typeof e==`string`,g=s?await h.hooks.getByToken(e):e,y=s||l,C=await F(g),{resumeContext:T}=C;if(d?.setAttributes({...b(g.token),...m(g.hookId),...p(g.runId),"workflow.hook.resume_context_source":C.source}),C.run&&O(C.run.status))throw new E(g.token);let k=x(T.workflowCoreVersion),j,P=c?void 0:r(T.encryptionPublicKey);if(P)j=n(P);else{let e=c??await I(g,C);k.supportedFormats.has(a.ENCRYPTED)||(e=void 0),j=e}let L=(T.runSpecVersion??0)>=5&&k.supportedFormats.has(a.GZIP),R=[],z=A(g.specVersion),B=await t(o,g.runId,j,R,globalThis,z,k.framedByteStreams,L);v(Promise.all(R),e=>{e!==void 0&&i.warn(`Background flush of hook payload ops failed`,{workflowRunId:g.runId,hookId:g.hookId,error:e instanceof Error?e.message:String(e)})}),d?.setAttributes({...ee(T.workflowName)});let V=await _(T.traceCarrier);V&&d?.addLink?.(V);let H={...z?{}:{token:g.token},payload:B},U=u(T.workflowName),W={deploymentId:T.deploymentId,specVersion:T.runSpecVersion??1},G=process.env.WORKFLOW_DISABLE_LAZY_HOOK_RESUME===`1`,K=(y?g.resumeCapabilities?.hookResumeDedupVersion??0:0)>=1||h.capabilities?.hookResumeDedup===!0,q=G?`disabled`:K?(T.hookResumeInputVersion??0)<1?`consumer_unsupported`:z?`legacy`:(T.runSpecVersion??0)<3?`non_cbor_transport`:B instanceof Uint8Array?B.byteLength>131072?`oversized`:null:`non_bytes`:`backend_unsupported`,J=q===null;d?.setAttributes({"workflow.hook.resume_strategy":J?`parallel`:`sequential`,...q?{"workflow.hook.resume_fallback_reason":q}:{}});let te=e=>E.is(e)||D.is(e)||w.is(e);if(!J){try{await h.events.create(g.runId,{eventType:`hook_received`,specVersion:5,correlationId:g.hookId,eventData:H},{v1Compat:z})}catch(e){throw te(e)?new E(g.token):e}return await h.queue(U,{runId:g.runId,traceCarrier:T.traceCarrier??void 0},W),g}let Y=M(),X=await N(B);d?.setAttributes({"workflow.hook.resume_id":Y});let[Z,Q]=await Promise.allSettled([h.events.create(g.runId,{eventType:`hook_received`,specVersion:5,correlationId:g.hookId,eventData:H},{v1Compat:z,resumeId:Y,resumePayloadDigest:X}),h.queue(U,{runId:g.runId,traceCarrier:T.traceCarrier??void 0,hookInput:{resumeId:Y,hookId:g.hookId,token:g.token,payload:B,payloadDigest:X}},W)]);if(Q.status===`rejected`)throw Q.reason;let $=!1;if(Z.status===`rejected`){let e=Z.reason;if(E.is(e)||w.is(e))throw new E(g.token);if(D.is(e)||S(e))$=!0,d?.setAttributes({...f(!0),"workflow.hook.resume_event_write_recovered":!0,"workflow.hook.resume_event_write_error":e instanceof Error?e.name:`unknown`}),i.warn(`Hook resume event write failed, but the run was re-triggered via the queue. The hook_received event will be ensured by the queue consumer.`,{workflowRunId:g.runId,hookId:g.hookId,resumeId:Y,error:e instanceof Error?e.message:String(e)});else throw e}return $?{...g,resilientResume:!0}:g}catch(t){throw d?.setAttributes({...b(typeof e==`string`?e:e.token),...g(!1)}),t}}))}async function V(e,t){let{hook:n,encryptionKey:r}=await L(e);if(n.isWebhook===!1)throw new E(e);let i,a;if(n.metadata&&typeof n.metadata==`object`&&`respondWith`in n.metadata)if(n.metadata.respondWith===`manual`){let{readable:e,writable:n}=new TransformStream;a=e,t[l]=n}else if(n.metadata.respondWith instanceof Response)i=n.metadata.respondWith;else throw new C(`Invalid \`respondWith\` value: ${n.metadata.respondWith}`,{slug:T.WEBHOOK_INVALID_RESPOND_WITH_VALUE});else i=new Response(null,{status:202});if(await B(n,t,r,!0),a){let e=a.getReader(),t=await e.read();t.value&&(i=t.value),e.cancel()}if(!i)throw new C(`Workflow run did not send a response`,{slug:T.WEBHOOK_RESPONSE_NOT_SENT});return i}export{j as i,z as n,V as r,R as t};
@@ -0,0 +1 @@
1
+ import{Dn as e,Fn as t,In as n,J as r,K as i,L as a,Ln as o,Mn as s,N as c,Nn as l,O as u,On as d,R as f,Rn as p,Tn as m,Yt as ee,_ as h,a as g,an as te,at as _,cr as v,ct as ne,gn as re,it as ie,j as y,mn as ae,n as b,on as oe,q as x,s as S,t as se,tr as ce,x as C,y as w,zn as le}from"./wait-until-CMX5LUWJ.js";import{C as T,D as E,E as D,T as O,r as k,w as A}from"./dist-CRTn4Sg8.js";import{t as ue}from"./attribute-changes-Du5ztewf.js";import{X as j,Y as M,c as N,i as de}from"./dist-CNXUKQCp.js";import{t as P}from"./env-config-CYoX3muK.js";import{t as F}from"./spec-version-C0hBsfu-.js";const I=[`node`,`quickjs`];function L(e=process.env){let t=e.WORKFLOW_VM;if(!(t===void 0||t===``)){if(I.includes(t))return t;throw new E(`Invalid WORKFLOW_VM value: "${t}". Expected one of: ${I.join(`, `)}.`)}}function R(e){let t=e.executionContext?.workflowVm;if(t!==void 0){if(!I.includes(t))throw new E(`Invalid executionContext.workflowVm value: "${t}". Expected one of: ${I.join(`, `)}.`);return t===`quickjs`}return L()===`quickjs`}const z=N();function B(){let e=x.getStore(),t=e?.workflowMetadata?.workflowRunId;if(t)return{[j]:e.rootRunId??t,[M]:t}}let V=!1;async function H(i,a,s){"use step";return await b(()=>{let c=i?.workflowId;if(!c)throw new E(`'start' received an invalid workflow function. Ensure the Workflow SDK is configured correctly and the function includes a 'use workflow' directive.`,{slug:`start-invalid-workflow-function`});return _(`workflow.start ${v(c)}`,async i=>{i?.setAttributes({...te(c),...oe(`start`)});let l=[],f=s??{};Array.isArray(a)?l=a:typeof a==`object`&&(f=a),i?.setAttributes({...ee(l.length)});let m=f.world??await p();le(m);let _=await m.getDeploymentId(),v=f.deploymentId??_;v===`latest`&&(m.resolveLatestDeploymentId?v=await m.resolveLatestDeploymentId():(V||(V=!0,r.warn(`deploymentId: 'latest' has no effect in this world and was ignored. It is only supported by worlds with atomic deployments, such as Vercel. The run will target the current deployment.`,{currentDeploymentId:_})),v=_));let y=`wrun_${m.createRunId?m.createRunId(f):z()}`,b,x,T,D;if(v===_)b=!0,x=!0,T=1;else if(typeof m.streams?.get!=`function`)b=!1,x=!1,T=void 0;else{let e=await S(m,{deploymentId:v,runId:y,timeout:2e3,namespace:f.namespace}).catch(()=>void 0);D=e?.encryptionPublicKey;let t=C(e?.workflowCoreVersion);b=t.framedByteStreams,x=t.supportedFormats.has(d.GZIP),T=e?.hookResumeInputVersion}let O=[],A=await ie(),j=f.specVersion??m.specVersion,M=F(j),N=f.allowReservedAttributes===!0,P;if(f.attributes&&Object.keys(f.attributes).length>0){if(j<4)throw new E(`Initial workflow attributes require a World that supports spec version 4 or later.`);for(let[e,t]of Object.entries(f.attributes))if(typeof t!=`string`)throw new E(`Initial workflow attribute ${JSON.stringify(e)} must be a string value.`);let e=ue(f.attributes,{allowReservedAttributes:N});P=Object.fromEntries(e.map(({key:e,value:t})=>[e,t]))}let I=j>=4?B():void 0,R=I?{...I,...P}:P,H=R?{attributes:R,...N||I!=null?{allowReservedAttributes:!0}:{}}:{};if(f.replayedFromRunId!==void 0&&!de.safeParse(f.replayedFromRunId).success)throw new E(`replayedFromRunId must be a run ID (wrun_<ulid>); received ${JSON.stringify(String(f.replayedFromRunId).slice(0,64))}.`);let U=n(D),W,G;if(U)W=e(U),G=D;else{let e=await m.getEncryptionKeyForRun?.(y,{...f,deploymentId:v});W=e?await ce(e):void 0,G=e?t((await o(e)).publicKey):void 0}let K=await u(l,y,W,O,globalThis,M,b,x&&j>=5),q=m.getEnvironment?.(),J=L(),Y={traceCarrier:A,workflowCoreVersion:h,features:{encryption:!!W},...T===void 0?{}:{hookResumeInputVersion:T},...J?{workflowVm:J}:{},...f.replayedFromRunId?{replayedFromRunId:f.replayedFromRunId}:{}},[X,Z]=await Promise.allSettled([m.events.create(y,{eventType:`run_created`,specVersion:j,eventData:{deploymentId:v,workflowName:c,input:K,executionContext:Y,...G?{encryptionPublicKey:G}:{},...H}},{v1Compat:M}),m.queue(g(c,f.namespace),{runId:y,traceCarrier:A,...j>=3?{runInput:{input:K,deploymentId:v,workflowName:c,specVersion:j,executionContext:Y,...G?{encryptionPublicKey:G}:{},...q===void 0?{}:{environment:q},...H}}:{}},{deploymentId:v,specVersion:j,...f.region===void 0?{}:{region:f.region}})]);if(Z.status===`rejected`)throw Z.reason;let $=!1;if(X.status===`rejected`){let e=X.reason;if(!k.is(e))if(w(e))$=!0,r.warn(`Run creation event failed, but the run was accepted via the queue. The run_created event will be re-tried async by the runtime.`,{workflowRunId:y,error:e.message});else throw e}else{let e=X.value;if(!e.run)throw new E(`Missing 'run' in server response for 'run_created' event`);if(!M&&e.run.runId!==y)throw new E(`Server returned different runId than requested: expected ${y}, got ${e.run.runId}`)}return se(Promise.all(O),e=>{r.warn(`Background flush of workflow argument streams failed`,{workflowRunId:y,error:e instanceof Error?e.message:String(e)})}),i?.setAttributes({...ae(y),...ne(v),...X.status===`fulfilled`&&X.value.run?re(X.value.run.status):{}}),new Q(y,{resilientStart:$})})})}const U=e=>Array.isArray(e)?e:[e];async function W(e,t,n={}){try{let r=await e.runs.get(t,{resolveData:`all`}),i=await e.getEncryptionKeyForRun?.(r),o=i?await m(i):void 0,s=U(await a(r.input,t,o,globalThis)),c=n.specVersion??r.specVersion??1,l=n.deploymentId??r.deploymentId;return(await H({workflowId:r.workflowName},s,{deploymentId:l,world:e,specVersion:c,replayedFromRunId:t,namespace:n.namespace})).runId}catch(e){throw Error(`Failed to recreate run from ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function G(e,t,n){try{let r=(await e.runs.get(t,{resolveData:`none`})).specVersion??1,i=F(r),a={eventType:`run_cancelled`,specVersion:r,...n?.cancelReason===void 0?{}:{eventData:{cancelReason:n.cancelReason}}};await e.events.create(t,a,{v1Compat:i})}catch(e){throw Error(`Failed to cancel run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function K(e,t,n){if(t.length===0)throw Error(`cancelRuns requires at least one run ID.`);if(t.length>500)throw Error(`cancelRuns accepts at most 500 run IDs (received ${t.length}).`);if(new Set(t).size!==t.length)throw Error(`cancelRuns requires unique run IDs (duplicates found).`);if(e.runs.cancelMany)return e.runs.cancelMany({runIds:t,...n?.cancelReason===void 0?{}:{cancelReason:n.cancelReason}});let r=Array(t.length),i=0,a=async()=>{for(;;){let a=i++;if(a>=t.length)return;let o=t[a];try{await G(e,o,n),r[a]={runId:o,outcome:`cancelled`}}catch{r[a]={runId:o,outcome:`failed`,code:`internal_error`,retryable:!0}}}},o=Math.min(20,t.length);await Promise.all(Array.from({length:o},()=>a()));let s={requested:t.length,cancelled:0,alreadyCancelled:0,notCancellable:0,notFound:0,failed:0};for(let e of r)switch(e.outcome){case`cancelled`:s.cancelled++;break;case`already_cancelled`:s.alreadyCancelled++;break;case`not_cancellable`:s.notCancellable++;break;case`not_found`:s.notFound++;break;case`failed`:s.failed++;break}return{summary:s,results:r}}async function q(e,t,n){try{let r=await e.runs.get(t,{resolveData:`none`});await e.queue(g(r.workflowName,n?.namespace),{runId:t},{deploymentId:r.deploymentId,specVersion:r.specVersion??1})}catch(e){throw Error(`Failed to re-enqueue run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function J(e,t,n){try{let r=await e.runs.get(t,{resolveData:`none`}),i=F(r.specVersion),a=[],o=null;do{let n=await e.events.list({runId:t,pagination:{limit:1e3,...o?{cursor:o}:{}},resolveData:`none`});a.push(...n.data),o=n.hasMore?n.cursor:null}while(o);let s=a.filter(e=>e.eventType===`wait_created`),c=new Set(a.filter(e=>e.eventType===`wait_completed`).map(e=>e.correlationId)),l=s.filter(e=>!c.has(e.correlationId));if(n?.correlationIds&&n.correlationIds.length>0){let e=new Set(n.correlationIds);l=l.filter(t=>t.correlationId&&e.has(t.correlationId))}let u=[],d=0;for(let n of l){if(!n.correlationId)continue;let a=i?{eventType:`wait_completed`,correlationId:n.correlationId}:{eventType:`wait_completed`,correlationId:n.correlationId,specVersion:r.specVersion,eventData:{resumeAt:n.eventData.resumeAt}};try{await e.events.create(t,a,{v1Compat:i}),d++}catch(e){k.is(e)?d++:u.push(e instanceof Error?e:Error(String(e)))}}if(d>0&&await e.queue(g(r.workflowName,n?.namespace),{runId:t},{deploymentId:r.deploymentId,specVersion:r.specVersion??1}),u.length>0)throw AggregateError(u,`Failed to complete ${u.length}/${l.length} pending wait(s) for run ${t}`);return{stoppedCount:d}}catch(e){throw e instanceof AggregateError?e:Error(`Failed to wake up run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function Y(e,t,n,r){try{return await e.streams.get(t,n,r?.startIndex)}catch(e){throw Error(`Failed to read stream ${n}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function X(e,t){try{return await e.streams.list(t)}catch(e){throw Error(`Failed to list streams for run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}function Z(){return P(`WORKFLOW_RETURN_VALUE_POLL_INTERVAL_MS`,1e3,{integer:!0,min:1})}var Q=class e{static[l](e){return{runId:e.runId,resilientStart:e.#r}}static[s](t){return new e(t.runId,{resilientStart:t.resilientStart})}runId;#e;get#t(){return this.#e||=p(),this.#e}#n=null;#r=!1;constructor(e,t){this.runId=e,this.#r=t?.resilientStart??!1}#i(){return this.#n||=(async()=>{let e=await this.#t,t=await e.runs.get(this.runId),n=await e.getEncryptionKeyForRun?.(t);return n?await m(n):void 0})(),this.#n}#a(){return()=>this.#i()}async wakeUp(e){"use step";return J(await this.#t,this.runId,e)}async cancel(e){"use step";await(await this.#t).events.create(this.runId,{eventType:`run_cancelled`,specVersion:5,...e?.cancelReason===void 0?{}:{eventData:{cancelReason:e.cancelReason}}})}get exists(){"use step";return this.#t.then(e=>e.runs.get(this.runId,{resolveData:`none`}).then(()=>!0).catch(e=>{if(D.is(e))return!1;throw e}))}get status(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.status))}get returnValue(){"use step";return this.#o()}get workflowName(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.workflowName))}get createdAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.createdAt))}get startedAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.startedAt))}get completedAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.completedAt))}get readable(){return this.getReadable()}getReadable(e={}){"use step";let{ops:t=[],global:n=globalThis,startIndex:r,namespace:a}=e,o=i(this.runId,a),s=this.#a(),c=y(n,t,this.runId,s).ReadableStream({name:o,startIndex:r}),l=this.#t,u=this.runId;return Object.assign(c,{getTailIndex:async()=>(await(await l).streams.getInfo(u,o)).tailIndex})}async#o(){let e=await this.#t,t=0,n=this.#r?3:0,r=[1e3,3e3,6e3];for(;;)try{let t=await e.runs.get(this.runId);if(t.status===`completed`){let e=await this.#i();return await f(t.output,this.runId,e)}if(t.status===`cancelled`)throw new T(this.runId);if(t.status===`failed`){let e=await this.#i(),n;try{n=await c(t.error,this.runId,e)}catch{n=Error(`Failed to hydrate workflow run error`)}throw new A(this.runId,n,{errorCode:t.errorCode})}throw new O(this.runId,t.status)}catch(e){if(O.is(e)){await new Promise(e=>setTimeout(e,Z()));continue}if(D.is(e)&&t<n){let e=r[t];t++,await new Promise(t=>setTimeout(t,e));continue}throw e}}};function $(e){return new Q(e)}export{X as a,q as c,R as d,K as i,J as l,$ as n,Y as o,G as r,W as s,Q as t,H as u};
@@ -0,0 +1 @@
1
+ import{i as e,t}from"./rolldown-runtime-DaDcL9Zw.js";var n=t(((e,t)=>{t.exports=[`SIGABRT`,`SIGALRM`,`SIGHUP`,`SIGINT`,`SIGTERM`],process.platform!==`win32`&&t.exports.push(`SIGVTALRM`,`SIGXCPU`,`SIGXFSZ`,`SIGUSR2`,`SIGTRAP`,`SIGSYS`,`SIGQUIT`,`SIGIOT`),process.platform===`linux`&&t.exports.push(`SIGIO`,`SIGPOLL`,`SIGPWR`,`SIGSTKFLT`,`SIGUNUSED`)})),r=t(((t,r)=>{var i=global.process;let a=function(e){return e&&typeof e==`object`&&typeof e.removeListener==`function`&&typeof e.emit==`function`&&typeof e.reallyExit==`function`&&typeof e.listeners==`function`&&typeof e.kill==`function`&&typeof e.pid==`number`&&typeof e.on==`function`};if(!a(i))r.exports=function(){return function(){}};else{var o=e(`assert`),s=n(),c=/^win/i.test(i.platform),l=e(`events`);typeof l!=`function`&&(l=l.EventEmitter);var u;i.__signal_exit_emitter__?u=i.__signal_exit_emitter__:(u=i.__signal_exit_emitter__=new l,u.count=0,u.emitted={}),u.infinite||(u.setMaxListeners(1/0),u.infinite=!0),r.exports=function(e,t){if(!a(global.process))return function(){};o.equal(typeof e,`function`,`a callback must be provided for exit handler`),m===!1&&h();var n=`exit`;return t&&t.alwaysLast&&(n=`afterexit`),u.on(n,e),function(){u.removeListener(n,e),u.listeners(`exit`).length===0&&u.listeners(`afterexit`).length===0&&d()}};var d=function(){!m||!a(global.process)||(m=!1,s.forEach(function(e){try{i.removeListener(e,p[e])}catch{}}),i.emit=v,i.reallyExit=g,--u.count)};r.exports.unload=d;var f=function(e,t,n){u.emitted[e]||(u.emitted[e]=!0,u.emit(e,t,n))},p={};s.forEach(function(e){p[e]=function(){a(global.process)&&i.listeners(e).length===u.count&&(d(),f(`exit`,null,e),f(`afterexit`,null,e),c&&e===`SIGHUP`&&(e=`SIGINT`),i.kill(i.pid,e))}}),r.exports.signals=function(){return s};var m=!1,h=function(){m||!a(global.process)||(m=!0,u.count+=1,s=s.filter(function(e){try{return i.on(e,p[e]),!0}catch{return!1}}),i.emit=y,i.reallyExit=_)};r.exports.load=h;var g=i.reallyExit,_=function(e){a(global.process)&&(i.exitCode=e||0,f(`exit`,i.exitCode,null),f(`afterexit`,i.exitCode,null),g.call(i,i.exitCode))},v=i.emit,y=function(e,t){if(e===`exit`&&a(global.process)){t!==void 0&&(i.exitCode=t);var n=v.apply(this,arguments);return f(`exit`,i.exitCode,null),f(`afterexit`,i.exitCode,null),n}else return v.apply(this,arguments)}}}));export{r as t};
@@ -0,0 +1 @@
1
+ import{$n as e}from"./wait-until-CMX5LUWJ.js";import{i as t}from"./attribute-changes-Du5ztewf.js";async function n(r){let i=globalThis[e];return i||t(`sleep()`,`https://workflow-sdk.dev/docs/api-reference/workflow/sleep`,n),i(r)}export{n as t};
@@ -1 +1 @@
1
- import{t as e}from"./rolldown-runtime-DaDcL9Zw.js";import{i as t,n,t as r}from"./token-util-DURSL1l8.js";var i=e(((e,i)=>{var a=Object.defineProperty,o=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,l=(e,t)=>{for(var n in t)a(e,n,{get:t[n],enumerable:!0})},u=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of s(t))!c.call(e,i)&&i!==n&&a(e,i,{get:()=>t[i],enumerable:!(r=o(t,i))||r.enumerable});return e},d=e=>u(a({},`__esModule`,{value:!0}),e),f={};l(f,{refreshToken:()=>g}),i.exports=d(f);var p=n(),m=t(),h=r();async function g(e){let t=e?.project,n=e?.team;if(!t&&!n){let e=(0,h.findProjectInfo)();t=e.projectId,n=e.teamId}else if(!t||!n){let e=(0,h.findProjectInfo)();t??=e.projectId,n??=e.teamId}if(!t)throw new m.VercelOidcTokenError("Failed to refresh OIDC token: No project specified. Try re-linking your project with `vc link`");let r=(0,h.loadToken)(t);if(!r||(0,h.isExpired)((0,h.getTokenPayload)(r.token),e?.expirationBufferMs)){let i=(0,p.getGlobalPathConfig)();if((0,p.getLikelyEffectiveCredStorage)(i)===`keyring`)r=await(0,h.getVercelOidcTokenFromCli)(t,n);else{let i=await(0,h.getVercelToken)({expirationBufferMs:e?.expirationBufferMs});r=await(0,h.getVercelOidcToken)(i,t,n)}if(!r)throw new m.VercelOidcTokenError(`Failed to refresh OIDC token`);(0,h.saveToken)(r,t)}process.env.VERCEL_OIDC_TOKEN=r.token}0&&(i.exports={refreshToken:g})}));export default i();export{};
1
+ import{t as e}from"./rolldown-runtime-DaDcL9Zw.js";import{i as t,n,t as r}from"./token-util-DNwIAn_u.js";var i=e(((e,i)=>{var a=Object.defineProperty,o=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,l=(e,t)=>{for(var n in t)a(e,n,{get:t[n],enumerable:!0})},u=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of s(t))!c.call(e,i)&&i!==n&&a(e,i,{get:()=>t[i],enumerable:!(r=o(t,i))||r.enumerable});return e},d=e=>u(a({},`__esModule`,{value:!0}),e),f={};l(f,{refreshToken:()=>g}),i.exports=d(f);var p=n(),m=t(),h=r();async function g(e){let t=e?.project,n=e?.team;if(!t&&!n){let e=(0,h.findProjectInfo)();t=e.projectId,n=e.teamId}else if(!t||!n){let e=(0,h.findProjectInfo)();t??=e.projectId,n??=e.teamId}if(!t)throw new m.VercelOidcTokenError("Failed to refresh OIDC token: No project specified. Try re-linking your project with `vc link`");let r=(0,h.loadToken)(t);if(!r||(0,h.isExpired)((0,h.getTokenPayload)(r.token),e?.expirationBufferMs)){let i=(0,p.getGlobalPathConfig)();if((0,p.getLikelyEffectiveCredStorage)(i)===`keyring`)r=await(0,h.getVercelOidcTokenFromCli)(t,n);else{let i=await(0,h.getVercelToken)({expirationBufferMs:e?.expirationBufferMs});r=await(0,h.getVercelOidcToken)(i,t,n)}if(!r)throw new m.VercelOidcTokenError(`Failed to refresh OIDC token`);(0,h.saveToken)(r,t)}process.env.VERCEL_OIDC_TOKEN=r.token}0&&(i.exports={refreshToken:g})}));export default i();export{};