@task-handoff/node-agent 0.0.46 → 0.0.47

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.
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
 
4
+ readonly script_dir="$(CDPATH= cd -- "$(dirname "$0")" && pwd)"
5
+
4
6
  # Compatibility for v0.0.34: the private config moved to a per-instance
5
7
  # directory mount, but the retired single-file path stays readable so
6
8
  # containers created by older node agents keep starting until they are rebuilt.
@@ -22,20 +24,7 @@ resolve_private_config_path() {
22
24
  # and Codex settings are an optional startup snapshot that the node agent pushes
23
25
  # over the authenticated internal API once the instance is registered.
24
26
  decode_private_config() {
25
- node -e '
26
- const fs = require("node:fs");
27
- const value = JSON.parse(fs.readFileSync(process.argv[1], "utf8"));
28
- if (value.version !== 1 || typeof value.instanceId !== "string" || !value.instanceId || typeof value.instanceCredential !== "string" || !value.instanceCredential) process.exit(78);
29
- const configured = value.environment === undefined ? {} : value.environment;
30
- if (!configured || typeof configured !== "object" || Array.isArray(configured)) process.exit(78);
31
- const environment = { ...configured, TASK_HANDOFF_REGISTRATION_TOKEN: value.instanceCredential, TASK_HANDOFF_PRIVATE_CONFIG_LOADED: "1", TASK_HANDOFF_INSTANCE_PRIVATE_CONFIG_PATH: process.argv[1] };
32
- if (value.modelCatalog !== undefined) environment.TASK_HANDOFF_PRIVATE_MODEL_CATALOG_JSON = JSON.stringify(value.modelCatalog);
33
- if (value.codexSettings !== undefined) environment.TASK_HANDOFF_PRIVATE_CODEX_SETTINGS_JSON = JSON.stringify(value.codexSettings);
34
- for (const [key, item] of Object.entries(environment)) {
35
- if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key) || typeof item !== "string") process.exit(78);
36
- process.stdout.write(`${key}\t${Buffer.from(item).toString("base64")}\n`);
37
- }
38
- ' "$1"
27
+ "${script_dir}/js-runtime.sh" "${script_dir}/private-config.mjs" "$1"
39
28
  }
40
29
 
