@openai/agents-realtime
Version:
The OpenAI Agents SDK is a lightweight yet powerful framework for building multi-agent workflows. This package contains the logic for building realtime voice agents on the server or in the browser.
5 lines • 1.4 MB
JavaScript
(function(P,G){typeof exports=="object"&&typeof module<"u"?G(exports):typeof define=="function"&&define.amd?define(["exports"],G):(P=typeof globalThis<"u"?globalThis:P||self,G(P.OpenAIAgentsRealtime={}))})(this,function(P){"use strict";var Tc=Object.defineProperty;var va=P=>{throw TypeError(P)};var kc=(P,G,X)=>G in P?Tc(P,G,{enumerable:!0,configurable:!0,writable:!0,value:X}):P[G]=X;var _=(P,G,X)=>kc(P,typeof G!="symbol"?G+"":G,X),Nr=(P,G,X)=>G.has(P)||va("Cannot "+X);var u=(P,G,X)=>(Nr(P,G,"read from private field"),X?X.call(P):G.get(P)),k=(P,G,X)=>G.has(P)?va("Cannot add the same private member more than once"):G instanceof WeakSet?G.add(P):G.set(P,X),y=(P,G,X,Ot)=>(Nr(P,G,"write to private field"),Ot?Ot.call(P,X):G.set(P,X),X),F=(P,G,X)=>(Nr(P,G,"access private method"),X);var yt,Gt,vt,Vt,zt,wt,ae,Pe,Ue,Je,bt,ce,Rr,Dr,Et,pe,Wt,Ht,Yt,Xt,rt,Be,qe,st,Qt,xt,je,se,at,Un,ba,fe,Kt,St,be,Ge,en,tn,nn,rn,Tt,ie,Pr,jr,Mr,xa,Zr,it,sn,he,an,z,on,ot,un,ut,kt,ee,cn,Me,ct,dt,Jn,Sa,B,Z,dn,M,It,At,ln,Y,pn,Ct,W,Bn,qn,Ta,Gn,ka,$r,Ia;const G={version:"0.0.9"};function X(n){const e=atob(n),t=e.length,r=new Uint8Array(t);for(let s=0;s<t;s++)r[s]=e.charCodeAt(s);return r.buffer}function Ot(n){const e=String.fromCharCode(...new Uint8Array(n));return btoa(e)}function Fr(n){if(typeof n>"u"||n===null||typeof n!="object"||!("type"in n)||typeof n.type!="string"||!n.type||n.type!=="message"||!("content"in n)||!Array.isArray(n.content)||n.content.length<1)return;const e=n.content[n.content.length-1];if(!(!("type"in e)||typeof e.type!="string")){if(e.type==="text")return typeof e.text=="string"?e.text:void 0;if(e.type==="audio")return typeof e.transcript=="string"?e.transcript:void 0}}function Aa(n,e){const t=n.filter(a=>!e.some(i=>i.itemId===a.itemId)),r=e.filter(a=>!n.some(i=>i.itemId===a.itemId)),s=e.filter(a=>n.some(i=>i.itemId===a.itemId&&JSON.stringify(i)!==JSON.stringify(a)));return{removals:t,additions:r,updates:s}}function Ca(){return typeof window>"u"?!1:typeof window.RTCPeerConnection<"u"}function Lr(n){return n.role==="system"?n:n.role==="assistant"?{...n,content:n.content.map(e=>e.type==="audio"?{...e,audio:null}:e)}:n.role==="user"?{...n,content:n.content.map(e=>e.type==="input_audio"?{...e,audio:null}:e)}:n}function Ea(n,e,t){const r=!t&&e.type==="message"?Lr(e):e,s=n.findIndex(a=>a.itemId===e.itemId);if(s!==-1)return n.map((a,i)=>i===s?r:!t&&a.type==="message"?Lr(a):a);if(e.previousItemId){const a=n.findIndex(i=>i.itemId===e.previousItemId);return a!==-1?[...n.slice(0,a+1),r,...n.slice(a+1)]:[...n,r]}else return[...n,r]}const Oa={"User-Agent":`Agents/JavaScript ${G.version}`,"X-OpenAI-Agents-SDK":`openai-agents-sdk.${G.version}`},Na=`openai-agents-sdk.${G.version}`;async function Vn(n){try{return[null,await n()]}catch(e){return[e,null]}}function Ra(n,e){const t={...n};return Object.defineProperties(t,{$brand:{value:"auto-parseable-response-format",enumerable:!1},$parseRaw:{value:e,enumerable:!1}}),t}const Da=Symbol("Let zodToJsonSchema decide on which parser to use"),Ur={name:void 0,$refStrategy:"root",effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",nullableStrategy:"from-target",removeAdditionalStrategy:"passthrough",definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},Pa=n=>typeof n=="string"?{...Ur,basePath:["#"],definitions:{},name:n}:{...Ur,basePath:["#"],definitions:{},...n},zn=n=>"_def"in n?n._def:n;function ja(n){if(!n)return!0;for(const e in n)return!1;return!0}const Ma=n=>{const e=Pa(n),t=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,currentPath:t,propertyPath:void 0,seenRefs:new Set,seen:new Map(Object.entries(e.definitions).map(([r,s])=>[zn(s),{def:zn(s),path:[...e.basePath,e.definitionPath,r],jsonSchema:void 0}]))}};function Jr(n,e,t,r){r!=null&&r.errorMessages&&t&&(n.errorMessage={...n.errorMessage,[e]:t})}function V(n,e,t,r,s){n[e]=t,Jr(n,e,r,s)}var Nt;(function(n){n.assertEqual=s=>{};function e(s){}n.assertIs=e;function t(s){throw new Error}n.assertNever=t,n.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},n.getValidEnumValues=s=>{const a=n.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return n.objectValues(i)},n.objectValues=s=>n.objectKeys(s).map(function(a){return s[a]}),n.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},n.find=(s,a)=>{for(const i of s)if(a(i))return i},n.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}n.joinValues=r,n.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(Nt||(Nt={}));var Br;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Br||(Br={})),Nt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Nt.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);let qr=class wa extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(a){return a.message},r={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)r._errors.push(t(i));else{let o=r,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return s(this),r}static assert(e){if(!(e instanceof wa))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Nt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}};qr.create=n=>new qr(n);var Gr;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Gr||(Gr={}));var D;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(D||(D={}));function Za(){return{}}function $a(n,e){var r,s;const t={type:"array"};return((s=(r=n.type)==null?void 0:r._def)==null?void 0:s.typeName)!==D.ZodAny&&(t.items=J(n.type._def,{...e,currentPath:[...e.currentPath,"items"]})),n.minLength&&V(t,"minItems",n.minLength.value,n.minLength.message,e),n.maxLength&&V(t,"maxItems",n.maxLength.value,n.maxLength.message,e),n.exactLength&&(V(t,"minItems",n.exactLength.value,n.exactLength.message,e),V(t,"maxItems",n.exactLength.value,n.exactLength.message,e)),t}function Fa(n,e){const t={type:"integer",format:"int64"};if(!n.checks)return t;for(const r of n.checks)switch(r.kind){case"min":e.target==="jsonSchema7"?r.inclusive?V(t,"minimum",r.value,r.message,e):V(t,"exclusiveMinimum",r.value,r.message,e):(r.inclusive||(t.exclusiveMinimum=!0),V(t,"minimum",r.value,r.message,e));break;case"max":e.target==="jsonSchema7"?r.inclusive?V(t,"maximum",r.value,r.message,e):V(t,"exclusiveMaximum",r.value,r.message,e):(r.inclusive||(t.exclusiveMaximum=!0),V(t,"maximum",r.value,r.message,e));break;case"multipleOf":V(t,"multipleOf",r.value,r.message,e);break}return t}function La(){return{type:"boolean"}}function Ua(n,e){return J(n.type._def,e)}const Ja=(n,e)=>J(n.innerType._def,e);function Vr(n,e,t){const r=t??e.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((s,a)=>Vr(n,e,s))};switch(r){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Ba(n,e)}}const Ba=(n,e)=>{const t={type:"integer",format:"unix-time"};if(e.target==="openApi3")return t;for(const r of n.checks)switch(r.kind){case"min":V(t,"minimum",r.value,r.message,e);break;case"max":V(t,"maximum",r.value,r.message,e);break}return t};function qa(n,e){return{...J(n.innerType._def,e),default:n.defaultValue()}}function Ga(n,e,t){return e.effectStrategy==="input"?J(n.schema._def,e,t):{}}function Va(n){return{type:"string",enum:[...n.values]}}const za=n=>"type"in n&&n.type==="string"?!1:"allOf"in n;function Wa(n,e){const t=[J(n.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),J(n.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(a=>!!a);let r=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0;const s=[];return t.forEach(a=>{if(za(a))s.push(...a.allOf),a.unevaluatedProperties===void 0&&(r=void 0);else{let i=a;if("additionalProperties"in a&&a.additionalProperties===!1){const{additionalProperties:o,...c}=a;i=c}else r=void 0;s.push(i)}}),s.length?{allOf:s,...r}:void 0}function Ha(n,e){const t=typeof n.value;return t!=="bigint"&&t!=="number"&&t!=="boolean"&&t!=="string"?{type:Array.isArray(n.value)?"array":"object"}:e.target==="openApi3"?{type:t==="bigint"?"integer":t,enum:[n.value]}:{type:t==="bigint"?"integer":t,const:n.value}}let Wn;const Ve={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(Wn===void 0&&(Wn=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Wn),base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/};function zr(n,e){const t={type:"string"};function r(s){return e.patternStrategy==="escape"?Ya(s):s}if(n.checks)for(const s of n.checks)switch(s.kind){case"min":V(t,"minLength",typeof t.minLength=="number"?Math.max(t.minLength,s.value):s.value,s.message,e);break;case"max":V(t,"maxLength",typeof t.maxLength=="number"?Math.min(t.maxLength,s.value):s.value,s.message,e);break;case"email":switch(e.emailStrategy){case"format:email":ye(t,"email",s.message,e);break;case"format:idn-email":ye(t,"idn-email",s.message,e);break;case"pattern:zod":ve(t,Ve.email,s.message,e);break}break;case"url":ye(t,"uri",s.message,e);break;case"uuid":ye(t,"uuid",s.message,e);break;case"regex":ve(t,s.regex,s.message,e);break;case"cuid":ve(t,Ve.cuid,s.message,e);break;case"cuid2":ve(t,Ve.cuid2,s.message,e);break;case"startsWith":ve(t,RegExp(`^${r(s.value)}`),s.message,e);break;case"endsWith":ve(t,RegExp(`${r(s.value)}$`),s.message,e);break;case"datetime":ye(t,"date-time",s.message,e);break;case"date":ye(t,"date",s.message,e);break;case"time":ye(t,"time",s.message,e);break;case"duration":ye(t,"duration",s.message,e);break;case"length":V(t,"minLength",typeof t.minLength=="number"?Math.max(t.minLength,s.value):s.value,s.message,e),V(t,"maxLength",typeof t.maxLength=="number"?Math.min(t.maxLength,s.value):s.value,s.message,e);break;case"includes":{ve(t,RegExp(r(s.value)),s.message,e);break}case"ip":{s.version!=="v6"&&ye(t,"ipv4",s.message,e),s.version!=="v4"&&ye(t,"ipv6",s.message,e);break}case"emoji":ve(t,Ve.emoji,s.message,e);break;case"ulid":{ve(t,Ve.ulid,s.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{ye(t,"binary",s.message,e);break}case"contentEncoding:base64":{V(t,"contentEncoding","base64",s.message,e);break}case"pattern:zod":{ve(t,Ve.base64,s.message,e);break}}break}case"nanoid":ve(t,Ve.nanoid,s.message,e)}return t}const Ya=n=>Array.from(n).map(e=>/[a-zA-Z0-9]/.test(e)?e:`\\${e}`).join(""),ye=(n,e,t,r)=>{var s;n.format||(s=n.anyOf)!=null&&s.some(a=>a.format)?(n.anyOf||(n.anyOf=[]),n.format&&(n.anyOf.push({format:n.format,...n.errorMessage&&r.errorMessages&&{errorMessage:{format:n.errorMessage.format}}}),delete n.format,n.errorMessage&&(delete n.errorMessage.format,Object.keys(n.errorMessage).length===0&&delete n.errorMessage)),n.anyOf.push({format:e,...t&&r.errorMessages&&{errorMessage:{format:t}}})):V(n,"format",e,t,r)},ve=(n,e,t,r)=>{var s;n.pattern||(s=n.allOf)!=null&&s.some(a=>a.pattern)?(n.allOf||(n.allOf=[]),n.pattern&&(n.allOf.push({pattern:n.pattern,...n.errorMessage&&r.errorMessages&&{errorMessage:{pattern:n.errorMessage.pattern}}}),delete n.pattern,n.errorMessage&&(delete n.errorMessage.pattern,Object.keys(n.errorMessage).length===0&&delete n.errorMessage)),n.allOf.push({pattern:Wr(e,r),...t&&r.errorMessages&&{errorMessage:{pattern:t}}})):V(n,"pattern",Wr(e,r),t,r)},Wr=(n,e)=>{var l;const t=typeof n=="function"?n():n;if(!e.applyRegexFlags||!t.flags)return t.source;const r={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},s=r.i?t.source.toLowerCase():t.source;let a="",i=!1,o=!1,c=!1;for(let p=0;p<s.length;p++){if(i){a+=s[p],i=!1;continue}if(r.i){if(o){if(s[p].match(/[a-z]/)){c?(a+=s[p],a+=`${s[p-2]}-${s[p]}`.toUpperCase(),c=!1):s[p+1]==="-"&&((l=s[p+2])!=null&&l.match(/[a-z]/))?(a+=s[p],c=!0):a+=`${s[p]}${s[p].toUpperCase()}`;continue}}else if(s[p].match(/[a-z]/)){a+=`[${s[p]}${s[p].toUpperCase()}]`;continue}}if(r.m){if(s[p]==="^"){a+=`(^|(?<=[\r
]))`;continue}else if(s[p]==="$"){a+=`($|(?=[\r
]))`;continue}}if(r.s&&s[p]==="."){a+=o?`${s[p]}\r
`:`[${s[p]}\r
]`;continue}a+=s[p],s[p]==="\\"?i=!0:o&&s[p]==="]"?o=!1:!o&&s[p]==="["&&(o=!0)}try{const p=new RegExp(a)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return a};function Hr(n,e){var r,s,a,i;if(e.target==="openApi3"&&((r=n.keyType)==null?void 0:r._def.typeName)===D.ZodEnum)return{type:"object",required:n.keyType._def.values,properties:n.keyType._def.values.reduce((o,c)=>({...o,[c]:J(n.valueType._def,{...e,currentPath:[...e.currentPath,"properties",c]})??{}}),{}),additionalProperties:!1};const t={type:"object",additionalProperties:J(n.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??{}};if(e.target==="openApi3")return t;if(((s=n.keyType)==null?void 0:s._def.typeName)===D.ZodString&&((a=n.keyType._def.checks)!=null&&a.length)){const o=Object.entries(zr(n.keyType._def,e)).reduce((c,[l,p])=>l==="type"?c:{...c,[l]:p},{});return{...t,propertyNames:o}}else if(((i=n.keyType)==null?void 0:i._def.typeName)===D.ZodEnum)return{...t,propertyNames:{enum:n.keyType._def.values}};return t}function Xa(n,e){if(e.mapStrategy==="record")return Hr(n,e);const t=J(n.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||{},r=J(n.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||{};return{type:"array",maxItems:125,items:{type:"array",items:[t,r],minItems:2,maxItems:2}}}function Qa(n){const e=n.values,r=Object.keys(n.values).filter(a=>typeof e[e[a]]!="number").map(a=>e[a]),s=Array.from(new Set(r.map(a=>typeof a)));return{type:s.length===1?s[0]==="string"?"string":"number":["string","number"],enum:r}}function Ka(){return{not:{}}}function ei(n){return n.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}const hn={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function ti(n,e){if(e.target==="openApi3")return Yr(n,e);const t=n.options instanceof Map?Array.from(n.options.values()):n.options;if(t.every(r=>r._def.typeName in hn&&(!r._def.checks||!r._def.checks.length))){const r=t.reduce((s,a)=>{const i=hn[a._def.typeName];return i&&!s.includes(i)?[...s,i]:s},[]);return{type:r.length>1?r:r[0]}}else if(t.every(r=>r._def.typeName==="ZodLiteral"&&!r.description)){const r=t.reduce((s,a)=>{const i=typeof a._def.value;switch(i){case"string":case"number":case"boolean":return[...s,i];case"bigint":return[...s,"integer"];case"object":if(a._def.value===null)return[...s,"null"];case"symbol":case"undefined":case"function":default:return s}},[]);if(r.length===t.length){const s=r.filter((a,i,o)=>o.indexOf(a)===i);return{type:s.length>1?s:s[0],enum:t.reduce((a,i)=>a.includes(i._def.value)?a:[...a,i._def.value],[])}}}else if(t.every(r=>r._def.typeName==="ZodEnum"))return{type:"string",enum:t.reduce((r,s)=>[...r,...s._def.values.filter(a=>!r.includes(a))],[])};return Yr(n,e)}const Yr=(n,e)=>{const t=(n.options instanceof Map?Array.from(n.options.values()):n.options).map((r,s)=>J(r._def,{...e,currentPath:[...e.currentPath,"anyOf",`${s}`]})).filter(r=>!!r&&(!e.strictUnions||typeof r=="object"&&Object.keys(r).length>0));return t.length?{anyOf:t}:void 0};function ni(n,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(n.innerType._def.typeName)&&(!n.innerType._def.checks||!n.innerType._def.checks.length))return e.target==="openApi3"||e.nullableStrategy==="property"?{type:hn[n.innerType._def.typeName],nullable:!0}:{type:[hn[n.innerType._def.typeName],"null"]};if(e.target==="openApi3"){const r=J(n.innerType._def,{...e,currentPath:[...e.currentPath]});return r&&"$ref"in r?{allOf:[r],nullable:!0}:r&&{...r,nullable:!0}}const t=J(n.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return t&&{anyOf:[t,{type:"null"}]}}function ri(n,e){const t={type:"number"};if(!n.checks)return t;for(const r of n.checks)switch(r.kind){case"int":t.type="integer",Jr(t,"type",r.message,e);break;case"min":e.target==="jsonSchema7"?r.inclusive?V(t,"minimum",r.value,r.message,e):V(t,"exclusiveMinimum",r.value,r.message,e):(r.inclusive||(t.exclusiveMinimum=!0),V(t,"minimum",r.value,r.message,e));break;case"max":e.target==="jsonSchema7"?r.inclusive?V(t,"maximum",r.value,r.message,e):V(t,"exclusiveMaximum",r.value,r.message,e):(r.inclusive||(t.exclusiveMaximum=!0),V(t,"maximum",r.value,r.message,e));break;case"multipleOf":V(t,"multipleOf",r.value,r.message,e);break}return t}function si(n,e){return e.removeAdditionalStrategy==="strict"?n.catchall._def.typeName==="ZodNever"?n.unknownKeys!=="strict":J(n.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??!0:n.catchall._def.typeName==="ZodNever"?n.unknownKeys==="passthrough":J(n.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??!0}function ai(n,e){const t={type:"object",...Object.entries(n.shape()).reduce((r,[s,a])=>{var c;if(a===void 0||a._def===void 0)return r;const i=[...e.currentPath,"properties",s],o=J(a._def,{...e,currentPath:i,propertyPath:i});if(o===void 0)return r;if(e.openaiStrictMode&&a.isOptional()&&!a.isNullable()&&typeof((c=a._def)==null?void 0:c.defaultValue)>"u")throw new Error(`Zod field at \`${i.join("/")}\` uses \`.optional()\` without \`.nullable()\` which is not supported by the API. See: https://platform.openai.com/docs/guides/structured-outputs?api-mode=responses#all-fields-must-be-required`);return{properties:{...r.properties,[s]:o},required:a.isOptional()&&!e.openaiStrictMode?r.required:[...r.required,s]}},{properties:{},required:[]}),additionalProperties:si(n,e)};return t.required.length||delete t.required,t}const ii=(n,e)=>{var r;if(e.currentPath.toString()===((r=e.propertyPath)==null?void 0:r.toString()))return J(n.innerType._def,e);const t=J(n.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return t?{anyOf:[{not:{}},t]}:{}},oi=(n,e)=>{if(e.pipeStrategy==="input")return J(n.in._def,e);if(e.pipeStrategy==="output")return J(n.out._def,e);const t=J(n.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),r=J(n.out._def,{...e,currentPath:[...e.currentPath,"allOf",t?"1":"0"]});return{allOf:[t,r].filter(s=>s!==void 0)}};function ui(n,e){return J(n.type._def,e)}function ci(n,e){const r={type:"array",uniqueItems:!0,items:J(n.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return n.minSize&&V(r,"minItems",n.minSize.value,n.minSize.message,e),n.maxSize&&V(r,"maxItems",n.maxSize.value,n.maxSize.message,e),r}function di(n,e){return n.rest?{type:"array",minItems:n.items.length,items:n.items.map((t,r)=>J(t._def,{...e,currentPath:[...e.currentPath,"items",`${r}`]})).reduce((t,r)=>r===void 0?t:[...t,r],[]),additionalItems:J(n.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:n.items.length,maxItems:n.items.length,items:n.items.map((t,r)=>J(t._def,{...e,currentPath:[...e.currentPath,"items",`${r}`]})).reduce((t,r)=>r===void 0?t:[...t,r],[])}}function li(){return{not:{}}}function pi(){return{}}const fi=(n,e)=>J(n.innerType._def,e);function J(n,e,t=!1){var i;const r=e.seen.get(n);if(e.override){const o=(i=e.override)==null?void 0:i.call(e,n,e,r,t);if(o!==Da)return o}if(r&&!t){const o=hi(r,e);if(o!==void 0)return"$ref"in o&&e.seenRefs.add(o.$ref),o}const s={def:n,path:e.currentPath,jsonSchema:void 0};e.seen.set(n,s);const a=gi(n,n.typeName,e,t);return a&&_i(n,e,a),s.jsonSchema=a,a}const hi=(n,e)=>{switch(e.$refStrategy){case"root":return{$ref:n.path.join("/")};case"extract-to-root":const t=n.path.slice(e.basePath.length+1).join("_");return t!==e.name&&e.nameStrategy==="duplicate-ref"&&(e.definitions[t]=n.def),{$ref:[...e.basePath,e.definitionPath,t].join("/")};case"relative":return{$ref:mi(e.currentPath,n.path)};case"none":case"seen":return n.path.length<e.currentPath.length&&n.path.every((r,s)=>e.currentPath[s]===r)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),{}):e.$refStrategy==="seen"?{}:void 0}},mi=(n,e)=>{let t=0;for(;t<n.length&&t<e.length&&n[t]===e[t];t++);return[(n.length-t).toString(),...e.slice(t)].join("/")},gi=(n,e,t,r)=>{switch(e){case D.ZodString:return zr(n,t);case D.ZodNumber:return ri(n,t);case D.ZodObject:return ai(n,t);case D.ZodBigInt:return Fa(n,t);case D.ZodBoolean:return La();case D.ZodDate:return Vr(n,t);case D.ZodUndefined:return li();case D.ZodNull:return ei(t);case D.ZodArray:return $a(n,t);case D.ZodUnion:case D.ZodDiscriminatedUnion:return ti(n,t);case D.ZodIntersection:return Wa(n,t);case D.ZodTuple:return di(n,t);case D.ZodRecord:return Hr(n,t);case D.ZodLiteral:return Ha(n,t);case D.ZodEnum:return Va(n);case D.ZodNativeEnum:return Qa(n);case D.ZodNullable:return ni(n,t);case D.ZodOptional:return ii(n,t);case D.ZodMap:return Xa(n,t);case D.ZodSet:return ci(n,t);case D.ZodLazy:return J(n.getter()._def,t);case D.ZodPromise:return ui(n,t);case D.ZodNaN:case D.ZodNever:return Ka();case D.ZodEffects:return Ga(n,t,r);case D.ZodAny:return Za();case D.ZodUnknown:return pi();case D.ZodDefault:return qa(n,t);case D.ZodBranded:return Ua(n,t);case D.ZodReadonly:return fi(n,t);case D.ZodCatch:return Ja(n,t);case D.ZodPipeline:return oi(n,t);case D.ZodFunction:case D.ZodVoid:case D.ZodSymbol:return;default:return(s=>{})()}},_i=(n,e,t)=>(n.description&&(t.description=n.description,e.markdownDescription&&(t.markdownDescription=n.description)),t),yi=(n,e)=>{const t=Ma(e),r=typeof e=="string"?e:(e==null?void 0:e.nameStrategy)==="title"||e==null?void 0:e.name,s=J(n._def,r===void 0?t:{...t,currentPath:[...t.basePath,t.definitionPath,r]},!1)??{},a=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;a!==void 0&&(s.title=a);const i=(()=>{if(ja(t.definitions))return;const c={},l=new Set;for(let p=0;p<500;p++){const f=Object.entries(t.definitions).filter(([h])=>!l.has(h));if(f.length===0)break;for(const[h,S]of f)c[h]=J(zn(S),{...t,currentPath:[...t.basePath,t.definitionPath,h]},!0)??{},l.add(h)}return c})(),o=r===void 0?i?{...s,[t.definitionPath]:i}:s:t.nameStrategy==="duplicate-ref"?{...s,...i||t.seenRefs.size?{[t.definitionPath]:{...i,...t.seenRefs.size?{[r]:s}:void 0}}:void 0}:{$ref:[...t.$refStrategy==="relative"?[]:t.basePath,t.definitionPath,r].join("/"),[t.definitionPath]:{...i,[r]:s}};return t.target==="jsonSchema7"?o.$schema="http://json-schema.org/draft-07/schema#":t.target==="jsonSchema2019-09"&&(o.$schema="https://json-schema.org/draft/2019-09/schema#"),o};function vi(n,{parser:e,callback:t}){const r={...n};return Object.defineProperties(r,{$brand:{value:"auto-parseable-tool",enumerable:!1},$parseRaw:{value:e,enumerable:!1},$callback:{value:t,enumerable:!1}}),r}function Xr(n,e){return yi(n,{openaiStrictMode:!0,name:e.name,nameStrategy:"duplicate-ref",$refStrategy:"extract-to-root",nullableStrategy:"property"})}function wi(n,e,t){return Ra({type:"json_schema",...t,name:e,strict:!0,schema:Xr(n,{name:e})},r=>n.parse(JSON.parse(r)))}function bi(n){return vi({type:"function",name:n.name,parameters:Xr(n.parameters,{name:n.name}),strict:!0},{callback:n.function,parser:e=>n.parameters.parse(JSON.parse(e))})}class Ze extends Error{constructor(t,r){super(t);_(this,"state");this.state=r}}class xi extends Ze{}class Qr extends Ze{}class de extends Ze{}class K extends Ze{}class Kr extends Ze{constructor(t,r,s){super(t,s);_(this,"error");this.error=r}}class Si extends Ze{constructor(t,r,s){super(t,s);_(this,"error");this.error=r}}class es extends Ze{constructor(t,r,s){super(t,s);_(this,"result");this.result=r}}class mn extends Ze{constructor(t,r,s){super(t,s);_(this,"result");this.result=r}}function ze(n){return typeof n=="object"&&n!==null&&"_def"in n&&typeof n._def=="object"&&n._def!==null&&"typeName"in n._def&&n._def.typeName==="ZodObject"}function Ti(n){return typeof n=="object"&&n!==null&&"input"in n&&typeof n.input=="string"}function gn(n){if(n=n.replace(/\s/g,"_"),n=n.replace(/[^a-zA-Z0-9]/g,"_"),n.length===0)throw new Error("Tool name cannot be empty");return n}function Hn(n,e){const t=r=>JSON.parse(r);if(ze(n)){const r=bi({name:e,parameters:n,function:()=>{}});return{schema:r.parameters,parser:r.$parseRaw}}else if(typeof n=="object"&&n!==null)return{schema:n,parser:t};throw new K("Input type is not a ZodObject or a valid JSON schema")}function ts(n){if(n==="text")return"text";if(ze(n)){const e=wi(n,"output");return{type:e.type,name:e.name,strict:e.strict||!1,schema:e.schema}}return n}function ki(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var _n={exports:{}},Yn,ns;function Ii(){if(ns)return Yn;ns=1;var n=1e3,e=n*60,t=e*60,r=t*24,s=r*7,a=r*365.25;Yn=function(p,f){f=f||{};var h=typeof p;if(h==="string"&&p.length>0)return i(p);if(h==="number"&&isFinite(p))return f.long?c(p):o(p);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(p))};function i(p){if(p=String(p),!(p.length>100)){var f=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(p);if(f){var h=parseFloat(f[1]),S=(f[2]||"ms").toLowerCase();switch(S){case"years":case"year":case"yrs":case"yr":case"y":return h*a;case"weeks":case"week":case"w":return h*s;case"days":case"day":case"d":return h*r;case"hours":case"hour":case"hrs":case"hr":case"h":return h*t;case"minutes":case"minute":case"mins":case"min":case"m":return h*e;case"seconds":case"second":case"secs":case"sec":case"s":return h*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return h;default:return}}}}function o(p){var f=Math.abs(p);return f>=r?Math.round(p/r)+"d":f>=t?Math.round(p/t)+"h":f>=e?Math.round(p/e)+"m":f>=n?Math.round(p/n)+"s":p+"ms"}function c(p){var f=Math.abs(p);return f>=r?l(p,f,r,"day"):f>=t?l(p,f,t,"hour"):f>=e?l(p,f,e,"minute"):f>=n?l(p,f,n,"second"):p+" ms"}function l(p,f,h,S){var b=f>=h*1.5;return Math.round(p/h)+" "+S+(b?"s":"")}return Yn}var Xn,rs;function Ai(){if(rs)return Xn;rs=1;function n(e){r.debug=r,r.default=r,r.coerce=l,r.disable=o,r.enable=a,r.enabled=c,r.humanize=Ii(),r.destroy=p,Object.keys(e).forEach(f=>{r[f]=e[f]}),r.names=[],r.skips=[],r.formatters={};function t(f){let h=0;for(let S=0;S<f.length;S++)h=(h<<5)-h+f.charCodeAt(S),h|=0;return r.colors[Math.abs(h)%r.colors.length]}r.selectColor=t;function r(f){let h,S=null,b,w;function E(...R){if(!E.enabled)return;const H=E,te=Number(new Date),me=te-(h||te);H.diff=me,H.prev=h,H.curr=te,h=te,R[0]=r.coerce(R[0]),typeof R[0]!="string"&&R.unshift("%O");let ge=0;R[0]=R[0].replace(/%([a-zA-Z%])/g,(Or,xc)=>{if(Or==="%%")return"%";ge++;const ya=r.formatters[xc];if(typeof ya=="function"){const Sc=R[ge];Or=ya.call(H,Sc),R.splice(ge,1),ge--}return Or}),r.formatArgs.call(H,R),(H.log||r.log).apply(H,R)}return E.namespace=f,E.useColors=r.useColors(),E.color=r.selectColor(f),E.extend=s,E.destroy=r.destroy,Object.defineProperty(E,"enabled",{enumerable:!0,configurable:!1,get:()=>S!==null?S:(b!==r.namespaces&&(b=r.namespaces,w=r.enabled(f)),w),set:R=>{S=R}}),typeof r.init=="function"&&r.init(E),E}function s(f,h){const S=r(this.namespace+(typeof h>"u"?":":h)+f);return S.log=this.log,S}function a(f){r.save(f),r.namespaces=f,r.names=[],r.skips=[];const h=(typeof f=="string"?f:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const S of h)S[0]==="-"?r.skips.push(S.slice(1)):r.names.push(S)}function i(f,h){let S=0,b=0,w=-1,E=0;for(;S<f.length;)if(b<h.length&&(h[b]===f[S]||h[b]==="*"))h[b]==="*"?(w=b,E=S,b++):(S++,b++);else if(w!==-1)b=w+1,E++,S=E;else return!1;for(;b<h.length&&h[b]==="*";)b++;return b===h.length}function o(){const f=[...r.names,...r.skips.map(h=>"-"+h)].join(",");return r.enable(""),f}function c(f){for(const h of r.skips)if(i(f,h))return!1;for(const h of r.names)if(i(f,h))return!0;return!1}function l(f){return f instanceof Error?f.stack||f.message:f}function p(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}return Xn=n,Xn}var ss;function Ci(){return ss||(ss=1,function(n,e){e.formatArgs=r,e.save=s,e.load=a,e.useColors=t,e.storage=i(),e.destroy=(()=>{let c=!1;return()=>{c||(c=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function t(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let c;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(c=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(c[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+n.exports.humanize(this.diff),!this.useColors)return;const l="color: "+this.color;c.splice(1,0,l,"color: inherit");let p=0,f=0;c[0].replace(/%[a-zA-Z%]/g,h=>{h!=="%%"&&(p++,h==="%c"&&(f=p))}),c.splice(f,0,l)}e.log=console.debug||console.log||(()=>{});function s(c){try{c?e.storage.setItem("debug",c):e.storage.removeItem("debug")}catch{}}function a(){let c;try{c=e.storage.getItem("debug")||e.storage.getItem("DEBUG")}catch{}return!c&&typeof process<"u"&&"env"in process&&(c=process.env.DEBUG),c}function i(){try{return localStorage}catch{}}n.exports=Ai()(e);const{formatters:o}=n.exports;o.j=function(c){try{return JSON.stringify(c)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}}(_n,_n.exports)),_n.exports}var Ei=Ci();const Oi=ki(Ei);function Ni(){return fo()}function as(n){const e=Ni();return typeof e<"u"&&(e[n]==="true"||e[n]==="1")}const is={get disabled(){return!0}},os={get dontLogModelData(){return as("OPENAI_AGENTS_DONT_LOG_MODEL_DATA")},get dontLogToolData(){return as("OPENAI_AGENTS_DONT_LOG_TOOL_DATA")}},Ri=os.dontLogModelData,Di=os.dontLogToolData;function us(n="openai-agents"){return{namespace:n,debug:Oi(n),error:console.error,warn:console.warn,dontLogModelData:Ri,dontLogToolData:Di}}const C=us("openai-agents:core");function We(n){if(n==null)return String(n);if(typeof n=="string")return n;if(typeof n=="object")try{return JSON.stringify(n)}catch{return"[object with circular references]"}return String(n)}function Pi(n,e){return`An error occurred while running the tool. Please try again. Error: ${e instanceof Error?e.toString():String(e)}`}function yn(n){const e=n.name?gn(n.name):gn(n.execute.name),t=typeof n.errorFunction>"u"?Pi:n.errorFunction;if(!e)throw new Error("Tool name cannot be empty. Either name your function or provide a name in the options.");const r=n.strict??!0;if(!r&&ze(n.parameters))throw new K("Strict mode is required for Zod parameters");const{parser:s,schema:a}=Hn(n.parameters,e);async function i(l,p){const[f,h]=await Vn(()=>s(p));if(f!==null)throw C.dontLogToolData?C.debug(`Invalid JSON input for tool ${e}`):C.debug(`Invalid JSON input for tool ${e}: ${p}`),new de("Invalid JSON input for tool");C.dontLogToolData?C.debug(`Invoking tool ${e}`):C.debug(`Invoking tool ${e} with input ${p}`);const S=await n.execute(h,l),b=We(S);return C.dontLogToolData?C.debug(`Tool ${e} completed`):C.debug(`Tool ${e} returned: ${b}`),S}async function o(l,p){return i(l,p).catch(f=>{if(t){const h=Zt();return h==null||h.setError({message:"Error running tool (non-fatal)",data:{tool_name:e,error:f.toString()}}),t(l,f)}throw f})}const c=typeof n.needsApproval=="function"?n.needsApproval:async()=>typeof n.needsApproval=="boolean"?n.needsApproval:!1;return{type:"function",name:e,description:n.description,parameters:a,strict:r,invoke:o,needsApproval:c}}var L;(function(n){n.assertEqual=s=>{};function e(s){}n.assertIs=e;function t(s){throw new Error}n.assertNever=t,n.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},n.getValidEnumValues=s=>{const a=n.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return n.objectValues(i)},n.objectValues=s=>n.objectKeys(s).map(function(a){return s[a]}),n.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},n.find=(s,a)=>{for(const i of s)if(a(i))return i},n.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}n.joinValues=r,n.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(L||(L={}));var cs;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(cs||(cs={}));const T=L.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),$e=n=>{switch(typeof n){case"undefined":return T.undefined;case"string":return T.string;case"number":return Number.isNaN(n)?T.nan:T.number;case"boolean":return T.boolean;case"function":return T.function;case"bigint":return T.bigint;case"symbol":return T.symbol;case"object":return Array.isArray(n)?T.array:n===null?T.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?T.promise:typeof Map<"u"&&n instanceof Map?T.map:typeof Set<"u"&&n instanceof Set?T.set:typeof Date<"u"&&n instanceof Date?T.date:T.object;default:return T.unknown}},v=L.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Ce extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(a){return a.message},r={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)r._errors.push(t(i));else{let o=r,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return s(this),r}static assert(e){if(!(e instanceof Ce))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,L.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}Ce.create=n=>new Ce(n);const Qn=(n,e)=>{let t;switch(n.code){case v.invalid_type:n.received===T.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case v.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,L.jsonStringifyReplacer)}`;break;case v.unrecognized_keys:t=`Unrecognized key(s) in object: ${L.joinValues(n.keys,", ")}`;break;case v.invalid_union:t="Invalid input";break;case v.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${L.joinValues(n.options)}`;break;case v.invalid_enum_value:t=`Invalid enum value. Expected ${L.joinValues(n.options)}, received '${n.received}'`;break;case v.invalid_arguments:t="Invalid function arguments";break;case v.invalid_return_type:t="Invalid function return type";break;case v.invalid_date:t="Invalid date";break;case v.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:L.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case v.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case v.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case v.custom:t="Invalid input";break;case v.invalid_intersection_types:t="Intersection results could not be merged";break;case v.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case v.not_finite:t="Number must be finite";break;default:t=e.defaultError,L.assertNever(n)}return{message:t}};let ji=Qn;function Mi(){return ji}const Zi=n=>{const{data:e,path:t,errorMaps:r,issueData:s}=n,a=[...t,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let o="";const c=r.filter(l=>!!l).slice().reverse();for(const l of c)o=l(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}};function x(n,e){const t=Mi(),r=Zi({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===Qn?void 0:Qn].filter(s=>!!s)});n.common.issues.push(r)}class oe{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const s of t){if(s.status==="aborted")return O;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const s of t){const a=await s.key,i=await s.value;r.push({key:a,value:i})}return oe.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const s of t){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return O;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(r[a.value]=i.value)}return{status:e.value,value:r}}}const O=Object.freeze({status:"aborted"}),Rt=n=>({status:"dirty",value:n}),_e=n=>({status:"valid",value:n}),ds=n=>n.status==="aborted",ls=n=>n.status==="dirty",lt=n=>n.status==="valid",vn=n=>typeof Promise<"u"&&n instanceof Promise;var I;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(I||(I={}));class xe{constructor(e,t,r,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const ps=(n,e)=>{if(lt(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Ce(n.common.issues);return this._error=t,this._error}}};function j(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:s}=n;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,o)=>{const{message:c}=n;return i.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??r??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:c??t??o.defaultError}},description:s}}class ${get description(){return this._def.description}_getType(e){return $e(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:$e(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new oe,ctx:{common:e.parent.common,data:e.data,parsedType:$e(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(vn(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){const r={common:{issues:[],async:(t==null?void 0:t.async)??!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$e(e)},s=this._parseSync({data:e,path:r.path,parent:r});return ps(r,s)}"~validate"(e){var r,s;const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$e(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:t});return lt(a)?{value:a.value}:{issues:t.common.issues}}catch(a){(s=(r=a==null?void 0:a.message)==null?void 0:r.toLowerCase())!=null&&s.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(a=>lt(a)?{value:a.value}:{issues:t.common.issues})}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$e(e)},s=this._parse({data:e,path:r.path,parent:r}),a=await(vn(s)?s:Promise.resolve(s));return ps(r,a)}refine(e,t){const r=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue({code:v.custom,...r(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof t=="function"?t(r,s):t),!1))}_refinement(e){return new Xe({schema:this,typeName:N.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return Ne.create(this,this._def)}nullable(){return Qe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Se.create(this)}promise(){return In.create(this,this._def)}or(e){return bn.create([this,e],this._def)}and(e){return xn.create(this,e,this._def)}transform(e){return new Xe({...j(this._def),schema:this,typeName:N.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new An({...j(this._def),innerType:this,defaultValue:t,typeName:N.ZodDefault})}brand(){return new bs({typeName:N.ZodBranded,type:this,...j(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Cn({...j(this._def),innerType:this,catchValue:t,typeName:N.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return or.create(this,e)}readonly(){return En.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const $i=/^c[^\s-]{8,}$/i,Fi=/^[0-9a-z]+$/,Li=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ui=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Ji=/^[a-z0-9_-]{21}$/i,Bi=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,qi=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Gi=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Vi="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Kn;const zi=/^(?:(?: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])$/,Wi=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,Hi=/^(([0-9a-fA-F]{1,4}:){7,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-