@botpress/sdk 4.15.9 → 4.15.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var dd=Object.create;var Jt=Object.defineProperty;var pd=Object.getOwnPropertyDescriptor;var fd=Object.getOwnPropertyNames;var gd=Object.getPrototypeOf,hd=Object.prototype.hasOwnProperty;var yt=(t,e)=>{for(var r in e)Jt(t,r,{get:e[r],enumerable:!0})},Ls=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of fd(e))!hd.call(t,s)&&s!==r&&Jt(t,s,{get:()=>e[s],enumerable:!(n=pd(e,s))||n.enumerable});return t};var Ws=(t,e,r)=>(r=t!=null?dd(gd(t)):{},Ls(e||!t||!t.__esModule?Jt(r,"default",{value:t,enumerable:!0}):r,t)),md=t=>Ls(Jt({},"__esModule",{value:!0}),t);var Gy={};yt(Gy,{BRAND:()=>Kl,Bot:()=>wn,BotDefinition:()=>bn,BotLogger:()=>ht,BotSpecificClient:()=>ce,DIRTY:()=>Re,EMPTY_PATH:()=>Rl,INVALID:()=>x,Integration:()=>Tn,IntegrationDefinition:()=>yn,IntegrationLogger:()=>gt,IntegrationSpecificClient:()=>pt,InterfaceDefinition:()=>Pn,NEVER:()=>nu,OK:()=>J,ParseInputLazyPath:()=>ae,ParseStatus:()=>te,Plugin:()=>kn,PluginDefinition:()=>xn,RuntimeError:()=>Sn.RuntimeError,Schema:()=>O,WELL_KNOWN_ATTRIBUTES:()=>oy,ZodAny:()=>at,ZodArray:()=>ot,ZodBigInt:()=>tn,ZodBoolean:()=>rn,ZodBranded:()=>nn,ZodCatch:()=>sn,ZodDate:()=>an,ZodDefault:()=>Kt,ZodDiscriminatedUnion:()=>ds,ZodEffects:()=>we,ZodEnum:()=>We,ZodError:()=>le,ZodFirstPartyTypeKind:()=>os,ZodFunction:()=>fs,ZodIntersection:()=>on,ZodIssueCode:()=>h,ZodLazy:()=>ln,ZodLiteral:()=>cn,ZodMap:()=>gs,ZodNaN:()=>hs,ZodNativeEnum:()=>un,ZodNever:()=>ut,ZodNull:()=>dn,ZodNullable:()=>De,ZodNumber:()=>pn,ZodObject:()=>Me,ZodOptional:()=>fe,ZodParsedType:()=>_,ZodPipeline:()=>fn,ZodPromise:()=>zt,ZodReadonly:()=>Ft,ZodRecord:()=>ms,ZodRef:()=>ys,ZodSchema:()=>O,ZodSet:()=>vs,ZodString:()=>X,ZodSymbol:()=>Ss,ZodTransformer:()=>we,ZodTuple:()=>Ne,ZodType:()=>O,ZodUndefined:()=>Lt,ZodUnion:()=>gn,ZodUnknown:()=>rt,ZodVoid:()=>Os,addIssueToContext:()=>v,agent:()=>dc,aimodel:()=>mc,any:()=>Oc,array:()=>Bc,bigint:()=>wc,boolean:()=>Is,botIdHeader:()=>Wt,botUserIdHeader:()=>Rs,coerce:()=>ru,configurationHeader:()=>qt,configurationTypeHeader:()=>Ms,conversation:()=>lc,createZodEnum:()=>Ut,cuid2Regex:()=>Ts,cuidRegex:()=>_s,custom:()=>us,datasource:()=>yc,date:()=>Pc,discriminatedUnion:()=>Hc,effect:()=>zn,emailRegex:()=>Ps,enum:()=>Wc,errorUtil:()=>w,event:()=>pc,function:()=>zc,getErrorMap:()=>st,getParsedType:()=>pe,instanceof:()=>Tc,integrationIdHeader:()=>Hs,intent:()=>hc,intersection:()=>Dc,ipv4Regex:()=>xs,ipv6Regex:()=>ks,isAborted:()=>dr,isApiError:()=>Sn.isApiError,isAsync:()=>Nt,isDirty:()=>pr,isEmojiRegex:()=>tc,isValid:()=>it,knowledgebase:()=>vc,late:()=>_c,lazy:()=>Fc,literal:()=>Lc,makeIssue:()=>Mt,map:()=>Kc,mergeObjectSchemas:()=>dt,message:()=>uc,messages:()=>As,nan:()=>bc,nativeEnum:()=>qc,never:()=>Zc,null:()=>Sc,nullable:()=>Jc,number:()=>Zs,object:()=>Cc,objectUtil:()=>cr,oboolean:()=>tu,onumber:()=>eu,operationHeader:()=>Vt,optional:()=>Gc,ostring:()=>Qc,parseBody:()=>oe,pipeline:()=>Yc,preprocess:()=>Xc,processCreateParams:()=>k,promise:()=>Vc,quotelessJson:()=>Bl,readonly:()=>jc,record:()=>Nc,ref:()=>$c,serve:()=>Gt,set:()=>Uc,setErrorMap:()=>cs,strictObject:()=>Ac,string:()=>Es,symbol:()=>xc,table:()=>fc,tablerow:()=>gc,transformer:()=>zn,transforms:()=>Ci,tuple:()=>Mc,typeHeader:()=>Ns,ulidRegex:()=>bs,undefined:()=>kc,union:()=>Rc,unknown:()=>Ec,user:()=>cc,util:()=>Z,uuidRegex:()=>ws,variable:()=>oc,void:()=>Ic,webhookIdHeader:()=>Ds,z:()=>y});module.exports=md(Gy);var As={};yt(As,{defaults:()=>ay,markdown:()=>iy});var Wn=Object.defineProperty,yd=Object.defineProperties,vd=Object.getOwnPropertyDescriptors,lr=Object.getOwnPropertySymbols,Zi=Object.prototype.hasOwnProperty,Ii=Object.prototype.propertyIsEnumerable,qs=(t,e,r)=>e in t?Wn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,c=(t,e)=>{for(var r in e||(e={}))Zi.call(e,r)&&qs(t,r,e[r]);if(lr)for(var r of lr(e))Ii.call(e,r)&&qs(t,r,e[r]);return t},p=(t,e)=>yd(t,vd(e)),a=(t,e)=>Wn(t,"name",{value:e,configurable:!0}),Bi=(t,e)=>{var r={};for(var n in t)Zi.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&lr)for(var n of lr(t))e.indexOf(n)<0&&Ii.call(t,n)&&(r[n]=t[n]);return r},Fr=(t,e)=>{for(var r in e)Wn(t,r,{get:e[r],enumerable:!0})},Ci={};Fr(Ci,{errors:()=>Di,fromJSONSchema:()=>ou,fromJSONSchemaLegacy:()=>Zm,fromObject:()=>Fn,toJSONSchema:()=>V,toJSONSchemaLegacy:()=>ty,toTypescriptSchema:()=>ss,toTypescriptType:()=>qn});var y={};Fr(y,{BRAND:()=>Kl,DIRTY:()=>Re,EMPTY_PATH:()=>Rl,INVALID:()=>x,NEVER:()=>nu,OK:()=>J,ParseInputLazyPath:()=>ae,ParseStatus:()=>te,Schema:()=>O,ZodAny:()=>at,ZodArray:()=>ot,ZodBigInt:()=>tn,ZodBoolean:()=>rn,ZodBranded:()=>nn,ZodCatch:()=>sn,ZodDate:()=>an,ZodDefault:()=>Kt,ZodDiscriminatedUnion:()=>ds,ZodEffects:()=>we,ZodEnum:()=>We,ZodError:()=>le,ZodFirstPartyTypeKind:()=>os,ZodFunction:()=>fs,ZodIntersection:()=>on,ZodIssueCode:()=>h,ZodLazy:()=>ln,ZodLiteral:()=>cn,ZodMap:()=>gs,ZodNaN:()=>hs,ZodNativeEnum:()=>un,ZodNever:()=>ut,ZodNull:()=>dn,ZodNullable:()=>De,ZodNumber:()=>pn,ZodObject:()=>Me,ZodOptional:()=>fe,ZodParsedType:()=>_,ZodPipeline:()=>fn,ZodPromise:()=>zt,ZodReadonly:()=>Ft,ZodRecord:()=>ms,ZodRef:()=>ys,ZodSchema:()=>O,ZodSet:()=>vs,ZodString:()=>X,ZodSymbol:()=>Ss,ZodTransformer:()=>we,ZodTuple:()=>Ne,ZodType:()=>O,ZodUndefined:()=>Lt,ZodUnion:()=>gn,ZodUnknown:()=>rt,ZodVoid:()=>Os,addIssueToContext:()=>v,agent:()=>dc,aimodel:()=>mc,any:()=>Oc,array:()=>Bc,bigint:()=>wc,boolean:()=>Is,coerce:()=>ru,conversation:()=>lc,createZodEnum:()=>Ut,cuid2Regex:()=>Ts,cuidRegex:()=>_s,custom:()=>us,datasource:()=>yc,date:()=>Pc,default:()=>im,discriminatedUnion:()=>Hc,effect:()=>zn,emailRegex:()=>Ps,enum:()=>Wc,errorUtil:()=>w,event:()=>pc,function:()=>zc,getErrorMap:()=>st,getParsedType:()=>pe,instanceof:()=>Tc,intent:()=>hc,intersection:()=>Dc,ipv4Regex:()=>xs,ipv6Regex:()=>ks,isAborted:()=>dr,isAsync:()=>Nt,isDirty:()=>pr,isEmojiRegex:()=>tc,isValid:()=>it,knowledgebase:()=>vc,late:()=>_c,lazy:()=>Fc,literal:()=>Lc,makeIssue:()=>Mt,map:()=>Kc,message:()=>uc,nan:()=>bc,nativeEnum:()=>qc,never:()=>Zc,null:()=>Sc,nullable:()=>Jc,number:()=>Zs,object:()=>Cc,objectUtil:()=>cr,oboolean:()=>tu,onumber:()=>eu,optional:()=>Gc,ostring:()=>Qc,pipeline:()=>Yc,preprocess:()=>Xc,processCreateParams:()=>k,promise:()=>Vc,quotelessJson:()=>Bl,readonly:()=>jc,record:()=>Nc,ref:()=>$c,set:()=>Uc,setErrorMap:()=>cs,strictObject:()=>Ac,string:()=>Es,symbol:()=>xc,table:()=>fc,tablerow:()=>gc,transformer:()=>zn,tuple:()=>Mc,ulidRegex:()=>bs,undefined:()=>kc,union:()=>Rc,unknown:()=>Ec,user:()=>cc,util:()=>Z,uuidRegex:()=>ws,variable:()=>oc,void:()=>Ic});var b="x-zui";function Ai(t){return typeof t=="symbol"?"symbol":typeof t=="bigint"?`${t.toString()}n`:T(t)}a(Ai,"primitiveToTypscriptLiteralType");function T(t){return typeof t>"u"?"undefined":typeof t=="symbol"?t.description?`Symbol(${T(t.description)})`:"Symbol()":typeof t=="bigint"?`BigInt(${t.toString()})`:JSON.stringify(t)}a(T,"primitiveToTypescriptValue");function et(t){return typeof t>"u"?"undefined":JSON.stringify(t)}a(et,"unknownToTypescriptValue");var Ri=a((t,e)=>{let r=Object.entries(t),n=e?" as const":"";return`{ ${r.map(([s,i])=>`${An(s)}: ${et(i)}`).join(", ")} }${n}`},"recordOfUnknownToTypescriptRecord"),An=a(t=>/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t)?t:T(t),"toPropertyKey"),_d=a(t=>t.charAt(0).toUpperCase()+t.slice(1),"capitalize"),Hi=a(t=>{let e=/[^a-zA-Z0-9_]/g;return t.split(e).map(_d).filter(n=>!!n).join("")},"toTypeArgumentName"),z=a(t=>{let e=(t??"").split(`
1
+ "use strict";var dd=Object.create;var Jt=Object.defineProperty;var pd=Object.getOwnPropertyDescriptor;var fd=Object.getOwnPropertyNames;var gd=Object.getPrototypeOf,hd=Object.prototype.hasOwnProperty;var yt=(t,e)=>{for(var r in e)Jt(t,r,{get:e[r],enumerable:!0})},Ls=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of fd(e))!hd.call(t,s)&&s!==r&&Jt(t,s,{get:()=>e[s],enumerable:!(n=pd(e,s))||n.enumerable});return t};var Ws=(t,e,r)=>(r=t!=null?dd(gd(t)):{},Ls(e||!t||!t.__esModule?Jt(r,"default",{value:t,enumerable:!0}):r,t)),md=t=>Ls(Jt({},"__esModule",{value:!0}),t);var Vy={};yt(Vy,{BRAND:()=>Kl,Bot:()=>wn,BotDefinition:()=>bn,BotLogger:()=>ht,BotSpecificClient:()=>ce,DIRTY:()=>Re,EMPTY_PATH:()=>Rl,INVALID:()=>x,Integration:()=>Tn,IntegrationDefinition:()=>yn,IntegrationLogger:()=>gt,IntegrationSpecificClient:()=>pt,InterfaceDefinition:()=>Pn,NEVER:()=>nu,OK:()=>J,ParseInputLazyPath:()=>ae,ParseStatus:()=>te,Plugin:()=>kn,PluginDefinition:()=>xn,RuntimeError:()=>Sn.RuntimeError,Schema:()=>O,WELL_KNOWN_ATTRIBUTES:()=>oy,ZodAny:()=>at,ZodArray:()=>ot,ZodBigInt:()=>tn,ZodBoolean:()=>rn,ZodBranded:()=>nn,ZodCatch:()=>sn,ZodDate:()=>an,ZodDefault:()=>Kt,ZodDiscriminatedUnion:()=>ds,ZodEffects:()=>we,ZodEnum:()=>We,ZodError:()=>le,ZodFirstPartyTypeKind:()=>os,ZodFunction:()=>fs,ZodIntersection:()=>on,ZodIssueCode:()=>h,ZodLazy:()=>ln,ZodLiteral:()=>cn,ZodMap:()=>gs,ZodNaN:()=>hs,ZodNativeEnum:()=>un,ZodNever:()=>ut,ZodNull:()=>dn,ZodNullable:()=>De,ZodNumber:()=>pn,ZodObject:()=>Me,ZodOptional:()=>fe,ZodParsedType:()=>_,ZodPipeline:()=>fn,ZodPromise:()=>zt,ZodReadonly:()=>Ft,ZodRecord:()=>ms,ZodRef:()=>ys,ZodSchema:()=>O,ZodSet:()=>vs,ZodString:()=>X,ZodSymbol:()=>Ss,ZodTransformer:()=>we,ZodTuple:()=>Ne,ZodType:()=>O,ZodUndefined:()=>Lt,ZodUnion:()=>gn,ZodUnknown:()=>rt,ZodVoid:()=>Os,addIssueToContext:()=>v,agent:()=>dc,aimodel:()=>mc,any:()=>Oc,array:()=>Bc,bigint:()=>wc,boolean:()=>Is,botIdHeader:()=>Wt,botUserIdHeader:()=>Rs,coerce:()=>ru,configurationHeader:()=>qt,configurationTypeHeader:()=>Ms,conversation:()=>lc,createZodEnum:()=>Ut,cuid2Regex:()=>Ts,cuidRegex:()=>_s,custom:()=>us,datasource:()=>yc,date:()=>Pc,discriminatedUnion:()=>Hc,effect:()=>zn,emailRegex:()=>Ps,enum:()=>Wc,errorUtil:()=>w,event:()=>pc,function:()=>zc,getErrorMap:()=>st,getParsedType:()=>pe,instanceof:()=>Tc,integrationIdHeader:()=>Hs,intent:()=>hc,intersection:()=>Dc,ipv4Regex:()=>xs,ipv6Regex:()=>ks,isAborted:()=>dr,isApiError:()=>Sn.isApiError,isAsync:()=>Nt,isDirty:()=>pr,isEmojiRegex:()=>tc,isValid:()=>it,knowledgebase:()=>vc,late:()=>_c,lazy:()=>Fc,literal:()=>Lc,makeIssue:()=>Mt,map:()=>Kc,mergeObjectSchemas:()=>dt,message:()=>uc,messages:()=>As,nan:()=>bc,nativeEnum:()=>qc,never:()=>Zc,null:()=>Sc,nullable:()=>Jc,number:()=>Zs,object:()=>Cc,objectUtil:()=>cr,oboolean:()=>tu,onumber:()=>eu,operationHeader:()=>Vt,optional:()=>Gc,ostring:()=>Qc,parseBody:()=>oe,pipeline:()=>Yc,preprocess:()=>Xc,processCreateParams:()=>k,promise:()=>Vc,quotelessJson:()=>Bl,readonly:()=>jc,record:()=>Nc,ref:()=>$c,serve:()=>Gt,set:()=>Uc,setErrorMap:()=>cs,strictObject:()=>Ac,string:()=>Es,symbol:()=>xc,table:()=>fc,tablerow:()=>gc,transformer:()=>zn,transforms:()=>Ci,tuple:()=>Mc,typeHeader:()=>Ns,ulidRegex:()=>bs,undefined:()=>kc,union:()=>Rc,unknown:()=>Ec,user:()=>cc,util:()=>Z,uuidRegex:()=>ws,variable:()=>oc,void:()=>Ic,webhookIdHeader:()=>Ds,z:()=>y});module.exports=md(Vy);var As={};yt(As,{defaults:()=>ay,markdown:()=>iy});var Wn=Object.defineProperty,yd=Object.defineProperties,vd=Object.getOwnPropertyDescriptors,lr=Object.getOwnPropertySymbols,Zi=Object.prototype.hasOwnProperty,Ii=Object.prototype.propertyIsEnumerable,qs=(t,e,r)=>e in t?Wn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,c=(t,e)=>{for(var r in e||(e={}))Zi.call(e,r)&&qs(t,r,e[r]);if(lr)for(var r of lr(e))Ii.call(e,r)&&qs(t,r,e[r]);return t},p=(t,e)=>yd(t,vd(e)),a=(t,e)=>Wn(t,"name",{value:e,configurable:!0}),Bi=(t,e)=>{var r={};for(var n in t)Zi.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&lr)for(var n of lr(t))e.indexOf(n)<0&&Ii.call(t,n)&&(r[n]=t[n]);return r},Fr=(t,e)=>{for(var r in e)Wn(t,r,{get:e[r],enumerable:!0})},Ci={};Fr(Ci,{errors:()=>Di,fromJSONSchema:()=>ou,fromJSONSchemaLegacy:()=>Zm,fromObject:()=>Fn,toJSONSchema:()=>V,toJSONSchemaLegacy:()=>ty,toTypescriptSchema:()=>ss,toTypescriptType:()=>qn});var y={};Fr(y,{BRAND:()=>Kl,DIRTY:()=>Re,EMPTY_PATH:()=>Rl,INVALID:()=>x,NEVER:()=>nu,OK:()=>J,ParseInputLazyPath:()=>ae,ParseStatus:()=>te,Schema:()=>O,ZodAny:()=>at,ZodArray:()=>ot,ZodBigInt:()=>tn,ZodBoolean:()=>rn,ZodBranded:()=>nn,ZodCatch:()=>sn,ZodDate:()=>an,ZodDefault:()=>Kt,ZodDiscriminatedUnion:()=>ds,ZodEffects:()=>we,ZodEnum:()=>We,ZodError:()=>le,ZodFirstPartyTypeKind:()=>os,ZodFunction:()=>fs,ZodIntersection:()=>on,ZodIssueCode:()=>h,ZodLazy:()=>ln,ZodLiteral:()=>cn,ZodMap:()=>gs,ZodNaN:()=>hs,ZodNativeEnum:()=>un,ZodNever:()=>ut,ZodNull:()=>dn,ZodNullable:()=>De,ZodNumber:()=>pn,ZodObject:()=>Me,ZodOptional:()=>fe,ZodParsedType:()=>_,ZodPipeline:()=>fn,ZodPromise:()=>zt,ZodReadonly:()=>Ft,ZodRecord:()=>ms,ZodRef:()=>ys,ZodSchema:()=>O,ZodSet:()=>vs,ZodString:()=>X,ZodSymbol:()=>Ss,ZodTransformer:()=>we,ZodTuple:()=>Ne,ZodType:()=>O,ZodUndefined:()=>Lt,ZodUnion:()=>gn,ZodUnknown:()=>rt,ZodVoid:()=>Os,addIssueToContext:()=>v,agent:()=>dc,aimodel:()=>mc,any:()=>Oc,array:()=>Bc,bigint:()=>wc,boolean:()=>Is,coerce:()=>ru,conversation:()=>lc,createZodEnum:()=>Ut,cuid2Regex:()=>Ts,cuidRegex:()=>_s,custom:()=>us,datasource:()=>yc,date:()=>Pc,default:()=>im,discriminatedUnion:()=>Hc,effect:()=>zn,emailRegex:()=>Ps,enum:()=>Wc,errorUtil:()=>w,event:()=>pc,function:()=>zc,getErrorMap:()=>st,getParsedType:()=>pe,instanceof:()=>Tc,intent:()=>hc,intersection:()=>Dc,ipv4Regex:()=>xs,ipv6Regex:()=>ks,isAborted:()=>dr,isAsync:()=>Nt,isDirty:()=>pr,isEmojiRegex:()=>tc,isValid:()=>it,knowledgebase:()=>vc,late:()=>_c,lazy:()=>Fc,literal:()=>Lc,makeIssue:()=>Mt,map:()=>Kc,message:()=>uc,nan:()=>bc,nativeEnum:()=>qc,never:()=>Zc,null:()=>Sc,nullable:()=>Jc,number:()=>Zs,object:()=>Cc,objectUtil:()=>cr,oboolean:()=>tu,onumber:()=>eu,optional:()=>Gc,ostring:()=>Qc,pipeline:()=>Yc,preprocess:()=>Xc,processCreateParams:()=>k,promise:()=>Vc,quotelessJson:()=>Bl,readonly:()=>jc,record:()=>Nc,ref:()=>$c,set:()=>Uc,setErrorMap:()=>cs,strictObject:()=>Ac,string:()=>Es,symbol:()=>xc,table:()=>fc,tablerow:()=>gc,transformer:()=>zn,tuple:()=>Mc,ulidRegex:()=>bs,undefined:()=>kc,union:()=>Rc,unknown:()=>Ec,user:()=>cc,util:()=>Z,uuidRegex:()=>ws,variable:()=>oc,void:()=>Ic});var b="x-zui";function Ai(t){return typeof t=="symbol"?"symbol":typeof t=="bigint"?`${t.toString()}n`:T(t)}a(Ai,"primitiveToTypscriptLiteralType");function T(t){return typeof t>"u"?"undefined":typeof t=="symbol"?t.description?`Symbol(${T(t.description)})`:"Symbol()":typeof t=="bigint"?`BigInt(${t.toString()})`:JSON.stringify(t)}a(T,"primitiveToTypescriptValue");function et(t){return typeof t>"u"?"undefined":JSON.stringify(t)}a(et,"unknownToTypescriptValue");var Ri=a((t,e)=>{let r=Object.entries(t),n=e?" as const":"";return`{ ${r.map(([s,i])=>`${An(s)}: ${et(i)}`).join(", ")} }${n}`},"recordOfUnknownToTypescriptRecord"),An=a(t=>/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t)?t:T(t),"toPropertyKey"),_d=a(t=>t.charAt(0).toUpperCase()+t.slice(1),"capitalize"),Hi=a(t=>{let e=/[^a-zA-Z0-9_]/g;return t.split(e).map(_d).filter(n=>!!n).join("")},"toTypeArgumentName"),z=a(t=>{let e=(t??"").split(`
2
2
  `).filter(r=>r.trim().length>0);return e.length===0?"":e.length===1?`/** ${e[0]} */`:`/**
3
3
  * ${e.join(`
4
4
  * `)}
@@ -8,7 +8,7 @@ ${g.join(" | ")}`;case d.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:let m=l.opt
8
8
  ${m.join(" | ")}`;case d.ZodFirstPartyTypeKind.ZodIntersection:return`${B(l.left,i)} & ${B(l.right,i)}`;case d.ZodFirstPartyTypeKind.ZodTuple:return l.items.length===0?"":`[${l.items.map(q=>B(q,i)).join(", ")}]`;case d.ZodFirstPartyTypeKind.ZodRecord:let E=B(l.keyType,i),I=B(l.valueType,i);return`${z(o.description)} { [key: ${E}]: ${I} }`;case d.ZodFirstPartyTypeKind.ZodMap:return`Map<${B(l.keyType,i)}, ${B(l.valueType,i)}>`;case d.ZodFirstPartyTypeKind.ZodSet:return`Set<${B(l.valueType,i)}>`;case d.ZodFirstPartyTypeKind.ZodFunction:let U=B(new Gs(l.args),i),W=B(new Js(l.returns),i);return`${z(o.description)}
9
9
  (${U}) => ${W}`;case d.ZodFirstPartyTypeKind.ZodLazy:return B(l.getter(),i);case d.ZodFirstPartyTypeKind.ZodLiteral:let Q=Ai(l.value);return`${z(o.description)}
10
10
  ${Q}`.trim();case d.ZodFirstPartyTypeKind.ZodEnum:return l.values.map(T).join(" | ");case d.ZodFirstPartyTypeKind.ZodEffects:return B(l.schema,i);case d.ZodFirstPartyTypeKind.ZodNativeEnum:throw new Ji(d.ZodFirstPartyTypeKind.ZodNativeEnum);case d.ZodFirstPartyTypeKind.ZodOptional:return`${B(l.innerType,i)} | undefined`;case d.ZodFirstPartyTypeKind.ZodNullable:return`${B(l.innerType,i)} | null`;case d.ZodFirstPartyTypeKind.ZodDefault:return B(l.innerType,i);case d.ZodFirstPartyTypeKind.ZodCatch:return B(l.innerType,i);case d.ZodFirstPartyTypeKind.ZodPromise:return`Promise<${B(l.type,i)}>`;case d.ZodFirstPartyTypeKind.ZodBranded:return B(l.type,i);case d.ZodFirstPartyTypeKind.ZodPipeline:return B(l.in,i);case d.ZodFirstPartyTypeKind.ZodSymbol:return`${z(o.description)} symbol`.trim();case d.ZodFirstPartyTypeKind.ZodReadonly:return`Readonly<${B(l.innerType,i)}>`;case d.ZodFirstPartyTypeKind.ZodRef:return Hi(l.uri);default:Z.assertNever(l)}}a(B,"sUnwrapZod");var wd=a((t,e)=>{if(t.props.type==="none")return B(t.props.schema,e);let r=z(t.props.schema.description),n=t.props.schema.describe(""),s=B(n,e);if(t.props.type==="variable")return Vs(`${r}declare const ${t.props.identifier}: ${s};`);let i=t.props.args.length>0?`<${t.props.args.map(Hi).join(", ")}>`:"";return Vs(`${r}type ${t.props.identifier}${i} = ${s};`)},"unwrapDeclaration"),Pd=a(t=>t.declaration?t.declaration===!0?"variable":t.declaration:"none","getDeclarationType"),xd=a((t,e)=>{let r=Pd(e),n=t.getReferences();if(r==="none"){if(n.length>0)throw new Hn;return new Qt({type:"none",schema:t})}let s="title"in t.ui?t.ui.title:null;if(!s)throw new Yi;if(r==="variable"){if(n.length>0)throw new Hn;return new Qt({type:"variable",identifier:s,schema:t})}return new Qt({type:"type",identifier:s,schema:t,args:n})},"getDeclarationProps"),kd=typeof global=="object"&&global&&global.Object===Object&&global,ia=kd,Sd=typeof self=="object"&&self&&self.Object===Object&&self,Od=ia||Sd||Function("return this")(),he=Od,Ed=he.Symbol,Te=Ed,aa=Object.prototype,Zd=aa.hasOwnProperty,Id=aa.toString,vt=Te?Te.toStringTag:void 0;function oa(t){var e=Zd.call(t,vt),r=t[vt];try{t[vt]=void 0;var n=!0}catch{}var s=Id.call(t);return n&&(e?t[vt]=r:delete t[vt]),s}a(oa,"getRawTag");var Bd=oa,Cd=Object.prototype,Ad=Cd.toString;function la(t){return Ad.call(t)}a(la,"objectToString");var Rd=la,Hd="[object Null]",Dd="[object Undefined]",Xs=Te?Te.toStringTag:void 0;function ca(t){return t==null?t===void 0?Dd:Hd:Xs&&Xs in Object(t)?Bd(t):Rd(t)}a(ca,"baseGetTag");var $e=ca;function ua(t){return t!=null&&typeof t=="object"}a(ua,"isObjectLike");var He=ua,Md="[object Symbol]";function da(t){return typeof t=="symbol"||He(t)&&$e(t)==Md}a(da,"isSymbol");var Vn=da;function pa(t,e){for(var r=-1,n=t==null?0:t.length,s=Array(n);++r<n;)s[r]=e(t[r],r,t);return s}a(pa,"arrayMap");var fa=pa,Nd=Array.isArray,ge=Nd,$d=1/0,Ys=Te?Te.prototype:void 0,Qs=Ys?Ys.toString:void 0;function Gn(t){if(typeof t=="string")return t;if(ge(t))return fa(t,Gn)+"";if(Vn(t))return Qs?Qs.call(t):"";var e=t+"";return e=="0"&&1/t==-$d?"-0":e}a(Gn,"baseToString");var jd=Gn;function ga(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}a(ga,"isObject");var nt=ga;function ha(t){return t}a(ha,"identity");var Kd=ha,Ud="[object AsyncFunction]",zd="[object Function]",Fd="[object GeneratorFunction]",Ld="[object Proxy]";function ma(t){if(!nt(t))return!1;var e=$e(t);return e==zd||e==Fd||e==Ud||e==Ld}a(ma,"isFunction");var ya=ma,Wd=he["__core-js_shared__"],On=Wd,ei=(function(){var t=/[^.]+$/.exec(On&&On.keys&&On.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function va(t){return!!ei&&ei in t}a(va,"isMasked");var qd=va,Vd=Function.prototype,Gd=Vd.toString;function _a(t){if(t!=null){try{return Gd.call(t)}catch{}try{return t+""}catch{}}return""}a(_a,"toSource");var je=_a,Jd=/[\\^$.*+?()[\]{}|]/g,Xd=/^\[object .+?Constructor\]$/,Yd=Function.prototype,Qd=Object.prototype,ep=Yd.toString,tp=Qd.hasOwnProperty,rp=RegExp("^"+ep.call(tp).replace(Jd,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ta(t){if(!nt(t)||qd(t))return!1;var e=ya(t)?rp:Xd;return e.test(je(t))}a(Ta,"baseIsNative");var np=Ta;function ba(t,e){return t?.[e]}a(ba,"getValue");var sp=ba;function wa(t,e){var r=sp(t,e);return np(r)?r:void 0}a(wa,"getNative");var Ke=wa,ip=Ke(he,"WeakMap"),Dn=ip,ap=(function(){try{var t=Ke(Object,"defineProperty");return t({},"",{}),t}catch{}})(),ti=ap,op=9007199254740991,lp=/^(?:0|[1-9]\d*)$/;function Pa(t,e){var r=typeof t;return e=e??op,!!e&&(r=="number"||r!="symbol"&&lp.test(t))&&t>-1&&t%1==0&&t<e}a(Pa,"isIndex");var Jn=Pa;function xa(t,e,r){e=="__proto__"&&ti?ti(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}a(xa,"baseAssignValue");var ka=xa;function Sa(t,e){return t===e||t!==t&&e!==e}a(Sa,"eq");var Xn=Sa,cp=Object.prototype,up=cp.hasOwnProperty;function Oa(t,e,r){var n=t[e];(!(up.call(t,e)&&Xn(n,r))||r===void 0&&!(e in t))&&ka(t,e,r)}a(Oa,"assignValue");var dp=Oa,pp=9007199254740991;function Ea(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=pp}a(Ea,"isLength");var Yn=Ea;function Za(t){return t!=null&&Yn(t.length)&&!ya(t)}a(Za,"isArrayLike");var Ia=Za,fp=Object.prototype;function Ba(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||fp;return t===r}a(Ba,"isPrototype");var Ca=Ba;function Aa(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}a(Aa,"baseTimes");var gp=Aa,hp="[object Arguments]";function Ra(t){return He(t)&&$e(t)==hp}a(Ra,"baseIsArguments");var ri=Ra,Ha=Object.prototype,mp=Ha.hasOwnProperty,yp=Ha.propertyIsEnumerable,vp=ri((function(){return arguments})())?ri:function(t){return He(t)&&mp.call(t,"callee")&&!yp.call(t,"callee")},Da=vp;function Ma(){return!1}a(Ma,"stubFalse");var _p=Ma,Na=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ni=Na&&typeof module=="object"&&module&&!module.nodeType&&module,Tp=ni&&ni.exports===Na,si=Tp?he.Buffer:void 0,bp=si?si.isBuffer:void 0,wp=bp||_p,Mn=wp,Pp="[object Arguments]",xp="[object Array]",kp="[object Boolean]",Sp="[object Date]",Op="[object Error]",Ep="[object Function]",Zp="[object Map]",Ip="[object Number]",Bp="[object Object]",Cp="[object RegExp]",Ap="[object Set]",Rp="[object String]",Hp="[object WeakMap]",Dp="[object ArrayBuffer]",Mp="[object DataView]",Np="[object Float32Array]",$p="[object Float64Array]",jp="[object Int8Array]",Kp="[object Int16Array]",Up="[object Int32Array]",zp="[object Uint8Array]",Fp="[object Uint8ClampedArray]",Lp="[object Uint16Array]",Wp="[object Uint32Array]",D={};D[Np]=D[$p]=D[jp]=D[Kp]=D[Up]=D[zp]=D[Fp]=D[Lp]=D[Wp]=!0;D[Pp]=D[xp]=D[Dp]=D[kp]=D[Mp]=D[Sp]=D[Op]=D[Ep]=D[Zp]=D[Ip]=D[Bp]=D[Cp]=D[Ap]=D[Rp]=D[Hp]=!1;function $a(t){return He(t)&&Yn(t.length)&&!!D[$e(t)]}a($a,"baseIsTypedArray");var qp=$a;function ja(t){return function(e){return t(e)}}a(ja,"baseUnary");var Vp=ja,Ka=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ct=Ka&&typeof module=="object"&&module&&!module.nodeType&&module,Gp=Ct&&Ct.exports===Ka,En=Gp&&ia.process,Jp=(function(){try{var t=Ct&&Ct.require&&Ct.require("util").types;return t||En&&En.binding&&En.binding("util")}catch{}})(),ii=Jp,ai=ii&&ii.isTypedArray,Xp=ai?Vp(ai):qp,Ua=Xp,Yp=Object.prototype,Qp=Yp.hasOwnProperty;function za(t,e){var r=ge(t),n=!r&&Da(t),s=!r&&!n&&Mn(t),i=!r&&!n&&!s&&Ua(t),o=r||n||s||i,l=o?gp(t.length,String):[],u=l.length;for(var f in t)(e||Qp.call(t,f))&&!(o&&(f=="length"||s&&(f=="offset"||f=="parent")||i&&(f=="buffer"||f=="byteLength"||f=="byteOffset")||Jn(f,u)))&&l.push(f);return l}a(za,"arrayLikeKeys");var Fa=za;function La(t,e){return function(r){return t(e(r))}}a(La,"overArg");var Wa=La,ef=Wa(Object.keys,Object),tf=ef,rf=Object.prototype,nf=rf.hasOwnProperty;function qa(t){if(!Ca(t))return tf(t);var e=[];for(var r in Object(t))nf.call(t,r)&&r!="constructor"&&e.push(r);return e}a(qa,"baseKeys");var sf=qa;function Va(t){return Ia(t)?Fa(t):sf(t)}a(Va,"keys");var Qn=Va;function Ga(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}a(Ga,"nativeKeysIn");var af=Ga,of=Object.prototype,lf=of.hasOwnProperty;function Ja(t){if(!nt(t))return af(t);var e=Ca(t),r=[];for(var n in t)n=="constructor"&&(e||!lf.call(t,n))||r.push(n);return r}a(Ja,"baseKeysIn");var cf=Ja;function Xa(t){return Ia(t)?Fa(t,!0):cf(t)}a(Xa,"keysIn");var uf=Xa,df=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,pf=/^\w*$/;function Ya(t,e){if(ge(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||Vn(t)?!0:pf.test(t)||!df.test(t)||e!=null&&t in Object(e)}a(Ya,"isKey");var es=Ya,ff=Ke(Object,"create"),Rt=ff;function Qa(){this.__data__=Rt?Rt(null):{},this.size=0}a(Qa,"hashClear");var gf=Qa;function eo(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}a(eo,"hashDelete");var hf=eo,mf="__lodash_hash_undefined__",yf=Object.prototype,vf=yf.hasOwnProperty;function to(t){var e=this.__data__;if(Rt){var r=e[t];return r===mf?void 0:r}return vf.call(e,t)?e[t]:void 0}a(to,"hashGet");var _f=to,Tf=Object.prototype,bf=Tf.hasOwnProperty;function ro(t){var e=this.__data__;return Rt?e[t]!==void 0:bf.call(e,t)}a(ro,"hashHas");var wf=ro,Pf="__lodash_hash_undefined__";function no(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Rt&&e===void 0?Pf:e,this}a(no,"hashSet");var xf=no;function Ue(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}a(Ue,"Hash");Ue.prototype.clear=gf;Ue.prototype.delete=hf;Ue.prototype.get=_f;Ue.prototype.has=wf;Ue.prototype.set=xf;var oi=Ue;function so(){this.__data__=[],this.size=0}a(so,"listCacheClear");var kf=so;function io(t,e){for(var r=t.length;r--;)if(Xn(t[r][0],e))return r;return-1}a(io,"assocIndexOf");var Vr=io,Sf=Array.prototype,Of=Sf.splice;function ao(t){var e=this.__data__,r=Vr(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():Of.call(e,r,1),--this.size,!0}a(ao,"listCacheDelete");var Ef=ao;function oo(t){var e=this.__data__,r=Vr(e,t);return r<0?void 0:e[r][1]}a(oo,"listCacheGet");var Zf=oo;function lo(t){return Vr(this.__data__,t)>-1}a(lo,"listCacheHas");var If=lo;function co(t,e){var r=this.__data__,n=Vr(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this}a(co,"listCacheSet");var Bf=co;function ze(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}a(ze,"ListCache");ze.prototype.clear=kf;ze.prototype.delete=Ef;ze.prototype.get=Zf;ze.prototype.has=If;ze.prototype.set=Bf;var Gr=ze,Cf=Ke(he,"Map"),Ht=Cf;function uo(){this.size=0,this.__data__={hash:new oi,map:new(Ht||Gr),string:new oi}}a(uo,"mapCacheClear");var Af=uo;function po(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}a(po,"isKeyable");var Rf=po;function fo(t,e){var r=t.__data__;return Rf(e)?r[typeof e=="string"?"string":"hash"]:r.map}a(fo,"getMapData");var Jr=fo;function go(t){var e=Jr(this,t).delete(t);return this.size-=e?1:0,e}a(go,"mapCacheDelete");var Hf=go;function ho(t){return Jr(this,t).get(t)}a(ho,"mapCacheGet");var Df=ho;function mo(t){return Jr(this,t).has(t)}a(mo,"mapCacheHas");var Mf=mo;function yo(t,e){var r=Jr(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this}a(yo,"mapCacheSet");var Nf=yo;function Fe(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}a(Fe,"MapCache");Fe.prototype.clear=Af;Fe.prototype.delete=Hf;Fe.prototype.get=Df;Fe.prototype.has=Mf;Fe.prototype.set=Nf;var Xr=Fe,$f="Expected a function";function Yr(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError($f);var r=a(function(){var n=arguments,s=e?e.apply(this,n):n[0],i=r.cache;if(i.has(s))return i.get(s);var o=t.apply(this,n);return r.cache=i.set(s,o)||i,o},"memoized");return r.cache=new(Yr.Cache||Xr),r}a(Yr,"memoize");Yr.Cache=Xr;var jf=Yr,Kf=500;function vo(t){var e=jf(t,function(n){return r.size===Kf&&r.clear(),n}),r=e.cache;return e}a(vo,"memoizeCapped");var Uf=vo,zf=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ff=/\\(\\)?/g,Lf=Uf(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(zf,function(r,n,s,i){e.push(s?i.replace(Ff,"$1"):n||r)}),e}),Wf=Lf;function _o(t){return t==null?"":jd(t)}a(_o,"toString");var qf=_o;function To(t,e){return ge(t)?t:es(t,e)?[t]:Wf(qf(t))}a(To,"castPath");var Qr=To,Vf=1/0;function bo(t){if(typeof t=="string"||Vn(t))return t;var e=t+"";return e=="0"&&1/t==-Vf?"-0":e}a(bo,"toKey");var jt=bo;function wo(t,e){e=Qr(e,t);for(var r=0,n=e.length;t!=null&&r<n;)t=t[jt(e[r++])];return r&&r==n?t:void 0}a(wo,"baseGet");var ts=wo;function Po(t,e,r){var n=t==null?void 0:ts(t,e);return n===void 0?r:n}a(Po,"get");var Gf=Po;function xo(t,e){for(var r=-1,n=e.length,s=t.length;++r<n;)t[s+r]=e[r];return t}a(xo,"arrayPush");var ko=xo,Jf=Wa(Object.getPrototypeOf,Object),So=Jf,Xf="[object Object]",Yf=Function.prototype,Qf=Object.prototype,Oo=Yf.toString,eg=Qf.hasOwnProperty,tg=Oo.call(Object);function Eo(t){if(!He(t)||$e(t)!=Xf)return!1;var e=So(t);if(e===null)return!0;var r=eg.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&Oo.call(r)==tg}a(Eo,"isPlainObject");var li=Eo;function Zo(){this.__data__=new Gr,this.size=0}a(Zo,"stackClear");var rg=Zo;function Io(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}a(Io,"stackDelete");var ng=Io;function Bo(t){return this.__data__.get(t)}a(Bo,"stackGet");var sg=Bo;function Co(t){return this.__data__.has(t)}a(Co,"stackHas");var ig=Co,ag=200;function Ao(t,e){var r=this.__data__;if(r instanceof Gr){var n=r.__data__;if(!Ht||n.length<ag-1)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Xr(n)}return r.set(t,e),this.size=r.size,this}a(Ao,"stackSet");var og=Ao;function Le(t){var e=this.__data__=new Gr(t);this.size=e.size}a(Le,"Stack");Le.prototype.clear=rg;Le.prototype.delete=ng;Le.prototype.get=sg;Le.prototype.has=ig;Le.prototype.set=og;var er=Le;function Ro(t,e){for(var r=-1,n=t==null?0:t.length,s=0,i=[];++r<n;){var o=t[r];e(o,r,t)&&(i[s++]=o)}return i}a(Ro,"arrayFilter");var lg=Ro;function Ho(){return[]}a(Ho,"stubArray");var Do=Ho,cg=Object.prototype,ug=cg.propertyIsEnumerable,ci=Object.getOwnPropertySymbols,dg=ci?function(t){return t==null?[]:(t=Object(t),lg(ci(t),function(e){return ug.call(t,e)}))}:Do,Mo=dg,pg=Object.getOwnPropertySymbols,fg=pg?function(t){for(var e=[];t;)ko(e,Mo(t)),t=So(t);return e}:Do,gg=fg;function No(t,e,r){var n=e(t);return ge(t)?n:ko(n,r(t))}a(No,"baseGetAllKeys");var $o=No;function jo(t){return $o(t,Qn,Mo)}a(jo,"getAllKeys");var ui=jo;function Ko(t){return $o(t,uf,gg)}a(Ko,"getAllKeysIn");var hg=Ko,mg=Ke(he,"DataView"),Nn=mg,yg=Ke(he,"Promise"),$n=yg,vg=Ke(he,"Set"),jn=vg,di="[object Map]",_g="[object Object]",pi="[object Promise]",fi="[object Set]",gi="[object WeakMap]",hi="[object DataView]",Tg=je(Nn),bg=je(Ht),wg=je($n),Pg=je(jn),xg=je(Dn),Ze=$e;(Nn&&Ze(new Nn(new ArrayBuffer(1)))!=hi||Ht&&Ze(new Ht)!=di||$n&&Ze($n.resolve())!=pi||jn&&Ze(new jn)!=fi||Dn&&Ze(new Dn)!=gi)&&(Ze=a(function(t){var e=$e(t),r=e==_g?t.constructor:void 0,n=r?je(r):"";if(n)switch(n){case Tg:return hi;case bg:return di;case wg:return pi;case Pg:return fi;case xg:return gi}return e},"getTag"));var mi=Ze,kg=he.Uint8Array,yi=kg,Sg="__lodash_hash_undefined__";function Uo(t){return this.__data__.set(t,Sg),this}a(Uo,"setCacheAdd");var Og=Uo;function zo(t){return this.__data__.has(t)}a(zo,"setCacheHas");var Eg=zo;function Dt(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new Xr;++e<r;)this.add(t[e])}a(Dt,"SetCache");Dt.prototype.add=Dt.prototype.push=Og;Dt.prototype.has=Eg;var Zg=Dt;function Fo(t,e){for(var r=-1,n=t==null?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}a(Fo,"arraySome");var Ig=Fo;function Lo(t,e){return t.has(e)}a(Lo,"cacheHas");var Bg=Lo,Cg=1,Ag=2;function Wo(t,e,r,n,s,i){var o=r&Cg,l=t.length,u=e.length;if(l!=u&&!(o&&u>l))return!1;var f=i.get(t),g=i.get(e);if(f&&g)return f==e&&g==t;var m=-1,P=!0,E=r&Ag?new Zg:void 0;for(i.set(t,e),i.set(e,t);++m<l;){var I=t[m],U=e[m];if(n)var W=o?n(U,I,m,e,t,i):n(I,U,m,t,e,i);if(W!==void 0){if(W)continue;P=!1;break}if(E){if(!Ig(e,function(Q,ie){if(!Bg(E,ie)&&(I===Q||s(I,Q,r,n,i)))return E.push(ie)})){P=!1;break}}else if(!(I===U||s(I,U,r,n,i))){P=!1;break}}return i.delete(t),i.delete(e),P}a(Wo,"equalArrays");var qo=Wo;function Vo(t){var e=-1,r=Array(t.size);return t.forEach(function(n,s){r[++e]=[s,n]}),r}a(Vo,"mapToArray");var Rg=Vo;function Go(t){var e=-1,r=Array(t.size);return t.forEach(function(n){r[++e]=n}),r}a(Go,"setToArray");var Hg=Go,Dg=1,Mg=2,Ng="[object Boolean]",$g="[object Date]",jg="[object Error]",Kg="[object Map]",Ug="[object Number]",zg="[object RegExp]",Fg="[object Set]",Lg="[object String]",Wg="[object Symbol]",qg="[object ArrayBuffer]",Vg="[object DataView]",vi=Te?Te.prototype:void 0,Zn=vi?vi.valueOf:void 0;function Jo(t,e,r,n,s,i,o){switch(r){case Vg:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case qg:return!(t.byteLength!=e.byteLength||!i(new yi(t),new yi(e)));case Ng:case $g:case Ug:return Xn(+t,+e);case jg:return t.name==e.name&&t.message==e.message;case zg:case Lg:return t==e+"";case Kg:var l=Rg;case Fg:var u=n&Dg;if(l||(l=Hg),t.size!=e.size&&!u)return!1;var f=o.get(t);if(f)return f==e;n|=Mg,o.set(t,e);var g=qo(l(t),l(e),n,s,i,o);return o.delete(t),g;case Wg:if(Zn)return Zn.call(t)==Zn.call(e)}return!1}a(Jo,"equalByTag");var Gg=Jo,Jg=1,Xg=Object.prototype,Yg=Xg.hasOwnProperty;function Xo(t,e,r,n,s,i){var o=r&Jg,l=ui(t),u=l.length,f=ui(e),g=f.length;if(u!=g&&!o)return!1;for(var m=u;m--;){var P=l[m];if(!(o?P in e:Yg.call(e,P)))return!1}var E=i.get(t),I=i.get(e);if(E&&I)return E==e&&I==t;var U=!0;i.set(t,e),i.set(e,t);for(var W=o;++m<u;){P=l[m];var Q=t[P],ie=e[P];if(n)var q=o?n(ie,Q,P,e,t,i):n(Q,ie,P,t,e,i);if(!(q===void 0?Q===ie||s(Q,ie,r,n,i):q)){U=!1;break}W||(W=P=="constructor")}if(U&&!W){var se=t.constructor,Ge=e.constructor;se!=Ge&&"constructor"in t&&"constructor"in e&&!(typeof se=="function"&&se instanceof se&&typeof Ge=="function"&&Ge instanceof Ge)&&(U=!1)}return i.delete(t),i.delete(e),U}a(Xo,"equalObjects");var Qg=Xo,eh=1,_i="[object Arguments]",Ti="[object Array]",Yt="[object Object]",th=Object.prototype,bi=th.hasOwnProperty;function Yo(t,e,r,n,s,i){var o=ge(t),l=ge(e),u=o?Ti:mi(t),f=l?Ti:mi(e);u=u==_i?Yt:u,f=f==_i?Yt:f;var g=u==Yt,m=f==Yt,P=u==f;if(P&&Mn(t)){if(!Mn(e))return!1;o=!0,g=!1}if(P&&!g)return i||(i=new er),o||Ua(t)?qo(t,e,r,n,s,i):Gg(t,e,u,r,n,s,i);if(!(r&eh)){var E=g&&bi.call(t,"__wrapped__"),I=m&&bi.call(e,"__wrapped__");if(E||I){var U=E?t.value():t,W=I?e.value():e;return i||(i=new er),s(U,W,r,n,i)}}return P?(i||(i=new er),Qg(t,e,r,n,s,i)):!1}a(Yo,"baseIsEqualDeep");var rh=Yo;function rs(t,e,r,n,s){return t===e?!0:t==null||e==null||!He(t)&&!He(e)?t!==t&&e!==e:rh(t,e,r,n,rs,s)}a(rs,"baseIsEqual");var en=rs,nh=1,sh=2;function Qo(t,e,r,n){var s=r.length,i=s,o=!n;if(t==null)return!i;for(t=Object(t);s--;){var l=r[s];if(o&&l[2]?l[1]!==t[l[0]]:!(l[0]in t))return!1}for(;++s<i;){l=r[s];var u=l[0],f=t[u],g=l[1];if(o&&l[2]){if(f===void 0&&!(u in t))return!1}else{var m=new er;if(n)var P=n(f,g,u,t,e,m);if(!(P===void 0?en(g,f,nh|sh,n,m):P))return!1}}return!0}a(Qo,"baseIsMatch");var ih=Qo;function el(t){return t===t&&!nt(t)}a(el,"isStrictComparable");var tl=el;function rl(t){for(var e=Qn(t),r=e.length;r--;){var n=e[r],s=t[n];e[r]=[n,s,tl(s)]}return e}a(rl,"getMatchData");var ah=rl;function nl(t,e){return function(r){return r==null?!1:r[t]===e&&(e!==void 0||t in Object(r))}}a(nl,"matchesStrictComparable");var sl=nl;function il(t){var e=ah(t);return e.length==1&&e[0][2]?sl(e[0][0],e[0][1]):function(r){return r===t||ih(r,t,e)}}a(il,"baseMatches");var oh=il;function al(t,e){return t!=null&&e in Object(t)}a(al,"baseHasIn");var lh=al;function ol(t,e,r){e=Qr(e,t);for(var n=-1,s=e.length,i=!1;++n<s;){var o=jt(e[n]);if(!(i=t!=null&&r(t,o)))break;t=t[o]}return i||++n!=s?i:(s=t==null?0:t.length,!!s&&Yn(s)&&Jn(o,s)&&(ge(t)||Da(t)))}a(ol,"hasPath");var ch=ol;function ll(t,e){return t!=null&&ch(t,e,lh)}a(ll,"hasIn");var uh=ll,dh=1,ph=2;function cl(t,e){return es(t)&&tl(e)?sl(jt(t),e):function(r){var n=Gf(r,t);return n===void 0&&n===e?uh(r,t):en(e,n,dh|ph)}}a(cl,"baseMatchesProperty");var fh=cl;function ul(t){return function(e){return e?.[t]}}a(ul,"baseProperty");var gh=ul;function dl(t){return function(e){return ts(e,t)}}a(dl,"basePropertyDeep");var hh=dl;function pl(t){return es(t)?gh(jt(t)):hh(t)}a(pl,"property");var mh=pl;function fl(t){return typeof t=="function"?t:t==null?Kd:typeof t=="object"?ge(t)?fh(t[0],t[1]):oh(t):mh(t)}a(fl,"baseIteratee");var ns=fl;function gl(t){return function(e,r,n){for(var s=-1,i=Object(e),o=n(e),l=o.length;l--;){var u=o[t?l:++s];if(r(i[u],u,i)===!1)break}return e}}a(gl,"createBaseFor");var yh=gl,vh=yh(),_h=vh;function hl(t,e){return t&&_h(t,e,Qn)}a(hl,"baseForOwn");var Th=hl;function ml(t,e){return en(t,e)}a(ml,"isEqual");var tt=ml;function yl(t,e,r){r=typeof r=="function"?r:void 0;var n=r?r(t,e):void 0;return n===void 0?en(t,e,void 0,r):!!n}a(yl,"isEqualWith");var bh=yl;function vl(t){return t===void 0}a(vl,"isUndefined");var wi=vl;function _l(t,e){var r={};return e=ns(e,3),Th(t,function(n,s,i){ka(r,s,e(n,s,i))}),r}a(_l,"mapValues");var wh=_l,Ph="Expected a function";function Tl(t){if(typeof t!="function")throw new TypeError(Ph);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}a(Tl,"negate");var xh=Tl;function bl(t,e,r,n){if(!nt(t))return t;e=Qr(e,t);for(var s=-1,i=e.length,o=i-1,l=t;l!=null&&++s<i;){var u=jt(e[s]),f=r;if(u==="__proto__"||u==="constructor"||u==="prototype")return t;if(s!=o){var g=l[u];f=n?n(g,u,l):void 0,f===void 0&&(f=nt(g)?g:Jn(e[s+1])?[]:{})}dp(l,u,f),l=l[u]}return t}a(bl,"baseSet");var kh=bl;function wl(t,e,r){for(var n=-1,s=e.length,i={};++n<s;){var o=e[n],l=ts(t,o);r(l,o)&&kh(i,Qr(o,t),l)}return i}a(wl,"basePickBy");var Sh=wl;function Pl(t,e){if(t==null)return{};var r=fa(hg(t),function(n){return[n]});return e=ns(e),Sh(t,r,function(n,s){return e(n,s[0])})}a(Pl,"pickBy");var Oh=Pl;function xl(t,e){return Oh(t,xh(ns(e)))}a(xl,"omitBy");var Pi=xl,Eh=a(t=>{let e=t.checks;return e.length===0?"":e.map(Zh).join("")},"generateStringChecks"),Zh=a(t=>{switch(t.kind){case"min":return`.min(${T(t.value)}, ${T(t.message)})`;case"max":return`.max(${T(t.value)}, ${T(t.message)})`;case"length":return`.length(${T(t.value)}, ${T(t.message)})`;case"email":return`.email(${T(t.message)})`;case"url":return`.url(${T(t.message)})`;case"emoji":return`.emoji(${T(t.message)})`;case"uuid":return`.uuid(${T(t.message)})`;case"cuid":return`.cuid(${T(t.message)})`;case"cuid2":return`.cuid2(${T(t.message)})`;case"ulid":return`.ulid(${T(t.message)})`;case"includes":let e=et({message:t.message,position:t.position});return`.includes(${T(t.value)}, ${e})`;case"startsWith":return`.startsWith(${T(t.value)}, ${T(t.message)})`;case"endsWith":return`.endsWith(${T(t.value)}, ${T(t.message)})`;case"regex":return`.regex(${String(t.regex)}, ${T(t.message)})`;case"trim":return".trim()";case"toLowerCase":return".toLowerCase()";case"toUpperCase":return".toUpperCase()";case"datetime":let n=t.precision===null?void 0:t.precision;return`.datetime(${et({message:t.message,precision:n,offset:t.offset})})`;case"ip":return`.ip(${et({message:t.message,version:t.version})})`;default:return""}},"_generateStringCheck"),Ih=a(t=>{let e=t.checks;return e.length===0?"":e.map(Bh).join("")},"generateNumberChecks"),Bh=a(t=>{switch(t.kind){case"min":return`.min(${T(t.value)}, ${T(t.message)})`;case"max":return`.max(${T(t.value)}, ${T(t.message)})`;case"int":return`.int(${T(t.message)})`;case"multipleOf":return`.multipleOf(${T(t.value)}, ${T(t.message)})`;case"finite":return`.finite(${T(t.message)})`;default:return""}},"_generateNumberCheck"),Ch=a(t=>{let e=t.checks;return e.length===0?"":e.map(Ah).join("")},"generateBigIntChecks"),Ah=a(t=>{switch(t.kind){case"min":return`.min(${T(t.value)}, ${T(t.message)})`;case"max":return`.max(${T(t.value)}, ${T(t.message)})`;case"multipleOf":return`.multipleOf(${T(t.value)}, ${T(t.message)})`;default:return""}},"_generateBigIntCheck"),Rh=a(t=>{let e=t.checks;return e.length===0?"":e.map(Hh).join("")},"generateDateChecks"),Hh=a(t=>{switch(t.kind){case"min":return`.min(${xi(t.value)}, ${T(t.message)})`;case"max":return`.max(${xi(t.value)}, ${T(t.message)})`;default:return""}},"_generateDateCheck"),xi=a(t=>`new Date(${t})`,"dateTs"),Dh=a(t=>{let e=[];if(t.exactLength){let{value:r,message:n}=t.exactLength;e.push(`.length(${T(r)}, ${T(n)})`)}if(t.minLength){let{value:r,message:n}=t.minLength;e.push(`.min(${T(r)}, ${T(n)})`)}if(t.maxLength){let{value:r,message:n}=t.maxLength;e.push(`.max(${T(r)}, ${T(n)})`)}return e.join("")},"generateArrayChecks"),Mh=a(t=>{let e=[];if(t.minSize){let{value:r,message:n}=t.minSize;e.push(`.min(${T(r)}, ${T(n)})`)}if(t.maxSize){let{value:r,message:n}=t.maxSize;e.push(`.max(${T(r)}, ${T(n)})`)}return e.join("")},"generateSetChecks");function ss(t){return N(t)}a(ss,"toTypescriptSchema");function N(t){let r=t._def;switch(r.typeName){case d.ZodFirstPartyTypeKind.ZodString:return`z.string()${Eh(r)}${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodNumber:return`z.number()${Ih(r)}${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodNaN:return`z.nan()${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodBigInt:return`z.bigint()${Ch(r)}${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodBoolean:return`z.boolean()${R(r)}${A(t._def)}`.trim();case d.ZodFirstPartyTypeKind.ZodDate:return`z.date()${Rh(r)}${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodUndefined:return`z.undefined()${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodNull:return`z.null()${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodAny:return`z.any()${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodUnknown:return`z.unknown()${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodNever:return`z.never()${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodVoid:return`z.void()${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodArray:return`z.array(${N(r.type)})${Dh(r)}${R(r)}${A(r)}`;case d.ZodFirstPartyTypeKind.ZodObject:let n=wh(r.shape(),N),s=t.additionalProperties(),i=s?`.catchall(${N(s)})`:"";return["z.object({",...Object.entries(n).map(([cd,ud])=>` ${cd}: ${ud},`),`})${i}${R(r)}${A(r)}`].join(`
11
- `).trim();case d.ZodFirstPartyTypeKind.ZodUnion:return`z.union([${r.options.map(N).join(", ")}])${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:let l=r.options.map(N);return`z.discriminatedUnion(${T(r.discriminator)}, [${l.join(", ")}])${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodIntersection:let f=N(r.left),g=N(r.right);return`z.intersection(${f}, ${g})${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodTuple:return`z.tuple([${r.items.map(N).join(", ")}])${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodRecord:let P=N(r.keyType),E=N(r.valueType);return`z.record(${P}, ${E})${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodMap:let I=N(r.keyType),U=N(r.valueType);return`z.map(${I}, ${U})${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodSet:return`z.set(${N(r.valueType)})${Mh(r)}${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodFunction:let W=r.args.items.map(N),Q=W.length?`.args(${W.join(", ")})`:"",ie=N(r.returns);return`z.function()${Q}.returns(${ie})${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodLazy:return`z.lazy(() => ${N(r.getter())})${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodLiteral:return`z.literal(${T(r.value)})${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodEnum:return`z.enum([${r.values.map(T).join(", ")}])${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodEffects:throw new Ee(d.ZodFirstPartyTypeKind.ZodEffects);case d.ZodFirstPartyTypeKind.ZodNativeEnum:throw new Ee(d.ZodFirstPartyTypeKind.ZodNativeEnum);case d.ZodFirstPartyTypeKind.ZodOptional:return`z.optional(${N(r.innerType)})${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodNullable:return`z.nullable(${N(r.innerType)})${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodDefault:let Ge=et(r.defaultValue());return`z.default(${N(r.innerType)}, ${Ge})${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodCatch:throw new Ee(d.ZodFirstPartyTypeKind.ZodCatch);case d.ZodFirstPartyTypeKind.ZodPromise:return`z.promise(${N(r.type)})${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodBranded:throw new Ee(d.ZodFirstPartyTypeKind.ZodBranded);case d.ZodFirstPartyTypeKind.ZodPipeline:throw new Ee(d.ZodFirstPartyTypeKind.ZodPipeline);case d.ZodFirstPartyTypeKind.ZodSymbol:throw new Ee(d.ZodFirstPartyTypeKind.ZodSymbol);case d.ZodFirstPartyTypeKind.ZodReadonly:return`z.readonly(${N(r.innerType)})${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodRef:return`z.ref(${T(r.uri)})${R(r)}${A(r)}`.trim();default:Z.assertNever(r)}}a(N,"sUnwrapZod");var A=a(t=>t.description?`.describe(${T(t.description)})`:"","_maybeDescribe"),R=a(t=>`${Nh(t)}${$h(t)}${jh(t)}${Kh(t)}${Uh(t)}${zh(t)}${Fh(t)}`,"_addZuiExtensions"),Nh=a(t=>{var e;return(e=t[b])!=null&&e.title?`.title(${T(t[b].title)})`:""},"_maybeTitle"),$h=a(t=>{var e;return(e=t[b])!=null&&e.displayAs?`.displayAs(${Ri({id:t[b].displayAs[0],params:t[b].displayAs[1]})})`:""},"_maybeDisplayAs"),jh=a(t=>{var e;return(e=t[b])!=null&&e.disabled?`.disabled(${t[b].disabled})`:""},"_maybeDisabled"),Kh=a(t=>{var e;return(e=t[b])!=null&&e.hidden?`.hidden(${t[b].hidden})`:""},"_maybeHidden"),Uh=a(t=>{var e;return(e=t[b])!=null&&e.placeholder?`.placeholder(${T(t[b].placeholder)})`:""},"_maybePlaceholder"),zh=a(t=>{var e;return(e=t[b])!=null&&e.secret?".secret()":""},"_maybeSecret"),Fh=a(t=>{var e;let r=["title","tooltip","displayAs","disabled","hidden","placeholder","secret","coerce"],n=Object.entries((e=t[b])!=null?e:{}).filter(([s])=>!r.includes(s));return n.length>0?`.metadata(${Ri(Object.fromEntries(n))})`:""},"_maybeSetMetadata"),Lh=a(t=>{let e={type:"number",description:t.description,"x-zui":t._def["x-zui"]};t._def[b]&&(e[b]=t._def[b]);for(let r of t._def.checks)switch(r.kind){case"min":{let n=r.inclusive?"minimum":"exclusiveMinimum",s=r.inclusive?"exclusiveMinimum":"minimum";e[n]=r.value,delete e[s];break}case"max":{let n=r.inclusive?"maximum":"exclusiveMaximum",s=r.inclusive?"exclusiveMaximum":"maximum";e[n]=r.value,delete e[s];break}case"int":e.type="integer";break;case"finite":{e.format="finite";break}case"multipleOf":e.multipleOf=r.value;break;default:}return e},"zodNumberToJsonNumber"),kl="\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}",Sl="(([+-]\\d{2}(:?\\d{2})?)|Z)",Wh="Z",Ol="(\\.\\d+)?",Kn="\\.\\d{",qh="}",El=a(t=>{let e=t.precision?Kn+t.precision+qh:t.precision===0?"":Ol,r=t.offset?Sl:Wh;return new RegExp(`^${kl}${e}${r}$`)},"generateDatetimeRegex"),Vh=a(t=>({precision:Gh(t),offset:t.endsWith(`${Sl}$`)}),"extractPrecisionAndOffset"),Gh=a(t=>{let e=t.slice(1+kl.length);return e.startsWith(Ol)?null:e.startsWith(Kn)?parseInt(e.slice(Kn.length)):0},"_extractPrecision"),At={};Fr(At,{escapeSpecialChars:()=>Jh});var Jh=a(t=>t.replaceAll(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeSpecialChars");function is(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage=p(c({},t.errorMessage),{[e]:r}))}a(is,"addErrorMessage");function H(t,e,r,n,s){t[e]=r,is(t,e,n,s)}a(H,"setResponseValueAndErrors");var j={cuid:"^[cC][^\\s-]{8,}$",cuid2:"^[a-z][a-z0-9]*$",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:"^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",uuid:"^[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}$",ipv4:"^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$",ipv6:"^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$"};function as(t,e){let r=c({type:"string"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});function n(s){return e.patternStrategy==="escape"?At.escapeSpecialChars(s):s}if(a(n,"processPattern"),t.checks)for(let s of t.checks)switch(s.kind){case"min":H(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,s.value):s.value,s.message,e);break;case"max":H(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,s.value):s.value,s.message,e);break;case"email":switch(e.emailStrategy){case"format:email":Oe(r,"email",s.message,e);break;case"format:idn-email":Oe(r,"idn-email",s.message,e);break;case"pattern:zod":ue(r,j.email,s.message,e);break}break;case"url":Oe(r,"uri",s.message,e);break;case"uuid":Oe(r,"uuid",s.message,e);break;case"regex":ue(r,s.regex.source,s.message,e);break;case"cuid":ue(r,j.cuid,s.message,e);break;case"cuid2":ue(r,j.cuid2,s.message,e);break;case"startsWith":ue(r,"^"+n(s.value),s.message,e);break;case"endsWith":ue(r,n(s.value)+"$",s.message,e);break;case"datetime":Oe(r,"date-time",s.message,e);break;case"length":H(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,s.value):s.value,s.message,e),H(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,s.value):s.value,s.message,e);break;case"includes":{ue(r,n(s.value),s.message,e);break}case"ip":{s.version!=="v6"&&Oe(r,"ipv4",s.message,e),s.version!=="v4"&&Oe(r,"ipv6",s.message,e);break}case"emoji":ue(r,j.emoji,s.message,e);break;case"ulid":{ue(r,j.ulid,s.message,e);break}case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}a(as,"parseStringDef");var Oe=a((t,e,r,n)=>{var s;t.format||(s=t.anyOf)!=null&&s.some(i=>i.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push(c({format:t.format},t.errorMessage&&n.errorMessages&&{errorMessage:{format:t.errorMessage.format}})),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push(c({format:e},r&&n.errorMessages&&{errorMessage:{format:r}}))):H(t,"format",e,r,n)},"addFormat"),ue=a((t,e,r,n)=>{var s;t.pattern||(s=t.allOf)!=null&&s.some(i=>i.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push(c({pattern:t.pattern},t.errorMessage&&n.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}})),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push(c({pattern:e},r&&n.errorMessages&&{errorMessage:{pattern:r}}))):H(t,"pattern",e,r,n)},"addPattern"),Xh=a(t=>{let e={type:"string",description:t.description,"x-zui":t._def["x-zui"]};t._def[b]&&(e[b]=t._def[b]);for(let r of t._def.checks)switch(r.kind){case"cuid":e.format="cuid",e.pattern=j.cuid;break;case"cuid2":e.format="cuid2",e.pattern=j.cuid2;break;case"ulid":e.format="ulid",e.pattern=j.ulid;break;case"uuid":e.format="uuid",e.pattern=j.uuid;break;case"emoji":e.format="emoji",e.pattern=j.emoji;break;case"email":e.format="email",e.pattern=j.email;break;case"ip":e.format=r.version==="v6"?"ipv6":"ipv4",e.pattern=r.version==="v6"?j.ipv6:j.ipv4;break;case"datetime":e.format="date-time",e.pattern=El(r).source,e[b]=p(c({},e[b]),{precision:r.precision,offset:r.offset});break;case"url":e.format="uri";break;case"endsWith":e.pattern=`${At.escapeSpecialChars(r.value)}$`;break;case"startsWith":e.pattern=`^${At.escapeSpecialChars(r.value)}`;break;case"includes":let n=r.position&&r.position>=1?`^(?:.{${r.position}}).*`:"";e.pattern=`${n}${At.escapeSpecialChars(r.value)}`;break;case"regex":e.pattern=r.regex.source;break;case"length":e.minLength=e.maxLength=Math.max(0,r.value);break;case"min":e.minLength=Math.max(0,r.value);break;case"max":e.maxLength=Math.max(0,r.value);break;default:throw new zi({zodType:d.ZodFirstPartyTypeKind.ZodString,checkKind:r.kind})}return e},"zodStringToJsonString"),Yh=a((t,e)=>{let r={type:"array",description:t.description,items:e(t._def.type),"x-zui":t._def["x-zui"]};return t._def[b]&&(r[b]=t._def[b]),t._def.minLength&&(r.minItems=t._def.minLength.value),t._def.maxLength&&(r.maxItems=t._def.maxLength.value),t._def.exactLength&&(r.minItems=t._def.exactLength.value,r.maxItems=t._def.exactLength.value),r},"zodArrayToJsonArray"),Qh=a((t,e)=>{let r={type:"array",description:t.description,uniqueItems:!0,items:e(t._def.valueType),"x-zui":t._def["x-zui"]};return t._def[b]&&(r[b]=t._def[b]),t._def.minSize&&(r.minItems=t._def.minSize.value),t._def.maxSize&&(r.maxItems=t._def.maxSize.value),r},"zodSetToJsonSet"),em=a((t,e)=>{let r={type:"array",description:t.description,items:t._def.items.map(n=>e(n))};return t._def[b]&&(r[b]=t._def[b]),t._def.rest&&(r.additionalItems=e(t._def.rest)),r},"zodTupleToJsonTuple");function V(t){let e=t,r=e._def;switch(r.typeName){case d.ZodFirstPartyTypeKind.ZodString:return Xh(e);case d.ZodFirstPartyTypeKind.ZodNumber:return Lh(e);case d.ZodFirstPartyTypeKind.ZodNaN:throw new ee(d.ZodFirstPartyTypeKind.ZodNaN);case d.ZodFirstPartyTypeKind.ZodBigInt:throw new ee(d.ZodFirstPartyTypeKind.ZodBigInt,{suggestedAlternative:"serialize bigint to string"});case d.ZodFirstPartyTypeKind.ZodBoolean:return{type:"boolean",description:r.description,"x-zui":r["x-zui"]};case d.ZodFirstPartyTypeKind.ZodDate:throw new ee(d.ZodFirstPartyTypeKind.ZodDate,{suggestedAlternative:"use z.string().datetime() instead"});case d.ZodFirstPartyTypeKind.ZodUndefined:return In(r);case d.ZodFirstPartyTypeKind.ZodNull:return Bn(r);case d.ZodFirstPartyTypeKind.ZodAny:return{description:r.description,"x-zui":r["x-zui"]};case d.ZodFirstPartyTypeKind.ZodUnknown:return{description:r.description,"x-zui":p(c({},r["x-zui"]),{def:{typeName:d.ZodFirstPartyTypeKind.ZodUnknown}})};case d.ZodFirstPartyTypeKind.ZodNever:return{not:!0,description:r.description,"x-zui":r["x-zui"]};case d.ZodFirstPartyTypeKind.ZodVoid:throw new ee(d.ZodFirstPartyTypeKind.ZodVoid);case d.ZodFirstPartyTypeKind.ZodArray:return Yh(e,V);case d.ZodFirstPartyTypeKind.ZodObject:let n=Object.entries(r.shape()),s=n.filter(([g,m])=>!m.isOptional()),i=s.length?s.map(([g])=>g):void 0,o=n.map(([g,m])=>[g,m.mandatory()]).map(([g,m])=>[g,V(m)]),l=!1;return r.unknownKeys instanceof d.ZodType?l=V(r.unknownKeys):r.unknownKeys==="passthrough"&&(l=!0),{type:"object",description:r.description,properties:Object.fromEntries(o),required:i,additionalProperties:l,"x-zui":r["x-zui"]};case d.ZodFirstPartyTypeKind.ZodUnion:return{description:r.description,anyOf:r.options.map(g=>V(g)),"x-zui":r["x-zui"]};case d.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:return{description:r.description,anyOf:r.options.map(g=>V(g)),"x-zui":r["x-zui"]};case d.ZodFirstPartyTypeKind.ZodIntersection:let u=V(r.left),f=V(r.right);return"additionalProperties"in u&&delete u.additionalProperties,"additionalProperties"in f&&delete f.additionalProperties,{description:r.description,allOf:[u,f],"x-zui":r["x-zui"]};case d.ZodFirstPartyTypeKind.ZodTuple:return em(e,V);case d.ZodFirstPartyTypeKind.ZodRecord:return{type:"object",description:r.description,additionalProperties:V(r.valueType),"x-zui":r["x-zui"]};case d.ZodFirstPartyTypeKind.ZodMap:throw new ee(d.ZodFirstPartyTypeKind.ZodMap);case d.ZodFirstPartyTypeKind.ZodSet:return Qh(e,V);case d.ZodFirstPartyTypeKind.ZodFunction:throw new ee(d.ZodFirstPartyTypeKind.ZodFunction);case d.ZodFirstPartyTypeKind.ZodLazy:throw new ee(d.ZodFirstPartyTypeKind.ZodLazy);case d.ZodFirstPartyTypeKind.ZodLiteral:if(typeof r.value=="string")return{type:"string",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(typeof r.value=="number")return{type:"number",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(typeof r.value=="boolean")return{type:"boolean",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(r.value===null)return Bn(r);if(r.value===void 0)return In(r);{d.util.assertEqual(!0);let g=typeof r.value;throw new Wr(`Unsupported literal type: "${g}"`)}case d.ZodFirstPartyTypeKind.ZodEnum:return{type:"string",description:r.description,enum:r.values,"x-zui":r["x-zui"]};case d.ZodFirstPartyTypeKind.ZodEffects:throw new ee(d.ZodFirstPartyTypeKind.ZodEffects);case d.ZodFirstPartyTypeKind.ZodNativeEnum:throw new ee(d.ZodFirstPartyTypeKind.ZodNativeEnum);case d.ZodFirstPartyTypeKind.ZodOptional:return{description:r.description,anyOf:[V(r.innerType),In()],"x-zui":p(c({},r["x-zui"]),{def:{typeName:d.ZodFirstPartyTypeKind.ZodOptional}})};case d.ZodFirstPartyTypeKind.ZodNullable:return{anyOf:[V(r.innerType),Bn()],"x-zui":p(c({},r["x-zui"]),{def:{typeName:d.ZodFirstPartyTypeKind.ZodNullable}})};case d.ZodFirstPartyTypeKind.ZodDefault:return p(c({},V(r.innerType)),{default:r.defaultValue()});case d.ZodFirstPartyTypeKind.ZodCatch:throw new ee(d.ZodFirstPartyTypeKind.ZodCatch);case d.ZodFirstPartyTypeKind.ZodPromise:throw new ee(d.ZodFirstPartyTypeKind.ZodPromise);case d.ZodFirstPartyTypeKind.ZodBranded:throw new ee(d.ZodFirstPartyTypeKind.ZodBranded);case d.ZodFirstPartyTypeKind.ZodPipeline:throw new ee(d.ZodFirstPartyTypeKind.ZodPipeline);case d.ZodFirstPartyTypeKind.ZodSymbol:throw new ee(d.ZodFirstPartyTypeKind.ZodPipeline);case d.ZodFirstPartyTypeKind.ZodReadonly:return p(c({},V(r.innerType)),{readOnly:!0});case d.ZodFirstPartyTypeKind.ZodRef:return{$ref:r.uri,description:r.description,"x-zui":r["x-zui"]};default:d.util.assertNever(r)}}a(V,"toJSONSchema");var In=a(t=>({not:!0,description:t?.description,"x-zui":p(c({},t?.["x-zui"]),{def:{typeName:d.ZodFirstPartyTypeKind.ZodUndefined}})}),"undefinedSchema"),Bn=a(t=>({type:"null",description:t?.description,"x-zui":t?.["x-zui"]}),"nullSchema"),Zl=class{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};a(Zl,"ParseInputLazyPath");var ae=Zl,ki=a((t,e)=>{if(it(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new le(t.common.issues);return this._error=r,this._error}}},"handleResult"),Il=class{constructor(e){this.__type__="ZuiType",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)}get description(){return this._metadataRoot._def.description}dereference(e){return this}getReferences(){return[]}clone(){let e=this.constructor;return new e(c({},this._def))}_getType(e){return pe(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:pe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new te,ctx:{common:e.parent.common,data:e.data,parsedType:pe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Nt(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){var n;let s={common:{issues:[],async:(n=r?.async)!=null?n:!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:pe(e)},i=this._parseSync({data:e,path:s.path,parent:s});return ki(s,i)}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:pe(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(Nt(s)?s:Promise.resolve(s));return ki(n,i)}refine(e,r){let n=a(s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r,"getIssueProperties");return this._refinement((s,i)=>{let o=e(s),l=a(()=>i.addIssue(c({code:h.custom},n(s))),"setError");return typeof Promise<"u"&&o instanceof Promise?o.then(u=>u?!0:(l(),!1)):o?!0:(l(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new we({schema:this,typeName:"ZodEffects",effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return fe.create(this,this._def)}nullable(){return De.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ot.create(this,this._def)}promise(){return zt.create(this,this._def)}mandatory(){return this}or(e){return gn.create([this,e],this._def)}and(e){return on.create(this,e,this._def)}transform(e){return new we(p(c({},k(this._def)),{schema:this,typeName:"ZodEffects",effect:{type:"transform",transform:e}}))}default(e){let r=typeof e=="function"?e:()=>e;return new Kt(p(c({},k(this._def)),{innerType:this,defaultValue:r,typeName:"ZodDefault"}))}brand(){return new nn(c({typeName:"ZodBranded",type:this},k(this._def)))}catch(e){let r=typeof e=="function"?e:()=>e;return new sn(p(c({},k(this._def)),{innerType:this,catchValue:r,typeName:"ZodCatch"}))}describe(e){let r=this.clone();return r._metadataRoot._def.description=e,r}pipe(e){return fn.create(this,e)}readonly(){return Ft.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}metadata(e){var r,n,s;let i=this.clone(),o=i._metadataRoot;(s=(r=o._def)[n=b])!=null||(r[n]={});for(let[l,u]of Object.entries(e))o._def[b]=p(c({},o._def[b]),{[l]:u});return i}getMetadata(){return c({},this._metadataRoot._def[b])}setMetadata(e){this._metadataRoot._def[b]=c({},e)}get ui(){return c({},this._metadataRoot._def[b])}get _metadataRoot(){return this.naked()}displayAs(e){return this.metadata({displayAs:[e.id,e.params]})}title(e){return this.metadata({title:e})}hidden(e){let r;return e===void 0?r=!0:typeof e=="function"?r=e.toString():r=e,this.metadata({hidden:r})}disabled(e){let r;return e===void 0?r=!0:typeof e=="function"?r=e.toString():r=e,this.metadata({disabled:r})}placeholder(e){return this.metadata({placeholder:e})}toJSONSchema(){return V(this)}toTypescriptType(e){return qn(this,e)}toTypescriptSchema(){return ss(this)}naked(){return this}};a(Il,"ZodType");var O=Il,os=(t=>(t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodRef="ZodRef",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly",t))(os||{}),Z;(t=>{t.assertEqual=a(s=>s,"assertEqual");function e(s){}t.assertIs=e,a(e,"assertIs");function r(s){throw new Error("assertNever called")}t.assertNever=r,a(r,"assertNever"),t.arrayToEnum=a(s=>{let i={};for(let o of s)i[o]=o;return i},"arrayToEnum"),t.getValidEnumValues=a(s=>{let i=(0,t.objectKeys)(s).filter(l=>typeof s[s[l]]!="number"),o={};for(let l of i)o[l]=s[l];return(0,t.objectValues)(o)},"getValidEnumValues"),t.objectValues=a(s=>(0,t.objectKeys)(s).map(function(i){return s[i]}),"objectValues"),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=a((s,i)=>{for(let o of s)if(i(o))return o},"find"),t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=n,a(n,"joinValues"),t.jsonStringifyReplacer=a((s,i)=>typeof i=="bigint"?i.toString():i,"jsonStringifyReplacer"),t.compareFunctions=a((s,i)=>s.toString()===i.toString(),"compareFunctions"),t.mock=a(()=>({}),"mock")})(Z||(Z={}));var cr;(t=>{t.mergeShapes=a((e,r)=>c(c({},e),r),"mergeShapes")})(cr||(cr={}));var _=Z.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),pe=a(t=>{switch(typeof t){case"undefined":return _.undefined;case"string":return _.string;case"number":return isNaN(t)?_.nan:_.number;case"boolean":return _.boolean;case"function":return _.function;case"bigint":return _.bigint;case"symbol":return _.symbol;case"object":return Array.isArray(t)?_.array:t===null?_.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?_.promise:typeof Map<"u"&&t instanceof Map?_.map:typeof Set<"u"&&t instanceof Set?_.set:typeof Date<"u"&&t instanceof Date?_.date:_.object;default:return _.unknown}},"getParsedType");function k(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s,supportsExtensions:i,[b]:o}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);let l=o?Object.fromEntries(Object.entries(o).filter(([f])=>f!=="secret"||i?.includes("secret"))):void 0;return e?{errorMap:e,description:s,[b]:l}:{errorMap:a((f,g)=>f.code!=="invalid_type"?{message:g.defaultError}:typeof g.data>"u"?{message:n??g.defaultError}:{message:r??g.defaultError},"customMap"),description:s,[b]:l}}a(k,"processCreateParams");var ls=a((t,e)=>{let r;switch(t.code){case h.invalid_type:t.received===_.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case h.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Z.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:r=`Unrecognized key(s) in object: ${Z.joinValues(t.keys,", ")}`;break;case h.invalid_union:r="Invalid input";break;case h.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Z.joinValues(t.options)}`;break;case h.invalid_enum_value:r=`Invalid enum value. Expected ${Z.joinValues(t.options)}, received '${t.received}'`;break;case h.invalid_arguments:r="Invalid function arguments";break;case h.invalid_return_type:r="Invalid function return type";break;case h.invalid_date:r="Invalid date";break;case h.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:Z.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case h.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case h.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case h.custom:r="Invalid input";break;case h.invalid_intersection_types:r="Intersection results could not be merged";break;case h.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case h.not_finite:r="Number must be finite";break;case h.unresolved_reference:r="Unresolved reference";break;default:r=e.defaultError,Z.assertNever(t)}return{message:r}},"errorMap"),Si=ls,h=Z.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","unresolved_reference"]),Bl=a(t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),ur=class Cl extends Error{constructor(e){super(),this.issues=[],this.addIssue=a(n=>{this.issues=[...this.issues,n]},"addIssue"),this.addIssues=a((n=[])=>{this.issues=[...this.issues,...n]},"addIssues");let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let r=e||function(i){return i.message},n={_errors:[]},s=a(i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)n._errors.push(r(o));else{let l=n,u=0;for(;u<o.path.length;){let f=o.path[u];u===o.path.length-1?(l[f]=l[f]||{_errors:[]},l[f]._errors.push(r(o))):l[f]=l[f]||{_errors:[]},l=l[f],u++}}},"processError");return s(this),n}static assert(e){if(!(e instanceof Cl))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Z.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};a(ur,"ZodError");ur.create=a(t=>new ur(t),"create");var le=ur,Al=ls;function cs(t){Al=t}a(cs,"setErrorMap");function st(){return Al}a(st,"getErrorMap");var Mt=a(t=>{var e;let{data:r,path:n,errorMaps:s,issueData:i}=t,o=[...n,...i.path||[]],l=p(c({},i),{path:o}),u="",f=s.filter(g=>!!g).slice().reverse();for(let g of f)u=g(l,{data:r,defaultError:u}).message;return p(c({},i),{path:o,message:(e=i.message)!=null?e:u})},"makeIssue"),Rl=[];function v(t,e){let r=Mt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,st(),ls].filter(n=>!!n)});t.common.issues.push(r)}a(v,"addIssueToContext");var Hl=class Dl{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let s of r){if(s.status==="aborted")return x;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let s of r)n.push({key:await s.key,value:await s.value});return Dl.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return x;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(n[i.value]=o.value)}return{status:e.value,value:n}}};a(Hl,"ParseStatus");var te=Hl,x=Object.freeze({status:"aborted"}),Re=a(t=>({status:"dirty",value:t}),"DIRTY"),J=a(t=>({status:"valid",value:t}),"OK"),dr=a(t=>t.status==="aborted","isAborted"),pr=a(t=>t.status==="dirty","isDirty"),it=a(t=>t.status==="valid","isValid"),Nt=a(t=>typeof Promise<"u"&&t instanceof Promise,"isAsync"),w;(t=>{t.errToObj=a(e=>typeof e=="string"?{message:e}:e||{},"errToObj"),t.toString=a(e=>typeof e=="string"?e:e?.message,"toString")})(w||(w={}));var fr=class Ml extends O{constructor(){super(...arguments),this._any=!0}_parse(e){return J(e.data)}isEqual(e){return e instanceof Ml}};a(fr,"ZodAny");fr.create=a(t=>new fr(c({typeName:"ZodAny"},k(t))),"create");var at=fr,gr=class Ie extends O{dereference(e){return new Ie(p(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new Ie(p(c({},this._def),{type:this._def.type.clone()}))}isEqual(e){var r,n,s,i,o,l;return e instanceof Ie?tt((r=this._def.exactLength)==null?void 0:r.value,(n=e._def.exactLength)==null?void 0:n.value)&&tt((s=this._def.maxLength)==null?void 0:s.value,(i=e._def.maxLength)==null?void 0:i.value)&&tt((o=this._def.minLength)==null?void 0:o.value,(l=e._def.minLength)==null?void 0:l.value)&&this._def.type.isEqual(e._def.type):!1}_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==_.array)return v(r,{code:h.invalid_type,expected:_.array,received:r.parsedType}),x;if(s.exactLength!==null){let o=r.data.length>s.exactLength.value,l=r.data.length<s.exactLength.value;(o||l)&&(v(r,{code:o?h.too_big:h.too_small,minimum:l?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(v(r,{code:h.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(v(r,{code:h.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((o,l)=>s.type._parseAsync(new ae(r,o,r.path,l)))).then(o=>te.mergeArray(n,o));let i=[...r.data].map((o,l)=>s.type._parseSync(new ae(r,o,r.path,l)));return te.mergeArray(n,i)}get element(){return this._def.type}min(e,r){return new Ie(p(c({},this._def),{minLength:{value:e,message:w.toString(r)}}))}max(e,r){return new Ie(p(c({},this._def),{maxLength:{value:e,message:w.toString(r)}}))}length(e,r){return new Ie(p(c({},this._def),{exactLength:{value:e,message:w.toString(r)}}))}nonempty(e){return this.min(1,e)}};a(gr,"ZodArray");gr.create=a((t,e)=>new gr(c({type:t,minLength:null,maxLength:null,exactLength:null,typeName:"ZodArray"},k(e))),"create");var ot=gr,tm=a((t,e)=>Nl(t,e,new WeakSet),"isEqual"),Nl=a((t,e,r)=>bh(t,e,rm(r)),"_isEqualWithVisitedTracking"),rm=a(t=>(e,r)=>{if(li(e)&&!t.has(e)&&li(r)&&!t.has(r)){let n=Pi(e,wi),s=Pi(r,wi);return t.add(n).add(s).add(e).add(r),Nl(n,s,t)}},"_customizerWithVisitedTracking"),nm={compare:tm},$l=class{constructor(e=[],r={}){this._options=c(c({},nm),r),this._items=[];for(let n of e)this.add(n)}get items(){return[...this._items]}get size(){return this._items.length}has(e){return this._items.some(r=>this._options.compare(r,e))}add(e){this.has(e)||this._items.push(e)}isEqual(e){return this.size!==e.size?!1:this.isSubsetOf(e)&&e.isSubsetOf(this)}isSubsetOf(e){return this.size>e.size?!1:this._items.every(r=>e.has(r))}};a($l,"CustomSet");var K=$l,hr=class tr extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==_.bigint){let i=this._getOrReturnCtx(e);return v(i,{code:h.invalid_type,expected:_.bigint,received:i.parsedType}),x}let n,s=new te;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Z.assertNever(i);return{status:s.value,value:e.data}}isEqual(e){if(!(e instanceof tr)||this._def.coerce!==e._def.coerce)return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)}gte(e,r){return this.setLimit("min",e,!0,w.toString(r))}gt(e,r){return this.setLimit("min",e,!1,w.toString(r))}lte(e,r){return this.setLimit("max",e,!0,w.toString(r))}lt(e,r){return this.setLimit("max",e,!1,w.toString(r))}setLimit(e,r,n,s){return new tr(p(c({},this._def),{checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:w.toString(s)}]}))}_addCheck(e){return new tr(p(c({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:w.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};a(hr,"ZodBigInt");hr.create=a(t=>{var e;return new hr(c({checks:[],typeName:"ZodBigInt",coerce:(e=t?.coerce)!=null?e:!1},k(t)))},"create");var tn=hr,mr=class jl extends O{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==_.boolean){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.boolean,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof jl?this._def.coerce===e._def.coerce:!1}};a(mr,"ZodBoolean");mr.create=a(t=>new mr(c({typeName:"ZodBoolean",coerce:t?.coerce||!1},k(t))),"create");var rn=mr,Kl=Symbol("zod_brand"),Ul=class Tt extends O{dereference(e){return new Tt(p(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new Tt(p(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}isEqual(e){return e instanceof Tt?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}mandatory(){return new Tt(p(c({},this._def),{type:this._def.type.mandatory()}))}};a(Ul,"ZodBranded");var nn=Ul,yr=class bt extends O{_parse(e){let{ctx:r}=this._processInputParams(e),n=p(c({},r),{common:p(c({},r.common),{issues:[]})}),s=this._def.innerType._parse({data:n.data,path:n.path,parent:c({},n)});return Nt(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new le(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new le(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}isEqual(e){return e instanceof bt?this._def.innerType.isEqual(e._def.innerType)&&Z.compareFunctions(this._def.catchValue,e._def.catchValue):!1}dereference(e){return new bt(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new bt(p(c({},this._def),{innerType:this._def.innerType.clone()}))}naked(){return this._def.innerType.naked()}mandatory(){return new bt(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(yr,"ZodCatch");yr.create=a((t,e)=>new yr(c({innerType:t,typeName:"ZodCatch",catchValue:typeof e.catch=="function"?e.catch:()=>e.catch},k(e))),"create");var sn=yr,us=a((t,e={},r)=>t?at.create().superRefine((n,s)=>{var i,o;if(!t(n)){let l=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(o=(i=l.fatal)!=null?i:r)!=null?o:!0,f=typeof l=="string"?{message:l}:l;s.addIssue(p(c({code:"custom"},f),{fatal:u}))}}):at.create(),"custom"),vr=class Un extends O{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==_.date){let i=this._getOrReturnCtx(e);return v(i,{code:h.invalid_type,expected:_.date,received:i.parsedType}),x}if(isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return v(i,{code:h.invalid_date}),x}let n=new te,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:h.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:h.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):Z.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Un(p(c({},this._def),{checks:[...this._def.checks,e]}))}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:w.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:w.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}isEqual(e){if(!(e instanceof Un))return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)&&this._def.coerce===e._def.coerce}};a(vr,"ZodDate");vr.create=a(t=>new vr(c({checks:[],coerce:t?.coerce||!1,typeName:"ZodDate"},k(t))),"create");var an=vr,_r=class wt extends O{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===_.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}dereference(e){return new wt(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new wt(p(c({},this._def),{innerType:this._def.innerType.clone()}))}isEqual(e){return e instanceof wt?this._def.innerType.isEqual(e._def.innerType)&&tt(this._def.defaultValue(),e._def.defaultValue()):!1}unwrap(){return this._def.innerType}naked(){return this._def.innerType.naked()}mandatory(){return new wt(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(_r,"ZodDefault");_r.create=a((t,e,r)=>new _r(c({innerType:t,typeName:"ZodDefault",defaultValue:typeof e=="function"?e:()=>e},k(r))),"create");var Kt=_r,me=a(t=>Array.from(new Set(t)),"unique"),de=a(t=>t instanceof ln?de(t.schema):t instanceof we?de(t.innerType()):t instanceof cn?[t.value]:t instanceof We?t.options:t instanceof un?Z.objectValues(t.enum):t instanceof Kt?de(t._def.innerType):t instanceof Lt?[void 0]:t instanceof dn?[null]:t instanceof fe?[void 0,...de(t.unwrap())]:t instanceof De?[null,...de(t.unwrap())]:t instanceof nn||t instanceof Ft?de(t.unwrap()):t instanceof sn?de(t._def.innerType):[],"getDiscriminator"),zl=class Be extends O{dereference(e){let r=this.options.map(s=>s.dereference(e)),n=Be._getOptionsMap(this.discriminator,r);return new Be(p(c({},this._def),{options:r,optionsMap:n}))}getReferences(){return me(this.options.flatMap(e=>e.getReferences()))}clone(){let e=this.options.map(r=>r.clone());return new Be(p(c({},this._def),{options:e}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==_.object)return v(r,{code:h.invalid_type,expected:_.object,received:r.parsedType}),x;let n=this.discriminator,s=r.data[n],i=this.optionsMap.get(s);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(v(r,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),x)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let s=Be._getOptionsMap(e,r);return new Be(c({typeName:"ZodDiscriminatedUnion",discriminator:e,options:r,optionsMap:s},k(n)))}static _getOptionsMap(e,r){let n=new Map;for(let s of r){let i=de(s.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of i){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,s)}}return n}isEqual(e){if(!(e instanceof Be)||this._def.discriminator!==e._def.discriminator)return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new K(this._def.options,{compare:r}),s=new K(e._def.options,{compare:r});return n.isEqual(s)}};a(zl,"ZodDiscriminatedUnion");var ds=zl;function Ut(t,e){return new We(c({values:t,typeName:"ZodEnum"},k(e)))}a(Ut,"createZodEnum");var ps=class rr extends O{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return v(r,{expected:Z.joinValues(n),received:r.parsedType,code:h.invalid_type}),x}if(this._def.values.indexOf(e.data)===-1){let r=this._getOrReturnCtx(e),n=this._def.values;return v(r,{received:r.data,code:h.invalid_enum_value,options:n}),x}return J(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return rr.create(e,c(c({},this._def),r))}exclude(e,r=this._def){return rr.create(this.options.filter(n=>!e.includes(n)),c(c({},this._def),r))}isEqual(e){if(!(e instanceof rr))return!1;let r=new K(this._def.values),n=new K(e._def.values);return r.isEqual(n)}};a(ps,"ZodEnum");ps.create=Ut;var We=ps,Fl=class Ce extends O{constructor(){super(...arguments),this.validate=this.implement}dereference(e){let r=this._def.args.dereference(e),n=this._def.returns.dereference(e);return new Ce(p(c({},this._def),{args:r,returns:n}))}getReferences(){return me([...this._def.args.getReferences(),...this._def.returns.getReferences()])}clone(){return new Ce(p(c({},this._def),{args:this._def.args.clone(),returns:this._def.returns.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==_.function)return v(r,{code:h.invalid_type,expected:_.function,received:r.parsedType}),x;function n(l,u){return Mt({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,st(),Si].filter(f=>!!f),issueData:{code:h.invalid_arguments,argumentsError:u}})}a(n,"makeArgsIssue");function s(l,u){return Mt({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,st(),Si].filter(f=>!!f),issueData:{code:h.invalid_return_type,returnTypeError:u}})}a(s,"makeReturnsIssue");let i={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof zt){let l=this;return J(async function(...u){let f=new le([]),g=await l._def.args.parseAsync(u,i).catch(E=>{throw f.addIssue(n(u,E)),f}),m=await Reflect.apply(o,this,g);return await l._def.returns._def.type.parseAsync(m,i).catch(E=>{throw f.addIssue(s(m,E)),f})})}else{let l=this;return J(function(...u){let f=l._def.args.safeParse(u,i);if(!f.success)throw new le([n(u,f.error)]);let g=Reflect.apply(o,this,f.data),m=l._def.returns.safeParse(g,i);if(!m.success)throw new le([s(g,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ce(p(c({},this._def),{args:Ne.create(e).rest(rt.create())}))}returns(e){return new Ce(p(c({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new Ce(c({args:e||Ne.create([]).rest(rt.create()),returns:r||rt.create(),typeName:"ZodFunction"},k(n)))}isEqual(e){return e instanceof Ce&&this._def.args.isEqual(e._def.args)&&this._def.returns.isEqual(e._def.returns)}};a(Fl,"ZodFunction");var fs=Fl;function Tr(t,e){let r=pe(t),n=pe(e);if(t===e)return{valid:!0,data:t};if(r===_.object&&n===_.object){let s=Z.objectKeys(e),i=Z.objectKeys(t).filter(l=>s.indexOf(l)!==-1),o=c(c({},t),e);for(let l of i){let u=Tr(t[l],e[l]);if(!u.valid)return{valid:!1};o[l]=u.data}return{valid:!0,data:o}}else if(r===_.array&&n===_.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let o=t[i],l=e[i],u=Tr(o,l);if(!u.valid)return{valid:!1};s.push(u.data)}return{valid:!0,data:s}}else return r===_.date&&n===_.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}a(Tr,"mergeValues");var br=class nr extends O{dereference(e){return new nr(p(c({},this._def),{left:this._def.left.dereference(e),right:this._def.right.dereference(e)}))}getReferences(){return me([...this._def.left.getReferences(),...this._def.right.getReferences()])}clone(){return new nr(p(c({},this._def),{left:this._def.left.clone(),right:this._def.right.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=a((i,o)=>{if(dr(i)||dr(o))return x;let l=Tr(i.value,o.value);return l.valid?((pr(i)||pr(o))&&r.dirty(),{status:r.value,value:l.data}):(v(n,{code:h.invalid_intersection_types}),x)},"handleParsed");return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}isEqual(e){if(!(e instanceof nr))return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new K([this._def.left,this._def.right],{compare:r}),s=new K([e._def.left,e._def.right],{compare:r});return n.isEqual(s)}};a(br,"ZodIntersection");br.create=a((t,e,r)=>new br(c({left:t,right:e,typeName:"ZodIntersection"},k(r))),"create");var on=br,wr=class Pt extends O{get schema(){return this._def.getter()}dereference(e){return new Pt(p(c({},this._def),{getter:a(()=>this._def.getter().dereference(e),"getter")}))}getReferences(){return this._def.getter().getReferences()}clone(){return new Pt(p(c({},this._def),{getter:a(()=>this._def.getter().clone(),"getter")}))}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}isEqual(e){return e instanceof Pt?this._def.getter().isEqual(e._def.getter()):!1}naked(){return this._def.getter().naked()}mandatory(){return new Pt(p(c({},this._def),{getter:a(()=>this._def.getter().mandatory(),"getter")}))}};a(wr,"ZodLazy");wr.create=a((t,e)=>new wr(c({getter:t,typeName:"ZodLazy"},k(e))),"create");var ln=wr,Pr=class Ll extends O{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return v(r,{received:r.data,code:h.invalid_literal,expected:this._def.value}),x}return{status:"valid",value:e.data}}get value(){return this._def.value}isEqual(e){return e instanceof Ll?tt(this._def.value,e._def.value):!1}};a(Pr,"ZodLiteral");Pr.create=a((t,e)=>new Pr(c({value:t,typeName:"ZodLiteral"},k(e))),"create");var cn=Pr,xr=class sr extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}dereference(e){let r=this._def.keyType.dereference(e),n=this._def.valueType.dereference(e);return new sr(p(c({},this._def),{keyType:r,valueType:n}))}getReferences(){return me([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new sr(p(c({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.map)return v(n,{code:h.invalid_type,expected:_.map,received:n.parsedType}),x;let s=this._def.keyType,i=this._def.valueType,o=[...n.data.entries()].map(([l,u],f)=>({key:s._parse(new ae(n,l,n.path,[f,"key"])),value:i._parse(new ae(n,u,n.path,[f,"value"]))}));if(n.common.async){let l=new Map;return Promise.resolve().then(async()=>{for(let u of o){let f=await u.key,g=await u.value;if(f.status==="aborted"||g.status==="aborted")return x;(f.status==="dirty"||g.status==="dirty")&&r.dirty(),l.set(f.value,g.value)}return{status:r.value,value:l}})}else{let l=new Map;for(let u of o){let f=u.key,g=u.value;if(f.status==="aborted"||g.status==="aborted")return x;(f.status==="dirty"||g.status==="dirty")&&r.dirty(),l.set(f.value,g.value)}return{status:r.value,value:l}}}isEqual(e){return!(!(e instanceof sr)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};a(xr,"ZodMap");xr.create=a((t,e,r)=>new xr(c({valueType:e,keyType:t,typeName:"ZodMap"},k(r))),"create");var gs=xr,kr=class Wl extends O{_parse(e){if(this._getType(e)!==_.nan){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.nan,received:n.parsedType}),x}return{status:"valid",value:e.data}}isEqual(e){return e instanceof Wl}};a(kr,"ZodNaN");kr.create=a(t=>new kr(c({typeName:"ZodNaN"},k(t))),"create");var hs=kr,Sr=class ql extends O{_parse(e){let r=Z.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==_.string&&n.parsedType!==_.number){let s=Z.objectValues(r);return v(n,{expected:Z.joinValues(s),received:n.parsedType,code:h.invalid_type}),x}if(r.indexOf(e.data)===-1){let s=Z.objectValues(r);return v(n,{received:n.data,code:h.invalid_enum_value,options:s}),x}return J(e.data)}get enum(){return this._def.values}isEqual(e){return e instanceof ql?tt(this._def.values,e._def.values):!1}};a(Sr,"ZodNativeEnum");Sr.create=a((t,e)=>new Sr(c({values:t,typeName:"ZodNativeEnum"},k(e))),"create");var un=Sr,Or=class Vl extends O{_parse(e){let r=this._getOrReturnCtx(e);return v(r,{code:h.invalid_type,expected:_.never,received:r.parsedType}),x}isEqual(e){return e instanceof Vl}};a(Or,"ZodNever");Or.create=a(t=>new Or(c({typeName:"ZodNever"},k(t))),"create");var ut=Or,Er=class Gl extends O{_parse(e){if(this._getType(e)!==_.null){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.null,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof Gl}};a(Er,"ZodNull");Er.create=a(t=>new Er(c({typeName:"ZodNull"},k(t))),"create");var dn=Er,Zr=class xt extends O{dereference(e){return new xt(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new xt(p(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)===_.null?J(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof xt?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new xt(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(Zr,"ZodNullable");Zr.create=a((t,e)=>new Zr(c({innerType:t,typeName:"ZodNullable"},k(e))),"create");var De=Zr;function Jl(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,i=parseInt(t.toFixed(s).replace(".","")),o=parseInt(e.toFixed(s).replace(".",""));return i%o/Math.pow(10,s)}a(Jl,"floatSafeRemainder");var Ir=class ir extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==_.number){let i=this._getOrReturnCtx(e);return v(i,{code:h.invalid_type,expected:_.number,received:i.parsedType}),x}let n,s=new te;for(let i of this._def.checks)i.kind==="int"?Z.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{code:h.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Jl(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{code:h.not_finite,message:i.message}),s.dirty()):Z.assertNever(i);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,w.toString(r))}gt(e,r){return this.setLimit("min",e,!1,w.toString(r))}lte(e,r){return this.setLimit("max",e,!0,w.toString(r))}lt(e,r){return this.setLimit("max",e,!1,w.toString(r))}setLimit(e,r,n,s){return new ir(p(c({},this._def),{checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:w.toString(s)}]}))}_addCheck(e){return new ir(p(c({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:w.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:w.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:w.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:w.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:w.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Z.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}isEqual(e){if(!(e instanceof ir))return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)}};a(Ir,"ZodNumber");Ir.create=a(t=>new Ir(c({checks:[],typeName:"ZodNumber",coerce:t?.coerce||!1},k(t))),"create");var pn=Ir;function Ae(t){if(t instanceof Me){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=fe.create(Ae(n))}return new Me(p(c({},t._def),{shape:a(()=>e,"shape")}))}else return t instanceof ot?new ot(p(c({},t._def),{type:Ae(t.element)})):t instanceof fe?fe.create(Ae(t.unwrap())):t instanceof De?De.create(Ae(t.unwrap())):t instanceof Ne?Ne.create(t.items.map(e=>Ae(e))):t}a(Ae,"deepPartialify");var be=class ne extends O{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=Z.objectKeys(e);return this._cached={shape:e,keys:r}}dereference(e){let r=this._def.shape(),n={};for(let s in r)n[s]=r[s].dereference(e);return new ne(p(c({},this._def),{shape:a(()=>n,"shape")}))}getReferences(){let e=this._def.shape(),r=[];for(let n in e)r.push(...e[n].getReferences());return me(r)}clone(){let e={},r=this._def.shape();for(let[n,s]of Object.entries(r))e[n]=s.clone();return new ne(p(c({},this._def),{shape:a(()=>e,"shape")}))}_parse(e){if(this._getType(e)!==_.object){let g=this._getOrReturnCtx(e);return v(g,{code:h.invalid_type,expected:_.object,received:g.parsedType}),x}let{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),l=[];if(this._def.unknownKeys!=="strip")for(let g in s.data)o.includes(g)||l.push(g);let u=[];for(let g of o){let m=i[g],P=s.data[g];u.push({key:{status:"valid",value:g},value:m._parse(new ae(s,P,s.path,g)),alwaysSet:g in s.data})}let f=this._def.unknownKeys;if(f==="passthrough")for(let g of l)u.push({key:{status:"valid",value:g},value:{status:"valid",value:s.data[g]}});else if(f==="strict")l.length>0&&(v(s,{code:h.unrecognized_keys,keys:l}),n.dirty());else if(f!=="strip")for(let g of l){let m=s.data[g];u.push({key:{status:"valid",value:g},value:f._parse(new ae(s,m,s.path,g)),alwaysSet:g in s.data})}return s.common.async?Promise.resolve().then(async()=>{let g=[];for(let m of u){let P=await m.key;g.push({key:P,value:await m.value,alwaysSet:m.alwaysSet})}return g}).then(g=>te.mergeObjectSync(n,g)):te.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return w.errToObj,new ne(c(p(c({},this._def),{unknownKeys:"strict"}),e!==void 0?{errorMap:a((r,n)=>{var s,i,o,l;let u=(o=(i=(s=this._def).errorMap)==null?void 0:i.call(s,r,n).message)!=null?o:n.defaultError;return r.code==="unrecognized_keys"?{message:(l=w.errToObj(e).message)!=null?l:u}:{message:u}},"errorMap")}:{}))}strip(){return new ne(p(c({},this._def),{unknownKeys:"strip"}))}passthrough(){return new ne(p(c({},this._def),{unknownKeys:"passthrough"}))}additionalProperties(){if(this._def.unknownKeys instanceof O)return this._def.unknownKeys;if(this._def.unknownKeys==="passthrough")return at.create();if(this._def.unknownKeys==="strict")return ut.create()}extend(e){return new ne(p(c({},this._def),{shape:a(()=>c(c({},this._def.shape()),e),"shape")}))}merge(e){return new ne({unknownKeys:e._def.unknownKeys,shape:a(()=>c(c({},this._def.shape()),e._def.shape()),"shape"),typeName:"ZodObject"})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new ne(p(c({},this._def),{unknownKeys:e}))}pick(e){let r={};return Z.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new ne(p(c({},this._def),{shape:a(()=>r,"shape")}))}omit(e){let r={};return Z.objectKeys(this.shape).forEach(n=>{e[n]||(r[n]=this.shape[n])}),new ne(p(c({},this._def),{shape:a(()=>r,"shape")}))}deepPartial(){return Ae(this)}partial(e){let r={};return Z.objectKeys(this.shape).forEach(n=>{let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s?.optional()}),new ne(p(c({},this._def),{shape:a(()=>r,"shape")}))}required(e){let r={};return Z.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof fe;)i=i._def.innerType;r[n]=i}}),new ne(p(c({},this._def),{shape:a(()=>r,"shape")}))}keyof(){return Ut(Z.objectKeys(this.shape))}isEqual(e){if(!(e instanceof ne)||!this._unknownKeysEqual(e))return!1;let r=this._def.shape(),n=e._def.shape(),s=a((l,u)=>l[0]===u[0]&&l[1].isEqual(u[1]),"compare"),i=new K(Object.entries(r),{compare:s}),o=new K(Object.entries(n),{compare:s});return i.isEqual(o)}_unknownKeysEqual(e){let r=this.additionalProperties(),n=e.additionalProperties();return r===void 0||n===void 0?r===n:r.isEqual(n)}};a(be,"ZodObject");be.create=a((t,e)=>new be(c({shape:a(()=>t,"shape"),unknownKeys:"strip",typeName:"ZodObject"},k(e))),"create");be.strictCreate=a((t,e)=>new be(c({shape:a(()=>t,"shape"),unknownKeys:"strict",typeName:"ZodObject"},k(e))),"strictCreate");be.lazycreate=a((t,e)=>new be(c({shape:t,unknownKeys:"strip",typeName:"ZodObject"},k(e))),"lazycreate");var Me=be,Br=class ar extends O{dereference(e){return new ar(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new ar(p(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)===_.undefined?J(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof ar?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return this._def.innerType.mandatory()}};a(Br,"ZodOptional");Br.create=a((t,e)=>new Br(c({innerType:t,typeName:"ZodOptional"},k(e))),"create");var fe=Br,Xl=class kt extends O{dereference(e){return new kt(p(c({},this._def),{in:this._def.in.dereference(e),out:this._def.out.dereference(e)}))}getReferences(){return me([...this._def.in.getReferences(),...this._def.out.getReferences()])}clone(){return new kt(p(c({},this._def),{in:this._def.in.clone(),out:this._def.out.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return a(async()=>{let i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?x:i.status==="dirty"?(r.dirty(),Re(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})},"handleAsync")();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?x:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new kt({in:e,out:r,typeName:"ZodPipeline"})}isEqual(e){return!(!(e instanceof kt)||!this._def.in.isEqual(e._def.in)||!this._def.out.isEqual(e._def.out))}};a(Xl,"ZodPipeline");var fn=Xl,Cr=class or extends O{unwrap(){return this._def.type}dereference(e){return new or(p(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new or(p(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==_.promise&&r.common.async===!1)return v(r,{code:h.invalid_type,expected:_.promise,received:r.parsedType}),x;let n=r.parsedType===_.promise?r.data:Promise.resolve(r.data);return J(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}isEqual(e){return e instanceof or?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}};a(Cr,"ZodPromise");Cr.create=a((t,e)=>new Cr(c({type:t,typeName:"ZodPromise"},k(e))),"create");var zt=Cr,Ar=class St extends O{dereference(e){return new St(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new St(p(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){let r=this._def.innerType._parse(e);return it(r)&&(r.value=Object.freeze(r.value)),r}unwrap(){return this._def.innerType}isEqual(e){return e instanceof St?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new St(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(Ar,"ZodReadonly");Ar.create=a((t,e)=>new Ar(c({innerType:t,typeName:"ZodReadonly"},k(e))),"create");var Ft=Ar,Yl=class Xe extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}dereference(e){let r=this._def.keyType.dereference(e),n=this._def.valueType.dereference(e);return new Xe(p(c({},this._def),{keyType:r,valueType:n}))}getReferences(){return me([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new Xe(p(c({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.object)return v(n,{code:h.invalid_type,expected:_.object,received:n.parsedType}),x;let s=[],i=this._def.keyType,o=this._def.valueType;for(let l in n.data)s.push({key:i._parse(new ae(n,l,n.path,l)),value:o._parse(new ae(n,n.data[l],n.path,l))});return n.common.async?te.mergeObjectAsync(r,s):te.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof O?new Xe(c({keyType:e,valueType:r,typeName:"ZodRecord"},k(n))):new Xe(c({keyType:X.create(),valueType:e,typeName:"ZodRecord"},k(r)))}isEqual(e){return!(!(e instanceof Xe)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};a(Yl,"ZodRecord");var ms=Yl,Rr=class Ql extends O{dereference(e){let r=e[this._def.uri];return r||this}getReferences(){return[this._def.uri]}_parse(e){let r=this._getOrReturnCtx(e);return v(r,{code:h.unresolved_reference}),x}isOptional(){return!1}isNullable(){return!1}isEqual(e){return e instanceof Ql?this._def.uri===e._def.uri:!1}};a(Rr,"ZodRef");Rr.create=a(t=>new Rr({typeName:"ZodRef",uri:t}),"create");var ys=Rr,Hr=class Ye extends O{dereference(e){return new Ye(p(c({},this._def),{valueType:this._def.valueType.dereference(e)}))}getReferences(){return this._def.valueType.getReferences()}clone(){return new Ye(p(c({},this._def),{valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.set)return v(n,{code:h.invalid_type,expected:_.set,received:n.parsedType}),x;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(v(n,{code:h.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(v(n,{code:h.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let i=this._def.valueType;function o(u){let f=new Set;for(let g of u){if(g.status==="aborted")return x;g.status==="dirty"&&r.dirty(),f.add(g.value)}return{status:r.value,value:f}}a(o,"finalizeSet");let l=[...n.data.values()].map((u,f)=>i._parse(new ae(n,u,n.path,f)));return n.common.async?Promise.all(l).then(u=>o(u)):o(l)}min(e,r){return new Ye(p(c({},this._def),{minSize:{value:e,message:w.toString(r)}}))}max(e,r){return new Ye(p(c({},this._def),{maxSize:{value:e,message:w.toString(r)}}))}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}isEqual(e){var r,n,s,i;if(!(e instanceof Ye))return!1;let o=(r=this._def.minSize)==null?void 0:r.value,l=(n=e._def.minSize)==null?void 0:n.value;if(o!==l)return!1;let u=(s=this._def.maxSize)==null?void 0:s.value,f=(i=e._def.maxSize)==null?void 0:i.value;return u!==f?!1:this._def.valueType.isEqual(e._def.valueType)}};a(Hr,"ZodSet");Hr.create=a((t,e)=>new Hr(c({valueType:t,minSize:null,maxSize:null,typeName:"ZodSet"},k(e))),"create");var vs=Hr,_s=/^c[^\s-]{8,}$/i,Ts=/^[a-z][a-z0-9]*$/,bs=/^[0-9A-HJKMNP-TV-Z]{26}$/,ws=/^[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,Ps=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ec="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",tc=a(t=>t===ec,"isEmojiRegex"),Cn,xs=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,ks=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;function rc(t,e){return!!((e==="v4"||!e)&&xs.test(t)||(e==="v6"||!e)&&ks.test(t))}a(rc,"isValidIP");var Dr=class Qe extends O{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==_.string){let i=this._getOrReturnCtx(e);return v(i,{code:h.invalid_type,expected:_.string,received:i.parsedType}),x}let n=new te,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:h.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:h.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,l=e.data.length<i.value;(o||l)&&(s=this._getOrReturnCtx(e,s),o?v(s,{code:h.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):l&&v(s,{code:h.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")Ps.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"email",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")Cn||(Cn=new RegExp(ec,"u")),Cn.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"emoji",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")ws.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"uuid",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")_s.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"cuid",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")Ts.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"cuid2",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")bs.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"ulid",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),v(s,{validation:"url",code:h.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"regex",code:h.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),v(s,{code:h.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),v(s,{code:h.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),v(s,{code:h.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?El(i).test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{code:h.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="ip"?rc(e.data,i.version)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"ip",code:h.invalid_string,message:i.message}),n.dirty()):Z.assertNever(i);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),c({validation:r,code:h.invalid_string},w.errToObj(n)))}_addCheck(e){return new Qe(p(c({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(c({kind:"email"},w.errToObj(e)))}url(e){return this._addCheck(c({kind:"url"},w.errToObj(e)))}emoji(e){return this._addCheck(c({kind:"emoji"},w.errToObj(e)))}uuid(e){return this._addCheck(c({kind:"uuid"},w.errToObj(e)))}cuid(e){return this._addCheck(c({kind:"cuid"},w.errToObj(e)))}cuid2(e){return this._addCheck(c({kind:"cuid2"},w.errToObj(e)))}ulid(e){return this._addCheck(c({kind:"ulid"},w.errToObj(e)))}ip(e){return this._addCheck(c({kind:"ip"},w.errToObj(e)))}datetime(e){var r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck(c({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(r=e?.offset)!=null?r:!1},w.errToObj(e?.message)))}regex(e,r){return this._addCheck(c({kind:"regex",regex:e},w.errToObj(r)))}includes(e,r){return this._addCheck(c({kind:"includes",value:e,position:r?.position},w.errToObj(r?.message)))}startsWith(e,r){return this._addCheck(c({kind:"startsWith",value:e},w.errToObj(r)))}endsWith(e,r){return this._addCheck(c({kind:"endsWith",value:e},w.errToObj(r)))}min(e,r){return this._addCheck(c({kind:"min",value:e},w.errToObj(r)))}max(e,r){return this._addCheck(c({kind:"max",value:e},w.errToObj(r)))}length(e,r){return this._addCheck(c({kind:"length",value:e},w.errToObj(r)))}nonempty(e){return this.min(1,w.errToObj(e))}trim(){return new Qe(p(c({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}secret(){return this._def[b]=p(c({},this._def[b]),{secret:!0}),this}toLowerCase(){return new Qe(p(c({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new Qe(p(c({},this._def),{checks:[...this._def.checks,{kind:"toUpperCase"}]}))}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}isEqual(e){if(!(e instanceof Qe))return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)}};a(Dr,"ZodString");Dr.create=a(t=>{var e;return new Dr(c({checks:[],typeName:"ZodString",coerce:(e=t?.coerce)!=null?e:!1},k(p(c({},t),{supportsExtensions:["secret"]}))))},"create");var X=Dr,Mr=class nc extends O{_parse(e){if(this._getType(e)!==_.symbol){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.symbol,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof nc}};a(Mr,"ZodSymbol");Mr.create=a(t=>new Mr(c({typeName:"ZodSymbol"},k(t))),"create");var Ss=Mr,lt=class Ot extends O{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName==="ZodEffects"?this._def.schema.sourceType():this._def.schema}dereference(e){return new Ot(p(c({},this._def),{schema:this._def.schema.dereference(e)}))}getReferences(){return this._def.schema.getReferences()}clone(){return new Ot(p(c({},this._def),{schema:this._def.schema.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a(o=>{v(n,o),o.fatal?r.abort():r.dirty()},"addIssue"),get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let o=s.transform(n.data,i);if(n.common.async)return Promise.resolve(o).then(async l=>{if(r.value==="aborted")return x;let u=await this._def.schema._parseAsync({data:l,path:n.path,parent:n});return u.status==="aborted"?x:u.status==="dirty"||r.value==="dirty"?Re(u.value):u});{if(r.value==="aborted")return x;let l=this._def.schema._parseSync({data:o,path:n.path,parent:n});return l.status==="aborted"?x:l.status==="dirty"||r.value==="dirty"?Re(l.value):l}}if(s.type==="refinement"){let o=a(l=>{let u=s.refinement(l,i);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return l},"executeRefinement");if(n.common.async===!1){let l=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return l.status==="aborted"?x:(l.status==="dirty"&&r.dirty(),o(l.value),{status:r.value,value:l.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(l=>l.status==="aborted"?x:(l.status==="dirty"&&r.dirty(),o(l.value).then(()=>({status:r.value,value:l.value}))))}if(s.type==="transform")if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!it(o))return o;let l=s.transform(o.value,i);if(l instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:l}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>it(o)?Promise.resolve(s.transform(o.value,i)).then(l=>({status:r.value,value:l})):o);Z.assertNever(s)}isEqual(e){return!(e instanceof Ot)||!this._def.schema.isEqual(e._def.schema)?!1:this._def.effect.type==="refinement"?e._def.effect.type!=="refinement"?!1:Z.compareFunctions(this._def.effect.refinement,e._def.effect.refinement):this._def.effect.type==="transform"?e._def.effect.type!=="transform"?!1:Z.compareFunctions(this._def.effect.transform,e._def.effect.transform):this._def.effect.type==="preprocess"?e._def.effect.type!=="preprocess"?!1:Z.compareFunctions(this._def.effect.transform,e._def.effect.transform):!1}naked(){return this._def.schema.naked()}mandatory(){return new Ot(p(c({},this._def),{schema:this._def.schema.mandatory()}))}};a(lt,"ZodEffects");lt.create=a((t,e,r)=>new lt(c({schema:t,typeName:"ZodEffects",effect:e},k(r))),"create");lt.createWithPreprocess=a((t,e,r)=>new lt(c({schema:e,effect:{type:"preprocess",transform:t},typeName:"ZodEffects"},k(r))),"createWithPreprocess");var we=lt,Nr=class Et extends O{dereference(e){let r=this._def.items.map(s=>s.dereference(e)),n=this._def.rest?this._def.rest.dereference(e):null;return new Et(p(c({},this._def),{items:r,rest:n}))}getReferences(){return me([...this._def.items.flatMap(e=>e.getReferences()),...this._def.rest?this._def.rest.getReferences():[]])}clone(){let e=this._def.items.map(n=>n.clone()),r=this._def.rest?this._def.rest.clone():null;return new Et(p(c({},this._def),{items:e,rest:r}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.array)return v(n,{code:h.invalid_type,expected:_.array,received:n.parsedType}),x;if(n.data.length<this._def.items.length)return v(n,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),x;!this._def.rest&&n.data.length>this._def.items.length&&(v(n,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...n.data].map((o,l)=>{let u=this._def.items[l]||this._def.rest;return u?u._parse(new ae(n,o,n.path,l)):null}).filter(o=>!!o);return n.common.async?Promise.all(i).then(o=>te.mergeArray(r,o)):te.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new Et(p(c({},this._def),{rest:e}))}isEqual(e){if(!(e instanceof Et)||!this._restEquals(e))return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new K(this._def.items,{compare:r}),s=new K(e._def.items,{compare:r});return n.isEqual(s)}_restEquals(e){return this._def.rest===null?e._def.rest===null:e._def.rest!==null&&this._def.rest.isEqual(e._def.rest)}};a(Nr,"ZodTuple");Nr.create=a((t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Nr(c({items:t,typeName:"ZodTuple",rest:null},k(e)))},"create");var Ne=Nr,$r=class sc extends O{_parse(e){if(this._getType(e)!==_.undefined){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.undefined,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof sc}mandatory(){return ut.create(c({},this._def))}};a($r,"ZodUndefined");$r.create=a(t=>new $r(c({typeName:"ZodUndefined"},k(t))),"create");var Lt=$r,jr=class Zt extends O{dereference(e){let r=this._def.options.map(n=>n.dereference(e));return new Zt(p(c({},this._def),{options:r}))}getReferences(){return me(this._def.options.reduce((e,r)=>[...e,...r.getReferences()],[]))}clone(){let e=this._def.options.map(r=>r.clone());return new Zt(p(c({},this._def),{options:e}))}_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function s(i){for(let l of i)if(l.result.status==="valid")return l.result;for(let l of i)if(l.result.status==="dirty")return r.common.issues.push(...l.ctx.common.issues),l.result;let o=i.map(l=>new le(l.ctx.common.issues));return v(r,{code:h.invalid_union,unionErrors:o}),x}if(a(s,"handleResults"),r.common.async)return Promise.all(n.map(async i=>{let o=p(c({},r),{common:p(c({},r.common),{issues:[]}),parent:null});return{result:await i._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(s);{let i,o=[];for(let u of n){let f=p(c({},r),{common:p(c({},r.common),{issues:[]}),parent:null}),g=u._parseSync({data:r.data,path:r.path,parent:f});if(g.status==="valid")return g;g.status==="dirty"&&!i&&(i={result:g,ctx:f}),f.common.issues.length&&o.push(f.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let l=o.map(u=>new le(u));return v(r,{code:h.invalid_union,unionErrors:l}),x}}get options(){return this._def.options}isEqual(e){if(!(e instanceof Zt))return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new K([...this._def.options],{compare:r}),s=new K([...e._def.options],{compare:r});return n.isEqual(s)}mandatory(){let e=this._def.options.filter(i=>!(i instanceof Lt)).map(i=>i.mandatory()),[r,n,...s]=e;return r?n?new Zt(p(c({},this._def),{options:[r,n,...s]})):r:ut.create(c({},this._def))}};a(jr,"ZodUnion");jr.create=a((t,e)=>new jr(c({options:t,typeName:"ZodUnion"},k(e))),"create");var gn=jr,Kr=class ic extends O{constructor(){super(...arguments),this._unknown=!0}_parse(e){return J(e.data)}isEqual(e){return e instanceof ic}};a(Kr,"ZodUnknown");Kr.create=a(t=>new Kr(c({typeName:"ZodUnknown"},k(t))),"create");var rt=Kr,Ur=class ac extends O{_parse(e){if(this._getType(e)!==_.undefined){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.void,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof ac}};a(Ur,"ZodVoid");Ur.create=a(t=>new Ur(c({typeName:"ZodVoid"},k(t))),"create");var Os=Ur,sm=["gpt-3.5-turbo","gpt-3.5-turbo-16k","gpt-4","gpt-4-1106-preview","gpt-4-vision-preview","gpt-4-0125-preview","gpt-4-turbo-preview","gpt-4-turbo","gpt-4o","gpt-3.5-turbo-0125","gpt-3.5-turbo-1106"],vv=We.create(["any","string","number","boolean","object","pattern","date","array","target","time","enum"]),oc=a(t=>X.create().displayAs({id:"variable",params:c({type:t?.type||"any"},t?.params)}),"variable"),lc=a(t=>X.create().displayAs({id:"conversation",params:c({},t?.params)}),"conversation"),cc=a(t=>X.create().displayAs({id:"user",params:c({},t?.params)}),"user"),uc=a(t=>X.create().displayAs({id:"message",params:c({},t?.params)}),"message"),dc=a(t=>X.create().displayAs({id:"agent",params:c({},t?.params)}),"agent"),pc=a(t=>X.create().displayAs({id:"event",params:c({},t?.params)}),"event"),fc=a(t=>X.create().displayAs({id:"table",params:c({},t?.params)}),"table"),gc=a(t=>X.create().displayAs({id:"tablerow",params:c({},t?.params)}),"tablerow"),hc=a(t=>X.create().displayAs({id:"intent",params:c({},t?.params)}),"intent"),mc=a(()=>We.create(sm).displayAs({id:"dropdown",params:{}}),"aimodel"),yc=a(t=>X.create().displayAs({id:"datasource",params:c({},t)}),"datasource"),vc=a(t=>X.create().displayAs({id:"knowledgebase",params:c({},t)}),"knowledgebase"),_c={object:Me.lazycreate},Tc=a((t,e={message:`Input not instance of ${t.name}`})=>us(r=>r instanceof t,e),"instanceOfType"),Es=X.create,Zs=pn.create,bc=hs.create,wc=tn.create,Is=rn.create,Pc=an.create,xc=Ss.create,kc=Lt.create,Sc=dn.create,Oc=at.create,Ec=rt.create,Zc=ut.create,Ic=Os.create,Bc=ot.create,Cc=Me.create,Ac=Me.strictCreate,Rc=gn.create,Hc=ds.create,Dc=on.create,Mc=Ne.create,Nc=ms.create,$c=ys.create,jc=Ft.create,Kc=gs.create,Uc=vs.create,zc=fs.create,Fc=ln.create,Lc=cn.create,Wc=We.create,qc=un.create,Vc=zt.create,zn=we.create,Gc=fe.create,Jc=De.create,im=Kt.create,Xc=we.createWithPreprocess,Yc=fn.create,Qc=a(()=>Es().optional(),"ostring"),eu=a(()=>Zs().optional(),"onumber"),tu=a(()=>Is().optional(),"oboolean"),ru={string:a(t=>X.create(p(c({},t),{coerce:!0})),"string"),number:a(t=>pn.create(p(c({},t),{coerce:!0})),"number"),boolean:a(t=>rn.create(p(c({},t),{coerce:!0})),"boolean"),bigint:a(t=>tn.create(p(c({},t),{coerce:!0})),"bigint"),date:a(t=>an.create(p(c({},t),{coerce:!0})),"date")},nu=x,d=y,su=a((t,e)=>t.anyOf.length?t.anyOf.length===1?L(t.anyOf[0],p(c({},e),{path:[...e.path,"anyOf",0]})):`z.union([${t.anyOf.map((r,n)=>L(r,p(c({},e),{path:[...e.path,"anyOf",n]}))).join(", ")}])`:"z.any()","parseAnyOf"),am=a(t=>{var e;return(e=t[b])!=null&&e.coerce?"z.coerce.boolean()":"z.boolean()"},"parseBoolean"),om=a(t=>"z.any()","parseDefault"),lm=a((t,e)=>`z.union([${t.type.map(r=>L(p(c({},t),{type:r}),e)).join(", ")}])`,"parseMultipleType"),cm=a((t,e)=>`z.any().refine((value) => !${L(t.not,p(c({},e),{path:[...e.path,"not"]}))}.safeParse(value).success, "Invalid input: Should NOT be valid against schema")`,"parseNot"),um=a(t=>"z.null()","parseNull"),dm=a(t=>[t.slice(0,t.length/2),t.slice(t.length/2)],"half"),pm=a((t,...e)=>Object.keys(t).reduce((r,n)=>(e.includes(n)||(r[n]=t[n]),r),{}),"omit");function G(t,e,r){var n;let s=t[e],i="";if(s!==void 0){let o=r({value:s,json:JSON.stringify(s)});if(o){let l=o[0],u=o.length===3?o[1]:"",f=o.length===3?o[2]:o[1];i+=l,((n=t.errorMessage)==null?void 0:n[e])!==void 0&&(i+=u+JSON.stringify(t.errorMessage[e])),i+=f}}return i}a(G,"withMessage");var It=Symbol("Original index"),fm=a(t=>{let e=[];for(let r=0;r<t.length;r++){let n=t[r];if(typeof n=="boolean")e.push(n?{[It]:r}:{[It]:r,not:{}});else{if(It in n)return t;e.push(p(c({},n),{[It]:r}))}}return e},"ensureOriginalIndex");function $t(t,e){if(t.allOf.length===0)return"z.never()";if(t.allOf.length===1){let r=t.allOf[0];return L(r,p(c({},e),{path:[...e.path,"allOf",r[It]]}))}else{let[r,n]=dm(fm(t.allOf));return`z.intersection(${$t({allOf:r},e)}, ${$t({allOf:n},e)})`}}a($t,"parseAllOf");var gm=a((t,e)=>{if(Array.isArray(t.items))return`z.tuple([${t.items.map((n,s)=>L(n,p(c({},e),{path:[...e.path,"items",s]})))}])`;let r=t.items?`z.array(${L(t.items,p(c({},e),{path:[...e.path,"items"]}))})`:"z.array(z.any())";return r+=G(t,"minItems",({json:n})=>[`.min(${n}`,", ",")"]),r+=G(t,"maxItems",({json:n})=>[`.max(${n}`,", ",")"]),r},"parseArray"),hm=a(t=>`z.literal(${JSON.stringify(t.const)})`,"parseConst"),mm=a(t=>t.enum.length===0?"z.never()":t.enum.length===1?`z.literal(${JSON.stringify(t.enum[0])})`:t.enum.every(e=>typeof e=="string")?`z.enum([${t.enum.map(e=>JSON.stringify(e))}])`:`z.union([${t.enum.map(e=>`z.literal(${JSON.stringify(e)})`).join(", ")}])`,"parseEnum"),ym=a((t,e)=>{let r=L(t.if,p(c({},e),{path:[...e.path,"if"]})),n=L(t.then,p(c({},e),{path:[...e.path,"then"]})),s=L(t.else,p(c({},e),{path:[...e.path,"else"]}));return`z.union([${n}, ${s}]).superRefine((value,ctx) => {
11
+ `).trim();case d.ZodFirstPartyTypeKind.ZodUnion:return`z.union([${r.options.map(N).join(", ")}])${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:let l=r.options.map(N);return`z.discriminatedUnion(${T(r.discriminator)}, [${l.join(", ")}])${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodIntersection:let f=N(r.left),g=N(r.right);return`z.intersection(${f}, ${g})${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodTuple:return`z.tuple([${r.items.map(N).join(", ")}])${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodRecord:let P=N(r.keyType),E=N(r.valueType);return`z.record(${P}, ${E})${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodMap:let I=N(r.keyType),U=N(r.valueType);return`z.map(${I}, ${U})${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodSet:return`z.set(${N(r.valueType)})${Mh(r)}${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodFunction:let W=r.args.items.map(N),Q=W.length?`.args(${W.join(", ")})`:"",ie=N(r.returns);return`z.function()${Q}.returns(${ie})${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodLazy:return`z.lazy(() => ${N(r.getter())})${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodLiteral:return`z.literal(${T(r.value)})${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodEnum:return`z.enum([${r.values.map(T).join(", ")}])${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodEffects:throw new Ee(d.ZodFirstPartyTypeKind.ZodEffects);case d.ZodFirstPartyTypeKind.ZodNativeEnum:throw new Ee(d.ZodFirstPartyTypeKind.ZodNativeEnum);case d.ZodFirstPartyTypeKind.ZodOptional:return`z.optional(${N(r.innerType)})${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodNullable:return`z.nullable(${N(r.innerType)})${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodDefault:let Ge=et(r.defaultValue());return`z.default(${N(r.innerType)}, ${Ge})${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodCatch:throw new Ee(d.ZodFirstPartyTypeKind.ZodCatch);case d.ZodFirstPartyTypeKind.ZodPromise:return`z.promise(${N(r.type)})${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodBranded:throw new Ee(d.ZodFirstPartyTypeKind.ZodBranded);case d.ZodFirstPartyTypeKind.ZodPipeline:throw new Ee(d.ZodFirstPartyTypeKind.ZodPipeline);case d.ZodFirstPartyTypeKind.ZodSymbol:throw new Ee(d.ZodFirstPartyTypeKind.ZodSymbol);case d.ZodFirstPartyTypeKind.ZodReadonly:return`z.readonly(${N(r.innerType)})${R(r)}${A(r)}`.trim();case d.ZodFirstPartyTypeKind.ZodRef:return`z.ref(${T(r.uri)})${R(r)}${A(r)}`.trim();default:Z.assertNever(r)}}a(N,"sUnwrapZod");var A=a(t=>t.description?`.describe(${T(t.description)})`:"","_maybeDescribe"),R=a(t=>`${Nh(t)}${$h(t)}${jh(t)}${Kh(t)}${Uh(t)}${zh(t)}${Fh(t)}`,"_addZuiExtensions"),Nh=a(t=>{var e;return(e=t[b])!=null&&e.title?`.title(${T(t[b].title)})`:""},"_maybeTitle"),$h=a(t=>{var e;return(e=t[b])!=null&&e.displayAs?`.displayAs(${Ri({id:t[b].displayAs[0],params:t[b].displayAs[1]})})`:""},"_maybeDisplayAs"),jh=a(t=>{var e;return(e=t[b])!=null&&e.disabled?`.disabled(${t[b].disabled})`:""},"_maybeDisabled"),Kh=a(t=>{var e;return(e=t[b])!=null&&e.hidden?`.hidden(${t[b].hidden})`:""},"_maybeHidden"),Uh=a(t=>{var e;return(e=t[b])!=null&&e.placeholder?`.placeholder(${T(t[b].placeholder)})`:""},"_maybePlaceholder"),zh=a(t=>{var e;return(e=t[b])!=null&&e.secret?".secret()":""},"_maybeSecret"),Fh=a(t=>{var e;let r=["title","tooltip","displayAs","disabled","hidden","placeholder","secret","coerce"],n=Object.entries((e=t[b])!=null?e:{}).filter(([s])=>!r.includes(s));return n.length>0?`.metadata(${Ri(Object.fromEntries(n))})`:""},"_maybeSetMetadata"),Lh=a(t=>{let e={type:"number",description:t.description,"x-zui":t._def["x-zui"]};t._def[b]&&(e[b]=t._def[b]);for(let r of t._def.checks)switch(r.kind){case"min":{let n=r.inclusive?"minimum":"exclusiveMinimum",s=r.inclusive?"exclusiveMinimum":"minimum";e[n]=r.value,delete e[s];break}case"max":{let n=r.inclusive?"maximum":"exclusiveMaximum",s=r.inclusive?"exclusiveMaximum":"maximum";e[n]=r.value,delete e[s];break}case"int":e.type="integer";break;case"finite":{e.format="finite";break}case"multipleOf":e.multipleOf=r.value;break;default:}return e},"zodNumberToJsonNumber"),kl="\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}",Sl="(([+-]\\d{2}(:?\\d{2})?)|Z)",Wh="Z",Ol="(\\.\\d+)?",Kn="\\.\\d{",qh="}",El=a(t=>{let e=t.precision?Kn+t.precision+qh:t.precision===0?"":Ol,r=t.offset?Sl:Wh;return new RegExp(`^${kl}${e}${r}$`)},"generateDatetimeRegex"),Vh=a(t=>({precision:Gh(t),offset:t.endsWith(`${Sl}$`)}),"extractPrecisionAndOffset"),Gh=a(t=>{let e=t.slice(1+kl.length);return e.startsWith(Ol)?null:e.startsWith(Kn)?parseInt(e.slice(Kn.length)):0},"_extractPrecision"),At={};Fr(At,{escapeSpecialChars:()=>Jh});var Jh=a(t=>t.replaceAll(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeSpecialChars");function is(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage=p(c({},t.errorMessage),{[e]:r}))}a(is,"addErrorMessage");function H(t,e,r,n,s){t[e]=r,is(t,e,n,s)}a(H,"setResponseValueAndErrors");var j={cuid:"^[cC][^\\s-]{8,}$",cuid2:"^[a-z][a-z0-9]*$",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:"^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",uuid:"^[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}$",ipv4:"^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$",ipv6:"^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$"};function as(t,e){let r=c({type:"string"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});function n(s){return e.patternStrategy==="escape"?At.escapeSpecialChars(s):s}if(a(n,"processPattern"),t.checks)for(let s of t.checks)switch(s.kind){case"min":H(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,s.value):s.value,s.message,e);break;case"max":H(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,s.value):s.value,s.message,e);break;case"email":switch(e.emailStrategy){case"format:email":Oe(r,"email",s.message,e);break;case"format:idn-email":Oe(r,"idn-email",s.message,e);break;case"pattern:zod":ue(r,j.email,s.message,e);break}break;case"url":Oe(r,"uri",s.message,e);break;case"uuid":Oe(r,"uuid",s.message,e);break;case"regex":ue(r,s.regex.source,s.message,e);break;case"cuid":ue(r,j.cuid,s.message,e);break;case"cuid2":ue(r,j.cuid2,s.message,e);break;case"startsWith":ue(r,"^"+n(s.value),s.message,e);break;case"endsWith":ue(r,n(s.value)+"$",s.message,e);break;case"datetime":Oe(r,"date-time",s.message,e);break;case"length":H(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,s.value):s.value,s.message,e),H(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,s.value):s.value,s.message,e);break;case"includes":{ue(r,n(s.value),s.message,e);break}case"ip":{s.version!=="v6"&&Oe(r,"ipv4",s.message,e),s.version!=="v4"&&Oe(r,"ipv6",s.message,e);break}case"emoji":ue(r,j.emoji,s.message,e);break;case"ulid":{ue(r,j.ulid,s.message,e);break}case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}a(as,"parseStringDef");var Oe=a((t,e,r,n)=>{var s;t.format||(s=t.anyOf)!=null&&s.some(i=>i.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push(c({format:t.format},t.errorMessage&&n.errorMessages&&{errorMessage:{format:t.errorMessage.format}})),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push(c({format:e},r&&n.errorMessages&&{errorMessage:{format:r}}))):H(t,"format",e,r,n)},"addFormat"),ue=a((t,e,r,n)=>{var s;t.pattern||(s=t.allOf)!=null&&s.some(i=>i.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push(c({pattern:t.pattern},t.errorMessage&&n.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}})),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push(c({pattern:e},r&&n.errorMessages&&{errorMessage:{pattern:r}}))):H(t,"pattern",e,r,n)},"addPattern"),Xh=a(t=>{let e={type:"string",description:t.description,"x-zui":t._def["x-zui"]};t._def[b]&&(e[b]=t._def[b]);for(let r of t._def.checks)switch(r.kind){case"cuid":e.format="cuid",e.pattern=j.cuid;break;case"cuid2":e.format="cuid2",e.pattern=j.cuid2;break;case"ulid":e.format="ulid",e.pattern=j.ulid;break;case"uuid":e.format="uuid",e.pattern=j.uuid;break;case"emoji":e.format="emoji",e.pattern=j.emoji;break;case"email":e.format="email",e.pattern=j.email;break;case"ip":e.format=r.version==="v6"?"ipv6":"ipv4",e.pattern=r.version==="v6"?j.ipv6:j.ipv4;break;case"datetime":e.format="date-time",e.pattern=El(r).source,e[b]=p(c({},e[b]),{precision:r.precision,offset:r.offset});break;case"url":e.format="uri";break;case"endsWith":e.pattern=`${At.escapeSpecialChars(r.value)}$`;break;case"startsWith":e.pattern=`^${At.escapeSpecialChars(r.value)}`;break;case"includes":let n=r.position&&r.position>=1?`^(?:.{${r.position}}).*`:"";e.pattern=`${n}${At.escapeSpecialChars(r.value)}`;break;case"regex":e.pattern=r.regex.source;break;case"length":e.minLength=e.maxLength=Math.max(0,r.value);break;case"min":e.minLength=Math.max(0,r.value);break;case"max":e.maxLength=Math.max(0,r.value);break;default:throw new zi({zodType:d.ZodFirstPartyTypeKind.ZodString,checkKind:r.kind})}return e},"zodStringToJsonString"),Yh=a((t,e)=>{let r={type:"array",description:t.description,items:e(t._def.type),"x-zui":t._def["x-zui"]};return t._def[b]&&(r[b]=t._def[b]),t._def.minLength&&(r.minItems=t._def.minLength.value),t._def.maxLength&&(r.maxItems=t._def.maxLength.value),t._def.exactLength&&(r.minItems=t._def.exactLength.value,r.maxItems=t._def.exactLength.value),r},"zodArrayToJsonArray"),Qh=a((t,e)=>{let r={type:"array",description:t.description,uniqueItems:!0,items:e(t._def.valueType),"x-zui":t._def["x-zui"]};return t._def[b]&&(r[b]=t._def[b]),t._def.minSize&&(r.minItems=t._def.minSize.value),t._def.maxSize&&(r.maxItems=t._def.maxSize.value),r},"zodSetToJsonSet"),em=a((t,e)=>{let r={type:"array",description:t.description,items:t._def.items.map(n=>e(n))};return t._def[b]&&(r[b]=t._def[b]),t._def.rest&&(r.additionalItems=e(t._def.rest)),r},"zodTupleToJsonTuple");function V(t){let e=t,r=e._def;switch(r.typeName){case d.ZodFirstPartyTypeKind.ZodString:return Xh(e);case d.ZodFirstPartyTypeKind.ZodNumber:return Lh(e);case d.ZodFirstPartyTypeKind.ZodNaN:throw new ee(d.ZodFirstPartyTypeKind.ZodNaN);case d.ZodFirstPartyTypeKind.ZodBigInt:throw new ee(d.ZodFirstPartyTypeKind.ZodBigInt,{suggestedAlternative:"serialize bigint to string"});case d.ZodFirstPartyTypeKind.ZodBoolean:return{type:"boolean",description:r.description,"x-zui":r["x-zui"]};case d.ZodFirstPartyTypeKind.ZodDate:throw new ee(d.ZodFirstPartyTypeKind.ZodDate,{suggestedAlternative:"use z.string().datetime() instead"});case d.ZodFirstPartyTypeKind.ZodUndefined:return In(r);case d.ZodFirstPartyTypeKind.ZodNull:return Bn(r);case d.ZodFirstPartyTypeKind.ZodAny:return{description:r.description,"x-zui":r["x-zui"]};case d.ZodFirstPartyTypeKind.ZodUnknown:return{description:r.description,"x-zui":p(c({},r["x-zui"]),{def:{typeName:d.ZodFirstPartyTypeKind.ZodUnknown}})};case d.ZodFirstPartyTypeKind.ZodNever:return{not:!0,description:r.description,"x-zui":r["x-zui"]};case d.ZodFirstPartyTypeKind.ZodVoid:throw new ee(d.ZodFirstPartyTypeKind.ZodVoid);case d.ZodFirstPartyTypeKind.ZodArray:return Yh(e,V);case d.ZodFirstPartyTypeKind.ZodObject:let n=Object.entries(r.shape()),s=n.filter(([g,m])=>!m.isOptional()),i=s.length?s.map(([g])=>g):void 0,o=n.map(([g,m])=>[g,m.mandatory()]).map(([g,m])=>[g,V(m)]),l=!1;return r.unknownKeys instanceof d.ZodType?l=V(r.unknownKeys):r.unknownKeys==="passthrough"&&(l=!0),{type:"object",description:r.description,properties:Object.fromEntries(o),required:i,additionalProperties:l,"x-zui":r["x-zui"]};case d.ZodFirstPartyTypeKind.ZodUnion:return{description:r.description,anyOf:r.options.map(g=>V(g)),"x-zui":r["x-zui"]};case d.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:return{description:r.description,anyOf:r.options.map(g=>V(g)),"x-zui":r["x-zui"]};case d.ZodFirstPartyTypeKind.ZodIntersection:let u=V(r.left),f=V(r.right);return"additionalProperties"in u&&delete u.additionalProperties,"additionalProperties"in f&&delete f.additionalProperties,{description:r.description,allOf:[u,f],"x-zui":r["x-zui"]};case d.ZodFirstPartyTypeKind.ZodTuple:return em(e,V);case d.ZodFirstPartyTypeKind.ZodRecord:return{type:"object",description:r.description,additionalProperties:V(r.valueType),"x-zui":r["x-zui"]};case d.ZodFirstPartyTypeKind.ZodMap:throw new ee(d.ZodFirstPartyTypeKind.ZodMap);case d.ZodFirstPartyTypeKind.ZodSet:return Qh(e,V);case d.ZodFirstPartyTypeKind.ZodFunction:throw new ee(d.ZodFirstPartyTypeKind.ZodFunction);case d.ZodFirstPartyTypeKind.ZodLazy:throw new ee(d.ZodFirstPartyTypeKind.ZodLazy);case d.ZodFirstPartyTypeKind.ZodLiteral:if(typeof r.value=="string")return{type:"string",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(typeof r.value=="number")return{type:"number",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(typeof r.value=="boolean")return{type:"boolean",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(r.value===null)return Bn(r);if(r.value===void 0)return In(r);{d.util.assertEqual(!0);let g=typeof r.value;throw new Wr(`Unsupported literal type: "${g}"`)}case d.ZodFirstPartyTypeKind.ZodEnum:return{type:"string",description:r.description,enum:r.values,"x-zui":r["x-zui"]};case d.ZodFirstPartyTypeKind.ZodEffects:throw new ee(d.ZodFirstPartyTypeKind.ZodEffects);case d.ZodFirstPartyTypeKind.ZodNativeEnum:throw new ee(d.ZodFirstPartyTypeKind.ZodNativeEnum);case d.ZodFirstPartyTypeKind.ZodOptional:return{description:r.description,anyOf:[V(r.innerType),In()],"x-zui":p(c({},r["x-zui"]),{def:{typeName:d.ZodFirstPartyTypeKind.ZodOptional}})};case d.ZodFirstPartyTypeKind.ZodNullable:return{anyOf:[V(r.innerType),Bn()],"x-zui":p(c({},r["x-zui"]),{def:{typeName:d.ZodFirstPartyTypeKind.ZodNullable}})};case d.ZodFirstPartyTypeKind.ZodDefault:return p(c({},V(r.innerType)),{default:r.defaultValue()});case d.ZodFirstPartyTypeKind.ZodCatch:throw new ee(d.ZodFirstPartyTypeKind.ZodCatch);case d.ZodFirstPartyTypeKind.ZodPromise:throw new ee(d.ZodFirstPartyTypeKind.ZodPromise);case d.ZodFirstPartyTypeKind.ZodBranded:throw new ee(d.ZodFirstPartyTypeKind.ZodBranded);case d.ZodFirstPartyTypeKind.ZodPipeline:throw new ee(d.ZodFirstPartyTypeKind.ZodPipeline);case d.ZodFirstPartyTypeKind.ZodSymbol:throw new ee(d.ZodFirstPartyTypeKind.ZodPipeline);case d.ZodFirstPartyTypeKind.ZodReadonly:return p(c({},V(r.innerType)),{readOnly:!0});case d.ZodFirstPartyTypeKind.ZodRef:return{$ref:r.uri,description:r.description,"x-zui":r["x-zui"]};default:d.util.assertNever(r)}}a(V,"toJSONSchema");var In=a(t=>({not:!0,description:t?.description,"x-zui":p(c({},t?.["x-zui"]),{def:{typeName:d.ZodFirstPartyTypeKind.ZodUndefined}})}),"undefinedSchema"),Bn=a(t=>({type:"null",description:t?.description,"x-zui":t?.["x-zui"]}),"nullSchema"),Zl=class{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};a(Zl,"ParseInputLazyPath");var ae=Zl,ki=a((t,e)=>{if(it(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new le(t.common.issues);return this._error=r,this._error}}},"handleResult"),Il=class{constructor(e){this.__type__="ZuiType",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)}get description(){return this._metadataRoot._def.description}dereference(e){return this}getReferences(){return[]}clone(){let e=this.constructor;return new e(c({},this._def))}_getType(e){return pe(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:pe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new te,ctx:{common:e.parent.common,data:e.data,parsedType:pe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Nt(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){var n;let s={common:{issues:[],async:(n=r?.async)!=null?n:!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:pe(e)},i=this._parseSync({data:e,path:s.path,parent:s});return ki(s,i)}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:pe(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(Nt(s)?s:Promise.resolve(s));return ki(n,i)}refine(e,r){let n=a(s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r,"getIssueProperties");return this._refinement((s,i)=>{let o=e(s),l=a(()=>i.addIssue(c({code:h.custom},n(s))),"setError");return typeof Promise<"u"&&o instanceof Promise?o.then(u=>u?!0:(l(),!1)):o?!0:(l(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new we({schema:this,typeName:"ZodEffects",effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return fe.create(this,this._def)}nullable(){return De.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ot.create(this,this._def)}promise(){return zt.create(this,this._def)}mandatory(){return this}or(e){return gn.create([this,e],this._def)}and(e){return on.create(this,e,this._def)}transform(e){return new we(p(c({},k(this._def)),{schema:this,typeName:"ZodEffects",effect:{type:"transform",transform:e}}))}default(e){let r=typeof e=="function"?e:()=>e;return new Kt(p(c({},k(this._def)),{innerType:this,defaultValue:r,typeName:"ZodDefault"}))}brand(){return new nn(c({typeName:"ZodBranded",type:this},k(this._def)))}catch(e){let r=typeof e=="function"?e:()=>e;return new sn(p(c({},k(this._def)),{innerType:this,catchValue:r,typeName:"ZodCatch"}))}describe(e){let r=this.clone();return r._metadataRoot._def.description=e,r}pipe(e){return fn.create(this,e)}readonly(){return Ft.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}metadata(e){var r,n,s;let i=this.clone(),o=i._metadataRoot;(s=(r=o._def)[n=b])!=null||(r[n]={});for(let[l,u]of Object.entries(e))o._def[b]=p(c({},o._def[b]),{[l]:u});return i}getMetadata(){return c({},this._metadataRoot._def[b])}setMetadata(e){this._metadataRoot._def[b]=c({},e)}get ui(){return c({},this._metadataRoot._def[b])}get _metadataRoot(){return this.naked()}displayAs(e){return this.metadata({displayAs:[e.id,e.params]})}title(e){return this.metadata({title:e})}hidden(e){let r;return e===void 0?r=!0:typeof e=="function"?r=e.toString():r=e,this.metadata({hidden:r})}disabled(e){let r;return e===void 0?r=!0:typeof e=="function"?r=e.toString():r=e,this.metadata({disabled:r})}placeholder(e){return this.metadata({placeholder:e})}toJSONSchema(){return V(this)}toTypescriptType(e){return qn(this,e)}toTypescriptSchema(){return ss(this)}naked(){return this}};a(Il,"ZodType");var O=Il,os=(t=>(t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodRef="ZodRef",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly",t))(os||{}),Z;(t=>{t.assertEqual=a(s=>s,"assertEqual");function e(s){}t.assertIs=e,a(e,"assertIs");function r(s){throw new Error("assertNever called")}t.assertNever=r,a(r,"assertNever"),t.arrayToEnum=a(s=>{let i={};for(let o of s)i[o]=o;return i},"arrayToEnum"),t.getValidEnumValues=a(s=>{let i=(0,t.objectKeys)(s).filter(l=>typeof s[s[l]]!="number"),o={};for(let l of i)o[l]=s[l];return(0,t.objectValues)(o)},"getValidEnumValues"),t.objectValues=a(s=>(0,t.objectKeys)(s).map(function(i){return s[i]}),"objectValues"),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=a((s,i)=>{for(let o of s)if(i(o))return o},"find"),t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=n,a(n,"joinValues"),t.jsonStringifyReplacer=a((s,i)=>typeof i=="bigint"?i.toString():i,"jsonStringifyReplacer"),t.compareFunctions=a((s,i)=>s.toString()===i.toString(),"compareFunctions"),t.mock=a(()=>({}),"mock")})(Z||(Z={}));var cr;(t=>{t.mergeShapes=a((e,r)=>c(c({},e),r),"mergeShapes")})(cr||(cr={}));var _=Z.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),pe=a(t=>{switch(typeof t){case"undefined":return _.undefined;case"string":return _.string;case"number":return isNaN(t)?_.nan:_.number;case"boolean":return _.boolean;case"function":return _.function;case"bigint":return _.bigint;case"symbol":return _.symbol;case"object":return Array.isArray(t)?_.array:t===null?_.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?_.promise:typeof Map<"u"&&t instanceof Map?_.map:typeof Set<"u"&&t instanceof Set?_.set:typeof Date<"u"&&t instanceof Date?_.date:_.object;default:return _.unknown}},"getParsedType");function k(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s,supportsExtensions:i,[b]:o}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);let l=o?Object.fromEntries(Object.entries(o).filter(([f])=>f!=="secret"||i?.includes("secret"))):void 0;return e?{errorMap:e,description:s,[b]:l}:{errorMap:a((f,g)=>f.code!=="invalid_type"?{message:g.defaultError}:typeof g.data>"u"?{message:n??g.defaultError}:{message:r??g.defaultError},"customMap"),description:s,[b]:l}}a(k,"processCreateParams");var ls=a((t,e)=>{let r;switch(t.code){case h.invalid_type:t.received===_.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case h.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Z.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:r=`Unrecognized key(s) in object: ${Z.joinValues(t.keys,", ")}`;break;case h.invalid_union:r="Invalid input";break;case h.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Z.joinValues(t.options)}`;break;case h.invalid_enum_value:r=`Invalid enum value. Expected ${Z.joinValues(t.options)}, received '${t.received}'`;break;case h.invalid_arguments:r="Invalid function arguments";break;case h.invalid_return_type:r="Invalid function return type";break;case h.invalid_date:r="Invalid date";break;case h.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:Z.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case h.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case h.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case h.custom:r="Invalid input";break;case h.invalid_intersection_types:r="Intersection results could not be merged";break;case h.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case h.not_finite:r="Number must be finite";break;case h.unresolved_reference:r="Unresolved reference";break;default:r=e.defaultError,Z.assertNever(t)}return{message:r}},"errorMap"),Si=ls,h=Z.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","unresolved_reference"]),Bl=a(t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),ur=class Cl extends Error{constructor(e){super(),this.issues=[],this.addIssue=a(n=>{this.issues=[...this.issues,n]},"addIssue"),this.addIssues=a((n=[])=>{this.issues=[...this.issues,...n]},"addIssues");let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let r=e||function(i){return i.message},n={_errors:[]},s=a(i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)n._errors.push(r(o));else{let l=n,u=0;for(;u<o.path.length;){let f=o.path[u];u===o.path.length-1?(l[f]=l[f]||{_errors:[]},l[f]._errors.push(r(o))):l[f]=l[f]||{_errors:[]},l=l[f],u++}}},"processError");return s(this),n}static assert(e){if(!(e instanceof Cl))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Z.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};a(ur,"ZodError");ur.create=a(t=>new ur(t),"create");var le=ur,Al=ls;function cs(t){Al=t}a(cs,"setErrorMap");function st(){return Al}a(st,"getErrorMap");var Mt=a(t=>{var e;let{data:r,path:n,errorMaps:s,issueData:i}=t,o=[...n,...i.path||[]],l=p(c({},i),{path:o}),u="",f=s.filter(g=>!!g).slice().reverse();for(let g of f)u=g(l,{data:r,defaultError:u}).message;return p(c({},i),{path:o,message:(e=i.message)!=null?e:u})},"makeIssue"),Rl=[];function v(t,e){let r=Mt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,st(),ls].filter(n=>!!n)});t.common.issues.push(r)}a(v,"addIssueToContext");var Hl=class Dl{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let s of r){if(s.status==="aborted")return x;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let s of r)n.push({key:await s.key,value:await s.value});return Dl.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return x;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(n[i.value]=o.value)}return{status:e.value,value:n}}};a(Hl,"ParseStatus");var te=Hl,x=Object.freeze({status:"aborted"}),Re=a(t=>({status:"dirty",value:t}),"DIRTY"),J=a(t=>({status:"valid",value:t}),"OK"),dr=a(t=>t.status==="aborted","isAborted"),pr=a(t=>t.status==="dirty","isDirty"),it=a(t=>t.status==="valid","isValid"),Nt=a(t=>typeof Promise<"u"&&t instanceof Promise,"isAsync"),w;(t=>{t.errToObj=a(e=>typeof e=="string"?{message:e}:e||{},"errToObj"),t.toString=a(e=>typeof e=="string"?e:e?.message,"toString")})(w||(w={}));var fr=class Ml extends O{constructor(){super(...arguments),this._any=!0}_parse(e){return J(e.data)}isEqual(e){return e instanceof Ml}};a(fr,"ZodAny");fr.create=a(t=>new fr(c({typeName:"ZodAny"},k(t))),"create");var at=fr,gr=class Ie extends O{dereference(e){return new Ie(p(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new Ie(p(c({},this._def),{type:this._def.type.clone()}))}isEqual(e){var r,n,s,i,o,l;return e instanceof Ie?tt((r=this._def.exactLength)==null?void 0:r.value,(n=e._def.exactLength)==null?void 0:n.value)&&tt((s=this._def.maxLength)==null?void 0:s.value,(i=e._def.maxLength)==null?void 0:i.value)&&tt((o=this._def.minLength)==null?void 0:o.value,(l=e._def.minLength)==null?void 0:l.value)&&this._def.type.isEqual(e._def.type):!1}_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==_.array)return v(r,{code:h.invalid_type,expected:_.array,received:r.parsedType}),x;if(s.exactLength!==null){let o=r.data.length>s.exactLength.value,l=r.data.length<s.exactLength.value;(o||l)&&(v(r,{code:o?h.too_big:h.too_small,minimum:l?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(v(r,{code:h.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(v(r,{code:h.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((o,l)=>s.type._parseAsync(new ae(r,o,r.path,l)))).then(o=>te.mergeArray(n,o));let i=[...r.data].map((o,l)=>s.type._parseSync(new ae(r,o,r.path,l)));return te.mergeArray(n,i)}get element(){return this._def.type}min(e,r){return new Ie(p(c({},this._def),{minLength:{value:e,message:w.toString(r)}}))}max(e,r){return new Ie(p(c({},this._def),{maxLength:{value:e,message:w.toString(r)}}))}length(e,r){return new Ie(p(c({},this._def),{exactLength:{value:e,message:w.toString(r)}}))}nonempty(e){return this.min(1,e)}};a(gr,"ZodArray");gr.create=a((t,e)=>new gr(c({type:t,minLength:null,maxLength:null,exactLength:null,typeName:"ZodArray"},k(e))),"create");var ot=gr,tm=a((t,e)=>Nl(t,e,new WeakSet),"isEqual"),Nl=a((t,e,r)=>bh(t,e,rm(r)),"_isEqualWithVisitedTracking"),rm=a(t=>(e,r)=>{if(li(e)&&!t.has(e)&&li(r)&&!t.has(r)){let n=Pi(e,wi),s=Pi(r,wi);return t.add(n).add(s).add(e).add(r),Nl(n,s,t)}},"_customizerWithVisitedTracking"),nm={compare:tm},$l=class{constructor(e=[],r={}){this._options=c(c({},nm),r),this._items=[];for(let n of e)this.add(n)}get items(){return[...this._items]}get size(){return this._items.length}has(e){return this._items.some(r=>this._options.compare(r,e))}add(e){this.has(e)||this._items.push(e)}isEqual(e){return this.size!==e.size?!1:this.isSubsetOf(e)&&e.isSubsetOf(this)}isSubsetOf(e){return this.size>e.size?!1:this._items.every(r=>e.has(r))}};a($l,"CustomSet");var K=$l,hr=class tr extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==_.bigint){let i=this._getOrReturnCtx(e);return v(i,{code:h.invalid_type,expected:_.bigint,received:i.parsedType}),x}let n,s=new te;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Z.assertNever(i);return{status:s.value,value:e.data}}isEqual(e){if(!(e instanceof tr)||this._def.coerce!==e._def.coerce)return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)}gte(e,r){return this.setLimit("min",e,!0,w.toString(r))}gt(e,r){return this.setLimit("min",e,!1,w.toString(r))}lte(e,r){return this.setLimit("max",e,!0,w.toString(r))}lt(e,r){return this.setLimit("max",e,!1,w.toString(r))}setLimit(e,r,n,s){return new tr(p(c({},this._def),{checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:w.toString(s)}]}))}_addCheck(e){return new tr(p(c({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:w.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};a(hr,"ZodBigInt");hr.create=a(t=>{var e;return new hr(c({checks:[],typeName:"ZodBigInt",coerce:(e=t?.coerce)!=null?e:!1},k(t)))},"create");var tn=hr,mr=class jl extends O{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==_.boolean){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.boolean,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof jl?this._def.coerce===e._def.coerce:!1}};a(mr,"ZodBoolean");mr.create=a(t=>new mr(c({typeName:"ZodBoolean",coerce:t?.coerce||!1},k(t))),"create");var rn=mr,Kl=Symbol("zod_brand"),Ul=class Tt extends O{dereference(e){return new Tt(p(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new Tt(p(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}isEqual(e){return e instanceof Tt?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}mandatory(){return new Tt(p(c({},this._def),{type:this._def.type.mandatory()}))}};a(Ul,"ZodBranded");var nn=Ul,yr=class bt extends O{_parse(e){let{ctx:r}=this._processInputParams(e),n=p(c({},r),{common:p(c({},r.common),{issues:[]})}),s=this._def.innerType._parse({data:n.data,path:n.path,parent:c({},n)});return Nt(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new le(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new le(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}isEqual(e){return e instanceof bt?this._def.innerType.isEqual(e._def.innerType)&&Z.compareFunctions(this._def.catchValue,e._def.catchValue):!1}dereference(e){return new bt(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new bt(p(c({},this._def),{innerType:this._def.innerType.clone()}))}naked(){return this._def.innerType.naked()}mandatory(){return new bt(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(yr,"ZodCatch");yr.create=a((t,e)=>new yr(c({innerType:t,typeName:"ZodCatch",catchValue:typeof e.catch=="function"?e.catch:()=>e.catch},k(e))),"create");var sn=yr,us=a((t,e={},r)=>t?at.create().superRefine((n,s)=>{var i,o;if(!t(n)){let l=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(o=(i=l.fatal)!=null?i:r)!=null?o:!0,f=typeof l=="string"?{message:l}:l;s.addIssue(p(c({code:"custom"},f),{fatal:u}))}}):at.create(),"custom"),vr=class Un extends O{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==_.date){let i=this._getOrReturnCtx(e);return v(i,{code:h.invalid_type,expected:_.date,received:i.parsedType}),x}if(isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return v(i,{code:h.invalid_date}),x}let n=new te,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:h.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:h.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):Z.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Un(p(c({},this._def),{checks:[...this._def.checks,e]}))}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:w.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:w.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}isEqual(e){if(!(e instanceof Un))return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)&&this._def.coerce===e._def.coerce}};a(vr,"ZodDate");vr.create=a(t=>new vr(c({checks:[],coerce:t?.coerce||!1,typeName:"ZodDate"},k(t))),"create");var an=vr,_r=class wt extends O{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===_.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}dereference(e){return new wt(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new wt(p(c({},this._def),{innerType:this._def.innerType.clone()}))}isEqual(e){return e instanceof wt?this._def.innerType.isEqual(e._def.innerType)&&tt(this._def.defaultValue(),e._def.defaultValue()):!1}unwrap(){return this._def.innerType}naked(){return this._def.innerType.naked()}mandatory(){return new wt(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(_r,"ZodDefault");_r.create=a((t,e,r)=>new _r(c({innerType:t,typeName:"ZodDefault",defaultValue:typeof e=="function"?e:()=>e},k(r))),"create");var Kt=_r,me=a(t=>Array.from(new Set(t)),"unique"),de=a(t=>t instanceof ln?de(t.schema):t instanceof we?de(t.innerType()):t instanceof cn?[t.value]:t instanceof We?t.options:t instanceof un?Z.objectValues(t.enum):t instanceof Kt?de(t._def.innerType):t instanceof Lt?[void 0]:t instanceof dn?[null]:t instanceof fe?[void 0,...de(t.unwrap())]:t instanceof De?[null,...de(t.unwrap())]:t instanceof nn||t instanceof Ft?de(t.unwrap()):t instanceof sn?de(t._def.innerType):[],"getDiscriminator"),zl=class Be extends O{dereference(e){let r=this.options.map(s=>s.dereference(e)),n=Be._getOptionsMap(this.discriminator,r);return new Be(p(c({},this._def),{options:r,optionsMap:n}))}getReferences(){return me(this.options.flatMap(e=>e.getReferences()))}clone(){let e=this.options.map(r=>r.clone());return new Be(p(c({},this._def),{options:e}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==_.object)return v(r,{code:h.invalid_type,expected:_.object,received:r.parsedType}),x;let n=this.discriminator,s=r.data[n],i=this.optionsMap.get(s);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(v(r,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),x)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let s=Be._getOptionsMap(e,r);return new Be(c({typeName:"ZodDiscriminatedUnion",discriminator:e,options:r,optionsMap:s},k(n)))}static _getOptionsMap(e,r){let n=new Map;for(let s of r){let i=de(s.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of i){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,s)}}return n}isEqual(e){if(!(e instanceof Be)||this._def.discriminator!==e._def.discriminator)return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new K(this._def.options,{compare:r}),s=new K(e._def.options,{compare:r});return n.isEqual(s)}};a(zl,"ZodDiscriminatedUnion");var ds=zl;function Ut(t,e){return new We(c({values:t,typeName:"ZodEnum"},k(e)))}a(Ut,"createZodEnum");var ps=class rr extends O{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return v(r,{expected:Z.joinValues(n),received:r.parsedType,code:h.invalid_type}),x}if(this._def.values.indexOf(e.data)===-1){let r=this._getOrReturnCtx(e),n=this._def.values;return v(r,{received:r.data,code:h.invalid_enum_value,options:n}),x}return J(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return rr.create(e,c(c({},this._def),r))}exclude(e,r=this._def){return rr.create(this.options.filter(n=>!e.includes(n)),c(c({},this._def),r))}isEqual(e){if(!(e instanceof rr))return!1;let r=new K(this._def.values),n=new K(e._def.values);return r.isEqual(n)}};a(ps,"ZodEnum");ps.create=Ut;var We=ps,Fl=class Ce extends O{constructor(){super(...arguments),this.validate=this.implement}dereference(e){let r=this._def.args.dereference(e),n=this._def.returns.dereference(e);return new Ce(p(c({},this._def),{args:r,returns:n}))}getReferences(){return me([...this._def.args.getReferences(),...this._def.returns.getReferences()])}clone(){return new Ce(p(c({},this._def),{args:this._def.args.clone(),returns:this._def.returns.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==_.function)return v(r,{code:h.invalid_type,expected:_.function,received:r.parsedType}),x;function n(l,u){return Mt({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,st(),Si].filter(f=>!!f),issueData:{code:h.invalid_arguments,argumentsError:u}})}a(n,"makeArgsIssue");function s(l,u){return Mt({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,st(),Si].filter(f=>!!f),issueData:{code:h.invalid_return_type,returnTypeError:u}})}a(s,"makeReturnsIssue");let i={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof zt){let l=this;return J(async function(...u){let f=new le([]),g=await l._def.args.parseAsync(u,i).catch(E=>{throw f.addIssue(n(u,E)),f}),m=await Reflect.apply(o,this,g);return await l._def.returns._def.type.parseAsync(m,i).catch(E=>{throw f.addIssue(s(m,E)),f})})}else{let l=this;return J(function(...u){let f=l._def.args.safeParse(u,i);if(!f.success)throw new le([n(u,f.error)]);let g=Reflect.apply(o,this,f.data),m=l._def.returns.safeParse(g,i);if(!m.success)throw new le([s(g,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ce(p(c({},this._def),{args:Ne.create(e).rest(rt.create())}))}returns(e){return new Ce(p(c({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new Ce(c({args:e||Ne.create([]).rest(rt.create()),returns:r||rt.create(),typeName:"ZodFunction"},k(n)))}isEqual(e){return e instanceof Ce&&this._def.args.isEqual(e._def.args)&&this._def.returns.isEqual(e._def.returns)}};a(Fl,"ZodFunction");var fs=Fl;function Tr(t,e){let r=pe(t),n=pe(e);if(t===e)return{valid:!0,data:t};if(r===_.object&&n===_.object){let s=Z.objectKeys(e),i=Z.objectKeys(t).filter(l=>s.indexOf(l)!==-1),o=c(c({},t),e);for(let l of i){let u=Tr(t[l],e[l]);if(!u.valid)return{valid:!1};o[l]=u.data}return{valid:!0,data:o}}else if(r===_.array&&n===_.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let o=t[i],l=e[i],u=Tr(o,l);if(!u.valid)return{valid:!1};s.push(u.data)}return{valid:!0,data:s}}else return r===_.date&&n===_.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}a(Tr,"mergeValues");var br=class nr extends O{dereference(e){return new nr(p(c({},this._def),{left:this._def.left.dereference(e),right:this._def.right.dereference(e)}))}getReferences(){return me([...this._def.left.getReferences(),...this._def.right.getReferences()])}clone(){return new nr(p(c({},this._def),{left:this._def.left.clone(),right:this._def.right.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=a((i,o)=>{if(dr(i)||dr(o))return x;let l=Tr(i.value,o.value);return l.valid?((pr(i)||pr(o))&&r.dirty(),{status:r.value,value:l.data}):(v(n,{code:h.invalid_intersection_types}),x)},"handleParsed");return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}isEqual(e){if(!(e instanceof nr))return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new K([this._def.left,this._def.right],{compare:r}),s=new K([e._def.left,e._def.right],{compare:r});return n.isEqual(s)}};a(br,"ZodIntersection");br.create=a((t,e,r)=>new br(c({left:t,right:e,typeName:"ZodIntersection"},k(r))),"create");var on=br,wr=class Pt extends O{get schema(){return this._def.getter()}dereference(e){return new Pt(p(c({},this._def),{getter:a(()=>this._def.getter().dereference(e),"getter")}))}getReferences(){return this._def.getter().getReferences()}clone(){return new Pt(p(c({},this._def),{getter:a(()=>this._def.getter().clone(),"getter")}))}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}isEqual(e){return e instanceof Pt?this._def.getter().isEqual(e._def.getter()):!1}naked(){return this._def.getter().naked()}mandatory(){return new Pt(p(c({},this._def),{getter:a(()=>this._def.getter().mandatory(),"getter")}))}};a(wr,"ZodLazy");wr.create=a((t,e)=>new wr(c({getter:t,typeName:"ZodLazy"},k(e))),"create");var ln=wr,Pr=class Ll extends O{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return v(r,{received:r.data,code:h.invalid_literal,expected:this._def.value}),x}return{status:"valid",value:e.data}}get value(){return this._def.value}isEqual(e){return e instanceof Ll?tt(this._def.value,e._def.value):!1}};a(Pr,"ZodLiteral");Pr.create=a((t,e)=>new Pr(c({value:t,typeName:"ZodLiteral"},k(e))),"create");var cn=Pr,xr=class sr extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}dereference(e){let r=this._def.keyType.dereference(e),n=this._def.valueType.dereference(e);return new sr(p(c({},this._def),{keyType:r,valueType:n}))}getReferences(){return me([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new sr(p(c({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.map)return v(n,{code:h.invalid_type,expected:_.map,received:n.parsedType}),x;let s=this._def.keyType,i=this._def.valueType,o=[...n.data.entries()].map(([l,u],f)=>({key:s._parse(new ae(n,l,n.path,[f,"key"])),value:i._parse(new ae(n,u,n.path,[f,"value"]))}));if(n.common.async){let l=new Map;return Promise.resolve().then(async()=>{for(let u of o){let f=await u.key,g=await u.value;if(f.status==="aborted"||g.status==="aborted")return x;(f.status==="dirty"||g.status==="dirty")&&r.dirty(),l.set(f.value,g.value)}return{status:r.value,value:l}})}else{let l=new Map;for(let u of o){let f=u.key,g=u.value;if(f.status==="aborted"||g.status==="aborted")return x;(f.status==="dirty"||g.status==="dirty")&&r.dirty(),l.set(f.value,g.value)}return{status:r.value,value:l}}}isEqual(e){return!(!(e instanceof sr)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};a(xr,"ZodMap");xr.create=a((t,e,r)=>new xr(c({valueType:e,keyType:t,typeName:"ZodMap"},k(r))),"create");var gs=xr,kr=class Wl extends O{_parse(e){if(this._getType(e)!==_.nan){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.nan,received:n.parsedType}),x}return{status:"valid",value:e.data}}isEqual(e){return e instanceof Wl}};a(kr,"ZodNaN");kr.create=a(t=>new kr(c({typeName:"ZodNaN"},k(t))),"create");var hs=kr,Sr=class ql extends O{_parse(e){let r=Z.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==_.string&&n.parsedType!==_.number){let s=Z.objectValues(r);return v(n,{expected:Z.joinValues(s),received:n.parsedType,code:h.invalid_type}),x}if(r.indexOf(e.data)===-1){let s=Z.objectValues(r);return v(n,{received:n.data,code:h.invalid_enum_value,options:s}),x}return J(e.data)}get enum(){return this._def.values}isEqual(e){return e instanceof ql?tt(this._def.values,e._def.values):!1}};a(Sr,"ZodNativeEnum");Sr.create=a((t,e)=>new Sr(c({values:t,typeName:"ZodNativeEnum"},k(e))),"create");var un=Sr,Or=class Vl extends O{_parse(e){let r=this._getOrReturnCtx(e);return v(r,{code:h.invalid_type,expected:_.never,received:r.parsedType}),x}isEqual(e){return e instanceof Vl}};a(Or,"ZodNever");Or.create=a(t=>new Or(c({typeName:"ZodNever"},k(t))),"create");var ut=Or,Er=class Gl extends O{_parse(e){if(this._getType(e)!==_.null){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.null,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof Gl}};a(Er,"ZodNull");Er.create=a(t=>new Er(c({typeName:"ZodNull"},k(t))),"create");var dn=Er,Zr=class xt extends O{dereference(e){return new xt(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new xt(p(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)===_.null?J(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof xt?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new xt(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(Zr,"ZodNullable");Zr.create=a((t,e)=>new Zr(c({innerType:t,typeName:"ZodNullable"},k(e))),"create");var De=Zr;function Jl(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,i=parseInt(t.toFixed(s).replace(".","")),o=parseInt(e.toFixed(s).replace(".",""));return i%o/Math.pow(10,s)}a(Jl,"floatSafeRemainder");var Ir=class ir extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==_.number){let i=this._getOrReturnCtx(e);return v(i,{code:h.invalid_type,expected:_.number,received:i.parsedType}),x}let n,s=new te;for(let i of this._def.checks)i.kind==="int"?Z.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{code:h.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Jl(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{code:h.not_finite,message:i.message}),s.dirty()):Z.assertNever(i);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,w.toString(r))}gt(e,r){return this.setLimit("min",e,!1,w.toString(r))}lte(e,r){return this.setLimit("max",e,!0,w.toString(r))}lt(e,r){return this.setLimit("max",e,!1,w.toString(r))}setLimit(e,r,n,s){return new ir(p(c({},this._def),{checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:w.toString(s)}]}))}_addCheck(e){return new ir(p(c({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:w.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:w.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:w.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:w.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:w.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Z.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}isEqual(e){if(!(e instanceof ir))return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)}};a(Ir,"ZodNumber");Ir.create=a(t=>new Ir(c({checks:[],typeName:"ZodNumber",coerce:t?.coerce||!1},k(t))),"create");var pn=Ir;function Ae(t){if(t instanceof Me){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=fe.create(Ae(n))}return new Me(p(c({},t._def),{shape:a(()=>e,"shape")}))}else return t instanceof ot?new ot(p(c({},t._def),{type:Ae(t.element)})):t instanceof fe?fe.create(Ae(t.unwrap())):t instanceof De?De.create(Ae(t.unwrap())):t instanceof Ne?Ne.create(t.items.map(e=>Ae(e))):t}a(Ae,"deepPartialify");var be=class ne extends O{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=Z.objectKeys(e);return this._cached={shape:e,keys:r}}dereference(e){let r=this._def.shape(),n={};for(let s in r)n[s]=r[s].dereference(e);return new ne(p(c({},this._def),{shape:a(()=>n,"shape")}))}getReferences(){let e=this._def.shape(),r=[];for(let n in e)r.push(...e[n].getReferences());return me(r)}clone(){let e={},r=this._def.shape();for(let[n,s]of Object.entries(r))e[n]=s.clone();return new ne(p(c({},this._def),{shape:a(()=>e,"shape")}))}_parse(e){if(this._getType(e)!==_.object){let g=this._getOrReturnCtx(e);return v(g,{code:h.invalid_type,expected:_.object,received:g.parsedType}),x}let{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),l=[];if(this._def.unknownKeys!=="strip")for(let g in s.data)o.includes(g)||l.push(g);let u=[];for(let g of o){let m=i[g],P=s.data[g];u.push({key:{status:"valid",value:g},value:m._parse(new ae(s,P,s.path,g)),alwaysSet:g in s.data})}let f=this._def.unknownKeys;if(f==="passthrough")for(let g of l)u.push({key:{status:"valid",value:g},value:{status:"valid",value:s.data[g]}});else if(f==="strict")l.length>0&&(v(s,{code:h.unrecognized_keys,keys:l}),n.dirty());else if(f!=="strip")for(let g of l){let m=s.data[g];u.push({key:{status:"valid",value:g},value:f._parse(new ae(s,m,s.path,g)),alwaysSet:g in s.data})}return s.common.async?Promise.resolve().then(async()=>{let g=[];for(let m of u){let P=await m.key;g.push({key:P,value:await m.value,alwaysSet:m.alwaysSet})}return g}).then(g=>te.mergeObjectSync(n,g)):te.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return w.errToObj,new ne(c(p(c({},this._def),{unknownKeys:"strict"}),e!==void 0?{errorMap:a((r,n)=>{var s,i,o,l;let u=(o=(i=(s=this._def).errorMap)==null?void 0:i.call(s,r,n).message)!=null?o:n.defaultError;return r.code==="unrecognized_keys"?{message:(l=w.errToObj(e).message)!=null?l:u}:{message:u}},"errorMap")}:{}))}strip(){return new ne(p(c({},this._def),{unknownKeys:"strip"}))}passthrough(){return new ne(p(c({},this._def),{unknownKeys:"passthrough"}))}additionalProperties(){if(this._def.unknownKeys instanceof O)return this._def.unknownKeys;if(this._def.unknownKeys==="passthrough")return at.create();if(this._def.unknownKeys==="strict")return ut.create()}extend(e){return new ne(p(c({},this._def),{shape:a(()=>c(c({},this._def.shape()),e),"shape")}))}merge(e){return new ne({unknownKeys:e._def.unknownKeys,shape:a(()=>c(c({},this._def.shape()),e._def.shape()),"shape"),typeName:"ZodObject"})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new ne(p(c({},this._def),{unknownKeys:e}))}pick(e){let r={};return Z.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new ne(p(c({},this._def),{shape:a(()=>r,"shape")}))}omit(e){let r={};return Z.objectKeys(this.shape).forEach(n=>{e[n]||(r[n]=this.shape[n])}),new ne(p(c({},this._def),{shape:a(()=>r,"shape")}))}deepPartial(){return Ae(this)}partial(e){let r={};return Z.objectKeys(this.shape).forEach(n=>{let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s?.optional()}),new ne(p(c({},this._def),{shape:a(()=>r,"shape")}))}required(e){let r={};return Z.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof fe;)i=i._def.innerType;r[n]=i}}),new ne(p(c({},this._def),{shape:a(()=>r,"shape")}))}keyof(){return Ut(Z.objectKeys(this.shape))}isEqual(e){if(!(e instanceof ne)||!this._unknownKeysEqual(e))return!1;let r=this._def.shape(),n=e._def.shape(),s=a((l,u)=>l[0]===u[0]&&l[1].isEqual(u[1]),"compare"),i=new K(Object.entries(r),{compare:s}),o=new K(Object.entries(n),{compare:s});return i.isEqual(o)}_unknownKeysEqual(e){let r=this.additionalProperties(),n=e.additionalProperties();return r===void 0||n===void 0?r===n:r.isEqual(n)}};a(be,"ZodObject");be.create=a((t,e)=>new be(c({shape:a(()=>t,"shape"),unknownKeys:"strip",typeName:"ZodObject"},k(e))),"create");be.strictCreate=a((t,e)=>new be(c({shape:a(()=>t,"shape"),unknownKeys:"strict",typeName:"ZodObject"},k(e))),"strictCreate");be.lazycreate=a((t,e)=>new be(c({shape:t,unknownKeys:"strip",typeName:"ZodObject"},k(e))),"lazycreate");var Me=be,Br=class ar extends O{dereference(e){return new ar(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new ar(p(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)===_.undefined?J(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof ar?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return this._def.innerType.mandatory()}};a(Br,"ZodOptional");Br.create=a((t,e)=>new Br(c({innerType:t,typeName:"ZodOptional"},k(e))),"create");var fe=Br,Xl=class kt extends O{dereference(e){return new kt(p(c({},this._def),{in:this._def.in.dereference(e),out:this._def.out.dereference(e)}))}getReferences(){return me([...this._def.in.getReferences(),...this._def.out.getReferences()])}clone(){return new kt(p(c({},this._def),{in:this._def.in.clone(),out:this._def.out.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return a(async()=>{let i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?x:i.status==="dirty"?(r.dirty(),Re(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})},"handleAsync")();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?x:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new kt({in:e,out:r,typeName:"ZodPipeline"})}isEqual(e){return!(!(e instanceof kt)||!this._def.in.isEqual(e._def.in)||!this._def.out.isEqual(e._def.out))}};a(Xl,"ZodPipeline");var fn=Xl,Cr=class or extends O{unwrap(){return this._def.type}dereference(e){return new or(p(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new or(p(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==_.promise&&r.common.async===!1)return v(r,{code:h.invalid_type,expected:_.promise,received:r.parsedType}),x;let n=r.parsedType===_.promise?r.data:Promise.resolve(r.data);return J(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}isEqual(e){return e instanceof or?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}};a(Cr,"ZodPromise");Cr.create=a((t,e)=>new Cr(c({type:t,typeName:"ZodPromise"},k(e))),"create");var zt=Cr,Ar=class St extends O{dereference(e){return new St(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new St(p(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){let r=this._def.innerType._parse(e);return it(r)&&(r.value=Object.freeze(r.value)),r}unwrap(){return this._def.innerType}isEqual(e){return e instanceof St?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new St(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(Ar,"ZodReadonly");Ar.create=a((t,e)=>new Ar(c({innerType:t,typeName:"ZodReadonly"},k(e))),"create");var Ft=Ar,Yl=class Xe extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}dereference(e){let r=this._def.keyType.dereference(e),n=this._def.valueType.dereference(e);return new Xe(p(c({},this._def),{keyType:r,valueType:n}))}getReferences(){return me([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new Xe(p(c({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.object)return v(n,{code:h.invalid_type,expected:_.object,received:n.parsedType}),x;let s=[],i=this._def.keyType,o=this._def.valueType;for(let l in n.data)s.push({key:i._parse(new ae(n,l,n.path,l)),value:o._parse(new ae(n,n.data[l],n.path,l))});return n.common.async?te.mergeObjectAsync(r,s):te.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof O?new Xe(c({keyType:e,valueType:r,typeName:"ZodRecord"},k(n))):new Xe(c({keyType:X.create(),valueType:e,typeName:"ZodRecord"},k(r)))}isEqual(e){return!(!(e instanceof Xe)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};a(Yl,"ZodRecord");var ms=Yl,Rr=class Ql extends O{dereference(e){let r=e[this._def.uri];return r||this}getReferences(){return[this._def.uri]}_parse(e){let r=this._getOrReturnCtx(e);return v(r,{code:h.unresolved_reference}),x}isOptional(){return!1}isNullable(){return!1}isEqual(e){return e instanceof Ql?this._def.uri===e._def.uri:!1}};a(Rr,"ZodRef");Rr.create=a(t=>new Rr({typeName:"ZodRef",uri:t}),"create");var ys=Rr,Hr=class Ye extends O{dereference(e){return new Ye(p(c({},this._def),{valueType:this._def.valueType.dereference(e)}))}getReferences(){return this._def.valueType.getReferences()}clone(){return new Ye(p(c({},this._def),{valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.set)return v(n,{code:h.invalid_type,expected:_.set,received:n.parsedType}),x;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(v(n,{code:h.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(v(n,{code:h.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let i=this._def.valueType;function o(u){let f=new Set;for(let g of u){if(g.status==="aborted")return x;g.status==="dirty"&&r.dirty(),f.add(g.value)}return{status:r.value,value:f}}a(o,"finalizeSet");let l=[...n.data.values()].map((u,f)=>i._parse(new ae(n,u,n.path,f)));return n.common.async?Promise.all(l).then(u=>o(u)):o(l)}min(e,r){return new Ye(p(c({},this._def),{minSize:{value:e,message:w.toString(r)}}))}max(e,r){return new Ye(p(c({},this._def),{maxSize:{value:e,message:w.toString(r)}}))}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}isEqual(e){var r,n,s,i;if(!(e instanceof Ye))return!1;let o=(r=this._def.minSize)==null?void 0:r.value,l=(n=e._def.minSize)==null?void 0:n.value;if(o!==l)return!1;let u=(s=this._def.maxSize)==null?void 0:s.value,f=(i=e._def.maxSize)==null?void 0:i.value;return u!==f?!1:this._def.valueType.isEqual(e._def.valueType)}};a(Hr,"ZodSet");Hr.create=a((t,e)=>new Hr(c({valueType:t,minSize:null,maxSize:null,typeName:"ZodSet"},k(e))),"create");var vs=Hr,_s=/^c[^\s-]{8,}$/i,Ts=/^[a-z][a-z0-9]*$/,bs=/^[0-9A-HJKMNP-TV-Z]{26}$/,ws=/^[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,Ps=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ec="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",tc=a(t=>t===ec,"isEmojiRegex"),Cn,xs=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,ks=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;function rc(t,e){return!!((e==="v4"||!e)&&xs.test(t)||(e==="v6"||!e)&&ks.test(t))}a(rc,"isValidIP");var Dr=class Qe extends O{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==_.string){let i=this._getOrReturnCtx(e);return v(i,{code:h.invalid_type,expected:_.string,received:i.parsedType}),x}let n=new te,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:h.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:h.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,l=e.data.length<i.value;(o||l)&&(s=this._getOrReturnCtx(e,s),o?v(s,{code:h.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):l&&v(s,{code:h.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")Ps.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"email",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")Cn||(Cn=new RegExp(ec,"u")),Cn.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"emoji",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")ws.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"uuid",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")_s.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"cuid",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")Ts.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"cuid2",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")bs.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"ulid",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),v(s,{validation:"url",code:h.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"regex",code:h.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),v(s,{code:h.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),v(s,{code:h.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),v(s,{code:h.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?El(i).test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{code:h.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="ip"?rc(e.data,i.version)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"ip",code:h.invalid_string,message:i.message}),n.dirty()):Z.assertNever(i);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),c({validation:r,code:h.invalid_string},w.errToObj(n)))}_addCheck(e){return new Qe(p(c({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(c({kind:"email"},w.errToObj(e)))}url(e){return this._addCheck(c({kind:"url"},w.errToObj(e)))}emoji(e){return this._addCheck(c({kind:"emoji"},w.errToObj(e)))}uuid(e){return this._addCheck(c({kind:"uuid"},w.errToObj(e)))}cuid(e){return this._addCheck(c({kind:"cuid"},w.errToObj(e)))}cuid2(e){return this._addCheck(c({kind:"cuid2"},w.errToObj(e)))}ulid(e){return this._addCheck(c({kind:"ulid"},w.errToObj(e)))}ip(e){return this._addCheck(c({kind:"ip"},w.errToObj(e)))}datetime(e){var r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck(c({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(r=e?.offset)!=null?r:!1},w.errToObj(e?.message)))}regex(e,r){return this._addCheck(c({kind:"regex",regex:e},w.errToObj(r)))}includes(e,r){return this._addCheck(c({kind:"includes",value:e,position:r?.position},w.errToObj(r?.message)))}startsWith(e,r){return this._addCheck(c({kind:"startsWith",value:e},w.errToObj(r)))}endsWith(e,r){return this._addCheck(c({kind:"endsWith",value:e},w.errToObj(r)))}min(e,r){return this._addCheck(c({kind:"min",value:e},w.errToObj(r)))}max(e,r){return this._addCheck(c({kind:"max",value:e},w.errToObj(r)))}length(e,r){return this._addCheck(c({kind:"length",value:e},w.errToObj(r)))}nonempty(e){return this.min(1,w.errToObj(e))}trim(){return new Qe(p(c({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}secret(){return this._def[b]=p(c({},this._def[b]),{secret:!0}),this}toLowerCase(){return new Qe(p(c({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new Qe(p(c({},this._def),{checks:[...this._def.checks,{kind:"toUpperCase"}]}))}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}isEqual(e){if(!(e instanceof Qe))return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)}};a(Dr,"ZodString");Dr.create=a(t=>{var e;return new Dr(c({checks:[],typeName:"ZodString",coerce:(e=t?.coerce)!=null?e:!1},k(p(c({},t),{supportsExtensions:["secret"]}))))},"create");var X=Dr,Mr=class nc extends O{_parse(e){if(this._getType(e)!==_.symbol){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.symbol,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof nc}};a(Mr,"ZodSymbol");Mr.create=a(t=>new Mr(c({typeName:"ZodSymbol"},k(t))),"create");var Ss=Mr,lt=class Ot extends O{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName==="ZodEffects"?this._def.schema.sourceType():this._def.schema}dereference(e){return new Ot(p(c({},this._def),{schema:this._def.schema.dereference(e)}))}getReferences(){return this._def.schema.getReferences()}clone(){return new Ot(p(c({},this._def),{schema:this._def.schema.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a(o=>{v(n,o),o.fatal?r.abort():r.dirty()},"addIssue"),get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let o=s.transform(n.data,i);if(n.common.async)return Promise.resolve(o).then(async l=>{if(r.value==="aborted")return x;let u=await this._def.schema._parseAsync({data:l,path:n.path,parent:n});return u.status==="aborted"?x:u.status==="dirty"||r.value==="dirty"?Re(u.value):u});{if(r.value==="aborted")return x;let l=this._def.schema._parseSync({data:o,path:n.path,parent:n});return l.status==="aborted"?x:l.status==="dirty"||r.value==="dirty"?Re(l.value):l}}if(s.type==="refinement"){let o=a(l=>{let u=s.refinement(l,i);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return l},"executeRefinement");if(n.common.async===!1){let l=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return l.status==="aborted"?x:(l.status==="dirty"&&r.dirty(),o(l.value),{status:r.value,value:l.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(l=>l.status==="aborted"?x:(l.status==="dirty"&&r.dirty(),o(l.value).then(()=>({status:r.value,value:l.value}))))}if(s.type==="transform")if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!it(o))return o;let l=s.transform(o.value,i);if(l instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:l}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>it(o)?Promise.resolve(s.transform(o.value,i)).then(l=>({status:r.value,value:l})):o);Z.assertNever(s)}isEqual(e){return!(e instanceof Ot)||!this._def.schema.isEqual(e._def.schema)?!1:this._def.effect.type==="refinement"?e._def.effect.type!=="refinement"?!1:Z.compareFunctions(this._def.effect.refinement,e._def.effect.refinement):this._def.effect.type==="transform"?e._def.effect.type!=="transform"?!1:Z.compareFunctions(this._def.effect.transform,e._def.effect.transform):this._def.effect.type==="preprocess"?e._def.effect.type!=="preprocess"?!1:Z.compareFunctions(this._def.effect.transform,e._def.effect.transform):!1}naked(){return this._def.schema.naked()}mandatory(){return new Ot(p(c({},this._def),{schema:this._def.schema.mandatory()}))}};a(lt,"ZodEffects");lt.create=a((t,e,r)=>new lt(c({schema:t,typeName:"ZodEffects",effect:e},k(r))),"create");lt.createWithPreprocess=a((t,e,r)=>new lt(c({schema:e,effect:{type:"preprocess",transform:t},typeName:"ZodEffects"},k(r))),"createWithPreprocess");var we=lt,Nr=class Et extends O{dereference(e){let r=this._def.items.map(s=>s.dereference(e)),n=this._def.rest?this._def.rest.dereference(e):null;return new Et(p(c({},this._def),{items:r,rest:n}))}getReferences(){return me([...this._def.items.flatMap(e=>e.getReferences()),...this._def.rest?this._def.rest.getReferences():[]])}clone(){let e=this._def.items.map(n=>n.clone()),r=this._def.rest?this._def.rest.clone():null;return new Et(p(c({},this._def),{items:e,rest:r}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.array)return v(n,{code:h.invalid_type,expected:_.array,received:n.parsedType}),x;if(n.data.length<this._def.items.length)return v(n,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),x;!this._def.rest&&n.data.length>this._def.items.length&&(v(n,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...n.data].map((o,l)=>{let u=this._def.items[l]||this._def.rest;return u?u._parse(new ae(n,o,n.path,l)):null}).filter(o=>!!o);return n.common.async?Promise.all(i).then(o=>te.mergeArray(r,o)):te.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new Et(p(c({},this._def),{rest:e}))}isEqual(e){if(!(e instanceof Et)||!this._restEquals(e))return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new K(this._def.items,{compare:r}),s=new K(e._def.items,{compare:r});return n.isEqual(s)}_restEquals(e){return this._def.rest===null?e._def.rest===null:e._def.rest!==null&&this._def.rest.isEqual(e._def.rest)}};a(Nr,"ZodTuple");Nr.create=a((t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Nr(c({items:t,typeName:"ZodTuple",rest:null},k(e)))},"create");var Ne=Nr,$r=class sc extends O{_parse(e){if(this._getType(e)!==_.undefined){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.undefined,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof sc}mandatory(){return ut.create(c({},this._def))}};a($r,"ZodUndefined");$r.create=a(t=>new $r(c({typeName:"ZodUndefined"},k(t))),"create");var Lt=$r,jr=class Zt extends O{dereference(e){let r=this._def.options.map(n=>n.dereference(e));return new Zt(p(c({},this._def),{options:r}))}getReferences(){return me(this._def.options.reduce((e,r)=>[...e,...r.getReferences()],[]))}clone(){let e=this._def.options.map(r=>r.clone());return new Zt(p(c({},this._def),{options:e}))}_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function s(i){for(let l of i)if(l.result.status==="valid")return l.result;for(let l of i)if(l.result.status==="dirty")return r.common.issues.push(...l.ctx.common.issues),l.result;let o=i.map(l=>new le(l.ctx.common.issues));return v(r,{code:h.invalid_union,unionErrors:o}),x}if(a(s,"handleResults"),r.common.async)return Promise.all(n.map(async i=>{let o=p(c({},r),{common:p(c({},r.common),{issues:[]}),parent:null});return{result:await i._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(s);{let i,o=[];for(let u of n){let f=p(c({},r),{common:p(c({},r.common),{issues:[]}),parent:null}),g=u._parseSync({data:r.data,path:r.path,parent:f});if(g.status==="valid")return g;g.status==="dirty"&&!i&&(i={result:g,ctx:f}),f.common.issues.length&&o.push(f.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let l=o.map(u=>new le(u));return v(r,{code:h.invalid_union,unionErrors:l}),x}}get options(){return this._def.options}isEqual(e){if(!(e instanceof Zt))return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new K([...this._def.options],{compare:r}),s=new K([...e._def.options],{compare:r});return n.isEqual(s)}mandatory(){let e=this._def.options.filter(i=>!(i instanceof Lt)).map(i=>i.mandatory()),[r,n,...s]=e;return r?n?new Zt(p(c({},this._def),{options:[r,n,...s]})):r:ut.create(c({},this._def))}};a(jr,"ZodUnion");jr.create=a((t,e)=>new jr(c({options:t,typeName:"ZodUnion"},k(e))),"create");var gn=jr,Kr=class ic extends O{constructor(){super(...arguments),this._unknown=!0}_parse(e){return J(e.data)}isEqual(e){return e instanceof ic}};a(Kr,"ZodUnknown");Kr.create=a(t=>new Kr(c({typeName:"ZodUnknown"},k(t))),"create");var rt=Kr,Ur=class ac extends O{_parse(e){if(this._getType(e)!==_.undefined){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.void,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof ac}};a(Ur,"ZodVoid");Ur.create=a(t=>new Ur(c({typeName:"ZodVoid"},k(t))),"create");var Os=Ur,sm=["gpt-3.5-turbo","gpt-3.5-turbo-16k","gpt-4","gpt-4-1106-preview","gpt-4-vision-preview","gpt-4-0125-preview","gpt-4-turbo-preview","gpt-4-turbo","gpt-4o","gpt-3.5-turbo-0125","gpt-3.5-turbo-1106"],yv=We.create(["any","string","number","boolean","object","pattern","date","array","target","time","enum"]),oc=a(t=>X.create().displayAs({id:"variable",params:c({type:t?.type||"any"},t?.params)}),"variable"),lc=a(t=>X.create().displayAs({id:"conversation",params:c({},t?.params)}),"conversation"),cc=a(t=>X.create().displayAs({id:"user",params:c({},t?.params)}),"user"),uc=a(t=>X.create().displayAs({id:"message",params:c({},t?.params)}),"message"),dc=a(t=>X.create().displayAs({id:"agent",params:c({},t?.params)}),"agent"),pc=a(t=>X.create().displayAs({id:"event",params:c({},t?.params)}),"event"),fc=a(t=>X.create().displayAs({id:"table",params:c({},t?.params)}),"table"),gc=a(t=>X.create().displayAs({id:"tablerow",params:c({},t?.params)}),"tablerow"),hc=a(t=>X.create().displayAs({id:"intent",params:c({},t?.params)}),"intent"),mc=a(()=>We.create(sm).displayAs({id:"dropdown",params:{}}),"aimodel"),yc=a(t=>X.create().displayAs({id:"datasource",params:c({},t)}),"datasource"),vc=a(t=>X.create().displayAs({id:"knowledgebase",params:c({},t)}),"knowledgebase"),_c={object:Me.lazycreate},Tc=a((t,e={message:`Input not instance of ${t.name}`})=>us(r=>r instanceof t,e),"instanceOfType"),Es=X.create,Zs=pn.create,bc=hs.create,wc=tn.create,Is=rn.create,Pc=an.create,xc=Ss.create,kc=Lt.create,Sc=dn.create,Oc=at.create,Ec=rt.create,Zc=ut.create,Ic=Os.create,Bc=ot.create,Cc=Me.create,Ac=Me.strictCreate,Rc=gn.create,Hc=ds.create,Dc=on.create,Mc=Ne.create,Nc=ms.create,$c=ys.create,jc=Ft.create,Kc=gs.create,Uc=vs.create,zc=fs.create,Fc=ln.create,Lc=cn.create,Wc=We.create,qc=un.create,Vc=zt.create,zn=we.create,Gc=fe.create,Jc=De.create,im=Kt.create,Xc=we.createWithPreprocess,Yc=fn.create,Qc=a(()=>Es().optional(),"ostring"),eu=a(()=>Zs().optional(),"onumber"),tu=a(()=>Is().optional(),"oboolean"),ru={string:a(t=>X.create(p(c({},t),{coerce:!0})),"string"),number:a(t=>pn.create(p(c({},t),{coerce:!0})),"number"),boolean:a(t=>rn.create(p(c({},t),{coerce:!0})),"boolean"),bigint:a(t=>tn.create(p(c({},t),{coerce:!0})),"bigint"),date:a(t=>an.create(p(c({},t),{coerce:!0})),"date")},nu=x,d=y,su=a((t,e)=>t.anyOf.length?t.anyOf.length===1?L(t.anyOf[0],p(c({},e),{path:[...e.path,"anyOf",0]})):`z.union([${t.anyOf.map((r,n)=>L(r,p(c({},e),{path:[...e.path,"anyOf",n]}))).join(", ")}])`:"z.any()","parseAnyOf"),am=a(t=>{var e;return(e=t[b])!=null&&e.coerce?"z.coerce.boolean()":"z.boolean()"},"parseBoolean"),om=a(t=>"z.any()","parseDefault"),lm=a((t,e)=>`z.union([${t.type.map(r=>L(p(c({},t),{type:r}),e)).join(", ")}])`,"parseMultipleType"),cm=a((t,e)=>`z.any().refine((value) => !${L(t.not,p(c({},e),{path:[...e.path,"not"]}))}.safeParse(value).success, "Invalid input: Should NOT be valid against schema")`,"parseNot"),um=a(t=>"z.null()","parseNull"),dm=a(t=>[t.slice(0,t.length/2),t.slice(t.length/2)],"half"),pm=a((t,...e)=>Object.keys(t).reduce((r,n)=>(e.includes(n)||(r[n]=t[n]),r),{}),"omit");function G(t,e,r){var n;let s=t[e],i="";if(s!==void 0){let o=r({value:s,json:JSON.stringify(s)});if(o){let l=o[0],u=o.length===3?o[1]:"",f=o.length===3?o[2]:o[1];i+=l,((n=t.errorMessage)==null?void 0:n[e])!==void 0&&(i+=u+JSON.stringify(t.errorMessage[e])),i+=f}}return i}a(G,"withMessage");var It=Symbol("Original index"),fm=a(t=>{let e=[];for(let r=0;r<t.length;r++){let n=t[r];if(typeof n=="boolean")e.push(n?{[It]:r}:{[It]:r,not:{}});else{if(It in n)return t;e.push(p(c({},n),{[It]:r}))}}return e},"ensureOriginalIndex");function $t(t,e){if(t.allOf.length===0)return"z.never()";if(t.allOf.length===1){let r=t.allOf[0];return L(r,p(c({},e),{path:[...e.path,"allOf",r[It]]}))}else{let[r,n]=dm(fm(t.allOf));return`z.intersection(${$t({allOf:r},e)}, ${$t({allOf:n},e)})`}}a($t,"parseAllOf");var gm=a((t,e)=>{if(Array.isArray(t.items))return`z.tuple([${t.items.map((n,s)=>L(n,p(c({},e),{path:[...e.path,"items",s]})))}])`;let r=t.items?`z.array(${L(t.items,p(c({},e),{path:[...e.path,"items"]}))})`:"z.array(z.any())";return r+=G(t,"minItems",({json:n})=>[`.min(${n}`,", ",")"]),r+=G(t,"maxItems",({json:n})=>[`.max(${n}`,", ",")"]),r},"parseArray"),hm=a(t=>`z.literal(${JSON.stringify(t.const)})`,"parseConst"),mm=a(t=>t.enum.length===0?"z.never()":t.enum.length===1?`z.literal(${JSON.stringify(t.enum[0])})`:t.enum.every(e=>typeof e=="string")?`z.enum([${t.enum.map(e=>JSON.stringify(e))}])`:`z.union([${t.enum.map(e=>`z.literal(${JSON.stringify(e)})`).join(", ")}])`,"parseEnum"),ym=a((t,e)=>{let r=L(t.if,p(c({},e),{path:[...e.path,"if"]})),n=L(t.then,p(c({},e),{path:[...e.path,"then"]})),s=L(t.else,p(c({},e),{path:[...e.path,"else"]}));return`z.union([${n}, ${s}]).superRefine((value,ctx) => {
12
12
  const result = ${r}.safeParse(value).success
13
13
  ? ${n}.safeParse(value)
14
14
  : ${s}.safeParse(value);
@@ -64,7 +64,7 @@ ${Q}`.trim();case d.ZodFirstPartyTypeKind.ZodEnum:return l.values.map(T).join("
64
64
  `,s+=`}
65
65
  `,s+=`}
66
66
  `),s+=`}
67
- `,s+="})"}let i=r?s?r+s:n?n==="z.never()"?r+".strict()":r+`.catchall(${n})`:r:s||(n?`z.record(${n})`:"z.record(z.any())");return $.an.anyOf(t)&&(i+=`.and(${su(p(c({},t),{anyOf:t.anyOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?p(c({},o),{type:"object"}):o)}),e)})`),$.a.oneOf(t)&&(i+=`.and(${Bs(p(c({},t),{oneOf:t.oneOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?p(c({},o),{type:"object"}):o)}),e)})`),$.an.allOf(t)&&(i+=`.and(${$t(p(c({},t),{allOf:t.allOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?p(c({},o),{type:"object"}):o)}),e)})`),i}a(iu,"parseObject");var _m=a(t=>{var e;let r="z.string()";if((e=t[b])!=null&&e.coerce){if(t.format==="date-time")return"z.coerce.date()";r="z.coerce.string()"}return r+=G(t,"format",({value:n})=>{switch(n){case"email":return[".email(",")"];case"ip":return[".ip(",")"];case"ipv4":return['.ip({ version: "v4"',", message: "," })"];case"ipv6":return['.ip({ version: "v6"',", message: "," })"];case"uri":return[".url(",")"];case"uuid":return[".uuid(",")"];case"date-time":return[".datetime(",")"]}}),r+=G(t,"pattern",({json:n})=>[`.regex(new RegExp(${n})`,", ",")"]),r+=G(t,"minLength",({json:n})=>[`.min(${n}`,", ",")"]),r+=G(t,"maxLength",({json:n})=>[`.max(${n}`,", ",")"]),r},"parseString"),Tm=a((t,e)=>`${L(pm(t,"nullable"),e,!0)}.nullable()`,"parseNullable"),bm=a(t=>`z.ref('${t.$ref}')`,"parseRef"),wm=a((t,e)=>{var r,n;if(t.oneOf.length<=1||!((r=t.discriminator)!=null&&r.propertyName))return Bs(t,e);let s=t.oneOf.map((i,o)=>L(i,p(c({},e),{path:[...e.path,"oneOf",o]})));return`z.discriminatedUnion("${(n=t.discriminator)==null?void 0:n.propertyName}", [${s.join(", ")}])`},"parseDiscriminator"),L=a((t,e={seen:new Map,path:[]},r)=>{if(typeof t!="object")return t?"z.any()":"z.never()";if(e.parserOverride){let i=e.parserOverride(t,e);if(typeof i=="string")return i}let n=e.seen.get(t);if(n){if(n.r!==void 0)return n.r;if(e.depth===void 0||n.n>=e.depth)return"z.any()";n.n+=1}else n={r:void 0,n:0},e.seen.set(t,n);let s=km(t,e);return r||(s=Pm(t,s),e.withoutDefaults||(s=xm(t,s))),n.r=s,s},"parseSchema"),Pm=a((t,e)=>(t.description&&(e+=`.describe(${JSON.stringify(t.description)})`),e),"addMeta"),xm=a((t,e)=>(t.default!==void 0&&(e+=`.default(${JSON.stringify(t.default)})`),e),"addDefaults"),km=a((t,e)=>$.a.nullable(t)?Tm(t,e):$.an.object(t)?iu(t,e):$.an.array(t)?gm(t,e):$.an.anyOf(t)?su(t,e):$.an.allOf(t)?$t(t,e):$.a.discriminator(t)?wm(t,e):$.a.oneOf(t)?Bs(t,e):$.a.not(t)?cm(t,e):$.an.enum(t)?mm(t):$.a.const(t)?hm(t):$.a.multipleType(t)?lm(t,e):$.a.primitive(t,"string")?_m(t):$.a.primitive(t,"number")||$.a.primitive(t,"integer")?vm(t):$.a.primitive(t,"boolean")?am(t):$.a.primitive(t,"null")?um(t):$.a.conditional(t)?ym(t,e):$.a.ref(t)?bm(t):om(t),"selectParser"),$={an:{object:a(t=>t.type==="object","object"),array:a(t=>t.type==="array","array"),anyOf:a(t=>t.anyOf!==void 0,"anyOf"),allOf:a(t=>t.allOf!==void 0,"allOf"),enum:a(t=>t.enum!==void 0,"enum")},a:{nullable:a(t=>t.nullable===!0,"nullable"),multipleType:a(t=>Array.isArray(t.type),"multipleType"),not:a(t=>t.not!==void 0,"not"),const:a(t=>t.const!==void 0,"const"),primitive:a((t,e)=>t.type===e,"primitive"),conditional:a(t=>!!("if"in t&&t.if&&"then"in t&&"else"in t&&t.then&&t.else),"conditional"),discriminator:a(t=>{var e;return t.oneOf!==void 0&&((e=t.discriminator)==null?void 0:e.propertyName)!==void 0},"discriminator"),oneOf:a(t=>t.oneOf!==void 0,"oneOf"),ref:a(t=>t.$ref!==void 0,"ref")}},Sm=a(t=>{let e;try{e=new Function("z",`return ${t}`)(d)}catch(r){return{sucess:!1,error:`Failed to evaluate schema: ${(r instanceof Error?r:new Error(String(r))).message}`}}return e instanceof d.ZodType?{sucess:!0,value:e}:{sucess:!1,error:`String "${t}" does not evaluate to a Zod schema`}},"evalZuiString"),Om=a(t=>L(t,{seen:new Map,path:[]}),"jsonSchemaToZodStr"),Em=a(t=>{let e=Om(t);e=e.replaceAll("errors: z.ZodError[]","errors");let r=Sm(e);if(!r.sucess)throw new Lr(r.error);return r.value},"jsonSchemaToZod"),Bt=a((t,e)=>{var r,n;if(e[b]&&t._def&&(t._def[b]=e[b]),((r=t._def)==null?void 0:r.typeName)==="ZodObject"&&e.type==="object"&&e.properties&&Object.entries(e.properties).forEach(([s,i])=>{let o=typeof t._def.shape=="function"?t._def.shape():t._def.shape;o[s]&&Bt(o[s],i)}),((n=t._def)==null?void 0:n.typeName)==="ZodRecord"&&e.type==="object"&&e.additionalProperties&&Bt(t._def.valueType,e.additionalProperties),e.type==="array"&&e.items){let s=e.items;if(typeof s=="object"&&!Array.isArray(s)){let i=t._def.type;i&&Bt(i,s)}else Array.isArray(s)&&s.forEach((i,o)=>{let l=t._def;l.typeName===y.ZodFirstPartyTypeKind.ZodTuple&&Bt(l.items[o],i)})}},"applyZuiPropsRecursively"),Zm=a(t=>{let e=Em(t);return Bt(e,t),e},"fromJSONSchemaLegacy"),Im=a(t=>{var e,r;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(n=>typeof n!="boolean"&&au(n))&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===d.ZodFirstPartyTypeKind.ZodOptional},"isOptionalSchema"),Bm=a(t=>{var e,r;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(n=>typeof n!="boolean"&&n.type==="null")&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===d.ZodFirstPartyTypeKind.ZodNullable},"isNullableSchema"),au=a(t=>{var e,r;return t.not===!0&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===d.ZodFirstPartyTypeKind.ZodUndefined},"isUndefinedSchema"),Cm=a(t=>{var e,r;return!t.not&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===d.ZodFirstPartyTypeKind.ZodUnknown},"isUnknownSchema"),Am=a(({type:t,minimum:e,exclusiveMinimum:r,maximum:n,exclusiveMaximum:s,multipleOf:i,format:o})=>{let l=d.number();return t==="integer"&&(l=l.int()),o==="finite"&&(l=l.finite()),r!==void 0?l=l.gt(r):e!==void 0&&(l=l.gte(e)),s!==void 0?l=l.lt(s):n!==void 0&&(l=l.lte(n)),i!==void 0&&(l=l.multipleOf(i)),l},"numberJSONSchemaToZuiNumber"),Rm=a(({format:t,pattern:e,minLength:r,maxLength:n})=>{let s=d.string();if(r&&n&&r===n?s=s.length(r):(r&&(s=s.min(r)),n&&(s=s.max(n))),t==="cuid"||e===j.cuid)s=s.cuid();else if(t==="cuid2"||e===j.cuid2)s=s.cuid2();else if(t==="emoji"||e===j.emoji)s=s.emoji();else if(t==="ulid"||e===j.ulid)s=s.ulid();else if(t==="date-time"){let{precision:i,offset:o}=e?Vh(e):{};s=s.datetime({precision:i,offset:o})}else t==="email"||e===j.email?s=s.email():t==="ipv4"||e===j.ipv4?s=s.ip():t==="ipv6"||e===j.ipv6?s=s.ip("v6"):t==="uri"?s=s.url():t==="uuid"||e===j.uuid?s=s.uuid():e&&(s=s.regex(new RegExp(e)));return s},"stringJSONSchemaToZuiString"),_t=a((t,e)=>{let r=[];e.enum!==void 0&&r.push(...e.enum),e.const!==void 0&&r.push(e.const);let n=r.filter(o=>typeof o===t),[s]=n;if(!s){if(t==="string"&&e.type==="string")return Rm(e);if(t==="number"&&(e.type==="number"||e.type==="integer"))return Am(e);if(t==="boolean")return d.boolean();if(t==="null")return d.null();throw new Lr(`Unknown primitive type: "${t}"`)}if(n.length===1)return d.literal(s);let i=n.map(o=>d.literal(o));return d.union(i)},"toZuiPrimitive"),Hm=a((t,e)=>Dm(t)?Nm(t,e):Mm(t)?$m(t,e):jm(t,e),"arrayJSONSchemaToZuiArray"),Dm=a(t=>Array.isArray(t.items),"_isTuple"),Mm=a(t=>t.items!==void 0&&t.uniqueItems,"_isSet"),Nm=a(({items:t,additionalItems:e},r)=>{let n=t.map(r),s=d.tuple(n);return e!==void 0&&(s=s.rest(r(e))),s},"_handleTuple"),$m=a(({items:t,minItems:e,maxItems:r},n)=>{let s=d.set(n(t));return e&&(s=s.min(e)),r&&(s=s.max(r)),s},"_handleSet"),jm=a(({minItems:t,maxItems:e,items:r},n)=>{let s=d.array(n(r));return t&&t===e?s.length(t):(t&&(s=s.min(t)),e&&(s=s.max(e)),s)},"_handleArray"),Je=d.any();function ou(t){return F(t)}a(ou,"fromJSONSchema");function F(t){var e;if(t===void 0)return Je;if(t===!0)return d.any();if(t===!1)return d.never();if(t.default!==void 0)return F(p(c({},t),{default:void 0})).default(t.default);if(t.readOnly)return F(p(c({},t),{readOnly:void 0})).readonly();if(t.oneOf!==void 0)throw new _e({oneOf:t.oneOf});if(t.patternProperties!==void 0)throw new _e({patternProperties:t.patternProperties});if(t.propertyNames!==void 0)throw new _e({propertyNames:t.propertyNames});if(t.if!==void 0)throw new _e({if:t.if});if(t.then!==void 0)throw new _e({then:t.then});if(t.else!==void 0)throw new _e({else:t.else});if(t.$ref!==void 0)return d.ref(t.$ref);if(t.not!==void 0){if(au(t))return d.undefined();if(t.not===!0)return d.never();throw new _e({not:t.not})}if(Array.isArray(t.type)){if(t.type.length===0)return Je;if(t.type.length===1)return F(p(c({},t),{type:t.type[0]}));let r=t,{type:n}=r,s=Bi(r,["type"]),i=t.type.map(o=>F(p(c({},s),{type:o})));return d.union(i)}if(t.type==="string")return t.enum&&t.enum.length>0?d.enum(t.enum):_t("string",t);if(t.type==="integer"){let r=_t("number",t);return r instanceof d.ZodNumber?r.int():r}if(t.type==="number")return _t("number",t);if(t.type==="boolean")return _t("boolean",t);if(t.type==="null")return _t("null",t);if(t.type==="array")return Hm(t,F);if(t.type==="object"){if(t.additionalProperties!==void 0&&t.properties!==void 0){let r=F(t.additionalProperties);return F(p(c({},t),{additionalProperties:void 0})).catchall(r)}if(t.properties!==void 0){let r={};for(let[n,s]of Object.entries(t.properties)){let i=F(s),o=(e=t.required)!=null?e:[];r[n]=o.includes(n)?i:i.optional()}return d.object(r)}if(t.additionalProperties!==void 0){let r=F(t.additionalProperties);return d.record(r)}return d.record(Je)}if(t.anyOf!==void 0){if(t.anyOf.length===0)return Je;if(t.anyOf.length===1)return F(t.anyOf[0]);if(Im(t))return F(t.anyOf[0]).optional();if(Bm(t))return F(t.anyOf[0]).nullable();let r=t.anyOf.map(F);return d.union(r)}if(t.allOf!==void 0){if(t.allOf.length===0)return Je;if(t.allOf.length===1)return F(t.allOf[0]);let[r,...n]=t.allOf,s=F(r),i=F({allOf:n});return d.intersection(s,i)}return Cm(t)?d.unknown():Je}a(F,"_fromJSONSchema");var Km=/^\d{4}-\d{2}-\d{2}(T|\s)?((\d{2}:\d{2}:\d{2}(\.\d{1,3})?)|(\d{2}:\d{2}))?(\s?([+-]\d{2}:\d{2}|Z))?$/,Fn=a((t,e,r=!0)=>{if(typeof t!="object")throw new Rn("Input must be an object");let n=a(o=>{let l=o;return e?.nullable&&(l=l.nullable()),e?.optional&&(l=l.optional()),e?.passtrough&&typeof l.passthrough=="function"&&(l=l.passthrough()),l},"applyOptions"),s=Object.entries(t).reduce((o,[l,u])=>{if(u===null)o[l]=n(y.null());else switch(typeof u){case"string":o[l]=Km.test(u)?n(y.string().datetime()):n(y.string());break;case"number":o[l]=n(y.number());break;case"boolean":o[l]=n(y.boolean());break;case"object":Array.isArray(u)?u.length===0?o[l]=n(y.array(y.unknown())):typeof u[0]=="object"?o[l]=n(y.array(Fn(u[0],e,!1))):["string","number","boolean"].includes(typeof u[0])&&(o[l]=n(y.array(y[typeof u[0]]()))):o[l]=n(Fn(u,e,!1));break;default:throw new Rn(`Unsupported type for key ${l}`)}return o},{}),i=Object.keys(s).length>0;return e?.passtrough||!r&&!i?y.object(s).passthrough():y.object(s)},"fromObject");function lu(){return{}}a(lu,"parseAnyDef");function cu(t,e){var r,n;let s={type:"array"};return((n=(r=t.type)==null?void 0:r._def)==null?void 0:n.typeName)!=="ZodAny"&&(s.items=C(t.type._def,p(c({},e),{currentPath:[...e.currentPath,"items"]}))),t.minLength&&H(s,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&H(s,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(H(s,"minItems",t.exactLength.value,t.exactLength.message,e),H(s,"maxItems",t.exactLength.value,t.exactLength.message,e)),s}a(cu,"parseArrayDef");function uu(t,e){let r=c({type:"integer",format:"int64"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?H(r,"minimum",n.value,n.message,e):H(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),H(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?H(r,"maximum",n.value,n.message,e):H(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),H(r,"maximum",n.value,n.message,e));break;case"multipleOf":H(r,"multipleOf",n.value,n.message,e);break}return r}a(uu,"parseBigintDef");function du(t){return c({type:"boolean"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{})}a(du,"parseBooleanDef");function pu(t,e){return C(t.type._def,e)}a(pu,"parseBrandedDef");var Um=a((t,e)=>C(t.innerType._def,e),"parseCatchDef");function fu(t,e){return e.dateStrategy=="integer"?zm(t,e):c({type:"string",format:"date-time"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{})}a(fu,"parseDateDef");var zm=a((t,e)=>{let r=c({type:"integer",format:"unix-time"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"&&H(r,"minimum",n.value,n.message,e);break;case"max":e.target==="jsonSchema7"&&H(r,"maximum",n.value,n.message,e);break}return r},"integerDateParser");function gu(t,e){return p(c({},C(t.innerType._def,e)),{default:t.defaultValue()})}a(gu,"parseDefaultDef");function hu(t,e){return e.effectStrategy==="input"?C(t.schema._def,e):{}}a(hu,"parseEffectsDef");function mu(t){return{type:"string",enum:t.values}}a(mu,"parseEnumDef");var Fm=a(t=>"type"in t&&t.type==="string"?!1:"allOf"in t,"isJsonSchema7AllOfType");function yu(t,e){let r=[C(t.left._def,p(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),C(t.right._def,p(c({},e),{currentPath:[...e.currentPath,"allOf","1"]}))].filter(i=>!!i),n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,s=[];return r.forEach(i=>{if(Fm(i))s.push(...i.allOf),i.unevaluatedProperties===void 0&&(n=void 0);else{let o=i;if("additionalProperties"in i&&i.additionalProperties===!1){let l=i,{additionalProperties:u}=l;o=Bi(l,["additionalProperties"])}else n=void 0;s.push(o)}}),s.length?c({allOf:s},n):void 0}a(yu,"parseIntersectionDef");function vu(t,e){let r=typeof t.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[t.value]}:{type:r==="bigint"?"integer":r,const:t.value}}a(vu,"parseLiteralDef");function Cs(t,e){var r,n,s,i,o;if(e.target==="openApi3"&&((r=t.keyType)==null?void 0:r._def.typeName)==="ZodEnum")return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((u,f)=>{var g;return p(c({},u),{[f]:(g=C(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"properties",f]})))!=null?g:{}})},{}),additionalProperties:!1};let l={type:"object",additionalProperties:(n=C(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?n:{}};if(e.target==="openApi3")return l;if(((s=t.keyType)==null?void 0:s._def.typeName)==="ZodString"&&((i=t.keyType._def.checks)!=null&&i.length)){let u=Object.entries(as(t.keyType._def,e)).reduce((f,[g,m])=>g==="type"?f:p(c({},f),{[g]:m}),{});return p(c({},l),{propertyNames:u})}else if(((o=t.keyType)==null?void 0:o._def.typeName)==="ZodEnum")return p(c({},l),{propertyNames:{enum:t.keyType._def.values}});return l}a(Cs,"parseRecordDef");function _u(t,e){if(e.mapStrategy==="record")return Cs(t,e);let r=C(t.keyType._def,p(c({},e),{currentPath:[...e.currentPath,"items","items","0"]}))||{},n=C(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"items","items","1"]}))||{};return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}a(_u,"parseMapDef");function Tu(t){let e=t.values,n=Object.keys(t.values).filter(i=>typeof e[e[i]]!="number").map(i=>e[i]),s=Array.from(new Set(n.map(i=>typeof i)));return{type:s.length===1?s[0]==="string"?"string":"number":["string","number"],enum:n.filter(i=>typeof i=="string"||typeof i=="number")}}a(Tu,"parseNativeEnumDef");function bu(){return{not:{}}}a(bu,"parseNeverDef");function wu(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}a(wu,"parseNullDef");var zr={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function Pu(t,e){if(e.target==="openApi3")return Oi(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in zr&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((s,i)=>{let o=zr[i._def.typeName];return o&&!s.includes(o)?[...s,o]:s},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((s,i)=>{let o=typeof i._def.value;switch(o){case"string":case"number":case"boolean":return[...s,o];case"bigint":return[...s,"integer"];case"object":if(i._def.value===null)return[...s,"null"];case"symbol":case"undefined":case"function":default:return s}},[]);if(n.length===r.length){let s=n.filter((i,o,l)=>l.indexOf(i)===o);return{type:s.length>1?s:s[0],enum:r.reduce((i,o)=>i.includes(o._def.value)?i:[...i,o._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,s)=>[...n,...s._def.values.filter(i=>!n.includes(i))],[])};return Oi(t,e)}a(Pu,"parseUnionDef");var Oi=a((t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((s,i)=>C(s._def,p(c({},e),{currentPath:[...e.currentPath,e.unionStrategy,`${i}`]}))).filter(s=>!!s&&(!e.strictUnions||typeof s=="object"&&Object.keys(s).length>0)),n=e.discriminator&&t.typeName==="ZodDiscriminatedUnion"&&typeof t.discriminator=="string"?{discriminator:{propertyName:t.discriminator}}:{};if(r.length)return e.unionStrategy==="anyOf"?c({anyOf:r},n):c({oneOf:r},n)},"asUnionOf");function xu(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length)){let n=t.innerType;if(e.target==="openApi3"){let i={type:zr[n._def.typeName],nullable:!0};return Ln(n._def,e,i)}let s={type:[zr[n._def.typeName],"null"]};return Ln(n._def,e,s)}if(e.target==="openApi3"){let n=C(t.innerType._def,p(c({},e),{currentPath:[...e.currentPath]}));return n&&p(c({},n),{nullable:!0})}let r=C(t.innerType._def,p(c({},e),{currentPath:[...e.currentPath,"anyOf","0"]}));return r&&{anyOf:[r,{type:"null"}]}}a(xu,"parseNullableDef");function ku(t,e){let r=c({type:"number"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"int":r.type="integer",is(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?H(r,"minimum",n.value,n.message,e):H(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),H(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?H(r,"maximum",n.value,n.message,e):H(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),H(r,"maximum",n.value,n.message,e));break;case"multipleOf":H(r,"multipleOf",n.value,n.message,e);break}return r}a(ku,"parseNumberDef");var Lm=a((t,e)=>{var r;return t.unknownKeys instanceof O?(r=C(t.unknownKeys._def,p(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?r:!0:t.unknownKeys==="passthrough"},"getAdditionalProperties");function Su(t,e){let r=p(c({type:"object"},Object.entries(t.shape()).reduce((n,[s,i])=>{if(i===void 0||i._def===void 0)return n;let o=C(i._def,p(c({},e),{currentPath:[...e.currentPath,"properties",s],propertyPath:[...e.currentPath,"properties",s]}));return o===void 0?n:{properties:p(c({},n.properties),{[s]:o}),required:i.isOptional()?n.required:[...n.required,s]}},{properties:{},required:[]})),{additionalProperties:Lm(t,e)});return r.required.length||delete r.required,r}a(Su,"parseObjectDef");var Wm=a((t,e)=>{var r;if(e.currentPath.toString()===((r=e.propertyPath)==null?void 0:r.toString()))return C(t.innerType._def,e);let n=C(t.innerType._def,p(c({},e),{currentPath:[...e.currentPath,"anyOf","1"]}));return n?{anyOf:[{not:{}},n]}:{}},"parseOptionalDef"),qm=a((t,e)=>{if(e.pipeStrategy==="input")return C(t.in._def,e);if(e.pipeStrategy==="output")return C(t.out._def,e);let r=C(t.in._def,p(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),n=C(t.out._def,p(c({},e),{currentPath:[...e.currentPath,"allOf",r?"1":"0"]}));return{allOf:[r,n].filter(s=>s!==void 0)}},"parsePipelineDef");function Ou(t,e){return C(t.type._def,e)}a(Ou,"parsePromiseDef");function Eu(t,e){let n={type:"array",uniqueItems:!0,items:C(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"items"]}))};return t.minSize&&H(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&H(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}a(Eu,"parseSetDef");function Zu(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>C(r._def,p(c({},e),{currentPath:[...e.currentPath,"items",`${n}`]}))).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:C(t.rest._def,p(c({},e),{currentPath:[...e.currentPath,"additionalItems"]}))}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>C(r._def,p(c({},e),{currentPath:[...e.currentPath,"items",`${n}`]}))).reduce((r,n)=>n===void 0?r:[...r,n],[])}}a(Zu,"parseTupleDef");function Iu(){return{not:{}}}a(Iu,"parseUndefinedDef");function Bu(){return{}}a(Bu,"parseUnknownDef");var Vm=a((t,e)=>C(t.innerType._def,e),"parseReadonlyDef");function Cu(t){return{$ref:t.uri}}a(Cu,"parseRefDef");function C(t,e,r=!1){let n=e.seen.get(t);if(n&&!r){let o=Gm(n,e);if(o!==void 0)return o}let s={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,s);let i=Xm(t,t.typeName,e);return i&&Ln(t,e,i),s.jsonSchema=i,i}a(C,"parseDef");var Gm=a((t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Jm(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((r,n)=>e.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),{}):e.$refStrategy==="seen"?{}:void 0}},"get$ref"),Jm=a((t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")},"getRelativePath"),Xm=a((t,e,r)=>{switch(e){case"ZodString":return as(t,r);case"ZodNumber":return ku(t,r);case"ZodObject":return Su(t,r);case"ZodBigInt":return uu(t,r);case"ZodBoolean":return du(t);case"ZodDate":return fu(t,r);case"ZodUndefined":return Iu();case"ZodNull":return wu(r);case"ZodArray":return cu(t,r);case"ZodUnion":case"ZodDiscriminatedUnion":return Pu(t,r);case"ZodIntersection":return yu(t,r);case"ZodTuple":return Zu(t,r);case"ZodRecord":return Cs(t,r);case"ZodRef":return Cu(t);case"ZodLiteral":return vu(t,r);case"ZodEnum":return mu(t);case"ZodNativeEnum":return Tu(t);case"ZodNullable":return xu(t,r);case"ZodOptional":return Wm(t,r);case"ZodMap":return _u(t,r);case"ZodSet":return Eu(t,r);case"ZodLazy":return C(t.getter()._def,r);case"ZodPromise":return Ou(t,r);case"ZodNaN":case"ZodNever":return bu();case"ZodEffects":return hu(t,r);case"ZodAny":return lu();case"ZodUnknown":return Bu();case"ZodDefault":return gu(t,r);case"ZodBranded":return pu(t,r);case"ZodReadonly":return Vm(t,r);case"ZodCatch":return Um(t,r);case"ZodPipeline":return qm(t,r);case"ZodFunction":case"ZodVoid":case"ZodSymbol":return;default:return(n=>{})(e)}},"selectParser"),Ln=a((t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),Object.assign(r,{[b]:c(c({},t[b]),r[b])}),r),"addMeta"),Ei={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"string",mapStrategy:"entries",definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",emailStrategy:"format:email",discriminator:!1,unionStrategy:"anyOf"},Ym=a(t=>typeof t=="string"?p(c({},Ei),{name:t}):c(c({},Ei),t),"getDefaultOptions"),Qm=a(t=>{let e=Ym(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return p(c({},e),{currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([n,s])=>[s._def,{def:s._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))})},"getRefs"),ey=a((t,e)=>{var r;let n=Qm(e),s=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((u,[f,g])=>{var m;return p(c({},u),{[f]:(m=C(g._def,p(c({},n),{currentPath:[...n.basePath,n.definitionPath,f]}),!0))!=null?m:{}})},{}):void 0,i=typeof e=="string"?e:e?.name,o=(r=C(t._def,i===void 0?n:p(c({},n),{currentPath:[...n.basePath,n.definitionPath,i]}),!1))!=null?r:{},l=i===void 0?s?p(c({},o),{[n.definitionPath]:s}):o:{$ref:[...n.$refStrategy==="relative"?[]:n.basePath,n.definitionPath,i].join("/"),[n.definitionPath]:p(c({},s),{[i]:o})};return n.target==="jsonSchema7"?l.$schema="http://json-schema.org/draft-07/schema#":n.target==="jsonSchema2019-09"&&(l.$schema="https://json-schema.org/draft/2019-09/schema#"),l},"zodToJsonSchema"),ty=a((t,e={target:"openApi3"})=>{let r=ey(t,e);return e.$schemaUrl===!1?delete r.$schema:typeof e.$schemaUrl=="string"&&(r.$schema=e.$schemaUrl),r},"toJSONSchemaLegacy");var dt=(t,e)=>{let r=t._def,n=e._def;if(r.typeName===y.ZodFirstPartyTypeKind.ZodObject&&n.typeName===y.ZodFirstPartyTypeKind.ZodObject){let s=r.shape(),i=n.shape();return y.object({...s,...i})}if(r.typeName===y.ZodFirstPartyTypeKind.ZodRecord&&n.typeName===y.ZodFirstPartyTypeKind.ZodRecord)return y.record(y.intersection(r.valueType,n.valueType));throw new Error("Cannot merge object schemas with record schemas")},Au=y;var re=y.string().min(1),Hu=y.object({text:re}),Du=y.object({markdown:re}),Mu=y.object({imageUrl:re}),Nu=y.object({audioUrl:re}),$u=y.object({videoUrl:re}),ju=y.object({fileUrl:re,title:re.optional()}),Ku=y.object({latitude:y.number(),longitude:y.number(),address:y.string().optional(),title:y.string().optional()}),Uu=y.object({title:re,subtitle:re.optional(),imageUrl:re.optional(),actions:y.array(y.object({action:y.enum(["postback","url","say"]),label:re,value:re}))}),Ru=y.object({text:re,options:y.array(y.object({label:re,value:re}))}),ry=y.object({items:y.array(Uu)}),ny=y.union([y.object({type:y.literal("text"),payload:Hu}),y.object({type:y.literal("markdown"),payload:Du}),y.object({type:y.literal("image"),payload:Mu}),y.object({type:y.literal("audio"),payload:Nu}),y.object({type:y.literal("video"),payload:$u}),y.object({type:y.literal("file"),payload:ju}),y.object({type:y.literal("location"),payload:Ku})]),sy=y.object({items:y.array(ny)}),iy={schema:Du},ay={text:{schema:Hu},image:{schema:Mu},audio:{schema:Nu},video:{schema:$u},file:{schema:ju},location:{schema:Ku},carousel:{schema:ry},card:{schema:Uu},dropdown:{schema:Ru},choice:{schema:Ru},bloc:{schema:sy}};var Wt="x-bot-id",Rs="x-bot-user-id",Hs="x-integration-id",Ds="x-webhook-id",Ms="x-bp-configuration-type",qt="x-bp-configuration",Vt="x-bp-operation",Ns="x-bp-type",oy={HIDDEN_IN_STUDIO:{bpActionHiddenInStudio:"true"},AWAIT_RETURN:{bpActionAwaitReturn:"true"}};var zu=require("browser-or-node");var $s=console;function oe(t){if(!t.body)throw new Error("Missing body");return JSON.parse(t.body)}async function Gt(t,e=8072,r=dy){if(!zu.isNode)throw new Error("This function can only be called in Node.js");let s=require("http").createServer(async(i,o)=>{try{let l=await ly(i);if(l.path==="/health"){o.writeHead(200).end("ok");return}let u=await t(l);o.writeHead(u?.status??200,u?.headers??{}).end(u?.body??"{}")}catch(l){$s.error("Error while handling request",{error:l?.message??"Internal error occured"}),o.writeHead(500).end(JSON.stringify({error:l?.message??"Internal error occured"}))}});return s.listen(e,()=>r(e)),s}async function ly(t){let e=await uy(t),r={};for(let s=0;s<t.rawHeaders.length;s+=2){let i=t.rawHeaders[s].toLowerCase(),o=t.rawHeaders[s+1];r[i]=o}let n=new URL(t.url??"",t.headers.host?`http://${t.headers.host}`:"http://botpress.cloud");return{body:e,path:n.pathname,query:cy(n.search,"?"),headers:r,method:t.method?.toUpperCase()??"GET"}}function cy(t,e){return t.indexOf(e)===0?t.slice(e.length):t}async function uy(t){return new Promise((e,r)=>{if(t.method!=="POST"&&t.method!=="PUT"&&t.method!=="PATCH")return e(void 0);let n="";t.on("data",s=>n+=s.toString()),t.on("error",s=>r(s)),t.on("end",()=>e(n))})}function dy(t){$s.info(`Listening on port ${t}`)}var Sn=require("@botpress/client");var M={};yt(M,{mapKeys:()=>gy,mapValues:()=>fy,mergeRecords:()=>my,pairs:()=>hn,stripUndefinedProps:()=>hy,values:()=>py});var hn=t=>Object.entries(t),py=t=>Object.values(t),fy=(t,e)=>Object.fromEntries(hn(t).map(([r,n])=>[r,e(n,r)])),gy=(t,e)=>Object.fromEntries(hn(t).map(([r,n])=>[e(r),n])),hy=t=>Object.fromEntries(hn(t).filter(([,e])=>e!==void 0)),my=(t,e,r)=>{let n=[...Object.keys(t),...Object.keys(e)],s=[...new Set(n)],i={};for(let o of s){let l=t[o],u=e[o];l&&u?i[o]=r(l,u):l?i[o]=l:u&&(i[o]=u)}return i};var S={};yt(S,{safePush:()=>yy,unique:()=>vy});var yy=(t,...e)=>t?[...t,...e]:[...e],vy=t=>Array.from(new Set(t));var ye={};yt(ye,{setName:()=>_y});var _y=(t,e)=>(Object.defineProperty(t,"name",{value:e}),t);var Fu=t=>{let{name:e,version:r}=t,n={actions:{},events:{},channels:{}},s={name:e,version:r,entities:M.mapValues(t.entities,o=>({name:o.name})),actions:{},events:{},channels:{}},i=M.mapValues(t.entities,o=>o.schema);for(let[o,l]of Object.entries(t.definition.actions??{})){let u=l.input.schema.dereference(i),f=l.output.schema.dereference(i),g=t.actions?.[o]?.name??o;n.actions[g]={...l,...t.actions?.[o]??{},input:{schema:u},output:{schema:f}},s.actions[o]={name:g}}for(let[o,l]of Object.entries(t.definition.events??{})){let u=l.schema.dereference(i),f=t.events?.[o]?.name??o;n.events[f]={...l,...t.events?.[o]??{},schema:u},s.events[o]={name:f}}for(let[o,l]of Object.entries(t.definition.channels??{})){let u={};for(let[g,m]of Object.entries(l.messages)){let P=m.schema.dereference(i);u[g]={...m,schema:P}}let f=t.channels?.[o]?.name??o;n.channels[f]={...l,...t.channels?.[o]??{},message:{...l.message??{},tags:{...l.message?.tags??{},...t.channels?.[o]?.message?.tags??{}}},conversation:{...l.conversation??{},tags:{...l.conversation?.tags??{},...t.channels?.[o]?.conversation?.tags??{}}},messages:u},s.channels[o]={name:f}}return{resolved:n,statement:s}};var mn=Symbol("schemaName"),Lu=t=>t?M.mapValues(t,(r,n)=>({...r,[mn]:n})):{},Wu=t=>mn in t&&t[mn]!==void 0,qu=t=>t[mn];var yn=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.readme=e.readme,this.title=e.title,this.identifier=e.identifier,this.description=e.description,this.configuration=e.configuration,this.configurations=e.configurations,this.events=e.events,this.actions=e.actions,this.channels=e.channels,this.states=e.states,this.user=e.user,this.secrets=e.secrets,this.entities=e.entities,this.interfaces=e.interfaces,this.__advanced=e.__advanced,this.attributes=e.attributes}name;version;title;description;icon;readme;configuration;configurations;events;actions;channels;states;user;secrets;identifier;entities;interfaces;__advanced;attributes;extend(e,r){let{entities:n,actions:s,events:i,channels:o}=this._callBuilder(e,r),l=this;l.interfaces??={};let u=Object.values(n).map(P=>P.name),f=u.length===0?e.name:`${e.name}<${u.join(",")}>`,{resolved:g,statement:m}=Fu({...e,entities:n,actions:M.stripUndefinedProps(s),events:M.stripUndefinedProps(i),channels:M.stripUndefinedProps(o)});return l.actions=M.mergeRecords(l.actions??{},g.actions,this._mergeActions),l.channels=M.mergeRecords(l.channels??{},g.channels,this._mergeChannels),l.events=M.mergeRecords(l.events??{},g.events,this._mergeEvents),l.interfaces[f]={id:e.id,...m},this}_callBuilder(e,r){let s={entities:Lu(this.entities)},i=r(s),o=M.pairs(i.entities).find(([u,f])=>!Wu(f));if(o)throw new Error(`Cannot extend interface "${e.name}" with entity "${o[0]}"; the provided schema is not part of the integration's entities.`);return{entities:M.mapValues(i.entities,u=>({name:qu(u),schema:u.schema})),actions:i.actions??{},events:i.events??{},channels:i.channels??{}}}_mergeActions=(e,r)=>({...e,...r,input:{schema:dt(e.input.schema,r.input.schema)},output:{schema:dt(e.output.schema,r.output.schema)}});_mergeEvents=(e,r)=>({...e,...r,schema:dt(e.schema,r.schema)});_mergeChannels=(e,r)=>{let n=M.mergeRecords(e.messages,r.messages,this._mergeMessage),s;(e.conversation||r.conversation)&&(s={tags:{...e.conversation?.tags,...r.conversation?.tags}});let i;return(e.message||r.message)&&(i={tags:{...e.message?.tags,...r.message?.tags}}),{...e,...r,messages:n,conversation:s,message:i}};_mergeMessage=(e,r)=>({schema:dt(e.schema,r.schema)})};var ve=require("@botpress/client");var Vu=Ws(require("@botpress/client")),vn={retries:3,retryCondition:t=>Vu.axiosRetry.isNetworkOrIdempotentRequestError(t)||[429,502].includes(t.response?.status??0),retryDelay:(t,e)=>(Ty(e.response?.headers??{})??t)*1e3},Ty=t=>{let e=["RateLimit-Reset","X-RateLimit-Reset","Retry-After","ratelimit-reset","x-ratelimit-reset","retry-after"];for(let r of e){let n=t[r];if(n!==void 0)return by(String(n))}},by=t=>{let e=wy(t)?Py(t):t.length>0?parseInt(t,10):void 0;return e===void 0||isNaN(e)?void 0:e},wy=t=>t.includes(" "),Py=t=>{let e=xy(t);if(!e)return;let r=new Date;return Math.max(0,Math.floor((e.getTime()-r.getTime())/1e3))},xy=t=>{let e=new Date(t);return isNaN(e.getTime())?void 0:e};var pt=class{constructor(e){this._client=e}get _inner(){return this._client}createConversation=(e=>this._client.createConversation(e));getConversation=(e=>this._client.getConversation(e));listConversations=(e=>this._client.listConversations(e));getOrCreateConversation=(e=>this._client.getOrCreateConversation(e));updateConversation=(e=>this._client.updateConversation(e));deleteConversation=(e=>this._client.deleteConversation(e));listParticipants=(e=>this._client.listParticipants(e));addParticipant=(e=>this._client.addParticipant(e));getParticipant=(e=>this._client.getParticipant(e));removeParticipant=(e=>this._client.removeParticipant(e));createEvent=(e=>this._client.createEvent(e));getEvent=(e=>this._client.getEvent(e));listEvents=(e=>this._client.listEvents(e));createMessage=(e=>this._client.createMessage(e));getOrCreateMessage=(e=>this._client.getOrCreateMessage(e));getMessage=(e=>this._client.getMessage(e).then(r=>r));updateMessage=(e=>this._client.updateMessage(e).then(r=>r));listMessages=(e=>this._client.listMessages(e));deleteMessage=(e=>this._client.deleteMessage(e));createUser=(e=>this._client.createUser(e));getUser=(e=>this._client.getUser(e));listUsers=e=>this._client.listUsers(e);getOrCreateUser=(e=>this._client.getOrCreateUser(e));updateUser=(e=>this._client.updateUser(e));deleteUser=e=>this._client.deleteUser(e);getState=(e=>this._client.getState(e));setState=(e=>this._client.setState(e));getOrSetState=(e=>this._client.getOrSetState(e));patchState=(e=>this._client.patchState(e));configureIntegration=e=>this._client.configureIntegration(e);uploadFile=e=>this._client.uploadFile(e);upsertFile=e=>this._client.upsertFile(e);deleteFile=e=>this._client.deleteFile(e);listFiles=e=>this._client.listFiles(e);getFile=e=>this._client.getFile(e);updateFileMetadata=e=>this._client.updateFileMetadata(e);trackAnalytics=e=>this._client.trackAnalytics(e)};var _n=class{_cost=0;get cost(){return this._cost}setCost(e){this._cost=e}toJSON(){return{cost:this.cost}}};var Pe="#";var Wv=y.enum(["webhook_received","message_created","action_triggered","register","unregister","ping","create_user","create_conversation"]),Gu=t=>{let e=t[Wt],r=t[Rs],n=t[Hs],s=t[Ds],i=t[Ms],o=t[qt],l=t[Vt];if(!e)throw new Error("Missing bot headers");if(!r)throw new Error("Missing bot user headers");if(!n)throw new Error("Missing integration headers");if(!s)throw new Error("Missing webhook headers");if(!o)throw new Error("Missing configuration headers");if(!l)throw new Error("Missing operation headers");return{botId:e,botUserId:r,integrationId:n,webhookId:s,operation:l,configurationType:i??null,configuration:o?JSON.parse(Buffer.from(o,"base64").toString("utf-8")):{}}};var Ju=Ws(require("util")),ft=class{defaultOptions;constructor(e){this.defaultOptions=e}info(...e){this._log("info",e)}debug(...e){this._log("debug",e)}warn(...e){this._log("warn",e)}error(...e){this._log("error",e)}_log(e,r){this._getConsoleMethod(e)(this._serializeMessage(r))}_serializeMessage(e){let r=Ju.default.format(...e);return process.env.BP_LOG_FORMAT==="json"?this.getJsonMessage(r):r}getJsonMessage(e){return JSON.stringify({msg:e,options:this.defaultOptions})}_getConsoleMethod(e){switch(e){case"debug":return console.debug;case"warn":return console.warn;case"error":return console.error;default:return console.info}}};var gt=class t extends ft{constructor(e){super({visibleToBotOwners:!0,...e})}with(e){return new t({...this.defaultOptions,...e})}withUserId(e){return this.with({userId:e})}withConversationId(e){return this.with({conversationId:e})}withVisibleToBotOwners(e){return this.with({visibleToBotOwners:e})}forBot(){return this.withVisibleToBotOwners(!0)}getJsonMessage(e){return JSON.stringify({msg:e,visible_to_bot_owner:this.defaultOptions.visibleToBotOwners,options:this.defaultOptions})}};var ky=t=>["traceparent","tracestate","sentry-trace"].reduce((e,r)=>(t[r]&&(e[r]=t[r]),e),{}),Sy=(t,e,r)=>{let[,n]=(e.headers.traceparent||"").split("-"),s=new ve.Client({botId:t.botId,integrationId:t.integrationId,retry:vn,headers:ky(e.headers)}),i=new pt(s),o=new gt({traceId:n});return{ctx:t,req:e,client:i,logger:o,instance:r}},Oy=async t=>{let{ctx:e}=t;switch(e.operation){case"webhook_received":return await Zy(t);case"register":return await Iy(t);case"unregister":return await By(t);case"message_created":return await Ry(t);case"action_triggered":return await Hy(t);case"ping":return await Ey(t);case"create_user":return await Cy(t);case"create_conversation":return await Ay(t);default:throw new ve.InvalidPayloadError(`Unknown operation ${e.operation}`)}},Xu=t=>async e=>{let r=Gu(e.headers),n=Sy(r,e,t),{logger:s}=n;try{let i;return i=await Dy(n),i?{...i,status:i.status??200}:(i=await Oy(n),i?{...i,status:i.status??200}:{status:200})}catch(i){if((0,ve.isApiError)(i)){let l=i.type==="Runtime"?i:new ve.RuntimeError(i.message,i);return s.forBot().error(l.message),{status:l.code,body:JSON.stringify(l.toJSON())}}console.error(i);let o=new ve.RuntimeError("An unexpected error occurred in the integration. Bot owners: Check logs for more informations. Integration owners: throw a RuntimeError to return a custom error message instead.");return s.forBot().error(o.message),{status:o.code,body:JSON.stringify(o.toJSON())}}},Ey=async t=>{},Zy=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{let{req:i}=oe(r);return s.webhook({client:t,ctx:e,req:i,logger:n})},Iy=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.register)return;let{webhookUrl:i}=oe(r);await s.register({client:t,ctx:e,webhookUrl:i,logger:n})},By=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.unregister)return;let{webhookUrl:i}=oe(r);await s.unregister({ctx:e,webhookUrl:i,client:t,logger:n})},Cy=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.createUser)return;let{tags:i}=oe(r);return await s.createUser({ctx:e,client:t,tags:i,logger:n})},Ay=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.createConversation)return;let{channel:i,tags:o}=oe(r);return await s.createConversation({ctx:e,client:t,channel:i,tags:o,logger:n})},Ry=async({ctx:t,req:e,client:r,logger:n,instance:s})=>{let{conversation:i,user:o,type:l,payload:u,message:f}=oe(e),g=s.channels[i.channel];if(!g)throw new Error(`Channel ${i.channel} not found`);let m=g.messages[l];if(!m)throw new Error(`Message of type ${l} not found in channel ${i.channel}`);await m({ctx:t,conversation:i,message:f,user:o,type:l,client:r,payload:u,ack:async({tags:E})=>{await r.updateMessage({id:f.id,tags:E})},logger:n})},Hy=async({req:t,ctx:e,client:r,logger:n,instance:s})=>{let{input:i,type:o}=oe(t);if(!o)throw new Error("Missing action type");let l=s.actions[o];if(!l)throw new Error(`Action ${o} not found`);let u=new _n,g={output:await l({ctx:e,input:i,client:r,type:o,logger:n,metadata:u}),meta:u.toJSON()};return{body:JSON.stringify(g)}},Dy=async({instance:t,client:e,ctx:r,logger:n,req:s})=>{let i=t.unknownOperationHandler;if(i)return await i({client:e,ctx:r,logger:n,req:s})};var Tn=class{constructor(e){this.props=e;this.actions=e.actions,this.channels=e.channels,this.register=e.register,this.unregister=e.unregister,this.createUser=e.createUser,this.createConversation=e.createConversation,this.webhook=e.handler,this.unknownOperationHandler=e.__advanced?.unknownOperationHandler}actions;channels;register;unregister;createUser;createConversation;webhook;unknownOperationHandler;handler=Xu(this);start=e=>Gt(this.handler,e)};var bn=class{constructor(e){this.props=e;this.integrations=e.integrations,this.plugins=e.plugins,this.user=e.user,this.conversation=e.conversation,this.message=e.message,this.states=e.states,this.configuration=e.configuration,this.events=e.events,this.recurringEvents=e.recurringEvents,this.actions=e.actions,this.tables=e.tables,this.workflows=e.workflows,this.attributes=e.attributes,this.withPlugins={user:e.user,conversation:e.conversation,message:e.message,states:e.states,events:e.events,recurringEvents:e.recurringEvents,actions:e.actions,tables:e.tables,workflows:e.workflows}}integrations;plugins;user;conversation;message;states;configuration;events;recurringEvents;actions;tables;workflows;attributes;withPlugins;addIntegration(e,r){let n=this;return n.integrations||(n.integrations={}),n.integrations[e.name]={...e,enabled:r?.enabled,configurationType:r?.configurationType,configuration:r?.configuration,disabledChannels:r?.disabledChannels},this}addPlugin(e,r){let n=this;n.plugins||(n.plugins={});let s=r.alias??e.name.replace("/","-");return n.plugins[s]={...e,alias:s,configuration:r.configuration,interfaces:r.interfaces},n.withPlugins.user=this._mergeUser(n.withPlugins.user,e.definition.user),n.withPlugins.conversation=this._mergeConversation(n.withPlugins.conversation,e.definition.conversation),n.withPlugins.message=this._mergeMessage(n.withPlugins.message,e.definition.message),n.withPlugins.recurringEvents=this._mergeRecurringEvents(n.withPlugins.recurringEvents,e.definition.recurringEvents),n.withPlugins.tables=this._mergeTables(n.withPlugins.tables,e.definition.tables),n.withPlugins.workflows=this._mergeWorkflows(n.withPlugins.workflows,e.definition.workflows),n.withPlugins.states=this._mergeStates(n.withPlugins.states,this._prefixKeysWithPluginAlias(e.definition.states,s)),n.withPlugins.events=this._mergeEvents(n.withPlugins.events,this._prefixKeysWithPluginAlias(e.definition.events,s)),n.withPlugins.actions=this._mergeActions(n.withPlugins.actions,this._prefixKeysWithPluginAlias(e.definition.actions,s)),this}_mergeUser=(e,r)=>({tags:{...e?.tags,...r?.tags}});_mergeConversation=(e,r)=>({tags:{...e?.tags,...r?.tags}});_mergeMessage=(e,r)=>({tags:{...e?.tags,...r?.tags}});_mergeStates=(e,r)=>({...e,...r});_mergeEvents=(e,r)=>({...e,...r});_mergeRecurringEvents=(e,r)=>({...e,...r});_mergeActions=(e,r)=>({...e,...r});_mergeTables=(e,r)=>({...e,...r});_mergeWorkflows=(e,r)=>({...e,...r});_prefixKeysWithPluginAlias=(e,r)=>M.mapKeys(e??{},n=>`${r}${Pe}${n}`);dereferencePluginEntities(){let e=this._buildZuiReferenceMap();return{...this,withPlugins:{...this.withPlugins,events:this._dereferenceDefinitionSchemas(this.withPlugins.events,e),states:this._dereferenceDefinitionSchemas(this.withPlugins.states,e),tables:this._dereferenceDefinitionSchemas(this.withPlugins.tables,e),actions:this._dereferenceActionDefinitionSchemas(this.withPlugins.actions,e)},plugins:Object.fromEntries(Object.entries(this.plugins??{}).map(([r,n])=>[r,{...n,definition:{...n.definition,configuration:this._dereferenceDefinitionSchema(n.definition.configuration,e),events:this._dereferenceDefinitionSchemas(n.definition.events,e),states:this._dereferenceDefinitionSchemas(n.definition.states,e),tables:this._dereferenceDefinitionSchemas(n.definition.tables,e),actions:this._dereferenceActionDefinitionSchemas(n.definition.actions,e)}}]))}}_buildZuiReferenceMap(){let e={},r=Object.entries(this.plugins??{});for(let[n,s]of r){let i=Object.entries(s.interfaces??{});for(let[o,l]of i){let u=this.integrations?.[l.name];if(!u)throw new Error(`Interface with alias "${o}" of plugin with alias "${n}" references integration "${l.name}" which is not installed`);let f=Object.entries(l.entities??{});for(let[g,{name:m}]of f){let P=u.definition.entities?.[m]?.schema;if(!P)throw new Error(`Interface entity "${m}" does not exist in integration "${u.name}"`);e[`interface:${o}/entities/${g}`]=P}}}return e}_dereferenceZuiSchema(e,r){return e.dereference(r)}_dereferenceDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,this._dereferenceDefinitionSchema(s,r)]))}_dereferenceDefinitionSchema(e,r){return e&&{...e,schema:this._dereferenceZuiSchema(e.schema,r)}}_dereferenceActionDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,{...s,input:{schema:this._dereferenceZuiSchema(s.input.schema,r)},output:{schema:this._dereferenceZuiSchema(s.output.schema,r)}}]))}};var Ve=require("@botpress/client");var ht=class t extends ft{constructor(e){super({...e})}with(e){return new t({...this.defaultOptions,...e})}withUserId(e){return this.with({userId:e})}withConversationId(e){return this.with({conversationId:e})}withWorkflowId(e){return this.with({workflowId:e})}withEventId(e){return this.with({eventId:e})}withMessageId(e){return this.with({messageId:e})}};var ce=class{constructor(e,r={before:{},after:{}}){this._client=e;this._hooks=r}get _inner(){return this._client}getConversation=(e=>this._run("getConversation",e));listConversations=(e=>this._run("listConversations",e));updateConversation=(e=>this._run("updateConversation",e));deleteConversation=(e=>this._run("deleteConversation",e));listParticipants=(e=>this._run("listParticipants",e));addParticipant=(e=>this._run("addParticipant",e));getParticipant=(e=>this._run("getParticipant",e));removeParticipant=(e=>this._run("removeParticipant",e));createEvent=(e=>this._run("createEvent",e));getEvent=(e=>this._run("getEvent",e));listEvents=(e=>this._run("listEvents",e));createMessage=(e=>this._run("createMessage",e));getOrCreateMessage=(e=>this._run("getOrCreateMessage",e));getMessage=(e=>this._run("getMessage",e));updateMessage=(e=>this._run("updateMessage",e));listMessages=(e=>this._run("listMessages",e));deleteMessage=(e=>this._run("deleteMessage",e));getUser=(e=>this._run("getUser",e));listUsers=(e=>this._run("listUsers",e));updateUser=(e=>this._run("updateUser",e));deleteUser=(e=>this._run("deleteUser",e));getState=(e=>this._run("getState",e));setState=(e=>this._run("setState",e));getOrSetState=(e=>this._run("getOrSetState",e));patchState=(e=>this._run("patchState",e));callAction=(e=>this._run("callAction",e));uploadFile=(e=>this._run("uploadFile",e));upsertFile=(e=>this._run("upsertFile",e));deleteFile=(e=>this._run("deleteFile",e));listFiles=(e=>this._run("listFiles",e));getFile=(e=>this._run("getFile",e));updateFileMetadata=(e=>this._run("updateFileMetadata",e));searchFiles=(e=>this._run("searchFiles",e));trackAnalytics=(e=>this._run("trackAnalytics",e));getTableRow=(e=>this._run("getTableRow",e));createTableRows=(e=>this._run("createTableRows",e));findTableRows=(e=>this._run("findTableRows",e));deleteTableRows=(e=>this._run("deleteTableRows",e));updateTableRows=(e=>this._run("updateTableRows",e));upsertTableRows=(e=>this._run("upsertTableRows",e));createWorkflow=(e=>this._run("createWorkflow",e));getWorkflow=(e=>this._run("getWorkflow",e));updateWorkflow=(e=>this._run("updateWorkflow",e));deleteWorkflow=(e=>this._run("deleteWorkflow",e));listWorkflows=(e=>this._run("listWorkflows",e));createConversation=e=>this._client.createConversation(e);getOrCreateConversation=e=>this._client.getOrCreateConversation(e);createUser=e=>this._client.createUser(e);getOrCreateUser=e=>this._client.getOrCreateUser(e);_run=async(e,r)=>{let n=this._hooks.before[e];n&&(r=await n(r));let s=await this._client[e](r),i=this._hooks.after[e];return i&&(s=await i(s,r)),s}};var mt=t=>new Proxy({},{get:(e,r)=>({listInstances:{all:n=>xe({workflowName:r,client:t,input:n}),running:n=>xe({workflowName:r,client:t,input:n,statuses:["in_progress"]}),scheduled:n=>xe({workflowName:r,client:t,input:n,statuses:["pending","listening"]}),allFinished:n=>xe({workflowName:r,client:t,input:n,statuses:["completed","cancelled","failed","timedout"]}),cancelled:n=>xe({workflowName:r,client:t,input:n,statuses:["cancelled"]}),failed:n=>xe({workflowName:r,client:t,input:n,statuses:["failed"]}),succeeded:n=>xe({workflowName:r,client:t,input:n,statuses:["completed"]}),timedOut:n=>xe({workflowName:r,client:t,input:n,statuses:["timedout"]})},startNewInstance:async n=>{let{workflow:s}=await t.createWorkflow({name:r,status:"pending",...n});return{workflow:ke({client:t,workflow:s})}}})}),xe=async t=>{let e=await t.client.listWorkflows({name:t.workflowName,statuses:t.statuses,...t.input});return{...e,workflows:e.workflows.map(r=>ke({client:t.client,workflow:r}))}},ke=t=>({...t.workflow,async update(e){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,...e});return{workflow:ke({client:t.client,workflow:r})}},async setFailed({failureReason:e}){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,status:"failed",failureReason:e});return{workflow:ke({client:t.client,workflow:r})}},async setCompleted({output:e}={}){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,status:"completed",output:e});return{workflow:ke({client:t.client,workflow:r})}},async cancel(){let{workflow:e}=await t.client.updateWorkflow({id:t.workflow.id,status:"cancelled"});return{workflow:ke({client:t.client,workflow:e})}}});var My=y.enum(["event_received","register","unregister","ping","action_triggered"]),Yu=t=>{let e=t[Wt],r=t[qt],n=t[Ns],s=My.parse(t[Vt]);if(!e)throw new Error("Missing bot headers");if(!n)throw new Error("Missing type headers");if(!r)throw new Error("Missing configuration headers");if(!s)throw new Error("Missing operation headers");return{botId:e,operation:s,type:n,configuration:r?JSON.parse(Buffer.from(r,"base64").toString("utf-8")):{}}};var Y={status:200};var Ks=t=>{switch(t){case"workflow_continued":return"continued";case"workflow_started":return"started";case"workflow_timedout":return"timed_out";default:throw new Error(`Unsupported workflow update type: ${t}`)}};var Ny=["child_workflow_deleted","child_workflow_finished","workflow_timedout","workflow_started","workflow_continued"],Qu=async(t,e)=>{if(t.ctx.type!=="workflow_update"||!Ny.includes(e.payload.type))throw new Error("Unexpected event type");let r={...t,logger:$y(t,e)};if(!e.payload.workflow.name)return r.logger.warn("Received workflow update event without a workflow name. Assuming this workflow was not defined by the bot.",e.payload.workflow),Y;switch(e.payload.type){case"child_workflow_deleted":case"child_workflow_finished":r.logger.info(`Received child workflow event "${e.payload.type}", but child workflows are not yet supported`);break;case"workflow_timedout":case"workflow_started":case"workflow_continued":return await jy(r,e);default:e.payload.type}return Y},$y=(t,e)=>t.logger.with({eventId:e.id,workflowId:e.payload.workflow.id,conversationId:e.payload.conversation?.id,userId:e.payload.user?.id}),jy=async(t,e)=>{let r=Ks(e.payload.type),n=t.self.workflowHandlers[r]?.[e.payload.workflow.name];return!n||n.length===0?(t.logger.warn(`No ${r} handler found for workflow "${e.payload.workflow.name}"`),Y):(await Ky(t,e),await Uy(t,e),Y)},Ky=async(t,e)=>{e.payload.workflow.status==="pending"&&await t.client.updateWorkflow({id:e.payload.workflow.id,status:"in_progress",eventId:e.id})},Uy=async(t,e)=>{let r=Ks(e.payload.type),n=t.self.workflowHandlers[r]?.[e.payload.workflow.name];for(let s of n)await s({...t,event:e,conversation:e.payload.conversation,user:e.payload.user,workflow:ke({...t,workflow:e.payload.workflow}),workflows:mt(t.client)})};var ed=t=>async e=>{let r=Yu(e.headers),n=new ht,s=new Ve.Client({botId:r.botId,retry:vn}),i=new ce(s,{before:{createMessage:async l=>{let u=t.hookHandlers.before_outgoing_message[l.type]??[];for(let f of u){let g=new ce(s);l=(await f({client:g,ctx:r,logger:n.with({conversationId:l.conversationId,userId:l.userId}),data:l,...Se({client:g})}))?.data??l}return l},callAction:async l=>{let u=t.hookHandlers.before_outgoing_call_action[l.type]??[];for(let f of u){let g=new ce(s);l=(await f({client:g,ctx:r,logger:n,data:l,...Se({client:g})}))?.data??l}return l}},after:{createMessage:async l=>{let u=t.hookHandlers.after_outgoing_message[l.message.type]??[];for(let f of u){let g=new ce(s);l=(await f({client:g,ctx:r,logger:n.with({messageId:l.message.id,conversationId:l.message.conversationId,userId:l.message.userId}),data:l,...Se({client:g})}))?.data??l}return l},callAction:async(l,u)=>{let{type:f}=u,g=t.hookHandlers.after_outgoing_call_action[f]??[];for(let m of g){let P=new ce(s);l=(await m({client:P,ctx:r,logger:n,data:{type:f,...l},...Se({client:P})}))?.data??l}return l}}}),o={req:e,ctx:r,logger:n,client:i,self:t};try{switch(r.operation){case"action_triggered":return await qy(o);case"event_received":return await Wy(o);case"register":return await Fy(o);case"unregister":return await Ly(o);case"ping":return await zy(o);default:throw new Error(`Unknown operation ${r.operation}`)}}catch(l){let u=l instanceof Error?l:new Error(String(l));if((0,Ve.isApiError)(u)){let g=u.type==="Runtime"?u:new Ve.RuntimeError(u.message,u);return n.error(g.message),{status:g.code,body:JSON.stringify(g.toJSON())}}let f=new Ve.RuntimeError("An unexpected error occurred in the bot.",u);return n.error(f.message,u),{status:f.code,body:JSON.stringify(f.toJSON())}}},zy=async t=>Y,Fy=async t=>Y,Ly=async t=>Y,Wy=async t=>{let{ctx:e,logger:r,req:n,client:s,self:i}=t,o={client:s,ctx:e,logger:r,...Se({client:s})},l=oe(n);if(o.logger=o.logger.with({eventId:l.event.id,messageId:l.event.messageId,conversationId:l.event.conversationId,userId:l.event.userId}),e.type==="workflow_update")return await Qu(t,l.event);if(e.type==="message_created"){let E=l.event,I=E.payload.message;o.logger=o.logger.with({messageId:I.id,conversationId:I.conversationId,userId:I.userId});let U=i.hookHandlers.before_incoming_message[I.type]??[];for(let q of U){let se=await q({...o,data:I});if(I=se?.data??I,se?.stop)return Y}let W={...o,user:E.payload.user,conversation:E.payload.conversation,message:I,event:E},Q=i.messageHandlers[I.type]??[];for(let q of Q)await q(W);let ie=i.hookHandlers.after_incoming_message[I.type]??[];for(let q of ie){let se=await q({...o,data:I});if(I=se?.data??I,se?.stop)return Y}return Y}if(e.type==="state_expired"){let I=l.event.payload.state,U={...o,state:I},W=i.stateExpiredHandlers[I.name]??[];for(let Q of W)await Q(U);return Y}let u=l.event,f=i.hookHandlers.before_incoming_event[u.type]??[];for(let E of f){let I=await E({...o,data:u});if(u=I?.data??u,I?.stop)return Y}let g={...o,event:u},m=i.eventHandlers[u.type]??[];for(let E of m)await E(g);let P=i.hookHandlers.after_incoming_event[u.type]??[];for(let E of P){let I=await E({...o,data:u});if(u=I?.data??u,I?.stop)return Y}return Y},qy=async({ctx:t,logger:e,req:r,client:n,self:s})=>{let{input:i,type:o}=oe(r);if(!o)throw new Error("Missing action type");let l=s.hookHandlers.before_incoming_call_action[o]??[];for(let P of l){let E=await P({ctx:t,logger:e,client:n,data:{type:o,input:i},...Se({client:n})});i=E?.data?.input??i,o=E?.data?.type??o}let u=s.actionHandlers[o];if(!u)throw new Error(`Action ${o} not found`);let f=await u({ctx:t,logger:e,input:i,client:n,type:o,...Se({client:n})}),g=s.hookHandlers.after_incoming_call_action[o]??[];for(let P of g){let E=await P({ctx:t,logger:e,client:n,data:{type:o,output:f},...Se({client:n})});o=E?.data?.type??o,f=E?.data?.output??f}return{status:200,body:JSON.stringify({output:f})}},Se=t=>({workflows:mt(t.client)});var wn=class{constructor(e){this.props=e;this._actionHandlers=e.actions,this._plugins=e.plugins}_actionHandlers;_messageHandlers={};_eventHandlers={};_stateExpiredHandlers={};_hookHandlers={before_incoming_event:{},before_incoming_message:{},before_outgoing_message:{},before_outgoing_call_action:{},before_incoming_call_action:{},after_incoming_event:{},after_incoming_message:{},after_outgoing_message:{},after_outgoing_call_action:{},after_incoming_call_action:{}};_workflowHandlers={started:{},continued:{},timed_out:{}};_plugins={};_registerOrder=0;get actionHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._actionHandlers[r];if(n)return n;for(let[s,i]of Object.entries(this._plugins)){let[o,l]=r.split(Pe);if(!(o!==s||!l)&&(n=i.actionHandlers[l],n))return n}}})}get messageHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.messageHandlers[r]??[]),s=this._messageHandlers[r]??[],i=this._messageHandlers["*"]??[],o=[...s,...i].sort((l,u)=>l.order-u.order).map(({handler:l})=>l);return S.unique([...n,...o])}})}get eventHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.eventHandlers[r]??[]),s=this._eventHandlers[r]??[],i=this._eventHandlers["*"]??[],o=[...s,...i].sort((l,u)=>l.order-u.order).map(({handler:l})=>l);return S.unique([...n,...o])}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.stateExpiredHandlers[r]??[]),s=this._stateExpiredHandlers[r]??[],i=this._stateExpiredHandlers["*"]??[],o=[...s,...i].sort((l,u)=>l.order-u.order).map(({handler:l})=>l);return S.unique([...n,...o])}})}get hookHandlers(){return new Proxy({},{get:(e,r)=>{if(this._hookHandlers[r])return new Proxy({},{get:(s,i)=>{let o=Object.values(this._plugins).flatMap(m=>m.hookHandlers[r]?.[i]??[]),l=this._hookHandlers[r]??{},u=l[i]??[],f=l["*"]??[],g=[...u,...f].sort((m,P)=>m.order-P.order).map(({handler:m})=>m);return S.unique([...o,...g])}})}})}get workflowHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._workflowHandlers[r];if(n)return new Proxy({},{get:(s,i)=>{let o=n[i]?.sort((u,f)=>u.order-f.order).map(({handler:u})=>u)??[],l=Object.values(this._plugins).flatMap(u=>u.workflowHandlers[r]?.[i]??[]);return S.unique([...o,...l])}})}})}on={message:(e,r)=>{this._messageHandlers[e]=S.safePush(this._messageHandlers[e],{handler:r,order:this._registerOrder++})},event:(e,r)=>{this._eventHandlers[e]=S.safePush(this._eventHandlers[e],{handler:r,order:this._registerOrder++})},stateExpired:(e,r)=>{this._stateExpiredHandlers[e]=S.safePush(this._stateExpiredHandlers[e],{handler:r,order:this._registerOrder++})},beforeIncomingEvent:(e,r)=>{this._hookHandlers.before_incoming_event[e]=S.safePush(this._hookHandlers.before_incoming_event[e],{handler:r,order:this._registerOrder++})},beforeIncomingMessage:(e,r)=>{this._hookHandlers.before_incoming_message[e]=S.safePush(this._hookHandlers.before_incoming_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingMessage:(e,r)=>{this._hookHandlers.before_outgoing_message[e]=S.safePush(this._hookHandlers.before_outgoing_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingCallAction:(e,r)=>{this._hookHandlers.before_outgoing_call_action[e]=S.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},beforeIncomingCallAction:(e,r)=>{this._hookHandlers.before_incoming_call_action[e]=S.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingEvent:(e,r)=>{this._hookHandlers.after_incoming_event[e]=S.safePush(this._hookHandlers.after_incoming_event[e],{handler:r,order:this._registerOrder++})},afterIncomingMessage:(e,r)=>{this._hookHandlers.after_incoming_message[e]=S.safePush(this._hookHandlers.after_incoming_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingMessage:(e,r)=>{this._hookHandlers.after_outgoing_message[e]=S.safePush(this._hookHandlers.after_outgoing_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingCallAction:(e,r)=>{this._hookHandlers.after_outgoing_call_action[e]=S.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingCallAction:(e,r)=>{this._hookHandlers.after_incoming_call_action[e]=S.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:r,order:this._registerOrder++})},workflowStart:(e,r)=>{this._workflowHandlers.started[e]=S.safePush(this._workflowHandlers.started[e],{handler:r,order:this._registerOrder++})},workflowContinue:(e,r)=>{this._workflowHandlers.continued[e]=S.safePush(this._workflowHandlers.continued[e],{handler:r,order:this._registerOrder++})},workflowTimeout:(e,r)=>{this._workflowHandlers.timed_out[e]=S.safePush(this._workflowHandlers.timed_out[e],{handler:r,order:this._registerOrder++})}};handler=ed(this);start=e=>Gt(this.handler,e)};var Pn=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.title=e.title,this.description=e.description,this.readme=e.readme,this.entities=e.entities??{},this.attributes=e.attributes;let r=this._getEntityReference(this.entities),n=e.events===void 0?{}:M.mapValues(e.events,o=>({...o,schema:o.schema(r)})),s=e.actions===void 0?{}:M.mapValues(e.actions,o=>({...o,input:{...o.input,schema:o.input.schema(r)},output:{...o.output,schema:o.output.schema(r)}})),i=e.channels===void 0?{}:M.mapValues(e.channels,o=>({...o,messages:M.mapValues(o.messages,l=>({...l,schema:l.schema(r)}))}));this.events=n,this.actions=s,this.channels=i}name;version;title;description;icon;readme;attributes;entities;events;actions;channels;_getEntityReference=e=>{let r={};for(let[n,s]of Object.entries(e)){let i=s.schema._def["x-zui"]?.title,o=s.schema._def.description,l=Au.ref(n);i&&l.title(i),o&&l.describe(o),r[n]=l}return r}};var xn=class{constructor(e){this.props=e;let r=Object.fromEntries(Object.entries(e.interfaces??{}).map(([n,s])=>[n,Object.fromEntries(Object.entries(s.definition.entities??{}).map(([i])=>[i,y.ref(`interface:${n}/entities/${i}`)]))]));this.name=e.name,this.version=e.version,this.icon=e.icon,this.readme=e.readme,this.title=e.title,this.description=e.description,this.integrations=e.integrations,this.interfaces=e.interfaces,this.user=e.user,this.conversation=e.conversation,this.message=e.message,this.recurringEvents=e.recurringEvents,this.workflows=e.workflows,this.attributes=e.attributes,this.configuration=e.configuration?{...e.configuration,schema:typeof e.configuration.schema=="object"?e.configuration.schema:e.configuration.schema({entities:r})}:void 0,this.states=Object.fromEntries(Object.entries(e.states??{}).map(([n,s])=>[n,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:r})}])),this.events=Object.fromEntries(Object.entries(e.events??{}).map(([n,s])=>[n,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:r})}])),this.actions=Object.fromEntries(Object.entries(e.actions??{}).map(([n,s])=>[n,{...s,input:{...s.input,schema:typeof s.input.schema=="object"?s.input.schema:s.input.schema({entities:r})},output:{...s.output,schema:typeof s.output.schema=="object"?s.output.schema:s.output.schema({entities:r})}}])),this.tables=Object.fromEntries(Object.entries(e.tables??{}).map(([n,s])=>[n,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:r})}]))}name;version;title;description;icon;readme;attributes;integrations;interfaces;user;conversation;message;states;configuration;events;recurringEvents;actions;tables;workflows;dereferenceEntities({intersectWithUnknownRecord:e}={intersectWithUnknownRecord:!0}){let r=this._buildZuiReferenceMap(e);return{...this,configuration:this.configuration?{...this.configuration,schema:this._dereferenceZuiSchema(this.configuration.schema,r)}:void 0,events:this._dereferenceDefinitionSchemas(this.events,r),states:this._dereferenceDefinitionSchemas(this.states,r),tables:this._dereferenceDefinitionSchemas(this.tables,r),actions:this._dereferenceActionDefinitionSchemas(this.actions,r)}}_buildZuiReferenceMap(e){return Object.fromEntries(Object.entries(this.interfaces??{}).flatMap(([r,n])=>Object.entries(n.definition.entities??{}).map(([s,i])=>[`interface:${r}/entities/${s}`,e?i.schema.and(y.record(y.string(),y.unknown())):i.schema])))}_dereferenceZuiSchema(e,r){return e.dereference(r)}_dereferenceDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,{...s,schema:this._dereferenceZuiSchema(s.schema,r)}]))}_dereferenceActionDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,{...s,input:{schema:this._dereferenceZuiSchema(s.input.schema,r)},output:{schema:this._dereferenceZuiSchema(s.output.schema,r)}}]))}};var Us=":";var td=t=>{let[e,r]=t.split(Us);return!e||!r?null:{namespace:e,eventName:r}},rd=t=>`${t.namespace}${Us}${t.actionName}`,nd=t=>`${t.namespace}${Us}${t.eventName}`,sd=(t,e)=>{let r=e[t.namespace]??{name:t.namespace,version:"0.0.0",entities:{},actions:{},events:{},channels:{}},n=r.name,s=r.actions[t.actionName]?.name??t.actionName;return{namespace:n,actionName:s}},id=(t,e)=>{let r=e[t.namespace]??{name:t.namespace,version:"0.0.0",entities:{},actions:{},events:{},channels:{}},n=r.name,s=r.events[t.eventName]?.name??t.eventName;return{namespace:n,eventName:s}};var ad=(t,e)=>new Proxy({},{get:(r,n)=>new Proxy({},{get:(s,i)=>o=>Vy({client:t,interfaces:e.interfaces,integrationOrInterfaceName:n,methodName:i,input:o})})}),Vy=async({client:t,interfaces:e,integrationOrInterfaceName:r,methodName:n,input:s})=>{let i=sd({namespace:r,actionName:n},e),o=rd(i);return(await t.callAction({type:o,input:s})).output};var zs=class t{constructor(e){this._props=e}async emit(e){let{conversationId:r,userId:n,messageId:s}=this._props;await this._props.client.createEvent({type:this._props.eventName,payload:e,conversationId:r,userId:n,messageId:s})}async schedule(e,r){let{conversationId:n,userId:s,messageId:i}=this._props;await this._props.client.createEvent({type:this._props.eventName,payload:e,conversationId:n,userId:s,messageId:i,schedule:r})}withConversationId(e){return new t({...this._props,conversationId:e})}withUserId(e){return new t({...this._props,userId:e})}withMessageId(e){return new t({...this._props,messageId:e})}},od=(t,e)=>new Proxy({},{get:(r,n)=>{let s=e.alias!==void 0?`${e.alias}${Pe}${n}`:n;return new zs({client:t,eventName:s})}});var Fs=class{constructor(e,r,n){this._client=e;this._stateType=r;this._stateName=n}async get(e){return await this._client.getState({type:this._stateType,name:this._stateName,id:e}).then(r=>r.state.payload)}async set(e,r){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:r})}async getOrSet(e,r){return await this._client.getOrSetState({type:this._stateType,name:this._stateName,id:e,payload:r}).then(n=>n.state.payload)}async delete(e){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:null})}async patch(e,r){await this._client.patchState({type:this._stateType,name:this._stateName,id:e,payload:r})}},ld=(t,e)=>new Proxy({},{get:(r,n)=>new Proxy({},{get:(s,i)=>{let o=e.alias!==void 0?`${e.alias}${Pe}${i}`:i;return new Fs(t,n,o)}})});var kn=class{constructor(e){this.props=e;this._actionHandlers=e.actions}_runtimeProps;_actionHandlers;_messageHandlers={};_eventHandlers={};_stateExpiredHandlers={};_hookHandlers={before_incoming_event:{},before_incoming_message:{},before_outgoing_message:{},before_outgoing_call_action:{},before_incoming_call_action:{},after_incoming_event:{},after_incoming_message:{},after_outgoing_message:{},after_outgoing_call_action:{},after_incoming_call_action:{}};_workflowHandlers={started:{},continued:{},timed_out:{}};_registerOrder=0;initialize(e){return this._runtimeProps=e,this}get _runtime(){if(!this._runtimeProps)throw new Error("Plugin not correctly initialized. This is likely because you access your plugin config outside of an handler.");return this._runtimeProps}_getTools(e){let{configuration:r,interfaces:n,alias:s}=this._runtime,i=ad(e,this._runtime),o=ld(e,this._runtime),l=mt(e),u=od(e,this._runtime);return{configuration:r,interfaces:n,actions:i,states:o,alias:s,workflows:l,events:u}}get actionHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._actionHandlers[r];if(n)return ye.setName(s=>n({...s,...this._getTools(s.client)}),n.name)}})}get messageHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._messageHandlers[r]??[],s=this._messageHandlers["*"]??[];return S.unique([...n,...s]).sort((o,l)=>o.order-l.order).map(({handler:o})=>ye.setName(l=>o({...l,...this._getTools(l.client)}),o.name))}})}get eventHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._eventHandlers[r]??[],s=Object.entries(this._eventHandlers).filter(([l])=>this._eventResolvesTo(l,r)).flatMap(([,l])=>l??[]),i=this._eventHandlers["*"]??[];return S.unique([...n,...s,...i]).sort((l,u)=>l.order-u.order).map(({handler:l})=>ye.setName(u=>l({...u,...this._getTools(u.client)}),l.name))}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._stateExpiredHandlers[r]??[],s=this._stateExpiredHandlers["*"]??[];return S.unique([...n,...s]).sort((o,l)=>o.order-l.order).map(({handler:o})=>ye.setName(l=>o({...l,...this._getTools(l.client)}),o.name))}})}get hookHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._hookHandlers[r];if(n)return new Proxy({},{get:(s,i)=>{i=this._stripAliasPrefix(i);let o=n[i]??[],l=Object.entries(n).filter(([g])=>this._eventResolvesTo(g,i)).flatMap(([,g])=>g??[]),u=n["*"]??[];return S.unique([...o,...l,...u]).sort((g,m)=>g.order-m.order).map(({handler:g})=>ye.setName(m=>g({...m,...this._getTools(m.client)}),g.name))}})}})}get workflowHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._workflowHandlers[r];if(n)return new Proxy({},{get:(s,i)=>(n[i]?.sort((l,u)=>l.order-u.order)??[]).map(({handler:l})=>ye.setName(u=>l({...u,...this._getTools(u.client)}),l.name))})}})}on={message:(e,r)=>{this._messageHandlers[e]=S.safePush(this._messageHandlers[e],{handler:r,order:this._registerOrder++})},event:(e,r)=>{this._eventHandlers[e]=S.safePush(this._eventHandlers[e],{handler:r,order:this._registerOrder++})},stateExpired:(e,r)=>{this._stateExpiredHandlers[e]=S.safePush(this._stateExpiredHandlers[e],{handler:r,order:this._registerOrder++})},beforeIncomingEvent:(e,r)=>{this._hookHandlers.before_incoming_event[e]=S.safePush(this._hookHandlers.before_incoming_event[e],{handler:r,order:this._registerOrder++})},beforeIncomingMessage:(e,r)=>{this._hookHandlers.before_incoming_message[e]=S.safePush(this._hookHandlers.before_incoming_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingMessage:(e,r)=>{this._hookHandlers.before_outgoing_message[e]=S.safePush(this._hookHandlers.before_outgoing_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingCallAction:(e,r)=>{this._hookHandlers.before_outgoing_call_action[e]=S.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},beforeIncomingCallAction:(e,r)=>{this._hookHandlers.before_incoming_call_action[e]=S.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingEvent:(e,r)=>{this._hookHandlers.after_incoming_event[e]=S.safePush(this._hookHandlers.after_incoming_event[e],{handler:r,order:this._registerOrder++})},afterIncomingMessage:(e,r)=>{this._hookHandlers.after_incoming_message[e]=S.safePush(this._hookHandlers.after_incoming_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingMessage:(e,r)=>{this._hookHandlers.after_outgoing_message[e]=S.safePush(this._hookHandlers.after_outgoing_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingCallAction:(e,r)=>{this._hookHandlers.after_outgoing_call_action[e]=S.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingCallAction:(e,r)=>{this._hookHandlers.after_incoming_call_action[e]=S.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:r,order:this._registerOrder++})},workflowStart:(e,r)=>{this._workflowHandlers.started[e]=S.safePush(this._workflowHandlers.started[e],{handler:r,order:this._registerOrder++})},workflowContinue:(e,r)=>{this._workflowHandlers.continued[e]=S.safePush(this._workflowHandlers.continued[e],{handler:r,order:this._registerOrder++})},workflowTimeout:(e,r)=>{this._workflowHandlers.timed_out[e]=S.safePush(this._workflowHandlers.timed_out[e],{handler:r,order:this._registerOrder++})}};_eventResolvesTo=(e,r)=>{let n=td(e);if(!n)return!1;let s=id(n,this._runtime.interfaces);return nd(s)===r};_stripAliasPrefix=e=>{let{alias:r}=this._runtime;if(!r)return e;let n=`${r}#`;return e.startsWith(n)?e.slice(n.length):e}};0&&(module.exports={BRAND,Bot,BotDefinition,BotLogger,BotSpecificClient,DIRTY,EMPTY_PATH,INVALID,Integration,IntegrationDefinition,IntegrationLogger,IntegrationSpecificClient,InterfaceDefinition,NEVER,OK,ParseInputLazyPath,ParseStatus,Plugin,PluginDefinition,RuntimeError,Schema,WELL_KNOWN_ATTRIBUTES,ZodAny,ZodArray,ZodBigInt,ZodBoolean,ZodBranded,ZodCatch,ZodDate,ZodDefault,ZodDiscriminatedUnion,ZodEffects,ZodEnum,ZodError,ZodFirstPartyTypeKind,ZodFunction,ZodIntersection,ZodIssueCode,ZodLazy,ZodLiteral,ZodMap,ZodNaN,ZodNativeEnum,ZodNever,ZodNull,ZodNullable,ZodNumber,ZodObject,ZodOptional,ZodParsedType,ZodPipeline,ZodPromise,ZodReadonly,ZodRecord,ZodRef,ZodSchema,ZodSet,ZodString,ZodSymbol,ZodTransformer,ZodTuple,ZodType,ZodUndefined,ZodUnion,ZodUnknown,ZodVoid,addIssueToContext,agent,aimodel,any,array,bigint,boolean,botIdHeader,botUserIdHeader,coerce,configurationHeader,configurationTypeHeader,conversation,createZodEnum,cuid2Regex,cuidRegex,custom,datasource,date,discriminatedUnion,effect,emailRegex,enum:null,errorUtil,event,function:null,getErrorMap,getParsedType,instanceof:null,integrationIdHeader,intent,intersection,ipv4Regex,ipv6Regex,isAborted,isApiError,isAsync,isDirty,isEmojiRegex,isValid,knowledgebase,late,lazy,literal,makeIssue,map,mergeObjectSchemas,message,messages,nan,nativeEnum,never,null:null,nullable,number,object,objectUtil,oboolean,onumber,operationHeader,optional,ostring,parseBody,pipeline,preprocess,processCreateParams,promise,quotelessJson,readonly,record,ref,serve,set,setErrorMap,strictObject,string,symbol,table,tablerow,transformer,transforms,tuple,typeHeader,ulidRegex,undefined,union,unknown,user,util,uuidRegex,variable,void:null,webhookIdHeader,z});
67
+ `,s+="})"}let i=r?s?r+s:n?n==="z.never()"?r+".strict()":r+`.catchall(${n})`:r:s||(n?`z.record(${n})`:"z.record(z.any())");return $.an.anyOf(t)&&(i+=`.and(${su(p(c({},t),{anyOf:t.anyOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?p(c({},o),{type:"object"}):o)}),e)})`),$.a.oneOf(t)&&(i+=`.and(${Bs(p(c({},t),{oneOf:t.oneOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?p(c({},o),{type:"object"}):o)}),e)})`),$.an.allOf(t)&&(i+=`.and(${$t(p(c({},t),{allOf:t.allOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?p(c({},o),{type:"object"}):o)}),e)})`),i}a(iu,"parseObject");var _m=a(t=>{var e;let r="z.string()";if((e=t[b])!=null&&e.coerce){if(t.format==="date-time")return"z.coerce.date()";r="z.coerce.string()"}return r+=G(t,"format",({value:n})=>{switch(n){case"email":return[".email(",")"];case"ip":return[".ip(",")"];case"ipv4":return['.ip({ version: "v4"',", message: "," })"];case"ipv6":return['.ip({ version: "v6"',", message: "," })"];case"uri":return[".url(",")"];case"uuid":return[".uuid(",")"];case"date-time":return[".datetime(",")"]}}),r+=G(t,"pattern",({json:n})=>[`.regex(new RegExp(${n})`,", ",")"]),r+=G(t,"minLength",({json:n})=>[`.min(${n}`,", ",")"]),r+=G(t,"maxLength",({json:n})=>[`.max(${n}`,", ",")"]),r},"parseString"),Tm=a((t,e)=>`${L(pm(t,"nullable"),e,!0)}.nullable()`,"parseNullable"),bm=a(t=>`z.ref('${t.$ref}')`,"parseRef"),wm=a((t,e)=>{var r,n;if(t.oneOf.length<=1||!((r=t.discriminator)!=null&&r.propertyName))return Bs(t,e);let s=t.oneOf.map((i,o)=>L(i,p(c({},e),{path:[...e.path,"oneOf",o]})));return`z.discriminatedUnion("${(n=t.discriminator)==null?void 0:n.propertyName}", [${s.join(", ")}])`},"parseDiscriminator"),L=a((t,e={seen:new Map,path:[]},r)=>{if(typeof t!="object")return t?"z.any()":"z.never()";if(e.parserOverride){let i=e.parserOverride(t,e);if(typeof i=="string")return i}let n=e.seen.get(t);if(n){if(n.r!==void 0)return n.r;if(e.depth===void 0||n.n>=e.depth)return"z.any()";n.n+=1}else n={r:void 0,n:0},e.seen.set(t,n);let s=km(t,e);return r||(s=Pm(t,s),e.withoutDefaults||(s=xm(t,s))),n.r=s,s},"parseSchema"),Pm=a((t,e)=>(t.description&&(e+=`.describe(${JSON.stringify(t.description)})`),e),"addMeta"),xm=a((t,e)=>(t.default!==void 0&&(e+=`.default(${JSON.stringify(t.default)})`),e),"addDefaults"),km=a((t,e)=>$.a.nullable(t)?Tm(t,e):$.an.object(t)?iu(t,e):$.an.array(t)?gm(t,e):$.an.anyOf(t)?su(t,e):$.an.allOf(t)?$t(t,e):$.a.discriminator(t)?wm(t,e):$.a.oneOf(t)?Bs(t,e):$.a.not(t)?cm(t,e):$.an.enum(t)?mm(t):$.a.const(t)?hm(t):$.a.multipleType(t)?lm(t,e):$.a.primitive(t,"string")?_m(t):$.a.primitive(t,"number")||$.a.primitive(t,"integer")?vm(t):$.a.primitive(t,"boolean")?am(t):$.a.primitive(t,"null")?um(t):$.a.conditional(t)?ym(t,e):$.a.ref(t)?bm(t):om(t),"selectParser"),$={an:{object:a(t=>t.type==="object","object"),array:a(t=>t.type==="array","array"),anyOf:a(t=>t.anyOf!==void 0,"anyOf"),allOf:a(t=>t.allOf!==void 0,"allOf"),enum:a(t=>t.enum!==void 0,"enum")},a:{nullable:a(t=>t.nullable===!0,"nullable"),multipleType:a(t=>Array.isArray(t.type),"multipleType"),not:a(t=>t.not!==void 0,"not"),const:a(t=>t.const!==void 0,"const"),primitive:a((t,e)=>t.type===e,"primitive"),conditional:a(t=>!!("if"in t&&t.if&&"then"in t&&"else"in t&&t.then&&t.else),"conditional"),discriminator:a(t=>{var e;return t.oneOf!==void 0&&((e=t.discriminator)==null?void 0:e.propertyName)!==void 0},"discriminator"),oneOf:a(t=>t.oneOf!==void 0,"oneOf"),ref:a(t=>t.$ref!==void 0,"ref")}},Sm=a(t=>{let e;try{e=new Function("z",`return ${t}`)(d)}catch(r){return{sucess:!1,error:`Failed to evaluate schema: ${(r instanceof Error?r:new Error(String(r))).message}`}}return e instanceof d.ZodType?{sucess:!0,value:e}:{sucess:!1,error:`String "${t}" does not evaluate to a Zod schema`}},"evalZuiString"),Om=a(t=>L(t,{seen:new Map,path:[]}),"jsonSchemaToZodStr"),Em=a(t=>{let e=Om(t);e=e.replaceAll("errors: z.ZodError[]","errors");let r=Sm(e);if(!r.sucess)throw new Lr(r.error);return r.value},"jsonSchemaToZod"),Bt=a((t,e)=>{var r,n;if(e[b]&&t._def&&(t._def[b]=e[b]),((r=t._def)==null?void 0:r.typeName)==="ZodObject"&&e.type==="object"&&e.properties&&Object.entries(e.properties).forEach(([s,i])=>{let o=typeof t._def.shape=="function"?t._def.shape():t._def.shape;o[s]&&Bt(o[s],i)}),((n=t._def)==null?void 0:n.typeName)==="ZodRecord"&&e.type==="object"&&e.additionalProperties&&Bt(t._def.valueType,e.additionalProperties),e.type==="array"&&e.items){let s=e.items;if(typeof s=="object"&&!Array.isArray(s)){let i=t._def.type;i&&Bt(i,s)}else Array.isArray(s)&&s.forEach((i,o)=>{let l=t._def;l.typeName===y.ZodFirstPartyTypeKind.ZodTuple&&Bt(l.items[o],i)})}},"applyZuiPropsRecursively"),Zm=a(t=>{let e=Em(t);return Bt(e,t),e},"fromJSONSchemaLegacy"),Im=a(t=>{var e,r;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(n=>typeof n!="boolean"&&au(n))&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===d.ZodFirstPartyTypeKind.ZodOptional},"isOptionalSchema"),Bm=a(t=>{var e,r;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(n=>typeof n!="boolean"&&n.type==="null")&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===d.ZodFirstPartyTypeKind.ZodNullable},"isNullableSchema"),au=a(t=>{var e,r;return t.not===!0&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===d.ZodFirstPartyTypeKind.ZodUndefined},"isUndefinedSchema"),Cm=a(t=>{var e,r;return!t.not&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===d.ZodFirstPartyTypeKind.ZodUnknown},"isUnknownSchema"),Am=a(({type:t,minimum:e,exclusiveMinimum:r,maximum:n,exclusiveMaximum:s,multipleOf:i,format:o})=>{let l=d.number();return t==="integer"&&(l=l.int()),o==="finite"&&(l=l.finite()),r!==void 0?l=l.gt(r):e!==void 0&&(l=l.gte(e)),s!==void 0?l=l.lt(s):n!==void 0&&(l=l.lte(n)),i!==void 0&&(l=l.multipleOf(i)),l},"numberJSONSchemaToZuiNumber"),Rm=a(({format:t,pattern:e,minLength:r,maxLength:n})=>{let s=d.string();if(r&&n&&r===n?s=s.length(r):(r&&(s=s.min(r)),n&&(s=s.max(n))),t==="cuid"||e===j.cuid)s=s.cuid();else if(t==="cuid2"||e===j.cuid2)s=s.cuid2();else if(t==="emoji"||e===j.emoji)s=s.emoji();else if(t==="ulid"||e===j.ulid)s=s.ulid();else if(t==="date-time"){let{precision:i,offset:o}=e?Vh(e):{};s=s.datetime({precision:i,offset:o})}else t==="email"||e===j.email?s=s.email():t==="ipv4"||e===j.ipv4?s=s.ip():t==="ipv6"||e===j.ipv6?s=s.ip("v6"):t==="uri"?s=s.url():t==="uuid"||e===j.uuid?s=s.uuid():e&&(s=s.regex(new RegExp(e)));return s},"stringJSONSchemaToZuiString"),_t=a((t,e)=>{let r=[];e.enum!==void 0&&r.push(...e.enum),e.const!==void 0&&r.push(e.const);let n=r.filter(o=>typeof o===t),[s]=n;if(!s){if(t==="string"&&e.type==="string")return Rm(e);if(t==="number"&&(e.type==="number"||e.type==="integer"))return Am(e);if(t==="boolean")return d.boolean();if(t==="null")return d.null();throw new Lr(`Unknown primitive type: "${t}"`)}if(n.length===1)return d.literal(s);let i=n.map(o=>d.literal(o));return d.union(i)},"toZuiPrimitive"),Hm=a((t,e)=>Dm(t)?Nm(t,e):Mm(t)?$m(t,e):jm(t,e),"arrayJSONSchemaToZuiArray"),Dm=a(t=>Array.isArray(t.items),"_isTuple"),Mm=a(t=>t.items!==void 0&&t.uniqueItems,"_isSet"),Nm=a(({items:t,additionalItems:e},r)=>{let n=t.map(r),s=d.tuple(n);return e!==void 0&&(s=s.rest(r(e))),s},"_handleTuple"),$m=a(({items:t,minItems:e,maxItems:r},n)=>{let s=d.set(n(t));return e&&(s=s.min(e)),r&&(s=s.max(r)),s},"_handleSet"),jm=a(({minItems:t,maxItems:e,items:r},n)=>{let s=d.array(n(r));return t&&t===e?s.length(t):(t&&(s=s.min(t)),e&&(s=s.max(e)),s)},"_handleArray"),Je=d.any();function ou(t){return F(t)}a(ou,"fromJSONSchema");function F(t){var e;if(t===void 0)return Je;if(t===!0)return d.any();if(t===!1)return d.never();if(t.default!==void 0)return F(p(c({},t),{default:void 0})).default(t.default);if(t.readOnly)return F(p(c({},t),{readOnly:void 0})).readonly();if(t.oneOf!==void 0)throw new _e({oneOf:t.oneOf});if(t.patternProperties!==void 0)throw new _e({patternProperties:t.patternProperties});if(t.propertyNames!==void 0)throw new _e({propertyNames:t.propertyNames});if(t.if!==void 0)throw new _e({if:t.if});if(t.then!==void 0)throw new _e({then:t.then});if(t.else!==void 0)throw new _e({else:t.else});if(t.$ref!==void 0)return d.ref(t.$ref);if(t.not!==void 0){if(au(t))return d.undefined();if(t.not===!0)return d.never();throw new _e({not:t.not})}if(Array.isArray(t.type)){if(t.type.length===0)return Je;if(t.type.length===1)return F(p(c({},t),{type:t.type[0]}));let r=t,{type:n}=r,s=Bi(r,["type"]),i=t.type.map(o=>F(p(c({},s),{type:o})));return d.union(i)}if(t.type==="string")return t.enum&&t.enum.length>0?d.enum(t.enum):_t("string",t);if(t.type==="integer"){let r=_t("number",t);return r instanceof d.ZodNumber?r.int():r}if(t.type==="number")return _t("number",t);if(t.type==="boolean")return _t("boolean",t);if(t.type==="null")return _t("null",t);if(t.type==="array")return Hm(t,F);if(t.type==="object"){if(t.additionalProperties!==void 0&&t.properties!==void 0){let r=F(t.additionalProperties);return F(p(c({},t),{additionalProperties:void 0})).catchall(r)}if(t.properties!==void 0){let r={};for(let[n,s]of Object.entries(t.properties)){let i=F(s),o=(e=t.required)!=null?e:[];r[n]=o.includes(n)?i:i.optional()}return d.object(r)}if(t.additionalProperties!==void 0){let r=F(t.additionalProperties);return d.record(r)}return d.record(Je)}if(t.anyOf!==void 0){if(t.anyOf.length===0)return Je;if(t.anyOf.length===1)return F(t.anyOf[0]);if(Im(t))return F(t.anyOf[0]).optional();if(Bm(t))return F(t.anyOf[0]).nullable();let r=t.anyOf.map(F);return d.union(r)}if(t.allOf!==void 0){if(t.allOf.length===0)return Je;if(t.allOf.length===1)return F(t.allOf[0]);let[r,...n]=t.allOf,s=F(r),i=F({allOf:n});return d.intersection(s,i)}return Cm(t)?d.unknown():Je}a(F,"_fromJSONSchema");var Km=/^\d{4}-\d{2}-\d{2}(T|\s)?((\d{2}:\d{2}:\d{2}(\.\d{1,3})?)|(\d{2}:\d{2}))?(\s?([+-]\d{2}:\d{2}|Z))?$/,Fn=a((t,e,r=!0)=>{if(typeof t!="object")throw new Rn("Input must be an object");let n=a(o=>{let l=o;return e?.nullable&&(l=l.nullable()),e?.optional&&(l=l.optional()),e?.passtrough&&typeof l.passthrough=="function"&&(l=l.passthrough()),l},"applyOptions"),s=Object.entries(t).reduce((o,[l,u])=>{if(u===null)o[l]=n(y.null());else switch(typeof u){case"string":o[l]=Km.test(u)?n(y.string().datetime()):n(y.string());break;case"number":o[l]=n(y.number());break;case"boolean":o[l]=n(y.boolean());break;case"object":Array.isArray(u)?u.length===0?o[l]=n(y.array(y.unknown())):typeof u[0]=="object"?o[l]=n(y.array(Fn(u[0],e,!1))):["string","number","boolean"].includes(typeof u[0])&&(o[l]=n(y.array(y[typeof u[0]]()))):o[l]=n(Fn(u,e,!1));break;default:throw new Rn(`Unsupported type for key ${l}`)}return o},{}),i=Object.keys(s).length>0;return e?.passtrough||!r&&!i?y.object(s).passthrough():y.object(s)},"fromObject");function lu(){return{}}a(lu,"parseAnyDef");function cu(t,e){var r,n;let s={type:"array"};return((n=(r=t.type)==null?void 0:r._def)==null?void 0:n.typeName)!=="ZodAny"&&(s.items=C(t.type._def,p(c({},e),{currentPath:[...e.currentPath,"items"]}))),t.minLength&&H(s,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&H(s,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(H(s,"minItems",t.exactLength.value,t.exactLength.message,e),H(s,"maxItems",t.exactLength.value,t.exactLength.message,e)),s}a(cu,"parseArrayDef");function uu(t,e){let r=c({type:"integer",format:"int64"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?H(r,"minimum",n.value,n.message,e):H(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),H(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?H(r,"maximum",n.value,n.message,e):H(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),H(r,"maximum",n.value,n.message,e));break;case"multipleOf":H(r,"multipleOf",n.value,n.message,e);break}return r}a(uu,"parseBigintDef");function du(t){return c({type:"boolean"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{})}a(du,"parseBooleanDef");function pu(t,e){return C(t.type._def,e)}a(pu,"parseBrandedDef");var Um=a((t,e)=>C(t.innerType._def,e),"parseCatchDef");function fu(t,e){return e.dateStrategy=="integer"?zm(t,e):c({type:"string",format:"date-time"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{})}a(fu,"parseDateDef");var zm=a((t,e)=>{let r=c({type:"integer",format:"unix-time"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"&&H(r,"minimum",n.value,n.message,e);break;case"max":e.target==="jsonSchema7"&&H(r,"maximum",n.value,n.message,e);break}return r},"integerDateParser");function gu(t,e){return p(c({},C(t.innerType._def,e)),{default:t.defaultValue()})}a(gu,"parseDefaultDef");function hu(t,e){return e.effectStrategy==="input"?C(t.schema._def,e):{}}a(hu,"parseEffectsDef");function mu(t){return{type:"string",enum:t.values}}a(mu,"parseEnumDef");var Fm=a(t=>"type"in t&&t.type==="string"?!1:"allOf"in t,"isJsonSchema7AllOfType");function yu(t,e){let r=[C(t.left._def,p(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),C(t.right._def,p(c({},e),{currentPath:[...e.currentPath,"allOf","1"]}))].filter(i=>!!i),n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,s=[];return r.forEach(i=>{if(Fm(i))s.push(...i.allOf),i.unevaluatedProperties===void 0&&(n=void 0);else{let o=i;if("additionalProperties"in i&&i.additionalProperties===!1){let l=i,{additionalProperties:u}=l;o=Bi(l,["additionalProperties"])}else n=void 0;s.push(o)}}),s.length?c({allOf:s},n):void 0}a(yu,"parseIntersectionDef");function vu(t,e){let r=typeof t.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[t.value]}:{type:r==="bigint"?"integer":r,const:t.value}}a(vu,"parseLiteralDef");function Cs(t,e){var r,n,s,i,o;if(e.target==="openApi3"&&((r=t.keyType)==null?void 0:r._def.typeName)==="ZodEnum")return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((u,f)=>{var g;return p(c({},u),{[f]:(g=C(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"properties",f]})))!=null?g:{}})},{}),additionalProperties:!1};let l={type:"object",additionalProperties:(n=C(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?n:{}};if(e.target==="openApi3")return l;if(((s=t.keyType)==null?void 0:s._def.typeName)==="ZodString"&&((i=t.keyType._def.checks)!=null&&i.length)){let u=Object.entries(as(t.keyType._def,e)).reduce((f,[g,m])=>g==="type"?f:p(c({},f),{[g]:m}),{});return p(c({},l),{propertyNames:u})}else if(((o=t.keyType)==null?void 0:o._def.typeName)==="ZodEnum")return p(c({},l),{propertyNames:{enum:t.keyType._def.values}});return l}a(Cs,"parseRecordDef");function _u(t,e){if(e.mapStrategy==="record")return Cs(t,e);let r=C(t.keyType._def,p(c({},e),{currentPath:[...e.currentPath,"items","items","0"]}))||{},n=C(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"items","items","1"]}))||{};return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}a(_u,"parseMapDef");function Tu(t){let e=t.values,n=Object.keys(t.values).filter(i=>typeof e[e[i]]!="number").map(i=>e[i]),s=Array.from(new Set(n.map(i=>typeof i)));return{type:s.length===1?s[0]==="string"?"string":"number":["string","number"],enum:n.filter(i=>typeof i=="string"||typeof i=="number")}}a(Tu,"parseNativeEnumDef");function bu(){return{not:{}}}a(bu,"parseNeverDef");function wu(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}a(wu,"parseNullDef");var zr={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function Pu(t,e){if(e.target==="openApi3")return Oi(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in zr&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((s,i)=>{let o=zr[i._def.typeName];return o&&!s.includes(o)?[...s,o]:s},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((s,i)=>{let o=typeof i._def.value;switch(o){case"string":case"number":case"boolean":return[...s,o];case"bigint":return[...s,"integer"];case"object":if(i._def.value===null)return[...s,"null"];case"symbol":case"undefined":case"function":default:return s}},[]);if(n.length===r.length){let s=n.filter((i,o,l)=>l.indexOf(i)===o);return{type:s.length>1?s:s[0],enum:r.reduce((i,o)=>i.includes(o._def.value)?i:[...i,o._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,s)=>[...n,...s._def.values.filter(i=>!n.includes(i))],[])};return Oi(t,e)}a(Pu,"parseUnionDef");var Oi=a((t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((s,i)=>C(s._def,p(c({},e),{currentPath:[...e.currentPath,e.unionStrategy,`${i}`]}))).filter(s=>!!s&&(!e.strictUnions||typeof s=="object"&&Object.keys(s).length>0)),n=e.discriminator&&t.typeName==="ZodDiscriminatedUnion"&&typeof t.discriminator=="string"?{discriminator:{propertyName:t.discriminator}}:{};if(r.length)return e.unionStrategy==="anyOf"?c({anyOf:r},n):c({oneOf:r},n)},"asUnionOf");function xu(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length)){let n=t.innerType;if(e.target==="openApi3"){let i={type:zr[n._def.typeName],nullable:!0};return Ln(n._def,e,i)}let s={type:[zr[n._def.typeName],"null"]};return Ln(n._def,e,s)}if(e.target==="openApi3"){let n=C(t.innerType._def,p(c({},e),{currentPath:[...e.currentPath]}));return n&&p(c({},n),{nullable:!0})}let r=C(t.innerType._def,p(c({},e),{currentPath:[...e.currentPath,"anyOf","0"]}));return r&&{anyOf:[r,{type:"null"}]}}a(xu,"parseNullableDef");function ku(t,e){let r=c({type:"number"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"int":r.type="integer",is(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?H(r,"minimum",n.value,n.message,e):H(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),H(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?H(r,"maximum",n.value,n.message,e):H(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),H(r,"maximum",n.value,n.message,e));break;case"multipleOf":H(r,"multipleOf",n.value,n.message,e);break}return r}a(ku,"parseNumberDef");var Lm=a((t,e)=>{var r;return t.unknownKeys instanceof O?(r=C(t.unknownKeys._def,p(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?r:!0:t.unknownKeys==="passthrough"},"getAdditionalProperties");function Su(t,e){let r=p(c({type:"object"},Object.entries(t.shape()).reduce((n,[s,i])=>{if(i===void 0||i._def===void 0)return n;let o=C(i._def,p(c({},e),{currentPath:[...e.currentPath,"properties",s],propertyPath:[...e.currentPath,"properties",s]}));return o===void 0?n:{properties:p(c({},n.properties),{[s]:o}),required:i.isOptional()?n.required:[...n.required,s]}},{properties:{},required:[]})),{additionalProperties:Lm(t,e)});return r.required.length||delete r.required,r}a(Su,"parseObjectDef");var Wm=a((t,e)=>{var r;if(e.currentPath.toString()===((r=e.propertyPath)==null?void 0:r.toString()))return C(t.innerType._def,e);let n=C(t.innerType._def,p(c({},e),{currentPath:[...e.currentPath,"anyOf","1"]}));return n?{anyOf:[{not:{}},n]}:{}},"parseOptionalDef"),qm=a((t,e)=>{if(e.pipeStrategy==="input")return C(t.in._def,e);if(e.pipeStrategy==="output")return C(t.out._def,e);let r=C(t.in._def,p(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),n=C(t.out._def,p(c({},e),{currentPath:[...e.currentPath,"allOf",r?"1":"0"]}));return{allOf:[r,n].filter(s=>s!==void 0)}},"parsePipelineDef");function Ou(t,e){return C(t.type._def,e)}a(Ou,"parsePromiseDef");function Eu(t,e){let n={type:"array",uniqueItems:!0,items:C(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"items"]}))};return t.minSize&&H(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&H(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}a(Eu,"parseSetDef");function Zu(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>C(r._def,p(c({},e),{currentPath:[...e.currentPath,"items",`${n}`]}))).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:C(t.rest._def,p(c({},e),{currentPath:[...e.currentPath,"additionalItems"]}))}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>C(r._def,p(c({},e),{currentPath:[...e.currentPath,"items",`${n}`]}))).reduce((r,n)=>n===void 0?r:[...r,n],[])}}a(Zu,"parseTupleDef");function Iu(){return{not:{}}}a(Iu,"parseUndefinedDef");function Bu(){return{}}a(Bu,"parseUnknownDef");var Vm=a((t,e)=>C(t.innerType._def,e),"parseReadonlyDef");function Cu(t){return{$ref:t.uri}}a(Cu,"parseRefDef");function C(t,e,r=!1){let n=e.seen.get(t);if(n&&!r){let o=Gm(n,e);if(o!==void 0)return o}let s={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,s);let i=Xm(t,t.typeName,e);return i&&Ln(t,e,i),s.jsonSchema=i,i}a(C,"parseDef");var Gm=a((t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Jm(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((r,n)=>e.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),{}):e.$refStrategy==="seen"?{}:void 0}},"get$ref"),Jm=a((t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")},"getRelativePath"),Xm=a((t,e,r)=>{switch(e){case"ZodString":return as(t,r);case"ZodNumber":return ku(t,r);case"ZodObject":return Su(t,r);case"ZodBigInt":return uu(t,r);case"ZodBoolean":return du(t);case"ZodDate":return fu(t,r);case"ZodUndefined":return Iu();case"ZodNull":return wu(r);case"ZodArray":return cu(t,r);case"ZodUnion":case"ZodDiscriminatedUnion":return Pu(t,r);case"ZodIntersection":return yu(t,r);case"ZodTuple":return Zu(t,r);case"ZodRecord":return Cs(t,r);case"ZodRef":return Cu(t);case"ZodLiteral":return vu(t,r);case"ZodEnum":return mu(t);case"ZodNativeEnum":return Tu(t);case"ZodNullable":return xu(t,r);case"ZodOptional":return Wm(t,r);case"ZodMap":return _u(t,r);case"ZodSet":return Eu(t,r);case"ZodLazy":return C(t.getter()._def,r);case"ZodPromise":return Ou(t,r);case"ZodNaN":case"ZodNever":return bu();case"ZodEffects":return hu(t,r);case"ZodAny":return lu();case"ZodUnknown":return Bu();case"ZodDefault":return gu(t,r);case"ZodBranded":return pu(t,r);case"ZodReadonly":return Vm(t,r);case"ZodCatch":return Um(t,r);case"ZodPipeline":return qm(t,r);case"ZodFunction":case"ZodVoid":case"ZodSymbol":return;default:return(n=>{})(e)}},"selectParser"),Ln=a((t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),Object.assign(r,{[b]:c(c({},t[b]),r[b])}),r),"addMeta"),Ei={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"string",mapStrategy:"entries",definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",emailStrategy:"format:email",discriminator:!1,unionStrategy:"anyOf"},Ym=a(t=>typeof t=="string"?p(c({},Ei),{name:t}):c(c({},Ei),t),"getDefaultOptions"),Qm=a(t=>{let e=Ym(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return p(c({},e),{currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([n,s])=>[s._def,{def:s._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))})},"getRefs"),ey=a((t,e)=>{var r;let n=Qm(e),s=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((u,[f,g])=>{var m;return p(c({},u),{[f]:(m=C(g._def,p(c({},n),{currentPath:[...n.basePath,n.definitionPath,f]}),!0))!=null?m:{}})},{}):void 0,i=typeof e=="string"?e:e?.name,o=(r=C(t._def,i===void 0?n:p(c({},n),{currentPath:[...n.basePath,n.definitionPath,i]}),!1))!=null?r:{},l=i===void 0?s?p(c({},o),{[n.definitionPath]:s}):o:{$ref:[...n.$refStrategy==="relative"?[]:n.basePath,n.definitionPath,i].join("/"),[n.definitionPath]:p(c({},s),{[i]:o})};return n.target==="jsonSchema7"?l.$schema="http://json-schema.org/draft-07/schema#":n.target==="jsonSchema2019-09"&&(l.$schema="https://json-schema.org/draft/2019-09/schema#"),l},"zodToJsonSchema"),ty=a((t,e={target:"openApi3"})=>{let r=ey(t,e);return e.$schemaUrl===!1?delete r.$schema:typeof e.$schemaUrl=="string"&&(r.$schema=e.$schemaUrl),r},"toJSONSchemaLegacy");var dt=(t,e)=>{let r=t._def,n=e._def;if(r.typeName===y.ZodFirstPartyTypeKind.ZodObject&&n.typeName===y.ZodFirstPartyTypeKind.ZodObject){let s=r.shape(),i=n.shape();return y.object({...s,...i})}if(r.typeName===y.ZodFirstPartyTypeKind.ZodRecord&&n.typeName===y.ZodFirstPartyTypeKind.ZodRecord)return y.record(y.intersection(r.valueType,n.valueType));throw new Error("Cannot merge object schemas with record schemas")},Au=y;var re=y.string().min(1),Hu=y.object({text:re}),Du=y.object({markdown:re}),Mu=y.object({imageUrl:re}),Nu=y.object({audioUrl:re}),$u=y.object({videoUrl:re}),ju=y.object({fileUrl:re,title:re.optional()}),Ku=y.object({latitude:y.number(),longitude:y.number(),address:y.string().optional(),title:y.string().optional()}),Uu=y.object({title:re,subtitle:re.optional(),imageUrl:re.optional(),actions:y.array(y.object({action:y.enum(["postback","url","say"]),label:re,value:re}))}),Ru=y.object({text:re,options:y.array(y.object({label:re,value:re}))}),ry=y.object({items:y.array(Uu)}),ny=y.union([y.object({type:y.literal("text"),payload:Hu}),y.object({type:y.literal("markdown"),payload:Du}),y.object({type:y.literal("image"),payload:Mu}),y.object({type:y.literal("audio"),payload:Nu}),y.object({type:y.literal("video"),payload:$u}),y.object({type:y.literal("file"),payload:ju}),y.object({type:y.literal("location"),payload:Ku})]),sy=y.object({items:y.array(ny)}),iy={schema:Du},ay={text:{schema:Hu},image:{schema:Mu},audio:{schema:Nu},video:{schema:$u},file:{schema:ju},location:{schema:Ku},carousel:{schema:ry},card:{schema:Uu},dropdown:{schema:Ru},choice:{schema:Ru},bloc:{schema:sy}};var Wt="x-bot-id",Rs="x-bot-user-id",Hs="x-integration-id",Ds="x-webhook-id",Ms="x-bp-configuration-type",qt="x-bp-configuration",Vt="x-bp-operation",Ns="x-bp-type",oy={HIDDEN_IN_STUDIO:{bpActionHiddenInStudio:"true"},AWAIT_RETURN:{bpActionAwaitReturn:"true"}};var zu=require("browser-or-node");var $s=console;function oe(t){if(!t.body)throw new Error("Missing body");return JSON.parse(t.body)}async function Gt(t,e=8072,r=dy){if(!zu.isNode)throw new Error("This function can only be called in Node.js");let s=require("http").createServer(async(i,o)=>{try{let l=await ly(i);if(l.path==="/health"){o.writeHead(200).end("ok");return}let u=await t(l);o.writeHead(u?.status??200,u?.headers??{}).end(u?.body??"{}")}catch(l){$s.error("Error while handling request",{error:l?.message??"Internal error occured"}),o.writeHead(500).end(JSON.stringify({error:l?.message??"Internal error occured"}))}});return s.listen(e,()=>r(e)),s}async function ly(t){let e=await uy(t),r={};for(let s=0;s<t.rawHeaders.length;s+=2){let i=t.rawHeaders[s].toLowerCase(),o=t.rawHeaders[s+1];r[i]=o}let n=new URL(t.url??"",t.headers.host?`http://${t.headers.host}`:"http://botpress.cloud");return{body:e,path:n.pathname,query:cy(n.search,"?"),headers:r,method:t.method?.toUpperCase()??"GET"}}function cy(t,e){return t.indexOf(e)===0?t.slice(e.length):t}async function uy(t){return new Promise((e,r)=>{if(t.method!=="POST"&&t.method!=="PUT"&&t.method!=="PATCH")return e(void 0);let n="";t.on("data",s=>n+=s.toString()),t.on("error",s=>r(s)),t.on("end",()=>e(n))})}function dy(t){$s.info(`Listening on port ${t}`)}var Sn=require("@botpress/client");var M={};yt(M,{mapKeys:()=>gy,mapValues:()=>fy,mergeRecords:()=>my,pairs:()=>hn,stripUndefinedProps:()=>hy,values:()=>py});var hn=t=>Object.entries(t),py=t=>Object.values(t),fy=(t,e)=>Object.fromEntries(hn(t).map(([r,n])=>[r,e(n,r)])),gy=(t,e)=>Object.fromEntries(hn(t).map(([r,n])=>[e(r),n])),hy=t=>Object.fromEntries(hn(t).filter(([,e])=>e!==void 0)),my=(t,e,r)=>{let n=[...Object.keys(t),...Object.keys(e)],s=[...new Set(n)],i={};for(let o of s){let l=t[o],u=e[o];l&&u?i[o]=r(l,u):l?i[o]=l:u&&(i[o]=u)}return i};var S={};yt(S,{safePush:()=>yy,unique:()=>vy});var yy=(t,...e)=>t?[...t,...e]:[...e],vy=t=>Array.from(new Set(t));var ye={};yt(ye,{setName:()=>_y});var _y=(t,e)=>(Object.defineProperty(t,"name",{value:e}),t);var Fu=t=>{let{name:e,version:r}=t,n={actions:{},events:{},channels:{}},s={name:e,version:r,entities:M.mapValues(t.entities,o=>({name:o.name})),actions:{},events:{},channels:{}},i=M.mapValues(t.entities,o=>o.schema);for(let[o,l]of Object.entries(t.definition.actions??{})){let u=l.input.schema.dereference(i),f=l.output.schema.dereference(i),g=t.actions?.[o]?.name??o;n.actions[g]={...l,...t.actions?.[o]??{},input:{schema:u},output:{schema:f}},s.actions[o]={name:g}}for(let[o,l]of Object.entries(t.definition.events??{})){let u=l.schema.dereference(i),f=t.events?.[o]?.name??o;n.events[f]={...l,...t.events?.[o]??{},schema:u},s.events[o]={name:f}}for(let[o,l]of Object.entries(t.definition.channels??{})){let u={};for(let[g,m]of Object.entries(l.messages)){let P=m.schema.dereference(i);u[g]={...m,schema:P}}let f=t.channels?.[o]?.name??o;n.channels[f]={...l,...t.channels?.[o]??{},message:{...l.message??{},tags:{...l.message?.tags??{},...t.channels?.[o]?.message?.tags??{}}},conversation:{...l.conversation??{},tags:{...l.conversation?.tags??{},...t.channels?.[o]?.conversation?.tags??{}}},messages:u},s.channels[o]={name:f}}return{resolved:n,statement:s}};var mn=Symbol("schemaName"),Lu=t=>t?M.mapValues(t,(r,n)=>({...r,[mn]:n})):{},Wu=t=>mn in t&&t[mn]!==void 0,qu=t=>t[mn];var yn=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.readme=e.readme,this.title=e.title,this.identifier=e.identifier,this.description=e.description,this.configuration=e.configuration,this.configurations=e.configurations,this.events=e.events,this.actions=e.actions,this.channels=e.channels,this.states=e.states,this.user=e.user,this.secrets=e.secrets,this.entities=e.entities,this.interfaces=e.interfaces,this.__advanced=e.__advanced,this.attributes=e.attributes}name;version;title;description;icon;readme;configuration;configurations;events;actions;channels;states;user;secrets;identifier;entities;interfaces;__advanced;attributes;extend(e,r){let{entities:n,actions:s,events:i,channels:o}=this._callBuilder(e,r),l=this;l.interfaces??={};let u=Object.values(n).map(P=>P.name),f=u.length===0?e.name:`${e.name}<${u.join(",")}>`,{resolved:g,statement:m}=Fu({...e,entities:n,actions:M.stripUndefinedProps(s),events:M.stripUndefinedProps(i),channels:M.stripUndefinedProps(o)});return l.actions=M.mergeRecords(l.actions??{},g.actions,this._mergeActions),l.channels=M.mergeRecords(l.channels??{},g.channels,this._mergeChannels),l.events=M.mergeRecords(l.events??{},g.events,this._mergeEvents),l.interfaces[f]={id:e.id,...m},this}_callBuilder(e,r){let s={entities:Lu(this.entities)},i=r(s),o=M.pairs(i.entities).find(([u,f])=>!Wu(f));if(o)throw new Error(`Cannot extend interface "${e.name}" with entity "${o[0]}"; the provided schema is not part of the integration's entities.`);return{entities:M.mapValues(i.entities,u=>({name:qu(u),schema:u.schema})),actions:i.actions??{},events:i.events??{},channels:i.channels??{}}}_mergeActions=(e,r)=>({...e,...r,input:{schema:dt(e.input.schema,r.input.schema)},output:{schema:dt(e.output.schema,r.output.schema)}});_mergeEvents=(e,r)=>({...e,...r,schema:dt(e.schema,r.schema)});_mergeChannels=(e,r)=>{let n=M.mergeRecords(e.messages,r.messages,this._mergeMessage),s;(e.conversation||r.conversation)&&(s={tags:{...e.conversation?.tags,...r.conversation?.tags}});let i;return(e.message||r.message)&&(i={tags:{...e.message?.tags,...r.message?.tags}}),{...e,...r,messages:n,conversation:s,message:i}};_mergeMessage=(e,r)=>({schema:dt(e.schema,r.schema)})};var ve=require("@botpress/client");var Vu=Ws(require("@botpress/client")),vn={retries:3,retryCondition:t=>Vu.axiosRetry.isNetworkOrIdempotentRequestError(t)||[429,502].includes(t.response?.status??0),retryDelay:(t,e)=>(Ty(e.response?.headers??{})??t)*1e3},Ty=t=>{let e=["RateLimit-Reset","X-RateLimit-Reset","Retry-After","ratelimit-reset","x-ratelimit-reset","retry-after"];for(let r of e){let n=t[r];if(n!==void 0)return by(String(n))}},by=t=>{let e=wy(t)?Py(t):t.length>0?parseInt(t,10):void 0;return e===void 0||isNaN(e)?void 0:e},wy=t=>t.includes(" "),Py=t=>{let e=xy(t);if(!e)return;let r=new Date;return Math.max(0,Math.floor((e.getTime()-r.getTime())/1e3))},xy=t=>{let e=new Date(t);return isNaN(e.getTime())?void 0:e};var pt=class{constructor(e){this._client=e}get _inner(){return this._client}createConversation=(e=>this._client.createConversation(e));getConversation=(e=>this._client.getConversation(e));listConversations=(e=>this._client.listConversations(e));getOrCreateConversation=(e=>this._client.getOrCreateConversation(e));updateConversation=(e=>this._client.updateConversation(e));deleteConversation=(e=>this._client.deleteConversation(e));listParticipants=(e=>this._client.listParticipants(e));addParticipant=(e=>this._client.addParticipant(e));getParticipant=(e=>this._client.getParticipant(e));removeParticipant=(e=>this._client.removeParticipant(e));createEvent=(e=>this._client.createEvent(e));getEvent=(e=>this._client.getEvent(e));listEvents=(e=>this._client.listEvents(e));createMessage=(e=>this._client.createMessage(e));getOrCreateMessage=(e=>this._client.getOrCreateMessage(e));getMessage=(e=>this._client.getMessage(e).then(r=>r));updateMessage=(e=>this._client.updateMessage(e).then(r=>r));listMessages=(e=>this._client.listMessages(e));deleteMessage=(e=>this._client.deleteMessage(e));createUser=(e=>this._client.createUser(e));getUser=(e=>this._client.getUser(e));listUsers=e=>this._client.listUsers(e);getOrCreateUser=(e=>this._client.getOrCreateUser(e));updateUser=(e=>this._client.updateUser(e));deleteUser=e=>this._client.deleteUser(e);getState=(e=>this._client.getState(e));setState=(e=>this._client.setState(e));getOrSetState=(e=>this._client.getOrSetState(e));patchState=(e=>this._client.patchState(e));configureIntegration=e=>this._client.configureIntegration(e);uploadFile=e=>this._client.uploadFile(e);upsertFile=e=>this._client.upsertFile(e);deleteFile=e=>this._client.deleteFile(e);listFiles=e=>this._client.listFiles(e);getFile=e=>this._client.getFile(e);updateFileMetadata=e=>this._client.updateFileMetadata(e);trackAnalytics=e=>this._client.trackAnalytics(e)};var _n=class{_cost=0;get cost(){return this._cost}setCost(e){this._cost=e}toJSON(){return{cost:this.cost}}};var Pe="#";var Lv=y.enum(["webhook_received","message_created","action_triggered","register","unregister","ping","create_user","create_conversation"]),Gu=t=>{let e=t[Wt],r=t[Rs],n=t[Hs],s=t[Ds],i=t[Ms],o=t[qt],l=t[Vt];if(!e)throw new Error("Missing bot headers");if(!r)throw new Error("Missing bot user headers");if(!n)throw new Error("Missing integration headers");if(!s)throw new Error("Missing webhook headers");if(!o)throw new Error("Missing configuration headers");if(!l)throw new Error("Missing operation headers");return{botId:e,botUserId:r,integrationId:n,webhookId:s,operation:l,configurationType:i??null,configuration:o?JSON.parse(Buffer.from(o,"base64").toString("utf-8")):{}}};var Ju=Ws(require("util")),ft=class{defaultOptions;constructor(e){this.defaultOptions=e}info(...e){this._log("info",e)}debug(...e){this._log("debug",e)}warn(...e){this._log("warn",e)}error(...e){this._log("error",e)}_log(e,r){this._getConsoleMethod(e)(this._serializeMessage(r))}_serializeMessage(e){let r=Ju.default.format(...e);return process.env.BP_LOG_FORMAT==="json"?this.getJsonMessage(r):r}getJsonMessage(e){return JSON.stringify({msg:e,options:this.defaultOptions})}_getConsoleMethod(e){switch(e){case"debug":return console.debug;case"warn":return console.warn;case"error":return console.error;default:return console.info}}};var gt=class t extends ft{constructor(e){super({visibleToBotOwners:!0,...e})}with(e){return new t({...this.defaultOptions,...e})}withUserId(e){return this.with({userId:e})}withConversationId(e){return this.with({conversationId:e})}withVisibleToBotOwners(e){return this.with({visibleToBotOwners:e})}forBot(){return this.withVisibleToBotOwners(!0)}getJsonMessage(e){return JSON.stringify({msg:e,visible_to_bot_owner:this.defaultOptions.visibleToBotOwners,options:this.defaultOptions})}};var ky=t=>["traceparent","tracestate","sentry-trace"].reduce((e,r)=>(t[r]&&(e[r]=t[r]),e),{}),Sy=(t,e,r)=>{let[,n]=(e.headers.traceparent||"").split("-"),s=new ve.Client({botId:t.botId,integrationId:t.integrationId,retry:vn,headers:ky(e.headers)}),i=new pt(s),o=new gt({traceId:n});return{ctx:t,req:e,client:i,logger:o,instance:r}},Oy=async t=>{let{ctx:e}=t;switch(e.operation){case"webhook_received":return await Zy(t);case"register":return await Iy(t);case"unregister":return await By(t);case"message_created":return await Ry(t);case"action_triggered":return await Hy(t);case"ping":return await Ey(t);case"create_user":return await Cy(t);case"create_conversation":return await Ay(t);default:throw new ve.InvalidPayloadError(`Unknown operation ${e.operation}`)}},Xu=t=>async e=>{let r=Gu(e.headers),n=Sy(r,e,t),{logger:s}=n;try{let i;return i=await Dy(n),i?{...i,status:i.status??200}:(i=await Oy(n),i?{...i,status:i.status??200}:{status:200})}catch(i){if((0,ve.isApiError)(i)){let l=i.type==="Runtime"?i:new ve.RuntimeError(i.message,i);return s.forBot().error(l.message),{status:l.code,body:JSON.stringify(l.toJSON())}}console.error(i);let o=new ve.RuntimeError("An unexpected error occurred in the integration. Bot owners: Check logs for more informations. Integration owners: throw a RuntimeError to return a custom error message instead.");return s.forBot().error(o.message),{status:o.code,body:JSON.stringify(o.toJSON())}}},Ey=async t=>{},Zy=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{let{req:i}=oe(r);return s.webhook({client:t,ctx:e,req:i,logger:n})},Iy=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.register)return;let{webhookUrl:i}=oe(r);await s.register({client:t,ctx:e,webhookUrl:i,logger:n})},By=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.unregister)return;let{webhookUrl:i}=oe(r);await s.unregister({ctx:e,webhookUrl:i,client:t,logger:n})},Cy=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.createUser)return;let{tags:i}=oe(r);return await s.createUser({ctx:e,client:t,tags:i,logger:n})},Ay=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.createConversation)return;let{channel:i,tags:o}=oe(r);return await s.createConversation({ctx:e,client:t,channel:i,tags:o,logger:n})},Ry=async({ctx:t,req:e,client:r,logger:n,instance:s})=>{let{conversation:i,user:o,type:l,payload:u,message:f}=oe(e),g=s.channels[i.channel];if(!g)throw new Error(`Channel ${i.channel} not found`);let m=g.messages[l];if(!m)throw new Error(`Message of type ${l} not found in channel ${i.channel}`);await m({ctx:t,conversation:i,message:f,user:o,type:l,client:r,payload:u,ack:async({tags:E})=>{await r.updateMessage({id:f.id,tags:E})},logger:n})},Hy=async({req:t,ctx:e,client:r,logger:n,instance:s})=>{let{input:i,type:o}=oe(t);if(!o)throw new Error("Missing action type");let l=s.actions[o];if(!l)throw new Error(`Action ${o} not found`);let u=new _n,g={output:await l({ctx:e,input:i,client:r,type:o,logger:n,metadata:u}),meta:u.toJSON()};return{body:JSON.stringify(g)}},Dy=async({instance:t,client:e,ctx:r,logger:n,req:s})=>{let i=t.unknownOperationHandler;if(i)return await i({client:e,ctx:r,logger:n,req:s})};var Tn=class{constructor(e){this.props=e;this.actions=e.actions,this.channels=e.channels,this.register=e.register,this.unregister=e.unregister,this.createUser=e.createUser,this.createConversation=e.createConversation,this.webhook=e.handler,this.unknownOperationHandler=e.__advanced?.unknownOperationHandler}actions;channels;register;unregister;createUser;createConversation;webhook;unknownOperationHandler;handler=Xu(this);start=e=>Gt(this.handler,e)};var bn=class{constructor(e){this.props=e;this.integrations=e.integrations,this.plugins=e.plugins,this.user=e.user,this.conversation=e.conversation,this.message=e.message,this.states=e.states,this.configuration=e.configuration,this.events=e.events,this.recurringEvents=e.recurringEvents,this.actions=e.actions,this.tables=e.tables,this.workflows=e.workflows,this.attributes=e.attributes,this.withPlugins={user:e.user,conversation:e.conversation,message:e.message,states:e.states,events:e.events,recurringEvents:e.recurringEvents,actions:e.actions,tables:e.tables,workflows:e.workflows}}integrations;plugins;user;conversation;message;states;configuration;events;recurringEvents;actions;tables;workflows;attributes;withPlugins;addIntegration(e,r){let n=this;return n.integrations||(n.integrations={}),n.integrations[e.name]={...e,enabled:r?.enabled,configurationType:r?.configurationType,configuration:r?.configuration,disabledChannels:r?.disabledChannels},this}addPlugin(e,r){let n=this;n.plugins||(n.plugins={});let s=r.alias??e.name.replace("/","-");return n.plugins[s]={...e,alias:s,configuration:r.configuration,interfaces:r.interfaces},n.withPlugins.user=this._mergeUser(n.withPlugins.user,e.definition.user),n.withPlugins.conversation=this._mergeConversation(n.withPlugins.conversation,e.definition.conversation),n.withPlugins.message=this._mergeMessage(n.withPlugins.message,e.definition.message),n.withPlugins.recurringEvents=this._mergeRecurringEvents(n.withPlugins.recurringEvents,e.definition.recurringEvents),n.withPlugins.tables=this._mergeTables(n.withPlugins.tables,e.definition.tables),n.withPlugins.workflows=this._mergeWorkflows(n.withPlugins.workflows,e.definition.workflows),n.withPlugins.states=this._mergeStates(n.withPlugins.states,this._prefixKeysWithPluginAlias(e.definition.states,s)),n.withPlugins.events=this._mergeEvents(n.withPlugins.events,this._prefixKeysWithPluginAlias(e.definition.events,s)),n.withPlugins.actions=this._mergeActions(n.withPlugins.actions,this._prefixKeysWithPluginAlias(e.definition.actions,s)),this}_mergeUser=(e,r)=>({tags:{...e?.tags,...r?.tags}});_mergeConversation=(e,r)=>({tags:{...e?.tags,...r?.tags}});_mergeMessage=(e,r)=>({tags:{...e?.tags,...r?.tags}});_mergeStates=(e,r)=>({...e,...r});_mergeEvents=(e,r)=>({...e,...r});_mergeRecurringEvents=(e,r)=>({...e,...r});_mergeActions=(e,r)=>({...e,...r});_mergeTables=(e,r)=>({...e,...r});_mergeWorkflows=(e,r)=>({...e,...r});_prefixKeysWithPluginAlias=(e,r)=>M.mapKeys(e??{},n=>`${r}${Pe}${n}`);dereferencePluginEntities(){let e=this._buildZuiReferenceMap();return{...this,withPlugins:{...this.withPlugins,events:this._dereferenceDefinitionSchemas(this.withPlugins.events,e),states:this._dereferenceDefinitionSchemas(this.withPlugins.states,e),tables:this._dereferenceDefinitionSchemas(this.withPlugins.tables,e),actions:this._dereferenceActionDefinitionSchemas(this.withPlugins.actions,e)},plugins:Object.fromEntries(Object.entries(this.plugins??{}).map(([r,n])=>[r,{...n,definition:{...n.definition,configuration:this._dereferenceDefinitionSchema(n.definition.configuration,e),events:this._dereferenceDefinitionSchemas(n.definition.events,e),states:this._dereferenceDefinitionSchemas(n.definition.states,e),tables:this._dereferenceDefinitionSchemas(n.definition.tables,e),actions:this._dereferenceActionDefinitionSchemas(n.definition.actions,e)}}]))}}_buildZuiReferenceMap(){let e={},r=Object.entries(this.plugins??{});for(let[n,s]of r){let i=Object.entries(s.interfaces??{});for(let[o,l]of i){let u=this.integrations?.[l.name];if(!u)throw new Error(`Interface with alias "${o}" of plugin with alias "${n}" references integration "${l.name}" which is not installed`);let f=Object.entries(l.entities??{});for(let[g,{name:m}]of f){let P=u.definition.entities?.[m]?.schema;if(!P)throw new Error(`Interface entity "${m}" does not exist in integration "${u.name}"`);e[`interface:${o}/entities/${g}`]=P}}}return e}_dereferenceZuiSchema(e,r){return e.dereference(r)}_dereferenceDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,this._dereferenceDefinitionSchema(s,r)]))}_dereferenceDefinitionSchema(e,r){return e&&{...e,schema:this._dereferenceZuiSchema(e.schema,r)}}_dereferenceActionDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,{...s,input:{schema:this._dereferenceZuiSchema(s.input.schema,r)},output:{schema:this._dereferenceZuiSchema(s.output.schema,r)}}]))}};var Ve=require("@botpress/client");var ht=class t extends ft{constructor(e){super({...e})}with(e){return new t({...this.defaultOptions,...e})}withUserId(e){return this.with({userId:e})}withConversationId(e){return this.with({conversationId:e})}withWorkflowId(e){return this.with({workflowId:e})}withEventId(e){return this.with({eventId:e})}withMessageId(e){return this.with({messageId:e})}};var ce=class{constructor(e,r={before:{},after:{}}){this._client=e;this._hooks=r}get _inner(){return this._client}getConversation=(e=>this._run("getConversation",e));listConversations=(e=>this._run("listConversations",e));updateConversation=(e=>this._run("updateConversation",e));deleteConversation=(e=>this._run("deleteConversation",e));listParticipants=(e=>this._run("listParticipants",e));addParticipant=(e=>this._run("addParticipant",e));getParticipant=(e=>this._run("getParticipant",e));removeParticipant=(e=>this._run("removeParticipant",e));createEvent=(e=>this._run("createEvent",e));getEvent=(e=>this._run("getEvent",e));listEvents=(e=>this._run("listEvents",e));createMessage=(e=>this._run("createMessage",e));getOrCreateMessage=(e=>this._run("getOrCreateMessage",e));getMessage=(e=>this._run("getMessage",e));updateMessage=(e=>this._run("updateMessage",e));listMessages=(e=>this._run("listMessages",e));deleteMessage=(e=>this._run("deleteMessage",e));getUser=(e=>this._run("getUser",e));listUsers=(e=>this._run("listUsers",e));updateUser=(e=>this._run("updateUser",e));deleteUser=(e=>this._run("deleteUser",e));getState=(e=>this._run("getState",e));setState=(e=>this._run("setState",e));getOrSetState=(e=>this._run("getOrSetState",e));patchState=(e=>this._run("patchState",e));callAction=(e=>this._run("callAction",e));uploadFile=(e=>this._run("uploadFile",e));upsertFile=(e=>this._run("upsertFile",e));deleteFile=(e=>this._run("deleteFile",e));listFiles=(e=>this._run("listFiles",e));getFile=(e=>this._run("getFile",e));updateFileMetadata=(e=>this._run("updateFileMetadata",e));searchFiles=(e=>this._run("searchFiles",e));trackAnalytics=(e=>this._run("trackAnalytics",e));getTableRow=(e=>this._run("getTableRow",e));createTableRows=(e=>this._run("createTableRows",e));findTableRows=(e=>this._run("findTableRows",e));deleteTableRows=(e=>this._run("deleteTableRows",e));updateTableRows=(e=>this._run("updateTableRows",e));upsertTableRows=(e=>this._run("upsertTableRows",e));createWorkflow=(e=>this._run("createWorkflow",e));getWorkflow=(e=>this._run("getWorkflow",e));updateWorkflow=(e=>this._run("updateWorkflow",e));deleteWorkflow=(e=>this._run("deleteWorkflow",e));listWorkflows=(e=>this._run("listWorkflows",e));createConversation=e=>this._client.createConversation(e);getOrCreateConversation=e=>this._client.getOrCreateConversation(e);createUser=e=>this._client.createUser(e);getOrCreateUser=e=>this._client.getOrCreateUser(e);_run=async(e,r)=>{let n=this._hooks.before[e];n&&(r=await n(r));let s=await this._client[e](r),i=this._hooks.after[e];return i&&(s=await i(s,r)),s}};var mt=t=>new Proxy({},{get:(e,r)=>({listInstances:{all:n=>xe({workflowName:r,client:t,input:n}),running:n=>xe({workflowName:r,client:t,input:n,statuses:["in_progress"]}),scheduled:n=>xe({workflowName:r,client:t,input:n,statuses:["pending","listening"]}),allFinished:n=>xe({workflowName:r,client:t,input:n,statuses:["completed","cancelled","failed","timedout"]}),cancelled:n=>xe({workflowName:r,client:t,input:n,statuses:["cancelled"]}),failed:n=>xe({workflowName:r,client:t,input:n,statuses:["failed"]}),succeeded:n=>xe({workflowName:r,client:t,input:n,statuses:["completed"]}),timedOut:n=>xe({workflowName:r,client:t,input:n,statuses:["timedout"]})},startNewInstance:async n=>{let{workflow:s}=await t.createWorkflow({name:r,status:"pending",...n});return{workflow:ke({client:t,workflow:s})}}})}),xe=async t=>{let e=await t.client.listWorkflows({name:t.workflowName,statuses:t.statuses,...t.input});return{...e,workflows:e.workflows.map(r=>ke({client:t.client,workflow:r}))}},ke=t=>{let e=!1;return{...t.workflow,async update(r){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,...r});return{workflow:ke({client:t.client,workflow:n})}},async acknowledgeStartOfProcessing(){!t.event||t.workflow.status!=="pending"||e||(await t.client.updateWorkflow({id:t.workflow.id,status:"in_progress",eventId:t.event.id}),e=!0)},async setFailed({failureReason:r}){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,status:"failed",failureReason:r});return{workflow:ke({client:t.client,workflow:n})}},async setCompleted({output:r}={}){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,status:"completed",output:r});return{workflow:ke({client:t.client,workflow:n})}},async cancel(){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,status:"cancelled"});return{workflow:ke({client:t.client,workflow:r})}}}};var My=y.enum(["event_received","register","unregister","ping","action_triggered"]),Yu=t=>{let e=t[Wt],r=t[qt],n=t[Ns],s=My.parse(t[Vt]);if(!e)throw new Error("Missing bot headers");if(!n)throw new Error("Missing type headers");if(!r)throw new Error("Missing configuration headers");if(!s)throw new Error("Missing operation headers");return{botId:e,operation:s,type:n,configuration:r?JSON.parse(Buffer.from(r,"base64").toString("utf-8")):{}}};var Y={status:200};var Ks=t=>{switch(t){case"workflow_continued":return"continued";case"workflow_started":return"started";case"workflow_timedout":return"timed_out";default:throw new Error(`Unsupported workflow update type: ${t}`)}};var Ny=["child_workflow_deleted","child_workflow_finished","workflow_timedout","workflow_started","workflow_continued"],Qu=async(t,e)=>{if(t.ctx.type!=="workflow_update"||!Ny.includes(e.payload.type))throw new Error("Unexpected event type");let r={...t,logger:$y(t,e)};if(!e.payload.workflow.name)return r.logger.warn("Received workflow update event without a workflow name. Assuming this workflow was not defined by the bot.",e.payload.workflow),Y;switch(e.payload.type){case"child_workflow_deleted":case"child_workflow_finished":r.logger.info(`Received child workflow event "${e.payload.type}", but child workflows are not yet supported`);break;case"workflow_timedout":case"workflow_started":case"workflow_continued":return await jy(r,e);default:e.payload.type}return Y},$y=(t,e)=>t.logger.with({eventId:e.id,workflowId:e.payload.workflow.id,conversationId:e.payload.conversation?.id,userId:e.payload.user?.id}),jy=async(t,e)=>{let r=Ks(e.payload.type),n=t.self.workflowHandlers[r]?.[e.payload.workflow.name];return!n||n.length===0?(t.logger.warn(`No ${r} handler found for workflow "${e.payload.workflow.name}"`),Y):(await Ky(t,e),e.payload.workflow.status==="pending"&&t.logger.warn(`Workflow "${e.payload.workflow.name}" is still in pending status after processing "${r}" event. This may indicate that the workflow was not properly acknowledged or terminated by the handler. `),Y)},Ky=async(t,e)=>{let r=Ks(e.payload.type),n=t.self.workflowHandlers[r]?.[e.payload.workflow.name];for(let s of n)await s({...t,event:e,conversation:e.payload.conversation,user:e.payload.user,workflow:ke({...t,workflow:e.payload.workflow,event:e}),workflows:mt(t.client)})};var ed=t=>async e=>{let r=Yu(e.headers),n=new ht,s=new Ve.Client({botId:r.botId,retry:vn}),i=new ce(s,{before:{createMessage:async l=>{let u=t.hookHandlers.before_outgoing_message[l.type]??[];for(let f of u){let g=new ce(s);l=(await f({client:g,ctx:r,logger:n.with({conversationId:l.conversationId,userId:l.userId}),data:l,...Se({client:g})}))?.data??l}return l},callAction:async l=>{let u=t.hookHandlers.before_outgoing_call_action[l.type]??[];for(let f of u){let g=new ce(s);l=(await f({client:g,ctx:r,logger:n,data:l,...Se({client:g})}))?.data??l}return l}},after:{createMessage:async l=>{let u=t.hookHandlers.after_outgoing_message[l.message.type]??[];for(let f of u){let g=new ce(s);l=(await f({client:g,ctx:r,logger:n.with({messageId:l.message.id,conversationId:l.message.conversationId,userId:l.message.userId}),data:l,...Se({client:g})}))?.data??l}return l},callAction:async(l,u)=>{let{type:f}=u,g=t.hookHandlers.after_outgoing_call_action[f]??[];for(let m of g){let P=new ce(s);l=(await m({client:P,ctx:r,logger:n,data:{type:f,...l},...Se({client:P})}))?.data??l}return l}}}),o={req:e,ctx:r,logger:n,client:i,self:t};try{switch(r.operation){case"action_triggered":return await Wy(o);case"event_received":return await Ly(o);case"register":return await zy(o);case"unregister":return await Fy(o);case"ping":return await Uy(o);default:throw new Error(`Unknown operation ${r.operation}`)}}catch(l){let u=l instanceof Error?l:new Error(String(l));if((0,Ve.isApiError)(u)){let g=u.type==="Runtime"?u:new Ve.RuntimeError(u.message,u);return n.error(g.message),{status:g.code,body:JSON.stringify(g.toJSON())}}let f=new Ve.RuntimeError("An unexpected error occurred in the bot.",u);return n.error(f.message,u),{status:f.code,body:JSON.stringify(f.toJSON())}}},Uy=async t=>Y,zy=async t=>Y,Fy=async t=>Y,Ly=async t=>{let{ctx:e,logger:r,req:n,client:s,self:i}=t,o={client:s,ctx:e,logger:r,...Se({client:s})},l=oe(n);if(o.logger=o.logger.with({eventId:l.event.id,messageId:l.event.messageId,conversationId:l.event.conversationId,userId:l.event.userId}),e.type==="workflow_update")return await Qu(t,l.event);if(e.type==="message_created"){let E=l.event,I=E.payload.message;o.logger=o.logger.with({messageId:I.id,conversationId:I.conversationId,userId:I.userId});let U=i.hookHandlers.before_incoming_message[I.type]??[];for(let q of U){let se=await q({...o,data:I});if(I=se?.data??I,se?.stop)return Y}let W={...o,user:E.payload.user,conversation:E.payload.conversation,message:I,event:E},Q=i.messageHandlers[I.type]??[];for(let q of Q)await q(W);let ie=i.hookHandlers.after_incoming_message[I.type]??[];for(let q of ie){let se=await q({...o,data:I});if(I=se?.data??I,se?.stop)return Y}return Y}if(e.type==="state_expired"){let I=l.event.payload.state,U={...o,state:I},W=i.stateExpiredHandlers[I.name]??[];for(let Q of W)await Q(U);return Y}let u=l.event,f=i.hookHandlers.before_incoming_event[u.type]??[];for(let E of f){let I=await E({...o,data:u});if(u=I?.data??u,I?.stop)return Y}let g={...o,event:u},m=i.eventHandlers[u.type]??[];for(let E of m)await E(g);let P=i.hookHandlers.after_incoming_event[u.type]??[];for(let E of P){let I=await E({...o,data:u});if(u=I?.data??u,I?.stop)return Y}return Y},Wy=async({ctx:t,logger:e,req:r,client:n,self:s})=>{let{input:i,type:o}=oe(r);if(!o)throw new Error("Missing action type");let l=s.hookHandlers.before_incoming_call_action[o]??[];for(let P of l){let E=await P({ctx:t,logger:e,client:n,data:{type:o,input:i},...Se({client:n})});i=E?.data?.input??i,o=E?.data?.type??o}let u=s.actionHandlers[o];if(!u)throw new Error(`Action ${o} not found`);let f=await u({ctx:t,logger:e,input:i,client:n,type:o,...Se({client:n})}),g=s.hookHandlers.after_incoming_call_action[o]??[];for(let P of g){let E=await P({ctx:t,logger:e,client:n,data:{type:o,output:f},...Se({client:n})});o=E?.data?.type??o,f=E?.data?.output??f}return{status:200,body:JSON.stringify({output:f})}},Se=t=>({workflows:mt(t.client)});var wn=class{constructor(e){this.props=e;this._actionHandlers=e.actions,this._plugins=e.plugins}_actionHandlers;_messageHandlers={};_eventHandlers={};_stateExpiredHandlers={};_hookHandlers={before_incoming_event:{},before_incoming_message:{},before_outgoing_message:{},before_outgoing_call_action:{},before_incoming_call_action:{},after_incoming_event:{},after_incoming_message:{},after_outgoing_message:{},after_outgoing_call_action:{},after_incoming_call_action:{}};_workflowHandlers={started:{},continued:{},timed_out:{}};_plugins={};_registerOrder=0;get actionHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._actionHandlers[r];if(n)return n;for(let[s,i]of Object.entries(this._plugins)){let[o,l]=r.split(Pe);if(!(o!==s||!l)&&(n=i.actionHandlers[l],n))return n}}})}get messageHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.messageHandlers[r]??[]),s=this._messageHandlers[r]??[],i=this._messageHandlers["*"]??[],o=[...s,...i].sort((l,u)=>l.order-u.order).map(({handler:l})=>l);return S.unique([...n,...o])}})}get eventHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.eventHandlers[r]??[]),s=this._eventHandlers[r]??[],i=this._eventHandlers["*"]??[],o=[...s,...i].sort((l,u)=>l.order-u.order).map(({handler:l})=>l);return S.unique([...n,...o])}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.stateExpiredHandlers[r]??[]),s=this._stateExpiredHandlers[r]??[],i=this._stateExpiredHandlers["*"]??[],o=[...s,...i].sort((l,u)=>l.order-u.order).map(({handler:l})=>l);return S.unique([...n,...o])}})}get hookHandlers(){return new Proxy({},{get:(e,r)=>{if(this._hookHandlers[r])return new Proxy({},{get:(s,i)=>{let o=Object.values(this._plugins).flatMap(m=>m.hookHandlers[r]?.[i]??[]),l=this._hookHandlers[r]??{},u=l[i]??[],f=l["*"]??[],g=[...u,...f].sort((m,P)=>m.order-P.order).map(({handler:m})=>m);return S.unique([...o,...g])}})}})}get workflowHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._workflowHandlers[r];if(n)return new Proxy({},{get:(s,i)=>{let o=n[i]?.sort((u,f)=>u.order-f.order).map(({handler:u})=>u)??[],l=Object.values(this._plugins).flatMap(u=>u.workflowHandlers[r]?.[i]??[]);return S.unique([...o,...l])}})}})}on={message:(e,r)=>{this._messageHandlers[e]=S.safePush(this._messageHandlers[e],{handler:r,order:this._registerOrder++})},event:(e,r)=>{this._eventHandlers[e]=S.safePush(this._eventHandlers[e],{handler:r,order:this._registerOrder++})},stateExpired:(e,r)=>{this._stateExpiredHandlers[e]=S.safePush(this._stateExpiredHandlers[e],{handler:r,order:this._registerOrder++})},beforeIncomingEvent:(e,r)=>{this._hookHandlers.before_incoming_event[e]=S.safePush(this._hookHandlers.before_incoming_event[e],{handler:r,order:this._registerOrder++})},beforeIncomingMessage:(e,r)=>{this._hookHandlers.before_incoming_message[e]=S.safePush(this._hookHandlers.before_incoming_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingMessage:(e,r)=>{this._hookHandlers.before_outgoing_message[e]=S.safePush(this._hookHandlers.before_outgoing_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingCallAction:(e,r)=>{this._hookHandlers.before_outgoing_call_action[e]=S.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},beforeIncomingCallAction:(e,r)=>{this._hookHandlers.before_incoming_call_action[e]=S.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingEvent:(e,r)=>{this._hookHandlers.after_incoming_event[e]=S.safePush(this._hookHandlers.after_incoming_event[e],{handler:r,order:this._registerOrder++})},afterIncomingMessage:(e,r)=>{this._hookHandlers.after_incoming_message[e]=S.safePush(this._hookHandlers.after_incoming_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingMessage:(e,r)=>{this._hookHandlers.after_outgoing_message[e]=S.safePush(this._hookHandlers.after_outgoing_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingCallAction:(e,r)=>{this._hookHandlers.after_outgoing_call_action[e]=S.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingCallAction:(e,r)=>{this._hookHandlers.after_incoming_call_action[e]=S.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:r,order:this._registerOrder++})},workflowStart:(e,r)=>{this._workflowHandlers.started[e]=S.safePush(this._workflowHandlers.started[e],{handler:r,order:this._registerOrder++})},workflowContinue:(e,r)=>{this._workflowHandlers.continued[e]=S.safePush(this._workflowHandlers.continued[e],{handler:r,order:this._registerOrder++})},workflowTimeout:(e,r)=>{this._workflowHandlers.timed_out[e]=S.safePush(this._workflowHandlers.timed_out[e],{handler:r,order:this._registerOrder++})}};handler=ed(this);start=e=>Gt(this.handler,e)};var Pn=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.title=e.title,this.description=e.description,this.readme=e.readme,this.entities=e.entities??{},this.attributes=e.attributes;let r=this._getEntityReference(this.entities),n=e.events===void 0?{}:M.mapValues(e.events,o=>({...o,schema:o.schema(r)})),s=e.actions===void 0?{}:M.mapValues(e.actions,o=>({...o,input:{...o.input,schema:o.input.schema(r)},output:{...o.output,schema:o.output.schema(r)}})),i=e.channels===void 0?{}:M.mapValues(e.channels,o=>({...o,messages:M.mapValues(o.messages,l=>({...l,schema:l.schema(r)}))}));this.events=n,this.actions=s,this.channels=i}name;version;title;description;icon;readme;attributes;entities;events;actions;channels;_getEntityReference=e=>{let r={};for(let[n,s]of Object.entries(e)){let i=s.schema._def["x-zui"]?.title,o=s.schema._def.description,l=Au.ref(n);i&&l.title(i),o&&l.describe(o),r[n]=l}return r}};var xn=class{constructor(e){this.props=e;let r=Object.fromEntries(Object.entries(e.interfaces??{}).map(([n,s])=>[n,Object.fromEntries(Object.entries(s.definition.entities??{}).map(([i])=>[i,y.ref(`interface:${n}/entities/${i}`)]))]));this.name=e.name,this.version=e.version,this.icon=e.icon,this.readme=e.readme,this.title=e.title,this.description=e.description,this.integrations=e.integrations,this.interfaces=e.interfaces,this.user=e.user,this.conversation=e.conversation,this.message=e.message,this.recurringEvents=e.recurringEvents,this.workflows=e.workflows,this.attributes=e.attributes,this.configuration=e.configuration?{...e.configuration,schema:typeof e.configuration.schema=="object"?e.configuration.schema:e.configuration.schema({entities:r})}:void 0,this.states=Object.fromEntries(Object.entries(e.states??{}).map(([n,s])=>[n,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:r})}])),this.events=Object.fromEntries(Object.entries(e.events??{}).map(([n,s])=>[n,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:r})}])),this.actions=Object.fromEntries(Object.entries(e.actions??{}).map(([n,s])=>[n,{...s,input:{...s.input,schema:typeof s.input.schema=="object"?s.input.schema:s.input.schema({entities:r})},output:{...s.output,schema:typeof s.output.schema=="object"?s.output.schema:s.output.schema({entities:r})}}])),this.tables=Object.fromEntries(Object.entries(e.tables??{}).map(([n,s])=>[n,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:r})}]))}name;version;title;description;icon;readme;attributes;integrations;interfaces;user;conversation;message;states;configuration;events;recurringEvents;actions;tables;workflows;dereferenceEntities({intersectWithUnknownRecord:e}={intersectWithUnknownRecord:!0}){let r=this._buildZuiReferenceMap(e);return{...this,configuration:this.configuration?{...this.configuration,schema:this._dereferenceZuiSchema(this.configuration.schema,r)}:void 0,events:this._dereferenceDefinitionSchemas(this.events,r),states:this._dereferenceDefinitionSchemas(this.states,r),tables:this._dereferenceDefinitionSchemas(this.tables,r),actions:this._dereferenceActionDefinitionSchemas(this.actions,r)}}_buildZuiReferenceMap(e){return Object.fromEntries(Object.entries(this.interfaces??{}).flatMap(([r,n])=>Object.entries(n.definition.entities??{}).map(([s,i])=>[`interface:${r}/entities/${s}`,e?i.schema.and(y.record(y.string(),y.unknown())):i.schema])))}_dereferenceZuiSchema(e,r){return e.dereference(r)}_dereferenceDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,{...s,schema:this._dereferenceZuiSchema(s.schema,r)}]))}_dereferenceActionDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,{...s,input:{schema:this._dereferenceZuiSchema(s.input.schema,r)},output:{schema:this._dereferenceZuiSchema(s.output.schema,r)}}]))}};var Us=":";var td=t=>{let[e,r]=t.split(Us);return!e||!r?null:{namespace:e,eventName:r}},rd=t=>`${t.namespace}${Us}${t.actionName}`,nd=t=>`${t.namespace}${Us}${t.eventName}`,sd=(t,e)=>{let r=e[t.namespace]??{name:t.namespace,version:"0.0.0",entities:{},actions:{},events:{},channels:{}},n=r.name,s=r.actions[t.actionName]?.name??t.actionName;return{namespace:n,actionName:s}},id=(t,e)=>{let r=e[t.namespace]??{name:t.namespace,version:"0.0.0",entities:{},actions:{},events:{},channels:{}},n=r.name,s=r.events[t.eventName]?.name??t.eventName;return{namespace:n,eventName:s}};var ad=(t,e)=>new Proxy({},{get:(r,n)=>new Proxy({},{get:(s,i)=>o=>qy({client:t,interfaces:e.interfaces,integrationOrInterfaceName:n,methodName:i,input:o})})}),qy=async({client:t,interfaces:e,integrationOrInterfaceName:r,methodName:n,input:s})=>{let i=sd({namespace:r,actionName:n},e),o=rd(i);return(await t.callAction({type:o,input:s})).output};var zs=class t{constructor(e){this._props=e}async emit(e){let{conversationId:r,userId:n,messageId:s}=this._props;await this._props.client.createEvent({type:this._props.eventName,payload:e,conversationId:r,userId:n,messageId:s})}async schedule(e,r){let{conversationId:n,userId:s,messageId:i}=this._props;await this._props.client.createEvent({type:this._props.eventName,payload:e,conversationId:n,userId:s,messageId:i,schedule:r})}withConversationId(e){return new t({...this._props,conversationId:e})}withUserId(e){return new t({...this._props,userId:e})}withMessageId(e){return new t({...this._props,messageId:e})}},od=(t,e)=>new Proxy({},{get:(r,n)=>{let s=e.alias!==void 0?`${e.alias}${Pe}${n}`:n;return new zs({client:t,eventName:s})}});var Fs=class{constructor(e,r,n){this._client=e;this._stateType=r;this._stateName=n}async get(e){return await this._client.getState({type:this._stateType,name:this._stateName,id:e}).then(r=>r.state.payload)}async set(e,r){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:r})}async getOrSet(e,r){return await this._client.getOrSetState({type:this._stateType,name:this._stateName,id:e,payload:r}).then(n=>n.state.payload)}async delete(e){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:null})}async patch(e,r){await this._client.patchState({type:this._stateType,name:this._stateName,id:e,payload:r})}},ld=(t,e)=>new Proxy({},{get:(r,n)=>new Proxy({},{get:(s,i)=>{let o=e.alias!==void 0?`${e.alias}${Pe}${i}`:i;return new Fs(t,n,o)}})});var kn=class{constructor(e){this.props=e;this._actionHandlers=e.actions}_runtimeProps;_actionHandlers;_messageHandlers={};_eventHandlers={};_stateExpiredHandlers={};_hookHandlers={before_incoming_event:{},before_incoming_message:{},before_outgoing_message:{},before_outgoing_call_action:{},before_incoming_call_action:{},after_incoming_event:{},after_incoming_message:{},after_outgoing_message:{},after_outgoing_call_action:{},after_incoming_call_action:{}};_workflowHandlers={started:{},continued:{},timed_out:{}};_registerOrder=0;initialize(e){return this._runtimeProps=e,this}get _runtime(){if(!this._runtimeProps)throw new Error("Plugin not correctly initialized. This is likely because you access your plugin config outside of an handler.");return this._runtimeProps}_getTools(e){let{configuration:r,interfaces:n,alias:s}=this._runtime,i=ad(e,this._runtime),o=ld(e,this._runtime),l=mt(e),u=od(e,this._runtime);return{configuration:r,interfaces:n,actions:i,states:o,alias:s,workflows:l,events:u}}get actionHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._actionHandlers[r];if(n)return ye.setName(s=>n({...s,...this._getTools(s.client)}),n.name)}})}get messageHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._messageHandlers[r]??[],s=this._messageHandlers["*"]??[];return S.unique([...n,...s]).sort((o,l)=>o.order-l.order).map(({handler:o})=>ye.setName(l=>o({...l,...this._getTools(l.client)}),o.name))}})}get eventHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._eventHandlers[r]??[],s=Object.entries(this._eventHandlers).filter(([l])=>this._eventResolvesTo(l,r)).flatMap(([,l])=>l??[]),i=this._eventHandlers["*"]??[];return S.unique([...n,...s,...i]).sort((l,u)=>l.order-u.order).map(({handler:l})=>ye.setName(u=>l({...u,...this._getTools(u.client)}),l.name))}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._stateExpiredHandlers[r]??[],s=this._stateExpiredHandlers["*"]??[];return S.unique([...n,...s]).sort((o,l)=>o.order-l.order).map(({handler:o})=>ye.setName(l=>o({...l,...this._getTools(l.client)}),o.name))}})}get hookHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._hookHandlers[r];if(n)return new Proxy({},{get:(s,i)=>{i=this._stripAliasPrefix(i);let o=n[i]??[],l=Object.entries(n).filter(([g])=>this._eventResolvesTo(g,i)).flatMap(([,g])=>g??[]),u=n["*"]??[];return S.unique([...o,...l,...u]).sort((g,m)=>g.order-m.order).map(({handler:g})=>ye.setName(m=>g({...m,...this._getTools(m.client)}),g.name))}})}})}get workflowHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._workflowHandlers[r];if(n)return new Proxy({},{get:(s,i)=>(n[i]?.sort((l,u)=>l.order-u.order)??[]).map(({handler:l})=>ye.setName(u=>l({...u,...this._getTools(u.client)}),l.name))})}})}on={message:(e,r)=>{this._messageHandlers[e]=S.safePush(this._messageHandlers[e],{handler:r,order:this._registerOrder++})},event:(e,r)=>{this._eventHandlers[e]=S.safePush(this._eventHandlers[e],{handler:r,order:this._registerOrder++})},stateExpired:(e,r)=>{this._stateExpiredHandlers[e]=S.safePush(this._stateExpiredHandlers[e],{handler:r,order:this._registerOrder++})},beforeIncomingEvent:(e,r)=>{this._hookHandlers.before_incoming_event[e]=S.safePush(this._hookHandlers.before_incoming_event[e],{handler:r,order:this._registerOrder++})},beforeIncomingMessage:(e,r)=>{this._hookHandlers.before_incoming_message[e]=S.safePush(this._hookHandlers.before_incoming_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingMessage:(e,r)=>{this._hookHandlers.before_outgoing_message[e]=S.safePush(this._hookHandlers.before_outgoing_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingCallAction:(e,r)=>{this._hookHandlers.before_outgoing_call_action[e]=S.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},beforeIncomingCallAction:(e,r)=>{this._hookHandlers.before_incoming_call_action[e]=S.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingEvent:(e,r)=>{this._hookHandlers.after_incoming_event[e]=S.safePush(this._hookHandlers.after_incoming_event[e],{handler:r,order:this._registerOrder++})},afterIncomingMessage:(e,r)=>{this._hookHandlers.after_incoming_message[e]=S.safePush(this._hookHandlers.after_incoming_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingMessage:(e,r)=>{this._hookHandlers.after_outgoing_message[e]=S.safePush(this._hookHandlers.after_outgoing_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingCallAction:(e,r)=>{this._hookHandlers.after_outgoing_call_action[e]=S.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingCallAction:(e,r)=>{this._hookHandlers.after_incoming_call_action[e]=S.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:r,order:this._registerOrder++})},workflowStart:(e,r)=>{this._workflowHandlers.started[e]=S.safePush(this._workflowHandlers.started[e],{handler:r,order:this._registerOrder++})},workflowContinue:(e,r)=>{this._workflowHandlers.continued[e]=S.safePush(this._workflowHandlers.continued[e],{handler:r,order:this._registerOrder++})},workflowTimeout:(e,r)=>{this._workflowHandlers.timed_out[e]=S.safePush(this._workflowHandlers.timed_out[e],{handler:r,order:this._registerOrder++})}};_eventResolvesTo=(e,r)=>{let n=td(e);if(!n)return!1;let s=id(n,this._runtime.interfaces);return nd(s)===r};_stripAliasPrefix=e=>{let{alias:r}=this._runtime;if(!r)return e;let n=`${r}#`;return e.startsWith(n)?e.slice(n.length):e}};0&&(module.exports={BRAND,Bot,BotDefinition,BotLogger,BotSpecificClient,DIRTY,EMPTY_PATH,INVALID,Integration,IntegrationDefinition,IntegrationLogger,IntegrationSpecificClient,InterfaceDefinition,NEVER,OK,ParseInputLazyPath,ParseStatus,Plugin,PluginDefinition,RuntimeError,Schema,WELL_KNOWN_ATTRIBUTES,ZodAny,ZodArray,ZodBigInt,ZodBoolean,ZodBranded,ZodCatch,ZodDate,ZodDefault,ZodDiscriminatedUnion,ZodEffects,ZodEnum,ZodError,ZodFirstPartyTypeKind,ZodFunction,ZodIntersection,ZodIssueCode,ZodLazy,ZodLiteral,ZodMap,ZodNaN,ZodNativeEnum,ZodNever,ZodNull,ZodNullable,ZodNumber,ZodObject,ZodOptional,ZodParsedType,ZodPipeline,ZodPromise,ZodReadonly,ZodRecord,ZodRef,ZodSchema,ZodSet,ZodString,ZodSymbol,ZodTransformer,ZodTuple,ZodType,ZodUndefined,ZodUnion,ZodUnknown,ZodVoid,addIssueToContext,agent,aimodel,any,array,bigint,boolean,botIdHeader,botUserIdHeader,coerce,configurationHeader,configurationTypeHeader,conversation,createZodEnum,cuid2Regex,cuidRegex,custom,datasource,date,discriminatedUnion,effect,emailRegex,enum:null,errorUtil,event,function:null,getErrorMap,getParsedType,instanceof:null,integrationIdHeader,intent,intersection,ipv4Regex,ipv6Regex,isAborted,isApiError,isAsync,isDirty,isEmojiRegex,isValid,knowledgebase,late,lazy,literal,makeIssue,map,mergeObjectSchemas,message,messages,nan,nativeEnum,never,null:null,nullable,number,object,objectUtil,oboolean,onumber,operationHeader,optional,ostring,parseBody,pipeline,preprocess,processCreateParams,promise,quotelessJson,readonly,record,ref,serve,set,setErrorMap,strictObject,string,symbol,table,tablerow,transformer,transforms,tuple,typeHeader,ulidRegex,undefined,union,unknown,user,util,uuidRegex,variable,void:null,webhookIdHeader,z});
68
68
  /*! Bundled license information:
69
69
 
70
70
  @bpinternal/zui/dist/index.js: