@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.42 MB
JavaScript
(function(M,G){typeof exports=="object"&&typeof module<"u"?G(exports):typeof define=="function"&&define.amd?define(["exports"],G):(M=typeof globalThis<"u"?globalThis:M||self,G(M.OpenAIAgentsRealtime={}))})(this,function(M){"use strict";var Oc=Object.defineProperty;var Ia=M=>{throw TypeError(M)};var Nc=(M,G,X)=>G in M?Oc(M,G,{enumerable:!0,configurable:!0,writable:!0,value:X}):M[G]=X;var _=(M,G,X)=>Nc(M,typeof G!="symbol"?G+"":G,X),Pr=(M,G,X)=>G.has(M)||Ia("Cannot "+X);var u=(M,G,X)=>(Pr(M,G,"read from private field"),X?X.call(M):G.get(M)),T=(M,G,X)=>G.has(M)?Ia("Cannot add the same private member more than once"):G instanceof WeakSet?G.add(M):G.set(M,X),y=(M,G,X,Pt)=>(Pr(M,G,"write to private field"),Pt?Pt.call(M,X):G.set(M,X),X),L=(M,G,X)=>(Pr(M,G,"access private method"),X);var wt,Ht,bt,Yt,Xt,xt,ae,Me,Je,Be,St,ce,Mr,jr,Dt,pe,Qt,Kt,en,tn,at,qe,Ge,it,nn,Tt,je,se,ot,qn,Ca,fe,rn,kt,xe,Ve,It,sn,an,on,At,ie,Zr,$r,Lr,Ea,Fr,ut,un,he,cn,dn,z,ln,ct,pn,dt,lt,te,fn,Ze,pt,ft,Gn,Oa,B,Z,hn,P,Et,Ot,mn,W,Nt,Rt,Ee,H,Vn,zn,Na,Wn,Ra,Ur,Da;const G={version:"0.0.14"};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 Pt(n){const e=String.fromCharCode(...new Uint8Array(n));return btoa(e)}function Jr(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 Pa(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 Ma(){return typeof window>"u"?!1:typeof window.RTCPeerConnection<"u"}function Br(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 qr(n,e,t){if(e.type==="conversation.item.input_audio_transcription.completed")return n.map(a=>{if(a.itemId===e.item_id&&a.type==="message"&&"role"in a&&a.role==="user"){const i=a.content.map(o=>o.type==="input_audio"?{...o,transcript:e.transcript}:o);return{...a,content:i,status:"completed"}}return a});const r=!t&&e.type==="message"?Br(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"?Br(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 ja={"User-Agent":`Agents/JavaScript ${G.version}`,"X-OpenAI-Agents-SDK":`openai-agents-sdk.${G.version}`},Za=`openai-agents-sdk.${G.version}`;async function Hn(n){try{return[null,await n()]}catch(e){return[e,null]}}function $a(n,e){const t={...n};return Object.defineProperties(t,{$brand:{value:"auto-parseable-response-format",enumerable:!1},$parseRaw:{value:e,enumerable:!1}}),t}const La=Symbol("Let zodToJsonSchema decide on which parser to use"),Gr={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"},Fa=n=>typeof n=="string"?{...Gr,basePath:["#"],definitions:{},name:n}:{...Gr,basePath:["#"],definitions:{},...n},Yn=n=>"_def"in n?n._def:n;function Ua(n){if(!n)return!0;for(const e in n)return!1;return!0}const Ja=n=>{const e=Fa(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])=>[Yn(s),{def:Yn(s),path:[...e.basePath,e.definitionPath,r],jsonSchema:void 0}]))}};function Vr(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,Vr(n,e,r,s)}var Mt;(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})(Mt||(Mt={}));var zr;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(zr||(zr={})),Mt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Mt.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 Wr=class Aa 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,l=0;for(;l<i.path.length;){const c=i.path[l];l===i.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(t(i))):o[c]=o[c]||{_errors:[]},o=o[c],l++}}};return s(this),r}static assert(e){if(!(e instanceof Aa))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Mt.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()}};Wr.create=n=>new Wr(n);var Hr;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Hr||(Hr={}));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 Ba(){return{}}function qa(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 Ga(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 Va(){return{type:"boolean"}}function za(n,e){return J(n.type._def,e)}const Wa=(n,e)=>J(n.innerType._def,e);function Yr(n,e,t){const r=t??e.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((s,a)=>Yr(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 Ha(n,e)}}const Ha=(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 Ya(n,e){return{...J(n.innerType._def,e),default:n.defaultValue()}}function Xa(n,e,t){return e.effectStrategy==="input"?J(n.schema._def,e,t):{}}function Qa(n){return{type:"string",enum:[...n.values]}}const Ka=n=>"type"in n&&n.type==="string"?!1:"allOf"in n;function ei(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(Ka(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,...l}=a;i=l}else r=void 0;s.push(i)}}),s.length?{allOf:s,...r}:void 0}function ti(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 Xn;const ze={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:()=>(Xn===void 0&&(Xn=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Xn),base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/};function Xr(n,e){const t={type:"string"};function r(s){return e.patternStrategy==="escape"?ni(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,ze.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,ze.cuid,s.message,e);break;case"cuid2":ve(t,ze.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,ze.emoji,s.message,e);break;case"ulid":{ve(t,ze.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,ze.base64,s.message,e);break}}break}case"nanoid":ve(t,ze.nanoid,s.message,e)}return t}const ni=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:Qr(e,r),...t&&r.errorMessages&&{errorMessage:{pattern:t}}})):V(n,"pattern",Qr(e,r),t,r)},Qr=(n,e)=>{var c;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,l=!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]/)){l?(a+=s[p],a+=`${s[p-2]}-${s[p]}`.toUpperCase(),l=!1):s[p+1]==="-"&&((c=s[p+2])!=null&&c.match(/[a-z]/))?(a+=s[p],l=!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 Kr(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,l)=>({...o,[l]:J(n.valueType._def,{...e,currentPath:[...e.currentPath,"properties",l]})??{}}),{}),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(Xr(n.keyType._def,e)).reduce((l,[c,p])=>c==="type"?l:{...l,[c]: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 ri(n,e){if(e.mapStrategy==="record")return Kr(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 si(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 ai(){return{not:{}}}function ii(n){return n.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}const _n={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function oi(n,e){if(e.target==="openApi3")return es(n,e);const t=n.options instanceof Map?Array.from(n.options.values()):n.options;if(t.every(r=>r._def.typeName in _n&&(!r._def.checks||!r._def.checks.length))){const r=t.reduce((s,a)=>{const i=_n[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 es(n,e)}const es=(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 ui(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:_n[n.innerType._def.typeName],nullable:!0}:{type:[_n[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 ci(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",Vr(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 di(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 li(n,e){const t={type:"object",...Object.entries(n.shape()).reduce((r,[s,a])=>{var l;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((l=a._def)==null?void 0:l.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:di(n,e)};return t.required.length||delete t.required,t}const pi=(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]}:{}},fi=(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 hi(n,e){return J(n.type._def,e)}function mi(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 gi(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 _i(){return{not:{}}}function yi(){return{}}const vi=(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!==La)return o}if(r&&!t){const o=wi(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=xi(n,n.typeName,e,t);return a&&Si(n,e,a),s.jsonSchema=a,a}const wi=(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:bi(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}},bi=(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("/")},xi=(n,e,t,r)=>{switch(e){case D.ZodString:return Xr(n,t);case D.ZodNumber:return ci(n,t);case D.ZodObject:return li(n,t);case D.ZodBigInt:return Ga(n,t);case D.ZodBoolean:return Va();case D.ZodDate:return Yr(n,t);case D.ZodUndefined:return _i();case D.ZodNull:return ii(t);case D.ZodArray:return qa(n,t);case D.ZodUnion:case D.ZodDiscriminatedUnion:return oi(n,t);case D.ZodIntersection:return ei(n,t);case D.ZodTuple:return gi(n,t);case D.ZodRecord:return Kr(n,t);case D.ZodLiteral:return ti(n,t);case D.ZodEnum:return Qa(n);case D.ZodNativeEnum:return si(n);case D.ZodNullable:return ui(n,t);case D.ZodOptional:return pi(n,t);case D.ZodMap:return ri(n,t);case D.ZodSet:return mi(n,t);case D.ZodLazy:return J(n.getter()._def,t);case D.ZodPromise:return hi(n,t);case D.ZodNaN:case D.ZodNever:return ai();case D.ZodEffects:return Xa(n,t,r);case D.ZodAny:return Ba();case D.ZodUnknown:return yi();case D.ZodDefault:return Ya(n,t);case D.ZodBranded:return za(n,t);case D.ZodReadonly:return vi(n,t);case D.ZodCatch:return Wa(n,t);case D.ZodPipeline:return fi(n,t);case D.ZodFunction:case D.ZodVoid:case D.ZodSymbol:return;default:return(s=>{})()}},Si=(n,e,t)=>(n.description&&(t.description=n.description,e.markdownDescription&&(t.markdownDescription=n.description)),t),Ti=(n,e)=>{const t=Ja(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(Ua(t.definitions))return;const l={},c=new Set;for(let p=0;p<500;p++){const f=Object.entries(t.definitions).filter(([h])=>!c.has(h));if(f.length===0)break;for(const[h,x]of f)l[h]=J(Yn(x),{...t,currentPath:[...t.basePath,t.definitionPath,h]},!0)??{},c.add(h)}return l})(),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 ki(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 ts(n,e){return Ti(n,{openaiStrictMode:!0,name:e.name,nameStrategy:"duplicate-ref",$refStrategy:"extract-to-root",nullableStrategy:"property"})}function Ii(n,e,t){return $a({type:"json_schema",...t,name:e,strict:!0,schema:ts(n,{name:e})},r=>n.parse(JSON.parse(r)))}function Ai(n){return ki({type:"function",name:n.name,parameters:ts(n.parameters,{name:n.name}),strict:!0},{callback:n.function,parser:e=>n.parameters.parse(JSON.parse(e))})}class $e extends Error{constructor(t,r){super(t);_(this,"state");this.state=r}}class Ci extends $e{}class ns extends $e{}class de extends $e{}class K extends $e{}class rs extends $e{constructor(t,r,s){super(t,s);_(this,"error");this.error=r}}class Ei extends $e{constructor(t,r,s){super(t,s);_(this,"error");this.error=r}}class ss extends $e{constructor(t,r,s){super(t,s);_(this,"result");this.result=r}}class yn extends $e{constructor(t,r,s){super(t,s);_(this,"result");this.result=r}}function We(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 Oi(n){return typeof n=="object"&&n!==null&&"input"in n&&typeof n.input=="string"}function vn(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 Qn(n,e){const t=r=>JSON.parse(r);if(We(n)){const r=Ai({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 as(n){if(n==="text")return"text";if(We(n)){const e=Ii(n,"output");return{type:e.type,name:e.name,strict:e.strict||!1,schema:e.schema}}return n}function Ni(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var wn={exports:{}},Kn,is;function Ri(){if(is)return Kn;is=1;var n=1e3,e=n*60,t=e*60,r=t*24,s=r*7,a=r*365.25;Kn=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?l(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]),x=(f[2]||"ms").toLowerCase();switch(x){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 l(p){var f=Math.abs(p);return f>=r?c(p,f,r,"day"):f>=t?c(p,f,t,"hour"):f>=e?c(p,f,e,"minute"):f>=n?c(p,f,n,"second"):p+" ms"}function c(p,f,h,x){var b=f>=h*1.5;return Math.round(p/h)+" "+x+(b?"s":"")}return Kn}var er,os;function Di(){if(os)return er;os=1;function n(e){r.debug=r,r.default=r,r.coerce=c,r.disable=o,r.enable=a,r.enabled=l,r.humanize=Ri(),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 x=0;x<f.length;x++)h=(h<<5)-h+f.charCodeAt(x),h|=0;return r.colors[Math.abs(h)%r.colors.length]}r.selectColor=t;function r(f){let h,x=null,b,w;function E(...R){if(!E.enabled)return;const Y=E,ne=Number(new Date),me=ne-(h||ne);Y.diff=me,Y.prev=h,Y.curr=ne,h=ne,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,(Dr,Cc)=>{if(Dr==="%%")return"%";ge++;const ka=r.formatters[Cc];if(typeof ka=="function"){const Ec=R[ge];Dr=ka.call(Y,Ec),R.splice(ge,1),ge--}return Dr}),r.formatArgs.call(Y,R),(Y.log||r.log).apply(Y,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:()=>x!==null?x:(b!==r.namespaces&&(b=r.namespaces,w=r.enabled(f)),w),set:R=>{x=R}}),typeof r.init=="function"&&r.init(E),E}function s(f,h){const x=r(this.namespace+(typeof h>"u"?":":h)+f);return x.log=this.log,x}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 x of h)x[0]==="-"?r.skips.push(x.slice(1)):r.names.push(x)}function i(f,h){let x=0,b=0,w=-1,E=0;for(;x<f.length;)if(b<h.length&&(h[b]===f[x]||h[b]==="*"))h[b]==="*"?(w=b,E=x,b++):(x++,b++);else if(w!==-1)b=w+1,E++,x=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 l(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 c(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 er=n,er}var us;function Pi(){return us||(us=1,function(n,e){e.formatArgs=r,e.save=s,e.load=a,e.useColors=t,e.storage=i(),e.destroy=(()=>{let l=!1;return()=>{l||(l=!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 l;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&&(l=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(l[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(l){if(l[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+l[0]+(this.useColors?"%c ":" ")+"+"+n.exports.humanize(this.diff),!this.useColors)return;const c="color: "+this.color;l.splice(1,0,c,"color: inherit");let p=0,f=0;l[0].replace(/%[a-zA-Z%]/g,h=>{h!=="%%"&&(p++,h==="%c"&&(f=p))}),l.splice(f,0,c)}e.log=console.debug||console.log||(()=>{});function s(l){try{l?e.storage.setItem("debug",l):e.storage.removeItem("debug")}catch{}}function a(){let l;try{l=e.storage.getItem("debug")||e.storage.getItem("DEBUG")}catch{}return!l&&typeof process<"u"&&"env"in process&&(l=process.env.DEBUG),l}function i(){try{return localStorage}catch{}}n.exports=Di()(e);const{formatters:o}=n.exports;o.j=function(l){try{return JSON.stringify(l)}catch(c){return"[UnexpectedJSONParseError]: "+c.message}}}(wn,wn.exports)),wn.exports}var Mi=Pi();const ji=Ni(Mi);function Zi(){return yo()}function cs(n){const e=Zi();return typeof e<"u"&&(e[n]==="true"||e[n]==="1")}const ds={get disabled(){return!0}},ls={get dontLogModelData(){return cs("OPENAI_AGENTS_DONT_LOG_MODEL_DATA")},get dontLogToolData(){return cs("OPENAI_AGENTS_DONT_LOG_TOOL_DATA")}},$i=ls.dontLogModelData,Li=ls.dontLogToolData;function ps(n="openai-agents"){return{namespace:n,debug:ji(n),error:console.error,warn:console.warn,dontLogModelData:$i,dontLogToolData:Li}}const C=ps("openai-agents:core");function He(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 Fi(n,e){return`An error occurred while running the tool. Please try again. Error: ${e instanceof Error?e.toString():String(e)}`}function bn(n){const e=n.name?vn(n.name):vn(n.execute.name),t=typeof n.errorFunction>"u"?Fi: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&&We(n.parameters))throw new K("Strict mode is required for Zod parameters");const{parser:s,schema:a}=Qn(n.parameters,e);async function i(c,p){const[f,h]=await Hn(()=>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 x=await n.execute(h,c),b=He(x);return C.dontLogToolData?C.debug(`Tool ${e} completed`):C.debug(`Tool ${e} returned: ${b}`),x}async function o(c,p){return i(c,p).catch(f=>{if(t){const h=Ut();return h==null||h.setError({message:"Error running tool (non-fatal)",data:{tool_name:e,error:f.toString()}}),t(c,f)}throw f})}const l=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:l}}var U;(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})(U||(U={}));var fs;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(fs||(fs={}));const k=U.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Le=n=>{switch(typeof n){case"undefined":return k.undefined;case"string":return k.string;case"number":return Number.isNaN(n)?k.nan:k.number;case"boolean":return k.boolean;case"function":return k.function;case"bigint":return k.bigint;case"symbol":return k.symbol;case"object":return Array.isArray(n)?k.array:n===null?k.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?k.promise:typeof Map<"u"&&n instanceof Map?k.map:typeof Set<"u"&&n instanceof Set?k.set:typeof Date<"u"&&n instanceof Date?k.date:k.object;default:return k.unknown}},v=U.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 Oe 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,l=0;for(;l<i.path.length;){const c=i.path[l];l===i.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(t(i))):o[c]=o[c]||{_errors:[]},o=o[c],l++}}};return s(this),r}static assert(e){if(!(e instanceof Oe))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,U.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()}}Oe.create=n=>new Oe(n);const tr=(n,e)=>{let t;switch(n.code){case v.invalid_type:n.received===k.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case v.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,U.jsonStringifyReplacer)}`;break;case v.unrecognized_keys:t=`Unrecognized key(s) in object: ${U.joinValues(n.keys,", ")}`;break;case v.invalid_union:t="Invalid input";break;case v.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${U.joinValues(n.options)}`;break;case v.invalid_enum_value:t=`Invalid enum value. Expected ${U.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}"`:U.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,U.assertNever(n)}return{message:t}};let Ui=tr;function Ji(){return Ui}const Bi=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 l=r.filter(c=>!!c).slice().reverse();for(const c of l)o=c(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}};function S(n,e){const t=Ji(),r=Bi({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===tr?void 0:tr].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"}),jt=n=>({status:"dirty",value:n}),_e=n=>({status:"valid",value:n}),hs=n=>n.status==="aborted",ms=n=>n.status==="dirty",ht=n=>n.status==="valid",xn=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 Se{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 gs=(n,e)=>{if(ht(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 Oe(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:l}=n;return i.code==="invalid_enum_value"?{message:l??o.defaultError}:typeof o.data>"u"?{message:l??r??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:l??t??o.defaultError}},description:s}}class ${get description(){return this._def.description}_getType(e){return Le(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Le(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:Le(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(xn(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:Le(e)},s=this._parseSync({data:e,path:r.path,parent:r});return gs(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:Le(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:t});return ht(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=>ht(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:Le(e)},s=this._parse({data:e,path:r.path,parent:r}),a=await(xn(s)?s:Promise.resolve(s));return gs(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(l=>l?!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 Qe({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 De.create(this,this._def)}nullable(){return Ke.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Te.create(this)}promise(){return En.create(this,this._def)}or(e){return Tn.create([this,e],this._def)}and(e){return kn.create(this,e,this._def)}transform(e){return new Qe({...j(this._def),schema:this,typeName:N.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new On({...j(this._def),innerType:this,defaultValue:t,typeName:N.ZodDefault})}brand(){return new ks({typeName:N.ZodBranded,type:this,...j(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Nn({...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 dr.create(this,e)}readonly(){return Rn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const qi=/^c[^\s-]{8,}$/i,Gi=/^[0-9a-z]+$/,Vi=/^[0-9A-HJKMNP-TV-Z]{26}$/i,zi=/^[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,Wi=/^[a-z0-9_-]{21}$/i,Hi=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Yi=/^[-+]?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)?)??$/,Xi=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Qi="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let nr;const Ki=/^(?:(?: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])$/,eo=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-