broods 0.52.1 → 0.52.3

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.
File without changes
@@ -0,0 +1,5 @@
1
+ function q(e){if(e.events&&e.input!==void 0)throw Error("Run input accepts either `input` or `events`, not both");if(e.events&&e.events.length>0)return e.events;if(typeof e.input==="string")return[{role:"user",content:[{type:"text",text:e.input}]}];throw Error("Run input requires `input` (string) or a non-empty `events` array")}async function*ie(e){let n=e.getReader(),t=new TextDecoder,o="";try{while(!0){let{done:r,value:i}=await n.read();if(r)break;o+=t.decode(i,{stream:!0});let s=o.split(`
2
+ `);o=s.pop()??"";for(let a of s)if(a.startsWith("data: "))yield a.slice(6)}}finally{await n.cancel().catch(()=>{return}),n.releaseLock()}}var ge=500,hn=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,Sn=/^(?!0{32}$)[0-9a-f]{32}$/;function pe(e){return e==="DEBUG"||e==="INFO"||e==="WARN"||e==="ERROR"}function ye(e){if(typeof e!=="object"||e===null)return!1;let n=e;if(n.type==="subscribe")return Rn(n);if(n.type==="unsubscribe")return J(n.stream);if(n.type==="fetchTrace")return L(n.traceId);return!1}function Se(e){return e==="task"||e==="cron"||e==="subtask"}function D(e){return typeof e==="string"&&hn.test(e)}function L(e){return typeof e==="string"&&Sn.test(e)}function J(e){return e==="logs"||e==="traces"}function Rn(e){let n=e.stream;if(!J(n))return!1;let t=e.backfill;if(t!==void 0&&(typeof t!=="number"||!Number.isSafeInteger(t)||t<0||t>500))return!1;if(e.liveOnly!==void 0&&typeof e.liveOnly!=="boolean")return!1;let o=e.minLevel;if(o!==void 0&&!pe(o))return!1;let r=e.sandboxId;return r===void 0||n==="logs"&&D(r)}import{readFileSync as bn}from"node:fs";import{chmod as Q,mkdir as In,writeFile as xn}from"node:fs/promises";import{homedir as kn}from"node:os";import{dirname as X,join as An}from"node:path";var y="broods",b="_generated",I=An(kn(),".broods","config.json"),z="broods.app",Y="dashboard",vn="gateway";function k(e){let n=process.env.BROODS_TOKEN,t=e??process.env.BROODS_BASE_URL;if(n&&t)return{baseUrl:f(t),token:n,createdAt:new Date().toISOString()};let o=ne();if(!o)return null;if(t)return o.logins[f(t)]??null;let r=process.env.BROODS_DASHBOARD_URL;if(r){let i=f(r);return Object.values(o.logins).find((s)=>s.dashboardUrl===i)??null}return o.logins[o.current]??null}async function U(e){let n=ne()?.logins??{},t={current:e.baseUrl,logins:{...n,[e.baseUrl]:e}};await In(X(I),{recursive:!0,mode:448}),await Q(X(I),448),await B(I,`${JSON.stringify(t,null,2)}
3
+ `)}async function B(e,n){await xn(e,n,{encoding:"utf8",mode:384}),await Q(e,384)}function S(){return process.env.BROODS_STAGE}function f(e){let n=e.length;while(n>0&&e.charCodeAt(n-1)===47)n-=1;return e.slice(0,n)}function A(e){try{let n=new URL(e);if(!n.hostname.startsWith(`${Y}.`))return;let t=n.hostname.slice(Y.length+1);if(t!==z&&!t.endsWith(`.${z}`))return;return n.hostname=`${vn}.${t}`,f(n.origin)}catch{return}}function ne(){try{let e=JSON.parse(bn(I,"utf8"));if(typeof e.current!=="string"||!e.logins)return null;return{current:e.current,logins:e.logins}}catch{return null}}import{existsSync as re,readFileSync as se,statSync as wn}from"node:fs";import{join as ce,resolve as ue}from"node:path";var G=new Map,Tn=new Set(Object.keys(process.env)),oe=new Set;function m(e=process.cwd()){En(e);let n=k();return{dashboardUrl:process.env.BROODS_DASHBOARD_URL??n?.dashboardUrl,baseUrl:process.env.BROODS_BASE_URL??n?.baseUrl,token:n?.token,project:process.env.BROODS_PROJECT,stage:S()}}function O(){let e={};for(let[n,t]of Object.entries(process.env))if(typeof t==="string"&&!n.startsWith("BROODS_"))e[n]=t;return e}function C(e,n=process.cwd()){let t=process.env[e];if(t===void 0)return!1;let o=ue(n);for(let r of[".env.local",".env"]){let i=ce(o,r);if(!re(i))continue;let s=F(se(i,"utf8"));if(s[e]!==void 0)return s[e]!==t}return!0}function En(e){let n=ue(e),t=process.env.BROODS_RELOAD_ENV==="1";for(let o of[".env",".env.local"]){let r=ce(n,o);if(!re(r)){G.delete(r);continue}let i=wn(r).mtimeMs,s=G.get(r);if(s&&s.mtimeMs===i)continue;G.set(r,{mtimeMs:i});for(let[a,c]of Object.entries(F(se(r,"utf8"))))if(t||!Tn.has(a)||oe.has(a))process.env[a]=c,oe.add(a)}}function F(e){let n={};for(let t of e.split(/\r?\n/)){let o=t.trim();if(!o||o.startsWith("#"))continue;let r=o.startsWith("export ")?o.slice(7).trim():o,i=r.indexOf("=");if(i<=0)continue;let s=r.slice(0,i).trim();if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(s))continue;n[s]=Nn(r.slice(i+1).trim())}return n}function Nn(e){if(e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1).replace(/\\n/g,`
4
+ `).replace(/\\"/g,'"');if(e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);let n=e.indexOf(" #");return n>=0?e.slice(0,n).trimEnd():e}var j=new TextEncoder,de={name:"HMAC",hash:"SHA-256"};async function fe(e,n,t,o){let r=le(j.encode(JSON.stringify(t))),i=await crypto.subtle.sign(de,await Dn(n,o),j.encode(r));return`${e}${r}.${le(new Uint8Array(i))}`}function le(e){let n="";for(let t of e)n+=String.fromCharCode(t);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function Dn(e,n){let t=await crypto.subtle.digest("SHA-256",j.encode(`${e}${n}`));return crypto.subtle.importKey("raw",t,de,!1,["sign","verify"])}var On="buat_",Z="bsig_",ee="x-broods-user-token",he="broods.user.";var en=600000,H=3600000,Mn="broods-user-token:",nn=/^[A-Za-z0-9._@+=-]{1,128}$/,tn=100,_n=256,Un=60000;async function on(e,n,t=Date.now()){if(!n.startsWith(Z))throw Error(`The user token signing secret must start with ${Z}. It is not the bsk_ runtime key.`);let o=Pn(e,t);if(!o||e.expiresAt>t+H)throw Error(`Invalid user token: userId must match ${nn.source}, conversations must be at most ${tn} non-empty keys, and expiresAt must be in the next ${H/60000} minutes.`);return await fe(On,Mn,o,n)}function Pn(e,n){if(!e||typeof e!=="object")return null;let{userId:t,conversations:o,expiresAt:r}=e;if(typeof t!=="string"||!nn.test(t)||typeof r!=="number"||!Number.isFinite(r)||r<=n||r>n+H+Un)return null;if(o===void 0)return{userId:t,expiresAt:r};if(!Array.isArray(o)||o.length>tn||!o.every((i)=>typeof i==="string"&&i.trim()===i&&i.length>0&&i.length<=_n))return null;return{userId:t,conversations:o,expiresAt:r}}var g="BROODS_USER_TOKEN_SECRET";async function be(e){let n=e.secret??process.env[g];if(!n)throw Error(`signUserToken needs the stage's signing secret: pass secret or set ${g}. \`broods dev\` and \`broods deploy\` write it to .env.local; the dashboard's Runtime key tab rotates it.`);return await on({userId:e.userId,...e.conversations?{conversations:e.conversations}:{},expiresAt:Date.now()+(e.ttlMs??en)},n)}var T="https://gateway.broods.app";class ae extends Error{accepted;constructor(e){super(`Ingress ${e.eventId} was accepted asynchronously with status ${e.status??"queued"}`);this.accepted=e;this.name="IngressAcceptedError"}}class M{baseUrl;apiKey;userToken;fetchImpl;constructor(e={}){m(),this.baseUrl=V(e.baseUrl||e.host||process.env.BROODS_BASE_URL||process.env.BROODS_HOST||T),this.apiKey=e.apiKey||process.env.BROODS_API_KEY||void 0,this.userToken=e.userToken,this.fetchImpl=e.fetch??fetch}channelWebhookUrl(e){return`${this.baseUrl}${e.webhookPath.startsWith("/")?"":"/"}${e.webhookPath}`}accountWebhookUrl(e,n){let t=[e,n].map(encodeURIComponent);return`${this.baseUrl}/v1/webhooks/${t.join("/")}`}stageWebhookUrl(e,n,t){let o=[e,"dev",n,t].map(encodeURIComponent);return`${this.baseUrl}/v1/webhooks/${o.join("/")}`}agent(e,n){if(typeof e==="string"){let o=e,r=n??"";if(!r)throw Error(`Agent ${o} is missing a generated id. Run broods dev --once or broods deploy to sync it first.`);return{id:r,run:(i)=>this.run({...i,agentName:o,agentId:r}),runAsync:(i)=>this.runAsync({...i,agentName:o,agentId:r}),continue:(i)=>this.continue({...i,agentId:r}),stream:(i)=>this.stream({...i,agentName:o,agentId:r})}}let t=e;if(!t.id)throw Error(`Agent ${t.name} is missing a generated id. Run broods dev --once or broods deploy to sync it first.`);return{id:t.id,run:(o)=>this.run(t,o),runAsync:(o)=>this.runAsync(t,o),continue:(o)=>this.continue(t,o),stream:(o)=>this.stream(t,o)}}async run(e,n){let t=[],o="",r=n?this.stream(e,n):this.stream(e);for await(let i of r)if(t.push(i),i.type==="text-delta")o+=i.text;return{text:o,events:t}}async*stream(e,n){let t=n?{...n,agentId:e.id,agentName:e.name}:e,o=rn(t,"cli"),r=n?this.scopedUrl(e):`${this.baseUrl}/v1/runs`,i=await this.openStream(o,r);if(!i.ok)throw Error(`Run failed: ${i.status} ${await i.text()}`);if(i.status===202)throw new ae(sn(await i.json(),o));if(!i.body)throw Error("Run response has no body");for await(let s of ie(i.body)){let a;try{a=JSON.parse(s)}catch{continue}if(a.type==="error")throw Error(`Agent run failed: ${Wn(a.error)}`);yield a}}async runAsync(e,n){let t=n?{...n,agentId:e.id,agentName:e.name}:e,o={...rn(t,"async"),background:!0},r=n?this.scopedUrl(e):`${this.baseUrl}/v1/runs`;return this.postAcceptedRun(r,o,"Async run")}async continue(e,n){let t=n?e:null,o=n??e,r={agentId:t?t.id:e.agentId,eventId:o.eventId??`continue-${crypto.randomUUID()}`,conversationKey:o.conversationKey,continue:!0},i=t?this.scopedUrl(t):`${this.baseUrl}/v1/runs`;return this.postAcceptedRun(i,r,"Continue")}async getAsyncStatus(e){let n=this.resolveStatusUrl(e),t=await this.fetchJson(n,{method:"GET",headers:await this.apiKeyHeaders()});if(t.status===404)return{status:"not_found"};if(!t.ok)throw Error(`Status check failed: ${t.status} ${await t.text()}`);return await t.json()}async waitForAsyncStatus(e,n={}){let t=Date.now()+(n.timeoutMs??180000),o=n.intervalMs??2000;while(Date.now()<t){if(n.signal?.aborted)throw Error("Async status polling aborted.");let r=await this.getAsyncStatus(e);if(r.status==="awaiting_approval"||r.status==="awaiting_input"||r.status==="completed"||r.status==="failed"||r.status==="expired"||r.status==="not_found")return r;await Ln(o,n.signal)}throw Error("Polling timeout")}scopedUrl(e){if(e.projectSlug&&e.stageSlug&&e.endpointId)return`${this.baseUrl}/v1/projects/${encodeURIComponent(e.projectSlug)}/stages/${encodeURIComponent(e.stageSlug)}/agents/${encodeURIComponent(e.endpointId)}`;return`${this.baseUrl}/v1/runs`}asyncAgentRun(e,n){return{...e,conversationKey:n,poll:()=>this.getAsyncStatus(e),wait:(t)=>this.waitForAsyncStatus(e,t)}}async postAcceptedRun(e,n,t){let o=await this.fetchJson(e,{method:"POST",headers:await this.apiKeyHeaders(),body:JSON.stringify(n)});if(o.status!==202)throw Error(`${t} failed: ${o.status} ${await Kn(o,"202 JSON")}`);return this.asyncAgentRun(sn(await o.json(),n),n.conversationKey)}async openStream(e,n){if(this.apiKey)return await this.fetchCore(e,n,{Authorization:`Bearer ${this.apiKey}`,...await this.userTokenHeaders()});throw Error(`BroodsClient streams directly from the core service at ${this.baseUrl}. Provide apiKey. For a self-hosted core service, set host/baseUrl or BROODS_HOST/BROODS_BASE_URL.`)}async fetchCore(e,n,t){try{return await this.fetchImpl(n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...t},body:JSON.stringify(e)})}catch(o){throw Error(`Cannot access the broods core service at ${n}. The SDK uses ${T} by default; set host/baseUrl or BROODS_HOST/BROODS_BASE_URL to your own core service URL if your account uses a custom deployment. Cause: ${o instanceof Error?o.message:String(o)}`)}}async apiKeyHeaders(){if(!this.apiKey)throw Error("BroodsClient requires apiKey or BROODS_API_KEY.");return{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`,...await this.userTokenHeaders()}}async userTokenHeaders(){let e=typeof this.userToken==="function"?await this.userToken():this.userToken;return e?{[ee]:e}:{}}async fetchJson(e,n){try{return await this.fetchImpl(e,n)}catch(t){throw Error(`Cannot access the broods core service at ${e}. Cause: ${t instanceof Error?t.message:String(t)}`)}}resolveStatusUrl(e){if(typeof e!=="string")return e.statusUrl;if(/^https?:\/\//.test(e))return e;return $n(this.baseUrl,e)}}function V(e){let n=e.trim(),t=/^[A-Za-z][A-Za-z0-9+.-]*:\/\//.test(n)?n:`https://${n}`;return f(t)}function rn(e,n){let t=e.eventId??`${n}-${crypto.randomUUID()}`;return{agentId:e.agentId,eventId:t,conversationKey:e.conversationKey??t,events:q(e),...e.mode!==void 0?{mode:e.mode}:{},...e.idempotencyKey!==void 0?{idempotencyKey:e.idempotencyKey}:{},...e.system!==void 0?{system:e.system}:{},...e.model!==void 0?{model:e.model}:{}}}function Wn(e){if(typeof e==="string")return e;if(!e||typeof e!=="object")return String(e);let n=e,t=n.data?.error?.message??n.message??n.responseBody??JSON.stringify(e),o=n.name?`${n.name}: `:"",r=n.statusCode?` (HTTP ${n.statusCode})`:"";return`${o}${t}${r}`}function sn(e,n){if(!e||typeof e!=="object")throw Error("Async response must be an object");let t=e.statusUrl;if(typeof t!=="string"||t.length===0)throw Error("Async response missing statusUrl");let o=e.runId;if(typeof o!=="string"||o.length===0)throw Error("Async response missing runId");let r=typeof e.eventId==="string"?e.eventId:o,{status:i,requestedMode:s}=e;return{statusUrl:t,runId:o,eventId:r,agentId:n.agentId,...i==="accepted"||i==="queued"||i==="applied"||i==="processing"?{status:i}:{},...s==="reject"||s==="followup"||s==="collect"||s==="steer"?{requestedMode:s}:{}}}async function Kn(e,n){if((e.headers.get("content-type")??"").toLowerCase().includes("text/event-stream"))return await e.body?.cancel().catch(()=>{}),`expected ${n}, but the server returned an SSE stream. This usually means the core deployment ignored the background flag and ran the request on the direct streaming runner.`;let o=await e.text();if(o.length<=2000)return o;return`${o.slice(0,2000)}... [truncated ${o.length-2000} chars]`}function Ln(e,n){return new Promise((t,o)=>{if(n?.aborted){o(Error("Async status polling aborted."));return}let r=setTimeout(t,e);n?.addEventListener("abort",()=>{clearTimeout(r),o(Error("Async status polling aborted."))},{once:!0})})}function $n(e,n){return`${V(e)}/v1/runs/${encodeURIComponent(n)}`}var Bn=2000,an=0,N=1;class me{baseUrl;apiKey;userToken;WebSocketImpl;connectTimeoutMs;constructor(e={}){if(m(),this.baseUrl=pn(e.baseUrl||e.host||process.env.BROODS_BASE_URL||process.env.BROODS_HOST||T),this.apiKey=e.apiKey||process.env.BROODS_API_KEY||"",!this.apiKey)throw Error("BroodsWebSocketClient requires apiKey or BROODS_API_KEY.");this.userToken=e.userToken,this.WebSocketImpl=e.WebSocket,this.connectTimeoutMs=e.connectTimeoutMs??Bn}subscribe(e,n={}){let t=this.resolveWebSocket(),o=this.buildUrl(e),r=Hn(e),i=ln(this.baseUrl),s=new t(o,E(this.apiKey,e.userToken??this.userToken)),a=!1,c=!1,d=setTimeout(()=>{if(!a)w(i)},this.connectTimeoutMs),R=(p=1000,P="client closed")=>{if(c)return;if(c=!0,clearTimeout(d),e.signal?.removeEventListener("abort",_),s.readyState===N||s.readyState===an)s.close(p,P)},w=(p)=>{n.onError?.(p),R(1000,"websocket error")},Cn=()=>{n.onDone?.(),R(1000,"done")},_=()=>{if(s.readyState===N)s.send(JSON.stringify({type:"cancel"}));w(Error("WebSocket run aborted."))};return e.signal?.addEventListener("abort",_,{once:!0}),s.onopen=()=>{if(a=!0,clearTimeout(d),e.signal?.aborted){_();return}s.send(JSON.stringify({type:"execute",agentId:r,...e.answers?{answers:e.answers}:{events:q(e)},sessionId:e.sessionId,...e.eventId!==void 0?{eventId:e.eventId}:{},...e.mode!==void 0?{mode:e.mode}:{},...e.idempotencyKey!==void 0?{idempotencyKey:e.idempotencyKey}:{},...e.system!==void 0?{system:e.system}:{},...e.model!==void 0?{model:e.model}:{}}))},s.onmessage=(p)=>{if(typeof p.data!=="string")return;let P=un(p.data);if(!P)return;let W=gn(P,n);switch(n.onMessage?.(W),W.type){case"meta":n.onMeta?.(W);break;case"done":Cn();break;case"error":w(Error(cn(W.error)));break}},s.onerror=()=>{w(i)},s.onclose=(p)=>{if(clearTimeout(d),e.signal?.removeEventListener("abort",_),c||p.code===1000)return;w(Error(p.reason||"WebSocket connection closed."))},{url:o,sendControl:function(p){if(s.readyState!==N)throw Error("WebSocket is not open");s.send(JSON.stringify({type:"control",...p}))},close:R}}attach(e,n={}){let t=this.resolveWebSocket(),o=this.buildUrl(e),r=new t(o,E(this.apiKey,e.userToken??this.userToken)),i=!1,s=(c=1000,d="client closed")=>{if(i)return;if(i=!0,e.signal?.removeEventListener("abort",a),r.readyState===N||r.readyState===an)r.close(c,d)},a=()=>{s(1000,"aborted"),n.onError?.(Error("WebSocket attach aborted."))};if(e.signal?.aborted)a();else e.signal?.addEventListener("abort",a,{once:!0});return r.onopen=()=>{if(i)return;r.send(JSON.stringify({type:"attach",...e,signal:void 0,agent:void 0,userToken:void 0}))},r.onmessage=(c)=>{if(i||typeof c.data!=="string")return;let d=un(c.data);if(!d)return;let R=gn(d,n);if(i)return;if(n.onMessage?.(R),i)return;if(R.type==="done")n.onDone?.();if(R.type==="error")n.onError?.(Error(cn(R.error)))},r.onerror=()=>{if(i)return;s(1000,"websocket error"),n.onError?.(ln(this.baseUrl))},r.onclose=(c)=>{if(e.signal?.removeEventListener("abort",a),!i&&c.code!==1000)n.onError?.(Error(c.reason||"WebSocket connection closed."))},{url:o,sendControl:function(c){if(r.readyState!==N)throw Error("WebSocket is not open");r.send(JSON.stringify({type:"control",...c}))},close:s}}async*stream(e){let n=[],t=!1,o=null,r=null,i=()=>{r?.(),r=null},s=this.subscribe(e,{onMessage:function(a){n.push(a),i()},onDone:function(){t=!0,i()},onError:function(a){o=a,i()}});try{while(!0){if(n.length>0){yield n.shift();continue}if(o)throw o;if(t)return;await new Promise((a)=>{r=a})}}finally{s.close()}}buildUrl(e){let n=Gn(e),t=e.projectSlug??e.agent?.projectSlug,o=e.stageSlug??e.agent?.stageSlug,r=t&&o?`/projects/${encodeURIComponent(t)}/stages/${encodeURIComponent(o)}`:"";return`${K(this.baseUrl)}/v1${r}/agents/${encodeURIComponent(n)}/ws`}resolveWebSocket(){let e=this.WebSocketImpl??globalThis.WebSocket;if(!e)throw Error("WebSocket is not available. Pass a WebSocket implementation in BroodsWebSocketClient options.");return e}}function K(e){let n=new URL(pn(e));if(n.protocol==="https:")n.protocol="wss:";if(n.protocol==="http:")n.protocol="ws:";return f(n.toString())}function E(e,n){return["broods.v1",`broods.token.${e}`,...n?[`${he}${n}`]:[]]}function cn(e){if(typeof e==="string")return e;if(e&&typeof e==="object"&&typeof e.message==="string")return e.message;return e===void 0?"WebSocket stream error.":JSON.stringify(e)}function pn(e){let n=e.trim();if(/^wss?:\/\//.test(n))return f(n);return V(n)}function un(e){try{let n=JSON.parse(e);return typeof n==="object"&&n!==null&&typeof n.type==="string"?n:null}catch{return null}}function Hn(e){let n=e.agentId??e.agent?.id??e.endpointId;if(!n)throw Error("WebSocket run requires agent, agentId, or endpointId.");return n}function Gn(e){let n=e.endpointId??e.agent?.endpointId??e.agent?.id;if(!n)throw Error("WebSocket run requires agent or endpointId.");return n}function gn(e,n){if(e.type!=="output")return e;let t=e;return n.onOutput?.(t),t.data}function ln(e){return Error(`Cannot access the WebSocket service at ${e}.`)}var fn=Symbol.for("broods.resource"),yn=Symbol.for("broods.config"),mn=Symbol.for("broods.connection"),dn=/^[A-Z][A-Z0-9_]{0,63}$/,ve=new Proxy((e)=>{if(!dn.test(e))throw Error("env name must match /^[A-Z][A-Z0-9_]*$/ and be at most 64 characters.");return{__beeblastEnv:!0,name:e}},{get:function(e,n,t){if(typeof n==="string"&&dn.test(n))throw Error(`env.${n} is not supported; use env("${n}")`);return Reflect.get(e,n,t)}});function _e(e){let{name:n,description:t,...o}=e;return x("agent",n,t,o)}function we(e){return{[yn]:!0,config:e}}function Re(e){let{name:n,description:t,...o}=e;return x("cron",n,t,o)}function $e(e){return e}function Ce(e){let{name:n,description:t,...o}=e;return x("mcp",n,t,o)}function Ee(e){let{name:n,description:t,...o}=e;return x("policy",n,t,o)}function ke(e){let{name:n,description:t,...o}=e;return x("sandbox",n,t,o)}function Te(e){let{name:n,description:t,...o}=e;return x("skill",n,t,o)}function Pe(e){let{name:n,description:t,...o}=e;return x("workspace",n,t,o)}function ze(e){return l("discord",e)}function Ie(e){return l("github",e)}function xe(e){return l("gchat",e)}function Ae(e){return l("instagram",e)}function Oe(e){return l("linear",e)}function Me(e){return l("matrix",e)}function Ne(e){return l("messenger",e)}function je(e){return l("pancake",e)}function qe(e){return l("slack",e)}function De(e){return l("teams",e)}function Le(e){return l("telegram",e)}function Ue(e){return l("twilio",e)}function Be(e){return l("whatsapp",e)}function Fe(e){return l("zalo",e)}function Ze(e){let{name:n,description:t,channelId:o,guildId:r,...i}=e;return u(n,t,o,r,i)}function He(e){let{name:n,description:t,repo:o,...r}=e,[i,...s]=o.split("/");if(!i||s.length!==1||!s[0])throw Error(`Channel "${n}" repo must be "owner/name", not "${o}"`);return u(n,t,o,i,r)}function Ve(e){let{name:n,description:t,spaceName:o,...r}=e;return u(n,t,o,void 0,r)}function Ke(e){let{name:n,description:t,igsid:o,...r}=e;return u(n,t,o,void 0,r)}function Ge(e){let{name:n,description:t,team:o,...r}=e;return u(n,t,o,void 0,r)}function We(e){let{name:n,description:t,channelId:o,...r}=e;return u(n,t,o,void 0,r)}function Je(e){let{name:n,description:t,psid:o,...r}=e;return u(n,t,o,void 0,r)}function Ye(e){let{name:n,description:t,conversationId:o,...r}=e;return u(n,t,o,void 0,r)}function Xe(e){let{name:n,description:t,channelId:o,teamId:r,...i}=e;return u(n,t,o,r,i)}function Qe(e){let{name:n,description:t,channelId:o,teamId:r,...i}=e;return u(n,t,o,r,i)}function et(e){let{name:n,description:t,chatId:o,...r}=e;return u(n,t,o,void 0,r)}function tt(e){let{name:n,description:t,from:o,...r}=e;return u(n,t,o,void 0,r)}function nt(e){let{name:n,description:t,waId:o,...r}=e;return u(n,t,o,void 0,r)}function rt(e){let{name:n,description:t,chatId:o,...r}=e;return u(n,t,o,void 0,r)}function te(e){return Boolean(e&&typeof e==="object"&&e[yn])}function v(e){return Boolean(e&&typeof e==="object"&&e[mn])}function h(e){return Boolean(e&&typeof e==="object"&&e[fn])}function u(e,n,t,o,r){return x("channelRecord",e,n,{...r,externalId:t,...o?{workspaceRef:o}:{}})}function l(e,n){let{partition:t,...o}=n;return{[mn]:!0,kind:"connection",type:e,...t?{partition:t}:{},config:o}}function x(e,n,t,o){return{[fn]:!0,kind:e,name:n,...t?{description:t}:{},config:o}}
5
+ export{q,ie,ge,pe,ye,Se,D,L,y,b,I,k,U,B,S,f,A,m,O,C,F,Z,ee,H,g,be,T,ae,M,V,me,K,E,ve,_e,we,Re,$e,Ce,Ee,ke,Te,Pe,ze,Ie,xe,Ae,Oe,Me,Ne,je,qe,De,Le,Ue,Be,Fe,Ze,He,Ve,Ke,Ge,We,Je,Ye,Xe,Qe,et,tt,nt,rt,te,v,h};
@@ -1,4 +1,4 @@
1
- import{N,k}from"./chunk-yqbtb9cd.js";import{e,o,i,c,n,t,u,R,s,d,r}from"./chunk-9th6spww.js";import{Q,ie,O}from"./cli/index.js";import{spawn as ne}from"node:child_process";import{statfsSync as se}from"node:fs";import{availableParallelism as ae,homedir as ce,hostname as le,totalmem as pe}from"node:os";import{performance as A}from"node:perf_hooks";var P=["cursor_position","double_click","hold_key","key","left_click","left_click_drag","left_mouse_down","left_mouse_up","middle_click","mouse_move","right_click","screenshot","scroll","triple_click","type","wait","zoom"];var C={badFrame:{code:4400,reason:"Malformed frame"},expired:{code:4419,reason:"Credential expired"},occupied:{code:4423,reason:"Already connected from another daemon"},replaced:{code:4409,reason:"Replaced by a newer connection"},unauthorized:{code:4401,reason:"Unauthorized; run broods login"},unknownSandbox:{code:4404,reason:"No machine sandbox with that name in this account"}};var U="/v1/machines/ws",B=t({action:d(P),coordinate:n(o().int()).length(2).optional().describe("[x, y] in screenshot pixels for mouse actions."),start_coordinate:n(o().int()).length(2).optional().describe("[x, y] where a left_click_drag starts."),text:e().optional().describe("Text for type, the key chord for key and hold_key, or modifiers to hold during a click, drag or scroll."),scroll_direction:d(["down","left","right","up"]).optional(),scroll_amount:o().int().min(1).optional().describe("Scroll clicks, default 3."),duration:o().min(0).max(300).optional().describe("Seconds for wait and hold_key."),region:n(o().int()).length(4).optional().describe("[x0, y0, x1, y1] of the screenshot to zoom into."),repeat:o().int().min(1).max(100).optional().describe("How many times to press the key.")}),G=B.extend({type:r("computer"),id:e()}),W=t({type:r("computer-result"),id:e(),text:e().optional(),image:t({data:e(),mediaType:e()}).optional(),app:e().optional(),error:e().optional()}),J=t({type:r("credential"),token:e().min(1)}),K=t({type:r("exec"),id:e(),code:e(),cwd:e().optional(),env:s(e(),e()).optional(),timeoutSeconds:o().positive(),outputLimitBytes:o().positive()}),X=t({type:r("hello"),sandbox:e().min(1),hostname:e().optional(),platform:e().optional(),computer:i().optional(),mcp:n(e()).optional(),instance:e().optional(),force:i().optional(),specs:t({vcpu:o().positive(),memoryMb:o().positive(),storageGb:o().positive().optional()}).optional().catch(void 0)}),Y=t({type:r("mcp-call"),id:e(),server:e(),tool:e(),args:s(e(),c())}),q=t({type:r("mcp-list"),id:e(),server:e()}),Z=t({type:r("mcp-result"),id:e(),result:u({content:n(c())}).optional(),error:e().optional()}),V=t({type:r("mcp-tools"),id:e(),tools:n(u({name:e(),inputSchema:s(e(),c())})).optional(),error:e().optional()}),ee=t({type:r("ready"),sandboxId:e(),expiresInMs:o().optional()}),te=t({type:r("result"),id:e(),exitCode:o().nullable(),stdout:e(),stderr:e(),durationMs:o(),timedOut:i(),truncated:i()}),oe=R("type",[G,K,Y,q,ee]),xe=R("type",[W,J,X,Z,V,te]);function z(a){let l=new URL(U,a);return l.protocol=l.protocol==="https:"?"wss:":"ws:",l.toString()}function I(a){return re(oe,a)}function re(a,l){if(typeof l!=="string")return null;try{let y=a.safeParse(JSON.parse(l));return y.success?y.data:null}catch{return null}}var de=new Set([C.occupied.code,C.replaced.code,C.unauthorized.code,C.unknownSandbox.code]),j=72,T=30000,D=1000;function me(a,l,y){return new Promise((g)=>{let h=A.now(),f=new L(a.outputLimitBytes),x=new L(a.outputLimitBytes),b=!1,v=!1,F=(m,p)=>{if(v)return;if(v=!0,clearTimeout(E),y?.removeEventListener("abort",_),p)x.append(Buffer.from(`${p}
2
- `));g({type:"result",id:a.id,exitCode:m,stdout:f.text(),stderr:x.text(),durationMs:Math.round(A.now()-h),timedOut:b,truncated:f.truncated||x.truncated})},M=ne("bash",["-lc",a.code],{cwd:a.cwd??l,env:{...N(),...a.env},detached:!0,stdio:["ignore","pipe","pipe"]}),S=()=>{if(!M.pid)return;try{process.kill(-M.pid,"SIGKILL")}catch{M.kill("SIGKILL")}},E=setTimeout(()=>{b=!0,S()},a.timeoutSeconds*1000),_=()=>{S(),F(null,"stopped: the daemon closed its socket")};if(y?.addEventListener("abort",_,{once:!0}),M.stdout.on("data",(m)=>f.append(m)),M.stderr.on("data",(m)=>x.append(m)),M.on("error",(m)=>F(null,m.message)),M.on("close",(m)=>F(m)),y?.aborted)_()})}async function Oe(a){let l=ie(),y=crypto.randomUUID(),g=a.mcpFile?await ge(a.mcpFile,a.log):null,h=a.computer?await fe(a.log):null,f=D;try{while(!a.signal.aborted){let x=Date.now(),b;try{b=await a.credential()}catch(F){if(F instanceof O)throw F;a.log(`stage session unavailable (${F instanceof Error?F.message:String(F)}), retrying in ${Math.round(f/1000)}s`),await Q(f,a.signal),f=Math.min(f*2,T);continue}let v=await Me(a,b,y,l,h,g);if(a.signal.aborted)return;if(de.has(v.code))throw Error(v.reason||`core closed the socket (${v.code})`);if(Date.now()-x>T)f=D;a.log(`disconnected (${v.reason||v.code}), reconnecting in ${Math.round(f/1000)}s`),await Q(f,a.signal),f=Math.min(f*2,T)}}finally{h?.stop(),await g?.stop()}}class L{#o=[];#e;#t=0;truncated=!1;constructor(a){this.#e=a}append(a){if(this.#t>=this.#e){this.truncated=!0;return}let l=this.#e-this.#t;if(a.byteLength>l){this.#o.push(a.subarray(0,l)),this.#t=this.#e,this.truncated=!0;return}this.#o.push(a),this.#t+=a.byteLength}text(){let a=Buffer.concat(this.#o).toString("utf8");return this.truncated?`${a}
3
- [output truncated]`:a}}function ue(a){let l=[a.action];if(a.coordinate)l.push(`at ${a.coordinate.join(",")}`);if(a.text!==void 0)l.push(JSON.stringify(H(a.text)));if(a.region)l.push(`region ${a.region.join(",")}`);return l.join(" ")}function he(){let a=ye();return{vcpu:ae(),memoryMb:Math.round(pe()/1048576),...a?{storageGb:a}:{}}}function ye(){try{let a=se(ce());return Math.round(a.blocks*a.bsize/1073741824)}catch{return}}function H(a){let l=a.trim().split(`
4
- `)[0]??"";return l.length>j?`${l.slice(0,j)}…`:l}async function fe(a){let{startDesktop:l}=await import("./chunk-5tnnqapc.js"),{display:y,driver:g,permissions:h}=await l(!1);if(a(`computer use on, ${y.width}x${y.height} screenshots`),!h.screenRecording||!h.accessibility)a(" screen recording or accessibility is missing, run `broods machine --doctor --request`");return g}async function ge(a,l){let{McpHost:y,readMcpServersFile:g}=await import("./chunk-pfvvdwms.js"),h=new y(g(a),l);return l(`mcp servers from ${a}: ${h.names().join(", ")}`),h}async function be(a,l,y){try{if(a.type==="mcp-list"){let h=await l.listTools(a.server);return y(` mcp ${a.server}: ${h.length} tools`),{type:"mcp-tools",id:a.id,tools:h}}y(` mcp ${a.server}.${a.tool}`);let g=await l.callTool(a.server,a.tool,a.args);return{type:"mcp-result",id:a.id,result:g}}catch(g){let h=g instanceof Error?g.message:String(g);return y(` mcp ${a.server}: ${h}`),{type:a.type==="mcp-call"?"mcp-result":"mcp-tools",id:a.id,error:h}}}function Me(a,l,y,g,h,f){return new Promise((x)=>{let b=new g(z(a.baseUrl),k(l)),v=new AbortController,F=()=>b.close(1000,"daemon stopped"),M=(m)=>{if(b.readyState===b.OPEN)b.send(JSON.stringify(m))},S,E=(m)=>{if(clearTimeout(S),v.signal.aborted)return;S=setTimeout(()=>{a.credential().then((p)=>M({type:"credential",token:p}),(p)=>a.log(`credential refresh failed (${p instanceof Error?p.message:String(p)}), retrying`)).finally(()=>E(m))},Math.max((m-Date.now())/2,D))},_=(m,p)=>{a.signal.removeEventListener("abort",F),clearTimeout(S),v.abort(),x({code:m,reason:p})};a.signal.addEventListener("abort",F,{once:!0}),b.onopen=()=>M({type:"hello",sandbox:a.sandbox,hostname:le(),platform:process.platform,computer:h!==null,mcp:f?.names(),instance:y,force:a.force,specs:he()}),b.onmessage=(m)=>{let p=I(m.data);if(p?.type==="ready"){if(S===void 0)a.log(`connected as ${a.sandbox} (${p.sandboxId})`);if(p.expiresInMs!==void 0)E(Date.now()+p.expiresInMs);return}if(p?.type==="computer"&&h){a.log(` ${ue(p)}`),h.run(p).then((w)=>{if(w.error)a.log(` error: ${w.error}`);M(w)});return}if((p?.type==="mcp-call"||p?.type==="mcp-list")&&f){be(p,f,a.log).then(M);return}if(p?.type!=="exec")return;a.log(`$ ${H(p.code)}`),me(p,a.cwd,v.signal).then((w)=>{a.log(` exit ${w.exitCode??"none"} in ${w.durationMs}ms${w.timedOut?" (timed out)":""}`),M(w)})},b.onerror=()=>_(1006,"connection failed"),b.onclose=(m)=>_(m.code,m.reason)})}export{Oe as runMachineDaemon};
1
+ import{O,E}from"./chunk-njamyfye.js";import{e,o,i,c,n,t,u,w,s,d,r}from"./chunk-zx8r5k20.js";import{Q,se,x}from"./cli/index.js";import{spawn as ne}from"node:child_process";import{statfsSync as ie}from"node:fs";import{availableParallelism as ae,homedir as ce,hostname as le,totalmem as pe}from"node:os";import{performance as j}from"node:perf_hooks";var P=["cursor_position","double_click","hold_key","key","left_click","left_click_drag","left_mouse_down","left_mouse_up","middle_click","mouse_move","right_click","screenshot","scroll","triple_click","type","wait","zoom"];var T={badFrame:{code:4400,reason:"Malformed frame"},expired:{code:4419,reason:"Credential expired"},occupied:{code:4423,reason:"Already connected from another daemon"},replaced:{code:4409,reason:"Replaced by a newer connection"},unauthorized:{code:4401,reason:"Unauthorized; run broods login"},unknownSandbox:{code:4404,reason:"No machine sandbox with that name in this account"}};var U="/v1/machines/ws",B=t({action:d(P),coordinate:n(o().int()).length(2).optional().describe("[x, y] in screenshot pixels for mouse actions."),start_coordinate:n(o().int()).length(2).optional().describe("[x, y] where a left_click_drag starts."),text:e().optional().describe("Text for type, the key chord for key and hold_key, or modifiers to hold during a click, drag or scroll."),scroll_direction:d(["down","left","right","up"]).optional(),scroll_amount:o().int().min(1).optional().describe("Scroll clicks, default 3."),duration:o().min(0).max(300).optional().describe("Seconds for wait and hold_key."),region:n(o().int()).length(4).optional().describe("[x0, y0, x1, y1] of the screenshot to zoom into."),repeat:o().int().min(1).max(100).optional().describe("How many times to press the key.")}),G=B.extend({type:r("computer"),id:e()}),W=t({type:r("computer-result"),id:e(),text:e().optional(),image:t({data:e(),mediaType:e()}).optional(),app:e().optional(),error:e().optional()}),J=t({type:r("credential"),token:e().min(1)}),K=t({type:r("exec"),id:e(),code:e(),cwd:e().optional(),env:s(e(),e()).optional(),timeoutSeconds:o().positive(),outputLimitBytes:o().positive()}),X=t({type:r("hello"),sandbox:e().min(1),hostname:e().optional(),platform:e().optional(),computer:i().optional(),mcp:n(e()).optional(),instance:e().optional(),force:i().optional(),specs:t({vcpu:o().positive(),memoryMb:o().positive(),storageGb:o().positive().optional()}).optional().catch(void 0)}),Y=t({type:r("mcp-call"),id:e(),server:e(),tool:e(),args:s(e(),c())}),q=t({type:r("mcp-list"),id:e(),server:e()}),Z=t({type:r("mcp-result"),id:e(),result:u({content:n(c())}).optional(),error:e().optional()}),V=t({type:r("mcp-tools"),id:e(),tools:n(u({name:e(),inputSchema:s(e(),c())})).optional(),error:e().optional()}),ee=t({type:r("ready"),sandboxId:e(),expiresInMs:o().optional()}),te=t({type:r("result"),id:e(),exitCode:o().nullable(),stdout:e(),stderr:e(),durationMs:o(),timedOut:i(),truncated:i()}),oe=w("type",[G,K,Y,q,ee]),xe=w("type",[W,J,X,Z,V,te]);function I(a){let l=new URL(U,a);return l.protocol=l.protocol==="https:"?"wss:":"ws:",l.toString()}function A(a){return re(oe,a)}function re(a,l){if(typeof l!=="string")return null;try{let y=a.safeParse(JSON.parse(l));return y.success?y.data:null}catch{return null}}var de=new Set([T.occupied.code,T.replaced.code,T.unauthorized.code,T.unknownSandbox.code]),H=72,R=30000,L=1000;function me(a,l,y){return new Promise((g)=>{let h=j.now(),f=new z(a.outputLimitBytes),k=new z(a.outputLimitBytes),b=!1,v=!1,F=(m,p)=>{if(v)return;if(v=!0,clearTimeout(D),y?.removeEventListener("abort",C),p)k.append(Buffer.from(`${p}
2
+ `));g({type:"result",id:a.id,exitCode:m,stdout:f.text(),stderr:k.text(),durationMs:Math.round(j.now()-h),timedOut:b,truncated:f.truncated||k.truncated})},M=ne("bash",["-lc",a.code],{cwd:a.cwd??l,env:{...O(),...a.env},detached:!0,stdio:["ignore","pipe","pipe"]}),_=()=>{if(!M.pid)return;try{process.kill(-M.pid,"SIGKILL")}catch{M.kill("SIGKILL")}},D=setTimeout(()=>{b=!0,_()},a.timeoutSeconds*1000),C=()=>{_(),F(null,"stopped: the daemon closed its socket")};if(y?.addEventListener("abort",C,{once:!0}),M.stdout.on("data",(m)=>f.append(m)),M.stderr.on("data",(m)=>k.append(m)),M.on("error",(m)=>F(null,m.message)),M.on("close",(m)=>F(m)),y?.aborted)C()})}async function Oe(a){let l=se(),y=crypto.randomUUID(),g=a.mcpFile?await ge(a.mcpFile,a.log):null,h=a.computer?await fe(a.log):null,f=L;try{while(!a.signal.aborted){let k=Date.now(),b;try{b=await a.credential()}catch(F){if(F instanceof x)throw F;a.log(`stage session unavailable (${F instanceof Error?F.message:String(F)}), retrying in ${Math.round(f/1000)}s`),await Q(f,a.signal),f=Math.min(f*2,R);continue}let v=await Me(a,b,y,l,h,g);if(a.signal.aborted)return;if(de.has(v.code))throw Error(v.reason||`core closed the socket (${v.code})`);if(Date.now()-k>R)f=L;a.log(`disconnected (${v.reason||v.code}), reconnecting in ${Math.round(f/1000)}s`),await Q(f,a.signal),f=Math.min(f*2,R)}}finally{h?.stop(),await g?.stop()}}class z{#o=[];#e;#t=0;truncated=!1;constructor(a){this.#e=a}append(a){if(this.#t>=this.#e){this.truncated=!0;return}let l=this.#e-this.#t;if(a.byteLength>l){this.#o.push(a.subarray(0,l)),this.#t=this.#e,this.truncated=!0;return}this.#o.push(a),this.#t+=a.byteLength}text(){let a=Buffer.concat(this.#o).toString("utf8");return this.truncated?`${a}
3
+ [output truncated]`:a}}function ue(a){let l=[a.action];if(a.coordinate)l.push(`at ${a.coordinate.join(",")}`);if(a.text!==void 0)l.push(JSON.stringify(N(a.text)));if(a.region)l.push(`region ${a.region.join(",")}`);return l.join(" ")}function he(){let a=ye();return{vcpu:ae(),memoryMb:Math.round(pe()/1048576),...a?{storageGb:a}:{}}}function ye(){try{let a=ie(ce());return Math.round(a.blocks*a.bsize/1073741824)}catch{return}}function N(a){let l=a.trim().split(`
4
+ `)[0]??"";return l.length>H?`${l.slice(0,H)}…`:l}async function fe(a){let{startDesktop:l}=await import("./chunk-5tnnqapc.js"),{display:y,driver:g,permissions:h}=await l(!1);if(a(`computer use on, ${y.width}x${y.height} screenshots`),!h.screenRecording||!h.accessibility)a(" screen recording or accessibility is missing, run `broods machine --doctor --request`");return g}async function ge(a,l){let{McpHost:y,readMcpServersFile:g}=await import("./chunk-5njt640x.js"),h=new y(g(a),l);return l(`mcp servers from ${a}: ${h.names().join(", ")}`),h}async function be(a,l,y){try{if(a.type==="mcp-list"){let h=await l.listTools(a.server);return y(` mcp ${a.server}: ${h.length} tools`),{type:"mcp-tools",id:a.id,tools:h}}y(` mcp ${a.server}.${a.tool}`);let g=await l.callTool(a.server,a.tool,a.args);return{type:"mcp-result",id:a.id,result:g}}catch(g){let h=g instanceof Error?g.message:String(g);return y(` mcp ${a.server}: ${h}`),{type:a.type==="mcp-call"?"mcp-result":"mcp-tools",id:a.id,error:h}}}function Me(a,l,y,g,h,f){return new Promise((k)=>{let b=new g(I(a.baseUrl),E(l)),v=new AbortController,F=()=>b.close(1000,"daemon stopped"),M=(m)=>{if(b.readyState===b.OPEN)b.send(JSON.stringify(m))},_,D=(m)=>{if(clearTimeout(_),v.signal.aborted)return;_=setTimeout(()=>{a.credential().then((p)=>M({type:"credential",token:p}),(p)=>a.log(`credential refresh failed (${p instanceof Error?p.message:String(p)}), retrying`)).finally(()=>D(m))},Math.max((m-Date.now())/2,L))},C=(m,p)=>{a.signal.removeEventListener("abort",F),clearTimeout(_),v.abort(),k({code:m,reason:p})};a.signal.addEventListener("abort",F,{once:!0}),b.onopen=()=>M({type:"hello",sandbox:a.sandbox,hostname:le(),platform:process.platform,computer:h!==null,mcp:f?.names(),instance:y,force:a.force,specs:he()}),b.onmessage=(m)=>{let p=A(m.data);if(p?.type==="ready"){if(_===void 0)a.log(`connected as ${a.sandbox} (${p.sandboxId})`);if(p.expiresInMs!==void 0)D(Date.now()+p.expiresInMs);return}if(p?.type==="computer"&&h){a.log(` ${ue(p)}`),h.run(p).then((S)=>{if(S.error)a.log(` error: ${S.error}`);M(S)});return}if((p?.type==="mcp-call"||p?.type==="mcp-list")&&f){be(p,f,a.log).then(M);return}if(p?.type!=="exec")return;a.log(`$ ${N(p.code)}`),me(p,a.cwd,v.signal).then((S)=>{a.log(` exit ${S.exitCode??"none"} in ${S.durationMs}ms${S.timedOut?" (timed out)":""}`),M(S)})},b.onerror=()=>C(1006,"connection failed"),b.onclose=(m)=>C(m.code,m.reason)})}export{Oe as runMachineDaemon};
@@ -0,0 +1,58 @@
1
+ function je(p){let f=Object.values(p).filter((h)=>typeof h==="number");return Object.entries(p).filter(([h,g])=>f.indexOf(+h)===-1).map(([h,g])=>g)}function Rt(p,f="|"){return p.map((m)=>Lt(m)).join(f)}function Le(p,f){if(typeof f==="bigint")return f.toString();return f}class nn{constructor(p){this._getter=p,this._value=void 0}get value(){let p=this._getter;if(p!==void 0)this._value=p(),this._getter=void 0;return this._value}}function Fe(p){return new nn(p)}function on(p){return p===null||p===void 0}function rt(p){let f=p.startsWith("^")?1:0,m=p.endsWith("$")?p.length-1:p.length;return p.slice(f,m)}function sn(p,f){let m=p/f,h=Math.round(m),g=4*Number.EPSILON*Math.max(Math.abs(m),1);if(Math.abs(m-h)<g)return 0;return m-h}var rn=Symbol("evaluating");function cn(p,f,m){let h=void 0;Object.defineProperty(p,f,{get(){if(h===rn)return;if(h===void 0)h=rn,h=m();return h},set(g){Object.defineProperty(p,f,{value:g})},configurable:!0})}function ie(p,f,m){Object.defineProperty(p,f,{value:m,writable:!0,enumerable:!0,configurable:!0})}function Me(p){let f=Object.getOwnPropertyDescriptor(p,"shape");return f?.get?f.get.raw:f?.value}function ve(p){return Me(p._zod.def)??p._zod.def.shape}function un(p,f,m){Object.defineProperty(p,f,{get(){let h=m();return ie(this,f,h),h},enumerable:!0,configurable:!0})}function an(p,f,m){if(f in p)ie(p,f,m);else p[f]=m}function Pe(p,f,m,h){let g=ve(f);for(let _ of m){let x=Object.getOwnPropertyDescriptor(g,_);if(!x.enumerable)continue;if(x.get)un(p,_,()=>{let y=f._zod.def.shape[_];return h?h(y,_):y});else an(p,_,h?h(x.value,_):x.value)}}function Sc(p,f){for(let m of Reflect.ownKeys(f)){let h=Object.getOwnPropertyDescriptor(f,m);if(!h.enumerable)continue;if(h.get)un(p,m,()=>f[m]);else an(p,m,h.value)}}function se(...p){let f={};for(let m of p){let h=Object.getOwnPropertyDescriptors(m);Object.assign(f,h)}return Object.defineProperties({},f)}function ln(p){return JSON.stringify(p)}function pn(p){return p.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Dt="captureStackTrace"in Error?Error.captureStackTrace:(...p)=>{};function Ae(p){return typeof p==="object"&&p!==null&&!Array.isArray(p)}var fn=Fe(()=>{if(ee.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(p){return!1}});function Se(p){if(Ae(p)===!1)return!1;let f=p.constructor;if(f===void 0)return!0;if(typeof f!=="function")return!0;let m=f.prototype;if(Ae(m)===!1)return!1;if(Object.prototype.hasOwnProperty.call(m,"isPrototypeOf")===!1)return!1;return!0}function jt(p){if(Se(p))return{...p};if(Array.isArray(p))return[...p];if(p instanceof Map)return new Map(p);if(p instanceof Set)return new Set(p);return p}var dn=new Set(["string","number","symbol"]);function we(p){return p.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function _e(p,f,m){let h=new p._zod.constr(f??p._zod.def);if(!f||m?.parent)h._zod.parent=p;return h}function E(p){let f=p;if(!f)return{};if(typeof f==="string")return{error:()=>f};if(f?.message!==void 0){if(f?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");f.error=f.message}if(delete f.message,typeof f.error==="string")return{...f,error:()=>f.error};return f}function Lt(p){if(typeof p==="bigint")return p.toString()+"n";if(typeof p==="string")return`"${p}"`;return`${p}`}function mn(p){return Object.keys(p).filter((f)=>p[f]._zod.optin!==void 0&&p[f]._zod.optout==="optional")}var nt=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),Ft={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Oc(p,f){let m=p._zod.def,h=m.checks;if(h&&h.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let _={};return Pe(_,p,ot(p,f)),_e(p,se(m,{shape:_,checks:[]}))}function ot(p,f){let m=ve(p),h=[];for(let g of Reflect.ownKeys(f)){if(!Object.getOwnPropertyDescriptor(m,g)?.enumerable)throw Error(`Unrecognized key: "${String(g)}"`);if(f[g])h.push(g)}return h}function Ic(p,f){let m=p._zod.def,h=m.checks;if(h&&h.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let _=new Set(ot(p,f)),x={};return Pe(x,p,Reflect.ownKeys(ve(p)).filter((y)=>!_.has(y))),_e(p,se(m,{shape:x,checks:[]}))}function Ac(p,f){if(!Se(f))throw Error("Invalid input to extend: expected a plain object");let m=p._zod.def.checks;if(m&&m.length>0){let g=ve(p);for(let _ of Reflect.ownKeys(f))if(Object.getOwnPropertyDescriptor(g,_)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return _e(p,se(p._zod.def,{shape:hn(p,f)}))}function hn(p,f){let m={};return Pe(m,p,Reflect.ownKeys(ve(p))),Sc(m,f),m}function Ec(p,f){if(!Se(f))throw Error("Invalid input to safeExtend: expected a plain object");return _e(p,se(p._zod.def,{shape:hn(p,f)}))}function Tc(p,f){if(!f?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(p._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let m={};Pe(m,p,Reflect.ownKeys(ve(p))),Pe(m,f,Reflect.ownKeys(ve(f)));let h=se(p._zod.def,{shape:m,get catchall(){return f._zod.def.catchall},checks:f._zod.def.checks??[]});return _e(p,h)}function gn(p,f,m,h="partial"){let _=f._zod.def.checks;if(_&&_.length>0)throw Error(`.${h}() cannot be used on object schemas containing refinements`);let y=m?new Set(ot(f,m)):void 0,b={};return Pe(b,f,Reflect.ownKeys(ve(f)),p&&((v,k)=>y&&!y.has(k)?v:new p({type:"optional",innerType:v}))),_e(f,se(f._zod.def,{shape:b,checks:[]}))}function Nc(p,f,m){let h=m?new Set(ot(f,m)):void 0,g={};return Pe(g,f,Reflect.ownKeys(ve(f)),(_,x)=>h&&!h.has(x)?_:new p({type:"nonoptional",innerType:_})),_e(f,se(f._zod.def,{shape:g}))}function xe(p,f=0){if(p.aborted===!0)return!0;for(let m=f;m<p.issues.length;m++)if(p.issues[m]?.continue!==!0)return!0;return!1}function _n(p,f=0){if(p.aborted===!0)return!0;for(let m=f;m<p.issues.length;m++)if(p.issues[m]?.continue===!1)return!0;return!1}function ke(p,f){return f.map((m)=>{var h;return(h=m).path??(h.path=[]),m.path.unshift(p),m})}function De(p){return typeof p==="string"?p:p?.message}function Mt(p){let f=[];for(let m of p??[]){let h=m._zod.def;if(!/_(length|size)$|_equals$/.test(h.check))break;let g=h.maximum??h.length??h.size;if(g>=0)f.push([g,m])}return f}function it(p,f,m){var h;for(let g=f;g<p.length;g++)(h=p[g]).schema??(h.schema=m)}function ye(p,f,m){var h;let g=p.inst?._zod?.traits;if(g?.has("$ZodType"))if(g.has("$ZodCheck"))(h=p).schema??(h.schema=p.inst);else p.schema=p.inst;let _=p.schema!==p.inst?p.schema?._zod.def?.error:void 0,x=p.message?p.message:De(p.inst?._zod.def?.error?.(p))??De(_?.(p))??De(f?.error?.(p))??De(m.customError?.(p))??De(m.localeError?.(p))??"Invalid input",y={};for(let b of Object.keys(p)){if(b==="inst"||b==="schema"||b==="continue"||b==="input"||b==="__proto__")continue;y[b]=p[b]}if(y.path??(y.path=[]),y.message=x,f?.reportInput)y.input=p.input;return y}var Cc=/[\uD800-\uDBFF]/;function st(p){let f=p.length;if(!Cc.test(p))return f;let m=f;for(let h=0;h<f-1;h++)if((p.charCodeAt(h)&64512)===55296&&(p.charCodeAt(h+1)&64512)===56320)m--,h++;return m}function ct(p){if(Array.isArray(p))return"array";if(typeof p==="string")return"string";return"unknown"}function xn(p){let f=typeof p;switch(f){case"number":return Number.isNaN(p)?"nan":"number";case"object":{if(p===null)return"null";if(Array.isArray(p))return"array";let m=p;if(m&&Object.getPrototypeOf(m)!==Object.prototype&&"constructor"in m&&m.constructor)return m.constructor.name}}return f}function Oe(...p){let[f,m,h]=p;if(typeof f==="string")return{message:f,code:"custom",input:m,inst:h};return{...f}}function yn(p,f){for(let m in f){let h=Object.getOwnPropertyDescriptor(f,m);if(h.get)Object.defineProperty(p,m,{...h,enumerable:!1});else Rc(p,m,h.value)}}function ze(p,f,m,h=!0){return Object.defineProperty(p,f,{configurable:!0,writable:!0,enumerable:h,value:m}),m}function ut(p,f,m){return ze(p,f,m,!1)}function bn(p,f){for(let m in p){let h=p[m];Object.defineProperty(f,m,{configurable:!0,enumerable:!0,get(){return ze(this,m,h(this))},set(g){ze(this,m,g)}})}return f}function Rc(p,f,m){Object.defineProperty(p,f,{configurable:!0,get(){return this==null?m:ze(this,f,m.bind(this))},set(h){ze(this,f,h)}})}function Dc(p,f){let m=Object.getPrototypeOf(p);return f in m?void 0:m}var Ct,$e=!1,jc={configurable:!0,get(){$e=!0;return}};function C(p,f,m){let h=Object.getPrototypeOf(p._zod);if(f in h&&Ct!==p._zod){Ct=void 0;return}Ct=p._zod,Object.defineProperty(h,f,{configurable:!0,get(){Object.defineProperty(this,f,jc);let g=$e;$e=!1;try{let _=m(this);if($e)delete this[f];else Object.defineProperty(this,f,{configurable:!0,writable:!0,value:_});return $e=$e||g,_}catch(_){throw delete this[f],$e=$e||g,_}},set(g){Object.defineProperty(this,f,{configurable:!0,writable:!0,value:g})}})}function Lc(p,f,m,h){let g=Dc(p,f);if(!g)return;Object.defineProperty(g,f,{configurable:!0,get(){let _={configurable:!0,writable:!0,enumerable:h,value:void 0};return Object.defineProperty(this,f,_),_.value=m(this),Object.defineProperty(this,f,_),_.value},set(_){Object.defineProperty(this,f,{configurable:!0,writable:!0,enumerable:h,value:_})}})}var Fc="~constantCatch";function vn(p){let f=()=>p;return f[Fc]=!0,f}var zn,ce=Object.freeze({status:"aborted"}),Ut={value:void 0,enumerable:!1},$n="captureStackTrace"in Error?Error:null;function Mc(p){let f=$n;if(f){let m=f.stackTraceLimit;if(typeof m==="number"){try{f.stackTraceLimit=0}catch{return $n=null,new p}try{return new p}finally{f.stackTraceLimit=m}}}return new p}function Z(p,f,m,h){let g={};function _(O){this.def=O,this.constr=S,this.traits=new Set}_.prototype=g;let x=m,y=x&&new WeakSet;function b(O,I){if(!O._zod){Ut.value=new _(I);try{Object.defineProperty(O,"_zod",Ut)}finally{Ut.value=void 0}}else if(O._zod.traits.has(p))return;if(O._zod.traits.add(p),f(O,I),y){let T=Object.getPrototypeOf(O),N=O._zod.constr.prototype,D=T;while(D&&D!==N)D=Object.getPrototypeOf(D);let fe=D??T;if(!y.has(fe))y.add(fe),yn(fe,x)}let A=S.prototype;for(let T in A){if(!Object.prototype.hasOwnProperty.call(A,T))continue;if(!(T in O))O[T]=A[T].bind(O)}}let v=h?.Parent??Object;class k extends v{}Object.defineProperty(k,"name",{value:p});function S(O){let I=h?.Parent?Mc(k):this;b(I,O);let A=I._zod.deferred;if(A){for(let N of A)N();I._zod.deferred=void 0}let T=globalThis.__zod_globalConfig?.postProcessor;if(T)T(I);return I}return Object.defineProperty(S,"init",{value:b}),Object.defineProperty(S,Symbol.hasInstance,{value:(O)=>{if(h?.Parent&&O instanceof h.Parent)return!0;return O?._zod?.traits?.has(p)}}),Object.defineProperty(S,"name",{value:p}),S}class be extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ue extends Error{constructor(p){super(`Encountered unidirectional transform during encode: ${p}`);this.name="ZodEncodeError"}}(zn=globalThis).__zod_globalConfig??(zn.__zod_globalConfig={});var ee=globalThis.__zod_globalConfig;function ae(p){if(p)Object.assign(ee,p);return ee}function Uc(){let p=this._zod;return p.message??(p.message=JSON.stringify(p.def,Le,2)),p.message}function Bc(p){this._zod.message=p}var Jc={get:Uc,set:Bc,enumerable:!0,configurable:!0},Jt={value:void 0,enumerable:!1},wn=new WeakSet([Object.prototype,Error.prototype]),kn=(p,f)=>{p.name="$ZodError",Jt.value=f,Object.defineProperty(p,"issues",Jt),Jt.value=void 0,Object.defineProperty(p,"message",Jc);let m=Object.getPrototypeOf(p);if(!wn.has(m))wn.add(m),Object.defineProperty(m,"toString",{configurable:!0,enumerable:!1,get(){let h=()=>this.message;return Object.defineProperty(this,"toString",{value:h,configurable:!0,writable:!0}),h},set(h){Object.defineProperty(this,"toString",{value:h,configurable:!0,writable:!0})}})},Zn=Z("$ZodError",kn),Aa=Z("$ZodError",kn,void 0,{Parent:Error});function Kc(p,f,m){if(!Object.prototype.hasOwnProperty.call(p,f))if(f==="__proto__")Object.defineProperty(p,f,{value:m(),writable:!0,enumerable:!0,configurable:!0});else p[f]=m();return p[f]}function Pn(p,f=(m)=>m.message){let m={},h=[];for(let g of p.issues)if(g.path.length>0)Kc(m,g.path[0],()=>[]).push(f(g));else h.push(f(g));return{formErrors:h,fieldErrors:m}}function Sn(p,f=(m)=>m.message){let m={_errors:[]},h=(g,_=[])=>{for(let x of g.issues)if(x.code==="invalid_union"&&x.errors.length)x.errors.map((y)=>h({issues:y},[..._,...x.path]));else if(x.code==="invalid_key")h({issues:x.issues},[..._,...x.path]);else if(x.code==="invalid_element")h({issues:x.issues},[..._,...x.path]);else{let y=[..._,...x.path];if(y.length===0)m._errors.push(f(x));else{let b=m,v=0;while(v<y.length){let k=y[v],S=v===y.length-1;if(k==="_errors"){if(S)b._errors.push(f(x));v++;continue}if(!Object.prototype.hasOwnProperty.call(b,k))Object.defineProperty(b,k,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let O=b[k];if(S)O._errors.push(f(x));b=O,v++}}}};return h(p),m}function Vc(p){let f=[],m=p.map((h)=>typeof h==="object"?h.key:h);for(let h of m)if(typeof h==="number")f.push(`[${h}]`);else if(typeof h==="symbol")f.push(`[${JSON.stringify(String(h))}]`);else if(/[^\w$]/.test(h))f.push(`[${JSON.stringify(h)}]`);else{if(f.length)f.push(".");f.push(h)}return f.join("")}function he(p){let f=[],m=[...p.issues].sort((h,g)=>(h.path??[]).length-(g.path??[]).length);for(let h of m)if(f.push(`✖ ${h.message}`),h.path?.length)f.push(` → at ${Vc(h.path)}`);return f.join(`
2
+ `)}function at(p,f){return{callee:f?.callee??p,Err:f?.Err}}var lt=(p)=>{let f=(m,h,g,_)=>{let x=g?{...g,async:!1}:{async:!1},y=m._zod.run({value:h,issues:[]},x);if(y instanceof Promise)throw new be;if(y.issues.length){let b=new(_?.Err??p)(y.issues.map((v)=>ye(v,x,ae())));throw Dt(b,_?.callee??f),b}return y.value};return f};var pt=(p)=>{let f=async(m,h,g,_)=>{let x=g?{...g,async:!0}:{async:!0},y=m._zod.run({value:h,issues:[]},x);if(y instanceof Promise)y=await y;if(y.issues.length){let b=new(_?.Err??p)(y.issues.map((v)=>ye(v,x,ae())));throw Dt(b,_?.callee??f),b}return y.value};return f};var ft=(p)=>(f,m,h)=>{let g=h?{...h,async:!1}:{async:!1},_=f._zod.run({value:m,issues:[]},g);if(_ instanceof Promise)throw new be;return _.issues.length?On(p,_.issues,g):{success:!0,data:_.value}};function On(p,f,m){let h;return{success:!1,get error(){if(!h)h=new p(f.map((g)=>ye(g,m,ae()))),f=void 0,m=void 0;return h},set error(g){h=g,f=void 0,m=void 0}}}var dt=(p)=>async(f,m,h)=>{let g=h?{...h,async:!0}:{async:!0},_=f._zod.run({value:m,issues:[]},g);if(_ instanceof Promise)_=await _;return _.issues.length?On(p,_.issues,g):{success:!0,data:_.value}};var Wc=Symbol.for("zod.compile.invalid"),Gc=Symbol.for("zod.compile.fallback"),Kt=(p,f,m)=>{let h=p._zod.bag.validator;if(h!==void 0){if(h(f)!==Wc)return!0;if(h.definite===!0&&m===void 0)return!1}return Xc(p,f,m)};function Xc(p,f,m){let h=m?{...m,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},g=p._zod.bag.fallbackRun,_;if(g)h[Gc]=!0,_=g({value:f,issues:[]},h);else _=p._zod.run({value:f,issues:[]},h);if(_ instanceof Promise)throw new be;return _.issues.length===0}var Vt=async(p,f,m)=>{let h=m?{...m,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},g=p._zod.run({value:f,issues:[]},h);if(g instanceof Promise)g=await g;return g.issues.length===0},In=(p)=>{let f=lt(p),m=(h,g,_,x)=>{let y=_?{..._,direction:"backward"}:{direction:"backward"};return f(h,g,y,at(m,x))};return m};var An=(p)=>{let f=lt(p),m=(h,g,_,x)=>f(h,g,_,at(m,x));return m};var En=(p)=>{let f=pt(p),m=async(h,g,_,x)=>{let y=_?{..._,direction:"backward"}:{direction:"backward"};return await f(h,g,y,at(m,x))};return m};var Tn=(p)=>{let f=pt(p),m=async(h,g,_,x)=>await f(h,g,_,at(m,x));return m};var Nn=(p)=>(f,m,h)=>{let g=h?{...h,direction:"backward"}:{direction:"backward"};return ft(p)(f,m,g)};var Cn=(p)=>(f,m,h)=>ft(p)(f,m,h);var Rn=(p)=>async(f,m,h)=>{let g=h?{...h,direction:"backward"}:{direction:"backward"};return dt(p)(f,m,g)};var Dn=(p)=>async(f,m,h)=>dt(p)(f,m,h);var jn=/^[cC][0-9a-z]{6,}$/,Ln=/^[0-9a-z]+$/,Fn=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Mn=/^[0-9a-vA-V]{20}$/,Un=/^[A-Za-z0-9]{27}$/,Bn=/^[a-zA-Z0-9_-]{21}$/;function Jn(p){return new RegExp(`^[a-zA-Z0-9_-]{${p}}$`)}var Kn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Vn=/^([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})$/,Gt=(p)=>{if(!p)return/^([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)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${p}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var Wn=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Yc="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Gn(){return new RegExp(Yc,"u")}var Xn=/^(?:(?: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])$/,Yn=/^(([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}|:))$/;var qn=/^((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])$/,Hn=/^(([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])$/,Qn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,eo=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var to=/^https?$/,ro=/^\+[1-9]\d{6,14}$/;var no="(?:(?:\\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 qc(p){return new RegExp(`^${p}$`)}var oo=qc(no);function Wt(p){return typeof p.precision==="number"?p.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":p.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${p.precision}}`:p.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function io(p){return new RegExp(`^${Wt(p)}$`)}function so(p){let f=["Z"];if(p.offset)f.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let m=`${Wt({precision:p.precision,seconds:!0})}(?:${f.join("|")})`,h=p.local?`${m}|${Wt({precision:p.precision})}`:m;return new RegExp(`^${no}T(?:${h})$`)}var co=/^[\s\S]{0,}$/;var Xt=/^-?\d+$/,Be=/^-?\d+(?:\.\d+)?$/,uo=/^(?:true|false)$/i,ao=/^null$/i;var lo=/^[^A-Z]*$/,po=/^[^a-z]*$/;var H=Z("$ZodCheck",(p,f)=>{var m;p._zod??(p._zod={}),p._zod.def=f,(m=p._zod).onattach??(m.onattach=[])});var Yt=(p)=>{let f=p.value;return!on(f)&&f.length!==void 0},mt={number:"number",bigint:"bigint",object:"date"},qt=Z("$ZodCheckLessThan",(p,f)=>{H.init(p,f);let m=mt[typeof f.value];p._zod.check=(h)=>{if(f.inclusive?h.value<=f.value:h.value<f.value)return;h.issues.push({origin:mt[typeof h.value]??m,code:"too_big",maximum:typeof f.value==="object"?f.value.getTime():f.value,input:h.value,inclusive:f.inclusive,inst:p,continue:!f.abort})}}),Ht=Z("$ZodCheckGreaterThan",(p,f)=>{H.init(p,f);let m=mt[typeof f.value];p._zod.check=(h)=>{if(f.inclusive?h.value>=f.value:h.value>f.value)return;h.issues.push({origin:mt[typeof h.value]??m,code:"too_small",minimum:typeof f.value==="object"?f.value.getTime():f.value,input:h.value,inclusive:f.inclusive,inst:p,continue:!f.abort})}}),fo=Z("$ZodCheckMultipleOf",(p,f)=>{H.init(p,f),p._zod.check=(m)=>{if(typeof m.value!==typeof f.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof m.value==="bigint"?f.value!==BigInt(0)&&m.value%f.value===BigInt(0):sn(m.value,f.value)===0)return;m.issues.push({origin:typeof m.value,code:"not_multiple_of",divisor:f.value,input:m.value,inst:p,continue:!f.abort})}}),mo=Z("$ZodCheckNumberFormat",(p,f)=>{H.init(p,f),f.format=f.format||"float64";let m=f.format?.includes("int"),h=m?"int":"number",[g,_]=nt[f.format];p._zod.check=(x)=>{let y=x.value;if(m){if(!Number.isInteger(y)){x.issues.push({expected:h,format:f.format,code:"invalid_type",continue:!1,input:y,inst:p});return}if(!Number.isSafeInteger(y)){if(y>0)x.issues.push({input:y,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:p,origin:h,inclusive:!0,continue:!f.abort});else x.issues.push({input:y,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:p,origin:h,inclusive:!0,continue:!f.abort});return}}if(y<g)x.issues.push({origin:"number",input:y,code:"too_small",minimum:g,inclusive:!0,inst:p,continue:!f.abort});if(y>_)x.issues.push({origin:"number",input:y,code:"too_big",maximum:_,inclusive:!0,inst:p,continue:!f.abort})}});var ho=Z("$ZodCheckMaxLength",(p,f)=>{var m;H.init(p,f),(m=p._zod.def).when??(m.when=Yt),p._zod.check=(h)=>{let g=h.value,_=g.length;if((typeof g==="string"&&_>f.maximum?st(g):_)<=f.maximum)return;let y=ct(g);h.issues.push({origin:y,code:"too_big",maximum:f.maximum,inclusive:!0,input:g,inst:p,continue:!f.abort})}}),go=Z("$ZodCheckMinLength",(p,f)=>{var m;H.init(p,f),(m=p._zod.def).when??(m.when=Yt),p._zod.check=(h)=>{let g=h.value,_=g.length;if((typeof g==="string"&&_>=f.minimum&&_<f.minimum*2?st(g):_)>=f.minimum)return;let y=ct(g);h.issues.push({origin:y,code:"too_small",minimum:f.minimum,inclusive:!0,input:g,inst:p,continue:!f.abort})}}),_o=Z("$ZodCheckLengthEquals",(p,f)=>{var m;H.init(p,f),(m=p._zod.def).when??(m.when=Yt),p._zod.check=(h)=>{let g=h.value,_=g.length,x=typeof g==="string"&&_>=f.length&&_<=f.length*2?st(g):_;if(x===f.length)return;let y=ct(g),b=x>f.length;h.issues.push({origin:y,...b?{code:"too_big",maximum:f.length}:{code:"too_small",minimum:f.length},inclusive:!0,exact:!0,input:h.value,inst:p,continue:!f.abort})}}),Ke=Z("$ZodCheckStringFormat",(p,f)=>{var m,h;if(H.init(p,f),f.pattern)(m=p._zod).check??(m.check=(g)=>{if(f.pattern.lastIndex=0,f.pattern.test(g.value))return;g.issues.push({origin:"string",code:"invalid_format",format:f.format,input:g.value,...f.pattern?{pattern:f.pattern.toString()}:{},inst:p,continue:!f.abort})});else(h=p._zod).check??(h.check=()=>{})}),xo=Z("$ZodCheckRegex",(p,f)=>{Ke.init(p,f),p._zod.check=(m)=>{if(f.pattern.lastIndex=0,f.pattern.test(m.value))return;m.issues.push({origin:"string",code:"invalid_format",format:"regex",input:m.value,pattern:f.pattern.toString(),inst:p,continue:!f.abort})}}),yo=Z("$ZodCheckLowerCase",(p,f)=>{f.pattern??(f.pattern=lo),Ke.init(p,f)}),bo=Z("$ZodCheckUpperCase",(p,f)=>{f.pattern??(f.pattern=po),Ke.init(p,f)}),vo=Z("$ZodCheckIncludes",(p,f)=>{H.init(p,f);let m=we(f.includes),h=new RegExp(typeof f.position==="number"?`^.{${f.position},}${m}`:m);f.pattern=h,p._zod.check=(g)=>{if(g.value.includes(f.includes,f.position))return;g.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:f.includes,input:g.value,inst:p,continue:!f.abort})}}),zo=Z("$ZodCheckStartsWith",(p,f)=>{H.init(p,f);let m=new RegExp(`^${we(f.prefix)}.*`);f.pattern??(f.pattern=m),p._zod.check=(h)=>{if(h.value.startsWith(f.prefix))return;h.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:f.prefix,input:h.value,inst:p,continue:!f.abort})}}),$o=Z("$ZodCheckEndsWith",(p,f)=>{H.init(p,f);let m=new RegExp(`.*${we(f.suffix)}$`);f.pattern??(f.pattern=m),p._zod.check=(h)=>{if(h.value.endsWith(f.suffix))return;h.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:f.suffix,input:h.value,inst:p,continue:!f.abort})}});var wo=Z("$ZodCheckOverwrite",(p,f)=>{H.init(p,f),p._zod.check=(m)=>{m.value=f.tx(m.value)}});class Qt{constructor(p=[],f={}){this.content=[],this.indent=0,this.args=p,this.closed=f}indented(p){this.indent+=1;try{p(this)}finally{this.indent-=1}}write(p){if(typeof p==="function"){p(this,{execution:"sync"}),p(this,{execution:"async"});return}let m=p.split(`
3
+ `).filter((_)=>_),h=Math.min(...m.map((_)=>_.length-_.trimStart().length)),g=m.map((_)=>_.slice(h)).map((_)=>" ".repeat(this.indent*2)+_);for(let _ of g)this.content.push(_)}compile(){let p=Function,f=this?.content??[""];return new p(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
4
+ ${f.join(`
5
+ `)}
6
+ };`)(...Object.values(this.closed))}}var Zo={major:4,minor:6,patch:7};var L=Z("$ZodType",(p,f)=>{var m;p??(p={}),p._zod.def=f,p._zod.bag=p._zod.bag||{},p._zod.version=Zo;let h=p._zod.def.checks,g=p._zod.traits.has("$ZodCheck")?[p,...h??[]]:h?.length?[...h]:[];for(let _ of g)for(let x of _._zod.onattach)x(p);if(g.length===0)(m=p._zod).deferred??(m.deferred=[]),p._zod.deferred?.push(()=>{p._zod.run=p._zod.parse});else{let _=(y,b,v)=>{if(y.memo)return y;let k=xe(y),S;for(let O of b){if(O._zod.def.when){if(_n(y))continue;if(!O._zod.def.when(y))continue}else if(k)continue;let I=y.issues.length,A=O._zod.check(y);if(A instanceof Promise&&v?.async===!1)throw new be;if(S||A instanceof Promise)S=(S??Promise.resolve()).then(async()=>{if(await A,y.issues.length===I)return;if(it(y.issues,I,p),!k)k=xe(y,I)});else{if(y.issues.length===I)continue;if(it(y.issues,I,p),!k)k=xe(y,I)}}if(S)return S.then(()=>y);return y},x=(y,b,v)=>{if(xe(y))return y.aborted=!0,y;let k=_(b,g,v);if(k instanceof Promise){if(v.async===!1)throw new be;return k.then((S)=>p._zod.parse(S,v))}return p._zod.parse(k,v)};p._zod.run=(y,b)=>{if(b.skipChecks)return p._zod.parse(y,b);if(b.direction==="backward"){let k=p._zod.parse({value:y.value,issues:[]},{...b,skipChecks:!0});if(k instanceof Promise)return k.then((S)=>x(S,y,b));return x(k,y,b)}let v=p._zod.parse(y,b);if(v instanceof Promise){if(b.async===!1)throw new be;return v.then((k)=>_(k,g,b))}return _(v,g,b)}}},{get "~standard"(){return ut(this,"~standard",tr(this))},set "~standard"(p){ze(this,"~standard",p)}}),Do=(p,f)=>p.issues.length?{issues:p.issues.map((m)=>ye(m,f,ae()))}:{value:p.value};async function Hc(p,f){let m={async:!0};return Do(await p._zod.run({value:f,issues:[]},m),m)}function tr(p){return{validate:(f)=>{let m={async:!1};try{let h=p._zod.run({value:f,issues:[]},m);if(!(h instanceof Promise))return Do(h,m)}catch(h){}return Hc(p,f)},vendor:"zod",version:1}}var xt=Z("$ZodString",(p,f)=>{L.init(p,f),p._zod.pattern=f.pattern??co,p._zod.parse=(m,h)=>{if(f.coerce)try{m.value=String(m.value)}catch(g){}if(typeof m.value==="string")return m;return m.issues.push({expected:"string",code:"invalid_type",input:m.value,inst:p}),m}}),B=Z("$ZodStringFormat",(p,f)=>{Ke.init(p,f),xt.init(p,f)}),jo=Z("$ZodGUID",(p,f)=>{f.pattern??(f.pattern=Vn),B.init(p,f)}),Lo=Z("$ZodUUID",(p,f)=>{if(f.version){let h={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[f.version];if(h===void 0)throw Error(`Invalid UUID version: "${f.version}"`);f.pattern??(f.pattern=Gt(h))}else f.pattern??(f.pattern=Gt());B.init(p,f)}),Fo=Z("$ZodEmail",(p,f)=>{f.pattern??(f.pattern=Wn),B.init(p,f)}),Mo=1,gt=2;function Uo(p){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(p);return new URL(p),!0}catch{return!1}}function Qc(p,f){if(!("normalize"in f)&&!("hostname"in f)&&!("protocol"in f))return Uo(p)||gt;return eu(p,f)}function eu(p,f){if(!f.normalize&&f.protocol?.source===to.source&&!/^https?:\/\//i.test(p))return Mo;try{if(typeof URL<"u"){let m=URL;if(typeof m.parse==="function")return m.parse(p)??gt}return new URL(p)}catch{return gt}}var tu=/[\t\n\r]/g;function Po(p){return p.replace(tu,"")}function ru(p,f){return f.lastIndex=0,f.test(p.hostname)}function nu(p,f){return f.lastIndex=0,f.test(p.protocol.endsWith(":")?p.protocol.slice(0,-1):p.protocol)}var Bo=Z("$ZodURL",(p,f)=>{B.init(p,f),p._zod.check=(m)=>{try{let h=m.value.trim(),g=Qc(h,f);if(g===Mo){m.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:m.value,inst:p,continue:!f.abort});return}if(g===gt){m.issues.push({code:"invalid_format",format:"url",input:m.value,inst:p,continue:!f.abort});return}if(g===!0){m.value=Po(h);return}if(f.hostname&&!ru(g,f.hostname))m.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:f.hostname.source,input:m.value,inst:p,continue:!f.abort});if(f.protocol&&!nu(g,f.protocol))m.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:f.protocol.source,input:m.value,inst:p,continue:!f.abort});m.value=f.normalize?g.href:Po(h);return}catch(h){m.issues.push({code:"invalid_format",format:"url",input:m.value,inst:p,continue:!f.abort})}}}),Jo=Z("$ZodEmoji",(p,f)=>{f.pattern??(f.pattern=Gn()),B.init(p,f)}),Ko=Z("$ZodNanoID",(p,f)=>{if(f.length!==void 0&&(!Number.isInteger(f.length)||f.length<1))throw Error(`Invalid nanoid length: ${f.length}`);f.pattern??(f.pattern=f.length===void 0?Bn:Jn(f.length)),B.init(p,f)}),Vo=Z("$ZodCUID",(p,f)=>{f.pattern??(f.pattern=jn),B.init(p,f)}),Wo=Z("$ZodCUID2",(p,f)=>{f.pattern??(f.pattern=Ln),B.init(p,f)}),Go=Z("$ZodULID",(p,f)=>{f.pattern??(f.pattern=Fn),B.init(p,f)}),Xo=Z("$ZodXID",(p,f)=>{f.pattern??(f.pattern=Mn),B.init(p,f)}),Yo=Z("$ZodKSUID",(p,f)=>{f.pattern??(f.pattern=Un),B.init(p,f)}),qo=Z("$ZodISODateTime",(p,f)=>{f.pattern??(f.pattern=so(f)),B.init(p,f)}),Ho=Z("$ZodISODate",(p,f)=>{f.pattern??(f.pattern=oo),B.init(p,f)}),Qo=Z("$ZodISOTime",(p,f)=>{f.pattern??(f.pattern=io(f)),B.init(p,f)}),ei=Z("$ZodISODuration",(p,f)=>{f.pattern??(f.pattern=Kn),B.init(p,f)}),ti=Z("$ZodIPv4",(p,f)=>{f.pattern??(f.pattern=Xn),B.init(p,f)}),ou=/^[0-9a-fA-F:.]+$/;function ri(p){if(!ou.test(p))return!1;return Uo(`http://[${p}]`)}var ni=Z("$ZodIPv6",(p,f)=>{f.pattern??(f.pattern=Yn),B.init(p,f),p._zod.check=(m)=>{if(!ri(m.value))m.issues.push({code:"invalid_format",format:"ipv6",input:m.value,inst:p,continue:!f.abort})}});var oi=Z("$ZodCIDRv4",(p,f)=>{f.pattern??(f.pattern=qn),B.init(p,f)});function iu(p){let f=p.split("/");if(f.length!==2)return!1;let[m,h]=f;if(!h)return!1;let g=Number(h);if(`${g}`!==h)return!1;if(g<0||g>128)return!1;return ri(m)}var ii=Z("$ZodCIDRv6",(p,f)=>{f.pattern??(f.pattern=Hn),B.init(p,f),p._zod.check=(m)=>{if(!iu(m.value))m.issues.push({code:"invalid_format",format:"cidrv6",input:m.value,inst:p,continue:!f.abort})}});function si(p){if(p==="")return!0;if(/\s/.test(p))return!1;if(p.length%4!==0)return!1;try{return atob(p),!0}catch{return!1}}var rr=/^[0-9a-zA-Z+/]*={0,2}$/,ci=Z("$ZodBase64",(p,f)=>{f.pattern??(f.pattern=rr),B.init(p,f),p._zod.check=(m)=>{if(si(m.value))return;m.issues.push({code:"invalid_format",format:"base64",input:m.value,inst:p,continue:!f.abort})}}),yt=/^[A-Za-z0-9_-]*$/;function su(p){if(!yt.test(p))return!1;let f=p.replace(/[-_]/g,(h)=>h==="-"?"+":"/"),m=f.padEnd(Math.ceil(f.length/4)*4,"=");return si(m)}var ui=Z("$ZodBase64URL",(p,f)=>{f.pattern??(f.pattern=yt),B.init(p,f),p._zod.check=(m)=>{if(su(m.value))return;m.issues.push({code:"invalid_format",format:"base64url",input:m.value,inst:p,continue:!f.abort})}}),ai=Z("$ZodE164",(p,f)=>{f.pattern??(f.pattern=ro),B.init(p,f)});function cu(p,f=null){try{let m=p.split(".");if(m.length!==3)return!1;let[h]=m;if(!h)return!1;let g=JSON.parse(atob(h));if("typ"in g&&g?.typ!=="JWT")return!1;if(!g.alg)return!1;if(f&&(!("alg"in g)||g.alg!==f))return!1;return!0}catch{return!1}}var li=Z("$ZodJWT",(p,f)=>{B.init(p,f),p._zod.check=(m)=>{if(cu(m.value,f.alg))return;m.issues.push({code:"invalid_format",format:"jwt",input:m.value,inst:p,continue:!f.abort})}});var nr=Z("$ZodNumber",(p,f)=>{L.init(p,f),p._zod.pattern=Be,p._zod.parse=(m,h)=>{if(f.coerce)try{m.value=Number(m.value)}catch(x){}let g=m.value;if(typeof g==="number"&&!Number.isNaN(g)&&Number.isFinite(g))return m;let _=typeof g==="number"?Number.isNaN(g)?"NaN":!Number.isFinite(g)?String(g):void 0:void 0;return m.issues.push({expected:"number",code:"invalid_type",input:g,inst:p,..._?{received:_}:{}}),m}}),pi=Z("$ZodNumberFormat",(p,f)=>{mo.init(p,f),nr.init(p,f)}),fi=Z("$ZodBoolean",(p,f)=>{L.init(p,f),p._zod.pattern=uo,p._zod.parse=(m,h)=>{if(f.coerce)try{m.value=Boolean(m.value)}catch(_){}let g=m.value;if(typeof g==="boolean")return m;return m.issues.push({expected:"boolean",code:"invalid_type",input:g,inst:p}),m}});var di=Z("$ZodNull",(p,f)=>{L.init(p,f),p._zod.pattern=ao,p._zod.values=new Set([null]),p._zod.parse=(m,h)=>{let g=m.value;if(g===null)return m;return m.issues.push({expected:"null",code:"invalid_type",input:g,inst:p}),m}}),mi=Z("$ZodAny",(p,f)=>{L.init(p,f),p._zod.parse=(m)=>m}),hi=Z("$ZodUnknown",(p,f)=>{L.init(p,f),p._zod.parse=(m)=>m}),gi=Z("$ZodNever",(p,f)=>{L.init(p,f),p._zod.parse=(m,h)=>(m.issues.push({expected:"never",code:"invalid_type",input:m.value,inst:p}),m)});function uu(p,f){let m=Mt(p._zod.def.checks);if(!m.length)return;let h=Math.min(...m.map((_)=>_[0])),g=p._zod.parse;p._zod.parse=(_,x)=>{let y=f(_.value);if(y>h&&!x?.skipChecks&&x?.direction!=="backward"){for(let[b,v]of Mt(p._zod.def.checks))if(y>b&&v._zod.def.when(_)){let k=_.issues.length;return v._zod.check(_),_.issues[k].continue=!1,it(_.issues,k,p),_}}return g(_,x)}}var au=(p)=>Array.isArray(p)?p.length:-1;function So(p,f,m){if(p.issues.length)f.issues.push(...ke(m,p.issues));f.value[m]=p.value}var _i=Z("$ZodArray",(p,f)=>{L.init(p,f);let m=ee.memoizer;m?.attach(p),p._zod.parse=(h,g)=>{let _=h.value;if(!Array.isArray(_))return h.issues.push({expected:"array",code:"invalid_type",input:_,inst:p}),h;h.value=m?m.alloc(p,h,Array(_.length),g):Array(_.length);let x=[],y=g?.abortEarly;for(let b=0;b<_.length;b++){let v=_[b],k=f.element._zod.run({value:v,issues:[]},g);if(k instanceof Promise)x.push(k.then((S)=>So(S,h,b)));else if(So(k,h,b),y&&k.issues.length!==0&&xe(k))break}if(x.length)return Promise.all(x).then(()=>h);return h},uu(p,au)});function _t(p,f,m,h,g,_){let x=m in h,y=_==="optional";if(!x&&y&&g==="optional")return;if(p.issues.length){if(g!==void 0&&y&&!x)return;f.issues.push(...ke(m,p.issues))}if(!x&&g===void 0){if(!p.issues.length)f.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[m]});return}if(p.value===void 0){if(x||g==="defaulted"&&!y)f.value[m]=void 0}else f.value[m]=p.value}var lu=[];function xi(p){let f=Object.keys(p.shape),m=Object.getOwnPropertySymbols(p.shape),h=m.length?m:lu,g=h.length?[...f,...h]:f;for(let x of g)if(!p.shape?.[x]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(x)}": expected a Zod schema`);let _=mn(p.shape);return{...p,allKeys:g,symbolKeys:h,keySet:new Set(f),numKeys:f.length,optionalKeys:new Set(_)}}function yi(p,f,m,h,g,_,x){let y=[],b=g.keySet,v=g.catchall._zod,k=v.def.type,{optin:S,optout:O}=v,I=0;for(let A in f){if(x&&m.issues.length!==I){if(xe(m,I))break;I=m.issues.length}if(b.has(A))continue;if(A==="__proto__"){if(k==="never")y.push(A);continue}if(k==="never"){y.push(A);continue}let T=v.run({value:f[A],issues:[]},h);if(T instanceof Promise)p.push(T.then((N)=>_t(N,m,A,f,S,O)));else _t(T,m,A,f,S,O)}if(y.length)m.issues.push({code:"unrecognized_keys",keys:y,input:f,inst:_,continue:!0});if(!p.length)return m;return Promise.all(p).then(()=>m)}var pu=Z("$ZodObject",(p,f)=>{L.init(p,f);let m=Object.getOwnPropertyDescriptor(f,"shape"),h=m?.get?m.get.raw:f.shape??{};if(h){let v=()=>{let k={...h};return Object.defineProperty(f,"shape",{value:k}),v.raw=k,k};v.raw=h,Object.defineProperty(f,"shape",{get:v})}let g=Fe(()=>xi(f));C(p,"propValues",(v)=>{let k=v.def.shape,S={};for(let O in k){let I=k[O]._zod;if(I.values){if(!Object.prototype.hasOwnProperty.call(S,O))ie(S,O,new Set);for(let A of I.values)S[O].add(A);if(I.optin!==void 0)S[O].add(void 0)}}return S});let _=Ae,x=f.catchall,y,b=ee.memoizer;b?.attach(p),p._zod.parse=(v,k)=>{y??(y=g.value);let S=v.value;if(!_(S))return v.issues.push({expected:"object",code:"invalid_type",input:S,inst:p}),v;v.value=b?b.alloc(p,v,{},k):{};let O=[],I=y.shape,A=k?.abortEarly,T=v.issues.length;for(let N of y.allKeys){if(A&&v.issues.length!==T){if(xe(v,T))break;T=v.issues.length}if(N==="__proto__")continue;let D=I[N],fe=D._zod.optin,Ce=D._zod.optout,Re=D._zod.run({value:S[N],issues:[]},k);if(Re instanceof Promise)O.push(Re.then((V)=>_t(V,v,N,S,fe,Ce)));else _t(Re,v,N,S,fe,Ce)}if(!x)return O.length?Promise.all(O).then(()=>v):v;return yi(O,S,v,k,g.value,p,A===!0)}}),bi=Z("$ZodObjectJIT",(p,f)=>{pu.init(p,f);let m=p._zod.parse,h=Fe(()=>xi(f)),g=ee.memoizer,_=(I)=>{let A=h.value,T=A.symbolKeys,N=new Qt(["payload","ctx"],{shape:I,inst:p,memo:g,syms:T}),D=(V)=>`shape[${V}]._zod.run({ value: input[${V}], issues: [] }, ctx)`,fe=(V,U)=>`
7
+ let ${V}_ab = false;
8
+ for (let i = 0; i < ${V}.issues.length; i++) {
9
+ const iss = ${V}.issues[i];
10
+ iss.path = iss.path ? [${U}, ...iss.path] : [${U}];
11
+ payload.issues.push(iss);
12
+ if (iss.continue !== true) ${V}_ab = true;
13
+ }
14
+ if (${V}_ab && ctx && ctx.abortEarly) {
15
+ payload.value = newResult;
16
+ return payload;
17
+ }`;N.write("const input = payload.value;");let Ce=Object.create(null),Re=0;for(let V of A.allKeys)Ce[V]=`key_${Re++}`;N.write(g?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let V of A.allKeys){if(V==="__proto__")continue;let U=Ce[V],ge=typeof V==="symbol"?`syms[${T.indexOf(V)}]`:ln(V),Tt=`${ge} in input`,en=I[V],Nt=en?._zod?.optin,tn=Nt!==void 0,Zc=en?._zod?.optout==="optional";if(N.write(`const ${U} = ${D(ge)};`),tn&&Zc){let Pc=Nt==="optional"?`${U}_present`:`${U}.value !== undefined || ${U}_present`;N.write(`
18
+ const ${U}_present = ${Tt};
19
+ if (!${U}.issues.length || ${U}_present) {
20
+ if (${U}.issues.length) {${fe(U,ge)}
21
+ }
22
+
23
+ if (${Pc}) {
24
+ newResult[${ge}] = ${U}.value;
25
+ }
26
+ }
27
+
28
+ `)}else if(!tn)N.write(`
29
+ const ${U}_present = ${Tt};
30
+ if (${U}.issues.length) {${fe(U,ge)}
31
+ }
32
+ if (!${U}_present && !${U}.issues.length) {
33
+ payload.issues.push({
34
+ code: "invalid_type",
35
+ expected: "nonoptional",
36
+ input: undefined,
37
+ path: [${ge}]
38
+ });
39
+ if (ctx && ctx.abortEarly) {
40
+ payload.value = newResult;
41
+ return payload;
42
+ }
43
+ }
44
+
45
+ if (${U}_present) {
46
+ newResult[${ge}] = ${U}.value;
47
+ }
48
+
49
+ `);else if(N.write(`
50
+ if (${U}.issues.length) {${fe(U,ge)}
51
+ }
52
+ `),Nt==="defaulted")N.write(`newResult[${ge}] = ${U}.value;`);else N.write(`
53
+ if (${U}.value !== undefined || ${Tt}) {
54
+ newResult[${ge}] = ${U}.value;
55
+ }
56
+ `)}return N.write("payload.value = newResult;"),N.write("return payload;"),N.compile()},x,y=Ae,b=!ee.jitless,k=b&&fn.value,S=f.catchall,O;p._zod.parse=(I,A)=>{O??(O=h.value);let T=I.value;if(!y(T))return I.issues.push({expected:"object",code:"invalid_type",input:T,inst:p}),I;if(b&&k&&A?.async===!1&&A.jitless!==!0){if(!x)x=_(f.shape);if(I=x(I,A),!S)return I;return yi([],T,I,A,O,p,A?.abortEarly===!0)}return m(I,A)}});function Oo(p,f,m,h){for(let _ of p)if(_.issues.length===0)return f.value=_.value,f;let g=p.filter((_)=>!xe(_));if(g.length===1)return f.value=g[0].value,g[0];return f.issues.push({code:"invalid_union",input:f.value,inst:m,errors:p.map((_)=>_.issues.map((x)=>ye(x,h,ae())))}),f}var or=Z("$ZodUnion",(p,f)=>{L.init(p,f),C(p,"optin",(h)=>h.def.options.some((g)=>g._zod.optin==="defaulted")?"defaulted":h.def.options.some((g)=>g._zod.optin!==void 0)?"optional":void 0),C(p,"optout",(h)=>h.def.options.some((g)=>g._zod.optout==="optional")?"optional":void 0),C(p,"values",(h)=>{if(h.def.options.every((g)=>g._zod.values))return new Set(h.def.options.flatMap((g)=>Array.from(g._zod.values)));return}),C(p,"pattern",(h)=>{if(h.def.options.every((g)=>g._zod.pattern)){let g=h.def.options.map((_)=>_._zod.pattern);return new RegExp(`^(${g.map((_)=>rt(_.source)).join("|")})$`)}return});let m=f.options.length===1?f.options[0]._zod.run:null;p._zod.parse=(h,g)=>{if(m)return m(h,g);let _=!1,x=[];for(let y of f.options){let b=y._zod.run({value:h.value,issues:[]},g);if(b instanceof Promise)x.push(b),_=!0;else{if(b.issues.length===0)return b;x.push(b)}}if(!_)return Oo(x,h,p,g);return Promise.all(x).then((y)=>Oo(y,h,p,g))}});function fu(p){let f=new Map;for(let m of p.options){let h=m._zod.propValues?.[p.discriminator];if(!h||h.size===0)throw Error(`Invalid discriminated union option at index "${p.options.indexOf(m)}"`);for(let g of h)if(f.has(g)){if(g!==void 0)throw Error(`Duplicate discriminator value "${String(g)}"`);f.set(g,null)}else f.set(g,m)}return f}var vi=Z("$ZodDiscriminatedUnion",(p,f)=>{f.inclusive=!1,or.init(p,f);let m=p._zod.parse;C(p,"propValues",(g)=>{let _={},x=0;for(let y of g.def.options){let b=y._zod.propValues;if(!b||Object.keys(b).length===0)throw Error(`Invalid discriminated union option at index "${g.def.options.indexOf(y)}"`);if(b[g.def.discriminator]?.has(void 0))x++;for(let[v,k]of Object.entries(b)){if(!Object.prototype.hasOwnProperty.call(_,v))ie(_,v,new Set);for(let S of k)_[v].add(S)}}if(!g.def.unionFallback&&x>1)_[g.def.discriminator]?.delete(void 0);return _}),f.options.forEach((g,_)=>{let x=Me(g._zod.def);if(x&&!Object.prototype.hasOwnProperty.call(x,f.discriminator))throw Error(`Invalid discriminated union option at index "${_}"`)});let h=Fe(()=>fu(f));p._zod.parse=(g,_)=>{let x=g.value;if(!Ae(x))return g.issues.push({code:"invalid_type",expected:"object",input:x,inst:p}),g;let y=x?.[f.discriminator],b=h.value.get(y);if(b&&(y!==void 0||_.direction!=="backward"))return b._zod.run(g,_);if(f.unionFallback||_.direction==="backward")return m(g,_);return g.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:f.discriminator,options:Array.from(h.value.keys()).filter((v)=>h.value.get(v)!==null),input:x,path:[f.discriminator],inst:p}),g}}),zi=Z("$ZodIntersection",(p,f)=>{L.init(p,f),p._zod.parse=(m,h)=>{let g=m.value,_=f.left._zod.run({value:g,issues:[]},h),x=f.right._zod.run({value:g,issues:[]},h);if(_ instanceof Promise||x instanceof Promise)return Promise.all([_,x]).then(([b,v])=>Io(m,b,v));return Io(m,_,x)}});function er(p,f){if(p===f)return{valid:!0,data:p};if(p instanceof Date&&f instanceof Date&&+p===+f)return{valid:!0,data:p};if(Se(p)&&Se(f)){let m=Object.keys(f),h=Object.keys(p).filter((_)=>m.indexOf(_)!==-1),g={...p,...f};if(Object.prototype.hasOwnProperty.call(g,"__proto__"))delete g.__proto__;for(let _ of h){if(_==="__proto__")continue;let x=er(p[_],f[_]);if(!x.valid)return{valid:!1,mergeErrorPath:[_,...x.mergeErrorPath]};g[_]=x.data}return{valid:!0,data:g}}if(Array.isArray(p)&&Array.isArray(f)){if(p.length!==f.length)return{valid:!1,mergeErrorPath:[]};let m=[];for(let h=0;h<p.length;h++){let g=p[h],_=f[h],x=er(g,_);if(!x.valid)return{valid:!1,mergeErrorPath:[h,...x.mergeErrorPath]};m.push(x.data)}return{valid:!0,data:m}}return{valid:!1,mergeErrorPath:[]}}function Io(p,f,m){let h=new Map,g,_=new Map,x=(v,k)=>{let S;if(v.code==="unrecognized_keys"&&!v.path?.length)g??(g=v),S=v.keys;else if(v.code==="invalid_key"&&v.origin==="record"&&v.path?.length===1){let O=String(v.path[0]);if(!_.has(O))_.set(O,v);S=[O]}else return!1;for(let O of S){if(!h.has(O))h.set(O,{});h.get(O)[k]=!0}return!0};for(let v of f.issues)if(!x(v,"l"))p.issues.push(v);for(let v of m.issues)if(!x(v,"r"))p.issues.push(v);let y=[...h].filter(([,v])=>v.l&&v.r).map(([v])=>v);if(y.length){let v=g?y.filter((k)=>g.keys.includes(k)):[];if(v.length)p.issues.push({...g,keys:v});for(let k of y)if(!v.includes(k)&&_.has(k))p.issues.push(_.get(k))}let b=er(f.value,m.value);if(!b.valid){if(xe(p))return p;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(b.mergeErrorPath)}`)}return p.value=b.data,p}var $i=Z("$ZodRecord",(p,f)=>{L.init(p,f);let m=ee.memoizer;m?.attach(p),p._zod.parse=(h,g)=>{let _=h.value;if(!Se(_))return h.issues.push({expected:"record",code:"invalid_type",input:_,inst:p}),h;let x=[],y=f.keyType._zod.values;if(y&&!f.partial){h.value=m?m.alloc(p,h,{},g):{};let b=new Set;for(let k of y)if(typeof k==="string"||typeof k==="number"||typeof k==="symbol"){if(b.add(typeof k==="number"?k.toString():k),k==="__proto__")continue;let S=f.keyType._zod.run({value:k,issues:[]},g);if(S instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(S.issues.length){h.issues.push({code:"invalid_key",origin:"record",issues:S.issues.map((A)=>ye(A,g,ae())),input:k,path:[k],inst:p});continue}let O=S.value;if(O==="__proto__")continue;let I=f.valueType._zod.run({value:_[k],issues:[]},g);if(I instanceof Promise)x.push(I.then((A)=>{if(A.issues.length)h.issues.push(...ke(k,A.issues));h.value[O]=A.value}));else{if(I.issues.length)h.issues.push(...ke(k,I.issues));h.value[O]=I.value}}let v;for(let k in _)if(!b.has(k))if(f.mode==="loose"){if(k==="__proto__")continue;h.value[k]=_[k]}else v=v??[],v.push(k);if(v&&v.length>0)h.issues.push({code:"unrecognized_keys",input:_,inst:p,keys:v,continue:!0})}else{h.value=m?m.alloc(p,h,{},g):{};let b;for(let v of Reflect.ownKeys(_)){if(v==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(_,v))continue;let k=f.keyType._zod.run({value:v,issues:[]},g);if(k instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof v==="string"&&Be.test(v)&&k.issues.length){let A=f.keyType._zod.run({value:Number(v),issues:[]},g);if(A instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(A.issues.length===0)k=A}if(k.issues.length){if(f.mode==="loose")h.value[v]=_[v];else if(y)b=b??[],b.push(v);else h.issues.push({code:"invalid_key",origin:"record",issues:k.issues.map((A)=>ye(A,g,ae())),input:v,path:[v],inst:p});continue}let O=k.value;if(O==="__proto__")continue;let I=f.valueType._zod.run({value:_[v],issues:[]},g);if(I instanceof Promise)x.push(I.then((A)=>{if(A.issues.length)h.issues.push(...ke(v,A.issues));h.value[O]=A.value}));else{if(I.issues.length)h.issues.push(...ke(v,I.issues));h.value[O]=I.value}}if(b&&b.length>0)h.issues.push({code:"unrecognized_keys",input:_,inst:p,keys:b,continue:!0})}if(x.length)return Promise.all(x).then(()=>h);return h}});var wi=Z("$ZodEnum",(p,f)=>{L.init(p,f);let m=je(f.entries),h=new Set(m);p._zod.values=h,C(p,"pattern",(g)=>{let _=je(g.def.entries).filter((x)=>dn.has(typeof x));return new RegExp(_.length?`^(${_.map((x)=>we(x.toString())).join("|")})$`:"^[^\\s\\S]$")}),p._zod.parse=(g,_)=>{let x=g.value;if(h.has(x))return g;return g.issues.push({code:"invalid_value",values:m,input:x,inst:p}),g}}),ki=Z("$ZodLiteral",(p,f)=>{L.init(p,f);let m=new Set(f.values);p._zod.values=m,C(p,"pattern",(h)=>{let g=h.def.values;return new RegExp(g.length?`^(${g.map((_)=>typeof _==="string"?we(_):_?we(_.toString()):String(_)).join("|")})$`:"^[^\\s\\S]$")}),p._zod.parse=(h,g)=>{let _=h.value;if(m.has(_))return h;return h.issues.push({code:"invalid_value",values:f.values,input:_,inst:p}),h}});var Zi=Z("$ZodTransform",(p,f)=>{L.init(p,f),p._zod.optin="optional",ee.memoizer?.guard(p),p._zod.parse=(m,h)=>{if(h.direction==="backward")throw new Ue(p.constructor.name);let g=f.transform(m.value,m);if(h.async)return(g instanceof Promise?g:Promise.resolve(g)).then((x)=>(m.value=x,m));if(g instanceof Promise)throw new be;return m.value=g,m}});function Ao(p,f){return p.value=f.issues.length?void 0:f.value,p}var ir=Z("$ZodOptional",(p,f)=>{L.init(p,f),C(p,"optin",(m)=>m.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),p._zod.optout="optional",C(p,"values",(m)=>{let h=m.def.innerType._zod.values;return h?new Set([...h,void 0]):void 0}),C(p,"pattern",(m)=>{let h=m.def.innerType._zod.pattern;return h?new RegExp(`^(${rt(h.source)})?$`):void 0}),p._zod.parse=(m,h)=>{if(m.value===void 0){if(f.innerType._zod.optin!=="defaulted")return m;let g=f.innerType._zod.run({value:m.value,issues:[]},h);if(g instanceof Promise)return g.then((_)=>Ao(m,_));return Ao(m,g)}return f.innerType._zod.run(m,h)}}),Pi=Z("$ZodExactOptional",(p,f)=>{ir.init(p,f),C(p,"values",(m)=>m.def.innerType._zod.values),C(p,"pattern",(m)=>m.def.innerType._zod.pattern),p._zod.parse=(m,h)=>f.innerType._zod.run(m,h)}),Si=Z("$ZodNullable",(p,f)=>{L.init(p,f),C(p,"optin",(m)=>m.def.innerType._zod.optin),C(p,"optout",(m)=>m.def.innerType._zod.optout),C(p,"pattern",(m)=>{let h=m.def.innerType._zod.pattern;return h?new RegExp(`^(${rt(h.source)}|null)$`):void 0}),C(p,"values",(m)=>m.def.innerType._zod.values?new Set([...m.def.innerType._zod.values,null]):void 0),p._zod.parse=(m,h)=>{if(m.value===null)return m;return f.innerType._zod.run(m,h)}}),Oi=Z("$ZodDefault",(p,f)=>{L.init(p,f),p._zod.optin="defaulted",C(p,"values",(m)=>m.def.innerType._zod.values),p._zod.parse=(m,h)=>{if(h.direction==="backward")return f.innerType._zod.run(m,h);if(m.value===void 0)return m.value=f.defaultValue,m;let g=f.innerType._zod.run(m,h);if(g instanceof Promise)return g.then((_)=>Eo(_,f));return Eo(g,f)}});function Eo(p,f){if(p.value===void 0)p.value=f.defaultValue;return p}var Ii=Z("$ZodPrefault",(p,f)=>{L.init(p,f),p._zod.optin="defaulted",C(p,"values",(m)=>m.def.innerType._zod.values),p._zod.parse=(m,h)=>{if(h.direction==="backward")return f.innerType._zod.run(m,h);if(m.value===void 0)m.value=f.defaultValue;return f.innerType._zod.run(m,h)}}),Ai=Z("$ZodNonOptional",(p,f)=>{L.init(p,f),C(p,"values",(m)=>{let h=m.def.innerType._zod.values;return h?new Set([...h].filter((g)=>g!==void 0)):void 0}),p._zod.parse=(m,h)=>{let g=f.innerType._zod.run(m,h);if(g instanceof Promise)return g.then((_)=>To(_,p));return To(g,p)}});function To(p,f){if(!p.issues.length&&p.value===void 0)p.issues.push({code:"invalid_type",expected:"nonoptional",input:p.value,inst:f});return p}function No(p,f,m,h){if(!f.issues.length){if(p.value=f.value,f.memo)p.memo=!0;return p}return p.value=m.catchValue({...f,value:p.value,error:{issues:f.issues.map((g)=>ye(g,h,ae()))},input:p.value}),p}var Ei=Z("$ZodCatch",(p,f)=>{L.init(p,f),C(p,"optin",(m)=>m.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),C(p,"optout",(m)=>m.def.innerType._zod.optout),C(p,"values",(m)=>m.def.innerType._zod.values),p._zod.parse=(m,h)=>{if(h.direction==="backward")return f.innerType._zod.run(m,h);let g=f.innerType._zod.run({value:m.value,issues:[]},h);if(g instanceof Promise)return g.then((_)=>No(m,_,f,h));return No(m,g,f,h)}});var sr=Z("$ZodPipe",(p,f)=>{L.init(p,f),C(p,"values",(m)=>m.def.in._zod.values),C(p,"optin",(m)=>m.def.in._zod.optin),C(p,"optout",(m)=>m.def.out._zod.optout),C(p,"propValues",(m)=>m.def.in._zod.propValues),p._zod.parse=(m,h)=>{if(h.direction==="backward"){let _=f.out._zod.run(m,h);if(_ instanceof Promise)return _.then((x)=>ht(x,f.in,h));return ht(_,f.in,h)}let g=f.in._zod.run(m,h);if(g instanceof Promise)return g.then((_)=>ht(_,f.out,h));return ht(g,f.out,h)}});function ht(p,f,m){if(p.issues.some((h)=>h.code!=="unrecognized_keys"))return p.aborted=!0,p;return f._zod.run({value:p.value,issues:p.issues},m)}var Ti=Z("$ZodPreprocess",(p,f)=>{sr.init(p,f)}),Ni=Z("$ZodReadonly",(p,f)=>{L.init(p,f),C(p,"propValues",(m)=>m.def.innerType._zod.propValues),C(p,"values",(m)=>m.def.innerType._zod.values),C(p,"optin",(m)=>m.def.innerType?._zod?.optin),C(p,"optout",(m)=>m.def.innerType?._zod?.optout),p._zod.parse=(m,h)=>{if(h.direction==="backward")return f.innerType._zod.run(m,h);let g=f.innerType._zod.run(m,h);if(g instanceof Promise)return g.then(Co);return Co(g)}});function Co(p){if(!p.memo)p.value=Object.freeze(p.value);return p}var Ci=Z("$ZodLazy",(p,f)=>{L.init(p,f),cn(p._zod,"innerType",()=>{let m=f;if(!m._cachedInner)m._cachedInner=f.getter();return m._cachedInner}),C(p,"pattern",(m)=>m.innerType?._zod?.pattern),C(p,"propValues",(m)=>m.innerType?._zod?.propValues),C(p,"optin",(m)=>m.innerType?._zod?.optin??void 0),C(p,"optout",(m)=>m.innerType?._zod?.optout??void 0),p._zod.parse=(m,h)=>p._zod.innerType._zod.run(m,h)}),Ri=Z("$ZodCustom",(p,f)=>{H.init(p,f),L.init(p,f),p._zod.parse=(m,h)=>m,p._zod.check=(m)=>{let h=m.value,g=f.fn(h);if(g instanceof Promise)return g.then((_)=>Ro(_,m,h,p));Ro(g,m,h,p);return}});function Ro(p,f,m,h){if(!p){let g={code:"custom",input:m,inst:h,path:[...h._zod.def.path??[]],continue:!h._zod.def.abort};if(h._zod.def.params)g.params=h._zod.def.params;f.issues.push(Oe(g))}}class ji extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var ur="~memo",Di=[];function Li(p){return p!==null&&typeof p==="object"}function cr(p){return p.map((f)=>f.path?{...f,path:f.path.slice()}:{...f})}var Fi=new WeakMap,Ve=0,zt=1,We=2;function $t(p,f,m){let h=Fi.get(p);if(h!==void 0)return h?We:Ve;if(f.has(p))return We;f.add(p);let g=Ve,_=(k)=>{if(g!==We&&k?._zod){let S=$t(k,f,m);if(S>g)g=S}},x=(k,S)=>{let O=Ve;for(let I of Reflect.ownKeys(k)){let A=Object.getOwnPropertyDescriptor(k,I);if(S&&!A.enumerable)continue;let T=A.get?zt:A.value?._zod?$t(A.value,f,m):Ve;if(T>O)O=T}return O},y=(k)=>{if(k>g)g=k},b=p._zod.def,v=b.type;switch(v){case"object":{let k=Me(b);y(k?x(k,!0):zt),_(b.catchall);break}case"array":_(b.element);break;case"tuple":for(let k of b.items)_(k);_(b.rest);break;case"record":case"map":_(b.keyType),_(b.valueType);break;case"set":_(b.valueType);break;case"union":for(let k of b.options)_(k);break;case"intersection":_(b.left),_(b.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":_(b.innerType);break;case"pipe":_(b.in),_(b.out);break;case"function":_(b.input),_(b.output);break;case"lazy":{let k=b._cachedInner??(m?p._zod.innerType:void 0);y(k?$t(k,f,!1):zt);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(let k in b){let S=Object.getOwnPropertyDescriptor(b,k);if(!S||S.get)continue;let O=S.value;if(!O||typeof O!=="object")continue;if(O._zod)_(O);else if(Array.isArray(O))for(let I of O)_(I)}}return f.delete(p),du(p,g)}function du(p,f){if(f!==zt)Fi.set(p,f===We);return f}function mu(p,f){let m=p.buckets.get(f);if(!m)m=new WeakMap,p.buckets.set(f,m);return m}var bt,vt=[],hu={alloc(p,f,m){let h=bt;if(!h)return m;bt=void 0;let g={value:m,issues:null};return h.set(f.value,g),vt.push(g),m},guard(p){var f;(f=p._zod).deferred??(f.deferred=[]),p._zod.deferred.push(()=>{let m=p._zod.parse,h=(g,_)=>{if(_.direction!=="backward"&&gu(_,g.value))throw new ji;return m(g,_)};if(p._zod.parse=h,p._zod.run===m)p._zod.run=h})},attach(p){var f;let m,h=!1,g,_;(f=p._zod).deferred??(f.deferred=[]),p._zod.deferred.push(()=>{let x=p._zod.parse,y=(b,v)=>{if(m===void 0){let D=$t(p,new Set,!1);if(D===Ve){if(p._zod.parse=x,p._zod.run===y)p._zod.run=x;return x(b,v)}if(D===We||h)m=!0;else h=!0}let k=b.value;if(!Li(k))return x(b,v);let S=v[ur];if(!S)S={buckets:new WeakMap,backEdges:void 0},v[ur]=S;let O;if(g===v)O=_;else O=mu(S,p),g=v,_=O;let I=O.get(k);if(I){if(b.value=I.value,I.issues){if(I.issues.length)b.issues.push(...cr(I.issues))}else b.memo=!0,S.backEdges??(S.backEdges=new WeakSet),S.backEdges.add(I.value);return b}bt=O;let A=vt.length,T=x(b,v);bt=void 0;let N=vt.length>A?vt.pop():void 0;if(T instanceof Promise)return T.then((D)=>{if(N)N.issues=D.issues.length?cr(D.issues):Di;return D});if(N)N.issues=T.issues.length?cr(T.issues):Di;return T};if(p._zod.parse=y,p._zod.run===x)p._zod.run=y})}};function Mi(){return hu}function gu(p,f){let m=p[ur]?.backEdges;return m!==void 0&&Li(f)&&m.has(f)}var _u=()=>{let p={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 f(_){return p[_]??null}let m={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"},h={nan:"NaN"};function g(_,x){if(_==="number"&&typeof x==="number"&&!Number.isFinite(x))return String(x);return h[_]??_}return(_)=>{switch(_.code){case"invalid_type":{let x=g(_.expected),y=xn(_.input),b=g(y,_.input);return`Invalid input: expected ${x}, received ${b}`}case"invalid_value":if(_.values.length===1)return`Invalid input: expected ${Lt(_.values[0])}`;return`Invalid option: expected one of ${Rt(_.values,"|")}`;case"too_big":{let x=_.exact?"exactly ":_.inclusive?"<=":"<",y=f(_.origin);if(y)return`Too big: expected ${_.origin??"value"} to have ${x}${_.maximum.toString()} ${y.unit??"elements"}`;return`Too big: expected ${_.origin??"value"} to be ${x}${_.maximum.toString()}`}case"too_small":{let x=_.exact?"exactly ":_.inclusive?">=":">",y=f(_.origin);if(y)return`Too small: expected ${_.origin} to have ${x}${_.minimum.toString()} ${y.unit}`;return`Too small: expected ${_.origin} to be ${x}${_.minimum.toString()}`}case"invalid_format":{let x=_;if(x.format==="starts_with")return`Invalid string: must start with "${x.prefix}"`;if(x.format==="ends_with")return`Invalid string: must end with "${x.suffix}"`;if(x.format==="includes")return`Invalid string: must include "${x.includes}"`;if(x.format==="regex")return`Invalid string: must match pattern ${x.pattern}`;return`Invalid ${m[x.format]??_.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${_.divisor}`;case"unrecognized_keys":return`Unrecognized key${_.keys.length>1?"s":""}: ${Rt(_.keys,", ")}`;case"invalid_key":return`Invalid key in ${_.origin}`;case"invalid_union":if(_.options&&Array.isArray(_.options)&&_.options.length>0)return`Invalid discriminator value. Expected ${_.options.map((y)=>`'${y}'`).join(" | ")}`;if(_.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${_.origin}`;default:return"Invalid input"}}};function ar(){return{localeError:_u()}}var Ui;class Bi{constructor(){this._map=new WeakMap,this._idmap=new Map}add(p,...f){let m=f[0];if(this._map.set(p,m),m&&typeof m==="object"&&"id"in m)this._idmap.set(m.id,p);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(p){let f=this._map.get(p);if(f&&typeof f==="object"&&"id"in f)this._idmap.delete(f.id);return this._map.delete(p),this}get(p){let f=p._zod.parent;if(f){let m={...this.get(f)??{}};delete m.id;let h={...m,...this._map.get(p)};return Object.keys(h).length?h:void 0}return this._map.get(p)}has(p){return this._map.has(p)}}function xu(){return new Bi}(Ui=globalThis).__zod_globalRegistry??(Ui.__zod_globalRegistry=xu());var Ie=globalThis.__zod_globalRegistry;function lr(p){if(p.checks)p.checks=[...p.checks];return p}function Ji(p,f){return new p(lr({type:"string",...E(f)}))}function pr(p,f){return new p({type:"string",format:"email",check:"string_format",abort:!1,...E(f)})}function Ki(p,f){return new p({type:"string",format:"guid",check:"string_format",abort:!1,...E(f)})}function Vi(p,f){return new p({type:"string",format:"uuid",check:"string_format",abort:!1,...E(f)})}function Wi(p,f){return new p({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...E(f)})}function Gi(p,f){return new p({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...E(f)})}function Xi(p,f){return new p({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...E(f)})}function fr(p,f){return new p({type:"string",format:"url",check:"string_format",abort:!1,...E(f)})}function Yi(p,f){return new p({type:"string",format:"emoji",check:"string_format",abort:!1,...E(f)})}function qi(p,f){return new p({type:"string",format:"nanoid",check:"string_format",abort:!1,...E(f)})}function Hi(p,f){return new p({type:"string",format:"cuid",check:"string_format",abort:!1,...E(f)})}function Qi(p,f){return new p({type:"string",format:"cuid2",check:"string_format",abort:!1,...E(f)})}function es(p,f){return new p({type:"string",format:"ulid",check:"string_format",abort:!1,...E(f)})}function ts(p,f){return new p({type:"string",format:"xid",check:"string_format",abort:!1,...E(f)})}function rs(p,f){return new p({type:"string",format:"ksuid",check:"string_format",abort:!1,...E(f)})}function ns(p,f){return new p({type:"string",format:"ipv4",check:"string_format",abort:!1,...E(f)})}function os(p,f){return new p({type:"string",format:"ipv6",check:"string_format",abort:!1,...E(f)})}function is(p,f){return new p({type:"string",format:"cidrv4",check:"string_format",abort:!1,...E(f)})}function ss(p,f){return new p({type:"string",format:"cidrv6",check:"string_format",abort:!1,...E(f)})}function cs(p,f){return new p({type:"string",format:"base64",check:"string_format",abort:!1,...E(f)})}function us(p,f){return new p({type:"string",format:"base64url",check:"string_format",abort:!1,...E(f)})}function as(p,f){return new p({type:"string",format:"e164",check:"string_format",abort:!1,...E(f)})}function ls(p,f){return new p({type:"string",format:"jwt",check:"string_format",abort:!1,...E(f)})}function G(p,f){return new p({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...E(f)})}function W(p,f){return new p({type:"string",format:"date",check:"string_format",...E(f)})}function ps(p,f){return new p({type:"string",format:"time",check:"string_format",precision:null,...E(f)})}function fs(p,f){return new p({type:"string",format:"duration",check:"string_format",...E(f)})}function ds(p,f){return new p(lr({type:"number",checks:[],...E(f)}))}function le(p,f){return new p(lr({type:"number",coerce:!0,checks:[],...E(f)}))}function ms(p,f){return new p({type:"number",check:"number_format",abort:!1,format:"safeint",...E(f)})}function hs(p,f){return new p({type:"boolean",...E(f)})}function gs(p,f){return new p({type:"null",...E(f)})}function _s(p){return new p({type:"any"})}function xs(p){return new p({type:"unknown"})}function ys(p,f){return new p({type:"never",...E(f)})}function wt(p,f){return new qt({check:"less_than",...E(f),value:p,inclusive:!1})}function Ge(p,f){return new qt({check:"less_than",...E(f),value:p,inclusive:!0})}function kt(p,f){return new Ht({check:"greater_than",...E(f),value:p,inclusive:!1})}function Xe(p,f){return new Ht({check:"greater_than",...E(f),value:p,inclusive:!0})}function Zt(p,f){return new fo({check:"multiple_of",...E(f),value:p})}function Pt(p,f){return new ho({check:"max_length",...E(f),maximum:p})}function Ee(p,f){return new go({check:"min_length",...E(f),minimum:p})}function St(p,f){return new _o({check:"length_equals",...E(f),length:p})}function dr(p,f){return new xo({check:"string_format",format:"regex",...E(f),pattern:p})}function mr(p){return new yo({check:"string_format",format:"lowercase",...E(p)})}function hr(p){return new bo({check:"string_format",format:"uppercase",...E(p)})}function gr(p,f){return new vo({check:"string_format",format:"includes",...E(f),includes:p})}function _r(p,f){return new zo({check:"string_format",format:"starts_with",...E(f),prefix:p})}function xr(p,f){return new $o({check:"string_format",format:"ends_with",...E(f),suffix:p})}function Ze(p){return new wo({check:"overwrite",tx:p})}function yr(p){return Ze((f)=>f.normalize(p))}function br(){return Ze((p)=>p.trim())}function vr(){return Ze((p)=>p.toLowerCase())}function zr(){return Ze((p)=>p.toUpperCase())}function $r(){return Ze((p)=>pn(p))}function bs(p,f,m){return new p({type:"array",element:f,...E(m)})}function vs(p,f,m){return new p({type:"custom",check:"custom",fn:f,...E(m)})}function zs(p,f){let m=yu((h)=>(h.addIssue=(g)=>{if(typeof g==="string")h.issues.push(Oe(g,h.value,m._zod.def));else{let _=g;if(_.fatal)_.continue=!1;if(_.code??(_.code="custom"),!("input"in _))_.input=h.value;_.inst??(_.inst=m),_.continue??(_.continue=!m._zod.def.abort),h.issues.push(Oe(_))}},p(h.value,h)),f);return m}function yu(p,f){let m=new H({check:"custom",...E(f)});return m._zod.check=p,m}function Ye(p,...f){for(let m of f)for(let h of Reflect.ownKeys(m))if(Object.prototype.propertyIsEnumerable.call(m,h))ie(p,h,m[h]);return p}function He(p){let f=p?.target??"draft-2020-12";if(f==="draft-4")f="draft-04";if(f==="draft-7")f="draft-07";return{processors:p.processors??{},metadataRegistry:p?.metadata??Ie,target:f,unrepresentable:p?.unrepresentable??"throw",override:p?.override??(()=>{}),io:p?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:p?.cycles??"ref",reused:p?.reused??"inline",intersections:[],deferred:[],external:p?.external??void 0}}function q(p,f,m,h,g){let _=typeof f.unrepresentable==="function"?f.unrepresentable({zodSchema:p,path:h.path,message:g}):f.unrepresentable;if(_==="any")return!1;if(_===void 0||_==="throw")throw Error(g);return Object.assign(m,_),!0}function F(p,f,m={path:[],schemaPath:[]}){var h;let g=p._zod.def,_=f.seen.get(p);if(_){if(_.count++,m.schemaPath.includes(p))_.cycle=m.path;return _.schema}let x={schema:{},count:1,cycle:void 0,path:m.path};f.seen.set(p,x),f.sharedDefsExtractedFor=void 0,f.sharedEmitDoneFor=void 0;let y=p._zod.toJSONSchema?.();if(y)x.schema=y;else{let k={...m,schemaPath:[...m.schemaPath,p],path:m.path};if(p._zod.processJSONSchema)p._zod.processJSONSchema(f,x.schema,k);else{let O=x.schema,I=f.processors[g.type];if(!I)throw Error(`[toJSONSchema]: Non-representable type encountered: ${g.type}`);I(p,f,O,k)}let S=p._zod.parent;if(S){if(!x.ref)x.ref=S;F(S,f,k),f.seen.get(S).isParent=!0}}let b=f.metadataRegistry.get(p);if(b)Ye(x.schema,b);if(f.io==="input"&&Q(p))delete x.schema.examples,delete x.schema.default;if(f.io==="input"&&"_prefault"in x.schema)(h=x.schema).default??(h.default=x.schema._prefault);return delete x.schema._prefault,f.seen.get(p).schema}function $s(p){return p.replace(/~/g,"~0").replace(/\//g,"~1")}function Qe(p,f){let m=p.seen.get(f);if(!m)throw Error("Unprocessed schema. This is a bug in Zod.");if(p.external&&p.sharedDefsExtractedFor===p.external)return;let h=new Map;for(let x of p.seen.entries()){let y=p.metadataRegistry.get(x[0])?.id;if(y){let b=h.get(y);if(b&&b!==x[0])throw Error(`Duplicate schema id "${y}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);h.set(y,x[0])}}let g=(x)=>{let y=p.target==="draft-2020-12"?"$defs":"definitions";if(p.external){let S=p.external.registry.get(x[0])?.id,O=p.external.uri??((A)=>A);if(S)return{ref:O(S)};let I=x[1].defId??x[1].schema.id??`schema${p.counter++}`;return x[1].defId=I,{defId:I,ref:`${O("__shared")}#/${y}/${$s(I)}`}}let b="#",v=`${b}/${y}/`;if(x[1]===m&&!x[1].schema.id)return{ref:b};let k=x[1].schema.id??`__schema${p.counter++}`;return{defId:k,ref:v+$s(k)}},_=(x)=>{if(x[1].schema.$ref)return;let y=x[1],{ref:b,defId:v}=g(x);if(y.def={...y.schema},v)y.defId=v;let k=y.schema;for(let S in k)delete k[S];k.$ref=b};if(p.cycles==="throw")for(let x of p.seen.entries()){let y=x[1];if(y.cycle)throw Error(`Cycle detected: #/${y.cycle?.join("/")}/<root>
57
+
58
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let x of p.seen.entries()){let y=x[1];if(f===x[0]){_(x);continue}if(p.external){let v=p.external.registry.get(x[0])?.id;if(f!==x[0]&&v){_(x);continue}}if(p.metadataRegistry.get(x[0])?.id){_(x);continue}if(y.cycle){_(x);continue}if(y.count>1){if(p.reused==="ref")_(x)}}if(p.external)p.sharedDefsExtractedFor=p.external}function Zs(p){let f=p.anyOf;if(!Array.isArray(f)||f.length===0||p.type!==void 0)return;let m=[];for(let h of f){if(!h||typeof h!=="object")return;Zs(h);let g=Object.keys(h);if(g.length!==1||g[0]!=="type")return;let _=h.type;for(let x of Array.isArray(_)?_:[_]){if(typeof x!=="string")return;if(!m.includes(x))m.push(x)}}delete p.anyOf,p.type=m.length===1?m[0]:m}var Ps=new Set(["type","properties","required","additionalProperties"]),ws=["oneOf","anyOf"];function ks(p){let f=p.additionalProperties;if(f===void 0||f===!1||typeof f!=="object"||f===null)return null;return Object.keys(f).length?f:null}function wr(p){let f=[];for(let _ of p){if(typeof _!=="object"||_.type!=="object")return null;for(let x in _)if(!Ps.has(x))return null;f.push(_)}let m={},h=new Set;for(let _ of f){for(let x in _.properties){if(Object.prototype.hasOwnProperty.call(m,x))continue;let y=[];for(let v of f){let k=v.properties?.[x]??ks(v);if(k===null||k===void 0)continue;if(!y.some((S)=>JSON.stringify(S)===JSON.stringify(k)))y.push(k)}let b=y.length===1?y[0]:wr(y)??{allOf:y};ie(m,x,b)}for(let x of _.required??[])h.add(x)}let g={type:"object",properties:m};if(h.size)g.required=[...h];if(f.every((_)=>_.additionalProperties===!1))g.additionalProperties=!1;else{let _=[];for(let x of f){let y=ks(x);if(y&&!_.some((b)=>JSON.stringify(b)===JSON.stringify(y)))_.push(y)}if(_.length===1)g.additionalProperties=_[0];else if(_.length>1)g.additionalProperties={allOf:_}}return g}function bu(p){let f=p.allOf;if(!Array.isArray(f)||f.length<2)return;for(let g of Ps)if(g in p)return;let m=f.filter((g)=>ws.some((_)=>Array.isArray(g[_]))),h=null;if(!m.length)h=wr(f);else{let g=m[0],_=ws.find((b)=>Array.isArray(g[b]));if(Object.keys(g).length!==1)return;let x=f.filter((b)=>b!==g),y=g[_].map((b)=>wr([...x,b]));if(y.some((b)=>!b))return;h={[_]:y}}if(!h)return;delete p.allOf,Ye(p,h)}function et(p,f){let m=p.seen.get(f);if(!m)throw Error("Unprocessed schema. This is a bug in Zod.");let h=(y)=>{let b=p.seen.get(y);if(b.ref===null)return;let v=b.def??b.schema,k={...v},S=b.ref;if(b.ref=null,S){h(S);let I=p.seen.get(S),A=I.schema;if(A.$ref&&(p.target==="draft-07"||p.target==="draft-04"||p.target==="openapi-3.0"))v.allOf=v.allOf??[],v.allOf.push(A);else Ye(v,A);if(Ye(v,k),y._zod.parent===S)for(let N in v){if(N==="$ref"||N==="allOf")continue;if(!(N in k))delete v[N]}if(A.$ref&&I.def)for(let N in v){if(N==="$ref"||N==="allOf")continue;if(N in I.def&&JSON.stringify(v[N])===JSON.stringify(I.def[N]))delete v[N]}}let O=y._zod.parent;if(O&&O!==S){h(O);let I=p.seen.get(O);if(I?.schema.$ref){if(v.$ref=I.schema.$ref,I.def)for(let A in v){if(A==="$ref"||A==="allOf")continue;if(A in I.def&&JSON.stringify(v[A])===JSON.stringify(I.def[A]))delete v[A]}}}p.override({zodSchema:y,jsonSchema:v,path:b.path??[]})};if(!p.external||p.sharedEmitDoneFor!==p.external){for(let y of[...p.seen.entries()].reverse())h(y[0]);if(p.target!=="openapi-3.0")for(let y of p.seen.entries())Zs(y[1].def??y[1].schema);for(let y of p.deferred)y();if(p.intersections.length){let y=new Map;for(let b of p.seen.values())for(let v of[b.schema,b.def]){let k=v?.allOf;if(!Array.isArray(k))continue;let S=y.get(k);if(S)S.push(v);else y.set(k,[v])}for(let b of p.intersections)for(let v of y.get(b)??[])bu(v)}}let g={};if(p.target==="draft-2020-12")g.$schema="https://json-schema.org/draft/2020-12/schema";else if(p.target==="draft-07")g.$schema="http://json-schema.org/draft-07/schema#";else if(p.target==="draft-04")g.$schema="http://json-schema.org/draft-04/schema#";else if(p.target==="openapi-3.0");if(p.external?.uri){let y=p.external.registry.get(f)?.id;if(!y)throw Error("Schema is missing an `id` property");g.$id=p.external.uri(y)}Ye(g,m.defId?m.schema:m.def??m.schema);let _=p.metadataRegistry.get(f)?.id;if(_!==void 0&&g.id===_)delete g.id;let x=p.external?.defs??{};if(!p.external||p.sharedEmitDoneFor!==p.external)for(let y of p.seen.entries()){let b=y[1];if(b.def&&b.defId){if(b.def.id===b.defId)delete b.def.id;ie(x,b.defId,b.def)}}if(p.external)p.sharedEmitDoneFor=p.external;if(p.external);else if(Object.keys(x).length>0)if(p.target==="draft-2020-12")g.$defs=x;else g.definitions=x;try{let y=JSON.parse(JSON.stringify(g));return Object.defineProperty(y,"~standard",{value:{...f["~standard"],jsonSchema:{input:qe(f,"input",p.processors),output:qe(f,"output",p.processors)}},enumerable:!1,writable:!1}),y}catch(y){throw Error("Error converting schema to JSON.")}}function Q(p,f){let m=f??{seen:new Set};if(m.seen.has(p))return!1;m.seen.add(p);let h=p._zod.def;if(h.type==="transform")return!0;if(h.type==="array")return Q(h.element,m);if(h.type==="set")return Q(h.valueType,m);if(h.type==="lazy")return Q(h.getter(),m);if(h.type==="promise"||h.type==="optional"||h.type==="nonoptional"||h.type==="nullable"||h.type==="readonly"||h.type==="default"||h.type==="prefault"||h.type==="catch")return Q(h.innerType,m);if(h.type==="intersection")return Q(h.left,m)||Q(h.right,m);if(h.type==="record"||h.type==="map")return Q(h.keyType,m)||Q(h.valueType,m);if(h.type==="pipe"){if(p._zod.traits.has("$ZodCodec"))return!0;return Q(h.in,m)||Q(h.out,m)}if(h.type==="object"){for(let g in h.shape)if(Q(h.shape[g],m))return!0;return!1}if(h.type==="union"){for(let g of h.options)if(Q(g,m))return!0;return!1}if(h.type==="tuple"){for(let g of h.items)if(Q(g,m))return!0;if(h.rest&&Q(h.rest,m))return!0;return!1}return!1}var Ss=(p,f={})=>(m)=>{let h=He({...m,processors:f});return F(p,h),Qe(h,p),et(h,p)},qe=(p,f,m={})=>(h)=>{let{libraryOptions:g,target:_}=h??{},x=He({...g??{},target:_,io:f,processors:m});return F(p,x),Qe(x,p),et(x,p)};var Te=(p,f,m)=>{if(p[f]===void 0||m>p[f])p[f]=m},Ne=(p,f,m)=>{if(p[f]===void 0||m<p[f])p[f]=m},Os=(p,f)=>{Te(p,"minimum",f),Ne(p,"maximum",f)},Ns=(p,f)=>{if(p.multipleOf??(p.multipleOf=[]),!p.multipleOf.includes(f))p.multipleOf.push(f)},Cs=(p,f)=>{p.patterns??(p.patterns=new Set),p.patterns.add(f)},Rs=(p,f)=>{p.mime=p.mime?p.mime.filter((m)=>f.includes(m)):[...f]},Ds=(p,f)=>{if(p.format=f,f.includes("int"))p.isInt=!0},Is=(p,f)=>Te(p,"minimum",f.minimum),As=(p,f)=>Ne(p,"maximum",f.maximum),Es=(p)=>(f,m)=>{Ds(f,m.format);let[h,g]=p[m.format];Te(f,"minimum",h),Ne(f,"maximum",g)},vu={greater_than:(p,f)=>Te(p,f.inclusive?"minimum":"exclusiveMinimum",f.value),less_than:(p,f)=>Ne(p,f.inclusive?"maximum":"exclusiveMaximum",f.value),multiple_of:(p,f)=>Ns(p,f.value),number_format:Es(nt),bigint_format:Es(Ft),min_length:Is,max_length:As,length_equals:(p,f)=>Os(p,f.length),min_size:Is,max_size:As,size_equals:(p,f)=>Os(p,f.size),string_format:(p,f)=>{if(Ds(p,f.format),f.pattern)Cs(p,f.pattern);if(f.format==="base64"||f.format==="base64url")p.contentEncoding=f.format;if(f.local||f.precision===-1)p.laxFormat=!0},mime_type:(p,f)=>Rs(p,f.mime)};function te(p){let f={},m=p._zod.def,h=p._zod.traits.has("$ZodCheck")?[p,...m.checks??[]]:m.checks??[];for(let _ of h)vu[_._zod.def.check]?.(f,_._zod.def);let g=p._zod.bag;if(g.minimum!==void 0)Te(f,"minimum",g.minimum);if(g.exclusiveMinimum!==void 0)Te(f,"exclusiveMinimum",g.exclusiveMinimum);if(g.maximum!==void 0)Ne(f,"maximum",g.maximum);if(g.exclusiveMaximum!==void 0)Ne(f,"exclusiveMaximum",g.exclusiveMaximum);if(g.multipleOf!==void 0)Ns(f,g.multipleOf);if(g.format!==void 0){if(f.format??(f.format=g.format),g.format.includes("int"))f.isInt=!0}if(g.mime)Rs(f,g.mime);for(let _ of g.patterns??[])Cs(f,_);return f}var zu={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},$u=new Map([[rr,Qn],[yt,eo]]),js=(p)=>$u.get(p)??p,Pr=(p,f,m,h)=>{let g=m;g.type="string";let{minimum:_,maximum:x,format:y,patterns:b,contentEncoding:v,laxFormat:k}=te(p);if(typeof _==="number")g.minLength=_;if(typeof x==="number")g.maxLength=x;if(y){if(g.format=zu[y]??y,g.format==="")delete g.format;if(y==="time"||k)delete g.format}if(v)g.contentEncoding=v;if(b&&b.size>0){let S=[...b].map(js);if(S.length===1)g.pattern=S[0].source;else if(S.length>1)g.allOf=[...S.map((O)=>({...f.target==="draft-07"||f.target==="draft-04"||f.target==="openapi-3.0"?{type:"string"}:{},pattern:O.source}))]}},Sr=(p,f,m,h)=>{let g=m,{minimum:_,maximum:x,multipleOf:y,exclusiveMaximum:b,exclusiveMinimum:v,isInt:k}=te(p);g.type=k?"integer":"number";let S=typeof v==="number"&&v>=(_??Number.NEGATIVE_INFINITY),O=typeof b==="number"&&b<=(x??Number.POSITIVE_INFINITY),I=f.target==="draft-04"||f.target==="openapi-3.0";if(S)if(I)g.minimum=v,g.exclusiveMinimum=!0;else g.exclusiveMinimum=v;else if(typeof _==="number")g.minimum=_;if(O)if(I)g.maximum=b,g.exclusiveMaximum=!0;else g.exclusiveMaximum=b;else if(typeof x==="number")g.maximum=x;if(y){let A=new Set;for(let D of y)if(Number.isFinite(D)&&D!==0)A.add(Math.abs(D));else q(p,f,g,h,`A multipleOf divisor of ${D} cannot be represented in JSON Schema`);let[T,...N]=A;if(T!==void 0)g.multipleOf=T;if(N.length)g.allOf=[...g.allOf??[],...N.map((D)=>({multipleOf:D}))]}},Or=(p,f,m,h)=>{m.type="boolean"},Ls=(p,f,m,h)=>{q(p,f,m,h,"BigInt cannot be represented in JSON Schema")},Fs=(p,f,m,h)=>{q(p,f,m,h,"Symbols cannot be represented in JSON Schema")},Ir=(p,f,m,h)=>{if(f.target==="openapi-3.0")m.type="string",m.nullable=!0,m.enum=[null];else m.type="null"},Ms=(p,f,m,h)=>{q(p,f,m,h,"Undefined cannot be represented in JSON Schema")},Us=(p,f,m,h)=>{q(p,f,m,h,"Void cannot be represented in JSON Schema")},Ar=(p,f,m,h)=>{m.not={}},Er=(p,f,m,h)=>{},Tr=(p,f,m,h)=>{},Bs=(p,f,m,h)=>{q(p,f,m,h,"Date cannot be represented in JSON Schema")},Nr=(p,f,m,h)=>{let g=p._zod.def,_=je(g.entries);if(_.length===0){m.not={};return}if(_.every((x)=>typeof x==="number"))m.type="number";if(_.every((x)=>typeof x==="string"))m.type="string";m.enum=_},Cr=(p,f,m,h)=>{let g=p._zod.def;if(g.values.length===0){m.not={};return}let _=[];for(let x of g.values)if(x===void 0){if(q(p,f,m,h,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof x==="bigint"){if(q(p,f,m,h,"BigInt literals cannot be represented in JSON Schema"))return;_.push(Number(x))}else _.push(x);if(_.length===0);else if(_.length===1){let x=_[0];if(m.type=x===null?"null":typeof x,f.target==="draft-04"||f.target==="openapi-3.0")m.enum=[x];else m.const=x}else{if(_.every((x)=>typeof x==="number"))m.type="number";if(_.every((x)=>typeof x==="string"))m.type="string";if(_.every((x)=>typeof x==="boolean"))m.type="boolean";if(_.every((x)=>x===null))m.type="null";m.enum=_}},Js=(p,f,m,h)=>{q(p,f,m,h,"NaN cannot be represented in JSON Schema")},Ks=(p,f,m,h)=>{let g=m,_=p._zod.pattern;if(!_)throw Error("Pattern not found in template literal");g.type="string",g.pattern=_.source},Vs=(p,f,m,h)=>{let g=m;g.type="string",g.format="binary",g.contentEncoding="binary";let{minimum:_,maximum:x,mime:y}=te(p);if(_!==void 0)g.minLength=_;if(x!==void 0)g.maxLength=x;if(!y)return;if(y.length===0)g.not={};else if(y.length===1)g.contentMediaType=y[0];else g.anyOf=y.map((b)=>({contentMediaType:b}))},Ws=(p,f,m,h)=>{m.type="boolean"},Rr=(p,f,m,h)=>{q(p,f,m,h,"Custom types cannot be represented in JSON Schema")},Gs=(p,f,m,h)=>{q(p,f,m,h,"Function types cannot be represented in JSON Schema")},Dr=(p,f,m,h)=>{q(p,f,m,h,"Transforms cannot be represented in JSON Schema")},Xs=(p,f,m,h)=>{q(p,f,m,h,"Map cannot be represented in JSON Schema")},Ys=(p,f,m,h)=>{q(p,f,m,h,"Set cannot be represented in JSON Schema")},jr=(p,f,m,h)=>{let g=m,_=p._zod.def,{minimum:x,maximum:y}=te(p);if(typeof x==="number")g.minItems=x;if(typeof y==="number")g.maxItems=y;g.type="array",g.items=F(_.element,f,{...h,path:[...h.path,"items"]})};function tt(p){let f=p._zod.def;if(f.type==="pipe"&&f.in._zod.traits.has("$ZodTransform"))return tt(f.out);if(f.type==="catch")return tt(f.innerType);return p._zod.optin}var Lr=(p,f,m,h)=>{let g=m,_=p._zod.def,x=_.shape;if(Object.getOwnPropertySymbols(x).length&&q(p,f,g,h,"Symbol keys cannot be represented in JSON Schema"))return;g.type="object",g.properties={};for(let v in x)ie(g.properties,v,F(x[v],f,{...h,path:[...h.path,"properties",v]}));let b=[];for(let v of Object.keys(x)){let k=_.shape[v];if(f.io==="input"?tt(k)===void 0:k._zod.optout===void 0)b.push(v)}if(b.length>0)g.required=b;if(_.catchall?._zod.def.type==="never")g.additionalProperties=!1;else if(!_.catchall){if(f.io==="output")g.additionalProperties=!1}else if(_.catchall)g.additionalProperties=F(_.catchall,f,{...h,path:[...h.path,"additionalProperties"]})},Fr=(p,f,m,h)=>{let g=p._zod.def,_=g.inclusive===!1,x=g.options.map((y,b)=>F(y,f,{...h,path:[...h.path,_?"oneOf":"anyOf",b]}));if(_)m.oneOf=x;else m.anyOf=x},Mr=(p,f,m,h)=>{let g=p._zod.def,_=F(g.left,f,{...h,path:[...h.path,"allOf",0]}),x=F(g.right,f,{...h,path:[...h.path,"allOf",1]}),y=(v)=>("allOf"in v)&&Object.keys(v).length===1,b=[...y(_)?_.allOf:[_],...y(x)?x.allOf:[x]];m.allOf=b,f.intersections.push(b)},qs=(p,f,m,h)=>{let g=m,_=p._zod.def;g.type="array";let x=f.target==="draft-2020-12"?"prefixItems":"items",y=f.target==="draft-2020-12"?"items":f.target==="openapi-3.0"?"items":"additionalItems",b=_.items.map((T,N)=>F(T,f,{...h,path:[...h.path,x,N]})),v=_.rest?F(_.rest,f,{...h,path:[...h.path,y,...f.target==="openapi-3.0"?[_.items.length]:[]]}):null,k=_.items.length;while(k>0){let T=_.items[k-1];if(!(f.io==="input"?tt(T)!==void 0:T._zod.optout==="optional"))break;k--}let S=_.items.length,O=!_.rest;if(f.target==="draft-2020-12"){if(g.prefixItems=b,O)g.items=!1;else if(v)g.items=v;if(k>0)g.minItems=k;if(O)g.maxItems=S}else if(f.target==="openapi-3.0"){if(g.items={anyOf:b},v)g.items.anyOf.push(v);if(k>0)g.minItems=k;if(O)g.maxItems=S}else{if(g.items=b,O)g.additionalItems=!1;else if(v)g.additionalItems=v;if(k>0)g.minItems=k;if(O)g.maxItems=S}let{minimum:I,maximum:A}=te(p);if(typeof I==="number")g.minItems=I;if(typeof A==="number")g.maxItems=A};function kr(p,f,m){if(f.$ref){if(m.has(f))return f;m.add(f);let A=p.get(f)?.def;if(!A)return f;let T=kr(p,A,m);return T===A?f:T}for(let A of["anyOf","oneOf"]){let T=f[A];if(!Array.isArray(T))continue;let N=T.map((D)=>kr(p,D,m));if(N.some((D,fe)=>D!==T[fe]))f={...f,[A]:N}}let h=Array.isArray(f.type)?f.type:[f.type],g=!h.includes("string")&&h.some((A)=>A==="number"||A==="integer"),_=f.enum??(f.const!==void 0?[f.const]:void 0);if(!g&&!_?.some((A)=>typeof A==="number"))return f;let{minimum:x,maximum:y,exclusiveMinimum:b,exclusiveMaximum:v,multipleOf:k,format:S,id:O,...I}=f;if(I.enum)I.enum=I.enum.map((A)=>typeof A==="number"?String(A):A);else if(typeof I.const==="number")I.const=String(I.const);if(!g)return I;if(I.type="string",!_)I.pattern=(h.includes("number")?Be:Xt).source;return I}var Zr=new WeakMap;function wu(p){let f=new Map;for(let h of p.seen.values())if(h.def&&!f.has(h.schema))f.set(h.schema,h);let m=new Map;for(let h of Zr.get(p)??[]){let g=p.seen.get(h),_=(g?.def??g?.schema)?.propertyNames;if(!_||_===!0||m.has(_))continue;let x=kr(f,_,new Set);if(x!==_)m.set(_,x)}if(!m.size)return;for(let h of p.seen.values())for(let g of[h.schema,h.def]){let _=g&&m.get(g.propertyNames);if(_)g.propertyNames=_}}var Ur=(p,f,m,h)=>{let g=m,_=p._zod.def;g.type="object";let x=_.keyType,y=te(x).patterns;if(_.mode==="loose"&&y&&y.size>0){let k=F(_.valueType,f,{...h,path:[...h.path,"patternProperties","*"]});g.patternProperties={};for(let S of y)ie(g.patternProperties,js(S).source,k)}else{if(f.target==="draft-07"||f.target==="draft-2020-12"){g.propertyNames=F(_.keyType,f,{...h,path:[...h.path,"propertyNames"]});let k=Zr.get(f);if(!k)k=[],Zr.set(f,k),f.deferred.push(()=>wu(f));k.push(p)}g.additionalProperties=F(_.valueType,f,{...h,path:[...h.path,"additionalProperties"]})}let b=x._zod.values,v=f.io==="input"&&tt(_.valueType)!==void 0;if(b&&!_.partial&&!v){let k=[...b].filter((S)=>typeof S==="string"||typeof S==="number");if(k.length>0)g.required=k.map(String)}},Br=(p,f,m,h)=>{let g=p._zod.def,_=F(g.innerType,f,h),x=f.seen.get(p);if(f.target==="openapi-3.0")x.ref=g.innerType,m.nullable=!0;else m.anyOf=[_,{type:"null"}]},Jr=(p,f,m,h)=>{let g=p._zod.def;F(g.innerType,f,h);let _=f.seen.get(p);_.ref=g.innerType},Kr=Symbol();function Hs(p,f,m,h,g){let _=!1,x=JSON.stringify(p,(y,b)=>{if(typeof b!=="bigint")return b;return _=!0,null});if(!_)return JSON.parse(x);return q(f,m,h,g,"BigInt defaults cannot be represented in JSON Schema"),Kr}var Vr=(p,f,m,h)=>{let g=p._zod.def;F(g.innerType,f,h);let _=f.seen.get(p);_.ref=g.innerType;let x=Hs(g.defaultValue,p,f,m,h);if(x!==Kr)m.default=x},Wr=(p,f,m,h)=>{let g=p._zod.def;F(g.innerType,f,h);let _=f.seen.get(p);if(_.ref=g.innerType,f.io!=="input")return;let x=Hs(g.defaultValue,p,f,m,h);if(x!==Kr)m._prefault=x},Gr=(p,f,m,h)=>{let g=p._zod.def;F(g.innerType,f,h);let _=f.seen.get(p);_.ref=g.innerType;let x;try{x=g.catchValue(void 0)}catch{q(p,f,m,h,"Dynamic catch values are not supported in JSON Schema");return}m.default=x},Xr=(p,f,m,h)=>{let g=p._zod.def,_=g.in._zod.traits.has("$ZodTransform"),x=f.io==="input"?_?g.out:g.in:g.out;F(x,f,h);let y=f.seen.get(p);y.ref=x},Yr=(p,f,m,h)=>{let g=p._zod.def;F(g.innerType,f,h);let _=f.seen.get(p);_.ref=g.innerType,m.readOnly=!0},Qs=(p,f,m,h)=>{let g=p._zod.def;F(g.innerType,f,h);let _=f.seen.get(p);_.ref=g.innerType},Ot=(p,f,m,h)=>{let g=p._zod.def;F(g.innerType,f,h);let _=f.seen.get(p);_.ref=g.innerType},qr=(p,f,m,h)=>{let g=p._zod.innerType;F(g,f,h);let _=f.seen.get(p);_.ref=g},Ts={string:Pr,number:Sr,boolean:Or,bigint:Ls,symbol:Fs,null:Ir,undefined:Ms,void:Us,never:Ar,any:Er,unknown:Tr,date:Bs,enum:Nr,literal:Cr,nan:Js,template_literal:Ks,file:Vs,success:Ws,custom:Rr,function:Gs,transform:Dr,map:Xs,set:Ys,array:jr,object:Lr,union:Fr,intersection:Mr,tuple:qs,record:Ur,nullable:Br,nonoptional:Jr,default:Vr,prefault:Wr,catch:Gr,pipe:Xr,readonly:Yr,promise:Qs,optional:Ot,lazy:qr};function ne(p,f){if("_idmap"in p){let h=p,g=He({...f,processors:Ts}),_={};for(let b of h._idmap.entries()){let[v,k]=b;F(k,g)}let x={},y={registry:h,uri:f?.uri,defs:_};g.external=y;for(let b of h._idmap.entries()){let[v,k]=b;Qe(g,k),ie(x,v,et(g,k))}if(Object.keys(_).length>0){let b=g.target==="draft-2020-12"?"$defs":"definitions";x.__shared={[b]:_}}return{schemas:x}}let m=He({...f,processors:Ts});return F(p,m),Qe(m,p),et(m,p)}var ec=new WeakSet([Object.prototype,Error.prototype]);function It(p,f,m){Object.defineProperty(p,f,{configurable:!0,enumerable:!1,get(){let h=m(this);return Object.defineProperty(this,f,{value:h,configurable:!0,writable:!0}),h},set(h){Object.defineProperty(this,f,{value:h,configurable:!0,writable:!0})}})}var Eu=(p,f)=>{Zn.init(p,f),p.name="ZodError";let m=Object.getPrototypeOf(p);if(ec.has(m))return;ec.add(m),It(m,"format",(h)=>(g)=>Sn(h,g)),It(m,"flatten",(h)=>(g)=>Pn(h,g)),It(m,"addIssue",(h)=>(g)=>{h.issues.push(g),h.message=JSON.stringify(h.issues,Le,2)}),It(m,"addIssues",(h)=>(g)=>{h.issues.push(...g),h.message=JSON.stringify(h.issues,Le,2)}),Object.defineProperty(m,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var pe=Z("ZodError",Eu,void 0,{Parent:Error});var tc=lt(pe),rc=pt(pe),J=ft(pe),nc=dt(pe),oc=In(pe),ic=An(pe),sc=En(pe),cc=Tn(pe),uc=Nn(pe),ac=Cn(pe),lc=Rn(pe),pc=Dn(pe);function Nu(){if(!ee.localeError)ae(ar())}function Et(){if(!ee.memoizer)ae({memoizer:Mi()})}var M=Z("ZodType",(p,f)=>(Nu(),L.init(p,f),p.def=f,p.type=f.type,p),{check(...p){let f=this.def;return this.clone(se(f,{checks:[...f.checks??[],...p.map((m)=>typeof m==="function"?{_zod:{check:m,def:{check:"custom"},onattach:[]}}:m)]}),{parent:!0})},with(...p){return this.check(...p)},clone(p,f){return _e(this,p,f)},brand(){return this},register(p,f){return p.add(this,f),this},refine(p,f){return this.check(Za(p,f))},superRefine(p,f){return this.check(Pa(p,f))},overwrite(p){return this.check(Ze(p))},optional(){return l(this)},exactOptional(){return fa(this)},nullable(){return mc(this)},nullish(){return l(mc(this))},nonoptional(p){return xa(this,p)},array(){return n(this)},or(p){return a([this,p])},and(p){return R(this,p)},transform(p){return hc(this,vc(p))},default(p){return ha(this,p)},prefault(p){return _a(this,p)},catch(p){return ba(this,p)},pipe(p){return hc(this,p)},readonly(){return $a(this)},describe(p){let f=this.clone();return Ie.add(f,{description:p}),f},meta(...p){if(p.length===0)return Ie.get(this);let f=this.clone();return Ie.add(f,p[0]),f},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(p,...f){return f.length===0?p(this):p(this,...f)},get "~standard"(){return ut(this,"~standard",{...tr(this),jsonSchema:{input:qe(this,"input"),output:qe(this,"output")}})},set "~standard"(p){ze(this,"~standard",p)},parse:function p(f,m){return tc(this,f,m,{callee:p})},parseAsync:async function p(f,m){return await rc(this,f,m,{callee:p})},safeParse(p,f){return J(this,p,f)},async safeParseAsync(p,f){return nc(this,p,f)},get spa(){return this?.safeParseAsync},set spa(p){ze(this,"spa",p)},validate(p,f){return Kt(this,p,f)},validateAsync(p,f){return Vt(this,p,f)},encode:function p(f,m){return oc(this,f,m,{callee:p})},decode:function p(f,m){return ic(this,f,m,{callee:p})},encodeAsync:async function p(f,m){return await sc(this,f,m,{callee:p})},decodeAsync:async function p(f,m){return await cc(this,f,m,{callee:p})},safeEncode(p,f){return uc(this,p,f)},safeDecode(p,f){return ac(this,p,f)},async safeEncodeAsync(p,f){return lc(this,p,f)},async safeDecodeAsync(p,f){return pc(this,p,f)},toJSONSchema(p){return Ss(this,{})(p)},get description(){return Ie.get(this)?.description},get _def(){return this._zod.def}}),gc=Z("_ZodString",(p,f)=>{xt.init(p,f),M.init(p,f),p._zod.processJSONSchema=(m,h,g)=>Pr(p,m,h,g)},bn({format:(p)=>te(p).format??null,minLength:(p)=>te(p).minimum??null,maxLength:(p)=>te(p).maximum??null},{regex(...p){return this.check(dr(...p))},includes(...p){return this.check(gr(...p))},startsWith(...p){return this.check(_r(...p))},endsWith(...p){return this.check(xr(...p))},min(...p){return this.check(Ee(...p))},max(...p){return this.check(Pt(...p))},length(...p){return this.check(St(...p))},nonempty(...p){return this.check(Ee(1,...p))},lowercase(p){return this.check(mr(p))},uppercase(p){return this.check(hr(p))},trim(){return this.check(br())},normalize(...p){return this.check(yr(...p))},toLowerCase(){return this.check(vr())},toUpperCase(){return this.check(zr())},slugify(){return this.check($r())}})),Cu=Z("ZodString",(p,f)=>{xt.init(p,f),gc.init(p,f)},{email(p){return this.check(pr(_c,p))},url(p){return this.check(fr(xc,p))},jwt(p){return this.check(ls(Qu,p))},emoji(p){return this.check(Yi(Lu,p))},guid(p){return this.check(Ki(ju,p))},uuid(p){return this.check(Vi(At,p))},uuidv4(p){return this.check(Wi(At,p))},uuidv6(p){return this.check(Gi(At,p))},uuidv7(p){return this.check(Xi(At,p))},nanoid(p){return this.check(qi(Fu,p))},cuid(p){return this.check(Hi(Mu,p))},cuid2(p){return this.check(Qi(Uu,p))},ulid(p){return this.check(es(Bu,p))},base64(p){return this.check(cs(Yu,p))},base64url(p){return this.check(us(qu,p))},xid(p){return this.check(ts(Ju,p))},ksuid(p){return this.check(rs(Ku,p))},ipv4(p){return this.check(ns(Vu,p))},ipv6(p){return this.check(os(Wu,p))},cidrv4(p){return this.check(is(Gu,p))},cidrv6(p){return this.check(ss(Xu,p))},e164(p){return this.check(as(Hu,p))},datetime(p){return this.check(G(re,p))},date(p){return this.check(W(oe,p))},time(p){return this.check(ps(Ru,p))},duration(p){return this.check(fs(Du,p))}});function e(p){return Ji(Cu,p)}var K=Z("ZodStringFormat",(p,f)=>{B.init(p,f),gc.init(p,f)}),re=Z("ZodISODateTime",(p,f)=>{qo.init(p,f),K.init(p,f)}),oe=Z("ZodISODate",(p,f)=>{Ho.init(p,f),K.init(p,f)}),Ru=Z("ZodISOTime",(p,f)=>{Qo.init(p,f),K.init(p,f)}),Du=Z("ZodISODuration",(p,f)=>{ei.init(p,f),K.init(p,f)}),_c=Z("ZodEmail",(p,f)=>{Fo.init(p,f),K.init(p,f)});function ue(p){return pr(_c,p)}var ju=Z("ZodGUID",(p,f)=>{jo.init(p,f),K.init(p,f)});var At=Z("ZodUUID",(p,f)=>{Lo.init(p,f),K.init(p,f)});var xc=Z("ZodURL",(p,f)=>{Bo.init(p,f),K.init(p,f)});function Y(p){return fr(xc,p)}var Lu=Z("ZodEmoji",(p,f)=>{Jo.init(p,f),K.init(p,f)});var Fu=Z("ZodNanoID",(p,f)=>{Ko.init(p,f),K.init(p,f)});var Mu=Z("ZodCUID",(p,f)=>{Vo.init(p,f),K.init(p,f)});var Uu=Z("ZodCUID2",(p,f)=>{Wo.init(p,f),K.init(p,f)});var Bu=Z("ZodULID",(p,f)=>{Go.init(p,f),K.init(p,f)});var Ju=Z("ZodXID",(p,f)=>{Xo.init(p,f),K.init(p,f)});var Ku=Z("ZodKSUID",(p,f)=>{Yo.init(p,f),K.init(p,f)});var Vu=Z("ZodIPv4",(p,f)=>{ti.init(p,f),K.init(p,f)});var Wu=Z("ZodIPv6",(p,f)=>{ni.init(p,f),K.init(p,f)});var Gu=Z("ZodCIDRv4",(p,f)=>{oi.init(p,f),K.init(p,f)});var Xu=Z("ZodCIDRv6",(p,f)=>{ii.init(p,f),K.init(p,f)});var Yu=Z("ZodBase64",(p,f)=>{ci.init(p,f),K.init(p,f)});var qu=Z("ZodBase64URL",(p,f)=>{ui.init(p,f),K.init(p,f)});var Hu=Z("ZodE164",(p,f)=>{ai.init(p,f),K.init(p,f)});var Qu=Z("ZodJWT",(p,f)=>{li.init(p,f),K.init(p,f)});var X=Z("ZodNumber",(p,f)=>{nr.init(p,f),M.init(p,f),p._zod.processJSONSchema=(m,h,g)=>Sr(p,m,h,g),p.isFinite=!0},bn({minValue:(p)=>{let{minimum:f,exclusiveMinimum:m}=te(p);return Math.max(f??Number.NEGATIVE_INFINITY,m??Number.NEGATIVE_INFINITY)},maxValue:(p)=>{let{maximum:f,exclusiveMaximum:m}=te(p);return Math.min(f??Number.POSITIVE_INFINITY,m??Number.POSITIVE_INFINITY)},isInt:(p)=>{let{isInt:f,multipleOf:m}=te(p);return!!f||!!m?.some(Number.isSafeInteger)},format:(p)=>te(p).format??null},{gt(p,f){return this.check(kt(p,f))},gte(p,f){return this.check(Xe(p,f))},min(p,f){return this.check(Xe(p,f))},lt(p,f){return this.check(wt(p,f))},lte(p,f){return this.check(Ge(p,f))},max(p,f){return this.check(Ge(p,f))},int(p){return this.check(fc(p))},safe(p){return this.check(fc(p))},positive(p){return this.check(kt(0,p))},nonnegative(p){return this.check(Xe(0,p))},negative(p){return this.check(wt(0,p))},nonpositive(p){return this.check(Ge(0,p))},multipleOf(p,f){return this.check(Zt(p,f))},step(p,f){return this.check(Zt(p,f))},finite(){return this}}));function o(p){return ds(X,p)}var ea=Z("ZodNumberFormat",(p,f)=>{pi.init(p,f),X.init(p,f)});function fc(p){return ms(ea,p)}var ta=Z("ZodBoolean",(p,f)=>{fi.init(p,f),M.init(p,f),p._zod.processJSONSchema=(m,h,g)=>Or(p,m,h,g)});function i(p){return hs(ta,p)}var ra=Z("ZodNull",(p,f)=>{di.init(p,f),M.init(p,f),p._zod.processJSONSchema=(m,h,g)=>Ir(p,m,h,g)});function P(p){return gs(ra,p)}var na=Z("ZodAny",(p,f)=>{mi.init(p,f),M.init(p,f),p._zod.processJSONSchema=(m,h,g)=>Er(p,m,h,g)});function de(){return _s(na)}var oa=Z("ZodUnknown",(p,f)=>{hi.init(p,f),M.init(p,f),p._zod.processJSONSchema=(m,h,g)=>Tr(p,m,h,g)});function c(){return xs(oa)}var ia=Z("ZodNever",(p,f)=>{gi.init(p,f),M.init(p,f),p._zod.processJSONSchema=(m,h,g)=>Ar(p,m,h,g)});function sa(p){return ys(ia,p)}var ca=Z("ZodArray",(p,f)=>{Et(),_i.init(p,f),M.init(p,f),p._zod.processJSONSchema=(m,h,g)=>jr(p,m,h,g),p.element=f.element},{min(p,f){return this.check(Ee(p,f))},nonempty(p){return this.check(Ee(1,p))},max(p,f){return this.check(Pt(p,f))},length(p,f){return this.check(St(p,f))},unwrap(){return this.element}});function n(p,f){return bs(ca,p,f)}var yc=Z("ZodObject",(p,f)=>{Et(),bi.init(p,f),M.init(p,f),p._zod.processJSONSchema=(m,h,g)=>Lr(p,m,h,g),Lc(p,"shape",(m)=>m._zod.def.shape,!1)},{keyof(){return d(Object.keys(this._zod.def.shape))},catchall(p){return this.clone(se(this._zod.def,{catchall:p}))},passthrough(){return this.clone(se(this._zod.def,{catchall:c()}))},loose(){return this.clone(se(this._zod.def,{catchall:c()}))},strict(){return this.clone(se(this._zod.def,{catchall:sa()}))},strip(){return this.clone(se(this._zod.def,{catchall:void 0}))},extend(p){return Ac(this,p)},safeExtend(p){return Ec(this,p)},merge(p){return Tc(this,p)},pick(p){return Oc(this,p)},omit(p){return Ic(this,p)},partial(...p){return gn(zc,this,p[0])},exactPartial(...p){return gn($c,this,p[0],"exactPartial")},required(...p){return Nc(wc,this,p[0])}});function t(p,f){let m={type:"object",shape:p??{},...E(f)};return new yc(m)}function u(p,f){return new yc({type:"object",shape:p,catchall:c(),...E(f)})}var bc=Z("ZodUnion",(p,f)=>{or.init(p,f),M.init(p,f),p._zod.processJSONSchema=(m,h,g)=>Fr(p,m,h,g),p.options=f.options});function a(p,f){return new bc({type:"union",options:p,...E(f)})}var ua=Z("ZodDiscriminatedUnion",(p,f)=>{bc.init(p,f),vi.init(p,f)});function w(p,f,m){return new ua({type:"union",options:f,discriminator:p,...E(m)})}var aa=Z("ZodIntersection",(p,f)=>{zi.init(p,f),M.init(p,f),p._zod.processJSONSchema=(m,h,g)=>Mr(p,m,h,g)});function R(p,f){return new aa({type:"intersection",left:p,right:f})}var dc=Z("ZodRecord",(p,f)=>{Et(),$i.init(p,f),M.init(p,f),p._zod.processJSONSchema=(m,h,g)=>Ur(p,m,h,g),p.keyType=f.keyType,p.valueType=f.valueType});function s(p,f,m){if(!f||!f._zod)return new dc({type:"record",keyType:e(),valueType:p,...E(f)});return new dc({type:"record",keyType:p,valueType:f,...E(m)})}var Qr=Z("ZodEnum",(p,f)=>{wi.init(p,f),M.init(p,f),p._zod.processJSONSchema=(h,g,_)=>Nr(p,h,g,_),p.enum=f.entries,p.options=[...p._zod.values];let m=new Set(Object.keys(f.entries));p.extract=(h,g)=>{let _={};for(let x of h)if(m.has(x))_[x]=f.entries[x];else throw Error(`Key ${x} not found in enum`);return new Qr({...f,checks:[],...E(g),entries:_})},p.exclude=(h,g)=>{let _={...f.entries};for(let x of h)if(m.has(x))delete _[x];else throw Error(`Key ${x} not found in enum`);return new Qr({...f,checks:[],...E(g),entries:_})}});function d(p,f){let m=Array.isArray(p)?Object.fromEntries(p.map((h)=>[h,h])):p;return new Qr({type:"enum",entries:m,...E(f)})}var la=Z("ZodLiteral",(p,f)=>{ki.init(p,f),M.init(p,f),p._zod.processJSONSchema=(m,h,g)=>Cr(p,m,h,g),p.values=new Set(f.values),Object.defineProperty(p,"value",{get(){if(f.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return f.values[0]}})});function r(p,f){return new la({type:"literal",values:Array.isArray(p)?p:[p],...E(f)})}var pa=Z("ZodTransform",(p,f)=>{Et(),Zi.init(p,f),M.init(p,f),p._zod.processJSONSchema=(m,h,g)=>Dr(p,m,h,g),p._zod.parse=(m,h)=>{if(h.direction==="backward")throw new Ue(p.constructor.name);m.addIssue=(_)=>{if(typeof _==="string")m.issues.push(Oe(_,m.value,f));else{let x=_;if(x.fatal)x.continue=!1;if(x.code??(x.code="custom"),!("input"in x))x.input=m.value;x.inst??(x.inst=p),m.issues.push(Oe(x))}};let g=f.transform(m.value,m);if(g instanceof Promise)return g.then((_)=>(m.value=_,m));return m.value=g,m}});function vc(p){return new pa({type:"transform",transform:p})}var zc=Z("ZodOptional",(p,f)=>{ir.init(p,f),M.init(p,f),p._zod.processJSONSchema=(m,h,g)=>Ot(p,m,h,g),p.unwrap=()=>p._zod.def.innerType});function l(p){return new zc({type:"optional",innerType:p})}var $c=Z("ZodExactOptional",(p,f)=>{Pi.init(p,f),M.init(p,f),p._zod.processJSONSchema=(m,h,g)=>Ot(p,m,h,g),p.unwrap=()=>p._zod.def.innerType});function fa(p){return new $c({type:"optional",innerType:p})}var da=Z("ZodNullable",(p,f)=>{Si.init(p,f),M.init(p,f),p._zod.processJSONSchema=(m,h,g)=>Br(p,m,h,g),p.unwrap=()=>p._zod.def.innerType});function mc(p){return new da({type:"nullable",innerType:p})}var ma=Z("ZodDefault",(p,f)=>{Oi.init(p,f),M.init(p,f),p._zod.processJSONSchema=(m,h,g)=>Vr(p,m,h,g),p.unwrap=()=>p._zod.def.innerType,p.removeDefault=p.unwrap});function ha(p,f){return new ma({type:"default",innerType:p,get defaultValue(){return typeof f==="function"?f():jt(f)}})}var ga=Z("ZodPrefault",(p,f)=>{Ii.init(p,f),M.init(p,f),p._zod.processJSONSchema=(m,h,g)=>Wr(p,m,h,g),p.unwrap=()=>p._zod.def.innerType});function _a(p,f){return new ga({type:"prefault",innerType:p,get defaultValue(){return typeof f==="function"?f():jt(f)}})}var wc=Z("ZodNonOptional",(p,f)=>{Ai.init(p,f),M.init(p,f),p._zod.processJSONSchema=(m,h,g)=>Jr(p,m,h,g),p.unwrap=()=>p._zod.def.innerType});function xa(p,f){return new wc({type:"nonoptional",innerType:p,...E(f)})}var ya=Z("ZodCatch",(p,f)=>{Ei.init(p,f),M.init(p,f),p._zod.processJSONSchema=(m,h,g)=>Gr(p,m,h,g),p.unwrap=()=>p._zod.def.innerType,p.removeCatch=p.unwrap});function ba(p,f){return new ya({type:"catch",innerType:p,catchValue:typeof f==="function"?f:vn(f)})}var kc=Z("ZodPipe",(p,f)=>{sr.init(p,f),M.init(p,f),p._zod.processJSONSchema=(m,h,g)=>Xr(p,m,h,g),p.in=f.in,p.out=f.out});function hc(p,f){return new kc({type:"pipe",in:p,out:f})}var va=Z("ZodPreprocess",(p,f)=>{kc.init(p,f),Ti.init(p,f)}),za=Z("ZodReadonly",(p,f)=>{Ni.init(p,f),M.init(p,f),p._zod.processJSONSchema=(m,h,g)=>Yr(p,m,h,g),p.unwrap=()=>p._zod.def.innerType});function $a(p){return new za({type:"readonly",innerType:p})}var wa=Z("ZodLazy",(p,f)=>{Ci.init(p,f),M.init(p,f),p._zod.processJSONSchema=(m,h,g)=>qr(p,m,h,g),p.unwrap=()=>p._zod.def.getter()});function j(p){return new wa({type:"lazy",getter:p})}var ka=Z("ZodCustom",(p,f)=>{Ri.init(p,f),M.init(p,f),p._zod.processJSONSchema=(m,h,g)=>Rr(p,m,h,g)});function Za(p,f={}){return vs(ka,p,f)}function Pa(p,f){return zs(p,f)}function z(p,f){return new va({type:"pipe",in:vc(p),out:f})}export{ce,he,G,W,le,ne,J,e,re,oe,ue,Y,X,o,i,P,de,c,n,t,u,a,w,R,s,d,r,l,j,z};