41
30
  load_private_config() {
@@ -76,7 +65,7 @@ start_node_agent_unix_proxy() {
76
65
  if [ -z "${TASK_HANDOFF_NODE_AGENT_SOCKET_PATH:-}" ]; then
77
66
  return
78
67
  fi
79
- node /run/task-handoff/bootstrap/node-agent-unix-proxy.mjs \
68
+ "${script_dir}/js-runtime.sh" "${script_dir}/node-agent-unix-proxy.mjs" \
80
69
  "${TASK_HANDOFF_NODE_AGENT_SOCKET_PATH}" \
81
70
  "${TASK_HANDOFF_NODE_AGENT_PROXY_PORT:-19001}" &
82
71
  }
@@ -6,6 +6,9 @@ staging="${workspace}/.task-handoff-git-provisioning"
6
6
  checkout="${staging}/checkout"
7
7
  owner_file="${staging}/owner"
8
8
  runtime_dir="/run/task-handoff/git-runtime"
9
+ bootstrap_dir="$(CDPATH= cd -- "$(dirname "$0")" && pwd)"
10
+ git_helper="${bootstrap_dir}/git-provisioning-helper.js"
11
+ js_runtime="${bootstrap_dir}/js-runtime.sh"
9
12
  mkdir -p "${workspace}" "${runtime_dir}"
10
13
 
11
14
  fail() {
@@ -85,9 +88,9 @@ done
85
88
 
86
89
  git_config=(
87
90
  -c credential.helper=
88
- -c credential.helper="!node /run/task-handoff/bootstrap/git-provisioning-helper.js credential"
91
+ -c credential.helper="!${js_runtime} ${git_helper} credential"
89
92
  -c credential.useHttpPath=true
90
- -c core.sshCommand="node /run/task-handoff/bootstrap/git-provisioning-helper.js ssh"
93
+ -c core.sshCommand="${js_runtime} ${git_helper} ssh"
91
94
  )
92
95
  # Workspace Git environment contract (mirrors @task-handoff/protocol/workspace-git).
93
96
  # Only the TASK_HANDOFF_WORKSPACE_GIT_* keys are provisioning input: released
@@ -108,7 +111,7 @@ stage cloning
108
111
  if ! runuser -u agent -- env \
109
112
  HOME=/tmp/task-handoff-git-home \
110
113
  GIT_TERMINAL_PROMPT=0 \
111
- GIT_SSH_COMMAND="node /run/task-handoff/bootstrap/git-provisioning-helper.js ssh" \
114
+ GIT_SSH_COMMAND="${js_runtime} ${git_helper} ssh" \
112
115
  git "${git_config[@]}" "${clone_args[@]}"; then
113
116
  fail CLONE_FAILED 74
114
117
  fi
@@ -124,7 +127,7 @@ if [ "${TASK_HANDOFF_WORKSPACE_GIT_SUBMODULES:-false}" = "true" ]; then
124
127
  if ! runuser -u agent -- env \
125
128
  HOME=/tmp/task-handoff-git-home \
126
129
  GIT_TERMINAL_PROMPT=0 \
127
- GIT_SSH_COMMAND="node /run/task-handoff/bootstrap/git-provisioning-helper.js ssh" \
130
+ GIT_SSH_COMMAND="${js_runtime} ${git_helper} ssh" \
128
131
  git "${git_config[@]}" -C "${checkout}" submodule update --init --recursive --progress; then
129
132
  fail CLONE_FAILED 74
130
133
  fi
@@ -132,7 +135,7 @@ fi
132
135
  if [ "${TASK_HANDOFF_WORKSPACE_GIT_LFS:-false}" = "true" ]; then
133
136
  stage lfs
134
137
  # git-lfs has no --progress flag; the stage marker is the progress contract here.
135
- if ! runuser -u agent -- env GIT_TERMINAL_PROMPT=0 GIT_SSH_COMMAND="node /run/task-handoff/bootstrap/git-provisioning-helper.js ssh" git "${git_config[@]}" -C "${checkout}" lfs pull; then
138
+ if ! runuser -u agent -- env GIT_TERMINAL_PROMPT=0 GIT_SSH_COMMAND="${js_runtime} ${git_helper} ssh" git "${git_config[@]}" -C "${checkout}" lfs pull; then
136
139
  fail LFS_FAILED 76
137
140
  fi
138
141
  fi
@@ -1 +1 @@
1
- "use strict";var e,t=require("node:fs"),n=require("node:path"),r=require("node:child_process");function i(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:s,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);const i=s.prototype,o=Object.keys(i);for(let e=0;e<o.length;e++){const t=o[e];t in n||(n[t]=i[t].bind(n))}}const i=n?.Parent??Object;class o extends i{}function s(e){var t;const i=n?.Parent?new o:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(const e of i._zod.deferred)e();return i}return Object.defineProperty(o,"name",{value:e}),Object.defineProperty(s,"init",{value:r}),Object.defineProperty(s,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}class o extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class s extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(e=globalThis).__zod_globalConfig??(e.__zod_globalConfig={});const a=globalThis.__zod_globalConfig;function c(e){return a}function u(e){const t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,n])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function d(e,t){return"bigint"==typeof t?t.toString():t}function p(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function l(e){return null==e}function f(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const h=Symbol("evaluating");function m(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==h)return void 0===r&&(r=h,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function g(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function v(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function y(e){return JSON.stringify(e)}const _="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function b(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const z=p(()=>{if(a.jitless)return!1;if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function w(e){if(!1===b(e))return!1;const t=e.constructor;if(void 0===t)return!0;if("function"!=typeof t)return!0;const n=t.prototype;return!1!==b(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function k(e){return w(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const $=new Set(["string","number","symbol"]);function x(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function S(e,t,n){const r=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(r._zod.parent=e),r}function O(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}const I={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function E(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n]?.continue)return!0;return!1}function Z(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!1===e.issues[n]?.continue)return!0;return!1}function T(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function N(e){return"string"==typeof e?e:e?.message}function P(e,t,n){const r=e.message?e.message:N(e.inst?._zod.def?.error?.(e))??N(t?.error?.(e))??N(n.customError?.(e))??N(n.localeError?.(e))??"Invalid input",{inst:i,continue:o,input:s,...a}=e;return a.path??(a.path=[]),a.message=r,t?.reportInput&&(a.input=s),a}function j(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function A(...e){const[t,n,r]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:r}:{...t}}const F=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,d,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},R=i("$ZodError",F),C=i("$ZodError",F,{Parent:Error}),U=e=>(t,n,r,i)=>{const s=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},s);if(a instanceof Promise)throw new o;if(a.issues.length){const t=new(i?.Err??e)(a.issues.map(e=>P(e,s,c())));throw _(t,i?.callee),t}return a.value},J=e=>async(t,n,r,i)=>{const o=r?{...r,async:!0}:{async:!0};let s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){const t=new(i?.Err??e)(s.issues.map(e=>P(e,o,c())));throw _(t,i?.callee),t}return s.value},M=e=>(t,n,r)=>{const i=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new o;return s.issues.length?{success:!1,error:new(e??R)(s.issues.map(e=>P(e,i,c())))}:{success:!0,data:s.value}},D=M(C),V=e=>async(t,n,r)=>{const i=r?{...r,async:!0}:{async:!0};let o=t._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(e=>P(e,i,c())))}:{success:!0,data:o.value}},L=V(C),G=e=>(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return U(e)(t,n,i)},W=e=>(t,n,r)=>U(e)(t,n,r),H=e=>async(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return J(e)(t,n,i)},K=e=>async(t,n,r)=>J(e)(t,n,r),B=e=>(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return M(e)(t,n,i)},q=e=>(t,n,r)=>M(e)(t,n,r),Y=e=>async(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return V(e)(t,n,i)},X=e=>async(t,n,r)=>V(e)(t,n,r),Q=/^[cC][0-9a-z]{6,}$/,ee=/^[0-9a-z]+$/,te=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ne=/^[0-9a-vA-V]{20}$/,re=/^[A-Za-z0-9]{27}$/,ie=/^[a-zA-Z0-9_-]{21}$/,oe=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,se=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ae=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,ce=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,ue=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,de=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,pe=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,le=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,fe=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,he=/^[A-Za-z0-9_-]*$/,me=/^https?$/,ge=/^\+[1-9]\d{6,14}$/,ve="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",ye=new RegExp(`^${ve}$`);function _e(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}const be=/^-?\d+$/,ze=/^-?\d+(?:\.\d+)?$/,we=/^(?:true|false)$/i,ke=/^[^A-Z]*$/,$e=/^[^a-z]*$/,xe=i("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Se={number:"number",bigint:"bigint",object:"date"},Oe=i("$ZodCheckLessThan",(e,t)=>{xe.init(e,t);const n=Se[typeof t.value];e._zod.onattach.push(e=>{const n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:"object"==typeof t.value?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ie=i("$ZodCheckGreaterThan",(e,t)=>{xe.init(e,t);const n=Se[typeof t.value];e._zod.onattach.push(e=>{const n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:"object"==typeof t.value?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ee=i("$ZodCheckMultipleOf",(e,t)=>{xe.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof n.value?n.value%t.value===BigInt(0):0===function(e,t){const n=e/t,r=Math.round(n),i=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}(n.value,t.value))||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Ze=i("$ZodCheckNumberFormat",(e,t)=>{xe.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[i,o]=I[t.format];e._zod.onattach.push(e=>{const r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=o,n&&(r.pattern=be)}),e._zod.check=s=>{const a=s.value;if(n){if(!Number.isInteger(a))return void s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});if(!Number.isSafeInteger(a))return void(a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}))}a<i&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),a>o&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),Te=i("$ZodCheckMaxLength",(e,t)=>{var n;xe.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!l(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const r=n.value;if(r.length<=t.maximum)return;const i=j(r);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Ne=i("$ZodCheckMinLength",(e,t)=>{var n;xe.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!l(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const r=n.value;if(r.length>=t.minimum)return;const i=j(r);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Pe=i("$ZodCheckLengthEquals",(e,t)=>{var n;xe.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!l(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{const r=n.value,i=r.length;if(i===t.length)return;const o=j(r),s=i>t.length;n.issues.push({origin:o,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),je=i("$ZodCheckStringFormat",(e,t)=>{var n,r;xe.init(e,t),e._zod.onattach.push(e=>{const n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??(n.patterns=new Set),n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Ae=i("$ZodCheckRegex",(e,t)=>{je.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Fe=i("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=ke),je.init(e,t)}),Re=i("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=$e),je.init(e,t)}),Ce=i("$ZodCheckIncludes",(e,t)=>{xe.init(e,t);const n=x(t.includes),r=new RegExp("number"==typeof t.position?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Ue=i("$ZodCheckStartsWith",(e,t)=>{xe.init(e,t);const n=new RegExp(`^${x(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Je=i("$ZodCheckEndsWith",(e,t)=>{xe.init(e,t);const n=new RegExp(`.*${x(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Me=i("$ZodCheckOverwrite",(e,t)=>{xe.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class De{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>" ".repeat(2*this.indent)+e);for(const e of r)this.content.push(e)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}}const Ve={major:4,minor:4,patch:3},Le=i("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ve;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const t of r)for(const n of t._zod.onattach)n(e);if(0===r.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(e,t,n)=>{let r,i=E(e);for(const s of t){if(s._zod.def.when){if(Z(e))continue;if(!s._zod.def.when(e))continue}else if(i)continue;const t=e.issues.length,a=s._zod.check(e);if(a instanceof Promise&&!1===n?.async)throw new o;if(r||a instanceof Promise)r=(r??Promise.resolve()).then(async()=>{await a,e.issues.length!==t&&(i||(i=E(e,t)))});else{if(e.issues.length===t)continue;i||(i=E(e,t))}}return r?r.then(()=>e):e},n=(n,i,s)=>{if(E(n))return n.aborted=!0,n;const a=t(i,r,s);if(a instanceof Promise){if(!1===s.async)throw new o;return a.then(t=>e._zod.parse(t,s))}return e._zod.parse(a,s)};e._zod.run=(i,s)=>{if(s.skipChecks)return e._zod.parse(i,s);if("backward"===s.direction){const t=e._zod.parse({value:i.value,issues:[]},{...s,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,s)):n(t,i,s)}const a=e._zod.parse(i,s);if(a instanceof Promise){if(!1===s.async)throw new o;return a.then(e=>t(e,r,s))}return t(a,r,s)}}m(e,"~standard",()=>({validate:t=>{try{const n=D(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return L(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),Ge=i("$ZodString",(e,t)=>{var n;Le.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(n=e._zod.bag,new RegExp(`^${n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),We=i("$ZodStringFormat",(e,t)=>{je.init(e,t),Ge.init(e,t)}),He=i("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=se),We.init(e,t)}),Ke=i("$ZodUUID",(e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ae(e))}else t.pattern??(t.pattern=ae());We.init(e,t)}),Be=i("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ce),We.init(e,t)}),qe=i("$ZodURL",(e,t)=>{We.init(e,t),e._zod.check=n=>{try{const r=n.value.trim();if(!t.normalize&&t.protocol?.source===me.source&&!/^https?:\/\//i.test(r))return void n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});const i=new URL(r);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),void(t.normalize?n.value=i.href:n.value=r)}catch(r){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Ye=i("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),We.init(e,t)}),Xe=i("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=ie),We.init(e,t)}),Qe=i("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Q),We.init(e,t)}),et=i("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ee),We.init(e,t)}),tt=i("$ZodULID",(e,t)=>{t.pattern??(t.pattern=te),We.init(e,t)}),nt=i("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ne),We.init(e,t)}),rt=i("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=re),We.init(e,t)}),it=i("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=_e({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${ve}T(?:${r})$`)}(t)),We.init(e,t)}),ot=i("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=ye),We.init(e,t)}),st=i("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${_e(t)}$`)),We.init(e,t)}),at=i("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=oe),We.init(e,t)}),ct=i("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ue),We.init(e,t),e._zod.bag.format="ipv4"}),ut=i("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=de),We.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),dt=i("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=pe),We.init(e,t)}),pt=i("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=le),We.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(2!==r.length)throw new Error;const[e,t]=r;if(!t)throw new Error;const n=Number(t);if(`${n}`!==t)throw new Error;if(n<0||n>128)throw new Error;new URL(`http://[${e}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function lt(e){if(""===e)return!0;if(/\s/.test(e))return!1;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const ft=i("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=fe),We.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{lt(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),ht=i("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=he),We.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!he.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return lt(t.padEnd(4*Math.ceil(t.length/4),"="))})(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),mt=i("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ge),We.init(e,t)}),gt=i("$ZodJWT",(e,t)=>{We.init(e,t),e._zod.check=n=>{(function(e,t=null){try{const n=e.split(".");if(3!==n.length)return!1;const[r]=n;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&"JWT"!==i?.typ||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}})(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),vt=i("$ZodNumber",(e,t)=>{Le.init(e,t),e._zod.pattern=e._zod.bag.pattern??ze,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(e){}const i=n.value;if("number"==typeof i&&!Number.isNaN(i)&&Number.isFinite(i))return n;const o="number"==typeof i?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),n}}),yt=i("$ZodNumberFormat",(e,t)=>{Ze.init(e,t),vt.init(e,t)}),_t=i("$ZodBoolean",(e,t)=>{Le.init(e,t),e._zod.pattern=we,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(e){}const i=n.value;return"boolean"==typeof i||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),bt=i("$ZodUnknown",(e,t)=>{Le.init(e,t),e._zod.parse=e=>e}),zt=i("$ZodNever",(e,t)=>{Le.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function wt(e,t,n){e.issues.length&&t.issues.push(...T(n,e.issues)),t.value[n]=e.value}const kt=i("$ZodArray",(e,t)=>{Le.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);const o=[];for(let e=0;e<i.length;e++){const s=i[e],a=t.element._zod.run({value:s,issues:[]},r);a instanceof Promise?o.push(a.then(t=>wt(t,n,e))):wt(a,n,e)}return o.length?Promise.all(o).then(()=>n):n}});function $t(e,t,n,r,i,o){const s=n in r;if(e.issues.length){if(i&&o&&!s)return;t.issues.push(...T(n,e.issues))}s||i?void 0===e.value?s&&(t.value[n]=void 0):t.value[n]=e.value:e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]})}function xt(e){const t=Object.keys(e.shape);for(const n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const n=(r=e.shape,Object.keys(r).filter(e=>"optional"===r[e]._zod.optin&&"optional"===r[e]._zod.optout));var r;return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function St(e,t,n,r,i,o){const s=[],a=i.keySet,c=i.catchall._zod,u=c.def.type,d="optional"===c.optin,p="optional"===c.optout;for(const i in t){if("__proto__"===i)continue;if(a.has(i))continue;if("never"===u){s.push(i);continue}const o=c.run({value:t[i],issues:[]},r);o instanceof Promise?e.push(o.then(e=>$t(e,n,i,t,d,p))):$t(o,n,i,t,d,p)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:o}),e.length?Promise.all(e).then(()=>n):n}const Ot=i("$ZodObject",(e,t)=>{Le.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!n?.get){const e=t.shape;Object.defineProperty(t,"shape",{get:()=>{const n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}const r=p(()=>xt(t));m(e._zod,"propValues",()=>{const e=t.shape,n={};for(const t in e){const r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(const e of r.values)n[t].add(e)}}return n});const i=b,o=t.catchall;let s;e._zod.parse=(t,n)=>{s??(s=r.value);const a=t.value;if(!i(a))return t.issues.push({expected:"object",code:"invalid_type",input:a,inst:e}),t;t.value={};const c=[],u=s.shape;for(const e of s.keys){const r=u[e],i="optional"===r._zod.optin,o="optional"===r._zod.optout,s=r._zod.run({value:a[e],issues:[]},n);s instanceof Promise?c.push(s.then(n=>$t(n,t,e,a,i,o))):$t(s,t,e,a,i,o)}return o?St(c,a,t,n,r.value,e):c.length?Promise.all(c).then(()=>t):t}}),It=i("$ZodObjectJIT",(e,t)=>{Ot.init(e,t);const n=e._zod.parse,r=p(()=>xt(t));let i;const o=b,s=!a.jitless,c=s&&z.value,u=t.catchall;let d;e._zod.parse=(a,p)=>{d??(d=r.value);const l=a.value;return o(l)?s&&c&&!1===p?.async&&!0!==p.jitless?(i||(i=(e=>{const t=new De(["shape","payload","ctx"]),n=r.value,i=e=>{const t=y(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const o=Object.create(null);let s=0;for(const e of n.keys)o[e]="key_"+s++;t.write("const newResult = {};");for(const r of n.keys){const n=o[r],s=y(r),a=e[r],c="optional"===a?._zod?.optin,u="optional"===a?._zod?.optout;t.write(`const ${n} = ${i(r)};`),c&&u?t.write(`\n if (${n}.issues.length) {\n if (${s} in input) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n }\n \n if (${n}.value === undefined) {\n if (${s} in input) {\n newResult[${s}] = undefined;\n }\n } else {\n newResult[${s}] = ${n}.value;\n }\n \n `):c?t.write(`\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n \n if (${n}.value === undefined) {\n if (${s} in input) {\n newResult[${s}] = undefined;\n }\n } else {\n newResult[${s}] = ${n}.value;\n }\n \n `):t.write(`\n const ${n}_present = ${s} in input;\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n if (!${n}_present && !${n}.issues.length) {\n payload.issues.push({\n code: "invalid_type",\n expected: "nonoptional",\n input: undefined,\n path: [${s}]\n });\n }\n\n if (${n}_present) {\n if (${n}.value === undefined) {\n newResult[${s}] = undefined;\n } else {\n newResult[${s}] = ${n}.value;\n }\n }\n\n `)}t.write("payload.value = newResult;"),t.write("return payload;");const a=t.compile();return(t,n)=>a(e,t,n)})(t.shape)),a=i(a,p),u?St([],l,a,p,d,e):a):n(a,p):(a.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),a)}});function Et(e,t,n,r){for(const n of e)if(0===n.issues.length)return t.value=n.value,t;const i=e.filter(e=>!E(e));return 1===i.length?(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=>P(e,r,c())))}),t)}const Zt=i("$ZodUnion",(e,t)=>{Le.init(e,t),m(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),m(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),m(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),m(e._zod,"pattern",()=>{if(t.options.every(e=>e._zod.pattern)){const e=t.options.map(e=>e._zod.pattern);return new RegExp(`^(${e.map(e=>f(e.source)).join("|")})$`)}});const n=1===t.options.length?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let o=!1;const s=[];for(const e of t.options){const t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)s.push(t),o=!0;else{if(0===t.issues.length)return t;s.push(t)}}return o?Promise.all(s).then(t=>Et(t,r,e,i)):Et(s,r,e,i)}}),Tt=i("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Zt.init(e,t);const n=e._zod.parse;m(e._zod,"propValues",()=>{const e={};for(const n of t.options){const r=n._zod.propValues;if(!r||0===Object.keys(r).length)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(const[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(const r of n)e[t].add(r)}}return e});const r=p(()=>{const e=t.options,n=new Map;for(const r of e){const e=r._zod.propValues?.[t.discriminator];if(!e||0===e.size)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(const t of e){if(n.has(t))throw new Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,o)=>{const s=i.value;if(!b(s))return i.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),i;const a=r.value.get(s?.[t.discriminator]);return a?a._zod.run(i,o):t.unionFallback||"backward"===o.direction?n(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()),input:s,path:[t.discriminator],inst:e}),i)}}),Nt=i("$ZodIntersection",(e,t)=>{Le.init(e,t),e._zod.parse=(e,n)=>{const r=e.value,i=t.left._zod.run({value:r,issues:[]},n),o=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([t,n])=>jt(e,t,n)):jt(e,i,o)}});function Pt(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(w(e)&&w(t)){const n=Object.keys(t),r=Object.keys(e).filter(e=>-1!==n.indexOf(e)),i={...e,...t};for(const n of r){const r=Pt(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:[]};const n=[];for(let r=0;r<e.length;r++){const i=Pt(e[r],t[r]);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function jt(e,t,n){const r=new Map;let i;for(const n of t.issues)if("unrecognized_keys"===n.code){i??(i=n);for(const e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(const t of n.issues)if("unrecognized_keys"===t.code)for(const e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);const o=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(o.length&&i&&e.issues.push({...i,keys:o}),E(e))return e;const s=Pt(t.value,n.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}const At=i("$ZodEnum",(e,t)=>{Le.init(e,t);const n=u(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(e=>$.has(typeof e)).map(e=>"string"==typeof e?x(e):e.toString()).join("|")})$`),e._zod.parse=(t,i)=>{const o=t.value;return r.has(o)||t.issues.push({code:"invalid_value",values:n,input:o,inst:e}),t}}),Ft=i("$ZodLiteral",(e,t)=>{if(Le.init(e,t),0===t.values.length)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(e=>"string"==typeof e?x(e):e?x(e.toString()):String(e)).join("|")})$`),e._zod.parse=(r,i)=>{const o=r.value;return n.has(o)||r.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),r}}),Rt=i("$ZodTransform",(e,t)=>{Le.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new s(e.constructor.name);const i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new o;return n.value=i,n.fallback=!0,n}});function Ct(e,t){return void 0===t&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const Ut=i("$ZodOptional",(e,t)=>{Le.init(e,t),e._zod.optin="optional",e._zod.optout="optional",m(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),m(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${f(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>Ct(e,r)):Ct(i,r)}return void 0===e.value?e:t.innerType._zod.run(e,n)}}),Jt=i("$ZodExactOptional",(e,t)=>{Ut.init(e,t),m(e._zod,"values",()=>t.innerType._zod.values),m(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Mt=i("$ZodNullable",(e,t)=>{Le.init(e,t),m(e._zod,"optin",()=>t.innerType._zod.optin),m(e._zod,"optout",()=>t.innerType._zod.optout),m(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${f(e.source)}|null)$`):void 0}),m(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>null===e.value?e:t.innerType._zod.run(e,n)}),Dt=i("$ZodDefault",(e,t)=>{Le.init(e,t),e._zod.optin="optional",m(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);if(void 0===e.value)return e.value=t.defaultValue,e;const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Vt(e,t)):Vt(r,t)}});function Vt(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const Lt=i("$ZodPrefault",(e,t)=>{Le.init(e,t),e._zod.optin="optional",m(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>("backward"===n.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Gt=i("$ZodNonOptional",(e,t)=>{Le.init(e,t),m(e._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(e=>void 0!==e)):void 0}),e._zod.parse=(n,r)=>{const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Wt(t,e)):Wt(i,e)}});function Wt(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Ht=i("$ZodCatch",(e,t)=>{Le.init(e,t),e._zod.optin="optional",m(e._zod,"optout",()=>t.innerType._zod.optout),m(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const 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=>P(e,n,c()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>P(e,n,c()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Kt=i("$ZodPipe",(e,t)=>{Le.init(e,t),m(e._zod,"values",()=>t.in._zod.values),m(e._zod,"optin",()=>t.in._zod.optin),m(e._zod,"optout",()=>t.out._zod.optout),m(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if("backward"===n.direction){const r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Bt(e,t.in,n)):Bt(r,t.in,n)}const r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Bt(e,t.out,n)):Bt(r,t.out,n)}});function Bt(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}const qt=i("$ZodReadonly",(e,t)=>{Le.init(e,t),m(e._zod,"propValues",()=>t.innerType._zod.propValues),m(e._zod,"values",()=>t.innerType._zod.values),m(e._zod,"optin",()=>t.innerType?._zod?.optin),m(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Yt):Yt(r)}});function Yt(e){return e.value=Object.freeze(e.value),e}const Xt=i("$ZodCustom",(e,t)=>{xe.init(e,t),Le.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Qt(t,n,r,e));Qt(i,n,r,e)}});function Qt(e,t,n,r){if(!e){const 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(A(e))}}var en;(en=globalThis).__zod_globalRegistry??(en.__zod_globalRegistry=new class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];return this._map.set(e,n),n&&"object"==typeof n&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const 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)}});const tn=globalThis.__zod_globalRegistry;function nn(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...O(t)})}function rn(e,t){return new Oe({check:"less_than",...O(t),value:e,inclusive:!1})}function on(e,t){return new Oe({check:"less_than",...O(t),value:e,inclusive:!0})}function sn(e,t){return new Ie({check:"greater_than",...O(t),value:e,inclusive:!1})}function an(e,t){return new Ie({check:"greater_than",...O(t),value:e,inclusive:!0})}function cn(e,t){return new Ee({check:"multiple_of",...O(t),value:e})}function un(e,t){return new Te({check:"max_length",...O(t),maximum:e})}function dn(e,t){return new Ne({check:"min_length",...O(t),minimum:e})}function pn(e,t){return new Pe({check:"length_equals",...O(t),length:e})}function ln(e){return new Me({check:"overwrite",tx:e})}function fn(e){let t=e?.target??"draft-2020-12";return"draft-4"===t&&(t="draft-04"),"draft-7"===t&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??tn,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 hn(e,t,n={path:[],schemaPath:[]}){var r;const i=e._zod.def,o=t.seen.get(e);if(o)return o.count++,n.schemaPath.includes(e)&&(o.cycle=n.path),o.schema;const s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s);const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,r);else{const n=s.schema,o=t.processors[i.type];if(!o)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);o(e,t,n,r)}const o=e._zod.parent;o&&(s.ref||(s.ref=o),hn(o,t,r),t.seen.get(o).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(s.schema,c),"input"===t.io&&vn(e)&&(delete s.schema.examples,delete s.schema.default),"input"===t.io&&"_prefault"in s.schema&&((r=s.schema).default??(r.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function mn(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const t of e.seen.entries()){const n=e.metadataRegistry.get(t[0])?.id;if(n){const e=r.get(n);if(e&&e!==t[0])throw new 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])}}const i=t=>{if(t[1].schema.$ref)return;const r=t[1],{ref:i,defId:o}=(t=>{const r="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){const n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};const o=t[1].defId??t[1].schema.id??"schema"+e.counter++;return t[1].defId=o,{defId:o,ref:`${i("__shared")}#/${r}/${o}`}}if(t[1]===n)return{ref:"#"};const i=`#/${r}/`,o=t[1].schema.id??"__schema"+e.counter++;return{defId:o,ref:i+o}})(t);r.def={...r.schema},o&&(r.defId=o);const s=r.schema;for(const e in s)delete s[e];s.$ref=i};if("throw"===e.cycles)for(const t of e.seen.entries()){const e=t[1];if(e.cycle)throw new Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>\n\nSet the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const n of e.seen.entries()){const r=n[1];if(t===n[0]){i(n);continue}if(e.external){const r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){i(n);continue}}const o=e.metadataRegistry.get(n[0])?.id;(o||r.cycle||r.count>1&&"ref"===e.reused)&&i(n)}}function gn(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=t=>{const n=e.seen.get(t);if(null===n.ref)return;const i=n.def??n.schema,o={...i},s=n.ref;if(n.ref=null,s){r(s);const n=e.seen.get(s),a=n.schema;if(!a.$ref||"draft-07"!==e.target&&"draft-04"!==e.target&&"openapi-3.0"!==e.target?Object.assign(i,a):(i.allOf=i.allOf??[],i.allOf.push(a)),Object.assign(i,o),t._zod.parent===s)for(const e in i)"$ref"!==e&&"allOf"!==e&&(e in o||delete i[e]);if(a.$ref&&n.def)for(const e in i)"$ref"!==e&&"allOf"!==e&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}const a=t._zod.parent;if(a&&a!==s){r(a);const t=e.seen.get(a);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(const e in i)"$ref"!==e&&"allOf"!==e&&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(const t of[...e.seen.entries()].reverse())r(t[0]);const i={};if("draft-2020-12"===e.target?i.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?i.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?i.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const n=e.external.registry.get(t)?.id;if(!n)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);const o=e.metadataRegistry.get(t)?.id;void 0!==o&&i.id===o&&delete i.id;const s=e.external?.defs??{};for(const t of e.seen.entries()){const e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,s[e.defId]=e.def)}e.external||Object.keys(s).length>0&&("draft-2020-12"===e.target?i.$defs=s:i.definitions=s);try{const n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t["~standard"],jsonSchema:{input:yn(t,"input",e.processors),output:yn(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(e){throw new Error("Error converting schema to JSON.")}}function vn(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if("transform"===r.type)return!0;if("array"===r.type)return vn(r.element,n);if("set"===r.type)return vn(r.valueType,n);if("lazy"===r.type)return vn(r.getter(),n);if("promise"===r.type||"optional"===r.type||"nonoptional"===r.type||"nullable"===r.type||"readonly"===r.type||"default"===r.type||"prefault"===r.type)return vn(r.innerType,n);if("intersection"===r.type)return vn(r.left,n)||vn(r.right,n);if("record"===r.type||"map"===r.type)return vn(r.keyType,n)||vn(r.valueType,n);if("pipe"===r.type)return!!e._zod.traits.has("$ZodCodec")||vn(r.in,n)||vn(r.out,n);if("object"===r.type){for(const e in r.shape)if(vn(r.shape[e],n))return!0;return!1}if("union"===r.type){for(const e of r.options)if(vn(e,n))return!0;return!1}if("tuple"===r.type){for(const e of r.items)if(vn(e,n))return!0;return!(!r.rest||!vn(r.rest,n))}return!1}const yn=(e,t,n={})=>r=>{const{libraryOptions:i,target:o}=r??{},s=fn({...i??{},target:o,io:t,processors:n});return hn(e,s),mn(s,e),gn(s,e)},_n={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},bn=(e,t,n,r)=>{const i=e._zod.def;hn(i.innerType,t,r),t.seen.get(e).ref=i.innerType},zn=i("ZodISODateTime",(e,t)=>{it.init(e,t),Gn.init(e,t)});const wn=i("ZodISODate",(e,t)=>{ot.init(e,t),Gn.init(e,t)});const kn=i("ZodISOTime",(e,t)=>{st.init(e,t),Gn.init(e,t)});const $n=i("ZodISODuration",(e,t)=>{at.init(e,t),Gn.init(e,t)});const xn=(e,t)=>{R.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t=e=>e.message){const n={_errors:[]},r=(e,i=[])=>{for(const o of e.issues)if("invalid_union"===o.code&&o.errors.length)o.errors.map(e=>r({issues:e},[...i,...o.path]));else if("invalid_key"===o.code)r({issues:o.issues},[...i,...o.path]);else if("invalid_element"===o.code)r({issues:o.issues},[...i,...o.path]);else{const e=[...i,...o.path];if(0===e.length)n._errors.push(t(o));else{let r=n,i=0;for(;i<e.length;){const n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(o))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const n={},r=[];for(const i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,d,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,d,2)}},isEmpty:{get:()=>0===e.issues.length}})},Sn=i("ZodError",xn,{Parent:Error}),On=U(Sn),In=J(Sn),En=M(Sn),Zn=V(Sn),Tn=G(Sn),Nn=W(Sn),Pn=H(Sn),jn=K(Sn),An=B(Sn),Fn=q(Sn),Rn=Y(Sn),Cn=X(Sn),Un=new WeakMap;function Jn(e,t,n){const r=Object.getPrototypeOf(e);let i=Un.get(r);if(i||(i=new Set,Un.set(r,i)),!i.has(t)){i.add(t);for(const e in n){const t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){const n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}const Mn=i("ZodType",(e,t)=>(Le.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:yn(e,"input"),output:yn(e,"output")}}),e.toJSONSchema=((e,t={})=>n=>{const r=fn({...n,processors:t});return hn(e,r),mn(r,e),gn(r,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>On(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>En(e,t,n),e.parseAsync=async(t,n)=>In(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Zn(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Tn(e,t,n),e.decode=(t,n)=>Nn(e,t,n),e.encodeAsync=async(t,n)=>Pn(e,t,n),e.decodeAsync=async(t,n)=>jn(e,t,n),e.safeEncode=(t,n)=>An(e,t,n),e.safeDecode=(t,n)=>Fn(e,t,n),e.safeEncodeAsync=async(t,n)=>Rn(e,t,n),e.safeDecodeAsync=async(t,n)=>Cn(e,t,n),Jn(e,"ZodType",{check(...e){const t=this.def;return this.clone(v(t,{checks:[...t.checks??[],...e.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return S(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(function(e,t={}){return function(e,t,n){return new Gr({type:"custom",check:"custom",fn:t,...O(n)})}(0,e,t)}(e,t))},superRefine(e,t){return this.check(function(e,t){return function(e,t){const n=function(e,t){const n=new xe({check:"custom",...O(t)});return n._zod.check=e,n}(t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(A(e,t.value,n._zod.def));else{const r=e;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=t.value),r.inst??(r.inst=n),r.continue??(r.continue=!n._zod.def.abort),t.issues.push(A(r))}},e(t.value,t)),t);return n}(e,t)}(e,t))},overwrite(e){return this.check(ln(e))},optional(){return jr(this)},exactOptional(){return new Ar({type:"optional",innerType:this})},nullable(){return Rr(this)},nullish(){return jr(Rr(this))},nonoptional(e){return function(e,t){return new Jr({type:"nonoptional",innerType:e,...O(t)})}(this,e)},array(){return zr(this)},or(e){return new $r({type:"union",options:[this,e],...O(void 0)})},and(e){return new Or({type:"intersection",left:this,right:e})},transform(e){return Vr(this,new Nr({type:"transform",transform:e}))},default(e){return t=e,new Cr({type:"default",innerType:this,get defaultValue(){return"function"==typeof t?t():k(t)}});var t},prefault(e){return t=e,new Ur({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof t?t():k(t)}});var t},catch(e){return new Mr({type:"catch",innerType:this,catchValue:"function"==typeof(t=e)?t:()=>t});var t},pipe(e){return Vr(this,e)},readonly(){return new Lr({type:"readonly",innerType:this})},describe(e){const t=this.clone();return tn.add(t,{description:e}),t},meta(...e){if(0===e.length)return tn.get(this);const t=this.clone();return tn.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get:()=>tn.get(e)?.description,configurable:!0}),e)),Dn=i("_ZodString",(e,t)=>{Ge.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=n;r.type="string";const{minimum:i,maximum:o,format:s,patterns:a,contentEncoding:c}=e._zod.bag;if("number"==typeof i&&(r.minLength=i),"number"==typeof o&&(r.maxLength=o),s&&(r.format=_n[s]??s,""===r.format&&delete r.format,"time"===s&&delete r.format),c&&(r.contentEncoding=c),a&&a.size>0){const e=[...a];1===e.length?r.pattern=e[0].source:e.length>1&&(r.allOf=[...e.map(e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source}))])}})(e,t,n);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Jn(e,"_ZodString",{regex(...e){return this.check(function(e,t){return new Ae({check:"string_format",format:"regex",...O(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new Ce({check:"string_format",format:"includes",...O(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new Ue({check:"string_format",format:"starts_with",...O(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new Je({check:"string_format",format:"ends_with",...O(t),suffix:e})}(...e))},min(...e){return this.check(dn(...e))},max(...e){return this.check(un(...e))},length(...e){return this.check(pn(...e))},nonempty(...e){return this.check(dn(1,...e))},lowercase(e){return this.check(function(e){return new Fe({check:"string_format",format:"lowercase",...O(e)})}(e))},uppercase(e){return this.check(function(e){return new Re({check:"string_format",format:"uppercase",...O(e)})}(e))},trim(){return this.check(ln(e=>e.trim()))},normalize(...e){return this.check(function(e){return ln(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(ln(e=>e.toLowerCase()))},toUpperCase(){return this.check(ln(e=>e.toUpperCase()))},slugify(){return this.check(ln(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}})}),Vn=i("ZodString",(e,t)=>{Ge.init(e,t),Dn.init(e,t),e.email=t=>e.check(function(e,t){return new Wn({type:"string",format:"email",check:"string_format",abort:!1,...O(t)})}(0,t)),e.url=t=>e.check(function(e,t){return new Bn({type:"string",format:"url",check:"string_format",abort:!1,...O(t)})}(0,t)),e.jwt=t=>e.check(function(e,t){return new dr({type:"string",format:"jwt",check:"string_format",abort:!1,...O(t)})}(0,t)),e.emoji=t=>e.check(function(e,t){return new qn({type:"string",format:"emoji",check:"string_format",abort:!1,...O(t)})}(0,t)),e.guid=t=>e.check(nn(Hn,t)),e.uuid=t=>e.check(function(e,t){return new Kn({type:"string",format:"uuid",check:"string_format",abort:!1,...O(t)})}(0,t)),e.uuidv4=t=>e.check(function(e,t){return new Kn({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...O(t)})}(0,t)),e.uuidv6=t=>e.check(function(e,t){return new Kn({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...O(t)})}(0,t)),e.uuidv7=t=>e.check(function(e,t){return new Kn({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...O(t)})}(0,t)),e.nanoid=t=>e.check(function(e,t){return new Yn({type:"string",format:"nanoid",check:"string_format",abort:!1,...O(t)})}(0,t)),e.guid=t=>e.check(nn(Hn,t)),e.cuid=t=>e.check(function(e,t){return new Xn({type:"string",format:"cuid",check:"string_format",abort:!1,...O(t)})}(0,t)),e.cuid2=t=>e.check(function(e,t){return new Qn({type:"string",format:"cuid2",check:"string_format",abort:!1,...O(t)})}(0,t)),e.ulid=t=>e.check(function(e,t){return new er({type:"string",format:"ulid",check:"string_format",abort:!1,...O(t)})}(0,t)),e.base64=t=>e.check(function(e,t){return new ar({type:"string",format:"base64",check:"string_format",abort:!1,...O(t)})}(0,t)),e.base64url=t=>e.check(function(e,t){return new cr({type:"string",format:"base64url",check:"string_format",abort:!1,...O(t)})}(0,t)),e.xid=t=>e.check(function(e,t){return new tr({type:"string",format:"xid",check:"string_format",abort:!1,...O(t)})}(0,t)),e.ksuid=t=>e.check(function(e,t){return new nr({type:"string",format:"ksuid",check:"string_format",abort:!1,...O(t)})}(0,t)),e.ipv4=t=>e.check(function(e,t){return new rr({type:"string",format:"ipv4",check:"string_format",abort:!1,...O(t)})}(0,t)),e.ipv6=t=>e.check(function(e,t){return new ir({type:"string",format:"ipv6",check:"string_format",abort:!1,...O(t)})}(0,t)),e.cidrv4=t=>e.check(function(e,t){return new or({type:"string",format:"cidrv4",check:"string_format",abort:!1,...O(t)})}(0,t)),e.cidrv6=t=>e.check(function(e,t){return new sr({type:"string",format:"cidrv6",check:"string_format",abort:!1,...O(t)})}(0,t)),e.e164=t=>e.check(function(e,t){return new ur({type:"string",format:"e164",check:"string_format",abort:!1,...O(t)})}(0,t)),e.datetime=t=>e.check(function(e){return function(e,t){return new zn({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O(t)})}(0,e)}(t)),e.date=t=>e.check(function(e){return function(e,t){return new wn({type:"string",format:"date",check:"string_format",...O(t)})}(0,e)}(t)),e.time=t=>e.check(function(e){return function(e,t){return new kn({type:"string",format:"time",check:"string_format",precision:null,...O(t)})}(0,e)}(t)),e.duration=t=>e.check(function(e){return function(e,t){return new $n({type:"string",format:"duration",check:"string_format",...O(t)})}(0,e)}(t))});function Ln(e){return function(e,t){return new Vn({type:"string",...O(t)})}(0,e)}const Gn=i("ZodStringFormat",(e,t)=>{We.init(e,t),Dn.init(e,t)}),Wn=i("ZodEmail",(e,t)=>{Be.init(e,t),Gn.init(e,t)}),Hn=i("ZodGUID",(e,t)=>{He.init(e,t),Gn.init(e,t)}),Kn=i("ZodUUID",(e,t)=>{Ke.init(e,t),Gn.init(e,t)}),Bn=i("ZodURL",(e,t)=>{qe.init(e,t),Gn.init(e,t)}),qn=i("ZodEmoji",(e,t)=>{Ye.init(e,t),Gn.init(e,t)}),Yn=i("ZodNanoID",(e,t)=>{Xe.init(e,t),Gn.init(e,t)}),Xn=i("ZodCUID",(e,t)=>{Qe.init(e,t),Gn.init(e,t)}),Qn=i("ZodCUID2",(e,t)=>{et.init(e,t),Gn.init(e,t)}),er=i("ZodULID",(e,t)=>{tt.init(e,t),Gn.init(e,t)}),tr=i("ZodXID",(e,t)=>{nt.init(e,t),Gn.init(e,t)}),nr=i("ZodKSUID",(e,t)=>{rt.init(e,t),Gn.init(e,t)}),rr=i("ZodIPv4",(e,t)=>{ct.init(e,t),Gn.init(e,t)}),ir=i("ZodIPv6",(e,t)=>{ut.init(e,t),Gn.init(e,t)}),or=i("ZodCIDRv4",(e,t)=>{dt.init(e,t),Gn.init(e,t)}),sr=i("ZodCIDRv6",(e,t)=>{pt.init(e,t),Gn.init(e,t)}),ar=i("ZodBase64",(e,t)=>{ft.init(e,t),Gn.init(e,t)}),cr=i("ZodBase64URL",(e,t)=>{ht.init(e,t),Gn.init(e,t)}),ur=i("ZodE164",(e,t)=>{mt.init(e,t),Gn.init(e,t)}),dr=i("ZodJWT",(e,t)=>{gt.init(e,t),Gn.init(e,t)}),pr=i("ZodNumber",(e,t)=>{vt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=n,{minimum:i,maximum:o,format:s,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u}=e._zod.bag;"string"==typeof s&&s.includes("int")?r.type="integer":r.type="number";const d="number"==typeof u&&u>=(i??Number.NEGATIVE_INFINITY),p="number"==typeof c&&c<=(o??Number.POSITIVE_INFINITY),l="draft-04"===t.target||"openapi-3.0"===t.target;d?l?(r.minimum=u,r.exclusiveMinimum=!0):r.exclusiveMinimum=u:"number"==typeof i&&(r.minimum=i),p?l?(r.maximum=c,r.exclusiveMaximum=!0):r.exclusiveMaximum=c:"number"==typeof o&&(r.maximum=o),"number"==typeof a&&(r.multipleOf=a)})(e,t,n),Jn(e,"ZodNumber",{gt(e,t){return this.check(sn(e,t))},gte(e,t){return this.check(an(e,t))},min(e,t){return this.check(an(e,t))},lt(e,t){return this.check(rn(e,t))},lte(e,t){return this.check(on(e,t))},max(e,t){return this.check(on(e,t))},int(e){return this.check(hr(e))},safe(e){return this.check(hr(e))},positive(e){return this.check(sn(0,e))},nonnegative(e){return this.check(an(0,e))},negative(e){return this.check(rn(0,e))},nonpositive(e){return this.check(on(0,e))},multipleOf(e,t){return this.check(cn(e,t))},step(e,t){return this.check(cn(e,t))},finite(){return this}});const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function lr(e){return function(e,t){return new pr({type:"number",checks:[],...O(t)})}(0,e)}const fr=i("ZodNumberFormat",(e,t)=>{yt.init(e,t),pr.init(e,t)});function hr(e){return function(e,t){return new fr({type:"number",check:"number_format",abort:!1,format:"safeint",...O(t)})}(0,e)}const mr=i("ZodBoolean",(e,t)=>{_t.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.type="boolean"})(0,0,t)});function gr(e){return function(e,t){return new mr({type:"boolean",...O(t)})}(0,e)}const vr=i("ZodUnknown",(e,t)=>{bt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function yr(){return new vr({type:"unknown"})}const _r=i("ZodNever",(e,t)=>{zt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.not={}})(0,0,t)});const br=i("ZodArray",(e,t)=>{kt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=n,o=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;"number"==typeof s&&(i.minItems=s),"number"==typeof a&&(i.maxItems=a),i.type="array",i.items=hn(o.element,t,{...r,path:[...r.path,"items"]})})(e,t,n,r),e.element=t.element,Jn(e,"ZodArray",{min(e,t){return this.check(dn(e,t))},nonempty(e){return this.check(dn(1,e))},max(e,t){return this.check(un(e,t))},length(e,t){return this.check(pn(e,t))},unwrap(){return this.element}})});function zr(e,t){return function(e,t,n){return new br({type:"array",element:t,...O(n)})}(0,e,t)}const wr=i("ZodObject",(e,t)=>{It.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=n,o=e._zod.def;i.type="object",i.properties={};const s=o.shape;for(const e in s)i.properties[e]=hn(s[e],t,{...r,path:[...r.path,"properties",e]});const a=new Set(Object.keys(s)),c=new Set([...a].filter(e=>{const n=o.shape[e]._zod;return"input"===t.io?void 0===n.optin:void 0===n.optout}));c.size>0&&(i.required=Array.from(c)),"never"===o.catchall?._zod.def.type?i.additionalProperties=!1:o.catchall?o.catchall&&(i.additionalProperties=hn(o.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):"output"===t.io&&(i.additionalProperties=!1)})(e,t,n,r),m(e,"shape",()=>t.shape),Jn(e,"ZodObject",{keyof(){return Er(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:yr()})},loose(){return this.clone({...this._zod.def,catchall:yr()})},strict(){return this.clone({...this._zod.def,catchall:function(e,t){return new _r({type:"never",...O(t)})}(0,e)});var e},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return function(e,t){if(!w(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const n=e._zod.def.shape;for(const e in t)if(void 0!==Object.getOwnPropertyDescriptor(n,e))throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const r=v(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return g(this,"shape",n),n}});return S(e,r)}(this,e)},safeExtend(e){return function(e,t){if(!w(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=v(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return g(this,"shape",n),n}});return S(e,n)}(this,e)},merge(e){return function(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=v(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return g(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return S(e,n)}(this,e)},pick(e){return function(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return S(e,v(e._zod.def,{get shape(){const e={};for(const r in t){if(!(r in n.shape))throw new Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return g(this,"shape",e),e},checks:[]}))}(this,e)},omit(e){return function(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=v(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return g(this,"shape",r),r},checks:[]});return S(e,i)}(this,e)},partial(...e){return function(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const i=v(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(n)for(const t in n){if(!(t in r))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:"optional",innerType:r[t]}):r[t])}else for(const t in r)i[t]=e?new e({type:"optional",innerType:r[t]}):r[t];return g(this,"shape",i),i},checks:[]});return S(t,i)}(Pr,this,e[0])},required(...e){return function(e,t,n){const r=v(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(n)for(const t in n){if(!(t in i))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:"nonoptional",innerType:r[t]}))}else for(const t in r)i[t]=new e({type:"nonoptional",innerType:r[t]});return g(this,"shape",i),i}});return S(t,r)}(Jr,this,e[0])}})});function kr(e,t){const n={type:"object",shape:e??{},...O(t)};return new wr(n)}const $r=i("ZodUnion",(e,t)=>{Zt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def,o=!1===i.inclusive,s=i.options.map((e,n)=>hn(e,t,{...r,path:[...r.path,o?"oneOf":"anyOf",n]}));o?n.oneOf=s:n.anyOf=s})(e,t,n,r),e.options=t.options}),xr=i("ZodDiscriminatedUnion",(e,t)=>{$r.init(e,t),Tt.init(e,t)});function Sr(e,t,n){return new xr({type:"union",options:t,discriminator:e,...O(n)})}const Or=i("ZodIntersection",(e,t)=>{Nt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def,o=hn(i.left,t,{...r,path:[...r.path,"allOf",0]}),s=hn(i.right,t,{...r,path:[...r.path,"allOf",1]}),a=e=>"allOf"in e&&1===Object.keys(e).length,c=[...a(o)?o.allOf:[o],...a(s)?s.allOf:[s]];n.allOf=c})(e,t,n,r)}),Ir=i("ZodEnum",(e,t)=>{At.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=u(e._zod.def.entries);r.every(e=>"number"==typeof e)&&(n.type="number"),r.every(e=>"string"==typeof e)&&(n.type="string"),n.enum=r})(e,0,n),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{const i={};for(const r of e){if(!n.has(r))throw new Error(`Key ${r} not found in enum`);i[r]=t.entries[r]}return new Ir({...t,checks:[],...O(r),entries:i})},e.exclude=(e,r)=>{const i={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete i[t]}return new Ir({...t,checks:[],...O(r),entries:i})}});function Er(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Ir({type:"enum",entries:n,...O(t)})}const Zr=i("ZodLiteral",(e,t)=>{Ft.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=e._zod.def,i=[];for(const e of r.values)if(void 0===e){if("throw"===t.unrepresentable)throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof e){if("throw"===t.unrepresentable)throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(e))}else i.push(e);if(0===i.length);else if(1===i.length){const e=i[0];n.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?n.enum=[e]:n.const=e}else i.every(e=>"number"==typeof e)&&(n.type="number"),i.every(e=>"string"==typeof e)&&(n.type="string"),i.every(e=>"boolean"==typeof e)&&(n.type="boolean"),i.every(e=>null===e)&&(n.type="null"),n.enum=i})(e,t,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Tr(e,t){return new Zr({type:"literal",values:Array.isArray(e)?e:[e],...O(t)})}const Nr=i("ZodTransform",(e,t)=>{Rt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema")})(0,e),e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new s(e.constructor.name);n.addIssue=r=>{if("string"==typeof r)n.issues.push(A(r,n.value,t));else{const t=r;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=n.value),t.inst??(t.inst=e),n.issues.push(A(t))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}}),Pr=i("ZodOptional",(e,t)=>{Ut.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bn(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});function jr(e){return new Pr({type:"optional",innerType:e})}const Ar=i("ZodExactOptional",(e,t)=>{Jt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bn(e,t,0,r),e.unwrap=()=>e._zod.def.innerType}),Fr=i("ZodNullable",(e,t)=>{Mt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def,o=hn(i.innerType,t,r),s=t.seen.get(e);"openapi-3.0"===t.target?(s.ref=i.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Rr(e){return new Fr({type:"nullable",innerType:e})}const Cr=i("ZodDefault",(e,t)=>{Dt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;hn(i.innerType,t,r),t.seen.get(e).ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}),Ur=i("ZodPrefault",(e,t)=>{Lt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;hn(i.innerType,t,r),t.seen.get(e).ref=i.innerType,"input"===t.io&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),Jr=i("ZodNonOptional",(e,t)=>{Gt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;hn(i.innerType,t,r),t.seen.get(e).ref=i.innerType})(e,t,0,r),e.unwrap=()=>e._zod.def.innerType}),Mr=i("ZodCatch",(e,t)=>{Ht.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;let o;hn(i.innerType,t,r),t.seen.get(e).ref=i.innerType;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=o})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}),Dr=i("ZodPipe",(e,t)=>{Kt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def,o=i.in._zod.traits.has("$ZodTransform"),s="input"===t.io?o?i.out:i.in:i.out;hn(s,t,r),t.seen.get(e).ref=s})(e,t,0,r),e.in=t.in,e.out=t.out});function Vr(e,t){return new Dr({type:"pipe",in:e,out:t})}const Lr=i("ZodReadonly",(e,t)=>{qt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;hn(i.innerType,t,r),t.seen.get(e).ref=i.innerType,n.readOnly=!0})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),Gr=i("ZodCustom",(e,t)=>{Xt.init(e,t),Mn.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")})(0,e)}),Wr=Ln().trim().min(1).max(120).regex(/^[a-zA-Z0-9][a-zA-Z0-9_.:-]*$/),Hr=Ln().datetime(),Kr=lr().int().nonnegative(),Br=Er(["https-token","ssh-key"]),qr=Er(["operation-only","instance-retained"]),Yr=Er(["enabled","disabled"]),Xr=Er(["pending","synced","deferred","revoking","revoked"]),Qr=kr({scheme:Er(["https","ssh"]),host:Ln().trim().min(1).max(253),port:lr().int().min(1).max(65535).optional(),pathPrefix:Ln().min(1).max(2048).default("/")}).strict();function ei(e){throw new Error(`Invalid Git credential scope: ${e}`)}function ti(e){const t=e.trim().replace(/^\[|\]$/g,"");(!t||t.includes("*")||/[/?#@\s]/.test(t))&&ei("host is invalid");try{const e=new URL(t.includes(":")?`http://[${t}]/`:`http://${t}/`).hostname.replace(/^\[|\]$/g,"").toLowerCase();return(!e||e.length>253||e.includes("*"))&&ei("host is invalid"),e}catch{ei("host is invalid")}}function ni(e){try{return decodeURIComponent(e)}catch{ei("path contains invalid percent encoding")}}function ri(e){const t=e?.trim()||"/";(t.includes("?")||t.includes("#")||t.includes("\\")||t.includes("\0"))&&ei("path contains an unsupported delimiter");const n=(t.startsWith("/")?t:`/${t}`).split("/").filter(Boolean);for(const e of n){const t=ni(e);("."===t||".."===t||t.includes("/")||t.includes("\\")||t.includes("\0"))&&ei("path contains an unsafe segment")}return 0===n.length?"/":`/${n.join("/")}/`}function ii(e){const t=Qr.parse(e),n="https"===t.scheme?443:22;return Qr.parse({scheme:t.scheme,host:ti(t.host),...void 0===t.port||t.port===n?{}:{port:t.port},pathPrefix:ri(t.pathPrefix)})}function oi(e){return ri(e.replace(/\.git\/?$/,""))}const si=kr({id:Wr,name:Ln().trim().min(1).max(160),kind:Br,scope:Qr,secretSet:Tr(!0),status:Yr,revision:Kr,createdAt:Hr,updatedAt:Hr}).strict(),ai=Sr("kind",[kr({kind:Tr("https-token"),username:Ln().trim().min(1).max(240),token:Ln().min(1).max(8192)}).strict(),kr({kind:Tr("ssh-key"),privateKey:Ln().min(1).max(131072),passphrase:Ln().max(8192).optional(),pinnedKnownHosts:Ln().min(1).max(131072)}).strict()]);kr({name:Ln().trim().min(1).max(160),scope:Qr,secret:ai}).strict().superRefine((e,t)=>{"https"===e.scope.scheme!=("https-token"===e.secret.kind)&&t.addIssue({code:"custom",path:["scope","scheme"],message:"Credential kind must match the remote scheme."});try{ii(e.scope)}catch(e){t.addIssue({code:"custom",path:["scope"],message:e instanceof Error?e.message:"Invalid Git scope."})}}),kr({name:Ln().trim().min(1).max(160).optional(),scope:Qr.optional(),secret:ai.optional(),status:Yr.optional()}).strict().refine(e=>Object.keys(e).length>0,"At least one credential field must be updated."),kr({items:zr(si).max(1e4)}).strict(),kr({host:Ln().trim().min(1).max(253),port:lr().int().min(1).max(65535).optional()}).strict();const ci=kr({keyType:Ln().trim().min(1).max(64),fingerprint:Ln().trim().min(1).max(256),publicKey:Ln().trim().min(1).max(8192),knownHosts:Ln().min(1).max(8192)}).strict();kr({host:Ln().trim().min(1).max(253),port:lr().int().min(1).max(65535),fetchedAt:Hr,knownHosts:Ln().min(1).max(65536),entries:zr(ci).min(1).max(32)}).strict(),kr({instanceId:Wr,credentialId:Wr,credentialRevision:Kr,assignmentRevision:Kr,status:Xr,authorizedAt:Hr,updatedAt:Hr}).strict();const ui=kr({credential:si,secret:ai}).strict().superRefine((e,t)=>{e.credential.kind!==e.secret.kind&&t.addIssue({code:"custom",path:["secret","kind"],message:"Credential payload kind mismatch."})});kr({instanceId:Wr,generation:Kr,credentialIds:zr(Wr).max(256).transform(e=>[...new Set(e)].sort()),updatedAt:Hr}).strict(),kr({remoteUrl:Ln().trim().min(1).max(4096)}).strict(),Sr("status",[kr({status:Tr("ok"),username:Ln().min(1).max(240),password:Ln().min(1).max(8192)}).strict(),kr({status:Er(["none","ambiguous","unsupported","missing-host-key","rejected"])}).strict()]),kr({remoteUrl:Ln().trim().min(1).max(4096)}).strict(),Sr("status",[kr({status:Tr("ok"),invocationId:Wr,publicIdentity:Ln().min(1).max(131072),pinnedKnownHosts:Ln().min(1).max(131072)}).strict(),kr({status:Er(["none","ambiguous","unsupported","missing-host-key","rejected"])}).strict()]),kr({invocationId:Wr,frame:Ln().min(1).max(1048576)}).strict(),kr({frame:Ln().min(1).max(1048576)}).strict();const di=kr({operationId:Wr,retention:qr,payload:ui}).strict();function pi(e){return`'${e.replace(/'/g,"'\\''")}'`}function li(e){const t=e.replace(/-/g,"_").toUpperCase();return Object.assign(new Error(`TASK_HANDOFF_GIT_PROVISIONING_ERROR=${t}`),{code:t})}function fi(e,r=process.env.TASK_HANDOFF_GIT_RUNTIME_DIR||"/run/task-handoff/git-runtime"){const i=function(e){return t.readdirSync(e,{withFileTypes:!0}).filter(e=>e.isDirectory()&&e.name.startsWith("credential-")).sort((e,t)=>e.name.localeCompare(t.name)).flatMap(r=>{const i=n.join(e,r.name),o=n.join(i,"scope.json");if(!t.existsSync(o))return[];const s=t.existsSync(n.join(i,"token")),a=t.existsSync(n.join(i,"public-identity"));return s||a?[{candidate:{id:r.name,kind:s?"https-token":"ssh-key",scope:JSON.parse(t.readFileSync(o,"utf8")),status:"enabled",...a?{pinnedKnownHosts:t.existsSync(n.join(i,"known_hosts"))}:{}},directory:i}]:[]})}(r),o=function(e,t){let n;try{n=function(e){const t=e.trim();if(t&&!t.includes("\0")||ei("remote is empty or invalid"),/^https?:\/\//i.test(t)||/^ssh:\/\//i.test(t)){let e;ri(t.replace(/^[a-z][a-z0-9+.-]*:\/\/[^/]+/i,"").split(/[?#]/,1)[0]||"/");try{e=new URL(t)}catch{ei("remote URL is invalid")}"https:"!==e.protocol&&"ssh:"!==e.protocol&&ei("remote scheme is unsupported"),(e.password||"https:"===e.protocol&&e.username)&&ei("HTTPS userinfo is forbidden"),(e.search||e.hash)&&ei("query and fragment are forbidden");const n="https:"===e.protocol?"https":"ssh",r=e.port?Number(e.port):void 0;return{...ii({scheme:n,host:e.hostname,port:r,pathPrefix:oi(e.pathname)}),original:t}}/^[a-z][a-z0-9+.-]*:\/\//i.test(t)&&ei("remote scheme is unsupported");const n=/^(?:([^@/:\s]+)@)?([^/:\s]+):(.+)$/.exec(t);n||ei("remote must use HTTPS, ssh://, or scp-like SSH syntax");const[,,r,i]=n;return(i.includes("?")||i.includes("#"))&&ei("query and fragment are forbidden"),{...ii({scheme:"ssh",host:r,pathPrefix:oi(i)}),original:t}}(e)}catch(e){return{status:"unsupported",reason:e instanceof Error?e.message:"Unsupported Git remote."}}const r=t.filter(e=>"enabled"===e.status).filter(e=>"https"===n.scheme==("https-token"===e.kind)).filter(e=>function(e,t){const n=ii(e);return n.scheme===t.scheme&&n.host===t.host&&n.port===t.port&&("/"===n.pathPrefix||t.pathPrefix.startsWith(n.pathPrefix))}(e.scope,n)).map(e=>({candidate:e,specificity:ii(e.scope).pathPrefix.length}));if(0===r.length)return{status:"none",remote:n};const i=Math.max(...r.map(e=>e.specificity)),o=r.filter(e=>e.specificity===i).map(e=>e.candidate);if(o.length>1)return{status:"ambiguous",remote:n,credentialIds:o.map(e=>e.id).sort()};const s=o[0];return"ssh-key"===s.kind&&!0!==s.pinnedKnownHosts?{status:"missing-host-key",remote:n,credentialId:s.id}:{status:"unique",remote:n,credential:s}}(e,i.map(e=>e.candidate));if("unique"!==o.status)throw li("none"===o.status?"credential-missing":o.status);const s=i.find(e=>e.candidate.id===o.credential.id);if(!s)throw li("credential-missing");return s.directory}async function hi(e){const i=function(e){if(!Array.isArray(e)||e.some(e=>"string"!=typeof e||e.includes("\0")))return;const t=e;let n,r="";const i=[];for(let e=0;e<t.length;e+=1){const o=t[e];if("-p"===o&&/^\d+$/.test(t[e+1]||"")&&void 0===n){const r=Number(t[++e]);if(r<1||r>65535)return;n=String(r);continue}if("-4"!==o&&"-6"!==o)if("-o"!==o||"SendEnv=GIT_PROTOCOL"!==t[e+1]){if("-oSendEnv=GIT_PROTOCOL"!==o){if(o.startsWith("-"))return;if(r=o,e+=1,e!==t.length-1)return;break}i.push(o)}else i.push("-o",t[++e]);else i.push(o)}if(!r||!/^(?:[a-zA-Z0-9._-]+@)?[^@\s]+$/.test(r))return;const o=r.replace(/^[^@]+@/,""),s=function(e){const t=/^(git-upload-pack|git-receive-pack|git-upload-archive) ([\s\S]+)$/.exec(e);if(!t)return;const n=t[2];let r;if(n.startsWith("'")){if(!n.endsWith("'"))return;if(r=n.slice(1,-1).replace(/'\\''/g,"'"),pi(r)!==n)return}else{if(!/^[a-zA-Z0-9._~@%+,:\/-]+$/.test(n))return;r=n}return!r||/[\0-\x1f\x7f]/.test(r)?void 0:{service:t[1],repository:r}}(t.at(-1)||"");if(!o||!s)return;const a=`${s.service} ${pi(s.repository)}`;return{remote:`ssh://${o}${n?`:${n}`:""}/${encodeURIComponent(s.repository.replace(/^\/+/,"")).replace(/%2F/gi,"/")}`,args:[...i,...n?["-p",n]:[],r,a]}}(e);if(!i)throw li("remote-unsupported");const o=fi(i.remote),s=n.join(o,"agent.sock"),a=n.join(o,"public-identity"),c=n.join(o,"known_hosts");if(!t.existsSync(s))throw li("ssh-agent-unavailable");if(!t.existsSync(c)||0===t.statSync(c).size)throw li("host-key-required");return function(e,t,n={}){return new Promise((t,i)=>{const o={...process.env};delete o.SSH_AUTH_SOCK,Object.assign(o,n);const s=r.spawn("ssh",e,{stdio:"inherit",shell:!1,env:o});s.once("error",i),s.once("close",(e,n)=>0===e?t():i(Object.assign(new Error("Git SSH transport failed."),{exitCode:e,signal:n})))})}(["-F","/dev/null","-oBatchMode=yes","-oPasswordAuthentication=no","-oKbdInteractiveAuthentication=no","-oIdentitiesOnly=yes","-oIdentityFile=none","-oStrictHostKeyChecking=yes",`-oUserKnownHostsFile=${c}`,"-oGlobalKnownHostsFile=/dev/null",`-oIdentityAgent=${s}`,"-i",a,...i.args],0,{SSH_AUTH_SOCK:s})}kr({operationId:Wr,instanceId:Wr,remoteUrl:Ln().trim().min(1).max(4096),ref:Sr("type",[kr({type:Er(["branch","tag"]),name:Ln().trim().min(1).max(240)}).strict(),kr({type:Tr("commit"),commit:Ln().trim().regex(/^[0-9a-fA-F]{4,64}$/,"commit must be a hexadecimal Git object id")}).strict()]),clone:kr({depth:lr().int().positive().max(1e5).optional(),submodules:gr().default(!1),lfs:gr().default(!1),subdirectory:Ln().trim().max(240).refine(e=>!e.startsWith("/")&&!e.split("/").some(e=>".."===e),"subdirectory must be a relative path within the repository").transform(e=>e.split("/").filter(e=>e&&"."!==e).join("/")).default("")}).strict(),credentials:zr(di).max(256).default([])}).strict(),process.platform,async function(){const[e,...r]=process.argv.slice(2);if("credential"===e)return async function(e){if("get"!==e)return;const r=function(e){const t="https"===e.protocol?"https":void 0,n="string"==typeof e.host?e.host.trim():"",r="string"==typeof e.path?e.path.replace(/^\/+/,""):"";return t&&n?`${t}://${n}/${r}`:void 0}(await new Promise(e=>{let t="";process.stdin.setEncoding("utf8"),process.stdin.on("data",e=>{t+=e}),process.stdin.on("end",()=>e(Object.fromEntries(t.split(/\r?\n/).flatMap(e=>{const t=e.indexOf("=");return t>0?[[e.slice(0,t),e.slice(t+1)]]:[]}))))}));if(!r)throw li("remote-unsupported");let i;try{i=fi(r)}catch(e){if("CREDENTIAL_MISSING"===e.code)return void process.stderr.write(`${e.message}\n`);throw e}const o=t.readFileSync(n.join(i,"username"),"utf8"),s=t.readFileSync(n.join(i,"token"),"utf8");process.stdout.write(`username=${o}\npassword=${s}\n\n`)}(r[0]);if("ssh"===e)return hi(r);throw new Error("TASK_HANDOFF_GIT_PROVISIONING_ERROR=REMOTE_UNSUPPORTED")}().catch(e=>{process.stderr.write(`${e instanceof Error?e.message:String(e)}\n`),process.exitCode=1});
1
+ "use strict";var e=require("node:fs"),t=require("node:path"),n=require("node:child_process");function r(e){const t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,n])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function i(e,t="|"){return e.map(e=>x(e)).join(t)}function o(e,t){return"bigint"==typeof t?t.toString():t}class s{constructor(e){this._getter=e,this._value=void 0}get value(){const e=this._getter;return void 0!==e&&(this._value=e(),this._getter=void 0),this._value}}function a(e){return new s(e)}function c(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function u(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function d(e){const t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function l(e){return d(e._zod.def)??e._zod.def.shape}function f(e,t,n){Object.defineProperty(e,t,{get(){const e=n();return u(this,t,e),e},enumerable:!0,configurable:!0})}function p(e,t,n){t in e?u(e,t,n):e[t]=n}function h(e,t,n,r){const i=l(t);for(const o of n){const n=Object.getOwnPropertyDescriptor(i,o);n.enumerable&&(n.get?f(e,o,()=>{const e=t._zod.def.shape[o];return r?r(e,o):e}):p(e,o,r?r(n.value,o):n.value))}}function m(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function g(e){return JSON.stringify(e)}const y="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function v(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const _=a(()=>{if(ie.jitless)return!1;if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function b(e){if(!1===v(e))return!1;const t=e.constructor;if(void 0===t)return!0;if("function"!=typeof t)return!0;const n=t.prototype;return!1!==v(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function w(e){return b(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const z=new Set(["string","number","symbol"]);function k(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $(e,t,n){const r=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(r._zod.parent=e),r}function O(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}function x(e){return"bigint"==typeof e?e.toString()+"n":"string"==typeof e?`"${e}"`:`${e}`}const S=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),I={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function j(e,t){const n=l(e),r=[];for(const e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw new Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function E(e,t){const n={};return h(n,e,Reflect.ownKeys(l(e))),function(e,t){for(const n of Reflect.ownKeys(t)){const r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?f(e,n,()=>t[n]):p(e,n,r.value))}}(n,t),n}function P(e,t,n,r="partial"){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(`.${r}() cannot be used on object schemas containing refinements`);const o=n?new Set(j(t,n)):void 0,s={};return h(s,t,Reflect.ownKeys(l(t)),e&&((t,n)=>o&&!o.has(n)?t:new e({type:"optional",innerType:t}))),$(t,m(t._zod.def,{shape:s,checks:[]}))}function A(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n]?.continue)return!0;return!1}function T(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!1===e.issues[n]?.continue)return!0;return!1}function Z(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function N(e){return"string"==typeof e?e:e?.message}function F(e){const t=[];for(const n of e??[]){const e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;const r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function R(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function C(e,t,n){var r;const i=e.inst?._zod?.traits;i?.has("$ZodType")&&(i.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);const o=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:N(e.inst?._zod.def?.error?.(e))??N(o?.(e))??N(t?.error?.(e))??N(n.customError?.(e))??N(n.localeError?.(e))??"Invalid input",a={};for(const t of Object.keys(e))"inst"!==t&&"schema"!==t&&"continue"!==t&&"input"!==t&&"__proto__"!==t&&(a[t]=e[t]);return a.path??(a.path=[]),a.message=s,t?.reportInput&&(a.input=e.input),a}const D=/[\uD800-\uDBFF]/;function U(e){const t=e.length;if(!D.test(e))return t;let n=t;for(let r=0;r<t-1;r++)55296==(64512&e.charCodeAt(r))&&56320==(64512&e.charCodeAt(r+1))&&(n--,r++);return n}function J(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function M(...e){const[t,n,r]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:r}:{...t}}function L(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function K(e,t,n){return L(e,t,n,!1)}function V(e,t){for(const n in e){const r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return L(this,n,r(this))},set(e){L(this,n,e)}})}return t}function W(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return null==this?n:L(this,t,n.bind(this))},set(e){L(this,t,e)}})}let G,H=!1;const B={configurable:!0,get(){H=!0}};function q(e,t,n){const r=Object.getPrototypeOf(e._zod);t in r&&G!==e._zod?G=void 0:(G=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,B);const e=H;H=!1;try{const r=n(this);return H?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),H=H||e,r}catch(n){throw delete this[t],H=H||e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function X(e){const t=()=>e;return t["~constantCatch"]=!0,t}var Y;const Q={value:void 0,enumerable:!1};let ee="captureStackTrace"in Error?Error:null;function te(e,t,n,r){function i(e){this.def=e,this.constr=d,this.traits=new Set}i.prototype={};const o=n,s=o&&new WeakSet;function a(n,r){if(n._zod){if(n._zod.traits.has(e))return}else{Q.value=new i(r);try{Object.defineProperty(n,"_zod",Q)}finally{Q.value=void 0}}if(n._zod.traits.add(e),t(n,r),s){const e=Object.getPrototypeOf(n),t=n._zod.constr.prototype;let r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);const i=r??e;s.has(i)||(s.add(i),function(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):W(e,n,r.value)}}(i,o))}const a=d.prototype;for(const e in a)Object.prototype.hasOwnProperty.call(a,e)&&(e in n||(n[e]=a[e].bind(n)))}const c=r?.Parent??Object;class u extends c{}function d(e){const t=r?.Parent?function(e){const t=ee;if(t){const n=t.stackTraceLimit;if("number"==typeof n){try{t.stackTraceLimit=0}catch{return ee=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}(u):this;a(t,e);const n=t._zod.deferred;if(n){for(const e of n)e();t._zod.deferred=void 0}const i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(u,"name",{value:e}),Object.defineProperty(d,"init",{value:a}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>!!(r?.Parent&&t instanceof r.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}class ne extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class re extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(Y=globalThis).__zod_globalConfig??(Y.__zod_globalConfig={});const ie=globalThis.__zod_globalConfig;function oe(e){return e&&Object.assign(ie,e),ie}const se={get:function(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,o,2)),e.message},set:function(e){this._zod.message=e},enumerable:!0,configurable:!0},ae={value:void 0,enumerable:!1},ce=new WeakSet([Object.prototype,Error.prototype]),ue=te("$ZodError",(e,t)=>{e.name="$ZodError",ae.value=t,Object.defineProperty(e,"issues",ae),ae.value=void 0,Object.defineProperty(e,"message",se);const n=Object.getPrototypeOf(e);ce.has(n)||(ce.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){const e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))});function de(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||("__proto__"===t?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function le(e,t){return{callee:t?.callee??e,Err:t?.Err}}const fe=e=>{const t=(n,r,i,o)=>{const s=i?{...i,async:!1}:{async:!1},a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new ne;if(a.issues.length){const n=new(o?.Err??e)(a.issues.map(e=>C(e,s,oe())));throw y(n,o?.callee??t),n}return a.value};return t},pe=e=>{const t=async(n,r,i,o)=>{const s=i?{...i,async:!0}:{async:!0};let a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){const n=new(o?.Err??e)(a.issues.map(e=>C(e,s,oe())));throw y(n,o?.callee??t),n}return a.value};return t},he=e=>(t,n,r)=>{const i=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new ne;return o.issues.length?me(e,o.issues,i):{success:!0,data:o.value}};function me(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>C(e,n,oe()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}const ge=e=>async(t,n,r)=>{const i=r?{...r,async:!0}:{async:!0};let o=t._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?me(e,o.issues,i):{success:!0,data:o.value}},ye=Symbol.for("zod.compile.invalid"),ve=Symbol.for("zod.compile.fallback"),_e=e=>{const t=fe(e),n=(e,r,i,o)=>{const s=i?{...i,direction:"backward"}:{direction:"backward"};return t(e,r,s,le(n,o))};return n},be=e=>{const t=fe(e),n=(e,r,i,o)=>t(e,r,i,le(n,o));return n},we=e=>{const t=pe(e),n=async(e,r,i,o)=>{const s=i?{...i,direction:"backward"}:{direction:"backward"};return await t(e,r,s,le(n,o))};return n},ze=e=>{const t=pe(e),n=async(e,r,i,o)=>await t(e,r,i,le(n,o));return n},ke=e=>(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return he(e)(t,n,i)},$e=e=>(t,n,r)=>he(e)(t,n,r),Oe=e=>async(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return ge(e)(t,n,i)},xe=e=>async(t,n,r)=>ge(e)(t,n,r),Se=/^[cC][0-9a-z]{6,}$/,Ie=/^[0-9a-z]+$/,je=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Ee=/^[0-9a-vA-V]{20}$/,Pe=/^[A-Za-z0-9]{27}$/,Ae=/^[a-zA-Z0-9_-]{21}$/,Te=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Ze=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Ne=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Fe=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Re=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ce=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,De=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Ue=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Je=/^https?$/,Me=/^\+[1-9]\d{6,14}$/,Le="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function Ke(e){return new RegExp(`^${e}$`)}const Ve=Ke(Le);function We(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}const Ge=/^[\s\S]{0,}$/,He=/^-?\d+(?:\.\d+)?$/,Be=/^(?:true|false)$/i,qe=/^[^A-Z]*$/,Xe=/^[^a-z]*$/,Ye=te("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Qe=e=>{const t=e.value;return!(null==t||void 0===t.length)},et={number:"number",bigint:"bigint",object:"date"},tt=te("$ZodCheckLessThan",(e,t)=>{Ye.init(e,t);const n=et[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:et[typeof r.value]??n,code:"too_big",maximum:"object"==typeof t.value?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),nt=te("$ZodCheckGreaterThan",(e,t)=>{Ye.init(e,t);const n=et[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:et[typeof r.value]??n,code:"too_small",minimum:"object"==typeof t.value?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),rt=te("$ZodCheckMultipleOf",(e,t)=>{Ye.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof n.value?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):0===function(e,t){const n=e/t,r=Math.round(n),i=4*Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}(n.value,t.value))||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),it=te("$ZodCheckNumberFormat",(e,t)=>{Ye.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[i,o]=S[t.format];e._zod.check=s=>{const a=s.value;if(n){if(!Number.isInteger(a))return void s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});if(!Number.isSafeInteger(a))return void(a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}))}a<i&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),a>o&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),ot=te("$ZodCheckMaxLength",(e,t)=>{var n;Ye.init(e,t),(n=e._zod.def).when??(n.when=Qe),e._zod.check=n=>{const r=n.value,i=r.length;if(("string"==typeof r&&i>t.maximum?U(r):i)<=t.maximum)return;const o=J(r);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),st=te("$ZodCheckMinLength",(e,t)=>{var n;Ye.init(e,t),(n=e._zod.def).when??(n.when=Qe),e._zod.check=n=>{const r=n.value,i=r.length;if(("string"==typeof r&&i>=t.minimum&&i<2*t.minimum?U(r):i)>=t.minimum)return;const o=J(r);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),at=te("$ZodCheckLengthEquals",(e,t)=>{var n;Ye.init(e,t),(n=e._zod.def).when??(n.when=Qe),e._zod.check=n=>{const r=n.value,i=r.length,o="string"==typeof r&&i>=t.length&&i<=2*t.length?U(r):i;if(o===t.length)return;const s=J(r),a=o>t.length;n.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),ct=te("$ZodCheckStringFormat",(e,t)=>{var n,r;Ye.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),ut=te("$ZodCheckRegex",(e,t)=>{ct.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),dt=te("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=qe),ct.init(e,t)}),lt=te("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Xe),ct.init(e,t)}),ft=te("$ZodCheckIncludes",(e,t)=>{Ye.init(e,t);const n=k(t.includes),r=new RegExp("number"==typeof t.position?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),pt=te("$ZodCheckStartsWith",(e,t)=>{Ye.init(e,t);const n=new RegExp(`^${k(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),ht=te("$ZodCheckEndsWith",(e,t)=>{Ye.init(e,t);const n=new RegExp(`.*${k(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),mt=te("$ZodCheckOverwrite",(e,t)=>{Ye.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class gt{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>" ".repeat(2*this.indent)+e);for(const e of r)this.content.push(e)}compile(){const e=Function,t=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {\n${t.join("\n")}\n};`)(...Object.values(this.closed))}}const yt={major:4,minor:6,patch:7},vt=te("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=yt;const r=e._zod.def.checks,i=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r?.length?[...r]:[];for(const t of i)for(const n of t._zod.onattach)n(e);if(0===i.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(t,n,r)=>{if(t.memo)return t;let i,o=A(t);for(const s of n){if(s._zod.def.when){if(T(t))continue;if(!s._zod.def.when(t))continue}else if(o)continue;const n=t.issues.length,a=s._zod.check(t);if(a instanceof Promise&&!1===r?.async)throw new ne;if(i||a instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await a,t.issues.length!==n&&(R(t.issues,n,e),o||(o=A(t,n)))});else{if(t.issues.length===n)continue;R(t.issues,n,e),o||(o=A(t,n))}}return i?i.then(()=>t):t},n=(n,r,o)=>{if(A(n))return n.aborted=!0,n;const s=t(r,i,o);if(s instanceof Promise){if(!1===o.async)throw new ne;return s.then(t=>e._zod.parse(t,o))}return e._zod.parse(s,o)};e._zod.run=(r,o)=>{if(o.skipChecks)return e._zod.parse(r,o);if("backward"===o.direction){const t=e._zod.parse({value:r.value,issues:[]},{...o,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,o)):n(t,r,o)}const s=e._zod.parse(r,o);if(s instanceof Promise){if(!1===o.async)throw new ne;return s.then(e=>t(e,i,o))}return t(s,i,o)}}},{get"~standard"(){return K(this,"~standard",bt(this))},set"~standard"(e){L(this,"~standard",e)}}),_t=(e,t)=>e.issues.length?{issues:e.issues.map(e=>C(e,t,oe()))}:{value:e.value};function bt(e){return{validate:t=>{const n={async:!1};try{const r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return _t(r,n)}catch(e){}return async function(e,t){const n={async:!0};return _t(await e._zod.run({value:t,issues:[]},n),n)}(e,t)},vendor:"zod",version:1}}const wt=te("$ZodString",(e,t)=>{vt.init(e,t),e._zod.pattern=t.pattern??Ge,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),zt=te("$ZodStringFormat",(e,t)=>{ct.init(e,t),wt.init(e,t)}),kt=te("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Ze),zt.init(e,t)}),$t=te("$ZodUUID",(e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Ne(e))}else t.pattern??(t.pattern=Ne());zt.init(e,t)}),Ot=te("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Fe),zt.init(e,t)});function xt(e){try{return"undefined"!=typeof URL&&"function"==typeof URL.canParse?URL.canParse(e):(new URL(e),!0)}catch{return!1}}const St=/[\t\n\r]/g;function It(e){return e.replace(St,"")}const jt=te("$ZodURL",(e,t)=>{zt.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),i=function(e,t){return"normalize"in t||"hostname"in t||"protocol"in t?function(e,t){if(!t.normalize&&t.protocol?.source===Je.source&&!/^https?:\/\//i.test(e))return 1;try{if("undefined"!=typeof URL){const t=URL;if("function"==typeof t.parse)return t.parse(e)??2}return new URL(e)}catch{return 2}}(e,t):xt(e)||2}(r,t);return 1===i?void n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort}):2===i?void n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort}):!0===i?void(n.value=It(r)):(t.hostname&&!function(e,t){return t.lastIndex=0,t.test(e.hostname)}(i,t.hostname)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!function(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}(i,t.protocol)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),void(n.value=t.normalize?i.href:It(r)))}catch(r){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Et=te("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$","u")),zt.init(e,t)}),Pt=te("$ZodNanoID",(e,t)=>{if(void 0!==t.length&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);var n;t.pattern??(t.pattern=void 0===t.length?Ae:(n=t.length,new RegExp(`^[a-zA-Z0-9_-]{${n}}$`))),zt.init(e,t)}),At=te("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Se),zt.init(e,t)}),Tt=te("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Ie),zt.init(e,t)}),Zt=te("$ZodULID",(e,t)=>{t.pattern??(t.pattern=je),zt.init(e,t)}),Nt=te("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Ee),zt.init(e,t)}),Ft=te("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Pe),zt.init(e,t)}),Rt=te("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${We({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${We({precision:e.precision})}`:n;return new RegExp(`^${Le}T(?:${r})$`)}(t)),zt.init(e,t)}),Ct=te("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ve),zt.init(e,t)}),Dt=te("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${We(t)}$`)),zt.init(e,t)}),Ut=te("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Te),zt.init(e,t)}),Jt=te("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Re),zt.init(e,t)}),Mt=/^[0-9a-fA-F:.]+$/;function Lt(e){return!!Mt.test(e)&&xt(`http://[${e}]`)}const Kt=te("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Ce),zt.init(e,t),e._zod.check=n=>{Lt(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),Vt=te("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=De),zt.init(e,t)}),Wt=te("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Ue),zt.init(e,t),e._zod.check=n=>{(function(e){const t=e.split("/");if(2!==t.length)return!1;const[n,r]=t;if(!r)return!1;const i=Number(r);return`${i}`===r&&!(i<0||i>128)&&Lt(n)})(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function Gt(e){if(""===e)return!0;if(/\s/.test(e))return!1;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const Ht=/^[0-9a-zA-Z+/]*={0,2}$/,Bt=te("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Ht),zt.init(e,t),e._zod.check=n=>{Gt(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),qt=/^[A-Za-z0-9_-]*$/,Xt=te("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=qt),zt.init(e,t),e._zod.check=n=>{(function(e){if(!qt.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return Gt(t.padEnd(4*Math.ceil(t.length/4),"="))})(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Yt=te("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Me),zt.init(e,t)}),Qt=te("$ZodJWT",(e,t)=>{zt.init(e,t),e._zod.check=n=>{(function(e,t=null){try{const n=e.split(".");if(3!==n.length)return!1;const[r]=n;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&"JWT"!==i?.typ||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}})(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),en=te("$ZodNumber",(e,t)=>{vt.init(e,t),e._zod.pattern=He,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(e){}const i=n.value;if("number"==typeof i&&!Number.isNaN(i)&&Number.isFinite(i))return n;const o="number"==typeof i?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),n}}),tn=te("$ZodNumberFormat",(e,t)=>{it.init(e,t),en.init(e,t)}),nn=te("$ZodBoolean",(e,t)=>{vt.init(e,t),e._zod.pattern=Be,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(e){}const i=n.value;return"boolean"==typeof i||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),rn=te("$ZodUnknown",(e,t)=>{vt.init(e,t),e._zod.parse=e=>e}),on=te("$ZodNever",(e,t)=>{vt.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)}),sn=e=>Array.isArray(e)?e.length:-1;function an(e,t,n){e.issues.length&&t.issues.push(...Z(n,e.issues)),t.value[n]=e.value}const cn=te("$ZodArray",(e,t)=>{vt.init(e,t);const n=ie.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{const o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=n?n.alloc(e,r,Array(o.length),i):Array(o.length);const s=[],a=i?.abortEarly;for(let e=0;e<o.length;e++){const n=o[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)s.push(c.then(t=>an(t,r,e)));else if(an(c,r,e),a&&0!==c.issues.length&&A(c))break}return s.length?Promise.all(s).then(()=>r):r},function(e,t){const n=F(e._zod.def.checks);if(!n.length)return;const r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,o)=>{const s=t(n.value);if(s>r&&!o?.skipChecks&&"backward"!==o?.direction)for(const[t,r]of F(e._zod.def.checks))if(s>t&&r._zod.def.when(n)){const t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,R(n.issues,t,e),n}return i(n,o)}}(e,sn)});function un(e,t,n,r,i,o){const s=n in r,a="optional"===o;if(s||!a||"optional"!==i){if(e.issues.length){if(void 0!==i&&a&&!s)return;t.issues.push(...Z(n,e.issues))}s||void 0!==i?void 0===e.value?(s||"defaulted"===i&&!a)&&(t.value[n]=void 0):t.value[n]=e.value:e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]})}}const dn=[];function ln(e){const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:dn,i=r.length?[...t,...r]:t;for(const t of i)if(!e.shape?.[t]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(t)}": expected a Zod schema`);const o=(s=e.shape,Object.keys(s).filter(e=>void 0!==s[e]._zod.optin&&"optional"===s[e]._zod.optout));var s;return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}function fn(e,t,n,r,i,o,s){const a=[],c=i.keySet,u=i.catchall._zod,d=u.def.type,l=u.optin,f=u.optout;let p=0;for(const i in t){if(s&&n.issues.length!==p){if(A(n,p))break;p=n.issues.length}if(c.has(i))continue;if("__proto__"===i){"never"===d&&a.push(i);continue}if("never"===d){a.push(i);continue}const o=u.run({value:t[i],issues:[]},r);o instanceof Promise?e.push(o.then(e=>un(e,n,i,t,l,f))):un(o,n,i,t,l,f)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:o,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const pn=te("$ZodObject",(e,t)=>{vt.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape"),r=n?.get?n.get.raw:t.shape??{};if(r){const e=()=>{const n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}const i=a(()=>ln(t));q(e,"propValues",e=>{const t=e.def.shape,n={};for(const e in t){const r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||u(n,e,new Set);for(const t of r.values)n[e].add(t);void 0!==r.optin&&n[e].add(void 0)}}return n});const o=v,s=t.catchall;let c;const d=ie.memoizer;d?.attach(e),e._zod.parse=(t,n)=>{c??(c=i.value);const r=t.value;if(!o(r))return t.issues.push({expected:"object",code:"invalid_type",input:r,inst:e}),t;t.value=d?d.alloc(e,t,{},n):{};const a=[],u=c.shape,l=n?.abortEarly;let f=t.issues.length;for(const e of c.allKeys){if(l&&t.issues.length!==f){if(A(t,f))break;f=t.issues.length}if("__proto__"===e)continue;const i=u[e],o=i._zod.optin,s=i._zod.optout,c=i._zod.run({value:r[e],issues:[]},n);c instanceof Promise?a.push(c.then(n=>un(n,t,e,r,o,s))):un(c,t,e,r,o,s)}return s?fn(a,r,t,n,i.value,e,!0===l):a.length?Promise.all(a).then(()=>t):t}}),hn=te("$ZodObjectJIT",(e,t)=>{pn.init(e,t);const n=e._zod.parse,r=a(()=>ln(t)),i=ie.memoizer;let o;const s=v,c=!ie.jitless,u=c&&_.value,d=t.catchall;let l;e._zod.parse=(a,f)=>{l??(l=r.value);const p=a.value;return s(p)?c&&u&&!1===f?.async&&!0!==f.jitless?(o||(o=(t=>{const n=r.value,o=n.symbolKeys,s=new gt(["payload","ctx"],{shape:t,inst:e,memo:i,syms:o}),a=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`\n let ${e}_ab = false;\n for (let i = 0; i < ${e}.issues.length; i++) {\n const iss = ${e}.issues[i];\n iss.path = iss.path ? [${t}, ...iss.path] : [${t}];\n payload.issues.push(iss);\n if (iss.continue !== true) ${e}_ab = true;\n }\n if (${e}_ab && ctx && ctx.abortEarly) {\n payload.value = newResult;\n return payload;\n }`;s.write("const input = payload.value;");const u=Object.create(null);let d=0;for(const e of n.allKeys)u[e]="key_"+d++;s.write(i?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const e of n.allKeys){if("__proto__"===e)continue;const n=u[e],r="symbol"==typeof e?`syms[${o.indexOf(e)}]`:g(e),i=`${r} in input`,d=t[e],l=d?._zod?.optin,f=void 0!==l,p="optional"===d?._zod?.optout;if(s.write(`const ${n} = ${a(r)};`),f&&p){const e="optional"===l?`${n}_present`:`${n}.value !== undefined || ${n}_present`;s.write(`\n const ${n}_present = ${i};\n if (!${n}.issues.length || ${n}_present) {\n if (${n}.issues.length) {${c(n,r)}\n }\n\n if (${e}) {\n newResult[${r}] = ${n}.value;\n }\n }\n\n `)}else f?(s.write(`\n if (${n}.issues.length) {${c(n,r)}\n }\n `),"defaulted"===l?s.write(`newResult[${r}] = ${n}.value;`):s.write(`\n if (${n}.value !== undefined || ${i}) {\n newResult[${r}] = ${n}.value;\n }\n `)):s.write(`\n const ${n}_present = ${i};\n if (${n}.issues.length) {${c(n,r)}\n }\n if (!${n}_present && !${n}.issues.length) {\n payload.issues.push({\n code: "invalid_type",\n expected: "nonoptional",\n input: undefined,\n path: [${r}]\n });\n if (ctx && ctx.abortEarly) {\n payload.value = newResult;\n return payload;\n }\n }\n\n if (${n}_present) {\n newResult[${r}] = ${n}.value;\n }\n\n `)}return s.write("payload.value = newResult;"),s.write("return payload;"),s.compile()})(t.shape)),a=o(a,f),d?fn([],p,a,f,l,e,!0===f?.abortEarly):a):n(a,f):(a.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),a)}});function mn(e,t,n,r){for(const n of e)if(0===n.issues.length)return t.value=n.value,t;const i=e.filter(e=>!A(e));return 1===i.length?(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=>C(e,r,oe())))}),t)}const gn=te("$ZodUnion",(e,t)=>{vt.init(e,t),q(e,"optin",e=>e.def.options.some(e=>"defaulted"===e._zod.optin)?"defaulted":e.def.options.some(e=>void 0!==e._zod.optin)?"optional":void 0),q(e,"optout",e=>e.def.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),q(e,"values",e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),q(e,"pattern",e=>{if(e.def.options.every(e=>e._zod.pattern)){const t=e.def.options.map(e=>e._zod.pattern);return new RegExp(`^(${t.map(e=>c(e.source)).join("|")})$`)}});const n=1===t.options.length?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let o=!1;const s=[];for(const e of t.options){const t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)s.push(t),o=!0;else{if(0===t.issues.length)return t;s.push(t)}}return o?Promise.all(s).then(t=>mn(t,r,e,i)):mn(s,r,e,i)}}),yn=te("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,gn.init(e,t);const n=e._zod.parse;q(e,"propValues",e=>{const t={};let n=0;for(const r of e.def.options){const i=r._zod.propValues;if(!i||0===Object.keys(i).length)throw new Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(const[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||u(t,e,new Set);for(const r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{const r=d(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw new Error(`Invalid discriminated union option at index "${n}"`)});const r=a(()=>function(e){const t=new Map;for(const n of e.options){const r=n._zod.propValues?.[e.discriminator];if(!r||0===r.size)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(const e of r)if(t.has(e)){if(void 0!==e)throw new Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}(t));e._zod.parse=(i,o)=>{const s=i.value;if(!v(s))return i.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),i;const a=s?.[t.discriminator],c=r.value.get(a);return!c||void 0===a&&"backward"===o.direction?t.unionFallback||"backward"===o.direction?n(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(e=>null!==r.value.get(e)),input:s,path:[t.discriminator],inst:e}),i):c._zod.run(i,o)}}),vn=te("$ZodIntersection",(e,t)=>{vt.init(e,t),e._zod.parse=(e,n)=>{const r=e.value,i=t.left._zod.run({value:r,issues:[]},n),o=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([t,n])=>bn(e,t,n)):bn(e,i,o)}});function _n(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(b(e)&&b(t)){const n=Object.keys(t),r=Object.keys(e).filter(e=>-1!==n.indexOf(e)),i={...e,...t};Object.prototype.hasOwnProperty.call(i,"__proto__")&&delete i.__proto__;for(const n of r){if("__proto__"===n)continue;const r=_n(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:[]};const n=[];for(let r=0;r<e.length;r++){const i=_n(e[r],t[r]);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function bn(e,t,n){const r=new Map;let i;const o=new Map,s=(e,t)=>{let n;if("unrecognized_keys"!==e.code||e.path?.length){if("invalid_key"!==e.code||"record"!==e.origin||1!==e.path?.length)return!1;{const t=String(e.path[0]);o.has(t)||o.set(t,e),n=[t]}}else i??(i=e),n=e.keys;for(const e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(const n of t.issues)s(n,"l")||e.issues.push(n);for(const t of n.issues)s(t,"r")||e.issues.push(t);const a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length){const t=i?a.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(const n of a)!t.includes(n)&&o.has(n)&&e.issues.push(o.get(n))}const c=_n(t.value,n.value);if(!c.valid){if(A(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}const wn=te("$ZodEnum",(e,t)=>{vt.init(e,t);const n=r(t.entries),i=new Set(n);e._zod.values=i,q(e,"pattern",e=>{const t=r(e.def.entries).filter(e=>z.has(typeof e));return new RegExp(t.length?`^(${t.map(e=>k(e.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(t,r)=>{const o=t.value;return i.has(o)||t.issues.push({code:"invalid_value",values:n,input:o,inst:e}),t}}),zn=te("$ZodLiteral",(e,t)=>{vt.init(e,t);const n=new Set(t.values);e._zod.values=n,q(e,"pattern",e=>{const t=e.def.values;return new RegExp(t.length?`^(${t.map(e=>"string"==typeof e?k(e):e?k(e.toString()):String(e)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,i)=>{const o=r.value;return n.has(o)||r.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),r}}),kn=te("$ZodTransform",(e,t)=>{vt.init(e,t),e._zod.optin="optional",ie.memoizer?.guard(e),e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new re(e.constructor.name);const 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 ne;return n.value=i,n}});function $n(e,t){return e.value=t.issues.length?void 0:t.value,e}const On=te("$ZodOptional",(e,t)=>{vt.init(e,t),q(e,"optin",e=>"defaulted"===e.def.innerType._zod.optin?"defaulted":"optional"),e._zod.optout="optional",q(e,"values",e=>{const t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),q(e,"pattern",e=>{const t=e.def.innerType._zod.pattern;return t?new RegExp(`^(${c(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(void 0===e.value){if("defaulted"!==t.innerType._zod.optin)return e;const r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>$n(e,t)):$n(e,r)}return t.innerType._zod.run(e,n)}}),xn=te("$ZodExactOptional",(e,t)=>{On.init(e,t),q(e,"values",e=>e.def.innerType._zod.values),q(e,"pattern",e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Sn=te("$ZodNullable",(e,t)=>{vt.init(e,t),q(e,"optin",e=>e.def.innerType._zod.optin),q(e,"optout",e=>e.def.innerType._zod.optout),q(e,"pattern",e=>{const t=e.def.innerType._zod.pattern;return t?new RegExp(`^(${c(t.source)}|null)$`):void 0}),q(e,"values",e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>null===e.value?e:t.innerType._zod.run(e,n)}),In=te("$ZodDefault",(e,t)=>{vt.init(e,t),e._zod.optin="defaulted",q(e,"values",e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);if(void 0===e.value)return e.value=t.defaultValue,e;const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>jn(e,t)):jn(r,t)}});function jn(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const En=te("$ZodPrefault",(e,t)=>{vt.init(e,t),e._zod.optin="defaulted",q(e,"values",e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>("backward"===n.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Pn=te("$ZodNonOptional",(e,t)=>{vt.init(e,t),q(e,"values",e=>{const t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>void 0!==e)):void 0}),e._zod.parse=(n,r)=>{const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>An(t,e)):An(i,e)}});function An(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function Tn(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>C(e,r,oe()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const Zn=te("$ZodCatch",(e,t)=>{vt.init(e,t),q(e,"optin",e=>"defaulted"===e.def.innerType._zod.optin?"defaulted":"optional"),q(e,"optout",e=>e.def.innerType._zod.optout),q(e,"values",e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>Tn(e,r,t,n)):Tn(e,r,t,n)}}),Nn=te("$ZodPipe",(e,t)=>{vt.init(e,t),q(e,"values",e=>e.def.in._zod.values),q(e,"optin",e=>e.def.in._zod.optin),q(e,"optout",e=>e.def.out._zod.optout),q(e,"propValues",e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if("backward"===n.direction){const r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Fn(e,t.in,n)):Fn(r,t.in,n)}const r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Fn(e,t.out,n)):Fn(r,t.out,n)}});function Fn(e,t,n){return e.issues.some(e=>"unrecognized_keys"!==e.code)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Rn=te("$ZodReadonly",(e,t)=>{vt.init(e,t),q(e,"propValues",e=>e.def.innerType._zod.propValues),q(e,"values",e=>e.def.innerType._zod.values),q(e,"optin",e=>e.def.innerType?._zod?.optin),q(e,"optout",e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Cn):Cn(r)}});function Cn(e){return e.memo||(e.value=Object.freeze(e.value)),e}const Dn=te("$ZodCustom",(e,t)=>{Ye.init(e,t),vt.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Un(t,n,r,e));Un(i,n,r,e)}});function Un(e,t,n,r){if(!e){const 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(M(e))}}class Jn extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const Mn="~memo",Ln=[];function Kn(e){return null!==e&&"object"==typeof e}function Vn(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}const Wn=new WeakMap;function Gn(e,t,n){const r=Wn.get(e);if(void 0!==r)return r?2:0;if(t.has(e))return 2;t.add(e);let i=0;const o=e=>{if(2!==i&&e?._zod){const n=Gn(e,t);n>i&&(i=n)}},s=e=>{e>i&&(i=e)},a=e._zod.def;switch(a.type){case"object":{const e=d(a);s(e?(e=>{let n=0;for(const r of Reflect.ownKeys(e)){const i=Object.getOwnPropertyDescriptor(e,r);if(!i.enumerable)continue;const o=i.get?1:i.value?._zod?Gn(i.value,t):0;o>n&&(n=o)}return n})(e):1),o(a.catchall);break}case"array":o(a.element);break;case"tuple":for(const e of a.items)o(e);o(a.rest);break;case"record":case"map":o(a.keyType),o(a.valueType);break;case"set":o(a.valueType);break;case"union":for(const e of a.options)o(e);break;case"intersection":o(a.left),o(a.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":o(a.innerType);break;case"pipe":o(a.in),o(a.out);break;case"function":o(a.input),o(a.output);break;case"lazy":{const e=a._cachedInner??void 0;s(e?Gn(e,t):1);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(const e in a){const t=Object.getOwnPropertyDescriptor(a,e);if(!t||t.get)continue;const n=t.value;if(n&&"object"==typeof n)if(n._zod)o(n);else if(Array.isArray(n))for(const e of n)o(e)}}return t.delete(e),function(e,t){return 1!==t&&Wn.set(e,2===t),t}(e,i)}let Hn;const Bn=[],qn={alloc(e,t,n){const r=Hn;if(!r)return n;Hn=void 0;const i={value:n,issues:null};return r.set(t.value,i),Bn.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const t=e._zod.parse,n=(e,n)=>{if("backward"!==n.direction&&function(e,t){const n=e[Mn]?.backEdges;return void 0!==n&&Kn(t)&&n.has(t)}(n,e.value))throw new Jn;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r,i,o=!1;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const t=e._zod.parse,s=(a,c)=>{if(void 0===n){const r=Gn(e,new Set);if(0===r)return e._zod.parse=t,e._zod.run===s&&(e._zod.run=t),t(a,c);2===r||o?n=!0:o=!0}const u=a.value;if(!Kn(u))return t(a,c);let d,l=c[Mn];l||(l={buckets:new WeakMap,backEdges:void 0},c[Mn]=l),r===c?d=i:(d=function(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}(l,e),r=c,i=d);const f=d.get(u);if(f)return a.value=f.value,f.issues?f.issues.length&&a.issues.push(...Vn(f.issues)):(a.memo=!0,l.backEdges??(l.backEdges=new WeakSet),l.backEdges.add(f.value)),a;Hn=d;const p=Bn.length,h=t(a,c);Hn=void 0;const m=Bn.length>p?Bn.pop():void 0;return h instanceof Promise?h.then(e=>(m&&(m.issues=e.issues.length?Vn(e.issues):Ln),e)):(m&&(m.issues=h.issues.length?Vn(h.issues):Ln),h)};e._zod.parse=s,e._zod.run===t&&(e._zod.run=s)})}},Xn=()=>{const e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(t){return e[t]??null}const n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function o(e,t){return"number"!==e||"number"!=typeof t||Number.isFinite(t)?r[e]??e:String(t)}return e=>{switch(e.code){case"invalid_type":return`Invalid input: expected ${o(e.expected)}, received ${o(function(e){const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(null===e)return"null";if(Array.isArray(e))return"array";const t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&"constructor"in t&&t.constructor)return t.constructor.name}}return t}(e.input),e.input)}`;case"invalid_value":return 1===e.values.length?`Invalid input: expected ${x(e.values[0])}`:`Invalid option: expected one of ${i(e.values,"|")}`;case"too_big":{const n=e.exact?"exactly ":e.inclusive?"<=":"<",r=t(e.origin);return r?`Too big: expected ${e.origin??"value"} to have ${n}${e.maximum.toString()} ${r.unit??"elements"}`:`Too big: expected ${e.origin??"value"} to be ${n}${e.maximum.toString()}`}case"too_small":{const n=e.exact?"exactly ":e.inclusive?">=":">",r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case"invalid_format":{const t=e;return"starts_with"===t.format?`Invalid string: must start with "${t.prefix}"`:"ends_with"===t.format?`Invalid string: must end with "${t.suffix}"`:"includes"===t.format?`Invalid string: must include "${t.includes}"`:"regex"===t.format?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${e.divisor}`;case"unrecognized_keys":return`Unrecognized key${e.keys.length>1?"s":""}: ${i(e.keys,", ")}`;case"invalid_key":return`Invalid key in ${e.origin}`;case"invalid_union":return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(" | ")}`:!1===e.inclusive?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${e.origin}`;default:return"Invalid input"}}};var Yn;(Yn=globalThis).__zod_globalRegistry??(Yn.__zod_globalRegistry=new class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];return this._map.set(e,n),n&&"object"==typeof n&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const 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)}});const Qn=globalThis.__zod_globalRegistry;function er(e){return e.checks&&(e.checks=[...e.checks]),e}function tr(e,t){return new tt({check:"less_than",...O(t),value:e,inclusive:!1})}function nr(e,t){return new tt({check:"less_than",...O(t),value:e,inclusive:!0})}function rr(e,t){return new nt({check:"greater_than",...O(t),value:e,inclusive:!1})}function ir(e,t){return new nt({check:"greater_than",...O(t),value:e,inclusive:!0})}function or(e,t){return new rt({check:"multiple_of",...O(t),value:e})}function sr(e,t){return new ot({check:"max_length",...O(t),maximum:e})}function ar(e,t){return new st({check:"min_length",...O(t),minimum:e})}function cr(e,t){return new at({check:"length_equals",...O(t),length:e})}function ur(e){return new mt({check:"overwrite",tx:e})}function dr(e,...t){for(const n of t)for(const t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&u(e,t,n[t]);return e}function lr(e){let t=e?.target??"draft-2020-12";return"draft-4"===t&&(t="draft-04"),"draft-7"===t&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Qn,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function fr(e,t,n,r,i){const o="function"==typeof t.unrepresentable?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if("any"===o)return!1;if(void 0===o||"throw"===o)throw new Error(i);return Object.assign(n,o),!0}function pr(e,t,n={path:[],schemaPath:[]}){var r;const i=e._zod.def,o=t.seen.get(e);if(o)return o.count++,n.schemaPath.includes(e)&&(o.cycle=n.path),o.schema;const s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,r);else{const n=s.schema,o=t.processors[i.type];if(!o)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);o(e,t,n,r)}const o=e._zod.parent;o&&(s.ref||(s.ref=o),pr(o,t,r),t.seen.get(o).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&dr(s.schema,c),"input"===t.io&&kr(e)&&(delete s.schema.examples,delete s.schema.default),"input"===t.io&&"_prefault"in s.schema&&((r=s.schema).default??(r.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function hr(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function mr(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;const r=new Map;for(const t of e.seen.entries()){const n=e.metadataRegistry.get(t[0])?.id;if(n){const e=r.get(n);if(e&&e!==t[0])throw new 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])}}const i=t=>{if(t[1].schema.$ref)return;const r=t[1],{ref:i,defId:o}=(t=>{const r="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){const n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};const o=t[1].defId??t[1].schema.id??"schema"+e.counter++;return t[1].defId=o,{defId:o,ref:`${i("__shared")}#/${r}/${hr(o)}`}}const i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:"#"};const o=t[1].schema.id??"__schema"+e.counter++;return{defId:o,ref:i+hr(o)}})(t);r.def={...r.schema},o&&(r.defId=o);const s=r.schema;for(const e in s)delete s[e];s.$ref=i};if("throw"===e.cycles)for(const t of e.seen.entries()){const e=t[1];if(e.cycle)throw new Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>\n\nSet the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const n of e.seen.entries()){const r=n[1];if(t===n[0]){i(n);continue}if(e.external){const r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){i(n);continue}}const o=e.metadataRegistry.get(n[0])?.id;(o||r.cycle||r.count>1&&"ref"===e.reused)&&i(n)}e.external&&(e.sharedDefsExtractedFor=e.external)}function gr(e){const t=e.anyOf;if(!Array.isArray(t)||0===t.length||void 0!==e.type)return;const n=[];for(const e of t){if(!e||"object"!=typeof e)return;gr(e);const t=Object.keys(e);if(1!==t.length||"type"!==t[0])return;const r=e.type;for(const e of Array.isArray(r)?r:[r]){if("string"!=typeof e)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=1===n.length?n[0]:n}const yr=new Set(["type","properties","required","additionalProperties"]),vr=["oneOf","anyOf"];function _r(e){const t=e.additionalProperties;return void 0===t||!1===t||"object"!=typeof t||null===t?null:Object.keys(t).length?t:null}function br(e){const t=[];for(const n of e){if("object"!=typeof n||"object"!==n.type)return null;for(const e in n)if(!yr.has(e))return null;t.push(n)}const n={},r=new Set;for(const e of t){for(const r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;const e=[];for(const n of t){const t=n.properties?.[r]??_r(n);null!=t&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}u(n,r,1===e.length?e[0]:br(e)??{allOf:e})}for(const t of e.required??[])r.add(t)}const i={type:"object",properties:n};if(r.size&&(i.required=[...r]),t.every(e=>!1===e.additionalProperties))i.additionalProperties=!1;else{const e=[];for(const n of t){const t=_r(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}1===e.length?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function wr(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const t of yr)if(t in e)return;const n=t.filter(e=>vr.some(t=>Array.isArray(e[t])));let r=null;if(n.length){const e=n[0],i=vr.find(t=>Array.isArray(e[t]));if(1!==Object.keys(e).length)return;const o=t.filter(t=>t!==e),s=e[i].map(e=>br([...o,e]));if(s.some(e=>!e))return;r={[i]:s}}else r=br(t);r&&(delete e.allOf,dr(e,r))}function zr(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=t=>{const n=e.seen.get(t);if(null===n.ref)return;const i=n.def??n.schema,o={...i},s=n.ref;if(n.ref=null,s){r(s);const n=e.seen.get(s),a=n.schema;if(!a.$ref||"draft-07"!==e.target&&"draft-04"!==e.target&&"openapi-3.0"!==e.target?dr(i,a):(i.allOf=i.allOf??[],i.allOf.push(a)),dr(i,o),t._zod.parent===s)for(const e in i)"$ref"!==e&&"allOf"!==e&&(e in o||delete i[e]);if(a.$ref&&n.def)for(const e in i)"$ref"!==e&&"allOf"!==e&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}const a=t._zod.parent;if(a&&a!==s){r(a);const t=e.seen.get(a);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(const e in i)"$ref"!==e&&"allOf"!==e&&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??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(const t of[...e.seen.entries()].reverse())r(t[0]);if("openapi-3.0"!==e.target)for(const t of e.seen.entries())gr(t[1].def??t[1].schema);for(const t of e.deferred)t();if(e.intersections.length){const t=new Map;for(const n of e.seen.values())for(const e of[n.schema,n.def]){const n=e?.allOf;if(!Array.isArray(n))continue;const r=t.get(n);r?r.push(e):t.set(n,[e])}for(const n of e.intersections)for(const e of t.get(n)??[])wr(e)}}const i={};if("draft-2020-12"===e.target?i.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?i.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?i.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const n=e.external.registry.get(t)?.id;if(!n)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}dr(i,n.defId?n.schema:n.def??n.schema);const o=e.metadataRegistry.get(t)?.id;void 0!==o&&i.id===o&&delete i.id;const s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const t of e.seen.entries()){const e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,u(s,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(s).length>0&&("draft-2020-12"===e.target?i.$defs=s:i.definitions=s);try{const n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t["~standard"],jsonSchema:{input:$r(t,"input",e.processors),output:$r(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(e){throw new Error("Error converting schema to JSON.")}}function kr(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if("transform"===r.type)return!0;if("array"===r.type)return kr(r.element,n);if("set"===r.type)return kr(r.valueType,n);if("lazy"===r.type)return kr(r.getter(),n);if("promise"===r.type||"optional"===r.type||"nonoptional"===r.type||"nullable"===r.type||"readonly"===r.type||"default"===r.type||"prefault"===r.type||"catch"===r.type)return kr(r.innerType,n);if("intersection"===r.type)return kr(r.left,n)||kr(r.right,n);if("record"===r.type||"map"===r.type)return kr(r.keyType,n)||kr(r.valueType,n);if("pipe"===r.type)return!!e._zod.traits.has("$ZodCodec")||kr(r.in,n)||kr(r.out,n);if("object"===r.type){for(const e in r.shape)if(kr(r.shape[e],n))return!0;return!1}if("union"===r.type){for(const e of r.options)if(kr(e,n))return!0;return!1}if("tuple"===r.type){for(const e of r.items)if(kr(e,n))return!0;return!(!r.rest||!kr(r.rest,n))}return!1}const $r=(e,t,n={})=>r=>{const{libraryOptions:i,target:o}=r??{},s=lr({...i??{},target:o,io:t,processors:n});return pr(e,s),mr(s,e),zr(s,e)},Or=(e,t,n)=>{(void 0===e[t]||n>e[t])&&(e[t]=n)},xr=(e,t,n)=>{(void 0===e[t]||n<e[t])&&(e[t]=n)},Sr=(e,t)=>{Or(e,"minimum",t),xr(e,"maximum",t)},Ir=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},jr=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Er=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Pr=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},Ar=(e,t)=>Or(e,"minimum",t.minimum),Tr=(e,t)=>xr(e,"maximum",t.maximum),Zr=e=>(t,n)=>{Pr(t,n.format);const[r,i]=e[n.format];Or(t,"minimum",r),xr(t,"maximum",i)},Nr={greater_than:(e,t)=>Or(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>xr(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Ir(e,t.value),number_format:Zr(S),bigint_format:Zr(I),min_length:Ar,max_length:Tr,length_equals:(e,t)=>Sr(e,t.length),min_size:Ar,max_size:Tr,size_equals:(e,t)=>Sr(e,t.size),string_format:(e,t)=>{Pr(e,t.format),t.pattern&&jr(e,t.pattern),"base64"!==t.format&&"base64url"!==t.format||(e.contentEncoding=t.format),(t.local||-1===t.precision)&&(e.laxFormat=!0)},mime_type:(e,t)=>Er(e,t.mime)};function Fr(e){const t={},n=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(const e of r)Nr[e._zod.def.check]?.(t,e._zod.def);const i=e._zod.bag;void 0!==i.minimum&&Or(t,"minimum",i.minimum),void 0!==i.exclusiveMinimum&&Or(t,"exclusiveMinimum",i.exclusiveMinimum),void 0!==i.maximum&&xr(t,"maximum",i.maximum),void 0!==i.exclusiveMaximum&&xr(t,"exclusiveMaximum",i.exclusiveMaximum),void 0!==i.multipleOf&&Ir(t,i.multipleOf),void 0!==i.format&&(t.format??(t.format=i.format),i.format.includes("int")&&(t.isInt=!0)),i.mime&&Er(t,i.mime);for(const e of i.patterns??[])jr(t,e);return t}const Rr={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Cr=new Map([[Ht,/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/],[qt,/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/]]),Dr=e=>Cr.get(e)??e;function Ur(e){const t=e._zod.def;return"pipe"===t.type&&t.in._zod.traits.has("$ZodTransform")?Ur(t.out):"catch"===t.type?Ur(t.innerType):e._zod.optin}const Jr=Symbol();function Mr(e,t,n,r,i){let o=!1;const s=JSON.stringify(e,(e,t)=>"bigint"!=typeof t?t:(o=!0,null));return o?(fr(t,n,r,i,"BigInt defaults cannot be represented in JSON Schema"),Jr):JSON.parse(s)}const Lr=(e,t,n,r)=>{const i=e._zod.def;pr(i.innerType,t,r),t.seen.get(e).ref=i.innerType},Kr=new WeakSet([Object.prototype,Error.prototype]);function Vr(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){const e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}const Wr=(e,t)=>{ue.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);Kr.has(n)||(Kr.add(n),Vr(n,"format",e=>t=>function(e,t=e=>e.message){const n={_errors:[]},r=(e,i=[])=>{for(const o of e.issues)if("invalid_union"===o.code&&o.errors.length)o.errors.map(e=>r({issues:e},[...i,...o.path]));else if("invalid_key"===o.code)r({issues:o.issues},[...i,...o.path]);else if("invalid_element"===o.code)r({issues:o.issues},[...i,...o.path]);else{const e=[...i,...o.path];if(0===e.length)n._errors.push(t(o));else{let r=n,i=0;for(;i<e.length;){const n=e[i],s=i===e.length-1;if("_errors"===n){s&&r._errors.push(t(o)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const a=r[n];s&&a._errors.push(t(o)),r=a,i++}}}};return r(e),n}(e,t)),Vr(n,"flatten",e=>t=>function(e,t=e=>e.message){const n={},r=[];for(const i of e.issues)i.path.length>0?de(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}(e,t)),Vr(n,"addIssue",e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,o,2)}),Vr(n,"addIssues",e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,o,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return 0===this.issues.length}}))},Gr=te("ZodError",Wr,void 0,{Parent:Error}),Hr=fe(Gr),Br=pe(Gr),qr=he(Gr),Xr=ge(Gr),Yr=_e(Gr),Qr=be(Gr),ei=we(Gr),ti=ze(Gr),ni=ke(Gr),ri=$e(Gr),ii=Oe(Gr),oi=xe(Gr);function si(){ie.memoizer||oe({memoizer:qn})}const ai=te("ZodType",(e,t)=>(ie.localeError||oe({localeError:Xn()}),vt.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(m(t,{checks:[...t.checks??[],...e.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return $(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(function(e,t={}){return function(e,t,n){return new go({type:"custom",check:"custom",fn:t,...O(n)})}(0,e,t)}(e,t))},superRefine(e,t){return this.check(function(e,t){return function(e,t){const n=function(e,t){const n=new Ye({check:"custom",...O(t)});return n._zod.check=e,n}(t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(M(e,t.value,n._zod.def));else{const r=e;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),"input"in r||(r.input=t.value),r.inst??(r.inst=n),r.continue??(r.continue=!n._zod.def.abort),t.issues.push(M(r))}},e(t.value,t)),t);return n}(e,t)}(e,t))},overwrite(e){return this.check(ur(e))},optional(){return io(this)},exactOptional(){return new oo({type:"optional",innerType:this})},nullable(){return ao(this)},nullish(){return io(ao(this))},nonoptional(e){return function(e,t){return new lo({type:"nonoptional",innerType:e,...O(t)})}(this,e)},array(){return Vi(this)},or(e){return new Hi({type:"union",options:[this,e],...O(void 0)})},and(e){return new Xi({type:"intersection",left:this,right:e})},transform(e){return ho(this,new no({type:"transform",transform:e}))},default(e){return t=e,new co({type:"default",innerType:this,get defaultValue(){return"function"==typeof t?t():w(t)}});var t},prefault(e){return t=e,new uo({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof t?t():w(t)}});var t},catch(e){return new fo({type:"catch",innerType:this,catchValue:"function"==typeof(t=e)?t:X(t)});var t},pipe(e){return ho(this,e)},readonly(){return new mo({type:"readonly",innerType:this})},describe(e){const t=this.clone();return Qn.add(t,{description:e}),t},meta(...e){if(0===e.length)return Qn.get(this);const t=this.clone();return Qn.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return 0===t.length?e(this):e(this,...t)},get"~standard"(){return K(this,"~standard",{...bt(this),jsonSchema:{input:$r(this,"input"),output:$r(this,"output")}})},set"~standard"(e){L(this,"~standard",e)},parse:function e(t,n){return Hr(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Br(this,t,n,{callee:e})},safeParse(e,t){return qr(this,e,t)},async safeParseAsync(e,t){return Xr(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){L(this,"spa",e)},validate(e,t){return((e,t,n)=>{const r=e._zod.bag.validator;if(void 0!==r){if(r(t)!==ye)return!0;if(!0===r.definite&&void 0===n)return!1}return function(e,t,n){const r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun;let o;if(i?(r[ve]=!0,o=i({value:t,issues:[]},r)):o=e._zod.run({value:t,issues:[]},r),o instanceof Promise)throw new ne;return 0===o.issues.length}(e,t,n)})(this,e,t)},validateAsync(e,t){return(async(e,t,n)=>{const r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0};let i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),0===i.issues.length})(this,e,t)},encode:function e(t,n){return Yr(this,t,n,{callee:e})},decode:function e(t,n){return Qr(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await ei(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await ti(this,t,n,{callee:e})},safeEncode(e,t){return ni(this,e,t)},safeDecode(e,t){return ri(this,e,t)},async safeEncodeAsync(e,t){return ii(this,e,t)},async safeDecodeAsync(e,t){return oi(this,e,t)},toJSONSchema(e){return((e,t={})=>n=>{const r=lr({...n,processors:t});return pr(e,r),mr(r,e),zr(r,e)})(this,{})(e)},get description(){return Qn.get(this)?.description},get _def(){return this._zod.def}}),ci=te("_ZodString",(e,t)=>{wt.init(e,t),ai.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=n;r.type="string";const{minimum:i,maximum:o,format:s,patterns:a,contentEncoding:c,laxFormat:u}=Fr(e);if("number"==typeof i&&(r.minLength=i),"number"==typeof o&&(r.maxLength=o),s&&(r.format=Rr[s]??s,""===r.format&&delete r.format,("time"===s||u)&&delete r.format),c&&(r.contentEncoding=c),a&&a.size>0){const e=[...a].map(Dr);1===e.length?r.pattern=e[0].source:e.length>1&&(r.allOf=[...e.map(e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source}))])}})(e,t,n)},V({format:e=>Fr(e).format??null,minLength:e=>Fr(e).minimum??null,maxLength:e=>Fr(e).maximum??null},{regex(...e){return this.check(function(e,t){return new ut({check:"string_format",format:"regex",...O(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new ft({check:"string_format",format:"includes",...O(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new pt({check:"string_format",format:"starts_with",...O(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new ht({check:"string_format",format:"ends_with",...O(t),suffix:e})}(...e))},min(...e){return this.check(ar(...e))},max(...e){return this.check(sr(...e))},length(...e){return this.check(cr(...e))},nonempty(...e){return this.check(ar(1,...e))},lowercase(e){return this.check(function(e){return new dt({check:"string_format",format:"lowercase",...O(e)})}(e))},uppercase(e){return this.check(function(e){return new lt({check:"string_format",format:"uppercase",...O(e)})}(e))},trim(){return this.check(ur(e=>e.trim()))},normalize(...e){return this.check(function(e){return ur(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(ur(e=>e.toLowerCase()))},toUpperCase(){return this.check(ur(e=>e.toUpperCase()))},slugify(){return this.check(ur(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}})),ui=te("ZodString",(e,t)=>{wt.init(e,t),ci.init(e,t)},{email(e){return this.check(function(e,t){return new gi({type:"string",format:"email",check:"string_format",abort:!1,...O(t)})}(0,e))},url(e){return this.check(function(e,t){return new _i({type:"string",format:"url",check:"string_format",abort:!1,...O(t)})}(0,e))},jwt(e){return this.check(function(e,t){return new Zi({type:"string",format:"jwt",check:"string_format",abort:!1,...O(t)})}(0,e))},emoji(e){return this.check(function(e,t){return new bi({type:"string",format:"emoji",check:"string_format",abort:!1,...O(t)})}(0,e))},guid(e){return this.check(function(e,t){return new yi({type:"string",format:"guid",check:"string_format",abort:!1,...O(t)})}(0,e))},uuid(e){return this.check(function(e,t){return new vi({type:"string",format:"uuid",check:"string_format",abort:!1,...O(t)})}(0,e))},uuidv4(e){return this.check(function(e,t){return new vi({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...O(t)})}(0,e))},uuidv6(e){return this.check(function(e,t){return new vi({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...O(t)})}(0,e))},uuidv7(e){return this.check(function(e,t){return new vi({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...O(t)})}(0,e))},nanoid(e){return this.check(function(e,t){return new wi({type:"string",format:"nanoid",check:"string_format",abort:!1,...O(t)})}(0,e))},cuid(e){return this.check(function(e,t){return new zi({type:"string",format:"cuid",check:"string_format",abort:!1,...O(t)})}(0,e))},cuid2(e){return this.check(function(e,t){return new ki({type:"string",format:"cuid2",check:"string_format",abort:!1,...O(t)})}(0,e))},ulid(e){return this.check(function(e,t){return new $i({type:"string",format:"ulid",check:"string_format",abort:!1,...O(t)})}(0,e))},base64(e){return this.check(function(e,t){return new Pi({type:"string",format:"base64",check:"string_format",abort:!1,...O(t)})}(0,e))},base64url(e){return this.check(function(e,t){return new Ai({type:"string",format:"base64url",check:"string_format",abort:!1,...O(t)})}(0,e))},xid(e){return this.check(function(e,t){return new Oi({type:"string",format:"xid",check:"string_format",abort:!1,...O(t)})}(0,e))},ksuid(e){return this.check(function(e,t){return new xi({type:"string",format:"ksuid",check:"string_format",abort:!1,...O(t)})}(0,e))},ipv4(e){return this.check(function(e,t){return new Si({type:"string",format:"ipv4",check:"string_format",abort:!1,...O(t)})}(0,e))},ipv6(e){return this.check(function(e,t){return new Ii({type:"string",format:"ipv6",check:"string_format",abort:!1,...O(t)})}(0,e))},cidrv4(e){return this.check(function(e,t){return new ji({type:"string",format:"cidrv4",check:"string_format",abort:!1,...O(t)})}(0,e))},cidrv6(e){return this.check(function(e,t){return new Ei({type:"string",format:"cidrv6",check:"string_format",abort:!1,...O(t)})}(0,e))},e164(e){return this.check(function(e,t){return new Ti({type:"string",format:"e164",check:"string_format",abort:!1,...O(t)})}(0,e))},datetime(e){return this.check(function(e,t){return new fi({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O(t)})}(0,e))},date(e){return this.check(function(e,t){return new pi({type:"string",format:"date",check:"string_format",...O(t)})}(0,e))},time(e){return this.check(function(e,t){return new hi({type:"string",format:"time",check:"string_format",precision:null,...O(t)})}(0,e))},duration(e){return this.check(function(e,t){return new mi({type:"string",format:"duration",check:"string_format",...O(t)})}(0,e))}});function di(e){return function(e,t){return new ui(er({type:"string",...O(t)}))}(0,e)}const li=te("ZodStringFormat",(e,t)=>{zt.init(e,t),ci.init(e,t)}),fi=te("ZodISODateTime",(e,t)=>{Rt.init(e,t),li.init(e,t)}),pi=te("ZodISODate",(e,t)=>{Ct.init(e,t),li.init(e,t)}),hi=te("ZodISOTime",(e,t)=>{Dt.init(e,t),li.init(e,t)}),mi=te("ZodISODuration",(e,t)=>{Ut.init(e,t),li.init(e,t)}),gi=te("ZodEmail",(e,t)=>{Ot.init(e,t),li.init(e,t)}),yi=te("ZodGUID",(e,t)=>{kt.init(e,t),li.init(e,t)}),vi=te("ZodUUID",(e,t)=>{$t.init(e,t),li.init(e,t)}),_i=te("ZodURL",(e,t)=>{jt.init(e,t),li.init(e,t)}),bi=te("ZodEmoji",(e,t)=>{Et.init(e,t),li.init(e,t)}),wi=te("ZodNanoID",(e,t)=>{Pt.init(e,t),li.init(e,t)}),zi=te("ZodCUID",(e,t)=>{At.init(e,t),li.init(e,t)}),ki=te("ZodCUID2",(e,t)=>{Tt.init(e,t),li.init(e,t)}),$i=te("ZodULID",(e,t)=>{Zt.init(e,t),li.init(e,t)}),Oi=te("ZodXID",(e,t)=>{Nt.init(e,t),li.init(e,t)}),xi=te("ZodKSUID",(e,t)=>{Ft.init(e,t),li.init(e,t)}),Si=te("ZodIPv4",(e,t)=>{Jt.init(e,t),li.init(e,t)}),Ii=te("ZodIPv6",(e,t)=>{Kt.init(e,t),li.init(e,t)}),ji=te("ZodCIDRv4",(e,t)=>{Vt.init(e,t),li.init(e,t)}),Ei=te("ZodCIDRv6",(e,t)=>{Wt.init(e,t),li.init(e,t)}),Pi=te("ZodBase64",(e,t)=>{Bt.init(e,t),li.init(e,t)}),Ai=te("ZodBase64URL",(e,t)=>{Xt.init(e,t),li.init(e,t)}),Ti=te("ZodE164",(e,t)=>{Yt.init(e,t),li.init(e,t)}),Zi=te("ZodJWT",(e,t)=>{Qt.init(e,t),li.init(e,t)}),Ni=te("ZodNumber",(e,t)=>{en.init(e,t),ai.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=n,{minimum:o,maximum:s,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:d}=Fr(e);i.type=d?"integer":"number";const l="number"==typeof u&&u>=(o??Number.NEGATIVE_INFINITY),f="number"==typeof c&&c<=(s??Number.POSITIVE_INFINITY),p="draft-04"===t.target||"openapi-3.0"===t.target;if(l?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:"number"==typeof o&&(i.minimum=o),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:"number"==typeof s&&(i.maximum=s),a){const n=new Set;for(const o of a)Number.isFinite(o)&&0!==o?n.add(Math.abs(o)):fr(e,t,i,r,`A multipleOf divisor of ${o} cannot be represented in JSON Schema`);const[o,...s]=n;void 0!==o&&(i.multipleOf=o),s.length&&(i.allOf=[...i.allOf??[],...s.map(e=>({multipleOf:e}))])}})(e,t,n,r),e.isFinite=!0},V({minValue:e=>{const{minimum:t,exclusiveMinimum:n}=Fr(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:e=>{const{maximum:t,exclusiveMaximum:n}=Fr(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:e=>{const{isInt:t,multipleOf:n}=Fr(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>Fr(e).format??null},{gt(e,t){return this.check(rr(e,t))},gte(e,t){return this.check(ir(e,t))},min(e,t){return this.check(ir(e,t))},lt(e,t){return this.check(tr(e,t))},lte(e,t){return this.check(nr(e,t))},max(e,t){return this.check(nr(e,t))},int(e){return this.check(Ci(e))},safe(e){return this.check(Ci(e))},positive(e){return this.check(rr(0,e))},nonnegative(e){return this.check(ir(0,e))},negative(e){return this.check(tr(0,e))},nonpositive(e){return this.check(nr(0,e))},multipleOf(e,t){return this.check(or(e,t))},step(e,t){return this.check(or(e,t))},finite(){return this}}));function Fi(e){return function(e,t){return new Ni(er({type:"number",checks:[],...O(t)}))}(0,e)}const Ri=te("ZodNumberFormat",(e,t)=>{tn.init(e,t),Ni.init(e,t)});function Ci(e){return function(e,t){return new Ri({type:"number",check:"number_format",abort:!1,format:"safeint",...O(t)})}(0,e)}const Di=te("ZodBoolean",(e,t)=>{nn.init(e,t),ai.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.type="boolean"})(0,0,t)});function Ui(e){return function(e,t){return new Di({type:"boolean",...O(t)})}(0,e)}const Ji=te("ZodUnknown",(e,t)=>{rn.init(e,t),ai.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function Mi(){return new Ji({type:"unknown"})}const Li=te("ZodNever",(e,t)=>{on.init(e,t),ai.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.not={}})(0,0,t)});const Ki=te("ZodArray",(e,t)=>{si(),cn.init(e,t),ai.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=n,o=e._zod.def,{minimum:s,maximum:a}=Fr(e);"number"==typeof s&&(i.minItems=s),"number"==typeof a&&(i.maxItems=a),i.type="array",i.items=pr(o.element,t,{...r,path:[...r.path,"items"]})})(e,t,n,r),e.element=t.element},{min(e,t){return this.check(ar(e,t))},nonempty(e){return this.check(ar(1,e))},max(e,t){return this.check(sr(e,t))},length(e,t){return this.check(cr(e,t))},unwrap(){return this.element}});function Vi(e,t){return function(e,t,n){return new Ki({type:"array",element:t,...O(n)})}(0,e,t)}const Wi=te("ZodObject",(e,t)=>{si(),hn.init(e,t),ai.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=n,o=e._zod.def,s=o.shape;if(Object.getOwnPropertySymbols(s).length&&fr(e,t,i,r,"Symbol keys cannot be represented in JSON Schema"))return;i.type="object",i.properties={};for(const e in s)u(i.properties,e,pr(s[e],t,{...r,path:[...r.path,"properties",e]}));const a=[];for(const e of Object.keys(s)){const n=o.shape[e];("input"===t.io?void 0===Ur(n):void 0===n._zod.optout)&&a.push(e)}a.length>0&&(i.required=a),"never"===o.catchall?._zod.def.type?i.additionalProperties=!1:o.catchall?o.catchall&&(i.additionalProperties=pr(o.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):"output"===t.io&&(i.additionalProperties=!1)})(e,t,n,r),function(e,t,n,r){const i=function(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){const e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}(e,"shape",e=>e._zod.def.shape,!1)},{keyof(){return Qi(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(m(this._zod.def,{catchall:e}))},passthrough(){return this.clone(m(this._zod.def,{catchall:Mi()}))},loose(){return this.clone(m(this._zod.def,{catchall:Mi()}))},strict(){return this.clone(m(this._zod.def,{catchall:function(e,t){return new Li({type:"never",...O(t)})}(0,e)}));var e},strip(){return this.clone(m(this._zod.def,{catchall:void 0}))},extend(e){return function(e,t){if(!b(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const n=l(e);for(const e of Reflect.ownKeys(t))if(void 0!==Object.getOwnPropertyDescriptor(n,e))throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return $(e,m(e._zod.def,{shape:E(e,t)}))}(this,e)},safeExtend(e){return function(e,t){if(!b(t))throw new Error("Invalid input to safeExtend: expected a plain object");return $(e,m(e._zod.def,{shape:E(e,t)}))}(this,e)},merge(e){return function(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n={};return h(n,e,Reflect.ownKeys(l(e))),h(n,t,Reflect.ownKeys(l(t))),$(e,m(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}(this,e)},pick(e){return function(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i={};return h(i,e,j(e,t)),$(e,m(n,{shape:i,checks:[]}))}(this,e)},omit(e){return function(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=new Set(j(e,t)),o={};return h(o,e,Reflect.ownKeys(l(e)).filter(e=>!i.has(e))),$(e,m(n,{shape:o,checks:[]}))}(this,e)},partial(...e){return P(ro,this,e[0])},exactPartial(...e){return P(oo,this,e[0],"exactPartial")},required(...e){return function(e,t,n){const r=n?new Set(j(t,n)):void 0,i={};return h(i,t,Reflect.ownKeys(l(t)),(t,n)=>r&&!r.has(n)?t:new e({type:"nonoptional",innerType:t})),$(t,m(t._zod.def,{shape:i}))}(lo,this,e[0])}});function Gi(e,t){const n={type:"object",shape:e??{},...O(t)};return new Wi(n)}const Hi=te("ZodUnion",(e,t)=>{gn.init(e,t),ai.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def,o=!1===i.inclusive,s=i.options.map((e,n)=>pr(e,t,{...r,path:[...r.path,o?"oneOf":"anyOf",n]}));o?n.oneOf=s:n.anyOf=s})(e,t,n,r),e.options=t.options}),Bi=te("ZodDiscriminatedUnion",(e,t)=>{Hi.init(e,t),yn.init(e,t)});function qi(e,t,n){return new Bi({type:"union",options:t,discriminator:e,...O(n)})}const Xi=te("ZodIntersection",(e,t)=>{vn.init(e,t),ai.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def,o=pr(i.left,t,{...r,path:[...r.path,"allOf",0]}),s=pr(i.right,t,{...r,path:[...r.path,"allOf",1]}),a=e=>"allOf"in e&&1===Object.keys(e).length,c=[...a(o)?o.allOf:[o],...a(s)?s.allOf:[s]];n.allOf=c,t.intersections.push(c)})(e,t,n,r)}),Yi=te("ZodEnum",(e,t)=>{wn.init(e,t),ai.init(e,t),e._zod.processJSONSchema=(t,n,i)=>((e,t,n)=>{const i=r(e._zod.def.entries);0!==i.length?(i.every(e=>"number"==typeof e)&&(n.type="number"),i.every(e=>"string"==typeof e)&&(n.type="string"),n.enum=i):n.not={}})(e,0,n),e.enum=t.entries,e.options=[...e._zod.values];const n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{const i={};for(const r of e){if(!n.has(r))throw new Error(`Key ${r} not found in enum`);i[r]=t.entries[r]}return new Yi({...t,checks:[],...O(r),entries:i})},e.exclude=(e,r)=>{const i={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete i[t]}return new Yi({...t,checks:[],...O(r),entries:i})}});function Qi(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Yi({type:"enum",entries:n,...O(t)})}const eo=te("ZodLiteral",(e,t)=>{zn.init(e,t),ai.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;if(0===i.values.length)return void(n.not={});const o=[];for(const s of i.values)if(void 0===s){if(fr(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if("bigint"==typeof s){if(fr(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(s))}else o.push(s);if(0===o.length);else if(1===o.length){const e=o[0];n.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?n.enum=[e]:n.const=e}else o.every(e=>"number"==typeof e)&&(n.type="number"),o.every(e=>"string"==typeof e)&&(n.type="string"),o.every(e=>"boolean"==typeof e)&&(n.type="boolean"),o.every(e=>null===e)&&(n.type="null"),n.enum=o})(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function to(e,t){return new eo({type:"literal",values:Array.isArray(e)?e:[e],...O(t)})}const no=te("ZodTransform",(e,t)=>{si(),kn.init(e,t),ai.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{fr(e,t,n,r,"Transforms cannot be represented in JSON Schema")})(e,t,n,r),e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new re(e.constructor.name);n.addIssue=r=>{if("string"==typeof r)n.issues.push(M(r,n.value,t));else{const t=r;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),"input"in t||(t.input=n.value),t.inst??(t.inst=e),n.issues.push(M(t))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}}),ro=te("ZodOptional",(e,t)=>{On.init(e,t),ai.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lr(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});function io(e){return new ro({type:"optional",innerType:e})}const oo=te("ZodExactOptional",(e,t)=>{xn.init(e,t),ai.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lr(e,t,0,r),e.unwrap=()=>e._zod.def.innerType}),so=te("ZodNullable",(e,t)=>{Sn.init(e,t),ai.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def,o=pr(i.innerType,t,r),s=t.seen.get(e);"openapi-3.0"===t.target?(s.ref=i.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ao(e){return new so({type:"nullable",innerType:e})}const co=te("ZodDefault",(e,t)=>{In.init(e,t),ai.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;pr(i.innerType,t,r),t.seen.get(e).ref=i.innerType;const o=Mr(i.defaultValue,e,t,n,r);o!==Jr&&(n.default=o)})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}),uo=te("ZodPrefault",(e,t)=>{En.init(e,t),ai.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;if(pr(i.innerType,t,r),t.seen.get(e).ref=i.innerType,"input"!==t.io)return;const o=Mr(i.defaultValue,e,t,n,r);o!==Jr&&(n._prefault=o)})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),lo=te("ZodNonOptional",(e,t)=>{Pn.init(e,t),ai.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;pr(i.innerType,t,r),t.seen.get(e).ref=i.innerType})(e,t,0,r),e.unwrap=()=>e._zod.def.innerType}),fo=te("ZodCatch",(e,t)=>{Zn.init(e,t),ai.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;let o;pr(i.innerType,t,r),t.seen.get(e).ref=i.innerType;try{o=i.catchValue(void 0)}catch{return void fr(e,t,n,r,"Dynamic catch values are not supported in JSON Schema")}n.default=o})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}),po=te("ZodPipe",(e,t)=>{Nn.init(e,t),ai.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def,o=i.in._zod.traits.has("$ZodTransform"),s="input"===t.io?o?i.out:i.in:i.out;pr(s,t,r),t.seen.get(e).ref=s})(e,t,0,r),e.in=t.in,e.out=t.out});function ho(e,t){return new po({type:"pipe",in:e,out:t})}const mo=te("ZodReadonly",(e,t)=>{Rn.init(e,t),ai.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const i=e._zod.def;pr(i.innerType,t,r),t.seen.get(e).ref=i.innerType,n.readOnly=!0})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),go=te("ZodCustom",(e,t)=>{Dn.init(e,t),ai.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{fr(e,t,n,r,"Custom types cannot be represented in JSON Schema")})(e,t,n,r)}),yo=di().trim().min(1).max(120).regex(/^[a-zA-Z0-9][a-zA-Z0-9_.:-]*$/),vo=di().datetime(),_o=Fi().int().nonnegative(),bo=Qi(["https-token","ssh-key"]),wo=Qi(["operation-only","instance-retained"]),zo=Qi(["enabled","disabled"]),ko=Qi(["pending","synced","deferred","revoking","revoked"]),$o=Gi({scheme:Qi(["https","ssh"]),host:di().trim().min(1).max(253),port:Fi().int().min(1).max(65535).optional(),pathPrefix:di().min(1).max(2048).default("/")}).strict();function Oo(e){throw new Error(`Invalid Git credential scope: ${e}`)}function xo(e){const t=e.trim().replace(/^\[|\]$/g,"");(!t||t.includes("*")||/[/?#@\s]/.test(t))&&Oo("host is invalid");try{const e=new URL(t.includes(":")?`http://[${t}]/`:`http://${t}/`).hostname.replace(/^\[|\]$/g,"").toLowerCase();return(!e||e.length>253||e.includes("*"))&&Oo("host is invalid"),e}catch{Oo("host is invalid")}}function So(e){try{return decodeURIComponent(e)}catch{Oo("path contains invalid percent encoding")}}function Io(e){const t=e?.trim()||"/";(t.includes("?")||t.includes("#")||t.includes("\\")||t.includes("\0"))&&Oo("path contains an unsupported delimiter");const n=(t.startsWith("/")?t:`/${t}`).split("/").filter(Boolean);for(const e of n){const t=So(e);("."===t||".."===t||t.includes("/")||t.includes("\\")||t.includes("\0"))&&Oo("path contains an unsafe segment")}return 0===n.length?"/":`/${n.join("/")}/`}function jo(e){const t=$o.parse(e),n="https"===t.scheme?443:22;return $o.parse({scheme:t.scheme,host:xo(t.host),...void 0===t.port||t.port===n?{}:{port:t.port},pathPrefix:Io(t.pathPrefix)})}function Eo(e){return Io(e.replace(/\.git\/?$/,""))}const Po=Gi({id:yo,name:di().trim().min(1).max(160),kind:bo,scope:$o,secretSet:to(!0),status:zo,revision:_o,createdAt:vo,updatedAt:vo}).strict(),Ao=qi("kind",[Gi({kind:to("https-token"),username:di().trim().min(1).max(240),token:di().min(1).max(8192)}).strict(),Gi({kind:to("ssh-key"),privateKey:di().min(1).max(131072),passphrase:di().max(8192).optional(),pinnedKnownHosts:di().min(1).max(131072)}).strict()]);Gi({name:di().trim().min(1).max(160),scope:$o,secret:Ao}).strict().superRefine((e,t)=>{"https"===e.scope.scheme!=("https-token"===e.secret.kind)&&t.addIssue({code:"custom",path:["scope","scheme"],message:"Credential kind must match the remote scheme."});try{jo(e.scope)}catch(e){t.addIssue({code:"custom",path:["scope"],message:e instanceof Error?e.message:"Invalid Git scope."})}}),Gi({name:di().trim().min(1).max(160).optional(),scope:$o.optional(),secret:Ao.optional(),status:zo.optional()}).strict().refine(e=>Object.keys(e).length>0,"At least one credential field must be updated."),Gi({items:Vi(Po).max(1e4)}).strict(),Gi({host:di().trim().min(1).max(253),port:Fi().int().min(1).max(65535).optional()}).strict();const To=Gi({keyType:di().trim().min(1).max(64),fingerprint:di().trim().min(1).max(256),publicKey:di().trim().min(1).max(8192),knownHosts:di().min(1).max(8192)}).strict();Gi({host:di().trim().min(1).max(253),port:Fi().int().min(1).max(65535),fetchedAt:vo,knownHosts:di().min(1).max(65536),entries:Vi(To).min(1).max(32)}).strict(),Gi({instanceId:yo,credentialId:yo,credentialRevision:_o,assignmentRevision:_o,status:ko,authorizedAt:vo,updatedAt:vo}).strict();const Zo=Gi({credential:Po,secret:Ao}).strict().superRefine((e,t)=>{e.credential.kind!==e.secret.kind&&t.addIssue({code:"custom",path:["secret","kind"],message:"Credential payload kind mismatch."})});Gi({instanceId:yo,generation:_o,credentialIds:Vi(yo).max(256).transform(e=>[...new Set(e)].sort()),updatedAt:vo}).strict(),Gi({remoteUrl:di().trim().min(1).max(4096)}).strict(),qi("status",[Gi({status:to("ok"),username:di().min(1).max(240),password:di().min(1).max(8192)}).strict(),Gi({status:Qi(["none","ambiguous","unsupported","missing-host-key","rejected"])}).strict()]),Gi({remoteUrl:di().trim().min(1).max(4096)}).strict(),qi("status",[Gi({status:to("ok"),invocationId:yo,publicIdentity:di().min(1).max(131072),pinnedKnownHosts:di().min(1).max(131072)}).strict(),Gi({status:Qi(["none","ambiguous","unsupported","missing-host-key","rejected"])}).strict()]),Gi({invocationId:yo,frame:di().min(1).max(1048576)}).strict(),Gi({frame:di().min(1).max(1048576)}).strict();const No=Gi({operationId:yo,retention:wo,payload:Zo}).strict();function Fo(e){return`'${e.replace(/'/g,"'\\''")}'`}function Ro(e){const t=e.replace(/-/g,"_").toUpperCase();return Object.assign(new Error(`TASK_HANDOFF_GIT_PROVISIONING_ERROR=${t}`),{code:t})}function Co(n,r=process.env.TASK_HANDOFF_GIT_RUNTIME_DIR||"/run/task-handoff/git-runtime"){const i=function(n){return e.readdirSync(n,{withFileTypes:!0}).filter(e=>e.isDirectory()&&e.name.startsWith("credential-")).sort((e,t)=>e.name.localeCompare(t.name)).flatMap(r=>{const i=t.join(n,r.name),o=t.join(i,"scope.json");if(!e.existsSync(o))return[];const s=e.existsSync(t.join(i,"token")),a=e.existsSync(t.join(i,"public-identity"));return s||a?[{candidate:{id:r.name,kind:s?"https-token":"ssh-key",scope:JSON.parse(e.readFileSync(o,"utf8")),status:"enabled",...a?{pinnedKnownHosts:e.existsSync(t.join(i,"known_hosts"))}:{}},directory:i}]:[]})}(r),o=function(e,t){let n;try{n=function(e){const t=e.trim();if(t&&!t.includes("\0")||Oo("remote is empty or invalid"),/^https?:\/\//i.test(t)||/^ssh:\/\//i.test(t)){let e;Io(t.replace(/^[a-z][a-z0-9+.-]*:\/\/[^/]+/i,"").split(/[?#]/,1)[0]||"/");try{e=new URL(t)}catch{Oo("remote URL is invalid")}"https:"!==e.protocol&&"ssh:"!==e.protocol&&Oo("remote scheme is unsupported"),(e.password||"https:"===e.protocol&&e.username)&&Oo("HTTPS userinfo is forbidden"),(e.search||e.hash)&&Oo("query and fragment are forbidden");const n="https:"===e.protocol?"https":"ssh",r=e.port?Number(e.port):void 0;return{...jo({scheme:n,host:e.hostname,port:r,pathPrefix:Eo(e.pathname)}),original:t}}/^[a-z][a-z0-9+.-]*:\/\//i.test(t)&&Oo("remote scheme is unsupported");const n=/^(?:([^@/:\s]+)@)?([^/:\s]+):(.+)$/.exec(t);n||Oo("remote must use HTTPS, ssh://, or scp-like SSH syntax");const[,,r,i]=n;return(i.includes("?")||i.includes("#"))&&Oo("query and fragment are forbidden"),{...jo({scheme:"ssh",host:r,pathPrefix:Eo(i)}),original:t}}(e)}catch(e){return{status:"unsupported",reason:e instanceof Error?e.message:"Unsupported Git remote."}}const r=t.filter(e=>"enabled"===e.status).filter(e=>"https"===n.scheme==("https-token"===e.kind)).filter(e=>function(e,t){const n=jo(e);return n.scheme===t.scheme&&n.host===t.host&&n.port===t.port&&("/"===n.pathPrefix||t.pathPrefix.startsWith(n.pathPrefix))}(e.scope,n)).map(e=>({candidate:e,specificity:jo(e.scope).pathPrefix.length}));if(0===r.length)return{status:"none",remote:n};const i=Math.max(...r.map(e=>e.specificity)),o=r.filter(e=>e.specificity===i).map(e=>e.candidate);if(o.length>1)return{status:"ambiguous",remote:n,credentialIds:o.map(e=>e.id).sort()};const s=o[0];return"ssh-key"===s.kind&&!0!==s.pinnedKnownHosts?{status:"missing-host-key",remote:n,credentialId:s.id}:{status:"unique",remote:n,credential:s}}(n,i.map(e=>e.candidate));if("unique"!==o.status)throw Ro("none"===o.status?"credential-missing":o.status);const s=i.find(e=>e.candidate.id===o.credential.id);if(!s)throw Ro("credential-missing");return s.directory}async function Do(r){const i=function(e){if(!Array.isArray(e)||e.some(e=>"string"!=typeof e||e.includes("\0")))return;const t=e;let n,r="";const i=[];for(let e=0;e<t.length;e+=1){const o=t[e];if("-p"===o&&/^\d+$/.test(t[e+1]||"")&&void 0===n){const r=Number(t[++e]);if(r<1||r>65535)return;n=String(r);continue}if("-4"!==o&&"-6"!==o)if("-o"!==o||"SendEnv=GIT_PROTOCOL"!==t[e+1]){if("-oSendEnv=GIT_PROTOCOL"!==o){if(o.startsWith("-"))return;if(r=o,e+=1,e!==t.length-1)return;break}i.push(o)}else i.push("-o",t[++e]);else i.push(o)}if(!r||!/^(?:[a-zA-Z0-9._-]+@)?[^@\s]+$/.test(r))return;const o=r.replace(/^[^@]+@/,""),s=function(e){const t=/^(git-upload-pack|git-receive-pack|git-upload-archive) ([\s\S]+)$/.exec(e);if(!t)return;const n=t[2];let r;if(n.startsWith("'")){if(!n.endsWith("'"))return;if(r=n.slice(1,-1).replace(/'\\''/g,"'"),Fo(r)!==n)return}else{if(!/^[a-zA-Z0-9._~@%+,:\/-]+$/.test(n))return;r=n}return!r||/[\0-\x1f\x7f]/.test(r)?void 0:{service:t[1],repository:r}}(t.at(-1)||"");if(!o||!s)return;const a=`${s.service} ${Fo(s.repository)}`;return{remote:`ssh://${o}${n?`:${n}`:""}/${encodeURIComponent(s.repository.replace(/^\/+/,"")).replace(/%2F/gi,"/")}`,args:[...i,...n?["-p",n]:[],r,a]}}(r);if(!i)throw Ro("remote-unsupported");const o=Co(i.remote),s=t.join(o,"agent.sock"),a=t.join(o,"public-identity"),c=t.join(o,"known_hosts");if(!e.existsSync(s))throw Ro("ssh-agent-unavailable");if(!e.existsSync(c)||0===e.statSync(c).size)throw Ro("host-key-required");return function(e,t,r={}){return new Promise((t,i)=>{const o={...process.env};delete o.SSH_AUTH_SOCK,Object.assign(o,r);const s=n.spawn("ssh",e,{stdio:"inherit",shell:!1,env:o});s.once("error",i),s.once("close",(e,n)=>0===e?t():i(Object.assign(new Error("Git SSH transport failed."),{exitCode:e,signal:n})))})}(["-F","/dev/null","-oBatchMode=yes","-oPasswordAuthentication=no","-oKbdInteractiveAuthentication=no","-oIdentitiesOnly=yes","-oIdentityFile=none","-oStrictHostKeyChecking=yes",`-oUserKnownHostsFile=${c}`,"-oGlobalKnownHostsFile=/dev/null",`-oIdentityAgent=${s}`,"-i",a,...i.args],0,{SSH_AUTH_SOCK:s})}Gi({operationId:yo,instanceId:yo,remoteUrl:di().trim().min(1).max(4096),ref:qi("type",[Gi({type:Qi(["branch","tag"]),name:di().trim().min(1).max(240)}).strict(),Gi({type:to("commit"),commit:di().trim().regex(/^[0-9a-fA-F]{4,64}$/,"commit must be a hexadecimal Git object id")}).strict()]),clone:Gi({depth:Fi().int().positive().max(1e5).optional(),submodules:Ui().default(!1),lfs:Ui().default(!1),subdirectory:di().trim().max(240).refine(e=>!e.startsWith("/")&&!e.split("/").some(e=>".."===e),"subdirectory must be a relative path within the repository").transform(e=>e.split("/").filter(e=>e&&"."!==e).join("/")).default("")}).strict(),credentials:Vi(No).max(256).default([])}).strict(),process.platform,async function(){const[n,...r]=process.argv.slice(2);if("credential"===n)return async function(n){if("get"!==n)return;const r=function(e){const t="https"===e.protocol?"https":void 0,n="string"==typeof e.host?e.host.trim():"",r="string"==typeof e.path?e.path.replace(/^\/+/,""):"";return t&&n?`${t}://${n}/${r}`:void 0}(await new Promise(e=>{let t="";process.stdin.setEncoding("utf8"),process.stdin.on("data",e=>{t+=e}),process.stdin.on("end",()=>e(Object.fromEntries(t.split(/\r?\n/).flatMap(e=>{const t=e.indexOf("=");return t>0?[[e.slice(0,t),e.slice(t+1)]]:[]}))))}));if(!r)throw Ro("remote-unsupported");let i;try{i=Co(r)}catch(e){if("CREDENTIAL_MISSING"===e.code)return void process.stderr.write(`${e.message}\n`);throw e}const o=e.readFileSync(t.join(i,"username"),"utf8"),s=e.readFileSync(t.join(i,"token"),"utf8");process.stdout.write(`username=${o}\npassword=${s}\n\n`)}(r[0]);if("ssh"===n)return Do(r);throw new Error("TASK_HANDOFF_GIT_PROVISIONING_ERROR=REMOTE_UNSUPPORTED")}().catch(e=>{process.stderr.write(`${e instanceof Error?e.message:String(e)}\n`),process.exitCode=1});
@@ -0,0 +1,18 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { pathToFileURL } from "node:url";
4
+
5
+ const current = process.argv[2];
6
+ if (!current) throw new Error("Active controlled-instance runtime path is missing.");
7
+ const releaseRoot = fs.realpathSync(current);
8
+ const manifestPath = path.join(releaseRoot, "runtime-manifest.json");
9
+ const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
10
+ if (manifest.packageName !== "@task-handoff/controlled-instance" || typeof manifest.entrypoint !== "string") {
11
+ throw new Error("Active controlled-instance runtime manifest is invalid.");
12
+ }
13
+ const entrypoint = path.resolve(releaseRoot, manifest.entrypoint);
14
+ if (!entrypoint.startsWith(`${releaseRoot}${path.sep}`) || !fs.statSync(entrypoint).isFile()) {
15
+ throw new Error("Active controlled-instance runtime entrypoint is invalid.");
16
+ }
17
+ process.argv = [process.execPath, entrypoint, "web", "--host", process.env.TASK_HANDOFF_WEB_HOST || "0.0.0.0", "--port", process.env.TASK_HANDOFF_WEB_PORT || "8080"];
18
+ await import(pathToFileURL(entrypoint).href);