broods 0.51.1 → 0.52.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -2856,8 +2856,9 @@ interface McpDefinitionConfig {
2856
2856
  command?: string[];
2857
2857
  /**
2858
2858
  * Hosted alternative to `url`: declare the server inline as
2859
- * `handler: createMcpHandler(...)` from @modelcontextprotocol/server,
2860
- * right next to the `defineMcp` call. The CLI bundles the defining module
2859
+ * `handler: createMcpHandler(factory, { legacy: "reject" })` from
2860
+ * @modelcontextprotocol/server, right next to the `defineMcp` call; Broods
2861
+ * speaks MCP 2026-07-28 only. The CLI bundles the defining module
2861
2862
  * and the platform hosts it, one invocation per batch of requests: with
2862
2863
  * `runtime` "auto" on Cloudflare Workers when the bundle builds for them,
2863
2864
  * on Lambda otherwise.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{G,we,Le,Ne,Ue,Fe,W,K,de,ee,y,Be,I,Re,B,te,je,ne,z,He,Ze,Ve,Ge,We,Ke,Je,Ye,Xe,Qe,et,tt,nt,rt,ot,st,it,at,ct,lt,ut,dt,pt,mt,ft,ht,gt,yt,St,bt,vt,_t,wt,Rt,$t,Ct,Et,kt,pe,R,g}from"./chunk-gqyk7vva.js";import{m,qe,Z,C}from"./chunk-njxsdp91.js";export{m as BroodsAccountApiError,C as BroodsAccountClient,B as BroodsClient,je as BroodsWebSocketClient,I as DEFAULT_CORE_BASE_URL,Re as IngressAcceptedError,Le as MAX_OBSERVABILITY_BACKFILL,de as USER_TOKEN_HEADER,ee as USER_TOKEN_MAX_TTL_MS,y as USER_TOKEN_SECRET_ENV,je as WebSocketClient,je as WebsocketClient,Ze as defineAgent,Ve as defineBroods,Ge as defineCron,ft as defineDiscordChannel,et as defineDiscordConnection,ht as defineGitHubChannel,tt as defineGitHubConnection,gt as defineGoogleChatChannel,nt as defineGoogleChatConnection,We as defineHarness,yt as defineInstagramChannel,rt as defineInstagramConnection,St as defineLinearChannel,ot as defineLinearConnection,bt as defineMatrixChannel,st as defineMatrixConnection,Ke as defineMcp,vt as defineMessengerChannel,it as defineMessengerConnection,_t as definePancakeChannel,at as definePancakeConnection,Je as definePolicy,Ye as defineSandbox,Xe as defineSkill,wt as defineSlackChannel,ct as defineSlackConnection,Rt as defineTeamsChannel,lt as defineTeamsConnection,$t as defineTelegramChannel,ut as defineTelegramConnection,Ct as defineTwilioChannel,dt as defineTwilioConnection,Et as defineWhatsAppChannel,pt as defineWhatsAppConnection,Qe as defineWorkspace,kt as defineZaloChannel,mt as defineZaloConnection,He as env,qe as envPlaceholder,pe as isBroodsConfig,R as isConnectionDefinition,Ne as isLogLevel,Ue as isObservabilityClientMessage,g as isResource,Fe as isRootSpanKind,W as isSandboxLogId,K as isTraceId,te as normalizeHttpServiceUrl,we as readSseStream,Z as resolveEnvCredential,G as resolveRunEvents,Be as signUserToken,ne as toWebSocketBaseUrl,z as webSocketSubprotocols};
1
+ import{L,ae,Se,he,be,ve,U,F,ee,G,g,_e,z,ce,j,K,fe,W,k,we,Re,$e,Ce,Ee,ke,Te,ze,Pe,Ie,xe,Ae,Oe,Me,Ne,je,qe,De,Le,Ue,Fe,Be,He,Ze,Ve,Ge,Ke,We,Je,Ye,Xe,Qe,et,tt,nt,rt,ot,st,te,_,f}from"./chunk-yqbtb9cd.js";import{p,ge,q,w}from"./chunk-a8zhzzj7.js";export{p as BroodsAccountApiError,w as BroodsAccountClient,j as BroodsClient,fe as BroodsWebSocketClient,z as DEFAULT_CORE_BASE_URL,ce as IngressAcceptedError,Se as MAX_OBSERVABILITY_BACKFILL,ee as USER_TOKEN_HEADER,G as USER_TOKEN_MAX_TTL_MS,g as USER_TOKEN_SECRET_ENV,fe as WebSocketClient,fe as WebsocketClient,Re as defineAgent,$e as defineBroods,Ce as defineCron,Ve as defineDiscordChannel,xe as defineDiscordConnection,Ge as defineGitHubChannel,Ae as defineGitHubConnection,Ke as defineGoogleChatChannel,Oe as defineGoogleChatConnection,Ee as defineHarness,We as defineInstagramChannel,Me as defineInstagramConnection,Je as defineLinearChannel,Ne as defineLinearConnection,Ye as defineMatrixChannel,je as defineMatrixConnection,ke as defineMcp,Xe as defineMessengerChannel,qe as defineMessengerConnection,Qe as definePancakeChannel,De as definePancakeConnection,Te as definePolicy,ze as defineSandbox,Pe as defineSkill,et as defineSlackChannel,Le as defineSlackConnection,tt as defineTeamsChannel,Ue as defineTeamsConnection,nt as defineTelegramChannel,Fe as defineTelegramConnection,rt as defineTwilioChannel,Be as defineTwilioConnection,ot as defineWhatsAppChannel,He as defineWhatsAppConnection,Ie as defineWorkspace,st as defineZaloChannel,Ze as defineZaloConnection,we as env,ge as envPlaceholder,te as isBroodsConfig,_ as isConnectionDefinition,he as isLogLevel,be as isObservabilityClientMessage,f as isResource,ve as isRootSpanKind,U as isSandboxLogId,F as isTraceId,K as normalizeHttpServiceUrl,ae as readSseStream,q as resolveEnvCredential,L as resolveRunEvents,_e as signUserToken,W as toWebSocketBaseUrl,k as webSocketSubprotocols};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "broods",
3
- "version": "0.51.1",
3
+ "version": "0.52.1",
4
4
  "description": "CLI + TypeScript SDK for the broods agent platform.",
5
5
  "keywords": [
6
6
  "agents",
@@ -52,7 +52,8 @@
52
52
  "check": "tsc --noEmit && tsc --noEmit -p tsconfig.scripts.json",
53
53
  "pack:check": "bun run build && publint && attw --pack .",
54
54
  "prepublishOnly": "bun run build",
55
- "test": "bun test"
55
+ "test": "bun test",
56
+ "test:desktop": "BROODS_TEST_DESKTOP=1 bun test tests/cli-desktop.test.ts"
56
57
  },
57
58
  "dependencies": {
58
59
  "@modelcontextprotocol/client": "^2.2.0",
@@ -65,7 +66,7 @@
65
66
  "@chat-adapter/github": "^4.38.1",
66
67
  "@chat-adapter/slack": "^4.38.1",
67
68
  "@chat-adapter/telegram": "^4.38.1",
68
- "@modelcontextprotocol/server": "2.2.0",
69
+ "@modelcontextprotocol/server": "2.3.1",
69
70
  "@types/bun": "^1.3.14",
70
71
  "@typescript/typescript6": "6.0.2",
71
72
  "ai": "^7.0.137",
@@ -1 +0,0 @@
1
- import{q}from"./chunk-ware5wzj.js";import{Z,C}from"./chunk-njxsdp91.js";import{e,o,a,l,s}from"./chunk-qxxrmem2.js";var R={project:e().optional(),stage:e().optional()},M={sandboxId:e().min(1),reservationKey:e().min(1)},v=a().describe("Must be true, after the owner has agreed to this delete."),E="'********' keeps a stored secret and null deletes a field: never send a placeholder you did not read from a get.",k=[{singular:"agent",plural:"agents",key:"agentId",createHint:"Needs name and config; a 409 returns the existing agentId.",deleteHint:"Deleting an agent also drops its runtime rows.",updateHint:E,list:(t)=>t.listAgents(),get:(t,r)=>t.getAgent(r),create:(t,r)=>t.createAgent(r),update:(t,r,n)=>t.updateAgent(r,n),remove:(t,r)=>t.deleteAgent(r)},{singular:"cron",plural:"crons",key:"cronId",createHint:"Needs name, agentId, scheduleExpression (rate/cron/at) and input or events.",list:(t)=>t.listCrons(),get:(t,r)=>t.getCron(r),create:(t,r)=>t.createCron(r),update:(t,r,n)=>t.updateCron(r,n),remove:(t,r)=>t.deleteCron(r)},{singular:"sandbox",plural:"sandboxes",key:"sandboxId",updateHint:E,list:(t)=>t.listSandboxes(),get:(t,r)=>t.getSandbox(r),create:(t,r)=>t.createSandbox(r),update:(t,r,n)=>t.updateSandbox(r,n),remove:(t,r)=>t.deleteSandbox(r)},{singular:"workspace",plural:"workspaces",key:"workspaceId",list:(t)=>t.listWorkspaces(),get:(t,r)=>t.getWorkspace(r),create:(t,r)=>t.createWorkspace(r),update:(t,r,n)=>t.updateWorkspace(r,n),remove:(t,r)=>t.deleteWorkspace(r)},{singular:"policy",plural:"policies",key:"policyId",createHint:"Agent-runtime policy document (tool.call, skill.load), not API credential scoping.",list:(t)=>t.listPolicies(),get:(t,r)=>t.getPolicy(r),create:(t,r)=>t.createPolicy(r),update:(t,r,n)=>t.updatePolicy(r,n),remove:(t,r)=>t.deletePolicy(r)},{singular:"role",plural:"roles",key:"roleId",createHint:"Needs name and a version-1 policy over the API namespace, e.g. agents:read. Account key only.",list:(t)=>t.listRoles(),get:(t,r)=>t.getRole(r),create:(t,r)=>t.createRole(r),update:(t,r,n)=>t.updateRole(r,n),remove:(t,r)=>t.deleteRole(r)},{singular:"channel",plural:"channels",key:"channelId",list:(t)=>t.listChannels(),get:(t,r)=>t.getChannel(r),create:(t,r)=>t.createChannel(r),update:(t,r,n)=>t.updateChannel(r,n),remove:(t,r)=>t.deleteChannel(r)},{singular:"skill",plural:"skills",key:"skillName",createHint:'source is "files" (base64), "json" or "github". The stored name comes from the SKILL.md frontmatter.',list:(t)=>t.listSkills(),get:(t,r)=>t.getSkill(r),create:(t,r)=>t.createSkill(r),remove:(t,r)=>t.deleteSkill(r)},{singular:"mcp",plural:"mcp",key:"serverId",scoped:!0,list:(t,r)=>t.listMcp(r),get:(t,r)=>t.getMcp(r),create:(t,r,n)=>t.createMcp(n,r),update:(t,r,n)=>t.updateMcp(r,n),remove:(t,r)=>t.deleteMcp(r)}];function Lt(t={}){let r=Z()?new C({}):null;if(!r&&!t.cli)throw Error("broods mcp needs a credential: set BROODS_SESSION_TOKEN or BROODS_ACCOUNT_SECRET, or run `broods login`.");let n=new q({name:"broods",version:"1"},{capabilities:{tools:{}}});if(r){for(let i of k)B(n,r,i,t.scope??{});j(n,r)}if(t.cli)O(n,t.cli);if(t.allowDestructive)x(n,r,t.cli??null);return n}function y(t,r){if(!t)throw Error(`Refusing without confirm:true. ${r}`)}async function d(t){try{return P(await t())}catch(r){return A(r)}}function A(t){return{content:[{type:"text",text:t instanceof Error?t.message:String(t)}],isError:!0}}function P(t){return{content:[{type:"text",text:JSON.stringify(t??null,null,2)}]}}function b(t,r,n,i){if(!t.scoped)return;let c=n??r.project,p=i??r.stage;if(!c||!p)throw Error(`${t.plural} live in one stage, so this call needs both 'project' and 'stage'`);return{project:c,stage:p}}function O(t,r){t.registerTool("list-orgs",{description:"Every organization this login can reach, with the current one marked.",inputSchema:{}},async()=>await d(async()=>{let n=await r.getOnboarding();return{currentOrgId:n.currentOrgId,orgs:n.orgs}})),t.registerTool("create-org",{description:"Create an organization and switch this login to it. Later calls act in the new org.",inputSchema:{name:e().min(1)}},async({name:n})=>await d(async()=>await r.createOnboardingOrg(n))),t.registerTool("select-org",{description:"Switch this login to another organization, by an orgId from list-orgs.",inputSchema:{orgId:e().min(1)}},async({orgId:n})=>await d(async()=>await r.selectOnboardingOrg(n))),t.registerTool("list-projects",{description:"Every project in the current org, empty ones last. Project names are not unique, so take the id from here.",inputSchema:{}},async()=>await d(async()=>await r.listProjects())),t.registerTool("list-stages",{description:"Every stage of one project, by project name.",inputSchema:{project:e().min(1)}},async({project:n})=>await d(async()=>await r.listStages(n))),t.registerTool("create-stage",{description:"Create a stage in a project, optionally cloning another stage's architecture and env vars. A project name that does not exist yet is created with it, which is the only way to make a project without deploying a manifest.",inputSchema:{project:e().min(1),name:e().min(1),from:e().optional().describe("Stage to clone architecture and env vars from.")}},async({project:n,name:i,from:c})=>await d(async()=>await r.createStage(n,i,c)))}function x(t,r,n){if(r)t.registerTool("rotate-secret",{description:"Rotate the account key. The current key stops working immediately and the new one is shown once, so this breaks every deployment and CI job still holding the old one. Requires confirm:true.",inputSchema:{confirm:v}},async({confirm:i})=>await d(async()=>(y(i,"Everything holding the current secret breaks the moment this runs."),await r.rotateSecret())));if(n)t.registerTool("delete-project",{description:"Delete a project and everything under it: stages, agents, canvas, env vars, crons and workspace files. Takes a projectId from list-projects and requires confirm:true.",inputSchema:{projectId:e().min(1),confirm:v}},async({projectId:i,confirm:c})=>await d(async()=>(y(c,`Project '${i}' and everything under it goes away: name it, get the owner's agreement, then retry.`),await n.deleteProject(i))))}function j(t,r){t.registerTool("list-cron-runs",{description:"Run history for one cron, newest first. Check this before telling anyone a cron fired.",inputSchema:{cronId:e().min(1),limit:o().int().positive().max(100).optional()}},async({cronId:i,limit:c})=>await d(async()=>await r.listCronRuns(i,c===void 0?{}:{limit:c})));let n=[["suspend-sandbox","Suspend a persistent sandbox reservation.",(i,c)=>r.suspendSandbox(i,c)],["resume-sandbox","Resume a suspended sandbox reservation.",(i,c)=>r.resumeSandbox(i,c)],["terminate-sandbox","Terminate a sandbox reservation and drop its live-instance row. Terminate only a sandbox you created, and never one holding state you did not put there.",(i,c)=>r.terminateSandbox(i,c)],["open-sandbox-terminal","Mint a short-lived sealed ticket for an interactive PTY session on a persistent sandbox.",(i,c)=>r.openSandboxTerminal(i,c)]];for(let[i,c,p]of n)t.registerTool(i,{description:c,inputSchema:M},async({sandboxId:f,reservationKey:g})=>await d(async()=>await p(f,g)));t.registerTool("snapshot-sandbox",{description:"Snapshot a sandbox reservation into an image its provider's sandboxes can pin with `snapshot` (sandbox, lambda, daytona, e2b or vercel; lambda builds for a few minutes).",inputSchema:{sandboxId:e().min(1),reservationKey:e().min(1),name:e().min(1)}},async({sandboxId:i,reservationKey:c,name:p})=>await d(async()=>await r.snapshotSandbox(i,c,p))),t.registerTool("upload-skill",{description:"Replace one skill's bundle wholesale (PUT, not a merge) by skillName. 'body' is the same source shape create-skill takes.",inputSchema:{id:e().min(1).describe("The skillName."),body:s(e(),l())}},async({id:i,body:c})=>await d(async()=>await r.uploadSkill(i,c))),t.registerTool("list-env-vars",{description:"List environment variable names. Values are write-only: the plane never returns them, so there is no read.",inputSchema:{}},async()=>await d(async()=>await r.listEnvVars())),t.registerTool("set-env-var",{description:"Create or replace one write-only environment variable. Reference it from a config as ${NAME} rather than inlining the value.",inputSchema:{name:e().min(1),value:e()}},async({name:i,value:c})=>await d(async()=>(await r.setEnvVar(i,c),{name:i,stored:!0}))),t.registerTool("delete-env-var",{description:"Delete one environment variable.",inputSchema:{name:e().min(1),confirm:v}},async({name:i,confirm:c})=>await d(async()=>(y(c,`Anything referencing \${${i}} breaks the moment this env var goes.`),{deleted:await r.deleteEnvVar(i),name:i}))),t.registerTool("assume-role",{description:"Exchange a role for a short-lived session token (default 1h, max 12h). Hand the returned token to whatever tool needs narrow access, as BROODS_SESSION_TOKEN. It is shown once and is not stored here.",inputSchema:{roleId:e().min(1),ttlSeconds:o().int().positive().max(43200).optional()}},async({roleId:i,ttlSeconds:c})=>await d(async()=>await r.assumeRole(i,c===void 0?{}:{ttlSeconds:c}))),t.registerTool("update-account",{description:"Rename this account or change its description. Everything else about an account is derived, not settable.",inputSchema:{username:e().optional(),description:e().nullable().optional()}},async({username:i,description:c})=>await d(async()=>await r.updateAccount({...i===void 0?{}:{username:i},...c===void 0?{}:{description:c}}))),t.registerTool("get-account",{description:"The account this server's credential resolves to. Run it first to confirm which tenant you are about to change.",inputSchema:{}},async()=>await d(async()=>await r.getAccount()))}function B(t,r,n,i){let c=e().min(1).describe(`The ${n.key}.`),p=n.scoped?` ${n.plural} live in one stage, so this also takes 'project' and 'stage'.`:"",{list:f,get:g,create:S,update:w,remove:_}=n;if(f){let u=`List every ${n.singular} on the account.${p}`;if(n.scoped)t.registerTool(`list-${n.plural}`,{description:u,inputSchema:R},async({project:h,stage:m})=>await d(async()=>await f(r,b(n,i,h,m))));else t.registerTool(`list-${n.plural}`,{description:u,inputSchema:{}},async()=>await d(async()=>await f(r)))}if(g)t.registerTool(`get-${n.singular}`,{description:`Read one ${n.singular} by ${n.key}.`,inputSchema:{id:c}},async({id:u})=>await d(async()=>await g(r,u)));if(S){let u=`Create one ${n.singular}. 'body' is the request body the config plane documents.`+(n.createHint?` ${n.createHint}`:"")+p+" Prefer changing the broods/ manifest and deploying for anything the project already declares.",h=s(e(),l());if(n.scoped)t.registerTool(`create-${n.singular}`,{description:u,inputSchema:{body:h,...R}},async({body:m,project:T,stage:I})=>await d(async()=>await S(r,m,b(n,i,T,I))));else t.registerTool(`create-${n.singular}`,{description:u,inputSchema:{body:h}},async({body:m})=>await d(async()=>await S(r,m)))}if(w)t.registerTool(`update-${n.singular}`,{description:`Deep-merge a patch into one ${n.singular} and return the updated record, so there is no need to read it back.`+(n.updateHint?` ${n.updateHint}`:""),inputSchema:{id:c,body:s(e(),l())}},async({id:u,body:h})=>await d(async()=>await w(r,u,h)));if(_)t.registerTool(`delete-${n.singular}`,{description:`Delete one ${n.singular}. Requires confirm:true, and takes one ${n.key} per call: never loop this over a list.`+(n.deleteHint?` ${n.deleteHint}`:""),inputSchema:{id:c,confirm:v}},async({id:u,confirm:h})=>await d(async()=>(y(h,`Deleting ${n.singular} '${u}' goes away for good: name it, get the owner's agreement, then retry.`),{deleted:await _(r,u),id:u})))}export{Lt as createBroodsMcpServer};
@@ -1,4 +0,0 @@
1
- import{F,z}from"./chunk-gqyk7vva.js";import{e,o,a,l,n,t,d,E,s,p,r}from"./chunk-qxxrmem2.js";import{ue,_e,L}from"./cli/index.js";import{spawn as re}from"node:child_process";import{statfsSync as ne}from"node:fs";import{availableParallelism as ie,homedir as se,hostname as ae,totalmem as ce}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 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:p(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:p(["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:a().optional(),mcp:n(e()).optional(),instance:e().optional(),force:a().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(),l())}),q=t({type:r("mcp-list"),id:e(),server:e()}),Z=t({type:r("mcp-result"),id:e(),result:d({content:n(l())}).optional(),error:e().optional()}),Q=t({type:r("mcp-tools"),id:e(),tools:n(d({name:e(),inputSchema:s(e(),l())})).optional(),error:e().optional()}),V=t({type:r("ready"),sandboxId:e(),expiresInMs:o().optional()}),ee=t({type:r("result"),id:e(),exitCode:o().nullable(),stdout:e(),stderr:e(),durationMs:o(),timedOut:a(),truncated:a()}),te=E("type",[G,K,Y,q,V]),Fe=E("type",[W,J,X,Z,Q,ee]);function I(i){let c=new URL(U,i);return c.protocol=c.protocol==="https:"?"wss:":"ws:",c.toString()}function A(i){return oe(te,i)}function oe(i,c){if(typeof c!=="string")return null;try{let y=i.safeParse(JSON.parse(c));return y.success?y.data:null}catch{return null}}var le=new Set([C.occupied.code,C.replaced.code,C.unauthorized.code,C.unknownSandbox.code]),H=72,D=30000,O=1000;function pe(i,c,y){return new Promise((g)=>{let h=j.now(),f=new R(i.outputLimitBytes),w=new R(i.outputLimitBytes),b=!1,v=!1,x=(u,m)=>{if(v)return;if(v=!0,clearTimeout(T),y?.removeEventListener("abort",_),m)w.append(Buffer.from(`${m}
2
- `));g({type:"result",id:i.id,exitCode:u,stdout:f.text(),stderr:w.text(),durationMs:Math.round(j.now()-h),timedOut:b,truncated:f.truncated||w.truncated})},M=re("bash",["-lc",i.code],{cwd:i.cwd??c,env:{...F(),...i.env},detached:!0,stdio:["ignore","pipe","pipe"]}),S=()=>{if(!M.pid)return;try{process.kill(-M.pid,"SIGKILL")}catch{M.kill("SIGKILL")}},T=setTimeout(()=>{b=!0,S()},i.timeoutSeconds*1000),_=()=>{S(),x(null,"stopped: the daemon closed its socket")};if(y?.addEventListener("abort",_,{once:!0}),M.stdout.on("data",(u)=>f.append(u)),M.stderr.on("data",(u)=>w.append(u)),M.on("error",(u)=>x(null,u.message)),M.on("close",(u)=>x(u)),y?.aborted)_()})}async function Oe(i){let c=_e(),y=crypto.randomUUID(),g=i.mcpFile?await fe(i.mcpFile,i.log):null,h=i.computer?await ye(i.log):null,f=O;try{while(!i.signal.aborted){let w=Date.now(),b;try{b=await i.credential()}catch(x){if(x instanceof L)throw x;i.log(`stage session unavailable (${x instanceof Error?x.message:String(x)}), retrying in ${Math.round(f/1000)}s`),await ue(f,i.signal),f=Math.min(f*2,D);continue}let v=await be(i,b,y,c,h,g);if(i.signal.aborted)return;if(le.has(v.code))throw Error(v.reason||`core closed the socket (${v.code})`);if(Date.now()-w>D)f=O;i.log(`disconnected (${v.reason||v.code}), reconnecting in ${Math.round(f/1000)}s`),await ue(f,i.signal),f=Math.min(f*2,D)}}finally{h?.stop(),await g?.stop()}}class R{#o=[];#e;#t=0;truncated=!1;constructor(i){this.#e=i}append(i){if(this.#t>=this.#e){this.truncated=!0;return}let c=this.#e-this.#t;if(i.byteLength>c){this.#o.push(i.subarray(0,c)),this.#t=this.#e,this.truncated=!0;return}this.#o.push(i),this.#t+=i.byteLength}text(){let i=Buffer.concat(this.#o).toString("utf8");return this.truncated?`${i}
3
- [output truncated]`:i}}function de(i){let c=[i.action];if(i.coordinate)c.push(`at ${i.coordinate.join(",")}`);if(i.text!==void 0)c.push(JSON.stringify(N(i.text)));if(i.region)c.push(`region ${i.region.join(",")}`);return c.join(" ")}function me(){let i=he();return{vcpu:ie(),memoryMb:Math.round(ce()/1048576),...i?{storageGb:i}:{}}}function he(){try{let i=ne(se());return Math.round(i.blocks*i.bsize/1073741824)}catch{return}}function N(i){let c=i.trim().split(`
4
- `)[0]??"";return c.length>H?`${c.slice(0,H)}…`:c}async function ye(i){let{startDesktop:c}=await import("./chunk-5tnnqapc.js"),{display:y,driver:g,permissions:h}=await c(!1);if(i(`computer use on, ${y.width}x${y.height} screenshots`),!h.screenRecording||!h.accessibility)i(" screen recording or accessibility is missing, run `broods machine --doctor --request`");return g}async function fe(i,c){let{McpHost:y,readMcpServersFile:g}=await import("./chunk-e2z6q3rv.js"),h=new y(g(i),c);return c(`mcp servers from ${i}: ${h.names().join(", ")}`),h}async function ge(i,c,y){try{if(i.type==="mcp-list"){let h=await c.listTools(i.server);return y(` mcp ${i.server}: ${h.length} tools`),{type:"mcp-tools",id:i.id,tools:h}}y(` mcp ${i.server}.${i.tool}`);let g=await c.callTool(i.server,i.tool,i.args);return{type:"mcp-result",id:i.id,result:g}}catch(g){let h=g instanceof Error?g.message:String(g);return y(` mcp ${i.server}: ${h}`),{type:i.type==="mcp-call"?"mcp-result":"mcp-tools",id:i.id,error:h}}}function be(i,c,y,g,h,f){return new Promise((w)=>{let b=new g(I(i.baseUrl),z(c)),v=new AbortController,x=()=>b.close(1000,"daemon stopped"),M=(u)=>{if(b.readyState===b.OPEN)b.send(JSON.stringify(u))},S,T=(u)=>{if(clearTimeout(S),v.signal.aborted)return;S=setTimeout(()=>{i.credential().then((m)=>M({type:"credential",token:m}),(m)=>i.log(`credential refresh failed (${m instanceof Error?m.message:String(m)}), retrying`)).finally(()=>T(u))},Math.max((u-Date.now())/2,O))},_=(u,m)=>{i.signal.removeEventListener("abort",x),clearTimeout(S),v.abort(),w({code:u,reason:m})};i.signal.addEventListener("abort",x,{once:!0}),b.onopen=()=>M({type:"hello",sandbox:i.sandbox,hostname:ae(),platform:process.platform,computer:h!==null,mcp:f?.names(),instance:y,force:i.force,specs:me()}),b.onmessage=(u)=>{let m=A(u.data);if(m?.type==="ready"){if(S===void 0)i.log(`connected as ${i.sandbox} (${m.sandboxId})`);if(m.expiresInMs!==void 0)T(Date.now()+m.expiresInMs);return}if(m?.type==="computer"&&h){i.log(` ${de(m)}`),h.run(m).then((k)=>{if(k.error)i.log(` error: ${k.error}`);M(k)});return}if((m?.type==="mcp-call"||m?.type==="mcp-list")&&f){ge(m,f,i.log).then(M);return}if(m?.type!=="exec")return;i.log(`$ ${N(m.code)}`),pe(m,i.cwd,v.signal).then((k)=>{i.log(` exit ${k.exitCode??"none"} in ${k.durationMs}ms${k.timedOut?" (timed out)":""}`),M(k)})},b.onerror=()=>_(1006,"connection failed"),b.onclose=(u)=>_(u.code,u.reason)})}export{Oe as runMachineDaemon};
@@ -1 +0,0 @@
1
- import{F}from"./chunk-gqyk7vva.js";import{De,e,n,t,s}from"./chunk-qxxrmem2.js";import{readFileSync as m}from"node:fs";import{dirname as d,resolve as p}from"node:path";import{Client as g}from"@modelcontextprotocol/client";import{StdioClientTransport as h}from"@modelcontextprotocol/client/stdio";var f={name:"broods-machine",version:"1.0.0"},u=t({command:e().min(1),args:n(e()).default([]),env:s(e(),e()).optional(),cwd:e().optional()}),w=t({mcpServers:s(e(),u).refine((r)=>Object.keys(r).length>0,"lists no MCP servers")});class y{#t=new Map;#e;#r;constructor(r,o){this.#r=r,this.#e=o}async callTool(r,o,i){return await(await this.#n(r)).callTool({name:o,arguments:i})}async listTools(r){return(await(await this.#n(r)).listTools()).tools}names(){return[...this.#r.keys()]}async stop(){let r=[...this.#t.values()];this.#t.clear(),await Promise.all(r.map((o)=>o.then((i)=>i.close()).catch(()=>{})))}#n(r){let o=this.#r.get(r);if(!o)return Promise.reject(Error(`no MCP server named "${r}" in the --mcp file`));let i=this.#t.get(r);if(i)return i;let c=(async()=>{this.#e(`mcp ${r}: ${[o.command,...o.args].join(" ")}`);let a=new h({...o,env:{...F(),...o.env},stderr:"inherit"});a.onclose=()=>{if(this.#e(`mcp ${r}: exited`),this.#t.get(r)===c)this.#t.delete(r)};let l=new g(f);return await l.connect(a),l})();return c.catch(()=>{if(this.#t.get(r)===c)this.#t.delete(r)}),this.#t.set(r,c),c}}function b(r){let o=p(r),i=w.safeParse(v(o));if(!i.success)throw Error(`${o}: ${De(i.error)}`);return new Map(Object.entries(i.data.mcpServers).map(([c,a])=>[c,a.cwd?{...a,cwd:p(d(o),a.cwd)}:a]))}function v(r){try{return JSON.parse(m(r,"utf8"))}catch(o){throw Error(`could not read ${r}: ${o instanceof Error?o.message:String(o)}`)}}export{y as McpHost,b as readMcpServersFile};
@@ -1 +0,0 @@
1
- import{x,i,H,j,re,oe,se,v,A,ie,me,fe,$e,Ce,Ee,ke,he,ge,Te,ze,Pe,q}from"./chunk-ware5wzj.js";var k=Symbol("swallowsErrorsAfterClose"),W=class{_readBuffer;_started=!1;_closed=!1;constructor(t=he.stdin,o=he.stdout,c){this._stdin=t,this._stdout=o,this._readBuffer=new Ee({maxBufferSize:c?.maxBufferSize})}onclose;onerror;onmessage;_ondata=(t)=>{try{this._readBuffer.append(t),this.processReadBuffer()}catch(o){this.onerror?.(o),this.close().catch(()=>{})}};_onerror=(t)=>{this.onerror?.(t)};_onstdouterror=(t)=>{if(this._closed)return;this.onerror?.(t),this.close().catch(()=>{})};_onstdinclose=()=>{this.close().catch(()=>{})};async start(){if(this._started)throw Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0;for(let t of this._stdout.listeners("error"))if(t[k])this._stdout.off("error",t);if(this._stdin.readableEnded||this._stdin.destroyed)setImmediate(this._onstdinclose);this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror),this._stdin.on("end",this._onstdinclose),this._stdin.on("close",this._onstdinclose),this._stdout.on("error",this._onstdouterror)}processReadBuffer(){while(!0)try{let t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}async close(){if(this._closed)return;if(this._closed=!0,this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.off("end",this._onstdinclose),this._stdin.off("close",this._onstdinclose),this._onstdouterror[k]=!0,this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),this.onclose?.()}send(t){if(this._closed)return Promise.reject(Error("StdioServerTransport is closed"));return new Promise((o,c)=>{let l=ke(t),r=!1,f=(_)=>{if(r)return;r=!0,this._stdout.off("error",f),this._stdout.off("drain",p),c(_)},p=()=>{if(r)return;r=!0,this._stdout.off("error",f),this._stdout.off("drain",p),o()};if(this._stdout.once("error",f),this._stdout.write(l)){if(r)return;r=!0,this._stdout.off("error",f),o()}else if(!r)this._stdout.once("drain",p)})}},D=3000,z=class{onclose;onerror;onmessage;_closed=!1;_pendingRequests=new Set;_drainWaiters=[];constructor(t,o,c){this._wire=t,this._onInstanceClose=o,this._outboundIntercept=c}async start(){}async send(t,o){if(ie(t)||me(t)){let{id:c}=t;if(c!==void 0)this._settle(c)}if(this._closed)return;if(this._outboundIntercept?.(t)==="handled")return;return this._wire.send(t,o)}setProtocolVersion=(t)=>{this._wire.setProtocolVersion?.(t)};deliver(t,o){if(this._closed)return;if(v(t))this._pendingRequests.add(t.id);else if(A(t)&&t.method==="notifications/cancelled"){let c=t.params?.requestId;if(c!==void 0)this._settle(c)}this.onmessage?.(t,o)}async whenRequestsAnswered(t){if(this._closed||this._pendingRequests.size===0)return!0;return await new Promise((o)=>{let c=()=>{clearTimeout(l),o(!0)},l=setTimeout(()=>{this._drainWaiters=this._drainWaiters.filter((r)=>r!==c),o(!1)},t);this._drainWaiters.push(c)})}async close(){if(this._closed)return;this._closed=!0,this._pendingRequests.clear(),this._releaseDrainWaiters();try{this._onInstanceClose()}finally{this.onclose?.()}}_settle(t){if(this._pendingRequests.delete(t),this._pendingRequests.size===0)this._releaseDrainWaiters()}_releaseDrainWaiters(){let t=this._drainWaiters;this._drainWaiters=[];for(let o of t)o()}};function J(t){let o=t.params;if(t.method==="initialize"&&!fe(o)){let f=o!==null&&typeof o==="object"&&typeof o.protocolVersion==="string"?o.protocolVersion:void 0;return{kind:"legacy",reason:"initialize",...f!==void 0&&{requestedVersion:f}}}if(!re(o))return{kind:"legacy",reason:"no-claim"};let c=j(o),l=(c===void 0?[]:se(c))[0];if(l!==void 0)return{kind:"invalid-envelope",issue:l};let r=oe(o);if(r===void 0||!x.includes(r))return{kind:"unsupported-revision",requested:r??"unknown"};return{kind:"modern",revision:r,classification:{era:"modern",revision:r}}}function F(t,o={}){let c=o.legacy??"serve",l=o.transport??new W,r={phase:"opening"},f,p=!1,_=()=>p||r.phase==="closed",d=(e)=>{try{o.onerror?.(e)}catch{}},m=(e,n,s,a)=>l.send({jsonrpc:"2.0",id:e,error:{code:n,message:s,...a!==void 0&&{data:a}}}).catch((u)=>d(h(u))),w=new Te(o.maxSubscriptions??ge),M=(e)=>{if(!A(e))return;let n=w.routeOutbound(e);if(n==="passthrough")return;for(let s of n)l.send({jsonrpc:"2.0",...s}).catch((a)=>d(h(a)));return"handled"},I=async(e)=>{if(v(e)&&e.method==="subscriptions/listen"){let n=j(e.params),s=re(e.params)?(n===void 0?[]:se(n))[0]:{key:"_meta",problem:"the per-request envelope is required on protocol revision 2026-07-28"},a=oe(e.params),u;if(s!==void 0)u={jsonrpc:"2.0",id:e.id,error:{code:-32602,message:`Invalid _meta envelope: ${s.key}: ${s.problem}`}};else if(a===void 0||!x.includes(a)){let y=new H({supported:[...x],requested:a??"unknown"});u={jsonrpc:"2.0",id:e.id,error:{code:y.code,message:y.message,data:y.data}}}else u=w.serve(e);return await l.send("error"in u?u:{jsonrpc:"2.0",method:u.method,params:u.params}).catch((y)=>d(h(y))),!0}if(A(e)&&e.method==="notifications/cancelled"){let n=e.params?.requestId;if(n!==void 0&&w.cancel(n))return!0}return!1},C=(e,n,s)=>{let a=$e({kind:"legacy",reason:n,...s!==void 0&&{requestedVersion:s}},x);if(a===void 0)return Promise.resolve();return d(Error(`Rejected 2025-era request on a modern-only stdio connection (${a.cell}): ${a.message}`)),m(e.id,a.code,a.message,a.data)},V=(e)=>{if(p||e===f)return;O()},R=async(e,n)=>{let s=await t({era:e}),a=s instanceof q?s.server:s;if(e==="modern")Ce(a,n),ze(a,x),w.setServerCapabilities(a.getCapabilities(),Pe(a));let u=new z(l,()=>V(u),e==="modern"?M:void 0);return await s.connect(u),{product:s,channel:u}},S=(e)=>e.product.close().catch((n)=>d(h(n))),T=async(e)=>{f=e.channel;try{if(!await e.channel.whenRequestsAnswered(D))d(Error(`Discarded the probe instance with requests still unanswered after ${D}ms; continuing with the fallback`));await e.product.close()}catch(n){d(h(n))}finally{f=void 0}},B=async(e)=>{if(r.phase==="closed")return;if(r.phase==="pinned"){if(r.era==="modern"&&v(e)&&e.method==="initialize"&&!fe(e.params)){await C(e,"initialize",e.params!==null&&typeof e.params==="object"&&typeof e.params.protocolVersion==="string"?e.params.protocolVersion:void 0);return}if(r.era==="modern"&&await I(e))return;if(_())return;r.instance.channel.deliver(e);return}if(!v(e)&&!A(e)){d(Error("Discarded a JSON-RPC response received before the connection negotiated an era"));return}let n=J(e);switch(n.kind){case"invalid-envelope":{let s=`Invalid _meta envelope for protocol revision 2026-07-28: ${n.issue.key}: ${n.issue.problem}`;if(v(e))await m(e.id,i.InvalidParams,s,{envelope:n.issue});else d(Error(`Discarded a notification with a malformed envelope: ${s}`));return}case"unsupported-revision":if(v(e)){let s=new H({supported:[...x],requested:n.requested});d(s),await m(e.id,s.code,s.message,s.data)}else d(Error(`Discarded a notification claiming unsupported protocol revision ${n.requested}`));return;case"modern":if(v(e)&&e.method==="server/discover"){if(r.phase==="probe"){r.instance.channel.deliver(e,{classification:n.classification});return}let s=await R("modern",n.revision);if(_()){await S(s);return}r={phase:"probe",instance:s},s.channel.deliver(e,{classification:n.classification});return}if(r.phase==="probe"){if(A(e)){r.instance.channel.deliver(e,{classification:n.classification});return}r={phase:"pinned",era:"modern",instance:r.instance}}else{let s=await R("modern",n.revision);if(_()){await S(s);return}r={phase:"pinned",era:"modern",instance:s}}if(await I(e))return;if(_())return;r.instance.channel.deliver(e,{classification:n.classification});return;case"legacy":{if(c==="reject"){if(v(e))await C(e,n.reason,n.requestedVersion);return}if(r.phase==="probe"){if(await T(r.instance),_())return;r={phase:"opening"}}let s=await R("legacy");if(_()){await S(s);return}r={phase:"pinned",era:"legacy",instance:s},r.instance.channel.deliver(e);return}}},E=[],b=!1,N=async()=>{if(b)return;b=!0;try{while(E.length>0){let e=E.shift();try{await B(e)}catch(n){if(v(e))await m(e.id,i.InternalError,"Internal server error");d(h(n))}}}finally{b=!1}},O=async()=>{if(p||r.phase==="closed")return;p=!0;let e=r;r={phase:"closed"};for(let n of w.teardownAll())await l.send(n).catch((s)=>d(h(s)));if(e.phase==="probe"||e.phase==="pinned")await e.instance.product.close().catch((n)=>d(h(n)));await l.close().catch((n)=>d(h(n)))};l.onmessage=(e)=>{E.push(e),N()},l.onerror=(e)=>{if(d(e),r.phase==="probe"||r.phase==="pinned")r.instance.channel.onerror?.(e)},l.onclose=()=>{if(p||r.phase==="closed")return;p=!0;let e=r;if(r={phase:"closed"},e.phase==="probe"||e.phase==="pinned")e.instance.product.close().catch((n)=>d(h(n)))};let P=l.start().catch((e)=>{throw d(h(e)),e});return P.catch(()=>{}),{close:async()=>{await P.catch(()=>{}),await O()}}}function h(t){return t instanceof Error?t:Error(String(t))}export{F as serveStdio};
@@ -1,5 +0,0 @@
1
- function G(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*we(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 Le=500,Oe=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,Me=/^(?!0{32}$)[0-9a-f]{32}$/;function Ne(e){return e==="DEBUG"||e==="INFO"||e==="WARN"||e==="ERROR"}function Ue(e){if(typeof e!=="object"||e===null)return!1;let n=e;if(n.type==="subscribe")return _e(n);if(n.type==="unsubscribe")return O(n.stream);if(n.type==="fetchTrace")return K(n.traceId);return!1}function Fe(e){return e==="task"||e==="cron"||e==="subtask"}function W(e){return typeof e==="string"&&Oe.test(e)}function K(e){return typeof e==="string"&&Me.test(e)}function O(e){return e==="logs"||e==="traces"}function _e(e){let n=e.stream;if(!O(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&&!Ne(o))return!1;let r=e.sandboxId;return r===void 0||n==="logs"&&W(r)}import{readFileSync as Pe}from"node:fs";import{chmod as j,mkdir as $e,writeFile as qe}from"node:fs/promises";import{homedir as ze}from"node:os";import{dirname as M,join as en}from"node:path";var S="broods",w="_generated",N=en(ze(),".broods","config.json"),L="broods.app",H="dashboard",nn="gateway";function P(e){let n=process.env.BROODS_TOKEN,t=e??process.env.BROODS_BASE_URL;if(n&&t)return{baseUrl:h(t),token:n,createdAt:new Date().toISOString()};let o=q();if(!o)return null;if(t)return o.logins[h(t)]??null;let r=process.env.BROODS_DASHBOARD_URL;if(r){let i=h(r);return Object.values(o.logins).find((s)=>s.dashboardUrl===i)??null}return o.logins[o.current]??null}async function J(e){let n=q()?.logins??{},t={current:e.baseUrl,logins:{...n,[e.baseUrl]:e}};await $e(M(N),{recursive:!0,mode:448}),await j(M(N),448),await Y(N,`${JSON.stringify(t,null,2)}
3
- `)}async function Y(e,n){await qe(e,n,{encoding:"utf8",mode:384}),await j(e,384)}function _(){return process.env.BROODS_STAGE}function h(e){let n=e.length;while(n>0&&e.charCodeAt(n-1)===47)n-=1;return e.slice(0,n)}function U(e){try{let n=new URL(e);if(!n.hostname.startsWith(`${H}.`))return;let t=n.hostname.slice(H.length+1);if(t!==L&&!t.endsWith(`.${L}`))return;return n.hostname=`${nn}.${t}`,h(n.origin)}catch{return}}function q(){try{let e=JSON.parse(Pe(N,"utf8"));if(typeof e.current!=="string"||!e.logins)return null;return{current:e.current,logins:e.logins}}catch{return null}}import{existsSync as V,readFileSync as oe,statSync as tn}from"node:fs";import{join as re,resolve as ie}from"node:path";var E=new Map,on=new Set(Object.keys(process.env)),Z=new Set;function f(e=process.cwd()){rn(e);let n=P();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:_()}}function F(){let e={};for(let[n,t]of Object.entries(process.env))if(typeof t==="string"&&!n.startsWith("BROODS_"))e[n]=t;return e}function T(e,n=process.cwd()){let t=process.env[e];if(t===void 0)return!1;let o=ie(n);for(let r of[".env.local",".env"]){let i=re(o,r);if(!V(i))continue;let s=X(oe(i,"utf8"));if(s[e]!==void 0)return s[e]!==t}return!0}function rn(e){let n=ie(e),t=process.env.BROODS_RELOAD_ENV==="1";for(let o of[".env",".env.local"]){let r=re(n,o);if(!V(r)){E.delete(r);continue}let i=tn(r).mtimeMs,s=E.get(r);if(s&&s.mtimeMs===i)continue;E.set(r,{mtimeMs:i});for(let[a,c]of Object.entries(X(oe(r,"utf8"))))if(t||!on.has(a)||Z.has(a))process.env[a]=c,Z.add(a)}}function X(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]=sn(r.slice(i+1).trim())}return n}function sn(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 D=new TextEncoder,ae={name:"HMAC",hash:"SHA-256"};async function ce(e,n,t,o){let r=se(D.encode(JSON.stringify(t))),i=await crypto.subtle.sign(ae,await an(n,o),D.encode(r));return`${e}${r}.${se(new Uint8Array(i))}`}function se(e){let n="";for(let t of e)n+=String.fromCharCode(t);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function an(e,n){let t=await crypto.subtle.digest("SHA-256",D.encode(`${e}${n}`));return crypto.subtle.importKey("raw",t,ae,!1,["sign","verify"])}var cn="buat_",Q="bsig_",de="x-broods-user-token",ue="broods.user.";var ge=600000,ee=3600000,un="broods-user-token:",le=/^[A-Za-z0-9._@+=-]{1,128}$/,fe=100,gn=256,ln=60000;async function ye(e,n,t=Date.now()){if(!n.startsWith(Q))throw Error(`The user token signing secret must start with ${Q}. It is not the bsk_ runtime key.`);let o=pn(e,t);if(!o||e.expiresAt>t+ee)throw Error(`Invalid user token: userId must match ${le.source}, conversations must be at most ${fe} non-empty keys, and expiresAt must be in the next ${ee/60000} minutes.`);return await ce(cn,un,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"||!le.test(t)||typeof r!=="number"||!Number.isFinite(r)||r<=n||r>n+ee+ln)return null;if(o===void 0)return{userId:t,expiresAt:r};if(!Array.isArray(o)||o.length>fe||!o.every((i)=>typeof i==="string"&&i.trim()===i&&i.length>0&&i.length<=gn))return null;return{userId:t,conversations:o,expiresAt:r}}var y="BROODS_USER_TOKEN_SECRET";async function Be(e){let n=e.secret??process.env[y];if(!n)throw Error(`signUserToken needs the stage's signing secret: pass secret or set ${y}. \`broods dev\` and \`broods deploy\` write it to .env.local; the dashboard's Runtime key tab rotates it.`);return await ye({userId:e.userId,...e.conversations?{conversations:e.conversations}:{},expiresAt:Date.now()+(e.ttlMs??ge)},n)}var I="https://gateway.broods.app";class Re extends Error{accepted;constructor(e){super(`Ingress ${e.eventId} was accepted asynchronously with status ${e.status??"queued"}`);this.accepted=e;this.name="IngressAcceptedError"}}class B{baseUrl;apiKey;userToken;fetchImpl;constructor(e={}){f(),this.baseUrl=te(e.baseUrl||e.host||process.env.BROODS_BASE_URL||process.env.BROODS_HOST||I),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=me(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 Re(Ce(await i.json(),o));if(!i.body)throw Error("Run response has no body");for await(let s of we(i.body)){let a;try{a=JSON.parse(s)}catch{continue}if(a.type==="error")throw Error(`Agent run failed: ${dn(a.error)}`);yield a}}async runAsync(e,n){let t=n?{...n,agentId:e.id,agentName:e.name}:e,o={...me(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 yn(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 fn(o,"202 JSON")}`);return this.asyncAgentRun(Ce(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 ${I} 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?{[de]: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 mn(this.baseUrl,e)}}function te(e){let n=e.trim(),t=/^[A-Za-z][A-Za-z0-9+.-]*:\/\//.test(n)?n:`https://${n}`;return h(t)}function me(e,n){let t=e.eventId??`${n}-${crypto.randomUUID()}`;return{agentId:e.agentId,eventId:t,conversationKey:e.conversationKey??t,events:G(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 dn(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 Ce(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 fn(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 yn(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 mn(e,n){return`${te(e)}/v1/runs/${encodeURIComponent(n)}`}var Cn=2000,he=0,x=1;class je{baseUrl;apiKey;userToken;WebSocketImpl;connectTimeoutMs;constructor(e={}){if(f(),this.baseUrl=ke(e.baseUrl||e.host||process.env.BROODS_BASE_URL||process.env.BROODS_HOST||I),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??Cn}subscribe(e,n={}){let t=this.resolveWebSocket(),o=this.buildUrl(e),r=hn(e),i=xe(this.baseUrl),s=new t(o,z(this.apiKey,e.userToken??this.userToken)),a=!1,c=!1,d=setTimeout(()=>{if(!a)b(i)},this.connectTimeoutMs),m=(p=1000,A="client closed")=>{if(c)return;if(c=!0,clearTimeout(d),e.signal?.removeEventListener("abort",k),s.readyState===x||s.readyState===he)s.close(p,A)},b=(p)=>{n.onError?.(p),m(1000,"websocket error")},De=()=>{n.onDone?.(),m(1000,"done")},k=()=>{if(s.readyState===x)s.send(JSON.stringify({type:"cancel"}));b(Error("WebSocket run aborted."))};return e.signal?.addEventListener("abort",k,{once:!0}),s.onopen=()=>{if(a=!0,clearTimeout(d),e.signal?.aborted){k();return}s.send(JSON.stringify({type:"execute",agentId:r,...e.answers?{answers:e.answers}:{events:G(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 A=be(p.data);if(!A)return;let v=Ie(A,n);switch(n.onMessage?.(v),v.type){case"meta":n.onMeta?.(v);break;case"done":De();break;case"error":b(Error(Se(v.error)));break}},s.onerror=()=>{b(i)},s.onclose=(p)=>{if(clearTimeout(d),e.signal?.removeEventListener("abort",k),c||p.code===1000)return;b(Error(p.reason||"WebSocket connection closed."))},{url:o,sendControl:function(p){if(s.readyState!==x)throw Error("WebSocket is not open");s.send(JSON.stringify({type:"control",...p}))},close:m}}attach(e,n={}){let t=this.resolveWebSocket(),o=this.buildUrl(e),r=new t(o,z(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===x||r.readyState===he)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=be(c.data);if(!d)return;let m=Ie(d,n);if(i)return;if(n.onMessage?.(m),i)return;if(m.type==="done")n.onDone?.();if(m.type==="error")n.onError?.(Error(Se(m.error)))},r.onerror=()=>{if(i)return;s(1000,"websocket error"),n.onError?.(xe(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!==x)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=Sn(e),t=e.projectSlug??e.agent?.projectSlug,o=e.stageSlug??e.agent?.stageSlug,r=t&&o?`/projects/${encodeURIComponent(t)}/stages/${encodeURIComponent(o)}`:"";return`${ne(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 ne(e){let n=new URL(ke(e));if(n.protocol==="https:")n.protocol="wss:";if(n.protocol==="http:")n.protocol="ws:";return h(n.toString())}function z(e,n){return["broods.v1",`broods.token.${e}`,...n?[`${ue}${n}`]:[]]}function Se(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 ke(e){let n=e.trim();if(/^wss?:\/\//.test(n))return h(n);return te(n)}function be(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 Sn(e){let n=e.endpointId??e.agent?.endpointId??e.agent?.id;if(!n)throw Error("WebSocket run requires agent or endpointId.");return n}function Ie(e,n){if(e.type!=="output")return e;let t=e;return n.onOutput?.(t),t.data}function xe(e){return Error(`Cannot access the WebSocket service at ${e}.`)}var ve=Symbol.for("broods.resource"),Te=Symbol.for("broods.config"),Ee=Symbol.for("broods.connection"),Ae=/^[A-Z][A-Z0-9_]{0,63}$/,He=new Proxy((e)=>{if(!Ae.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"&&Ae.test(n))throw Error(`env.${n} is not supported; use env("${n}")`);return Reflect.get(e,n,t)}});function Ze(e){let{name:n,description:t,...o}=e;return C("agent",n,t,o)}function Ve(e){return{[Te]:!0,config:e}}function Ge(e){let{name:n,description:t,...o}=e;return C("cron",n,t,o)}function We(e){return e}function Ke(e){let{name:n,description:t,...o}=e;return C("mcp",n,t,o)}function Je(e){let{name:n,description:t,...o}=e;return C("policy",n,t,o)}function Ye(e){let{name:n,description:t,...o}=e;return C("sandbox",n,t,o)}function Xe(e){let{name:n,description:t,...o}=e;return C("skill",n,t,o)}function Qe(e){let{name:n,description:t,...o}=e;return C("workspace",n,t,o)}function et(e){return l("discord",e)}function tt(e){return l("github",e)}function nt(e){return l("gchat",e)}function rt(e){return l("instagram",e)}function ot(e){return l("linear",e)}function st(e){return l("matrix",e)}function it(e){return l("messenger",e)}function at(e){return l("pancake",e)}function ct(e){return l("slack",e)}function lt(e){return l("teams",e)}function ut(e){return l("telegram",e)}function dt(e){return l("twilio",e)}function pt(e){return l("whatsapp",e)}function mt(e){return l("zalo",e)}function ft(e){let{name:n,description:t,channelId:o,guildId:r,...i}=e;return u(n,t,o,r,i)}function ht(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 gt(e){let{name:n,description:t,spaceName:o,...r}=e;return u(n,t,o,void 0,r)}function yt(e){let{name:n,description:t,igsid:o,...r}=e;return u(n,t,o,void 0,r)}function St(e){let{name:n,description:t,team:o,...r}=e;return u(n,t,o,void 0,r)}function bt(e){let{name:n,description:t,channelId:o,...r}=e;return u(n,t,o,void 0,r)}function vt(e){let{name:n,description:t,psid:o,...r}=e;return u(n,t,o,void 0,r)}function _t(e){let{name:n,description:t,conversationId:o,...r}=e;return u(n,t,o,void 0,r)}function wt(e){let{name:n,description:t,channelId:o,teamId:r,...i}=e;return u(n,t,o,r,i)}function Rt(e){let{name:n,description:t,channelId:o,teamId:r,...i}=e;return u(n,t,o,r,i)}function $t(e){let{name:n,description:t,chatId:o,...r}=e;return u(n,t,o,void 0,r)}function Ct(e){let{name:n,description:t,from:o,...r}=e;return u(n,t,o,void 0,r)}function Et(e){let{name:n,description:t,waId:o,...r}=e;return u(n,t,o,void 0,r)}function kt(e){let{name:n,description:t,chatId:o,...r}=e;return u(n,t,o,void 0,r)}function pe(e){return Boolean(e&&typeof e==="object"&&e[Te])}function R(e){return Boolean(e&&typeof e==="object"&&e[Ee])}function g(e){return Boolean(e&&typeof e==="object"&&e[ve])}function u(e,n,t,o,r){return C("channelRecord",e,n,{...r,externalId:t,...o?{workspaceRef:o}:{}})}function l(e,n){let{partition:t,...o}=n;return{[Ee]:!0,kind:"connection",type:e,...t?{partition:t}:{},config:o}}function C(e,n,t,o){return{[ve]:!0,kind:e,name:n,...t?{description:t}:{},config:o}}
5
- export{G,we,Le,Ne,Ue,Fe,W,K,S,w,N,P,J,Y,_,h,U,f,F,T,X,Q,de,ee,y,Be,I,Re,B,te,je,ne,z,He,Ze,Ve,Ge,We,Ke,Je,Ye,Xe,Qe,et,tt,nt,rt,ot,st,it,at,ct,lt,ut,dt,pt,mt,ft,ht,gt,yt,St,bt,vt,_t,wt,Rt,$t,Ct,Et,kt,pe,R,g};
File without changes
@@ -1,66 +0,0 @@
1
- var at,Ie=Object.freeze({status:"aborted"});function w(i,f,m){function h(z,v){if(!z._zod)Object.defineProperty(z,"_zod",{value:{def:v,constr:x,traits:new Set},enumerable:!1});if(z._zod.traits.has(i))return;z._zod.traits.add(i),f(z,v);let y=x.prototype,Z=Object.keys(y);for(let S=0;S<Z.length;S++){let T=Z[S];if(!(T in z))z[T]=y[T].bind(z)}}let _=m?.Parent??Object;class g extends _{}Object.defineProperty(g,"name",{value:i});function x(z){var v;let y=m?.Parent?new g:this;h(y,z),(v=y._zod).deferred??(v.deferred=[]);for(let Z of y._zod.deferred)Z();return y}return Object.defineProperty(x,"init",{value:h}),Object.defineProperty(x,Symbol.hasInstance,{value:(z)=>{if(m?.Parent&&z instanceof m.Parent)return!0;return z?._zod?.traits?.has(i)}}),Object.defineProperty(x,"name",{value:i}),x}var yc=Symbol("zod_brand");class H extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class _e extends Error{constructor(i){super(`Encountered unidirectional transform during encode: ${i}`);this.name="ZodEncodeError"}}(at=globalThis).__zod_globalConfig??(at.__zod_globalConfig={});var fe=globalThis.__zod_globalConfig;function b(i){if(i)Object.assign(fe,i);return fe}function Le(i){let f=Object.values(i).filter((h)=>typeof h==="number");return Object.entries(i).filter(([h,_])=>f.indexOf(+h)===-1).map(([h,_])=>_)}function ye(i,f="|"){return i.map((m)=>Se(m)).join(f)}function ge(i,f){if(typeof f==="bigint")return f.toString();return f}function ze(i){return{get value(){{let m=i();return Object.defineProperty(this,"value",{value:m}),m}throw Error("cached value already set")}}}function Fe(i){return i===null||i===void 0}function Ue(i){let f=i.startsWith("^")?1:0,m=i.endsWith("$")?i.length-1:i.length;return i.slice(f,m)}function lt(i,f){let m=i/f,h=Math.round(m),_=Number.EPSILON*Math.max(Math.abs(m),1);if(Math.abs(m-h)<_)return 0;return m-h}var pt=Symbol("evaluating");function N(i,f,m){let h=void 0;Object.defineProperty(i,f,{get(){if(h===pt)return;if(h===void 0)h=pt,h=m();return h},set(_){Object.defineProperty(i,f,{value:_})},configurable:!0})}function ne(i,f,m){Object.defineProperty(i,f,{value:m,writable:!0,enumerable:!0,configurable:!0})}function Q(...i){let f={};for(let m of i){let h=Object.getOwnPropertyDescriptors(m);Object.assign(f,h)}return Object.defineProperties({},f)}function cr(i){return JSON.stringify(i)}function ft(i){return i.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var ur="captureStackTrace"in Error?Error.captureStackTrace:(...i)=>{};function de(i){return typeof i==="object"&&i!==null&&!Array.isArray(i)}var dt=ze(()=>{if(fe.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(i){return!1}});function se(i){if(de(i)===!1)return!1;let f=i.constructor;if(f===void 0)return!0;if(typeof f!=="function")return!0;let m=f.prototype;if(de(m)===!1)return!1;if(Object.prototype.hasOwnProperty.call(m,"isPrototypeOf")===!1)return!1;return!0}function ar(i){if(se(i))return{...i};if(Array.isArray(i))return[...i];if(i instanceof Map)return new Map(i);if(i instanceof Set)return new Set(i);return i}var mt=new Set(["string","number","symbol"]);function ee(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function X(i,f,m){let h=new i._zod.constr(f??i._zod.def);if(!f||m?.parent)h._zod.parent=i;return h}function P(i){let f=i;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 Se(i){if(typeof i==="bigint")return i.toString()+"n";if(typeof i==="string")return`"${i}"`;return`${i}`}function ht(i){return Object.keys(i).filter((f)=>i[f]._zod.optin==="optional"&&i[f]._zod.optout==="optional")}var _t={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]};function ei(i,f){let m=i._zod.def,h=m.checks;if(h&&h.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let g=Q(i._zod.def,{get shape(){let x={};for(let z in f){if(!(z in m.shape))throw Error(`Unrecognized key: "${z}"`);if(!f[z])continue;x[z]=m.shape[z]}return ne(this,"shape",x),x},checks:[]});return X(i,g)}function ri(i,f){let m=i._zod.def,h=m.checks;if(h&&h.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let g=Q(i._zod.def,{get shape(){let x={...i._zod.def.shape};for(let z in f){if(!(z in m.shape))throw Error(`Unrecognized key: "${z}"`);if(!f[z])continue;delete x[z]}return ne(this,"shape",x),x},checks:[]});return X(i,g)}function ti(i,f){if(!se(f))throw Error("Invalid input to extend: expected a plain object");let m=i._zod.def.checks;if(m&&m.length>0){let g=i._zod.def.shape;for(let x in f)if(Object.getOwnPropertyDescriptor(g,x)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let _=Q(i._zod.def,{get shape(){let g={...i._zod.def.shape,...f};return ne(this,"shape",g),g}});return X(i,_)}function oi(i,f){if(!se(f))throw Error("Invalid input to safeExtend: expected a plain object");let m=Q(i._zod.def,{get shape(){let h={...i._zod.def.shape,...f};return ne(this,"shape",h),h}});return X(i,m)}function ni(i,f){if(i._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let m=Q(i._zod.def,{get shape(){let h={...i._zod.def.shape,...f._zod.def.shape};return ne(this,"shape",h),h},get catchall(){return f._zod.def.catchall},checks:f._zod.def.checks??[]});return X(i,m)}function si(i,f,m){let _=f._zod.def.checks;if(_&&_.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let x=Q(f._zod.def,{get shape(){let z=f._zod.def.shape,v={...z};if(m)for(let y in m){if(!(y in z))throw Error(`Unrecognized key: "${y}"`);if(!m[y])continue;v[y]=i?new i({type:"optional",innerType:z[y]}):z[y]}else for(let y in z)v[y]=i?new i({type:"optional",innerType:z[y]}):z[y];return ne(this,"shape",v),v},checks:[]});return X(f,x)}function ii(i,f,m){let h=Q(f._zod.def,{get shape(){let _=f._zod.def.shape,g={..._};if(m)for(let x in m){if(!(x in g))throw Error(`Unrecognized key: "${x}"`);if(!m[x])continue;g[x]=new i({type:"nonoptional",innerType:_[x]})}else for(let x in _)g[x]=new i({type:"nonoptional",innerType:_[x]});return ne(this,"shape",g),g}});return X(f,h)}function ie(i,f=0){if(i.aborted===!0)return!0;for(let m=f;m<i.issues.length;m++)if(i.issues[m]?.continue!==!0)return!0;return!1}function gt(i,f=0){if(i.aborted===!0)return!0;for(let m=f;m<i.issues.length;m++)if(i.issues[m]?.continue===!1)return!0;return!1}function re(i,f){return f.map((m)=>{var h;return(h=m).path??(h.path=[]),m.path.unshift(i),m})}function Re(i){return typeof i==="string"?i:i?.message}function q(i,f,m){let h=i.message?i.message:Re(i.inst?._zod.def?.error?.(i))??Re(f?.error?.(i))??Re(m.customError?.(i))??Re(m.localeError?.(i))??"Invalid input",{inst:_,continue:g,input:x,...z}=i;if(z.path??(z.path=[]),z.message=h,f?.reportInput)z.input=x;return z}function Je(i){if(Array.isArray(i))return"array";if(typeof i==="string")return"string";return"unknown"}function xe(i){let f=typeof i;switch(f){case"number":return Number.isNaN(i)?"nan":"number";case"object":{if(i===null)return"null";if(Array.isArray(i))return"array";let m=i;if(m&&Object.getPrototypeOf(m)!==Object.prototype&&"constructor"in m&&m.constructor)return m.constructor.name}}return f}function ue(...i){let[f,m,h]=i;if(typeof f==="string")return{message:f,code:"custom",input:m,inst:h};return{...f}}var xt=(i,f)=>{i.name="$ZodError",Object.defineProperty(i,"_zod",{value:i._zod,enumerable:!1}),Object.defineProperty(i,"issues",{value:f,enumerable:!1}),i.message=JSON.stringify(f,ge,2),Object.defineProperty(i,"toString",{value:()=>i.message,enumerable:!1})},Be=w("$ZodError",xt),pr=w("$ZodError",xt,{Parent:Error});function zt(i,f=(m)=>m.message){let m={},h=[];for(let _ of i.issues)if(_.path.length>0)m[_.path[0]]=m[_.path[0]]||[],m[_.path[0]].push(f(_));else h.push(f(_));return{formErrors:h,fieldErrors:m}}function vt(i,f=(m)=>m.message){let m={_errors:[]},h=(_,g=[])=>{for(let x of _.issues)if(x.code==="invalid_union"&&x.errors.length)x.errors.map((z)=>h({issues:z},[...g,...x.path]));else if(x.code==="invalid_key")h({issues:x.issues},[...g,...x.path]);else if(x.code==="invalid_element")h({issues:x.issues},[...g,...x.path]);else{let z=[...g,...x.path];if(z.length===0)m._errors.push(f(x));else{let v=m,y=0;while(y<z.length){let Z=z[y];if(y!==z.length-1)v[Z]=v[Z]||{_errors:[]};else v[Z]=v[Z]||{_errors:[]},v[Z]._errors.push(f(x));v=v[Z],y++}}}};return h(i),m}function ci(i){let f=[],m=i.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 De(i){let f=[],m=[...i.issues].sort((h,_)=>(h.path??[]).length-(_.path??[]).length);for(let h of m)if(f.push(`✖ ${h.message}`),h.path?.length)f.push(` → at ${ci(h.path)}`);return f.join(`
2
- `)}var Ve=(i)=>(f,m,h,_)=>{let g=h?{...h,async:!1}:{async:!1},x=f._zod.run({value:m,issues:[]},g);if(x instanceof Promise)throw new H;if(x.issues.length){let z=new(_?.Err??i)(x.issues.map((v)=>q(v,g,b())));throw ur(z,_?.callee),z}return x.value};var We=(i)=>async(f,m,h,_)=>{let g=h?{...h,async:!0}:{async:!0},x=f._zod.run({value:m,issues:[]},g);if(x instanceof Promise)x=await x;if(x.issues.length){let z=new(_?.Err??i)(x.issues.map((v)=>q(v,g,b())));throw ur(z,_?.callee),z}return x.value};var $e=(i)=>(f,m,h)=>{let _=h?{...h,async:!1}:{async:!1},g=f._zod.run({value:m,issues:[]},_);if(g instanceof Promise)throw new H;return g.issues.length?{success:!1,error:new(i??Be)(g.issues.map((x)=>q(x,_,b())))}:{success:!0,data:g.value}},yt=$e(pr),we=(i)=>async(f,m,h)=>{let _=h?{...h,async:!0}:{async:!0},g=f._zod.run({value:m,issues:[]},_);if(g instanceof Promise)g=await g;return g.issues.length?{success:!1,error:new i(g.issues.map((x)=>q(x,_,b())))}:{success:!0,data:g.value}},$t=we(pr),bt=(i)=>(f,m,h)=>{let _=h?{...h,direction:"backward"}:{direction:"backward"};return Ve(i)(f,m,_)};var wt=(i)=>(f,m,h)=>Ve(i)(f,m,h);var kt=(i)=>async(f,m,h)=>{let _=h?{...h,direction:"backward"}:{direction:"backward"};return We(i)(f,m,_)};var Zt=(i)=>async(f,m,h)=>We(i)(f,m,h);var Pt=(i)=>(f,m,h)=>{let _=h?{...h,direction:"backward"}:{direction:"backward"};return $e(i)(f,m,_)};var St=(i)=>(f,m,h)=>$e(i)(f,m,h);var Ot=(i)=>async(f,m,h)=>{let _=h?{...h,direction:"backward"}:{direction:"backward"};return we(i)(f,m,_)};var Et=(i)=>async(f,m,h)=>we(i)(f,m,h);var It=/^[cC][0-9a-z]{6,}$/,Tt=/^[0-9a-z]+$/,Nt=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,At=/^[0-9a-vA-V]{20}$/,jt=/^[A-Za-z0-9]{27}$/,Ct=/^[a-zA-Z0-9_-]{21}$/,Rt=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Dt=/^([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})$/,lr=(i)=>{if(!i)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}-${i}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var Lt=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var ai="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Ft(){return new RegExp(ai,"u")}var Ut=/^(?:(?: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])$/,Mt=/^(([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 Jt=/^((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])$/,Bt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Vt=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,fr=/^[A-Za-z0-9_-]*$/;var Wt=/^https?$/,Kt=/^\+[1-9]\d{6,14}$/,Gt="(?:(?:\\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])))",qt=new RegExp(`^${Gt}$`);function Yt(i){return typeof i.precision==="number"?i.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":i.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{${i.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function Xt(i){return new RegExp(`^${Yt(i)}$`)}function Ht(i){let f=Yt({precision:i.precision}),m=["Z"];if(i.local)m.push("");if(i.offset)m.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let h=`${f}(?:${m.join("|")})`;return new RegExp(`^${Gt}T(?:${h})$`)}var Qt=(i)=>{let f=i?`[\\s\\S]{${i?.minimum??0},${i?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${f}$`)};var eo=/^-?\d+$/,dr=/^-?\d+(?:\.\d+)?$/,ro=/^(?:true|false)$/i,to=/^null$/i;var oo=/^[^A-Z]*$/,no=/^[^a-z]*$/;var W=w("$ZodCheck",(i,f)=>{var m;i._zod??(i._zod={}),i._zod.def=f,(m=i._zod).onattach??(m.onattach=[])}),so={number:"number",bigint:"bigint",object:"date"},mr=w("$ZodCheckLessThan",(i,f)=>{W.init(i,f);let m=so[typeof f.value];i._zod.onattach.push((h)=>{let _=h._zod.bag,g=(f.inclusive?_.maximum:_.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(f.value<g)if(f.inclusive)_.maximum=f.value;else _.exclusiveMaximum=f.value}),i._zod.check=(h)=>{if(f.inclusive?h.value<=f.value:h.value<f.value)return;h.issues.push({origin:m,code:"too_big",maximum:typeof f.value==="object"?f.value.getTime():f.value,input:h.value,inclusive:f.inclusive,inst:i,continue:!f.abort})}}),hr=w("$ZodCheckGreaterThan",(i,f)=>{W.init(i,f);let m=so[typeof f.value];i._zod.onattach.push((h)=>{let _=h._zod.bag,g=(f.inclusive?_.minimum:_.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(f.value>g)if(f.inclusive)_.minimum=f.value;else _.exclusiveMinimum=f.value}),i._zod.check=(h)=>{if(f.inclusive?h.value>=f.value:h.value>f.value)return;h.issues.push({origin:m,code:"too_small",minimum:typeof f.value==="object"?f.value.getTime():f.value,input:h.value,inclusive:f.inclusive,inst:i,continue:!f.abort})}}),io=w("$ZodCheckMultipleOf",(i,f)=>{W.init(i,f),i._zod.onattach.push((m)=>{var h;(h=m._zod.bag).multipleOf??(h.multipleOf=f.value)}),i._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"?m.value%f.value===BigInt(0):lt(m.value,f.value)===0)return;m.issues.push({origin:typeof m.value,code:"not_multiple_of",divisor:f.value,input:m.value,inst:i,continue:!f.abort})}}),co=w("$ZodCheckNumberFormat",(i,f)=>{W.init(i,f),f.format=f.format||"float64";let m=f.format?.includes("int"),h=m?"int":"number",[_,g]=_t[f.format];i._zod.onattach.push((x)=>{let z=x._zod.bag;if(z.format=f.format,z.minimum=_,z.maximum=g,m)z.pattern=eo}),i._zod.check=(x)=>{let z=x.value;if(m){if(!Number.isInteger(z)){x.issues.push({expected:h,format:f.format,code:"invalid_type",continue:!1,input:z,inst:i});return}if(!Number.isSafeInteger(z)){if(z>0)x.issues.push({input:z,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:i,origin:h,inclusive:!0,continue:!f.abort});else x.issues.push({input:z,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:i,origin:h,inclusive:!0,continue:!f.abort});return}}if(z<_)x.issues.push({origin:"number",input:z,code:"too_small",minimum:_,inclusive:!0,inst:i,continue:!f.abort});if(z>g)x.issues.push({origin:"number",input:z,code:"too_big",maximum:g,inclusive:!0,inst:i,continue:!f.abort})}});var uo=w("$ZodCheckMaxLength",(i,f)=>{var m;W.init(i,f),(m=i._zod.def).when??(m.when=(h)=>{let _=h.value;return!Fe(_)&&_.length!==void 0}),i._zod.onattach.push((h)=>{let _=h._zod.bag.maximum??Number.POSITIVE_INFINITY;if(f.maximum<_)h._zod.bag.maximum=f.maximum}),i._zod.check=(h)=>{let _=h.value;if(_.length<=f.maximum)return;let x=Je(_);h.issues.push({origin:x,code:"too_big",maximum:f.maximum,inclusive:!0,input:_,inst:i,continue:!f.abort})}}),ao=w("$ZodCheckMinLength",(i,f)=>{var m;W.init(i,f),(m=i._zod.def).when??(m.when=(h)=>{let _=h.value;return!Fe(_)&&_.length!==void 0}),i._zod.onattach.push((h)=>{let _=h._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(f.minimum>_)h._zod.bag.minimum=f.minimum}),i._zod.check=(h)=>{let _=h.value;if(_.length>=f.minimum)return;let x=Je(_);h.issues.push({origin:x,code:"too_small",minimum:f.minimum,inclusive:!0,input:_,inst:i,continue:!f.abort})}}),po=w("$ZodCheckLengthEquals",(i,f)=>{var m;W.init(i,f),(m=i._zod.def).when??(m.when=(h)=>{let _=h.value;return!Fe(_)&&_.length!==void 0}),i._zod.onattach.push((h)=>{let _=h._zod.bag;_.minimum=f.length,_.maximum=f.length,_.length=f.length}),i._zod.check=(h)=>{let _=h.value,g=_.length;if(g===f.length)return;let x=Je(_),z=g>f.length;h.issues.push({origin:x,...z?{code:"too_big",maximum:f.length}:{code:"too_small",minimum:f.length},inclusive:!0,exact:!0,input:h.value,inst:i,continue:!f.abort})}}),ke=w("$ZodCheckStringFormat",(i,f)=>{var m,h;if(W.init(i,f),i._zod.onattach.push((_)=>{let g=_._zod.bag;if(g.format=f.format,f.pattern)g.patterns??(g.patterns=new Set),g.patterns.add(f.pattern)}),f.pattern)(m=i._zod).check??(m.check=(_)=>{if(f.pattern.lastIndex=0,f.pattern.test(_.value))return;_.issues.push({origin:"string",code:"invalid_format",format:f.format,input:_.value,...f.pattern?{pattern:f.pattern.toString()}:{},inst:i,continue:!f.abort})});else(h=i._zod).check??(h.check=()=>{})}),lo=w("$ZodCheckRegex",(i,f)=>{ke.init(i,f),i._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:i,continue:!f.abort})}}),fo=w("$ZodCheckLowerCase",(i,f)=>{f.pattern??(f.pattern=oo),ke.init(i,f)}),mo=w("$ZodCheckUpperCase",(i,f)=>{f.pattern??(f.pattern=no),ke.init(i,f)}),ho=w("$ZodCheckIncludes",(i,f)=>{W.init(i,f);let m=ee(f.includes),h=new RegExp(typeof f.position==="number"?`^.{${f.position}}${m}`:m);f.pattern=h,i._zod.onattach.push((_)=>{let g=_._zod.bag;g.patterns??(g.patterns=new Set),g.patterns.add(h)}),i._zod.check=(_)=>{if(_.value.includes(f.includes,f.position))return;_.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:f.includes,input:_.value,inst:i,continue:!f.abort})}}),_o=w("$ZodCheckStartsWith",(i,f)=>{W.init(i,f);let m=new RegExp(`^${ee(f.prefix)}.*`);f.pattern??(f.pattern=m),i._zod.onattach.push((h)=>{let _=h._zod.bag;_.patterns??(_.patterns=new Set),_.patterns.add(m)}),i._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:i,continue:!f.abort})}}),go=w("$ZodCheckEndsWith",(i,f)=>{W.init(i,f);let m=new RegExp(`.*${ee(f.suffix)}$`);f.pattern??(f.pattern=m),i._zod.onattach.push((h)=>{let _=h._zod.bag;_.patterns??(_.patterns=new Set),_.patterns.add(m)}),i._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:i,continue:!f.abort})}});var xo=w("$ZodCheckOverwrite",(i,f)=>{W.init(i,f),i._zod.check=(m)=>{m.value=f.tx(m.value)}});class _r{constructor(i=[]){if(this.content=[],this.indent=0,this)this.args=i}indented(i){this.indent+=1,i(this),this.indent-=1}write(i){if(typeof i==="function"){i(this,{execution:"sync"}),i(this,{execution:"async"});return}let m=i.split(`
3
- `).filter((g)=>g),h=Math.min(...m.map((g)=>g.length-g.trimStart().length)),_=m.map((g)=>g.slice(h)).map((g)=>" ".repeat(this.indent*2)+g);for(let g of _)this.content.push(g)}compile(){let i=Function,f=this?.args,h=[...(this?.content??[""]).map((_)=>` ${_}`)];return new i(...f,h.join(`
4
- `))}}var vo={major:4,minor:4,patch:3};var j=w("$ZodType",(i,f)=>{var m;i??(i={}),i._zod.def=f,i._zod.bag=i._zod.bag||{},i._zod.version=vo;let h=[...i._zod.def.checks??[]];if(i._zod.traits.has("$ZodCheck"))h.unshift(i);for(let _ of h)for(let g of _._zod.onattach)g(i);if(h.length===0)(m=i._zod).deferred??(m.deferred=[]),i._zod.deferred?.push(()=>{i._zod.run=i._zod.parse});else{let _=(x,z,v)=>{let y=ie(x),Z;for(let S of z){if(S._zod.def.when){if(gt(x))continue;if(!S._zod.def.when(x))continue}else if(y)continue;let T=x.issues.length,I=S._zod.check(x);if(I instanceof Promise&&v?.async===!1)throw new H;if(Z||I instanceof Promise)Z=(Z??Promise.resolve()).then(async()=>{if(await I,x.issues.length===T)return;if(!y)y=ie(x,T)});else{if(x.issues.length===T)continue;if(!y)y=ie(x,T)}}if(Z)return Z.then(()=>x);return x},g=(x,z,v)=>{if(ie(x))return x.aborted=!0,x;let y=_(z,h,v);if(y instanceof Promise){if(v.async===!1)throw new H;return y.then((Z)=>i._zod.parse(Z,v))}return i._zod.parse(y,v)};i._zod.run=(x,z)=>{if(z.skipChecks)return i._zod.parse(x,z);if(z.direction==="backward"){let y=i._zod.parse({value:x.value,issues:[]},{...z,skipChecks:!0});if(y instanceof Promise)return y.then((Z)=>g(Z,x,z));return g(y,x,z)}let v=i._zod.parse(x,z);if(v instanceof Promise){if(z.async===!1)throw new H;return v.then((y)=>_(y,h,z))}return _(v,h,z)}}N(i,"~standard",()=>({validate:(_)=>{try{let g=yt(i,_);return g.success?{value:g.data}:{issues:g.error?.issues}}catch(g){return $t(i,_).then((x)=>x.success?{value:x.data}:{issues:x.error?.issues})}},vendor:"zod",version:1}))}),Ye=w("$ZodString",(i,f)=>{j.init(i,f),i._zod.pattern=[...i?._zod.bag?.patterns??[]].pop()??Qt(i._zod.bag),i._zod.parse=(m,h)=>{if(f.coerce)try{m.value=String(m.value)}catch(_){}if(typeof m.value==="string")return m;return m.issues.push({expected:"string",code:"invalid_type",input:m.value,inst:i}),m}}),L=w("$ZodStringFormat",(i,f)=>{ke.init(i,f),Ye.init(i,f)}),Oo=w("$ZodGUID",(i,f)=>{f.pattern??(f.pattern=Dt),L.init(i,f)}),Eo=w("$ZodUUID",(i,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=lr(h))}else f.pattern??(f.pattern=lr());L.init(i,f)}),Io=w("$ZodEmail",(i,f)=>{f.pattern??(f.pattern=Lt),L.init(i,f)}),To=w("$ZodURL",(i,f)=>{L.init(i,f),i._zod.check=(m)=>{try{let h=m.value.trim();if(!f.normalize&&f.protocol?.source===Wt.source){if(!/^https?:\/\//i.test(h)){m.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:m.value,inst:i,continue:!f.abort});return}}let _=new URL(h);if(f.hostname){if(f.hostname.lastIndex=0,!f.hostname.test(_.hostname))m.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:f.hostname.source,input:m.value,inst:i,continue:!f.abort})}if(f.protocol){if(f.protocol.lastIndex=0,!f.protocol.test(_.protocol.endsWith(":")?_.protocol.slice(0,-1):_.protocol))m.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:f.protocol.source,input:m.value,inst:i,continue:!f.abort})}if(f.normalize)m.value=_.href;else m.value=h;return}catch(h){m.issues.push({code:"invalid_format",format:"url",input:m.value,inst:i,continue:!f.abort})}}}),No=w("$ZodEmoji",(i,f)=>{f.pattern??(f.pattern=Ft()),L.init(i,f)}),Ao=w("$ZodNanoID",(i,f)=>{f.pattern??(f.pattern=Ct),L.init(i,f)}),jo=w("$ZodCUID",(i,f)=>{f.pattern??(f.pattern=It),L.init(i,f)}),Co=w("$ZodCUID2",(i,f)=>{f.pattern??(f.pattern=Tt),L.init(i,f)}),Ro=w("$ZodULID",(i,f)=>{f.pattern??(f.pattern=Nt),L.init(i,f)}),Do=w("$ZodXID",(i,f)=>{f.pattern??(f.pattern=At),L.init(i,f)}),Lo=w("$ZodKSUID",(i,f)=>{f.pattern??(f.pattern=jt),L.init(i,f)}),Fo=w("$ZodISODateTime",(i,f)=>{f.pattern??(f.pattern=Ht(f)),L.init(i,f)}),Uo=w("$ZodISODate",(i,f)=>{f.pattern??(f.pattern=qt),L.init(i,f)}),Mo=w("$ZodISOTime",(i,f)=>{f.pattern??(f.pattern=Xt(f)),L.init(i,f)}),Jo=w("$ZodISODuration",(i,f)=>{f.pattern??(f.pattern=Rt),L.init(i,f)}),Bo=w("$ZodIPv4",(i,f)=>{f.pattern??(f.pattern=Ut),L.init(i,f),i._zod.bag.format="ipv4"}),Vo=w("$ZodIPv6",(i,f)=>{f.pattern??(f.pattern=Mt),L.init(i,f),i._zod.bag.format="ipv6",i._zod.check=(m)=>{try{new URL(`http://[${m.value}]`)}catch{m.issues.push({code:"invalid_format",format:"ipv6",input:m.value,inst:i,continue:!f.abort})}}});var Wo=w("$ZodCIDRv4",(i,f)=>{f.pattern??(f.pattern=Jt),L.init(i,f)}),Ko=w("$ZodCIDRv6",(i,f)=>{f.pattern??(f.pattern=Bt),L.init(i,f),i._zod.check=(m)=>{let h=m.value.split("/");try{if(h.length!==2)throw Error();let[_,g]=h;if(!g)throw Error();let x=Number(g);if(`${x}`!==g)throw Error();if(x<0||x>128)throw Error();new URL(`http://[${_}]`)}catch{m.issues.push({code:"invalid_format",format:"cidrv6",input:m.value,inst:i,continue:!f.abort})}}});function Go(i){if(i==="")return!0;if(/\s/.test(i))return!1;if(i.length%4!==0)return!1;try{return atob(i),!0}catch{return!1}}var qo=w("$ZodBase64",(i,f)=>{f.pattern??(f.pattern=Vt),L.init(i,f),i._zod.bag.contentEncoding="base64",i._zod.check=(m)=>{if(Go(m.value))return;m.issues.push({code:"invalid_format",format:"base64",input:m.value,inst:i,continue:!f.abort})}});function pi(i){if(!fr.test(i))return!1;let f=i.replace(/[-_]/g,(h)=>h==="-"?"+":"/"),m=f.padEnd(Math.ceil(f.length/4)*4,"=");return Go(m)}var Yo=w("$ZodBase64URL",(i,f)=>{f.pattern??(f.pattern=fr),L.init(i,f),i._zod.bag.contentEncoding="base64url",i._zod.check=(m)=>{if(pi(m.value))return;m.issues.push({code:"invalid_format",format:"base64url",input:m.value,inst:i,continue:!f.abort})}}),Xo=w("$ZodE164",(i,f)=>{f.pattern??(f.pattern=Kt),L.init(i,f)});function li(i,f=null){try{let m=i.split(".");if(m.length!==3)return!1;let[h]=m;if(!h)return!1;let _=JSON.parse(atob(h));if("typ"in _&&_?.typ!=="JWT")return!1;if(!_.alg)return!1;if(f&&(!("alg"in _)||_.alg!==f))return!1;return!0}catch{return!1}}var Ho=w("$ZodJWT",(i,f)=>{L.init(i,f),i._zod.check=(m)=>{if(li(m.value,f.alg))return;m.issues.push({code:"invalid_format",format:"jwt",input:m.value,inst:i,continue:!f.abort})}});var xr=w("$ZodNumber",(i,f)=>{j.init(i,f),i._zod.pattern=i._zod.bag.pattern??dr,i._zod.parse=(m,h)=>{if(f.coerce)try{m.value=Number(m.value)}catch(x){}let _=m.value;if(typeof _==="number"&&!Number.isNaN(_)&&Number.isFinite(_))return m;let g=typeof _==="number"?Number.isNaN(_)?"NaN":!Number.isFinite(_)?"Infinity":void 0:void 0;return m.issues.push({expected:"number",code:"invalid_type",input:_,inst:i,...g?{received:g}:{}}),m}}),Qo=w("$ZodNumberFormat",(i,f)=>{co.init(i,f),xr.init(i,f)}),en=w("$ZodBoolean",(i,f)=>{j.init(i,f),i._zod.pattern=ro,i._zod.parse=(m,h)=>{if(f.coerce)try{m.value=Boolean(m.value)}catch(g){}let _=m.value;if(typeof _==="boolean")return m;return m.issues.push({expected:"boolean",code:"invalid_type",input:_,inst:i}),m}});var rn=w("$ZodNull",(i,f)=>{j.init(i,f),i._zod.pattern=to,i._zod.values=new Set([null]),i._zod.parse=(m,h)=>{let _=m.value;if(_===null)return m;return m.issues.push({expected:"null",code:"invalid_type",input:_,inst:i}),m}}),tn=w("$ZodAny",(i,f)=>{j.init(i,f),i._zod.parse=(m)=>m}),on=w("$ZodUnknown",(i,f)=>{j.init(i,f),i._zod.parse=(m)=>m}),nn=w("$ZodNever",(i,f)=>{j.init(i,f),i._zod.parse=(m,h)=>(m.issues.push({expected:"never",code:"invalid_type",input:m.value,inst:i}),m)});function yo(i,f,m){if(i.issues.length)f.issues.push(...re(m,i.issues));f.value[m]=i.value}var sn=w("$ZodArray",(i,f)=>{j.init(i,f),i._zod.parse=(m,h)=>{let _=m.value;if(!Array.isArray(_))return m.issues.push({expected:"array",code:"invalid_type",input:_,inst:i}),m;m.value=Array(_.length);let g=[];for(let x=0;x<_.length;x++){let z=_[x],v=f.element._zod.run({value:z,issues:[]},h);if(v instanceof Promise)g.push(v.then((y)=>yo(y,m,x)));else yo(v,m,x)}if(g.length)return Promise.all(g).then(()=>m);return m}});function qe(i,f,m,h,_,g){let x=m in h;if(i.issues.length){if(_&&g&&!x)return;f.issues.push(...re(m,i.issues))}if(!x&&!_){if(!i.issues.length)f.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[m]});return}if(i.value===void 0){if(x)f.value[m]=void 0}else f.value[m]=i.value}function cn(i){let f=Object.keys(i.shape);for(let h of f)if(!i.shape?.[h]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${h}": expected a Zod schema`);let m=ht(i.shape);return{...i,keys:f,keySet:new Set(f),numKeys:f.length,optionalKeys:new Set(m)}}function un(i,f,m,h,_,g){let x=[],z=_.keySet,v=_.catchall._zod,y=v.def.type,Z=v.optin==="optional",S=v.optout==="optional";for(let T in f){if(T==="__proto__")continue;if(z.has(T))continue;if(y==="never"){x.push(T);continue}let I=v.run({value:f[T],issues:[]},h);if(I instanceof Promise)i.push(I.then((A)=>qe(A,m,T,f,Z,S)));else qe(I,m,T,f,Z,S)}if(x.length)m.issues.push({code:"unrecognized_keys",keys:x,input:f,inst:g});if(!i.length)return m;return Promise.all(i).then(()=>m)}var fi=w("$ZodObject",(i,f)=>{if(j.init(i,f),!Object.getOwnPropertyDescriptor(f,"shape")?.get){let z=f.shape;Object.defineProperty(f,"shape",{get:()=>{let v={...z};return Object.defineProperty(f,"shape",{value:v}),v}})}let h=ze(()=>cn(f));N(i._zod,"propValues",()=>{let z=f.shape,v={};for(let y in z){let Z=z[y]._zod;if(Z.values){v[y]??(v[y]=new Set);for(let S of Z.values)v[y].add(S)}}return v});let _=de,g=f.catchall,x;i._zod.parse=(z,v)=>{x??(x=h.value);let y=z.value;if(!_(y))return z.issues.push({expected:"object",code:"invalid_type",input:y,inst:i}),z;z.value={};let Z=[],S=x.shape;for(let T of x.keys){let I=S[T],A=I._zod.optin==="optional",he=I._zod.optout==="optional",J=I._zod.run({value:y[T],issues:[]},v);if(J instanceof Promise)Z.push(J.then((sr)=>qe(sr,z,T,y,A,he)));else qe(J,z,T,y,A,he)}if(!g)return Z.length?Promise.all(Z).then(()=>z):z;return un(Z,y,z,v,h.value,i)}}),an=w("$ZodObjectJIT",(i,f)=>{fi.init(i,f);let m=i._zod.parse,h=ze(()=>cn(f)),_=(T)=>{let I=new _r(["shape","payload","ctx"]),A=h.value,he=(Y)=>{let U=cr(Y);return`shape[${U}]._zod.run({ value: input[${U}], issues: [] }, ctx)`};I.write("const input = payload.value;");let J=Object.create(null),sr=0;for(let Y of A.keys)J[Y]=`key_${sr++}`;I.write("const newResult = {};");for(let Y of A.keys){let U=J[Y],B=cr(Y),ct=T[Y],ut=ct?._zod?.optin==="optional",Qs=ct?._zod?.optout==="optional";if(I.write(`const ${U} = ${he(Y)};`),ut&&Qs)I.write(`
5
- if (${U}.issues.length) {
6
- if (${B} in input) {
7
- payload.issues = payload.issues.concat(${U}.issues.map(iss => ({
8
- ...iss,
9
- path: iss.path ? [${B}, ...iss.path] : [${B}]
10
- })));
11
- }
12
- }
13
-
14
- if (${U}.value === undefined) {
15
- if (${B} in input) {
16
- newResult[${B}] = undefined;
17
- }
18
- } else {
19
- newResult[${B}] = ${U}.value;
20
- }
21
-
22
- `);else if(!ut)I.write(`
23
- const ${U}_present = ${B} in input;
24
- if (${U}.issues.length) {
25
- payload.issues = payload.issues.concat(${U}.issues.map(iss => ({
26
- ...iss,
27
- path: iss.path ? [${B}, ...iss.path] : [${B}]
28
- })));
29
- }
30
- if (!${U}_present && !${U}.issues.length) {
31
- payload.issues.push({
32
- code: "invalid_type",
33
- expected: "nonoptional",
34
- input: undefined,
35
- path: [${B}]
36
- });
37
- }
38
-
39
- if (${U}_present) {
40
- if (${U}.value === undefined) {
41
- newResult[${B}] = undefined;
42
- } else {
43
- newResult[${B}] = ${U}.value;
44
- }
45
- }
46
-
47
- `);else I.write(`
48
- if (${U}.issues.length) {
49
- payload.issues = payload.issues.concat(${U}.issues.map(iss => ({
50
- ...iss,
51
- path: iss.path ? [${B}, ...iss.path] : [${B}]
52
- })));
53
- }
54
-
55
- if (${U}.value === undefined) {
56
- if (${B} in input) {
57
- newResult[${B}] = undefined;
58
- }
59
- } else {
60
- newResult[${B}] = ${U}.value;
61
- }
62
-
63
- `)}I.write("payload.value = newResult;"),I.write("return payload;");let Hs=I.compile();return(Y,U)=>Hs(T,Y,U)},g,x=de,z=!fe.jitless,y=z&&dt.value,Z=f.catchall,S;i._zod.parse=(T,I)=>{S??(S=h.value);let A=T.value;if(!x(A))return T.issues.push({expected:"object",code:"invalid_type",input:A,inst:i}),T;if(z&&y&&I?.async===!1&&I.jitless!==!0){if(!g)g=_(f.shape);if(T=g(T,I),!Z)return T;return un([],A,T,I,S,i)}return m(T,I)}});function $o(i,f,m,h){for(let g of i)if(g.issues.length===0)return f.value=g.value,f;let _=i.filter((g)=>!ie(g));if(_.length===1)return f.value=_[0].value,_[0];return f.issues.push({code:"invalid_union",input:f.value,inst:m,errors:i.map((g)=>g.issues.map((x)=>q(x,h,b())))}),f}var zr=w("$ZodUnion",(i,f)=>{j.init(i,f),N(i._zod,"optin",()=>f.options.some((h)=>h._zod.optin==="optional")?"optional":void 0),N(i._zod,"optout",()=>f.options.some((h)=>h._zod.optout==="optional")?"optional":void 0),N(i._zod,"values",()=>{if(f.options.every((h)=>h._zod.values))return new Set(f.options.flatMap((h)=>Array.from(h._zod.values)));return}),N(i._zod,"pattern",()=>{if(f.options.every((h)=>h._zod.pattern)){let h=f.options.map((_)=>_._zod.pattern);return new RegExp(`^(${h.map((_)=>Ue(_.source)).join("|")})$`)}return});let m=f.options.length===1?f.options[0]._zod.run:null;i._zod.parse=(h,_)=>{if(m)return m(h,_);let g=!1,x=[];for(let z of f.options){let v=z._zod.run({value:h.value,issues:[]},_);if(v instanceof Promise)x.push(v),g=!0;else{if(v.issues.length===0)return v;x.push(v)}}if(!g)return $o(x,h,i,_);return Promise.all(x).then((z)=>$o(z,h,i,_))}});var pn=w("$ZodDiscriminatedUnion",(i,f)=>{f.inclusive=!1,zr.init(i,f);let m=i._zod.parse;N(i._zod,"propValues",()=>{let _={};for(let g of f.options){let x=g._zod.propValues;if(!x||Object.keys(x).length===0)throw Error(`Invalid discriminated union option at index "${f.options.indexOf(g)}"`);for(let[z,v]of Object.entries(x)){if(!_[z])_[z]=new Set;for(let y of v)_[z].add(y)}}return _});let h=ze(()=>{let _=f.options,g=new Map;for(let x of _){let z=x._zod.propValues?.[f.discriminator];if(!z||z.size===0)throw Error(`Invalid discriminated union option at index "${f.options.indexOf(x)}"`);for(let v of z){if(g.has(v))throw Error(`Duplicate discriminator value "${String(v)}"`);g.set(v,x)}}return g});i._zod.parse=(_,g)=>{let x=_.value;if(!de(x))return _.issues.push({code:"invalid_type",expected:"object",input:x,inst:i}),_;let z=h.value.get(x?.[f.discriminator]);if(z)return z._zod.run(_,g);if(f.unionFallback||g.direction==="backward")return m(_,g);return _.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:f.discriminator,options:Array.from(h.value.keys()),input:x,path:[f.discriminator],inst:i}),_}}),ln=w("$ZodIntersection",(i,f)=>{j.init(i,f),i._zod.parse=(m,h)=>{let _=m.value,g=f.left._zod.run({value:_,issues:[]},h),x=f.right._zod.run({value:_,issues:[]},h);if(g instanceof Promise||x instanceof Promise)return Promise.all([g,x]).then(([v,y])=>bo(m,v,y));return bo(m,g,x)}});function gr(i,f){if(i===f)return{valid:!0,data:i};if(i instanceof Date&&f instanceof Date&&+i===+f)return{valid:!0,data:i};if(se(i)&&se(f)){let m=Object.keys(f),h=Object.keys(i).filter((g)=>m.indexOf(g)!==-1),_={...i,...f};for(let g of h){let x=gr(i[g],f[g]);if(!x.valid)return{valid:!1,mergeErrorPath:[g,...x.mergeErrorPath]};_[g]=x.data}return{valid:!0,data:_}}if(Array.isArray(i)&&Array.isArray(f)){if(i.length!==f.length)return{valid:!1,mergeErrorPath:[]};let m=[];for(let h=0;h<i.length;h++){let _=i[h],g=f[h],x=gr(_,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 bo(i,f,m){let h=new Map,_;for(let z of f.issues)if(z.code==="unrecognized_keys"){_??(_=z);for(let v of z.keys){if(!h.has(v))h.set(v,{});h.get(v).l=!0}}else i.issues.push(z);for(let z of m.issues)if(z.code==="unrecognized_keys")for(let v of z.keys){if(!h.has(v))h.set(v,{});h.get(v).r=!0}else i.issues.push(z);let g=[...h].filter(([,z])=>z.l&&z.r).map(([z])=>z);if(g.length&&_)i.issues.push({..._,keys:g});if(ie(i))return i;let x=gr(f.value,m.value);if(!x.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(x.mergeErrorPath)}`);return i.value=x.data,i}var fn=w("$ZodRecord",(i,f)=>{j.init(i,f),i._zod.parse=(m,h)=>{let _=m.value;if(!se(_))return m.issues.push({expected:"record",code:"invalid_type",input:_,inst:i}),m;let g=[],x=f.keyType._zod.values;if(x){m.value={};let z=new Set;for(let y of x)if(typeof y==="string"||typeof y==="number"||typeof y==="symbol"){z.add(typeof y==="number"?y.toString():y);let Z=f.keyType._zod.run({value:y,issues:[]},h);if(Z instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(Z.issues.length){m.issues.push({code:"invalid_key",origin:"record",issues:Z.issues.map((I)=>q(I,h,b())),input:y,path:[y],inst:i});continue}let S=Z.value,T=f.valueType._zod.run({value:_[y],issues:[]},h);if(T instanceof Promise)g.push(T.then((I)=>{if(I.issues.length)m.issues.push(...re(y,I.issues));m.value[S]=I.value}));else{if(T.issues.length)m.issues.push(...re(y,T.issues));m.value[S]=T.value}}let v;for(let y in _)if(!z.has(y))v=v??[],v.push(y);if(v&&v.length>0)m.issues.push({code:"unrecognized_keys",input:_,inst:i,keys:v})}else{m.value={};for(let z of Reflect.ownKeys(_)){if(z==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(_,z))continue;let v=f.keyType._zod.run({value:z,issues:[]},h);if(v instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof z==="string"&&dr.test(z)&&v.issues.length){let S=f.keyType._zod.run({value:Number(z),issues:[]},h);if(S instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(S.issues.length===0)v=S}if(v.issues.length){if(f.mode==="loose")m.value[z]=_[z];else m.issues.push({code:"invalid_key",origin:"record",issues:v.issues.map((S)=>q(S,h,b())),input:z,path:[z],inst:i});continue}let Z=f.valueType._zod.run({value:_[z],issues:[]},h);if(Z instanceof Promise)g.push(Z.then((S)=>{if(S.issues.length)m.issues.push(...re(z,S.issues));m.value[v.value]=S.value}));else{if(Z.issues.length)m.issues.push(...re(z,Z.issues));m.value[v.value]=Z.value}}}if(g.length)return Promise.all(g).then(()=>m);return m}});var dn=w("$ZodEnum",(i,f)=>{j.init(i,f);let m=Le(f.entries),h=new Set(m);i._zod.values=h,i._zod.pattern=new RegExp(`^(${m.filter((_)=>mt.has(typeof _)).map((_)=>typeof _==="string"?ee(_):_.toString()).join("|")})$`),i._zod.parse=(_,g)=>{let x=_.value;if(h.has(x))return _;return _.issues.push({code:"invalid_value",values:m,input:x,inst:i}),_}}),mn=w("$ZodLiteral",(i,f)=>{if(j.init(i,f),f.values.length===0)throw Error("Cannot create literal schema with no valid values");let m=new Set(f.values);i._zod.values=m,i._zod.pattern=new RegExp(`^(${f.values.map((h)=>typeof h==="string"?ee(h):h?ee(h.toString()):String(h)).join("|")})$`),i._zod.parse=(h,_)=>{let g=h.value;if(m.has(g))return h;return h.issues.push({code:"invalid_value",values:f.values,input:g,inst:i}),h}});var hn=w("$ZodTransform",(i,f)=>{j.init(i,f),i._zod.optin="optional",i._zod.parse=(m,h)=>{if(h.direction==="backward")throw new _e(i.constructor.name);let _=f.transform(m.value,m);if(h.async)return(_ instanceof Promise?_:Promise.resolve(_)).then((x)=>(m.value=x,m.fallback=!0,m));if(_ instanceof Promise)throw new H;return m.value=_,m.fallback=!0,m}});function wo(i,f){if(f===void 0&&(i.issues.length||i.fallback))return{issues:[],value:void 0};return i}var vr=w("$ZodOptional",(i,f)=>{j.init(i,f),i._zod.optin="optional",i._zod.optout="optional",N(i._zod,"values",()=>f.innerType._zod.values?new Set([...f.innerType._zod.values,void 0]):void 0),N(i._zod,"pattern",()=>{let m=f.innerType._zod.pattern;return m?new RegExp(`^(${Ue(m.source)})?$`):void 0}),i._zod.parse=(m,h)=>{if(f.innerType._zod.optin==="optional"){let _=m.value,g=f.innerType._zod.run(m,h);if(g instanceof Promise)return g.then((x)=>wo(x,_));return wo(g,_)}if(m.value===void 0)return m;return f.innerType._zod.run(m,h)}}),_n=w("$ZodExactOptional",(i,f)=>{vr.init(i,f),N(i._zod,"values",()=>f.innerType._zod.values),N(i._zod,"pattern",()=>f.innerType._zod.pattern),i._zod.parse=(m,h)=>f.innerType._zod.run(m,h)}),gn=w("$ZodNullable",(i,f)=>{j.init(i,f),N(i._zod,"optin",()=>f.innerType._zod.optin),N(i._zod,"optout",()=>f.innerType._zod.optout),N(i._zod,"pattern",()=>{let m=f.innerType._zod.pattern;return m?new RegExp(`^(${Ue(m.source)}|null)$`):void 0}),N(i._zod,"values",()=>f.innerType._zod.values?new Set([...f.innerType._zod.values,null]):void 0),i._zod.parse=(m,h)=>{if(m.value===null)return m;return f.innerType._zod.run(m,h)}}),xn=w("$ZodDefault",(i,f)=>{j.init(i,f),i._zod.optin="optional",N(i._zod,"values",()=>f.innerType._zod.values),i._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 _=f.innerType._zod.run(m,h);if(_ instanceof Promise)return _.then((g)=>ko(g,f));return ko(_,f)}});function ko(i,f){if(i.value===void 0)i.value=f.defaultValue;return i}var zn=w("$ZodPrefault",(i,f)=>{j.init(i,f),i._zod.optin="optional",N(i._zod,"values",()=>f.innerType._zod.values),i._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)}}),vn=w("$ZodNonOptional",(i,f)=>{j.init(i,f),N(i._zod,"values",()=>{let m=f.innerType._zod.values;return m?new Set([...m].filter((h)=>h!==void 0)):void 0}),i._zod.parse=(m,h)=>{let _=f.innerType._zod.run(m,h);if(_ instanceof Promise)return _.then((g)=>Zo(g,i));return Zo(_,i)}});function Zo(i,f){if(!i.issues.length&&i.value===void 0)i.issues.push({code:"invalid_type",expected:"nonoptional",input:i.value,inst:f});return i}var yn=w("$ZodCatch",(i,f)=>{j.init(i,f),i._zod.optin="optional",N(i._zod,"optout",()=>f.innerType._zod.optout),N(i._zod,"values",()=>f.innerType._zod.values),i._zod.parse=(m,h)=>{if(h.direction==="backward")return f.innerType._zod.run(m,h);let _=f.innerType._zod.run(m,h);if(_ instanceof Promise)return _.then((g)=>{if(m.value=g.value,g.issues.length)m.value=f.catchValue({...m,error:{issues:g.issues.map((x)=>q(x,h,b()))},input:m.value}),m.issues=[],m.fallback=!0;return m});if(m.value=_.value,_.issues.length)m.value=f.catchValue({...m,error:{issues:_.issues.map((g)=>q(g,h,b()))},input:m.value}),m.issues=[],m.fallback=!0;return m}});var yr=w("$ZodPipe",(i,f)=>{j.init(i,f),N(i._zod,"values",()=>f.in._zod.values),N(i._zod,"optin",()=>f.in._zod.optin),N(i._zod,"optout",()=>f.out._zod.optout),N(i._zod,"propValues",()=>f.in._zod.propValues),i._zod.parse=(m,h)=>{if(h.direction==="backward"){let g=f.out._zod.run(m,h);if(g instanceof Promise)return g.then((x)=>Ge(x,f.in,h));return Ge(g,f.in,h)}let _=f.in._zod.run(m,h);if(_ instanceof Promise)return _.then((g)=>Ge(g,f.out,h));return Ge(_,f.out,h)}});function Ge(i,f,m){if(i.issues.length)return i.aborted=!0,i;return f._zod.run({value:i.value,issues:i.issues,fallback:i.fallback},m)}var $n=w("$ZodPreprocess",(i,f)=>{yr.init(i,f)}),bn=w("$ZodReadonly",(i,f)=>{j.init(i,f),N(i._zod,"propValues",()=>f.innerType._zod.propValues),N(i._zod,"values",()=>f.innerType._zod.values),N(i._zod,"optin",()=>f.innerType?._zod?.optin),N(i._zod,"optout",()=>f.innerType?._zod?.optout),i._zod.parse=(m,h)=>{if(h.direction==="backward")return f.innerType._zod.run(m,h);let _=f.innerType._zod.run(m,h);if(_ instanceof Promise)return _.then(Po);return Po(_)}});function Po(i){return i.value=Object.freeze(i.value),i}var wn=w("$ZodLazy",(i,f)=>{j.init(i,f),N(i._zod,"innerType",()=>{let m=f;if(!m._cachedInner)m._cachedInner=f.getter();return m._cachedInner}),N(i._zod,"pattern",()=>i._zod.innerType?._zod?.pattern),N(i._zod,"propValues",()=>i._zod.innerType?._zod?.propValues),N(i._zod,"optin",()=>i._zod.innerType?._zod?.optin??void 0),N(i._zod,"optout",()=>i._zod.innerType?._zod?.optout??void 0),i._zod.parse=(m,h)=>i._zod.innerType._zod.run(m,h)}),kn=w("$ZodCustom",(i,f)=>{W.init(i,f),j.init(i,f),i._zod.parse=(m,h)=>m,i._zod.check=(m)=>{let h=m.value,_=f.fn(h);if(_ instanceof Promise)return _.then((g)=>So(g,m,h,i));So(_,m,h,i);return}});function So(i,f,m,h){if(!i){let _={code:"custom",input:m,inst:h,path:[...h._zod.def.path??[]],continue:!h._zod.def.abort};if(h._zod.def.params)_.params=h._zod.def.params;f.issues.push(ue(_))}}var Zn,Uc=Symbol("ZodOutput"),Mc=Symbol("ZodInput");class Pn{constructor(){this._map=new WeakMap,this._idmap=new Map}add(i,...f){let m=f[0];if(this._map.set(i,m),m&&typeof m==="object"&&"id"in m)this._idmap.set(m.id,i);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(i){let f=this._map.get(i);if(f&&typeof f==="object"&&"id"in f)this._idmap.delete(f.id);return this._map.delete(i),this}get(i){let f=i._zod.parent;if(f){let m={...this.get(f)??{}};delete m.id;let h={...m,...this._map.get(i)};return Object.keys(h).length?h:void 0}return this._map.get(i)}has(i){return this._map.has(i)}}function di(){return new Pn}(Zn=globalThis).__zod_globalRegistry??(Zn.__zod_globalRegistry=di());var pe=globalThis.__zod_globalRegistry;function Sn(i,f){return new i({type:"string",...P(f)})}function $r(i,f){return new i({type:"string",format:"email",check:"string_format",abort:!1,...P(f)})}function br(i,f){return new i({type:"string",format:"guid",check:"string_format",abort:!1,...P(f)})}function On(i,f){return new i({type:"string",format:"uuid",check:"string_format",abort:!1,...P(f)})}function En(i,f){return new i({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...P(f)})}function In(i,f){return new i({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...P(f)})}function Tn(i,f){return new i({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...P(f)})}function wr(i,f){return new i({type:"string",format:"url",check:"string_format",abort:!1,...P(f)})}function Nn(i,f){return new i({type:"string",format:"emoji",check:"string_format",abort:!1,...P(f)})}function An(i,f){return new i({type:"string",format:"nanoid",check:"string_format",abort:!1,...P(f)})}function jn(i,f){return new i({type:"string",format:"cuid",check:"string_format",abort:!1,...P(f)})}function Cn(i,f){return new i({type:"string",format:"cuid2",check:"string_format",abort:!1,...P(f)})}function Rn(i,f){return new i({type:"string",format:"ulid",check:"string_format",abort:!1,...P(f)})}function Dn(i,f){return new i({type:"string",format:"xid",check:"string_format",abort:!1,...P(f)})}function Ln(i,f){return new i({type:"string",format:"ksuid",check:"string_format",abort:!1,...P(f)})}function Fn(i,f){return new i({type:"string",format:"ipv4",check:"string_format",abort:!1,...P(f)})}function Un(i,f){return new i({type:"string",format:"ipv6",check:"string_format",abort:!1,...P(f)})}function Mn(i,f){return new i({type:"string",format:"cidrv4",check:"string_format",abort:!1,...P(f)})}function Jn(i,f){return new i({type:"string",format:"cidrv6",check:"string_format",abort:!1,...P(f)})}function Bn(i,f){return new i({type:"string",format:"base64",check:"string_format",abort:!1,...P(f)})}function Vn(i,f){return new i({type:"string",format:"base64url",check:"string_format",abort:!1,...P(f)})}function Wn(i,f){return new i({type:"string",format:"e164",check:"string_format",abort:!1,...P(f)})}function Kn(i,f){return new i({type:"string",format:"jwt",check:"string_format",abort:!1,...P(f)})}function Gn(i,f){return new i({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...P(f)})}function qn(i,f){return new i({type:"string",format:"date",check:"string_format",...P(f)})}function Yn(i,f){return new i({type:"string",format:"time",check:"string_format",precision:null,...P(f)})}function Xn(i,f){return new i({type:"string",format:"duration",check:"string_format",...P(f)})}function Hn(i,f){return new i({type:"number",checks:[],...P(f)})}function Ae(i,f){return new i({type:"number",coerce:!0,checks:[],...P(f)})}function Qn(i,f){return new i({type:"number",check:"number_format",abort:!1,format:"safeint",...P(f)})}function es(i,f){return new i({type:"boolean",...P(f)})}function rs(i,f){return new i({type:"null",...P(f)})}function ts(i){return new i({type:"any"})}function os(i){return new i({type:"unknown"})}function ns(i,f){return new i({type:"never",...P(f)})}function Xe(i,f){return new mr({check:"less_than",...P(f),value:i,inclusive:!1})}function Ze(i,f){return new mr({check:"less_than",...P(f),value:i,inclusive:!0})}function He(i,f){return new hr({check:"greater_than",...P(f),value:i,inclusive:!1})}function Pe(i,f){return new hr({check:"greater_than",...P(f),value:i,inclusive:!0})}function Qe(i,f){return new io({check:"multiple_of",...P(f),value:i})}function er(i,f){return new uo({check:"max_length",...P(f),maximum:i})}function me(i,f){return new ao({check:"min_length",...P(f),minimum:i})}function rr(i,f){return new po({check:"length_equals",...P(f),length:i})}function kr(i,f){return new lo({check:"string_format",format:"regex",...P(f),pattern:i})}function Zr(i){return new fo({check:"string_format",format:"lowercase",...P(i)})}function Pr(i){return new mo({check:"string_format",format:"uppercase",...P(i)})}function Sr(i,f){return new ho({check:"string_format",format:"includes",...P(f),includes:i})}function Or(i,f){return new _o({check:"string_format",format:"starts_with",...P(f),prefix:i})}function Er(i,f){return new go({check:"string_format",format:"ends_with",...P(f),suffix:i})}function oe(i){return new xo({check:"overwrite",tx:i})}function Ir(i){return oe((f)=>f.normalize(i))}function Tr(){return oe((i)=>i.trim())}function Nr(){return oe((i)=>i.toLowerCase())}function Ar(){return oe((i)=>i.toUpperCase())}function jr(){return oe((i)=>ft(i))}function ss(i,f,m){return new i({type:"array",element:f,...P(m)})}function is(i,f,m){return new i({type:"custom",check:"custom",fn:f,...P(m)})}function cs(i,f){let m=mi((h)=>(h.addIssue=(_)=>{if(typeof _==="string")h.issues.push(ue(_,h.value,m._zod.def));else{let g=_;if(g.fatal)g.continue=!1;g.code??(g.code="custom"),g.input??(g.input=h.value),g.inst??(g.inst=m),g.continue??(g.continue=!m._zod.def.abort),h.issues.push(ue(g))}},i(h.value,h)),f);return m}function mi(i,f){let m=new W({check:"custom",...P(f)});return m._zod.check=i,m}function Te(i){let f=i?.target??"draft-2020-12";if(f==="draft-4")f="draft-04";if(f==="draft-7")f="draft-07";return{processors:i.processors??{},metadataRegistry:i?.metadata??pe,target:f,unrepresentable:i?.unrepresentable??"throw",override:i?.override??(()=>{}),io:i?.io??"output",counter:0,seen:new Map,cycles:i?.cycles??"ref",reused:i?.reused??"inline",external:i?.external??void 0}}function C(i,f,m={path:[],schemaPath:[]}){var h;let _=i._zod.def,g=f.seen.get(i);if(g){if(g.count++,m.schemaPath.includes(i))g.cycle=m.path;return g.schema}let x={schema:{},count:1,cycle:void 0,path:m.path};f.seen.set(i,x);let z=i._zod.toJSONSchema?.();if(z)x.schema=z;else{let Z={...m,schemaPath:[...m.schemaPath,i],path:m.path};if(i._zod.processJSONSchema)i._zod.processJSONSchema(f,x.schema,Z);else{let T=x.schema,I=f.processors[_.type];if(!I)throw Error(`[toJSONSchema]: Non-representable type encountered: ${_.type}`);I(i,f,T,Z)}let S=i._zod.parent;if(S){if(!x.ref)x.ref=S;C(S,f,Z),f.seen.get(S).isParent=!0}}let v=f.metadataRegistry.get(i);if(v)Object.assign(x.schema,v);if(f.io==="input"&&K(i))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(i).schema}function Ne(i,f){let m=i.seen.get(f);if(!m)throw Error("Unprocessed schema. This is a bug in Zod.");let h=new Map;for(let x of i.seen.entries()){let z=i.metadataRegistry.get(x[0])?.id;if(z){let v=h.get(z);if(v&&v!==x[0])throw Error(`Duplicate schema id "${z}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);h.set(z,x[0])}}let _=(x)=>{let z=i.target==="draft-2020-12"?"$defs":"definitions";if(i.external){let S=i.external.registry.get(x[0])?.id,T=i.external.uri??((A)=>A);if(S)return{ref:T(S)};let I=x[1].defId??x[1].schema.id??`schema${i.counter++}`;return x[1].defId=I,{defId:I,ref:`${T("__shared")}#/${z}/${I}`}}if(x[1]===m)return{ref:"#"};let y=`${"#"}/${z}/`,Z=x[1].schema.id??`__schema${i.counter++}`;return{defId:Z,ref:y+Z}},g=(x)=>{if(x[1].schema.$ref)return;let z=x[1],{ref:v,defId:y}=_(x);if(z.def={...z.schema},y)z.defId=y;let Z=z.schema;for(let S in Z)delete Z[S];Z.$ref=v};if(i.cycles==="throw")for(let x of i.seen.entries()){let z=x[1];if(z.cycle)throw Error(`Cycle detected: #/${z.cycle?.join("/")}/<root>
64
-
65
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let x of i.seen.entries()){let z=x[1];if(f===x[0]){g(x);continue}if(i.external){let y=i.external.registry.get(x[0])?.id;if(f!==x[0]&&y){g(x);continue}}if(i.metadataRegistry.get(x[0])?.id){g(x);continue}if(z.cycle){g(x);continue}if(z.count>1){if(i.reused==="ref"){g(x);continue}}}}function je(i,f){let m=i.seen.get(f);if(!m)throw Error("Unprocessed schema. This is a bug in Zod.");let h=(z)=>{let v=i.seen.get(z);if(v.ref===null)return;let y=v.def??v.schema,Z={...y},S=v.ref;if(v.ref=null,S){h(S);let I=i.seen.get(S),A=I.schema;if(A.$ref&&(i.target==="draft-07"||i.target==="draft-04"||i.target==="openapi-3.0"))y.allOf=y.allOf??[],y.allOf.push(A);else Object.assign(y,A);if(Object.assign(y,Z),z._zod.parent===S)for(let J in y){if(J==="$ref"||J==="allOf")continue;if(!(J in Z))delete y[J]}if(A.$ref&&I.def)for(let J in y){if(J==="$ref"||J==="allOf")continue;if(J in I.def&&JSON.stringify(y[J])===JSON.stringify(I.def[J]))delete y[J]}}let T=z._zod.parent;if(T&&T!==S){h(T);let I=i.seen.get(T);if(I?.schema.$ref){if(y.$ref=I.schema.$ref,I.def)for(let A in y){if(A==="$ref"||A==="allOf")continue;if(A in I.def&&JSON.stringify(y[A])===JSON.stringify(I.def[A]))delete y[A]}}}i.override({zodSchema:z,jsonSchema:y,path:v.path??[]})};for(let z of[...i.seen.entries()].reverse())h(z[0]);let _={};if(i.target==="draft-2020-12")_.$schema="https://json-schema.org/draft/2020-12/schema";else if(i.target==="draft-07")_.$schema="http://json-schema.org/draft-07/schema#";else if(i.target==="draft-04")_.$schema="http://json-schema.org/draft-04/schema#";else if(i.target==="openapi-3.0");if(i.external?.uri){let z=i.external.registry.get(f)?.id;if(!z)throw Error("Schema is missing an `id` property");_.$id=i.external.uri(z)}Object.assign(_,m.def??m.schema);let g=i.metadataRegistry.get(f)?.id;if(g!==void 0&&_.id===g)delete _.id;let x=i.external?.defs??{};for(let z of i.seen.entries()){let v=z[1];if(v.def&&v.defId){if(v.def.id===v.defId)delete v.def.id;x[v.defId]=v.def}}if(i.external);else if(Object.keys(x).length>0)if(i.target==="draft-2020-12")_.$defs=x;else _.definitions=x;try{let z=JSON.parse(JSON.stringify(_));return Object.defineProperty(z,"~standard",{value:{...f["~standard"],jsonSchema:{input:Ee(f,"input",i.processors),output:Ee(f,"output",i.processors)}},enumerable:!1,writable:!1}),z}catch(z){throw Error("Error converting schema to JSON.")}}function K(i,f){let m=f??{seen:new Set};if(m.seen.has(i))return!1;m.seen.add(i);let h=i._zod.def;if(h.type==="transform")return!0;if(h.type==="array")return K(h.element,m);if(h.type==="set")return K(h.valueType,m);if(h.type==="lazy")return K(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")return K(h.innerType,m);if(h.type==="intersection")return K(h.left,m)||K(h.right,m);if(h.type==="record"||h.type==="map")return K(h.keyType,m)||K(h.valueType,m);if(h.type==="pipe"){if(i._zod.traits.has("$ZodCodec"))return!0;return K(h.in,m)||K(h.out,m)}if(h.type==="object"){for(let _ in h.shape)if(K(h.shape[_],m))return!0;return!1}if(h.type==="union"){for(let _ of h.options)if(K(_,m))return!0;return!1}if(h.type==="tuple"){for(let _ of h.items)if(K(_,m))return!0;if(h.rest&&K(h.rest,m))return!0;return!1}return!1}var us=(i,f={})=>(m)=>{let h=Te({...m,processors:f});return C(i,h),Ne(h,i),je(h,i)},Ee=(i,f,m={})=>(h)=>{let{libraryOptions:_,target:g}=h??{},x=Te({..._??{},target:g,io:f,processors:m});return C(i,x),Ne(x,i),je(x,i)};var hi={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Cr=(i,f,m,h)=>{let _=m;_.type="string";let{minimum:g,maximum:x,format:z,patterns:v,contentEncoding:y}=i._zod.bag;if(typeof g==="number")_.minLength=g;if(typeof x==="number")_.maxLength=x;if(z){if(_.format=hi[z]??z,_.format==="")delete _.format;if(z==="time")delete _.format}if(y)_.contentEncoding=y;if(v&&v.size>0){let Z=[...v];if(Z.length===1)_.pattern=Z[0].source;else if(Z.length>1)_.allOf=[...Z.map((S)=>({...f.target==="draft-07"||f.target==="draft-04"||f.target==="openapi-3.0"?{type:"string"}:{},pattern:S.source}))]}},Rr=(i,f,m,h)=>{let _=m,{minimum:g,maximum:x,format:z,multipleOf:v,exclusiveMaximum:y,exclusiveMinimum:Z}=i._zod.bag;if(typeof z==="string"&&z.includes("int"))_.type="integer";else _.type="number";let S=typeof Z==="number"&&Z>=(g??Number.NEGATIVE_INFINITY),T=typeof y==="number"&&y<=(x??Number.POSITIVE_INFINITY),I=f.target==="draft-04"||f.target==="openapi-3.0";if(S)if(I)_.minimum=Z,_.exclusiveMinimum=!0;else _.exclusiveMinimum=Z;else if(typeof g==="number")_.minimum=g;if(T)if(I)_.maximum=y,_.exclusiveMaximum=!0;else _.exclusiveMaximum=y;else if(typeof x==="number")_.maximum=x;if(typeof v==="number")_.multipleOf=v},Dr=(i,f,m,h)=>{m.type="boolean"},ps=(i,f,m,h)=>{if(f.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")},ls=(i,f,m,h)=>{if(f.unrepresentable==="throw")throw Error("Symbols cannot be represented in JSON Schema")},Lr=(i,f,m,h)=>{if(f.target==="openapi-3.0")m.type="string",m.nullable=!0,m.enum=[null];else m.type="null"},fs=(i,f,m,h)=>{if(f.unrepresentable==="throw")throw Error("Undefined cannot be represented in JSON Schema")},ds=(i,f,m,h)=>{if(f.unrepresentable==="throw")throw Error("Void cannot be represented in JSON Schema")},Fr=(i,f,m,h)=>{m.not={}},Ur=(i,f,m,h)=>{},Mr=(i,f,m,h)=>{},ms=(i,f,m,h)=>{if(f.unrepresentable==="throw")throw Error("Date cannot be represented in JSON Schema")},Jr=(i,f,m,h)=>{let _=i._zod.def,g=Le(_.entries);if(g.every((x)=>typeof x==="number"))m.type="number";if(g.every((x)=>typeof x==="string"))m.type="string";m.enum=g},Br=(i,f,m,h)=>{let _=i._zod.def,g=[];for(let x of _.values)if(x===void 0){if(f.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof x==="bigint")if(f.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else g.push(Number(x));else g.push(x);if(g.length===0);else if(g.length===1){let x=g[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(g.every((x)=>typeof x==="number"))m.type="number";if(g.every((x)=>typeof x==="string"))m.type="string";if(g.every((x)=>typeof x==="boolean"))m.type="boolean";if(g.every((x)=>x===null))m.type="null";m.enum=g}},hs=(i,f,m,h)=>{if(f.unrepresentable==="throw")throw Error("NaN cannot be represented in JSON Schema")},_s=(i,f,m,h)=>{let _=m,g=i._zod.pattern;if(!g)throw Error("Pattern not found in template literal");_.type="string",_.pattern=g.source},gs=(i,f,m,h)=>{let _=m,g={type:"string",format:"binary",contentEncoding:"binary"},{minimum:x,maximum:z,mime:v}=i._zod.bag;if(x!==void 0)g.minLength=x;if(z!==void 0)g.maxLength=z;if(v)if(v.length===1)g.contentMediaType=v[0],Object.assign(_,g);else Object.assign(_,g),_.anyOf=v.map((y)=>({contentMediaType:y}));else Object.assign(_,g)},xs=(i,f,m,h)=>{m.type="boolean"},Vr=(i,f,m,h)=>{if(f.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},zs=(i,f,m,h)=>{if(f.unrepresentable==="throw")throw Error("Function types cannot be represented in JSON Schema")},Wr=(i,f,m,h)=>{if(f.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},vs=(i,f,m,h)=>{if(f.unrepresentable==="throw")throw Error("Map cannot be represented in JSON Schema")},ys=(i,f,m,h)=>{if(f.unrepresentable==="throw")throw Error("Set cannot be represented in JSON Schema")},Kr=(i,f,m,h)=>{let _=m,g=i._zod.def,{minimum:x,maximum:z}=i._zod.bag;if(typeof x==="number")_.minItems=x;if(typeof z==="number")_.maxItems=z;_.type="array",_.items=C(g.element,f,{...h,path:[...h.path,"items"]})},Gr=(i,f,m,h)=>{let _=m,g=i._zod.def;_.type="object",_.properties={};let x=g.shape;for(let y in x)_.properties[y]=C(x[y],f,{...h,path:[...h.path,"properties",y]});let z=new Set(Object.keys(x)),v=new Set([...z].filter((y)=>{let Z=g.shape[y]._zod;if(f.io==="input")return Z.optin===void 0;else return Z.optout===void 0}));if(v.size>0)_.required=Array.from(v);if(g.catchall?._zod.def.type==="never")_.additionalProperties=!1;else if(!g.catchall){if(f.io==="output")_.additionalProperties=!1}else if(g.catchall)_.additionalProperties=C(g.catchall,f,{...h,path:[...h.path,"additionalProperties"]})},qr=(i,f,m,h)=>{let _=i._zod.def,g=_.inclusive===!1,x=_.options.map((z,v)=>C(z,f,{...h,path:[...h.path,g?"oneOf":"anyOf",v]}));if(g)m.oneOf=x;else m.anyOf=x},Yr=(i,f,m,h)=>{let _=i._zod.def,g=C(_.left,f,{...h,path:[...h.path,"allOf",0]}),x=C(_.right,f,{...h,path:[...h.path,"allOf",1]}),z=(y)=>("allOf"in y)&&Object.keys(y).length===1,v=[...z(g)?g.allOf:[g],...z(x)?x.allOf:[x]];m.allOf=v},$s=(i,f,m,h)=>{let _=m,g=i._zod.def;_.type="array";let x=f.target==="draft-2020-12"?"prefixItems":"items",z=f.target==="draft-2020-12"?"items":f.target==="openapi-3.0"?"items":"additionalItems",v=g.items.map((T,I)=>C(T,f,{...h,path:[...h.path,x,I]})),y=g.rest?C(g.rest,f,{...h,path:[...h.path,z,...f.target==="openapi-3.0"?[g.items.length]:[]]}):null;if(f.target==="draft-2020-12"){if(_.prefixItems=v,y)_.items=y}else if(f.target==="openapi-3.0"){if(_.items={anyOf:v},y)_.items.anyOf.push(y);if(_.minItems=v.length,!y)_.maxItems=v.length}else if(_.items=v,y)_.additionalItems=y;let{minimum:Z,maximum:S}=i._zod.bag;if(typeof Z==="number")_.minItems=Z;if(typeof S==="number")_.maxItems=S},Xr=(i,f,m,h)=>{let _=m,g=i._zod.def;_.type="object";let x=g.keyType,v=x._zod.bag?.patterns;if(g.mode==="loose"&&v&&v.size>0){let Z=C(g.valueType,f,{...h,path:[...h.path,"patternProperties","*"]});_.patternProperties={};for(let S of v)_.patternProperties[S.source]=Z}else{if(f.target==="draft-07"||f.target==="draft-2020-12")_.propertyNames=C(g.keyType,f,{...h,path:[...h.path,"propertyNames"]});_.additionalProperties=C(g.valueType,f,{...h,path:[...h.path,"additionalProperties"]})}let y=x._zod.values;if(y){let Z=[...y].filter((S)=>typeof S==="string"||typeof S==="number");if(Z.length>0)_.required=Z}},Hr=(i,f,m,h)=>{let _=i._zod.def,g=C(_.innerType,f,h),x=f.seen.get(i);if(f.target==="openapi-3.0")x.ref=_.innerType,m.nullable=!0;else m.anyOf=[g,{type:"null"}]},Qr=(i,f,m,h)=>{let _=i._zod.def;C(_.innerType,f,h);let g=f.seen.get(i);g.ref=_.innerType},et=(i,f,m,h)=>{let _=i._zod.def;C(_.innerType,f,h);let g=f.seen.get(i);g.ref=_.innerType,m.default=JSON.parse(JSON.stringify(_.defaultValue))},rt=(i,f,m,h)=>{let _=i._zod.def;C(_.innerType,f,h);let g=f.seen.get(i);if(g.ref=_.innerType,f.io==="input")m._prefault=JSON.parse(JSON.stringify(_.defaultValue))},tt=(i,f,m,h)=>{let _=i._zod.def;C(_.innerType,f,h);let g=f.seen.get(i);g.ref=_.innerType;let x;try{x=_.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}m.default=x},ot=(i,f,m,h)=>{let _=i._zod.def,g=_.in._zod.traits.has("$ZodTransform"),x=f.io==="input"?g?_.out:_.in:_.out;C(x,f,h);let z=f.seen.get(i);z.ref=x},nt=(i,f,m,h)=>{let _=i._zod.def;C(_.innerType,f,h);let g=f.seen.get(i);g.ref=_.innerType,m.readOnly=!0},bs=(i,f,m,h)=>{let _=i._zod.def;C(_.innerType,f,h);let g=f.seen.get(i);g.ref=_.innerType},tr=(i,f,m,h)=>{let _=i._zod.def;C(_.innerType,f,h);let g=f.seen.get(i);g.ref=_.innerType},st=(i,f,m,h)=>{let _=i._zod.innerType;C(_,f,h);let g=f.seen.get(i);g.ref=_},as={string:Cr,number:Rr,boolean:Dr,bigint:ps,symbol:ls,null:Lr,undefined:fs,void:ds,never:Fr,any:Ur,unknown:Mr,date:ms,enum:Jr,literal:Br,nan:hs,template_literal:_s,file:gs,success:xs,custom:Vr,function:zs,transform:Wr,map:vs,set:ys,array:Kr,object:Gr,union:qr,intersection:Yr,tuple:$s,record:Xr,nullable:Hr,nonoptional:Qr,default:et,prefault:rt,catch:tt,pipe:ot,readonly:nt,promise:bs,optional:tr,lazy:st};function be(i,f){if("_idmap"in i){let h=i,_=Te({...f,processors:as}),g={};for(let v of h._idmap.entries()){let[y,Z]=v;C(Z,_)}let x={},z={registry:h,uri:f?.uri,defs:g};_.external=z;for(let v of h._idmap.entries()){let[y,Z]=v;Ne(_,Z),x[y]=je(_,Z)}if(Object.keys(g).length>0){let v=_.target==="draft-2020-12"?"$defs":"definitions";x.__shared={[v]:g}}return{schemas:x}}let m=Te({...f,processors:as});return C(i,m),Ne(m,i),je(m,i)}var $i=w("ZodISODateTime",(i,f)=>{Fo.init(i,f),F.init(i,f)});function D(i){return Gn($i,i)}var bi=w("ZodISODate",(i,f)=>{Uo.init(i,f),F.init(i,f)});function ve(i){return qn(bi,i)}var wi=w("ZodISOTime",(i,f)=>{Mo.init(i,f),F.init(i,f)});function ws(i){return Yn(wi,i)}var ki=w("ZodISODuration",(i,f)=>{Jo.init(i,f),F.init(i,f)});function ks(i){return Xn(ki,i)}var Si=(i,f)=>{Be.init(i,f),i.name="ZodError",Object.defineProperties(i,{format:{value:(m)=>vt(i,m)},flatten:{value:(m)=>zt(i,m)},addIssue:{value:(m)=>{i.issues.push(m),i.message=JSON.stringify(i.issues,ge,2)}},addIssues:{value:(m)=>{i.issues.push(...m),i.message=JSON.stringify(i.issues,ge,2)}},isEmpty:{get(){return i.issues.length===0}}})};var G=w("ZodError",Si,{Parent:Error});var Zs=Ve(G),Ps=We(G),ae=$e(G),Ss=we(G),Os=bt(G),Es=wt(G),Is=kt(G),Ts=Zt(G),Ns=Pt(G),As=St(G),js=Ot(G),Cs=Et(G);var Rs=new WeakMap;function Ce(i,f,m){let h=Object.getPrototypeOf(i),_=Rs.get(h);if(!_)_=new Set,Rs.set(h,_);if(_.has(f))return;_.add(f);for(let g in m){let x=m[g];Object.defineProperty(h,g,{configurable:!0,enumerable:!1,get(){let z=x.bind(this);return Object.defineProperty(this,g,{configurable:!0,writable:!0,enumerable:!0,value:z}),z},set(z){Object.defineProperty(this,g,{configurable:!0,writable:!0,enumerable:!0,value:z})}})}}var R=w("ZodType",(i,f)=>(j.init(i,f),Object.assign(i["~standard"],{jsonSchema:{input:Ee(i,"input"),output:Ee(i,"output")}}),i.toJSONSchema=us(i,{}),i.def=f,i.type=f.type,Object.defineProperty(i,"_def",{value:f}),i.parse=(m,h)=>Zs(i,m,h,{callee:i.parse}),i.safeParse=(m,h)=>ae(i,m,h),i.parseAsync=async(m,h)=>Ps(i,m,h,{callee:i.parseAsync}),i.safeParseAsync=async(m,h)=>Ss(i,m,h),i.spa=i.safeParseAsync,i.encode=(m,h)=>Os(i,m,h),i.decode=(m,h)=>Es(i,m,h),i.encodeAsync=async(m,h)=>Is(i,m,h),i.decodeAsync=async(m,h)=>Ts(i,m,h),i.safeEncode=(m,h)=>Ns(i,m,h),i.safeDecode=(m,h)=>As(i,m,h),i.safeEncodeAsync=async(m,h)=>js(i,m,h),i.safeDecodeAsync=async(m,h)=>Cs(i,m,h),Ce(i,"ZodType",{check(...m){let h=this.def;return this.clone(Q(h,{checks:[...h.checks??[],...m.map((_)=>typeof _==="function"?{_zod:{check:_,def:{check:"custom"},onattach:[]}}:_)]}),{parent:!0})},with(...m){return this.check(...m)},clone(m,h){return X(this,m,h)},brand(){return this},register(m,h){return m.add(this,h),this},refine(m,h){return this.check(zc(m,h))},superRefine(m,h){return this.check(vc(m,h))},overwrite(m){return this.check(oe(m))},optional(){return u(this)},exactOptional(){return sc(this)},nullable(){return Us(this)},nullish(){return u(Us(this))},nonoptional(m){return lc(this,m)},array(){return n(this)},or(m){return c([this,m])},and(m){return k(this,m)},transform(m){return Ms(this,Gs(m))},default(m){return uc(this,m)},prefault(m){return pc(this,m)},catch(m){return dc(this,m)},pipe(m){return Ms(this,m)},readonly(){return _c(this)},describe(m){let h=this.clone();return pe.add(h,{description:m}),h},meta(...m){if(m.length===0)return pe.get(this);let h=this.clone();return pe.add(h,m[0]),h},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(m){return m(this)}}),Object.defineProperty(i,"description",{get(){return pe.get(i)?.description},configurable:!0}),i)),Js=w("_ZodString",(i,f)=>{Ye.init(i,f),R.init(i,f),i._zod.processJSONSchema=(h,_,g)=>Cr(i,h,_,g);let m=i._zod.bag;i.format=m.format??null,i.minLength=m.minimum??null,i.maxLength=m.maximum??null,Ce(i,"_ZodString",{regex(...h){return this.check(kr(...h))},includes(...h){return this.check(Sr(...h))},startsWith(...h){return this.check(Or(...h))},endsWith(...h){return this.check(Er(...h))},min(...h){return this.check(me(...h))},max(...h){return this.check(er(...h))},length(...h){return this.check(rr(...h))},nonempty(...h){return this.check(me(1,...h))},lowercase(h){return this.check(Zr(h))},uppercase(h){return this.check(Pr(h))},trim(){return this.check(Tr())},normalize(...h){return this.check(Ir(...h))},toLowerCase(){return this.check(Nr())},toUpperCase(){return this.check(Ar())},slugify(){return this.check(jr())}})}),Ei=w("ZodString",(i,f)=>{Ye.init(i,f),Js.init(i,f),i.email=(m)=>i.check($r(Bs,m)),i.url=(m)=>i.check(wr(Vs,m)),i.jwt=(m)=>i.check(Kn(Vi,m)),i.emoji=(m)=>i.check(Nn(Ii,m)),i.guid=(m)=>i.check(br(Ds,m)),i.uuid=(m)=>i.check(On(nr,m)),i.uuidv4=(m)=>i.check(En(nr,m)),i.uuidv6=(m)=>i.check(In(nr,m)),i.uuidv7=(m)=>i.check(Tn(nr,m)),i.nanoid=(m)=>i.check(An(Ti,m)),i.guid=(m)=>i.check(br(Ds,m)),i.cuid=(m)=>i.check(jn(Ni,m)),i.cuid2=(m)=>i.check(Cn(Ai,m)),i.ulid=(m)=>i.check(Rn(ji,m)),i.base64=(m)=>i.check(Bn(Mi,m)),i.base64url=(m)=>i.check(Vn(Ji,m)),i.xid=(m)=>i.check(Dn(Ci,m)),i.ksuid=(m)=>i.check(Ln(Ri,m)),i.ipv4=(m)=>i.check(Fn(Di,m)),i.ipv6=(m)=>i.check(Un(Li,m)),i.cidrv4=(m)=>i.check(Mn(Fi,m)),i.cidrv6=(m)=>i.check(Jn(Ui,m)),i.e164=(m)=>i.check(Wn(Bi,m)),i.datetime=(m)=>i.check(D(m)),i.date=(m)=>i.check(ve(m)),i.time=(m)=>i.check(ws(m)),i.duration=(m)=>i.check(ks(m))});function e(i){return Sn(Ei,i)}var F=w("ZodStringFormat",(i,f)=>{L.init(i,f),Js.init(i,f)}),Bs=w("ZodEmail",(i,f)=>{Io.init(i,f),F.init(i,f)});function Oe(i){return $r(Bs,i)}var Ds=w("ZodGUID",(i,f)=>{Oo.init(i,f),F.init(i,f)});var nr=w("ZodUUID",(i,f)=>{Eo.init(i,f),F.init(i,f)});var Vs=w("ZodURL",(i,f)=>{To.init(i,f),F.init(i,f)});function ce(i){return wr(Vs,i)}var Ii=w("ZodEmoji",(i,f)=>{No.init(i,f),F.init(i,f)});var Ti=w("ZodNanoID",(i,f)=>{Ao.init(i,f),F.init(i,f)});var Ni=w("ZodCUID",(i,f)=>{jo.init(i,f),F.init(i,f)});var Ai=w("ZodCUID2",(i,f)=>{Co.init(i,f),F.init(i,f)});var ji=w("ZodULID",(i,f)=>{Ro.init(i,f),F.init(i,f)});var Ci=w("ZodXID",(i,f)=>{Do.init(i,f),F.init(i,f)});var Ri=w("ZodKSUID",(i,f)=>{Lo.init(i,f),F.init(i,f)});var Di=w("ZodIPv4",(i,f)=>{Bo.init(i,f),F.init(i,f)});var Li=w("ZodIPv6",(i,f)=>{Vo.init(i,f),F.init(i,f)});var Fi=w("ZodCIDRv4",(i,f)=>{Wo.init(i,f),F.init(i,f)});var Ui=w("ZodCIDRv6",(i,f)=>{Ko.init(i,f),F.init(i,f)});var Mi=w("ZodBase64",(i,f)=>{qo.init(i,f),F.init(i,f)});var Ji=w("ZodBase64URL",(i,f)=>{Yo.init(i,f),F.init(i,f)});var Bi=w("ZodE164",(i,f)=>{Xo.init(i,f),F.init(i,f)});var Vi=w("ZodJWT",(i,f)=>{Ho.init(i,f),F.init(i,f)});var le=w("ZodNumber",(i,f)=>{xr.init(i,f),R.init(i,f),i._zod.processJSONSchema=(h,_,g)=>Rr(i,h,_,g),Ce(i,"ZodNumber",{gt(h,_){return this.check(He(h,_))},gte(h,_){return this.check(Pe(h,_))},min(h,_){return this.check(Pe(h,_))},lt(h,_){return this.check(Xe(h,_))},lte(h,_){return this.check(Ze(h,_))},max(h,_){return this.check(Ze(h,_))},int(h){return this.check(Ls(h))},safe(h){return this.check(Ls(h))},positive(h){return this.check(He(0,h))},nonnegative(h){return this.check(Pe(0,h))},negative(h){return this.check(Xe(0,h))},nonpositive(h){return this.check(Ze(0,h))},multipleOf(h,_){return this.check(Qe(h,_))},step(h,_){return this.check(Qe(h,_))},finite(){return this}});let m=i._zod.bag;i.minValue=Math.max(m.minimum??Number.NEGATIVE_INFINITY,m.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,i.maxValue=Math.min(m.maximum??Number.POSITIVE_INFINITY,m.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,i.isInt=(m.format??"").includes("int")||Number.isSafeInteger(m.multipleOf??0.5),i.isFinite=!0,i.format=m.format??null});function o(i){return Hn(le,i)}var Wi=w("ZodNumberFormat",(i,f)=>{Qo.init(i,f),le.init(i,f)});function Ls(i){return Qn(Wi,i)}var Ki=w("ZodBoolean",(i,f)=>{en.init(i,f),R.init(i,f),i._zod.processJSONSchema=(m,h,_)=>Dr(i,m,h,_)});function a(i){return es(Ki,i)}var Gi=w("ZodNull",(i,f)=>{rn.init(i,f),R.init(i,f),i._zod.processJSONSchema=(m,h,_)=>Lr(i,m,h,_)});function O(i){return rs(Gi,i)}var qi=w("ZodAny",(i,f)=>{tn.init(i,f),R.init(i,f),i._zod.processJSONSchema=(m,h,_)=>Ur(i,m,h,_)});function Me(){return ts(qi)}var Yi=w("ZodUnknown",(i,f)=>{on.init(i,f),R.init(i,f),i._zod.processJSONSchema=(m,h,_)=>Mr(i,m,h,_)});function l(){return os(Yi)}var Xi=w("ZodNever",(i,f)=>{nn.init(i,f),R.init(i,f),i._zod.processJSONSchema=(m,h,_)=>Fr(i,m,h,_)});function Hi(i){return ns(Xi,i)}var Qi=w("ZodArray",(i,f)=>{sn.init(i,f),R.init(i,f),i._zod.processJSONSchema=(m,h,_)=>Kr(i,m,h,_),i.element=f.element,Ce(i,"ZodArray",{min(m,h){return this.check(me(m,h))},nonempty(m){return this.check(me(1,m))},max(m,h){return this.check(er(m,h))},length(m,h){return this.check(rr(m,h))},unwrap(){return this.element}})});function n(i,f){return ss(Qi,i,f)}var Ws=w("ZodObject",(i,f)=>{an.init(i,f),R.init(i,f),i._zod.processJSONSchema=(m,h,_)=>Gr(i,m,h,_),N(i,"shape",()=>f.shape),Ce(i,"ZodObject",{keyof(){return p(Object.keys(this._zod.def.shape))},catchall(m){return this.clone({...this._zod.def,catchall:m})},passthrough(){return this.clone({...this._zod.def,catchall:l()})},loose(){return this.clone({...this._zod.def,catchall:l()})},strict(){return this.clone({...this._zod.def,catchall:Hi()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(m){return ti(this,m)},safeExtend(m){return oi(this,m)},merge(m){return ni(this,m)},pick(m){return ei(this,m)},omit(m){return ri(this,m)},partial(...m){return si(qs,this,m[0])},required(...m){return ii(Ys,this,m[0])}})});function t(i,f){let m={type:"object",shape:i??{},...P(f)};return new Ws(m)}function d(i,f){return new Ws({type:"object",shape:i,catchall:l(),...P(f)})}var Ks=w("ZodUnion",(i,f)=>{zr.init(i,f),R.init(i,f),i._zod.processJSONSchema=(m,h,_)=>qr(i,m,h,_),i.options=f.options});function c(i,f){return new Ks({type:"union",options:i,...P(f)})}var ec=w("ZodDiscriminatedUnion",(i,f)=>{Ks.init(i,f),pn.init(i,f)});function E(i,f,m){return new ec({type:"union",options:f,discriminator:i,...P(m)})}var rc=w("ZodIntersection",(i,f)=>{ln.init(i,f),R.init(i,f),i._zod.processJSONSchema=(m,h,_)=>Yr(i,m,h,_)});function k(i,f){return new rc({type:"intersection",left:i,right:f})}var Fs=w("ZodRecord",(i,f)=>{fn.init(i,f),R.init(i,f),i._zod.processJSONSchema=(m,h,_)=>Xr(i,m,h,_),i.keyType=f.keyType,i.valueType=f.valueType});function s(i,f,m){if(!f||!f._zod)return new Fs({type:"record",keyType:e(),valueType:i,...P(f)});return new Fs({type:"record",keyType:i,valueType:f,...P(m)})}var it=w("ZodEnum",(i,f)=>{dn.init(i,f),R.init(i,f),i._zod.processJSONSchema=(h,_,g)=>Jr(i,h,_,g),i.enum=f.entries,i.options=Object.values(f.entries);let m=new Set(Object.keys(f.entries));i.extract=(h,_)=>{let g={};for(let x of h)if(m.has(x))g[x]=f.entries[x];else throw Error(`Key ${x} not found in enum`);return new it({...f,checks:[],...P(_),entries:g})},i.exclude=(h,_)=>{let g={...f.entries};for(let x of h)if(m.has(x))delete g[x];else throw Error(`Key ${x} not found in enum`);return new it({...f,checks:[],...P(_),entries:g})}});function p(i,f){let m=Array.isArray(i)?Object.fromEntries(i.map((h)=>[h,h])):i;return new it({type:"enum",entries:m,...P(f)})}var tc=w("ZodLiteral",(i,f)=>{mn.init(i,f),R.init(i,f),i._zod.processJSONSchema=(m,h,_)=>Br(i,m,h,_),i.values=new Set(f.values),Object.defineProperty(i,"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(i,f){return new tc({type:"literal",values:Array.isArray(i)?i:[i],...P(f)})}var oc=w("ZodTransform",(i,f)=>{hn.init(i,f),R.init(i,f),i._zod.processJSONSchema=(m,h,_)=>Wr(i,m,h,_),i._zod.parse=(m,h)=>{if(h.direction==="backward")throw new _e(i.constructor.name);m.addIssue=(g)=>{if(typeof g==="string")m.issues.push(ue(g,m.value,f));else{let x=g;if(x.fatal)x.continue=!1;x.code??(x.code="custom"),x.input??(x.input=m.value),x.inst??(x.inst=i),m.issues.push(ue(x))}};let _=f.transform(m.value,m);if(_ instanceof Promise)return _.then((g)=>(m.value=g,m.fallback=!0,m));return m.value=_,m.fallback=!0,m}});function Gs(i){return new oc({type:"transform",transform:i})}var qs=w("ZodOptional",(i,f)=>{vr.init(i,f),R.init(i,f),i._zod.processJSONSchema=(m,h,_)=>tr(i,m,h,_),i.unwrap=()=>i._zod.def.innerType});function u(i){return new qs({type:"optional",innerType:i})}var nc=w("ZodExactOptional",(i,f)=>{_n.init(i,f),R.init(i,f),i._zod.processJSONSchema=(m,h,_)=>tr(i,m,h,_),i.unwrap=()=>i._zod.def.innerType});function sc(i){return new nc({type:"optional",innerType:i})}var ic=w("ZodNullable",(i,f)=>{gn.init(i,f),R.init(i,f),i._zod.processJSONSchema=(m,h,_)=>Hr(i,m,h,_),i.unwrap=()=>i._zod.def.innerType});function Us(i){return new ic({type:"nullable",innerType:i})}var cc=w("ZodDefault",(i,f)=>{xn.init(i,f),R.init(i,f),i._zod.processJSONSchema=(m,h,_)=>et(i,m,h,_),i.unwrap=()=>i._zod.def.innerType,i.removeDefault=i.unwrap});function uc(i,f){return new cc({type:"default",innerType:i,get defaultValue(){return typeof f==="function"?f():ar(f)}})}var ac=w("ZodPrefault",(i,f)=>{zn.init(i,f),R.init(i,f),i._zod.processJSONSchema=(m,h,_)=>rt(i,m,h,_),i.unwrap=()=>i._zod.def.innerType});function pc(i,f){return new ac({type:"prefault",innerType:i,get defaultValue(){return typeof f==="function"?f():ar(f)}})}var Ys=w("ZodNonOptional",(i,f)=>{vn.init(i,f),R.init(i,f),i._zod.processJSONSchema=(m,h,_)=>Qr(i,m,h,_),i.unwrap=()=>i._zod.def.innerType});function lc(i,f){return new Ys({type:"nonoptional",innerType:i,...P(f)})}var fc=w("ZodCatch",(i,f)=>{yn.init(i,f),R.init(i,f),i._zod.processJSONSchema=(m,h,_)=>tt(i,m,h,_),i.unwrap=()=>i._zod.def.innerType,i.removeCatch=i.unwrap});function dc(i,f){return new fc({type:"catch",innerType:i,catchValue:typeof f==="function"?f:()=>f})}var Xs=w("ZodPipe",(i,f)=>{yr.init(i,f),R.init(i,f),i._zod.processJSONSchema=(m,h,_)=>ot(i,m,h,_),i.in=f.in,i.out=f.out});function Ms(i,f){return new Xs({type:"pipe",in:i,out:f})}var mc=w("ZodPreprocess",(i,f)=>{Xs.init(i,f),$n.init(i,f)}),hc=w("ZodReadonly",(i,f)=>{bn.init(i,f),R.init(i,f),i._zod.processJSONSchema=(m,h,_)=>nt(i,m,h,_),i.unwrap=()=>i._zod.def.innerType});function _c(i){return new hc({type:"readonly",innerType:i})}var gc=w("ZodLazy",(i,f)=>{wn.init(i,f),R.init(i,f),i._zod.processJSONSchema=(m,h,_)=>st(i,m,h,_),i.unwrap=()=>i._zod.def.getter()});function V(i){return new gc({type:"lazy",getter:i})}var xc=w("ZodCustom",(i,f)=>{kn.init(i,f),R.init(i,f),i._zod.processJSONSchema=(m,h,_)=>Vr(i,m,h,_)});function zc(i,f={}){return is(xc,i,f)}function vc(i,f){return cs(i,f)}function M(i,f){return new mc({type:"pipe",in:Gs(i),out:f})}
66
- export{Ie,b,ye,Se,xe,De,Ae,be,D,ve,ae,e,Oe,ce,le,o,a,O,Me,l,n,t,d,c,E,k,s,p,r,u,V,M};