@botpress/sdk 4.21.0 → 5.0.0

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.
Files changed (41) hide show
  1. package/.turbo/turbo-build.log +5 -5
  2. package/dist/bot/definition.d.ts +45 -7
  3. package/dist/bot/server/types.d.ts +2 -5
  4. package/dist/bot/workflow-proxy/proxy.d.ts +7 -3
  5. package/dist/bot/workflow-proxy/types.d.ts +24 -23
  6. package/dist/common/index.d.ts +1 -0
  7. package/dist/common/types.d.ts +2 -0
  8. package/dist/fixtures.d.ts +84 -13
  9. package/dist/index.cjs +41 -38
  10. package/dist/index.cjs.map +4 -4
  11. package/dist/index.d.ts +2 -2
  12. package/dist/index.mjs +33 -30
  13. package/dist/index.mjs.map +4 -4
  14. package/dist/integration/client/types.d.ts +15 -14
  15. package/dist/integration/common/index.d.ts +0 -1
  16. package/dist/integration/server/types.d.ts +8 -7
  17. package/dist/plugin/common/generic.d.ts +12 -0
  18. package/dist/plugin/common/types.d.ts +17 -5
  19. package/dist/plugin/conversation-proxy/index.d.ts +2 -0
  20. package/dist/plugin/conversation-proxy/proxy.d.ts +13 -0
  21. package/dist/plugin/conversation-proxy/types.d.ts +54 -0
  22. package/dist/plugin/conversation-proxy/types.test.d.ts +1 -0
  23. package/dist/plugin/definition.d.ts +1 -1
  24. package/dist/plugin/event-proxy/proxy.d.ts +2 -2
  25. package/dist/plugin/event-proxy/types.d.ts +11 -6
  26. package/dist/plugin/implementation.d.ts +4 -4
  27. package/dist/plugin/message-proxy/index.d.ts +2 -0
  28. package/dist/plugin/message-proxy/proxy.d.ts +13 -0
  29. package/dist/plugin/message-proxy/types.d.ts +22 -0
  30. package/dist/plugin/server/types.d.ts +129 -51
  31. package/dist/plugin/tag-prefixer.d.ts +10 -0
  32. package/dist/plugin/tag-prefixer.test.d.ts +1 -0
  33. package/dist/plugin/user-proxy/index.d.ts +2 -0
  34. package/dist/plugin/user-proxy/proxy.d.ts +14 -0
  35. package/dist/plugin/user-proxy/types.d.ts +30 -0
  36. package/dist/utils/api-paging-utils.d.ts +43 -0
  37. package/dist/utils/api-paging-utils.test.d.ts +1 -0
  38. package/dist/utils/type-utils.d.ts +1 -0
  39. package/package.json +1 -1
  40. package/dist/integration/common/types.d.ts +0 -2
  41. package/dist/plugin/interface-resolution.d.ts +0 -15
package/dist/index.cjs CHANGED
@@ -1,27 +1,27 @@
1
- "use strict";var bu=Object.create;var Jt=Object.defineProperty;var wu=Object.getOwnPropertyDescriptor;var Pu=Object.getOwnPropertyNames;var xu=Object.getPrototypeOf,ku=Object.prototype.hasOwnProperty;var Xe=(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 Pu(e))!ku.call(t,s)&&s!==r&&Jt(t,s,{get:()=>e[s],enumerable:!(n=wu(e,s))||n.enumerable});return t};var In=(t,e,r)=>(r=t!=null?bu(xu(t)):{},Ls(e||!t||!t.__esModule?Jt(r,"default",{value:t,enumerable:!0}):r,t)),Su=t=>Ls(Jt({},"__esModule",{value:!0}),t);var cv={};Xe(cv,{BRAND:()=>zl,Bot:()=>xn,BotDefinition:()=>Pn,BotLogger:()=>vt,BotSpecificClient:()=>fe,DIRTY:()=>Ne,EMPTY_PATH:()=>Hl,INVALID:()=>x,Integration:()=>wn,IntegrationDefinition:()=>hn,IntegrationLogger:()=>yt,IntegrationSpecificClient:()=>mt,InterfaceDefinition:()=>kn,NEVER:()=>id,OK:()=>G,ParseInputLazyPath:()=>oe,ParseStatus:()=>re,Plugin:()=>En,PluginDefinition:()=>Sn,RuntimeError:()=>On.RuntimeError,Schema:()=>O,WELL_KNOWN_ATTRIBUTES:()=>_y,ZodAny:()=>ct,ZodArray:()=>dt,ZodBigInt:()=>en,ZodBoolean:()=>tn,ZodBranded:()=>rn,ZodCatch:()=>nn,ZodDate:()=>sn,ZodDefault:()=>zt,ZodDiscriminatedUnion:()=>hs,ZodEffects:()=>Se,ZodEnum:()=>Ge,ZodError:()=>pe,ZodFirstPartyTypeKind:()=>ps,ZodFunction:()=>vs,ZodIntersection:()=>an,ZodIssueCode:()=>m,ZodLazy:()=>on,ZodLiteral:()=>ln,ZodMap:()=>_s,ZodNaN:()=>Ts,ZodNativeEnum:()=>cn,ZodNever:()=>ft,ZodNull:()=>dn,ZodNullable:()=>$e,ZodNumber:()=>un,ZodObject:()=>je,ZodOptional:()=>ye,ZodParsedType:()=>_,ZodPipeline:()=>pn,ZodPromise:()=>Wt,ZodReadonly:()=>Lt,ZodRecord:()=>bs,ZodRef:()=>ws,ZodSchema:()=>O,ZodSet:()=>Ps,ZodString:()=>J,ZodSymbol:()=>Bs,ZodTransformer:()=>Se,ZodTuple:()=>Ke,ZodType:()=>O,ZodUndefined:()=>qt,ZodUnion:()=>fn,ZodUnknown:()=>it,ZodVoid:()=>As,addIssueToContext:()=>v,agent:()=>fc,aimodel:()=>vc,any:()=>Zc,array:()=>Rc,bigint:()=>xc,boolean:()=>Ds,coerce:()=>sd,conversation:()=>dc,createZodEnum:()=>Ft,cuid2Regex:()=>ks,cuidRegex:()=>xs,custom:()=>ms,datasource:()=>_c,date:()=>kc,discriminatedUnion:()=>Nc,effect:()=>Vn,emailRegex:()=>Os,enum:()=>Vc,errorUtil:()=>P,event:()=>gc,function:()=>Wc,getErrorMap:()=>ot,getParsedType:()=>he,instanceof:()=>wc,intent:()=>yc,intersection:()=>Mc,ipv4Regex:()=>Zs,ipv6Regex:()=>Is,isAborted:()=>dr,isApiError:()=>On.isApiError,isAsync:()=>jt,isDirty:()=>ur,isEmojiRegex:()=>nc,isValid:()=>lt,json:()=>Zu,knowledgebase:()=>Tc,late:()=>bc,lazy:()=>Lc,literal:()=>qc,makeIssue:()=>$t,map:()=>zc,mergeObjectSchemas:()=>gt,message:()=>pc,messages:()=>Ms,nan:()=>Pc,nativeEnum:()=>Gc,never:()=>Bc,null:()=>Oc,nullable:()=>Xc,number:()=>Cs,object:()=>Cc,objectUtil:()=>lr,oboolean:()=>nd,onumber:()=>rd,optional:()=>Yc,ostring:()=>td,parseBody:()=>le,pipeline:()=>ed,preprocess:()=>Qc,processCreateParams:()=>S,promise:()=>Jc,quotelessJson:()=>Rl,readonly:()=>Uc,record:()=>jc,ref:()=>Kc,serve:()=>Vt,set:()=>Fc,setErrorMap:()=>gs,strictObject:()=>Dc,string:()=>Rs,symbol:()=>Sc,table:()=>mc,tablerow:()=>hc,transformer:()=>Vn,transforms:()=>Ri,tuple:()=>$c,ulidRegex:()=>Ss,undefined:()=>Ec,union:()=>Hc,unknown:()=>Ic,user:()=>uc,util:()=>I,uuidRegex:()=>Es,variable:()=>cc,version:()=>Ws,void:()=>Ac,z:()=>y});module.exports=Su(cv);var Ms={};Xe(Ms,{defaults:()=>vy,markdown:()=>hy,markdownBloc:()=>yy});var Yn=Object.defineProperty,Eu=Object.defineProperties,Ou=Object.getOwnPropertyDescriptors,or=Object.getOwnPropertySymbols,Ii=Object.prototype.hasOwnProperty,Bi=Object.prototype.propertyIsEnumerable,qs=(t,e,r)=>e in t?Yn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,c=(t,e)=>{for(var r in e||(e={}))Ii.call(e,r)&&qs(t,r,e[r]);if(or)for(var r of or(e))Bi.call(e,r)&&qs(t,r,e[r]);return t},f=(t,e)=>Eu(t,Ou(e)),a=(t,e)=>Yn(t,"name",{value:e,configurable:!0}),Ai=(t,e)=>{var r={};for(var n in t)Ii.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&or)for(var n of or(t))e.indexOf(n)<0&&Bi.call(t,n)&&(r[n]=t[n]);return r},zr=(t,e)=>{for(var r in e)Yn(t,r,{get:e[r],enumerable:!0})},Zu={},Ri={};zr(Ri,{errors:()=>Mi,fromJSONSchema:()=>cd,fromJSONSchemaLegacy:()=>Kh,fromObject:()=>Gn,toJSONSchema:()=>q,toJSONSchemaLegacy:()=>fy,toTypescriptSchema:()=>cs,toTypescriptType:()=>Xn});var y={};zr(y,{BRAND:()=>zl,DIRTY:()=>Ne,EMPTY_PATH:()=>Hl,INVALID:()=>x,NEVER:()=>id,OK:()=>G,ParseInputLazyPath:()=>oe,ParseStatus:()=>re,Schema:()=>O,ZodAny:()=>ct,ZodArray:()=>dt,ZodBigInt:()=>en,ZodBoolean:()=>tn,ZodBranded:()=>rn,ZodCatch:()=>nn,ZodDate:()=>sn,ZodDefault:()=>zt,ZodDiscriminatedUnion:()=>hs,ZodEffects:()=>Se,ZodEnum:()=>Ge,ZodError:()=>pe,ZodFirstPartyTypeKind:()=>ps,ZodFunction:()=>vs,ZodIntersection:()=>an,ZodIssueCode:()=>m,ZodLazy:()=>on,ZodLiteral:()=>ln,ZodMap:()=>_s,ZodNaN:()=>Ts,ZodNativeEnum:()=>cn,ZodNever:()=>ft,ZodNull:()=>dn,ZodNullable:()=>$e,ZodNumber:()=>un,ZodObject:()=>je,ZodOptional:()=>ye,ZodParsedType:()=>_,ZodPipeline:()=>pn,ZodPromise:()=>Wt,ZodReadonly:()=>Lt,ZodRecord:()=>bs,ZodRef:()=>ws,ZodSchema:()=>O,ZodSet:()=>Ps,ZodString:()=>J,ZodSymbol:()=>Bs,ZodTransformer:()=>Se,ZodTuple:()=>Ke,ZodType:()=>O,ZodUndefined:()=>qt,ZodUnion:()=>fn,ZodUnknown:()=>it,ZodVoid:()=>As,addIssueToContext:()=>v,agent:()=>fc,aimodel:()=>vc,any:()=>Zc,array:()=>Rc,bigint:()=>xc,boolean:()=>Ds,coerce:()=>sd,conversation:()=>dc,createZodEnum:()=>Ft,cuid2Regex:()=>ks,cuidRegex:()=>xs,custom:()=>ms,datasource:()=>_c,date:()=>kc,default:()=>yh,discriminatedUnion:()=>Nc,effect:()=>Vn,emailRegex:()=>Os,enum:()=>Vc,errorUtil:()=>P,event:()=>gc,function:()=>Wc,getErrorMap:()=>ot,getParsedType:()=>he,instanceof:()=>wc,intent:()=>yc,intersection:()=>Mc,ipv4Regex:()=>Zs,ipv6Regex:()=>Is,isAborted:()=>dr,isAsync:()=>jt,isDirty:()=>ur,isEmojiRegex:()=>nc,isValid:()=>lt,knowledgebase:()=>Tc,late:()=>bc,lazy:()=>Lc,literal:()=>qc,makeIssue:()=>$t,map:()=>zc,message:()=>pc,nan:()=>Pc,nativeEnum:()=>Gc,never:()=>Bc,null:()=>Oc,nullable:()=>Xc,number:()=>Cs,object:()=>Cc,objectUtil:()=>lr,oboolean:()=>nd,onumber:()=>rd,optional:()=>Yc,ostring:()=>td,pipeline:()=>ed,preprocess:()=>Qc,processCreateParams:()=>S,promise:()=>Jc,quotelessJson:()=>Rl,readonly:()=>Uc,record:()=>jc,ref:()=>Kc,set:()=>Fc,setErrorMap:()=>gs,strictObject:()=>Dc,string:()=>Rs,symbol:()=>Sc,table:()=>mc,tablerow:()=>hc,transformer:()=>Vn,tuple:()=>$c,ulidRegex:()=>Ss,undefined:()=>Ec,union:()=>Hc,unknown:()=>Ic,user:()=>uc,util:()=>I,uuidRegex:()=>Es,variable:()=>cc,void:()=>Ac});var w="x-zui";function Ci(t){return typeof t=="symbol"?"symbol":typeof t=="bigint"?`${t.toString()}n`:b(t)}a(Ci,"primitiveToTypscriptLiteralType");function b(t){return typeof t>"u"?"undefined":typeof t=="symbol"?t.description?`Symbol(${b(t.description)})`:"Symbol()":typeof t=="bigint"?`BigInt(${t.toString()})`:typeof t=="string"?Ni(t):JSON.stringify(t)}a(b,"primitiveToTypescriptValue");function nt(t){return typeof t>"u"?"undefined":JSON.stringify(t)}a(nt,"unknownToTypescriptValue");var Di=a((t,e)=>{let r=Object.entries(t),n=e?" as const":"";return`{ ${r.map(([s,i])=>`${Mn(s)}: ${nt(i)}`).join(", ")} }${n}`},"recordOfUnknownToTypescriptRecord"),Mn=a(t=>/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t)?t:b(t),"toPropertyKey"),Iu=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(Iu).filter(n=>!!n).join("")},"toTypeArgumentName"),Vs=a(t=>{for(var e;t.length&&!((e=t[0])!=null&&e.trim());)t.shift();for(;t.length&&!t[t.length-1].trim();)t.pop()},"trimEmptyLinesInPlace"),z=a(t=>{t=t?.replace(/(\n(\s*)?){3,}/g,`
1
+ "use strict";var xd=Object.create;var tn=Object.defineProperty;var kd=Object.getOwnPropertyDescriptor;var Sd=Object.getOwnPropertyNames;var Ed=Object.getPrototypeOf,Od=Object.prototype.hasOwnProperty;var nt=(t,e)=>{for(var n in e)tn(t,n,{get:e[n],enumerable:!0})},es=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Sd(e))!Od.call(t,i)&&i!==n&&tn(t,i,{get:()=>e[i],enumerable:!(r=kd(e,i))||r.enumerable});return t};var Dr=(t,e,n)=>(n=t!=null?xd(Ed(t)):{},es(e||!t||!t.__esModule?tn(n,"default",{value:t,enumerable:!0}):n,t)),Id=t=>es(tn({},"__esModule",{value:!0}),t);var dv={};nt(dv,{BRAND:()=>Yl,Bot:()=>Ir,BotDefinition:()=>Or,BotLogger:()=>wt,BotSpecificClient:()=>ye,DIRTY:()=>Ke,EMPTY_PATH:()=>zl,INVALID:()=>x,Integration:()=>Er,IntegrationDefinition:()=>br,IntegrationLogger:()=>bt,IntegrationSpecificClient:()=>_t,InterfaceDefinition:()=>Zr,NEVER:()=>fu,OK:()=>G,ParseInputLazyPath:()=>le,ParseStatus:()=>ne,Plugin:()=>Ar,PluginDefinition:()=>Br,RuntimeError:()=>Cr.RuntimeError,Schema:()=>O,WELL_KNOWN_ATTRIBUTES:()=>wy,ZodAny:()=>ft,ZodArray:()=>gt,ZodBigInt:()=>ar,ZodBoolean:()=>or,ZodBranded:()=>lr,ZodCatch:()=>cr,ZodDate:()=>ur,ZodDefault:()=>qt,ZodDiscriminatedUnion:()=>bi,ZodEffects:()=>Ae,ZodEnum:()=>Qe,ZodError:()=>he,ZodFirstPartyTypeKind:()=>yi,ZodFunction:()=>Pi,ZodIntersection:()=>dr,ZodIssueCode:()=>h,ZodLazy:()=>pr,ZodLiteral:()=>fr,ZodMap:()=>xi,ZodNaN:()=>ki,ZodNativeEnum:()=>gr,ZodNever:()=>yt,ZodNull:()=>mr,ZodNullable:()=>Fe,ZodNumber:()=>hr,ZodObject:()=>ze,ZodOptional:()=>Pe,ZodParsedType:()=>_,ZodPipeline:()=>yr,ZodPromise:()=>Jt,ZodReadonly:()=>Yt,ZodRecord:()=>Si,ZodRef:()=>Ei,ZodSchema:()=>O,ZodSet:()=>Oi,ZodString:()=>J,ZodSymbol:()=>Hi,ZodTransformer:()=>Ae,ZodTuple:()=>We,ZodType:()=>O,ZodUndefined:()=>Xt,ZodUnion:()=>vr,ZodUnknown:()=>ct,ZodVoid:()=>Ni,addIssueToContext:()=>v,agent:()=>bc,aimodel:()=>Sc,any:()=>Nc,array:()=>Kc,bigint:()=>Ac,boolean:()=>ji,coerce:()=>pu,conversation:()=>vc,createZodEnum:()=>Gt,cuid2Regex:()=>Zi,cuidRegex:()=>Ii,custom:()=>Ti,datasource:()=>Ec,date:()=>Cc,discriminatedUnion:()=>Wc,effect:()=>Qr,emailRegex:()=>Ci,enum:()=>nu,errorUtil:()=>P,event:()=>wc,function:()=>Qc,getErrorMap:()=>dt,getParsedType:()=>we,instanceof:()=>Zc,intent:()=>kc,intersection:()=>Lc,ipv4Regex:()=>Ri,ipv6Regex:()=>Di,isAborted:()=>hn,isApiError:()=>Cr.isApiError,isAsync:()=>Wt,isDirty:()=>yn,isEmojiRegex:()=>dc,isValid:()=>pt,json:()=>Ad,knowledgebase:()=>Oc,late:()=>Ic,lazy:()=>eu,literal:()=>tu,makeIssue:()=>zt,map:()=>Yc,mergeObjectSchemas:()=>vt,message:()=>Tc,messages:()=>Fi,nan:()=>Bc,nativeEnum:()=>ru,never:()=>$c,null:()=>Hc,nullable:()=>au,number:()=>$i,object:()=>Uc,objectUtil:()=>gn,oboolean:()=>du,onumber:()=>uu,optional:()=>su,ostring:()=>cu,parseBody:()=>ce,pipeline:()=>lu,preprocess:()=>ou,processCreateParams:()=>S,promise:()=>iu,quotelessJson:()=>Kl,readonly:()=>Jc,record:()=>qc,ref:()=>Gc,serve:()=>Qt,set:()=>Xc,setErrorMap:()=>_i,strictObject:()=>Fc,string:()=>Mi,symbol:()=>Rc,table:()=>Pc,tablerow:()=>xc,transformer:()=>Qr,transforms:()=>Ks,tuple:()=>Vc,ulidRegex:()=>Bi,undefined:()=>Dc,union:()=>zc,unknown:()=>Mc,user:()=>_c,util:()=>Z,uuidRegex:()=>Ai,variable:()=>yc,version:()=>Qi,void:()=>jc,z:()=>y});module.exports=Id(dv);var Fi={};nt(Fi,{defaults:()=>by,markdown:()=>_y,markdownBloc:()=>Ty});var ni=Object.defineProperty,Zd=Object.defineProperties,Bd=Object.getOwnPropertyDescriptors,fn=Object.getOwnPropertySymbols,Ms=Object.prototype.hasOwnProperty,$s=Object.prototype.propertyIsEnumerable,ts=(t,e,n)=>e in t?ni(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,u=(t,e)=>{for(var n in e||(e={}))Ms.call(e,n)&&ts(t,n,e[n]);if(fn)for(var n of fn(e))$s.call(e,n)&&ts(t,n,e[n]);return t},f=(t,e)=>Zd(t,Bd(e)),o=(t,e)=>ni(t,"name",{value:e,configurable:!0}),js=(t,e)=>{var n={};for(var r in t)Ms.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&fn)for(var r of fn(t))e.indexOf(r)<0&&$s.call(t,r)&&(n[r]=t[r]);return n},Gn=(t,e)=>{for(var n in e)ni(t,n,{get:e[n],enumerable:!0})},Ad={},Ks={};Gn(Ks,{errors:()=>Ls,fromJSONSchema:()=>yu,fromJSONSchemaLegacy:()=>zh,fromObject:()=>ei,toJSONSchema:()=>V,toJSONSchemaLegacy:()=>hy,toTypescriptSchema:()=>gi,toTypescriptType:()=>ri});var y={};Gn(y,{BRAND:()=>Yl,DIRTY:()=>Ke,EMPTY_PATH:()=>zl,INVALID:()=>x,NEVER:()=>fu,OK:()=>G,ParseInputLazyPath:()=>le,ParseStatus:()=>ne,Schema:()=>O,ZodAny:()=>ft,ZodArray:()=>gt,ZodBigInt:()=>ar,ZodBoolean:()=>or,ZodBranded:()=>lr,ZodCatch:()=>cr,ZodDate:()=>ur,ZodDefault:()=>qt,ZodDiscriminatedUnion:()=>bi,ZodEffects:()=>Ae,ZodEnum:()=>Qe,ZodError:()=>he,ZodFirstPartyTypeKind:()=>yi,ZodFunction:()=>Pi,ZodIntersection:()=>dr,ZodIssueCode:()=>h,ZodLazy:()=>pr,ZodLiteral:()=>fr,ZodMap:()=>xi,ZodNaN:()=>ki,ZodNativeEnum:()=>gr,ZodNever:()=>yt,ZodNull:()=>mr,ZodNullable:()=>Fe,ZodNumber:()=>hr,ZodObject:()=>ze,ZodOptional:()=>Pe,ZodParsedType:()=>_,ZodPipeline:()=>yr,ZodPromise:()=>Jt,ZodReadonly:()=>Yt,ZodRecord:()=>Si,ZodRef:()=>Ei,ZodSchema:()=>O,ZodSet:()=>Oi,ZodString:()=>J,ZodSymbol:()=>Hi,ZodTransformer:()=>Ae,ZodTuple:()=>We,ZodType:()=>O,ZodUndefined:()=>Xt,ZodUnion:()=>vr,ZodUnknown:()=>ct,ZodVoid:()=>Ni,addIssueToContext:()=>v,agent:()=>bc,aimodel:()=>Sc,any:()=>Nc,array:()=>Kc,bigint:()=>Ac,boolean:()=>ji,coerce:()=>pu,conversation:()=>vc,createZodEnum:()=>Gt,cuid2Regex:()=>Zi,cuidRegex:()=>Ii,custom:()=>Ti,datasource:()=>Ec,date:()=>Cc,default:()=>Th,discriminatedUnion:()=>Wc,effect:()=>Qr,emailRegex:()=>Ci,enum:()=>nu,errorUtil:()=>P,event:()=>wc,function:()=>Qc,getErrorMap:()=>dt,getParsedType:()=>we,instanceof:()=>Zc,intent:()=>kc,intersection:()=>Lc,ipv4Regex:()=>Ri,ipv6Regex:()=>Di,isAborted:()=>hn,isAsync:()=>Wt,isDirty:()=>yn,isEmojiRegex:()=>dc,isValid:()=>pt,knowledgebase:()=>Oc,late:()=>Ic,lazy:()=>eu,literal:()=>tu,makeIssue:()=>zt,map:()=>Yc,message:()=>Tc,nan:()=>Bc,nativeEnum:()=>ru,never:()=>$c,null:()=>Hc,nullable:()=>au,number:()=>$i,object:()=>Uc,objectUtil:()=>gn,oboolean:()=>du,onumber:()=>uu,optional:()=>su,ostring:()=>cu,pipeline:()=>lu,preprocess:()=>ou,processCreateParams:()=>S,promise:()=>iu,quotelessJson:()=>Kl,readonly:()=>Jc,record:()=>qc,ref:()=>Gc,set:()=>Xc,setErrorMap:()=>_i,strictObject:()=>Fc,string:()=>Mi,symbol:()=>Rc,table:()=>Pc,tablerow:()=>xc,transformer:()=>Qr,tuple:()=>Vc,ulidRegex:()=>Bi,undefined:()=>Dc,union:()=>zc,unknown:()=>Mc,user:()=>_c,util:()=>Z,uuidRegex:()=>Ai,variable:()=>yc,void:()=>jc});var w="x-zui";function Us(t){return typeof t=="symbol"?"symbol":typeof t=="bigint"?`${t.toString()}n`:b(t)}o(Us,"primitiveToTypscriptLiteralType");function b(t){return typeof t>"u"?"undefined":typeof t=="symbol"?t.description?`Symbol(${b(t.description)})`:"Symbol()":typeof t=="bigint"?`BigInt(${t.toString()})`:typeof t=="string"?Ws(t):JSON.stringify(t)}o(b,"primitiveToTypescriptValue");function ot(t){return typeof t>"u"?"undefined":JSON.stringify(t)}o(ot,"unknownToTypescriptValue");var Fs=o((t,e)=>{let n=Object.entries(t),r=e?" as const":"";return`{ ${n.map(([i,s])=>`${Fr(i)}: ${ot(s)}`).join(", ")} }${r}`},"recordOfUnknownToTypescriptRecord"),Fr=o(t=>/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t)?t:b(t),"toPropertyKey"),Cd=o(t=>t.charAt(0).toUpperCase()+t.slice(1),"capitalize"),zs=o(t=>{let e=/[^a-zA-Z0-9_]/g;return t.split(e).map(Cd).filter(r=>!!r).join("")},"toTypeArgumentName"),ns=o(t=>{for(var e;t.length&&!((e=t[0])!=null&&e.trim());)t.shift();for(;t.length&&!t[t.length-1].trim();)t.pop()},"trimEmptyLinesInPlace"),F=o(t=>{t=t?.replace(/(\n(\s*)?){3,}/g,`
2
2
 
3
- `);let e=a(s=>s.startsWith("* ")?` ${s}`:` * ${s}`,"ensureLineStartsWithAsterisk"),r=a(s=>s.replace(/\*\//g,"*\\/"),"escapeCommentEnd"),n=(t??"").split(`
4
- `).map(s=>s.trim());return Vs(n),n.length&&(n[0]=n[0].replace(/^\/\*\*?/,""),n[n.length-1]=n[n.length-1].replace(/\*\/$/,"")),Vs(n),n.length===0?"":n.length===1?`/** ${r(n[0])} */`:`/**
5
- ${n.map(e).map(r).join(`
3
+ `);let e=o(i=>i.startsWith("* ")?` ${i}`:` * ${i}`,"ensureLineStartsWithAsterisk"),n=o(i=>i.replace(/\*\//g,"*\\/"),"escapeCommentEnd"),r=(t??"").split(`
4
+ `).map(i=>i.trim());return ns(r),r.length&&(r[0]=r[0].replace(/^\/\*\*?/,""),r[r.length-1]=r[r.length-1].replace(/\*\/$/,"")),ns(r),r.length===0?"":r.length===1?`/** ${n(r[0])} */`:`/**
5
+ ${r.map(e).map(n).join(`
6
6
  `)}
7
- */`},"getMultilineComment");function Ni(t){if(typeof t!="string")return"";let r=String.raw`${t}`.replace(/\\/g,"\\\\").replace(/\n/g,"\\n").replace(/"/g,'\\"').replace(/'/g,"\\'");return r.includes("`")?`"${r}"`:r.includes("'")?`"${r}"`:`'${r}'`}a(Ni,"escapeString");var Mi={};zr(Mi,{JSONSchemaToZuiError:()=>Fr,ObjectToZuiError:()=>$n,UnrepresentableGenericError:()=>jn,UnsupportedJSONSchemaToZuiError:()=>Pe,UnsupportedZuiCheckToJSONSchemaError:()=>Wi,UnsupportedZuiToJSONSchemaError:()=>te,UnsupportedZuiToTypescriptSchemaError:()=>Be,UnsupportedZuiToTypescriptTypeError:()=>Xi,UntitledDeclarationError:()=>ea,ZuiToJSONSchemaError:()=>Wr,ZuiToTypescriptSchemaError:()=>Vi,ZuiToTypescriptTypeError:()=>Lr,ZuiTransformError:()=>pt});var $i=class extends Error{constructor(e,r){super(r),this.transform=e}};a($i,"ZuiTransformError");var pt=$i,ji=class extends pt{constructor(e){super("json-schema-to-zui",e)}};a(ji,"JSONSchemaToZuiError");var Fr=ji,Ki=class extends pt{constructor(e){super("object-to-zui",e)}};a(Ki,"ObjectToZuiError");var $n=Ki,Ui=class extends pt{constructor(e){super("zui-to-json-schema",e)}};a(Ui,"ZuiToJSONSchemaError");var Wr=Ui,zi=class extends Wr{constructor(e,{suggestedAlternative:r}={}){super(`Zod type ${e} cannot be transformed to JSON Schema.`+(r?` Suggested alternative: ${r}`:""))}};a(zi,"UnsupportedZuiToJSONSchemaError");var te=zi,Fi=class extends Wr{constructor({zodType:e,checkKind:r}){super(`Zod check .${r}() of type ${e} cannot be transformed to JSON Schema.`)}};a(Fi,"UnsupportedZuiCheckToJSONSchemaError");var Wi=Fi,Li=class extends Fr{constructor(e){super(`JSON Schema ${JSON.stringify(e)} cannot be transformed to ZUI type.`)}};a(Li,"UnsupportedJSONSchemaToZuiError");var Pe=Li,qi=class extends pt{constructor(e){super("zui-to-typescript-schema",e)}};a(qi,"ZuiToTypescriptSchemaError");var Vi=qi,Gi=class extends Vi{constructor(e){super(`Zod type ${e} cannot be transformed to TypeScript schema.`)}};a(Gi,"UnsupportedZuiToTypescriptSchemaError");var Be=Gi,Ji=class extends pt{constructor(e){super("zui-to-typescript-type",e)}};a(Ji,"ZuiToTypescriptTypeError");var Lr=Ji,Yi=class extends Lr{constructor(e){super(`Zod type ${e} cannot be transformed to TypeScript type.`)}};a(Yi,"UnsupportedZuiToTypescriptTypeError");var Xi=Yi,Qi=class extends Lr{constructor(){super("Schema must have a title to be transformed to a TypeScript type with a declaration.")}};a(Qi,"UntitledDeclarationError");var ea=Qi,ta=class extends Lr{constructor(){super('ZodRef can only be transformed to a TypeScript type with a "type" declaration.')}};a(ta,"UnrepresentableGenericError");var jn=ta,ra=["string","number","boolean","unknown","void","any","null","undefined","never","bigint","symbol","object"],Bu=5,Au=a(t=>ra.includes(t),"isPrimitive"),Ru=a(t=>ra.map(e=>`${e}[]`).includes(t),"isArrayOfPrimitives"),Bn=a(t=>t.replace(/ +/g," ").trim(),"stripSpaces"),na=class{constructor(e,r){this.key=e,this.value=r}};a(na,"KeyValue");var Yt=na,sa=class{constructor(e){this.schema=e}};a(sa,"FnParameters");var Gs=sa,ia=class{constructor(e){this.schema=e}};a(ia,"FnReturn");var Js=ia,aa=class{constructor(e){this.props=e}};a(aa,"Declaration");var Rt=aa;function Xn(t,e={}){let r=Hu(t,e),n=B(r,e);return e.formatter&&(n=e.formatter(n)),n}a(Xn,"toTypescriptType");var Ys=a(t=>t.endsWith("?")?t:`${t}?`,"_optionalKey");function B(t,e){var r,n,s;let i=f(c({},e),{declaration:!1,parent:t});if(t===null)return"";if(t instanceof Rt)return Cu(t,i);if(t instanceof Yt){let d;if(t.value instanceof p.ZodOptional?d=t.value:t.value instanceof p.ZodDefault&&e.treatDefaultAsOptional&&(d=t.value._def.innerType.optional()),d){let k=d._def.innerType;return k instanceof p.Schema&&!k.description&&d.description&&(k=k?.describe(d.description)),B(new Yt(Ys(t.key),k),i)}let u=z(t.value._def.description||t.value.description),g=u?.trim().length>0?`
8
- `:"",h=t.value.describe(""),Z=t.value instanceof p.ZodAny?Ys(t.key):t.key;return`${g}${u}${g}${Z}: ${B(h,i)}${g}`}if(t instanceof Gs){if(t.schema instanceof p.ZodTuple){let h="";for(let T=0;T<t.schema.items.length;T++){let Z=(s=(n=(r=t.schema.items[T])==null?void 0:r.ui)==null?void 0:n.title)!=null?s:`arg${T}`,k=t.schema.items[T];h+=`${B(new Yt(Mn(Z),k),i)}${T<t.schema.items.length-1?", ":""} `}return h}let d=t.schema.naked()instanceof p.ZodLiteral,u=B(t.schema,i).trim();return u.startsWith("{")&&u.endsWith("}")||u.startsWith("[")&&u.endsWith("]")||u.startsWith("(")&&u.endsWith(")")||u.startsWith("Array<")&&u.endsWith(">")||u.startsWith("Record<")&&u.endsWith(">")||Ru(u)||d?`args: ${u}`:u}if(t instanceof Js)return t.schema instanceof p.ZodOptional?`${B(t.schema.unwrap(),i)} | undefined`:B(t.schema,i);let o=t,l=o._def;switch(l.typeName){case p.ZodFirstPartyTypeKind.ZodString:return`${z(o.description)} string`.trim();case p.ZodFirstPartyTypeKind.ZodNumber:case p.ZodFirstPartyTypeKind.ZodNaN:case p.ZodFirstPartyTypeKind.ZodBigInt:return`${z(o.description)} number`.trim();case p.ZodFirstPartyTypeKind.ZodBoolean:return`${z(o.description)} boolean`.trim();case p.ZodFirstPartyTypeKind.ZodDate:return`${z(o.description)} Date`.trim();case p.ZodFirstPartyTypeKind.ZodUndefined:return`${z(o.description)} undefined`.trim();case p.ZodFirstPartyTypeKind.ZodNull:return`${z(o.description)} null`.trim();case p.ZodFirstPartyTypeKind.ZodAny:return`${z(o.description)} any`.trim();case p.ZodFirstPartyTypeKind.ZodUnknown:return`${z(o.description)} unknown`.trim();case p.ZodFirstPartyTypeKind.ZodNever:return`${z(o.description)} never`.trim();case p.ZodFirstPartyTypeKind.ZodVoid:return`${z(o.description)} void`.trim();case p.ZodFirstPartyTypeKind.ZodArray:let d=B(l.type,i);return Au(d)?`${d}[]`:`Array<${d}>`;case p.ZodFirstPartyTypeKind.ZodObject:return`{ ${Object.entries(l.shape()).map(([ee,Zn])=>Zn instanceof p.Schema?B(new Yt(Mn(ee),Zn),i):`${ee}: unknown`).join("; ")} }`;case p.ZodFirstPartyTypeKind.ZodUnion:let g=l.options.map(ee=>B(ee,i));return`${z(o.description)}
9
- ${g.join(" | ")}`;case p.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:let h=l.options.map(ee=>B(ee,i));return`${z(o.description)}
10
- ${h.join(" | ")}`;case p.ZodFirstPartyTypeKind.ZodIntersection:return`${B(l.left,i)} & ${B(l.right,i)}`;case p.ZodFirstPartyTypeKind.ZodTuple:return l.items.length===0?"[]":`[${l.items.map(ee=>B(ee,i)).join(", ")}]`;case p.ZodFirstPartyTypeKind.ZodRecord:let Z=B(l.keyType,i),k=B(l.valueType,i);return`${z(o.description)} { [key: ${Z}]: ${k} }`;case p.ZodFirstPartyTypeKind.ZodMap:return`Map<${B(l.keyType,i)}, ${B(l.valueType,i)}>`;case p.ZodFirstPartyTypeKind.ZodSet:return`Set<${B(l.valueType,i)}>`;case p.ZodFirstPartyTypeKind.ZodFunction:let K=B(new Gs(l.args),i),F=B(new Js(l.returns),i),Q=e?.parent instanceof Rt&&e?.parent.props.type==="type";return e?.declaration&&!Q?`${z(o.description)}
11
- (${K}): ${F}`:`${z(o.description)}
12
- (${K}) => ${F}`;case p.ZodFirstPartyTypeKind.ZodLazy:return B(l.getter(),i);case p.ZodFirstPartyTypeKind.ZodLiteral:let ie=Ci(l.value);return`${z(o.description)}
13
- ${ie}`.trim();case p.ZodFirstPartyTypeKind.ZodEnum:return l.values.map(b).join(" | ");case p.ZodFirstPartyTypeKind.ZodEffects:return B(l.schema,i);case p.ZodFirstPartyTypeKind.ZodNativeEnum:throw new Xi(p.ZodFirstPartyTypeKind.ZodNativeEnum);case p.ZodFirstPartyTypeKind.ZodOptional:return`${B(l.innerType,i)} | undefined`;case p.ZodFirstPartyTypeKind.ZodNullable:return`${B(l.innerType,i)} | null`;case p.ZodFirstPartyTypeKind.ZodDefault:let ae=e.treatDefaultAsOptional?l.innerType.optional():l.innerType;return B(ae,i);case p.ZodFirstPartyTypeKind.ZodCatch:return B(l.innerType,i);case p.ZodFirstPartyTypeKind.ZodPromise:return`Promise<${B(l.type,i)}>`;case p.ZodFirstPartyTypeKind.ZodBranded:return B(l.type,i);case p.ZodFirstPartyTypeKind.ZodPipeline:return B(l.in,i);case p.ZodFirstPartyTypeKind.ZodSymbol:return`${z(o.description)} symbol`.trim();case p.ZodFirstPartyTypeKind.ZodReadonly:return`Readonly<${B(l.innerType,i)}>`;case p.ZodFirstPartyTypeKind.ZodRef:return Hi(l.uri);default:I.assertNever(l)}}a(B,"sUnwrapZod");var Cu=a((t,e)=>{if(t.props.type==="none")return B(t.props.schema,e);let{schema:r,identifier:n}=t.props,s=z(r.description),i=r.describe(""),o=B(i,f(c({},e),{declaration:!0})),d=o.split(`
14
- `).length>=Bu&&e.includeClosingTags?`// end of ${n}`:"";if(t.props.type!=="type"&&r instanceof p.ZodFunction)return Bn(`${s}
15
- declare function ${n}${o};${d}`);if(t.props.type==="variable")return Bn(`${s}declare const ${n}: ${o};${d}`);let u=t.props.args.length>0?`<${t.props.args.map(Hi).join(", ")}>`:"";return Bn(`${s}type ${t.props.identifier}${u} = ${o};${d}`)},"unwrapDeclaration"),Du=a(t=>t.declaration?t.declaration===!0?"variable":t.declaration:"none","getDeclarationType"),Hu=a((t,e)=>{let r=Du(e),n=t.getReferences();if(r==="none"){if(n.length>0)throw new jn;return new Rt({type:"none",schema:t})}let s="title"in t.ui?t.ui.title:null;if(!s)throw new ea;if(r==="variable"){if(n.length>0)throw new jn;return new Rt({type:"variable",identifier:s,schema:t})}return new Rt({type:"type",identifier:s,schema:t,args:n})},"getDeclarationProps"),Nu=typeof global=="object"&&global&&global.Object===Object&&global,oa=Nu,Mu=typeof self=="object"&&self&&self.Object===Object&&self,$u=oa||Mu||Function("return this")(),_e=$u,ju=_e.Symbol,xe=ju,la=Object.prototype,Ku=la.hasOwnProperty,Uu=la.toString,_t=xe?xe.toStringTag:void 0;function ca(t){var e=Ku.call(t,_t),r=t[_t];try{t[_t]=void 0;var n=!0}catch{}var s=Uu.call(t);return n&&(e?t[_t]=r:delete t[_t]),s}a(ca,"getRawTag");var zu=ca,Fu=Object.prototype,Wu=Fu.toString;function da(t){return Wu.call(t)}a(da,"objectToString");var Lu=da,qu="[object Null]",Vu="[object Undefined]",Xs=xe?xe.toStringTag:void 0;function ua(t){return t==null?t===void 0?Vu:qu:Xs&&Xs in Object(t)?zu(t):Lu(t)}a(ua,"baseGetTag");var Ue=ua;function pa(t){return t!=null&&typeof t=="object"}a(pa,"isObjectLike");var Me=pa,Gu="[object Symbol]";function fa(t){return typeof t=="symbol"||Me(t)&&Ue(t)==Gu}a(fa,"isSymbol");var Qn=fa;function ga(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(ga,"arrayMap");var ma=ga,Ju=Array.isArray,ve=Ju,Yu=1/0,Qs=xe?xe.prototype:void 0,ei=Qs?Qs.toString:void 0;function es(t){if(typeof t=="string")return t;if(ve(t))return ma(t,es)+"";if(Qn(t))return ei?ei.call(t):"";var e=t+"";return e=="0"&&1/t==-Yu?"-0":e}a(es,"baseToString");var Xu=es;function ha(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}a(ha,"isObject");var at=ha;function ya(t){return t}a(ya,"identity");var Qu=ya,ep="[object AsyncFunction]",tp="[object Function]",rp="[object GeneratorFunction]",np="[object Proxy]";function va(t){if(!at(t))return!1;var e=Ue(t);return e==tp||e==rp||e==ep||e==np}a(va,"isFunction");var _a=va,sp=_e["__core-js_shared__"],An=sp,ti=(function(){var t=/[^.]+$/.exec(An&&An.keys&&An.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function Ta(t){return!!ti&&ti in t}a(Ta,"isMasked");var ip=Ta,ap=Function.prototype,op=ap.toString;function ba(t){if(t!=null){try{return op.call(t)}catch{}try{return t+""}catch{}}return""}a(ba,"toSource");var ze=ba,lp=/[\\^$.*+?()[\]{}|]/g,cp=/^\[object .+?Constructor\]$/,dp=Function.prototype,up=Object.prototype,pp=dp.toString,fp=up.hasOwnProperty,gp=RegExp("^"+pp.call(fp).replace(lp,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function wa(t){if(!at(t)||ip(t))return!1;var e=_a(t)?gp:cp;return e.test(ze(t))}a(wa,"baseIsNative");var mp=wa;function Pa(t,e){return t?.[e]}a(Pa,"getValue");var hp=Pa;function xa(t,e){var r=hp(t,e);return mp(r)?r:void 0}a(xa,"getNative");var Fe=xa,yp=Fe(_e,"WeakMap"),Kn=yp,vp=(function(){try{var t=Fe(Object,"defineProperty");return t({},"",{}),t}catch{}})(),ri=vp,_p=9007199254740991,Tp=/^(?:0|[1-9]\d*)$/;function ka(t,e){var r=typeof t;return e=e??_p,!!e&&(r=="number"||r!="symbol"&&Tp.test(t))&&t>-1&&t%1==0&&t<e}a(ka,"isIndex");var ts=ka;function Sa(t,e,r){e=="__proto__"&&ri?ri(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}a(Sa,"baseAssignValue");var Ea=Sa;function Oa(t,e){return t===e||t!==t&&e!==e}a(Oa,"eq");var rs=Oa,bp=Object.prototype,wp=bp.hasOwnProperty;function Za(t,e,r){var n=t[e];(!(wp.call(t,e)&&rs(n,r))||r===void 0&&!(e in t))&&Ea(t,e,r)}a(Za,"assignValue");var Pp=Za,xp=9007199254740991;function Ia(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=xp}a(Ia,"isLength");var ns=Ia;function Ba(t){return t!=null&&ns(t.length)&&!_a(t)}a(Ba,"isArrayLike");var Aa=Ba,kp=Object.prototype;function Ra(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||kp;return t===r}a(Ra,"isPrototype");var Ca=Ra;function Da(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}a(Da,"baseTimes");var Sp=Da,Ep="[object Arguments]";function Ha(t){return Me(t)&&Ue(t)==Ep}a(Ha,"baseIsArguments");var ni=Ha,Na=Object.prototype,Op=Na.hasOwnProperty,Zp=Na.propertyIsEnumerable,Ip=ni((function(){return arguments})())?ni:function(t){return Me(t)&&Op.call(t,"callee")&&!Zp.call(t,"callee")},Ma=Ip;function $a(){return!1}a($a,"stubFalse");var Bp=$a,ja=typeof exports=="object"&&exports&&!exports.nodeType&&exports,si=ja&&typeof module=="object"&&module&&!module.nodeType&&module,Ap=si&&si.exports===ja,ii=Ap?_e.Buffer:void 0,Rp=ii?ii.isBuffer:void 0,Cp=Rp||Bp,Un=Cp,Dp="[object Arguments]",Hp="[object Array]",Np="[object Boolean]",Mp="[object Date]",$p="[object Error]",jp="[object Function]",Kp="[object Map]",Up="[object Number]",zp="[object Object]",Fp="[object RegExp]",Wp="[object Set]",Lp="[object String]",qp="[object WeakMap]",Vp="[object ArrayBuffer]",Gp="[object DataView]",Jp="[object Float32Array]",Yp="[object Float64Array]",Xp="[object Int8Array]",Qp="[object Int16Array]",ef="[object Int32Array]",tf="[object Uint8Array]",rf="[object Uint8ClampedArray]",nf="[object Uint16Array]",sf="[object Uint32Array]",H={};H[Jp]=H[Yp]=H[Xp]=H[Qp]=H[ef]=H[tf]=H[rf]=H[nf]=H[sf]=!0;H[Dp]=H[Hp]=H[Vp]=H[Np]=H[Gp]=H[Mp]=H[$p]=H[jp]=H[Kp]=H[Up]=H[zp]=H[Fp]=H[Wp]=H[Lp]=H[qp]=!1;function Ka(t){return Me(t)&&ns(t.length)&&!!H[Ue(t)]}a(Ka,"baseIsTypedArray");var af=Ka;function Ua(t){return function(e){return t(e)}}a(Ua,"baseUnary");var of=Ua,za=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ct=za&&typeof module=="object"&&module&&!module.nodeType&&module,lf=Ct&&Ct.exports===za,Rn=lf&&oa.process,cf=(function(){try{var t=Ct&&Ct.require&&Ct.require("util").types;return t||Rn&&Rn.binding&&Rn.binding("util")}catch{}})(),ai=cf,oi=ai&&ai.isTypedArray,df=oi?of(oi):af,Fa=df,uf=Object.prototype,pf=uf.hasOwnProperty;function Wa(t,e){var r=ve(t),n=!r&&Ma(t),s=!r&&!n&&Un(t),i=!r&&!n&&!s&&Fa(t),o=r||n||s||i,l=o?Sp(t.length,String):[],d=l.length;for(var u in t)(e||pf.call(t,u))&&!(o&&(u=="length"||s&&(u=="offset"||u=="parent")||i&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||ts(u,d)))&&l.push(u);return l}a(Wa,"arrayLikeKeys");var La=Wa;function qa(t,e){return function(r){return t(e(r))}}a(qa,"overArg");var Va=qa,ff=Va(Object.keys,Object),gf=ff,mf=Object.prototype,hf=mf.hasOwnProperty;function Ga(t){if(!Ca(t))return gf(t);var e=[];for(var r in Object(t))hf.call(t,r)&&r!="constructor"&&e.push(r);return e}a(Ga,"baseKeys");var yf=Ga;function Ja(t){return Aa(t)?La(t):yf(t)}a(Ja,"keys");var ss=Ja;function Ya(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}a(Ya,"nativeKeysIn");var vf=Ya,_f=Object.prototype,Tf=_f.hasOwnProperty;function Xa(t){if(!at(t))return vf(t);var e=Ca(t),r=[];for(var n in t)n=="constructor"&&(e||!Tf.call(t,n))||r.push(n);return r}a(Xa,"baseKeysIn");var bf=Xa;function Qa(t){return Aa(t)?La(t,!0):bf(t)}a(Qa,"keysIn");var wf=Qa,Pf=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,xf=/^\w*$/;function eo(t,e){if(ve(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||Qn(t)?!0:xf.test(t)||!Pf.test(t)||e!=null&&t in Object(e)}a(eo,"isKey");var is=eo,kf=Fe(Object,"create"),Ht=kf;function to(){this.__data__=Ht?Ht(null):{},this.size=0}a(to,"hashClear");var Sf=to;function ro(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}a(ro,"hashDelete");var Ef=ro,Of="__lodash_hash_undefined__",Zf=Object.prototype,If=Zf.hasOwnProperty;function no(t){var e=this.__data__;if(Ht){var r=e[t];return r===Of?void 0:r}return If.call(e,t)?e[t]:void 0}a(no,"hashGet");var Bf=no,Af=Object.prototype,Rf=Af.hasOwnProperty;function so(t){var e=this.__data__;return Ht?e[t]!==void 0:Rf.call(e,t)}a(so,"hashHas");var Cf=so,Df="__lodash_hash_undefined__";function io(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Ht&&e===void 0?Df:e,this}a(io,"hashSet");var Hf=io;function We(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(We,"Hash");We.prototype.clear=Sf;We.prototype.delete=Ef;We.prototype.get=Bf;We.prototype.has=Cf;We.prototype.set=Hf;var li=We;function ao(){this.__data__=[],this.size=0}a(ao,"listCacheClear");var Nf=ao;function oo(t,e){for(var r=t.length;r--;)if(rs(t[r][0],e))return r;return-1}a(oo,"assocIndexOf");var qr=oo,Mf=Array.prototype,$f=Mf.splice;function lo(t){var e=this.__data__,r=qr(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():$f.call(e,r,1),--this.size,!0}a(lo,"listCacheDelete");var jf=lo;function co(t){var e=this.__data__,r=qr(e,t);return r<0?void 0:e[r][1]}a(co,"listCacheGet");var Kf=co;function uo(t){return qr(this.__data__,t)>-1}a(uo,"listCacheHas");var Uf=uo;function po(t,e){var r=this.__data__,n=qr(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this}a(po,"listCacheSet");var zf=po;function Le(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(Le,"ListCache");Le.prototype.clear=Nf;Le.prototype.delete=jf;Le.prototype.get=Kf;Le.prototype.has=Uf;Le.prototype.set=zf;var Vr=Le,Ff=Fe(_e,"Map"),Nt=Ff;function fo(){this.size=0,this.__data__={hash:new li,map:new(Nt||Vr),string:new li}}a(fo,"mapCacheClear");var Wf=fo;function go(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}a(go,"isKeyable");var Lf=go;function mo(t,e){var r=t.__data__;return Lf(e)?r[typeof e=="string"?"string":"hash"]:r.map}a(mo,"getMapData");var Gr=mo;function ho(t){var e=Gr(this,t).delete(t);return this.size-=e?1:0,e}a(ho,"mapCacheDelete");var qf=ho;function yo(t){return Gr(this,t).get(t)}a(yo,"mapCacheGet");var Vf=yo;function vo(t){return Gr(this,t).has(t)}a(vo,"mapCacheHas");var Gf=vo;function _o(t,e){var r=Gr(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this}a(_o,"mapCacheSet");var Jf=_o;function qe(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(qe,"MapCache");qe.prototype.clear=Wf;qe.prototype.delete=qf;qe.prototype.get=Vf;qe.prototype.has=Gf;qe.prototype.set=Jf;var Jr=qe,Yf="Expected a function";function Yr(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(Yf);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||Jr),r}a(Yr,"memoize");Yr.Cache=Jr;var Xf=Yr,Qf=500;function To(t){var e=Xf(t,function(n){return r.size===Qf&&r.clear(),n}),r=e.cache;return e}a(To,"memoizeCapped");var eg=To,tg=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,rg=/\\(\\)?/g,ng=eg(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(tg,function(r,n,s,i){e.push(s?i.replace(rg,"$1"):n||r)}),e}),sg=ng;function bo(t){return t==null?"":Xu(t)}a(bo,"toString");var ig=bo;function wo(t,e){return ve(t)?t:is(t,e)?[t]:sg(ig(t))}a(wo,"castPath");var Xr=wo,ag=1/0;function Po(t){if(typeof t=="string"||Qn(t))return t;var e=t+"";return e=="0"&&1/t==-ag?"-0":e}a(Po,"toKey");var Ut=Po;function xo(t,e){e=Xr(e,t);for(var r=0,n=e.length;t!=null&&r<n;)t=t[Ut(e[r++])];return r&&r==n?t:void 0}a(xo,"baseGet");var as=xo;function ko(t,e,r){var n=t==null?void 0:as(t,e);return n===void 0?r:n}a(ko,"get");var og=ko;function So(t,e){for(var r=-1,n=e.length,s=t.length;++r<n;)t[s+r]=e[r];return t}a(So,"arrayPush");var Eo=So,lg=Va(Object.getPrototypeOf,Object),Oo=lg,cg="[object Object]",dg=Function.prototype,ug=Object.prototype,Zo=dg.toString,pg=ug.hasOwnProperty,fg=Zo.call(Object);function Io(t){if(!Me(t)||Ue(t)!=cg)return!1;var e=Oo(t);if(e===null)return!0;var r=pg.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&Zo.call(r)==fg}a(Io,"isPlainObject");var ci=Io;function Bo(){this.__data__=new Vr,this.size=0}a(Bo,"stackClear");var gg=Bo;function Ao(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}a(Ao,"stackDelete");var mg=Ao;function Ro(t){return this.__data__.get(t)}a(Ro,"stackGet");var hg=Ro;function Co(t){return this.__data__.has(t)}a(Co,"stackHas");var yg=Co,vg=200;function Do(t,e){var r=this.__data__;if(r instanceof Vr){var n=r.__data__;if(!Nt||n.length<vg-1)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Jr(n)}return r.set(t,e),this.size=r.size,this}a(Do,"stackSet");var _g=Do;function Ve(t){var e=this.__data__=new Vr(t);this.size=e.size}a(Ve,"Stack");Ve.prototype.clear=gg;Ve.prototype.delete=mg;Ve.prototype.get=hg;Ve.prototype.has=yg;Ve.prototype.set=_g;var Qt=Ve;function Ho(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(Ho,"arrayFilter");var Tg=Ho;function No(){return[]}a(No,"stubArray");var Mo=No,bg=Object.prototype,wg=bg.propertyIsEnumerable,di=Object.getOwnPropertySymbols,Pg=di?function(t){return t==null?[]:(t=Object(t),Tg(di(t),function(e){return wg.call(t,e)}))}:Mo,$o=Pg,xg=Object.getOwnPropertySymbols,kg=xg?function(t){for(var e=[];t;)Eo(e,$o(t)),t=Oo(t);return e}:Mo,Sg=kg;function jo(t,e,r){var n=e(t);return ve(t)?n:Eo(n,r(t))}a(jo,"baseGetAllKeys");var Ko=jo;function Uo(t){return Ko(t,ss,$o)}a(Uo,"getAllKeys");var ui=Uo;function zo(t){return Ko(t,wf,Sg)}a(zo,"getAllKeysIn");var Eg=zo,Og=Fe(_e,"DataView"),zn=Og,Zg=Fe(_e,"Promise"),Fn=Zg,Ig=Fe(_e,"Set"),Wn=Ig,pi="[object Map]",Bg="[object Object]",fi="[object Promise]",gi="[object Set]",mi="[object WeakMap]",hi="[object DataView]",Ag=ze(zn),Rg=ze(Nt),Cg=ze(Fn),Dg=ze(Wn),Hg=ze(Kn),Ae=Ue;(zn&&Ae(new zn(new ArrayBuffer(1)))!=hi||Nt&&Ae(new Nt)!=pi||Fn&&Ae(Fn.resolve())!=fi||Wn&&Ae(new Wn)!=gi||Kn&&Ae(new Kn)!=mi)&&(Ae=a(function(t){var e=Ue(t),r=e==Bg?t.constructor:void 0,n=r?ze(r):"";if(n)switch(n){case Ag:return hi;case Rg:return pi;case Cg:return fi;case Dg:return gi;case Hg:return mi}return e},"getTag"));var yi=Ae,Ng=_e.Uint8Array,vi=Ng,Mg="__lodash_hash_undefined__";function Fo(t){return this.__data__.set(t,Mg),this}a(Fo,"setCacheAdd");var $g=Fo;function Wo(t){return this.__data__.has(t)}a(Wo,"setCacheHas");var jg=Wo;function Mt(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new Jr;++e<r;)this.add(t[e])}a(Mt,"SetCache");Mt.prototype.add=Mt.prototype.push=$g;Mt.prototype.has=jg;var Kg=Mt;function Lo(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(Lo,"arraySome");var Ug=Lo;function qo(t,e){return t.has(e)}a(qo,"cacheHas");var zg=qo,Fg=1,Wg=2;function Vo(t,e,r,n,s,i){var o=r&Fg,l=t.length,d=e.length;if(l!=d&&!(o&&d>l))return!1;var u=i.get(t),g=i.get(e);if(u&&g)return u==e&&g==t;var h=-1,T=!0,Z=r&Wg?new Kg:void 0;for(i.set(t,e),i.set(e,t);++h<l;){var k=t[h],K=e[h];if(n)var F=o?n(K,k,h,e,t,i):n(k,K,h,t,e,i);if(F!==void 0){if(F)continue;T=!1;break}if(Z){if(!Ug(e,function(Q,ie){if(!zg(Z,ie)&&(k===Q||s(k,Q,r,n,i)))return Z.push(ie)})){T=!1;break}}else if(!(k===K||s(k,K,r,n,i))){T=!1;break}}return i.delete(t),i.delete(e),T}a(Vo,"equalArrays");var Go=Vo;function Jo(t){var e=-1,r=Array(t.size);return t.forEach(function(n,s){r[++e]=[s,n]}),r}a(Jo,"mapToArray");var Lg=Jo;function Yo(t){var e=-1,r=Array(t.size);return t.forEach(function(n){r[++e]=n}),r}a(Yo,"setToArray");var qg=Yo,Vg=1,Gg=2,Jg="[object Boolean]",Yg="[object Date]",Xg="[object Error]",Qg="[object Map]",em="[object Number]",tm="[object RegExp]",rm="[object Set]",nm="[object String]",sm="[object Symbol]",im="[object ArrayBuffer]",am="[object DataView]",_i=xe?xe.prototype:void 0,Cn=_i?_i.valueOf:void 0;function Xo(t,e,r,n,s,i,o){switch(r){case am:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case im:return!(t.byteLength!=e.byteLength||!i(new vi(t),new vi(e)));case Jg:case Yg:case em:return rs(+t,+e);case Xg:return t.name==e.name&&t.message==e.message;case tm:case nm:return t==e+"";case Qg:var l=Lg;case rm:var d=n&Vg;if(l||(l=qg),t.size!=e.size&&!d)return!1;var u=o.get(t);if(u)return u==e;n|=Gg,o.set(t,e);var g=Go(l(t),l(e),n,s,i,o);return o.delete(t),g;case sm:if(Cn)return Cn.call(t)==Cn.call(e)}return!1}a(Xo,"equalByTag");var om=Xo,lm=1,cm=Object.prototype,dm=cm.hasOwnProperty;function Qo(t,e,r,n,s,i){var o=r&lm,l=ui(t),d=l.length,u=ui(e),g=u.length;if(d!=g&&!o)return!1;for(var h=d;h--;){var T=l[h];if(!(o?T in e:dm.call(e,T)))return!1}var Z=i.get(t),k=i.get(e);if(Z&&k)return Z==e&&k==t;var K=!0;i.set(t,e),i.set(e,t);for(var F=o;++h<d;){T=l[h];var Q=t[T],ie=e[T];if(n)var ue=o?n(ie,Q,T,e,t,i):n(Q,ie,T,t,e,i);if(!(ue===void 0?Q===ie||s(Q,ie,r,n,i):ue)){K=!1;break}F||(F=T=="constructor")}if(K&&!F){var ae=t.constructor,ee=e.constructor;ae!=ee&&"constructor"in t&&"constructor"in e&&!(typeof ae=="function"&&ae instanceof ae&&typeof ee=="function"&&ee instanceof ee)&&(K=!1)}return i.delete(t),i.delete(e),K}a(Qo,"equalObjects");var um=Qo,pm=1,Ti="[object Arguments]",bi="[object Array]",Xt="[object Object]",fm=Object.prototype,wi=fm.hasOwnProperty;function el(t,e,r,n,s,i){var o=ve(t),l=ve(e),d=o?bi:yi(t),u=l?bi:yi(e);d=d==Ti?Xt:d,u=u==Ti?Xt:u;var g=d==Xt,h=u==Xt,T=d==u;if(T&&Un(t)){if(!Un(e))return!1;o=!0,g=!1}if(T&&!g)return i||(i=new Qt),o||Fa(t)?Go(t,e,r,n,s,i):om(t,e,d,r,n,s,i);if(!(r&pm)){var Z=g&&wi.call(t,"__wrapped__"),k=h&&wi.call(e,"__wrapped__");if(Z||k){var K=Z?t.value():t,F=k?e.value():e;return i||(i=new Qt),s(K,F,r,n,i)}}return T?(i||(i=new Qt),um(t,e,r,n,s,i)):!1}a(el,"baseIsEqualDeep");var gm=el;function os(t,e,r,n,s){return t===e?!0:t==null||e==null||!Me(t)&&!Me(e)?t!==t&&e!==e:gm(t,e,r,n,os,s)}a(os,"baseIsEqual");var Qr=os,mm=1,hm=2;function tl(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 d=l[0],u=t[d],g=l[1];if(o&&l[2]){if(u===void 0&&!(d in t))return!1}else{var h=new Qt;if(n)var T=n(u,g,d,t,e,h);if(!(T===void 0?Qr(g,u,mm|hm,n,h):T))return!1}}return!0}a(tl,"baseIsMatch");var ym=tl;function rl(t){return t===t&&!at(t)}a(rl,"isStrictComparable");var nl=rl;function sl(t){for(var e=ss(t),r=e.length;r--;){var n=e[r],s=t[n];e[r]=[n,s,nl(s)]}return e}a(sl,"getMatchData");var vm=sl;function il(t,e){return function(r){return r==null?!1:r[t]===e&&(e!==void 0||t in Object(r))}}a(il,"matchesStrictComparable");var al=il;function ol(t){var e=vm(t);return e.length==1&&e[0][2]?al(e[0][0],e[0][1]):function(r){return r===t||ym(r,t,e)}}a(ol,"baseMatches");var _m=ol;function ll(t,e){return t!=null&&e in Object(t)}a(ll,"baseHasIn");var Tm=ll;function cl(t,e,r){e=Xr(e,t);for(var n=-1,s=e.length,i=!1;++n<s;){var o=Ut(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&&ns(s)&&ts(o,s)&&(ve(t)||Ma(t)))}a(cl,"hasPath");var bm=cl;function dl(t,e){return t!=null&&bm(t,e,Tm)}a(dl,"hasIn");var wm=dl,Pm=1,xm=2;function ul(t,e){return is(t)&&nl(e)?al(Ut(t),e):function(r){var n=og(r,t);return n===void 0&&n===e?wm(r,t):Qr(e,n,Pm|xm)}}a(ul,"baseMatchesProperty");var km=ul;function pl(t){return function(e){return e?.[t]}}a(pl,"baseProperty");var Sm=pl;function fl(t){return function(e){return as(e,t)}}a(fl,"basePropertyDeep");var Em=fl;function gl(t){return is(t)?Sm(Ut(t)):Em(t)}a(gl,"property");var Om=gl;function ml(t){return typeof t=="function"?t:t==null?Qu:typeof t=="object"?ve(t)?km(t[0],t[1]):_m(t):Om(t)}a(ml,"baseIteratee");var ls=ml;function hl(t){return function(e,r,n){for(var s=-1,i=Object(e),o=n(e),l=o.length;l--;){var d=o[t?l:++s];if(r(i[d],d,i)===!1)break}return e}}a(hl,"createBaseFor");var Zm=hl,Im=Zm(),Bm=Im;function yl(t,e){return t&&Bm(t,e,ss)}a(yl,"baseForOwn");var Am=yl;function vl(t,e){return Qr(t,e)}a(vl,"isEqual");var st=vl;function _l(t,e,r){r=typeof r=="function"?r:void 0;var n=r?r(t,e):void 0;return n===void 0?Qr(t,e,void 0,r):!!n}a(_l,"isEqualWith");var Rm=_l;function Tl(t){return t===void 0}a(Tl,"isUndefined");var Pi=Tl;function bl(t,e){var r={};return e=ls(e,3),Am(t,function(n,s,i){Ea(r,s,e(n,s,i))}),r}a(bl,"mapValues");var Cm=bl,Dm="Expected a function";function wl(t){if(typeof t!="function")throw new TypeError(Dm);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(wl,"negate");var Hm=wl;function Pl(t,e,r,n){if(!at(t))return t;e=Xr(e,t);for(var s=-1,i=e.length,o=i-1,l=t;l!=null&&++s<i;){var d=Ut(e[s]),u=r;if(d==="__proto__"||d==="constructor"||d==="prototype")return t;if(s!=o){var g=l[d];u=n?n(g,d,l):void 0,u===void 0&&(u=at(g)?g:ts(e[s+1])?[]:{})}Pp(l,d,u),l=l[d]}return t}a(Pl,"baseSet");var Nm=Pl;function xl(t,e,r){for(var n=-1,s=e.length,i={};++n<s;){var o=e[n],l=as(t,o);r(l,o)&&Nm(i,Xr(o,t),l)}return i}a(xl,"basePickBy");var Mm=xl;function kl(t,e){if(t==null)return{};var r=ma(Eg(t),function(n){return[n]});return e=ls(e),Mm(t,r,function(n,s){return e(n,s[0])})}a(kl,"pickBy");var $m=kl;function Sl(t,e){return $m(t,Hm(ls(e)))}a(Sl,"omitBy");var xi=Sl,jm=a(t=>{let e=t.checks;return e.length===0?"":e.map(Km).join("")},"generateStringChecks"),Km=a(t=>{switch(t.kind){case"min":return`.min(${b(t.value)}, ${b(t.message)})`;case"max":return`.max(${b(t.value)}, ${b(t.message)})`;case"length":return`.length(${b(t.value)}, ${b(t.message)})`;case"email":return`.email(${b(t.message)})`;case"url":return`.url(${b(t.message)})`;case"emoji":return`.emoji(${b(t.message)})`;case"uuid":return`.uuid(${b(t.message)})`;case"cuid":return`.cuid(${b(t.message)})`;case"cuid2":return`.cuid2(${b(t.message)})`;case"ulid":return`.ulid(${b(t.message)})`;case"includes":let e=nt({message:t.message,position:t.position});return`.includes(${b(t.value)}, ${e})`;case"startsWith":return`.startsWith(${b(t.value)}, ${b(t.message)})`;case"endsWith":return`.endsWith(${b(t.value)}, ${b(t.message)})`;case"regex":return`.regex(${String(t.regex)}, ${b(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(${nt({message:t.message,precision:n,offset:t.offset})})`;case"ip":return`.ip(${nt({message:t.message,version:t.version})})`;default:return""}},"_generateStringCheck"),Um=a(t=>{let e=t.checks;return e.length===0?"":e.map(zm).join("")},"generateNumberChecks"),zm=a(t=>{switch(t.kind){case"min":return`.min(${b(t.value)}, ${b(t.message)})`;case"max":return`.max(${b(t.value)}, ${b(t.message)})`;case"int":return`.int(${b(t.message)})`;case"multipleOf":return`.multipleOf(${b(t.value)}, ${b(t.message)})`;case"finite":return`.finite(${b(t.message)})`;default:return""}},"_generateNumberCheck"),Fm=a(t=>{let e=t.checks;return e.length===0?"":e.map(Wm).join("")},"generateBigIntChecks"),Wm=a(t=>{switch(t.kind){case"min":return`.min(${b(t.value)}, ${b(t.message)})`;case"max":return`.max(${b(t.value)}, ${b(t.message)})`;case"multipleOf":return`.multipleOf(${b(t.value)}, ${b(t.message)})`;default:return""}},"_generateBigIntCheck"),Lm=a(t=>{let e=t.checks;return e.length===0?"":e.map(qm).join("")},"generateDateChecks"),qm=a(t=>{switch(t.kind){case"min":return`.min(${ki(t.value)}, ${b(t.message)})`;case"max":return`.max(${ki(t.value)}, ${b(t.message)})`;default:return""}},"_generateDateCheck"),ki=a(t=>`new Date(${t})`,"dateTs"),Vm=a(t=>{let e=[];if(t.exactLength){let{value:r,message:n}=t.exactLength;e.push(`.length(${b(r)}, ${b(n)})`)}if(t.minLength){let{value:r,message:n}=t.minLength;e.push(`.min(${b(r)}, ${b(n)})`)}if(t.maxLength){let{value:r,message:n}=t.maxLength;e.push(`.max(${b(r)}, ${b(n)})`)}return e.join("")},"generateArrayChecks"),Gm=a(t=>{let e=[];if(t.minSize){let{value:r,message:n}=t.minSize;e.push(`.min(${b(r)}, ${b(n)})`)}if(t.maxSize){let{value:r,message:n}=t.maxSize;e.push(`.max(${b(r)}, ${b(n)})`)}return e.join("")},"generateSetChecks");function cs(t){return M(t)}a(cs,"toTypescriptSchema");function M(t){let r=t._def;switch(r.typeName){case p.ZodFirstPartyTypeKind.ZodString:return`z.string()${jm(r)}${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodNumber:return`z.number()${Um(r)}${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodNaN:return`z.nan()${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodBigInt:return`z.bigint()${Fm(r)}${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodBoolean:return`z.boolean()${C(r)}${R(t._def)}`.trim();case p.ZodFirstPartyTypeKind.ZodDate:return`z.date()${Lm(r)}${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodUndefined:return`z.undefined()${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodNull:return`z.null()${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodAny:return`z.any()${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodUnknown:return`z.unknown()${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodNever:return`z.never()${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodVoid:return`z.void()${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodArray:return`z.array(${M(r.type)})${Vm(r)}${C(r)}${R(r)}`;case p.ZodFirstPartyTypeKind.ZodObject:let n=Cm(r.shape(),M),s=t.additionalProperties(),i=s?`.catchall(${M(s)})`:"";return["z.object({",...Object.entries(n).map(([_u,Tu])=>` ${_u}: ${Tu},`),`})${i}${C(r)}${R(r)}`].join(`
16
- `).trim();case p.ZodFirstPartyTypeKind.ZodUnion:return`z.union([${r.options.map(M).join(", ")}])${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:let l=r.options.map(M);return`z.discriminatedUnion(${b(r.discriminator)}, [${l.join(", ")}])${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodIntersection:let u=M(r.left),g=M(r.right);return`z.intersection(${u}, ${g})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodTuple:return`z.tuple([${r.items.map(M).join(", ")}])${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodRecord:let T=M(r.keyType),Z=M(r.valueType);return`z.record(${T}, ${Z})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodMap:let k=M(r.keyType),K=M(r.valueType);return`z.map(${k}, ${K})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodSet:return`z.set(${M(r.valueType)})${Gm(r)}${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodFunction:let F=r.args.items.map(M),Q=F.length?`.args(${F.join(", ")})`:"",ie=M(r.returns);return`z.function()${Q}.returns(${ie})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodLazy:return`z.lazy(() => ${M(r.getter())})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodLiteral:return`z.literal(${b(r.value)})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodEnum:return`z.enum([${r.values.map(b).join(", ")}])${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodEffects:throw new Be(p.ZodFirstPartyTypeKind.ZodEffects);case p.ZodFirstPartyTypeKind.ZodNativeEnum:throw new Be(p.ZodFirstPartyTypeKind.ZodNativeEnum);case p.ZodFirstPartyTypeKind.ZodOptional:return`z.optional(${M(r.innerType)})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodNullable:return`z.nullable(${M(r.innerType)})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodDefault:let ee=nt(r.defaultValue());return`z.default(${M(r.innerType)}, ${ee})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodCatch:throw new Be(p.ZodFirstPartyTypeKind.ZodCatch);case p.ZodFirstPartyTypeKind.ZodPromise:return`z.promise(${M(r.type)})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodBranded:throw new Be(p.ZodFirstPartyTypeKind.ZodBranded);case p.ZodFirstPartyTypeKind.ZodPipeline:throw new Be(p.ZodFirstPartyTypeKind.ZodPipeline);case p.ZodFirstPartyTypeKind.ZodSymbol:throw new Be(p.ZodFirstPartyTypeKind.ZodSymbol);case p.ZodFirstPartyTypeKind.ZodReadonly:return`z.readonly(${M(r.innerType)})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodRef:return`z.ref(${b(r.uri)})${C(r)}${R(r)}`.trim();default:I.assertNever(r)}}a(M,"sUnwrapZod");var R=a(t=>t.description?`.describe(${b(t.description)})`:"","_maybeDescribe"),C=a(t=>`${Jm(t)}${Ym(t)}${Xm(t)}${Qm(t)}${eh(t)}${th(t)}${rh(t)}`,"_addZuiExtensions"),Jm=a(t=>{var e;return(e=t[w])!=null&&e.title?`.title(${b(t[w].title)})`:""},"_maybeTitle"),Ym=a(t=>{var e;return(e=t[w])!=null&&e.displayAs?`.displayAs(${Di({id:t[w].displayAs[0],params:t[w].displayAs[1]})})`:""},"_maybeDisplayAs"),Xm=a(t=>{var e;return(e=t[w])!=null&&e.disabled?`.disabled(${t[w].disabled})`:""},"_maybeDisabled"),Qm=a(t=>{var e;return(e=t[w])!=null&&e.hidden?`.hidden(${t[w].hidden})`:""},"_maybeHidden"),eh=a(t=>{var e;return(e=t[w])!=null&&e.placeholder?`.placeholder(${b(t[w].placeholder)})`:""},"_maybePlaceholder"),th=a(t=>{var e;return(e=t[w])!=null&&e.secret?".secret()":""},"_maybeSecret"),rh=a(t=>{var e;let r=["title","tooltip","displayAs","disabled","hidden","placeholder","secret","coerce"],n=Object.entries((e=t[w])!=null?e:{}).filter(([s])=>!r.includes(s));return n.length>0?`.metadata(${Di(Object.fromEntries(n))})`:""},"_maybeSetMetadata"),nh=a(t=>{let e={type:"number",description:t.description,"x-zui":t._def["x-zui"]};t._def[w]&&(e[w]=t._def[w]);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"),El="\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}",Ol="(([+-]\\d{2}(:?\\d{2})?)|Z)",sh="Z",Zl="(\\.\\d+)?",Ln="\\.\\d{",ih="}",Il=a(t=>{let e=t.precision?Ln+t.precision+ih:t.precision===0?"":Zl,r=t.offset?Ol:sh;return new RegExp(`^${El}${e}${r}$`)},"generateDatetimeRegex"),ah=a(t=>({precision:oh(t),offset:t.endsWith(`${Ol}$`)}),"extractPrecisionAndOffset"),oh=a(t=>{let e=t.slice(1+El.length);return e.startsWith(Zl)?null:e.startsWith(Ln)?parseInt(e.slice(Ln.length)):0},"_extractPrecision"),Dt={};zr(Dt,{escapeSpecialChars:()=>lh});var lh=a(t=>t.replaceAll(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeSpecialChars");function ds(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage=f(c({},t.errorMessage),{[e]:r}))}a(ds,"addErrorMessage");function D(t,e,r,n,s){t[e]=r,ds(t,e,n,s)}a(D,"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 us(t,e){let r=c({type:"string"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{});function n(s){return e.patternStrategy==="escape"?Dt.escapeSpecialChars(s):s}if(a(n,"processPattern"),t.checks)for(let s of t.checks)switch(s.kind){case"min":D(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,s.value):s.value,s.message,e);break;case"max":D(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":Ie(r,"email",s.message,e);break;case"format:idn-email":Ie(r,"idn-email",s.message,e);break;case"pattern:zod":ge(r,j.email,s.message,e);break}break;case"url":Ie(r,"uri",s.message,e);break;case"uuid":Ie(r,"uuid",s.message,e);break;case"regex":ge(r,s.regex.source,s.message,e);break;case"cuid":ge(r,j.cuid,s.message,e);break;case"cuid2":ge(r,j.cuid2,s.message,e);break;case"startsWith":ge(r,"^"+n(s.value),s.message,e);break;case"endsWith":ge(r,n(s.value)+"$",s.message,e);break;case"datetime":Ie(r,"date-time",s.message,e);break;case"length":D(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,s.value):s.value,s.message,e),D(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,s.value):s.value,s.message,e);break;case"includes":{ge(r,n(s.value),s.message,e);break}case"ip":{s.version!=="v6"&&Ie(r,"ipv4",s.message,e),s.version!=="v4"&&Ie(r,"ipv6",s.message,e);break}case"emoji":ge(r,j.emoji,s.message,e);break;case"ulid":{ge(r,j.ulid,s.message,e);break}case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}a(us,"parseStringDef");var Ie=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}}))):D(t,"format",e,r,n)},"addFormat"),ge=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}}))):D(t,"pattern",e,r,n)},"addPattern"),ch=a(t=>{let e={type:"string",description:t.description,"x-zui":t._def["x-zui"]};t._def[w]&&(e[w]=t._def[w]);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=Il(r).source,e[w]=f(c({},e[w]),{precision:r.precision,offset:r.offset});break;case"url":e.format="uri";break;case"endsWith":e.pattern=`${Dt.escapeSpecialChars(r.value)}$`;break;case"startsWith":e.pattern=`^${Dt.escapeSpecialChars(r.value)}`;break;case"includes":let n=r.position&&r.position>=1?`^(?:.{${r.position}}).*`:"";e.pattern=`${n}${Dt.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 Wi({zodType:p.ZodFirstPartyTypeKind.ZodString,checkKind:r.kind})}return e},"zodStringToJsonString"),dh=a((t,e)=>{let r={type:"array",description:t.description,items:e(t._def.type),"x-zui":t._def["x-zui"]};return t._def[w]&&(r[w]=t._def[w]),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"),uh=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[w]&&(r[w]=t._def[w]),t._def.minSize&&(r.minItems=t._def.minSize.value),t._def.maxSize&&(r.maxItems=t._def.maxSize.value),r},"zodSetToJsonSet"),ph=a((t,e)=>{let r={type:"array",description:t.description,items:t._def.items.map(n=>e(n))};return t._def[w]&&(r[w]=t._def[w]),t._def.rest&&(r.additionalItems=e(t._def.rest)),r},"zodTupleToJsonTuple");function q(t){let e=t,r=e._def;switch(r.typeName){case p.ZodFirstPartyTypeKind.ZodString:return ch(e);case p.ZodFirstPartyTypeKind.ZodNumber:return nh(e);case p.ZodFirstPartyTypeKind.ZodNaN:throw new te(p.ZodFirstPartyTypeKind.ZodNaN);case p.ZodFirstPartyTypeKind.ZodBigInt:throw new te(p.ZodFirstPartyTypeKind.ZodBigInt,{suggestedAlternative:"serialize bigint to string"});case p.ZodFirstPartyTypeKind.ZodBoolean:return{type:"boolean",description:r.description,"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodDate:throw new te(p.ZodFirstPartyTypeKind.ZodDate,{suggestedAlternative:"use z.string().datetime() instead"});case p.ZodFirstPartyTypeKind.ZodUndefined:return Dn(r);case p.ZodFirstPartyTypeKind.ZodNull:return Hn(r);case p.ZodFirstPartyTypeKind.ZodAny:return{description:r.description,"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodUnknown:return{description:r.description,"x-zui":f(c({},r["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodUnknown}})};case p.ZodFirstPartyTypeKind.ZodNever:return{not:!0,description:r.description,"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodVoid:throw new te(p.ZodFirstPartyTypeKind.ZodVoid);case p.ZodFirstPartyTypeKind.ZodArray:return dh(e,q);case p.ZodFirstPartyTypeKind.ZodObject:let n=Object.entries(r.shape()),s=n.filter(([g,h])=>!h.isOptional()),i=s.length?s.map(([g])=>g):void 0,o=n.map(([g,h])=>[g,h.mandatory()]).map(([g,h])=>[g,q(h)]),l=!1;return r.unknownKeys instanceof p.ZodType?l=q(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 p.ZodFirstPartyTypeKind.ZodUnion:return{description:r.description,anyOf:r.options.map(g=>q(g)),"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:return{description:r.description,anyOf:r.options.map(g=>q(g)),"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodIntersection:let d=q(r.left),u=q(r.right);return"additionalProperties"in d&&delete d.additionalProperties,"additionalProperties"in u&&delete u.additionalProperties,{description:r.description,allOf:[d,u],"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodTuple:return ph(e,q);case p.ZodFirstPartyTypeKind.ZodRecord:return{type:"object",description:r.description,additionalProperties:q(r.valueType),"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodMap:throw new te(p.ZodFirstPartyTypeKind.ZodMap);case p.ZodFirstPartyTypeKind.ZodSet:return uh(e,q);case p.ZodFirstPartyTypeKind.ZodFunction:throw new te(p.ZodFirstPartyTypeKind.ZodFunction);case p.ZodFirstPartyTypeKind.ZodLazy:throw new te(p.ZodFirstPartyTypeKind.ZodLazy);case p.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 Hn(r);if(r.value===void 0)return Dn(r);{p.util.assertEqual(!0);let g=typeof r.value;throw new Wr(`Unsupported literal type: "${g}"`)}case p.ZodFirstPartyTypeKind.ZodEnum:return{type:"string",description:r.description,enum:r.values,"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodEffects:throw new te(p.ZodFirstPartyTypeKind.ZodEffects);case p.ZodFirstPartyTypeKind.ZodNativeEnum:throw new te(p.ZodFirstPartyTypeKind.ZodNativeEnum);case p.ZodFirstPartyTypeKind.ZodOptional:return{description:r.description,anyOf:[q(r.innerType),Dn()],"x-zui":f(c({},r["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodOptional}})};case p.ZodFirstPartyTypeKind.ZodNullable:return{anyOf:[q(r.innerType),Hn()],"x-zui":f(c({},r["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodNullable}})};case p.ZodFirstPartyTypeKind.ZodDefault:return f(c({},q(r.innerType)),{default:r.defaultValue()});case p.ZodFirstPartyTypeKind.ZodCatch:throw new te(p.ZodFirstPartyTypeKind.ZodCatch);case p.ZodFirstPartyTypeKind.ZodPromise:throw new te(p.ZodFirstPartyTypeKind.ZodPromise);case p.ZodFirstPartyTypeKind.ZodBranded:throw new te(p.ZodFirstPartyTypeKind.ZodBranded);case p.ZodFirstPartyTypeKind.ZodPipeline:throw new te(p.ZodFirstPartyTypeKind.ZodPipeline);case p.ZodFirstPartyTypeKind.ZodSymbol:throw new te(p.ZodFirstPartyTypeKind.ZodPipeline);case p.ZodFirstPartyTypeKind.ZodReadonly:return f(c({},q(r.innerType)),{readOnly:!0});case p.ZodFirstPartyTypeKind.ZodRef:return{$ref:r.uri,description:r.description,"x-zui":r["x-zui"]};default:p.util.assertNever(r)}}a(q,"toJSONSchema");var Dn=a(t=>({not:!0,description:t?.description,"x-zui":f(c({},t?.["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodUndefined}})}),"undefinedSchema"),Hn=a(t=>({type:"null",description:t?.description,"x-zui":t?.["x-zui"]}),"nullSchema"),Bl=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(Bl,"ParseInputLazyPath");var oe=Bl,Si=a((t,e)=>{if(lt(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 pe(t.common.issues);return this._error=r,this._error}}},"handleResult"),Al=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 he(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:he(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new re,ctx:{common:e.parent.common,data:e.data,parsedType:he(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(jt(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:he(e)},i=this._parseSync({data:e,path:s.path,parent:s});return Si(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:he(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(jt(s)?s:Promise.resolve(s));return Si(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:m.custom},n(s))),"setError");return typeof Promise<"u"&&o instanceof Promise?o.then(d=>d?!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 Se({schema:this,typeName:"ZodEffects",effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ye.create(this,this._def)}nullable(){return $e.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return dt.create(this,this._def)}promise(){return Wt.create(this,this._def)}mandatory(){return this}or(e){return fn.create([this,e],this._def)}and(e){return an.create(this,e,this._def)}transform(e){return new Se(f(c({},S(this._def)),{schema:this,typeName:"ZodEffects",effect:{type:"transform",transform:e}}))}default(e){let r=typeof e=="function"?e:()=>e;return new zt(f(c({},S(this._def)),{innerType:this,defaultValue:r,typeName:"ZodDefault"}))}brand(){return new rn(c({typeName:"ZodBranded",type:this},S(this._def)))}catch(e){let r=typeof e=="function"?e:()=>e;return new nn(f(c({},S(this._def)),{innerType:this,catchValue:r,typeName:"ZodCatch"}))}describe(e){let r=this.clone();return r._metadataRoot._def.description=e,r}pipe(e){return pn.create(this,e)}readonly(){return Lt.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=w])!=null||(r[n]={});for(let[l,d]of Object.entries(e))o._def[w]=f(c({},o._def[w]),{[l]:d});return i}getMetadata(){return c({},this._metadataRoot._def[w])}setMetadata(e){this._metadataRoot._def[w]=c({},e)}get ui(){return c({},this._metadataRoot._def[w])}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 q(this)}toTypescriptType(e){return Xn(this,e)}toTypescriptSchema(){return cs(this)}naked(){return this}};a(Al,"ZodType");var O=Al,ps=(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))(ps||{}),I;(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")})(I||(I={}));var lr;(t=>{t.mergeShapes=a((e,r)=>c(c({},e),r),"mergeShapes")})(lr||(lr={}));var _=I.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),he=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 S(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s,supportsExtensions:i,[w]: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(([u])=>u!=="secret"||i?.includes("secret"))):void 0;return e?{errorMap:e,description:s,[w]:l}:{errorMap:a((u,g)=>u.code!=="invalid_type"?{message:g.defaultError}:typeof g.data>"u"?{message:n??g.defaultError}:{message:r??g.defaultError},"customMap"),description:s,[w]:l}}a(S,"processCreateParams");var fs=a((t,e)=>{let r;switch(t.code){case m.invalid_type:t.received===_.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case m.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,I.jsonStringifyReplacer)}`;break;case m.unrecognized_keys:r=`Unrecognized key(s) in object: ${I.joinValues(t.keys,", ")}`;break;case m.invalid_union:r="Invalid input";break;case m.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${I.joinValues(t.options)}`;break;case m.invalid_enum_value:r=`Invalid enum value. Expected ${I.joinValues(t.options)}, received '${t.received}'`;break;case m.invalid_arguments:r="Invalid function arguments";break;case m.invalid_return_type:r="Invalid function return type";break;case m.invalid_date:r="Invalid date";break;case m.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}"`:I.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case m.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 m.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 m.custom:r="Invalid input";break;case m.invalid_intersection_types:r="Intersection results could not be merged";break;case m.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case m.not_finite:r="Number must be finite";break;case m.unresolved_reference:r="Unresolved reference";break;default:r=e.defaultError,I.assertNever(t)}return{message:r}},"errorMap"),Ei=fs,m=I.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"]),Rl=a(t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),cr=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,d=0;for(;d<o.path.length;){let u=o.path[d];d===o.path.length-1?(l[u]=l[u]||{_errors:[]},l[u]._errors.push(r(o))):l[u]=l[u]||{_errors:[]},l=l[u],d++}}},"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,I.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(cr,"ZodError");cr.create=a(t=>new cr(t),"create");var pe=cr,Dl=fs;function gs(t){Dl=t}a(gs,"setErrorMap");function ot(){return Dl}a(ot,"getErrorMap");var $t=a(t=>{var e;let{data:r,path:n,errorMaps:s,issueData:i}=t,o=[...n,...i.path||[]],l=f(c({},i),{path:o}),d="",u=s.filter(g=>!!g).slice().reverse();for(let g of u)d=g(l,{data:r,defaultError:d}).message;return f(c({},i),{path:o,message:(e=i.message)!=null?e:d})},"makeIssue"),Hl=[];function v(t,e){let r=$t({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ot(),fs].filter(n=>!!n)});t.common.issues.push(r)}a(v,"addIssueToContext");var Nl=class Ml{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 Ml.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(Nl,"ParseStatus");var re=Nl,x=Object.freeze({status:"aborted"}),Ne=a(t=>({status:"dirty",value:t}),"DIRTY"),G=a(t=>({status:"valid",value:t}),"OK"),dr=a(t=>t.status==="aborted","isAborted"),ur=a(t=>t.status==="dirty","isDirty"),lt=a(t=>t.status==="valid","isValid"),jt=a(t=>typeof Promise<"u"&&t instanceof Promise,"isAsync"),P;(t=>{t.errToObj=a(e=>typeof e=="string"?{message:e}:e||{},"errToObj"),t.toString=a(e=>typeof e=="string"?e:e?.message,"toString")})(P||(P={}));var pr=class $l extends O{constructor(){super(...arguments),this._any=!0}_parse(e){return G(e.data)}isEqual(e){return e instanceof $l}};a(pr,"ZodAny");pr.create=a(t=>new pr(c({typeName:"ZodAny"},S(t))),"create");var ct=pr,fr=class Re extends O{dereference(e){return new Re(f(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new Re(f(c({},this._def),{type:this._def.type.clone()}))}isEqual(e){var r,n,s,i,o,l;return e instanceof Re?st((r=this._def.exactLength)==null?void 0:r.value,(n=e._def.exactLength)==null?void 0:n.value)&&st((s=this._def.maxLength)==null?void 0:s.value,(i=e._def.maxLength)==null?void 0:i.value)&&st((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:m.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?m.too_big:m.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:m.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:m.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 oe(r,o,r.path,l)))).then(o=>re.mergeArray(n,o));let i=[...r.data].map((o,l)=>s.type._parseSync(new oe(r,o,r.path,l)));return re.mergeArray(n,i)}get element(){return this._def.type}min(e,r){return new Re(f(c({},this._def),{minLength:{value:e,message:P.toString(r)}}))}max(e,r){return new Re(f(c({},this._def),{maxLength:{value:e,message:P.toString(r)}}))}length(e,r){return new Re(f(c({},this._def),{exactLength:{value:e,message:P.toString(r)}}))}nonempty(e){return this.min(1,e)}};a(fr,"ZodArray");fr.create=a((t,e)=>new fr(c({type:t,minLength:null,maxLength:null,exactLength:null,typeName:"ZodArray"},S(e))),"create");var dt=fr,fh=a((t,e)=>jl(t,e,new WeakSet),"isEqual"),jl=a((t,e,r)=>Rm(t,e,gh(r)),"_isEqualWithVisitedTracking"),gh=a(t=>(e,r)=>{if(ci(e)&&!t.has(e)&&ci(r)&&!t.has(r)){let n=xi(e,Pi),s=xi(r,Pi);return t.add(n).add(s).add(e).add(r),jl(n,s,t)}},"_customizerWithVisitedTracking"),mh={compare:fh},Kl=class{constructor(e=[],r={}){this._options=c(c({},mh),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(Kl,"CustomSet");var U=Kl,gr=class er 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:m.invalid_type,expected:_.bigint,received:i.parsedType}),x}let n,s=new re;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:m.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:m.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:m.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):I.assertNever(i);return{status:s.value,value:e.data}}isEqual(e){if(!(e instanceof er)||this._def.coerce!==e._def.coerce)return!1;let r=new U(this._def.checks),n=new U(e._def.checks);return r.isEqual(n)}gte(e,r){return this.setLimit("min",e,!0,P.toString(r))}gt(e,r){return this.setLimit("min",e,!1,P.toString(r))}lte(e,r){return this.setLimit("max",e,!0,P.toString(r))}lt(e,r){return this.setLimit("max",e,!1,P.toString(r))}setLimit(e,r,n,s){return new er(f(c({},this._def),{checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:P.toString(s)}]}))}_addCheck(e){return new er(f(c({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:P.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:P.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:P.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:P.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:P.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(gr,"ZodBigInt");gr.create=a(t=>{var e;return new gr(c({checks:[],typeName:"ZodBigInt",coerce:(e=t?.coerce)!=null?e:!1},S(t)))},"create");var en=gr,mr=class Ul 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:m.invalid_type,expected:_.boolean,received:n.parsedType}),x}return G(e.data)}isEqual(e){return e instanceof Ul?this._def.coerce===e._def.coerce:!1}};a(mr,"ZodBoolean");mr.create=a(t=>new mr(c({typeName:"ZodBoolean",coerce:t?.coerce||!1},S(t))),"create");var tn=mr,zl=Symbol("zod_brand"),Fl=class bt extends O{dereference(e){return new bt(f(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new bt(f(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 bt?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}mandatory(){return new bt(f(c({},this._def),{type:this._def.type.mandatory()}))}};a(Fl,"ZodBranded");var rn=Fl,hr=class wt extends O{_parse(e){let{ctx:r}=this._processInputParams(e),n=f(c({},r),{common:f(c({},r.common),{issues:[]})}),s=this._def.innerType._parse({data:n.data,path:n.path,parent:c({},n)});return jt(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new pe(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new pe(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}isEqual(e){return e instanceof wt?this._def.innerType.isEqual(e._def.innerType)&&I.compareFunctions(this._def.catchValue,e._def.catchValue):!1}dereference(e){return new wt(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new wt(f(c({},this._def),{innerType:this._def.innerType.clone()}))}naked(){return this._def.innerType.naked()}mandatory(){return new wt(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(hr,"ZodCatch");hr.create=a((t,e)=>new hr(c({innerType:t,typeName:"ZodCatch",catchValue:typeof e.catch=="function"?e.catch:()=>e.catch},S(e))),"create");var nn=hr,ms=a((t,e={},r)=>t?ct.create().superRefine((n,s)=>{var i,o;if(!t(n)){let l=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,d=(o=(i=l.fatal)!=null?i:r)!=null?o:!0,u=typeof l=="string"?{message:l}:l;s.addIssue(f(c({code:"custom"},u),{fatal:d}))}}):ct.create(),"custom"),yr=class qn 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:m.invalid_type,expected:_.date,received:i.parsedType}),x}if(isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return v(i,{code:m.invalid_date}),x}let n=new re,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:m.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:m.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):I.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new qn(f(c({},this._def),{checks:[...this._def.checks,e]}))}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:P.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:P.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 qn))return!1;let r=new U(this._def.checks),n=new U(e._def.checks);return r.isEqual(n)&&this._def.coerce===e._def.coerce}};a(yr,"ZodDate");yr.create=a(t=>new yr(c({checks:[],coerce:t?.coerce||!1,typeName:"ZodDate"},S(t))),"create");var sn=yr,vr=class Pt 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 Pt(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new Pt(f(c({},this._def),{innerType:this._def.innerType.clone()}))}isEqual(e){return e instanceof Pt?this._def.innerType.isEqual(e._def.innerType)&&st(this._def.defaultValue(),e._def.defaultValue()):!1}unwrap(){return this._def.innerType}naked(){return this._def.innerType.naked()}mandatory(){return new Pt(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(vr,"ZodDefault");vr.create=a((t,e,r)=>new vr(c({innerType:t,typeName:"ZodDefault",defaultValue:typeof e=="function"?e:()=>e},S(r))),"create");var zt=vr,Te=a(t=>Array.from(new Set(t)),"unique"),me=a(t=>t instanceof on?me(t.schema):t instanceof Se?me(t.innerType()):t instanceof ln?[t.value]:t instanceof Ge?t.options:t instanceof cn?I.objectValues(t.enum):t instanceof zt?me(t._def.innerType):t instanceof qt?[void 0]:t instanceof dn?[null]:t instanceof ye?[void 0,...me(t.unwrap())]:t instanceof $e?[null,...me(t.unwrap())]:t instanceof rn||t instanceof Lt?me(t.unwrap()):t instanceof nn?me(t._def.innerType):[],"getDiscriminator"),Wl=class Ce extends O{dereference(e){let r=this.options.map(s=>s.dereference(e)),n=Ce._getOptionsMap(this.discriminator,r);return new Ce(f(c({},this._def),{options:r,optionsMap:n}))}getReferences(){return Te(this.options.flatMap(e=>e.getReferences()))}clone(){let e=this.options.map(r=>r.clone());return new Ce(f(c({},this._def),{options:e}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==_.object)return v(r,{code:m.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:m.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=Ce._getOptionsMap(e,r);return new Ce(c({typeName:"ZodDiscriminatedUnion",discriminator:e,options:r,optionsMap:s},S(n)))}static _getOptionsMap(e,r){let n=new Map;for(let s of r){let i=me(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 Ce)||this._def.discriminator!==e._def.discriminator)return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new U(this._def.options,{compare:r}),s=new U(e._def.options,{compare:r});return n.isEqual(s)}};a(Wl,"ZodDiscriminatedUnion");var hs=Wl;function Ft(t,e){return new Ge(c({values:t,typeName:"ZodEnum"},S(e)))}a(Ft,"createZodEnum");var ys=class tr extends O{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return v(r,{expected:I.joinValues(n),received:r.parsedType,code:m.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:m.invalid_enum_value,options:n}),x}return G(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 tr.create(e,c(c({},this._def),r))}exclude(e,r=this._def){return tr.create(this.options.filter(n=>!e.includes(n)),c(c({},this._def),r))}isEqual(e){if(!(e instanceof tr))return!1;let r=new U(this._def.values),n=new U(e._def.values);return r.isEqual(n)}};a(ys,"ZodEnum");ys.create=Ft;var Ge=ys,Ll=class De 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 De(f(c({},this._def),{args:r,returns:n}))}getReferences(){return Te([...this._def.args.getReferences(),...this._def.returns.getReferences()])}clone(){return new De(f(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:m.invalid_type,expected:_.function,received:r.parsedType}),x;function n(l,d){return $t({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ot(),Ei].filter(u=>!!u),issueData:{code:m.invalid_arguments,argumentsError:d}})}a(n,"makeArgsIssue");function s(l,d){return $t({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ot(),Ei].filter(u=>!!u),issueData:{code:m.invalid_return_type,returnTypeError:d}})}a(s,"makeReturnsIssue");let i={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof Wt){let l=this;return G(async function(...d){let u=new pe([]),g=await l._def.args.parseAsync(d,i).catch(Z=>{throw u.addIssue(n(d,Z)),u}),h=await Reflect.apply(o,this,g);return await l._def.returns._def.type.parseAsync(h,i).catch(Z=>{throw u.addIssue(s(h,Z)),u})})}else{let l=this;return G(function(...d){let u=l._def.args.safeParse(d,i);if(!u.success)throw new pe([n(d,u.error)]);let g=Reflect.apply(o,this,u.data),h=l._def.returns.safeParse(g,i);if(!h.success)throw new pe([s(g,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new De(f(c({},this._def),{args:Ke.create(e).rest(it.create())}))}returns(e){return new De(f(c({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new De(c({args:e||Ke.create([]).rest(it.create()),returns:r||it.create(),typeName:"ZodFunction"},S(n)))}isEqual(e){return e instanceof De&&this._def.args.isEqual(e._def.args)&&this._def.returns.isEqual(e._def.returns)}};a(Ll,"ZodFunction");var vs=Ll;function _r(t,e){let r=he(t),n=he(e);if(t===e)return{valid:!0,data:t};if(r===_.object&&n===_.object){let s=I.objectKeys(e),i=I.objectKeys(t).filter(l=>s.indexOf(l)!==-1),o=c(c({},t),e);for(let l of i){let d=_r(t[l],e[l]);if(!d.valid)return{valid:!1};o[l]=d.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],d=_r(o,l);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return r===_.date&&n===_.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}a(_r,"mergeValues");var Tr=class rr extends O{dereference(e){return new rr(f(c({},this._def),{left:this._def.left.dereference(e),right:this._def.right.dereference(e)}))}getReferences(){return Te([...this._def.left.getReferences(),...this._def.right.getReferences()])}clone(){return new rr(f(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=_r(i.value,o.value);return l.valid?((ur(i)||ur(o))&&r.dirty(),{status:r.value,value:l.data}):(v(n,{code:m.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 rr))return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new U([this._def.left,this._def.right],{compare:r}),s=new U([e._def.left,e._def.right],{compare:r});return n.isEqual(s)}};a(Tr,"ZodIntersection");Tr.create=a((t,e,r)=>new Tr(c({left:t,right:e,typeName:"ZodIntersection"},S(r))),"create");var an=Tr,br=class xt extends O{get schema(){return this._def.getter()}dereference(e){return new xt(f(c({},this._def),{getter:a(()=>this._def.getter().dereference(e),"getter")}))}getReferences(){return this._def.getter().getReferences()}clone(){return new xt(f(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 xt?this._def.getter().isEqual(e._def.getter()):!1}naked(){return this._def.getter().naked()}mandatory(){return new xt(f(c({},this._def),{getter:a(()=>this._def.getter().mandatory(),"getter")}))}};a(br,"ZodLazy");br.create=a((t,e)=>new br(c({getter:t,typeName:"ZodLazy"},S(e))),"create");var on=br,wr=class ql extends O{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return v(r,{received:r.data,code:m.invalid_literal,expected:this._def.value}),x}return{status:"valid",value:e.data}}get value(){return this._def.value}isEqual(e){return e instanceof ql?st(this._def.value,e._def.value):!1}};a(wr,"ZodLiteral");wr.create=a((t,e)=>new wr(c({value:t,typeName:"ZodLiteral"},S(e))),"create");var ln=wr,Pr=class nr 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 nr(f(c({},this._def),{keyType:r,valueType:n}))}getReferences(){return Te([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new nr(f(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:m.invalid_type,expected:_.map,received:n.parsedType}),x;let s=this._def.keyType,i=this._def.valueType,o=[...n.data.entries()].map(([l,d],u)=>({key:s._parse(new oe(n,l,n.path,[u,"key"])),value:i._parse(new oe(n,d,n.path,[u,"value"]))}));if(n.common.async){let l=new Map;return Promise.resolve().then(async()=>{for(let d of o){let u=await d.key,g=await d.value;if(u.status==="aborted"||g.status==="aborted")return x;(u.status==="dirty"||g.status==="dirty")&&r.dirty(),l.set(u.value,g.value)}return{status:r.value,value:l}})}else{let l=new Map;for(let d of o){let u=d.key,g=d.value;if(u.status==="aborted"||g.status==="aborted")return x;(u.status==="dirty"||g.status==="dirty")&&r.dirty(),l.set(u.value,g.value)}return{status:r.value,value:l}}}isEqual(e){return!(!(e instanceof nr)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};a(Pr,"ZodMap");Pr.create=a((t,e,r)=>new Pr(c({valueType:e,keyType:t,typeName:"ZodMap"},S(r))),"create");var _s=Pr,xr=class Vl extends O{_parse(e){if(this._getType(e)!==_.nan){let n=this._getOrReturnCtx(e);return v(n,{code:m.invalid_type,expected:_.nan,received:n.parsedType}),x}return{status:"valid",value:e.data}}isEqual(e){return e instanceof Vl}};a(xr,"ZodNaN");xr.create=a(t=>new xr(c({typeName:"ZodNaN"},S(t))),"create");var Ts=xr,kr=class Gl extends O{_parse(e){let r=I.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==_.string&&n.parsedType!==_.number){let s=I.objectValues(r);return v(n,{expected:I.joinValues(s),received:n.parsedType,code:m.invalid_type}),x}if(r.indexOf(e.data)===-1){let s=I.objectValues(r);return v(n,{received:n.data,code:m.invalid_enum_value,options:s}),x}return G(e.data)}get enum(){return this._def.values}isEqual(e){return e instanceof Gl?st(this._def.values,e._def.values):!1}};a(kr,"ZodNativeEnum");kr.create=a((t,e)=>new kr(c({values:t,typeName:"ZodNativeEnum"},S(e))),"create");var cn=kr,Sr=class Jl extends O{_parse(e){let r=this._getOrReturnCtx(e);return v(r,{code:m.invalid_type,expected:_.never,received:r.parsedType}),x}isEqual(e){return e instanceof Jl}};a(Sr,"ZodNever");Sr.create=a(t=>new Sr(c({typeName:"ZodNever"},S(t))),"create");var ft=Sr,Er=class Yl extends O{_parse(e){if(this._getType(e)!==_.null){let n=this._getOrReturnCtx(e);return v(n,{code:m.invalid_type,expected:_.null,received:n.parsedType}),x}return G(e.data)}isEqual(e){return e instanceof Yl}};a(Er,"ZodNull");Er.create=a(t=>new Er(c({typeName:"ZodNull"},S(t))),"create");var dn=Er,Or=class kt extends O{dereference(e){return new kt(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new kt(f(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)===_.null?G(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof kt?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new kt(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(Or,"ZodNullable");Or.create=a((t,e)=>new Or(c({innerType:t,typeName:"ZodNullable"},S(e))),"create");var $e=Or;function Xl(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(Xl,"floatSafeRemainder");var Zr=class sr 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:m.invalid_type,expected:_.number,received:i.parsedType}),x}let n,s=new re;for(let i of this._def.checks)i.kind==="int"?I.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{code:m.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:m.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:m.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Xl(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),v(n,{code:m.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:m.not_finite,message:i.message}),s.dirty()):I.assertNever(i);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,P.toString(r))}gt(e,r){return this.setLimit("min",e,!1,P.toString(r))}lte(e,r){return this.setLimit("max",e,!0,P.toString(r))}lt(e,r){return this.setLimit("max",e,!1,P.toString(r))}setLimit(e,r,n,s){return new sr(f(c({},this._def),{checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:P.toString(s)}]}))}_addCheck(e){return new sr(f(c({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:P.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:P.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:P.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:P.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:P.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:P.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:P.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:P.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:P.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"&&I.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 sr))return!1;let r=new U(this._def.checks),n=new U(e._def.checks);return r.isEqual(n)}};a(Zr,"ZodNumber");Zr.create=a(t=>new Zr(c({checks:[],typeName:"ZodNumber",coerce:t?.coerce||!1},S(t))),"create");var un=Zr;function He(t){if(t instanceof je){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=ye.create(He(n))}return new je(f(c({},t._def),{shape:a(()=>e,"shape")}))}else return t instanceof dt?new dt(f(c({},t._def),{type:He(t.element)})):t instanceof ye?ye.create(He(t.unwrap())):t instanceof $e?$e.create(He(t.unwrap())):t instanceof Ke?Ke.create(t.items.map(e=>He(e))):t}a(He,"deepPartialify");var ke=class se 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=I.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 se(f(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 Te(r)}clone(){let e={},r=this._def.shape();for(let[n,s]of Object.entries(r))e[n]=s.clone();return new se(f(c({},this._def),{shape:a(()=>e,"shape")}))}_parse(e){if(this._getType(e)!==_.object){let g=this._getOrReturnCtx(e);return v(g,{code:m.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 d=[];for(let g of o){let h=i[g],T=s.data[g];d.push({key:{status:"valid",value:g},value:h._parse(new oe(s,T,s.path,g)),alwaysSet:g in s.data})}let u=this._def.unknownKeys;if(u==="passthrough")for(let g of l)d.push({key:{status:"valid",value:g},value:{status:"valid",value:s.data[g]}});else if(u==="strict")l.length>0&&(v(s,{code:m.unrecognized_keys,keys:l}),n.dirty());else if(u!=="strip")for(let g of l){let h=s.data[g];d.push({key:{status:"valid",value:g},value:u._parse(new oe(s,h,s.path,g)),alwaysSet:g in s.data})}return s.common.async?Promise.resolve().then(async()=>{let g=[];for(let h of d){let T=await h.key;g.push({key:T,value:await h.value,alwaysSet:h.alwaysSet})}return g}).then(g=>re.mergeObjectSync(n,g)):re.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return P.errToObj,new se(c(f(c({},this._def),{unknownKeys:"strict"}),e!==void 0?{errorMap:a((r,n)=>{var s,i,o,l;let d=(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=P.errToObj(e).message)!=null?l:d}:{message:d}},"errorMap")}:{}))}strip(){return new se(f(c({},this._def),{unknownKeys:"strip"}))}passthrough(){return new se(f(c({},this._def),{unknownKeys:"passthrough"}))}additionalProperties(){if(this._def.unknownKeys instanceof O)return this._def.unknownKeys;if(this._def.unknownKeys==="passthrough")return ct.create();if(this._def.unknownKeys==="strict")return ft.create()}extend(e){return new se(f(c({},this._def),{shape:a(()=>c(c({},this._def.shape()),e),"shape")}))}merge(e){return new se({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 se(f(c({},this._def),{unknownKeys:e}))}pick(e){let r={};return I.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new se(f(c({},this._def),{shape:a(()=>r,"shape")}))}omit(e){let r={};return I.objectKeys(this.shape).forEach(n=>{e[n]||(r[n]=this.shape[n])}),new se(f(c({},this._def),{shape:a(()=>r,"shape")}))}deepPartial(){return He(this)}partial(e){let r={};return I.objectKeys(this.shape).forEach(n=>{let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s?.optional()}),new se(f(c({},this._def),{shape:a(()=>r,"shape")}))}required(e){let r={};return I.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof ye;)i=i._def.innerType;r[n]=i}}),new se(f(c({},this._def),{shape:a(()=>r,"shape")}))}keyof(){return Ft(I.objectKeys(this.shape))}isEqual(e){if(!(e instanceof se)||!this._unknownKeysEqual(e))return!1;let r=this._def.shape(),n=e._def.shape(),s=a((l,d)=>l[0]===d[0]&&l[1].isEqual(d[1]),"compare"),i=new U(Object.entries(r),{compare:s}),o=new U(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(ke,"ZodObject");ke.create=a((t,e)=>new ke(c({shape:a(()=>t,"shape"),unknownKeys:"strip",typeName:"ZodObject"},S(e))),"create");ke.strictCreate=a((t,e)=>new ke(c({shape:a(()=>t,"shape"),unknownKeys:"strict",typeName:"ZodObject"},S(e))),"strictCreate");ke.lazycreate=a((t,e)=>new ke(c({shape:t,unknownKeys:"strip",typeName:"ZodObject"},S(e))),"lazycreate");var je=ke,Ir=class ir extends O{dereference(e){return new ir(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new ir(f(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)===_.undefined?G(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof ir?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return this._def.innerType.mandatory()}};a(Ir,"ZodOptional");Ir.create=a((t,e)=>new Ir(c({innerType:t,typeName:"ZodOptional"},S(e))),"create");var ye=Ir,Ql=class St extends O{dereference(e){return new St(f(c({},this._def),{in:this._def.in.dereference(e),out:this._def.out.dereference(e)}))}getReferences(){return Te([...this._def.in.getReferences(),...this._def.out.getReferences()])}clone(){return new St(f(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(),Ne(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 St({in:e,out:r,typeName:"ZodPipeline"})}isEqual(e){return!(!(e instanceof St)||!this._def.in.isEqual(e._def.in)||!this._def.out.isEqual(e._def.out))}};a(Ql,"ZodPipeline");var pn=Ql,Br=class ar extends O{unwrap(){return this._def.type}dereference(e){return new ar(f(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new ar(f(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:m.invalid_type,expected:_.promise,received:r.parsedType}),x;let n=r.parsedType===_.promise?r.data:Promise.resolve(r.data);return G(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}isEqual(e){return e instanceof ar?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}};a(Br,"ZodPromise");Br.create=a((t,e)=>new Br(c({type:t,typeName:"ZodPromise"},S(e))),"create");var Wt=Br,Ar=class Et extends O{dereference(e){return new Et(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new Et(f(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){let r=this._def.innerType._parse(e);return lt(r)&&(r.value=Object.freeze(r.value)),r}unwrap(){return this._def.innerType}isEqual(e){return e instanceof Et?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new Et(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(Ar,"ZodReadonly");Ar.create=a((t,e)=>new Ar(c({innerType:t,typeName:"ZodReadonly"},S(e))),"create");var Lt=Ar,ec=class et 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 et(f(c({},this._def),{keyType:r,valueType:n}))}getReferences(){return Te([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new et(f(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:m.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 oe(n,l,n.path,l)),value:o._parse(new oe(n,n.data[l],n.path,l))});return n.common.async?re.mergeObjectAsync(r,s):re.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof O?new et(c({keyType:e,valueType:r,typeName:"ZodRecord"},S(n))):new et(c({keyType:J.create(),valueType:e,typeName:"ZodRecord"},S(r)))}isEqual(e){return!(!(e instanceof et)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};a(ec,"ZodRecord");var bs=ec,Rr=class tc 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:m.unresolved_reference}),x}isOptional(){return!1}isNullable(){return!1}isEqual(e){return e instanceof tc?this._def.uri===e._def.uri:!1}};a(Rr,"ZodRef");Rr.create=a(t=>new Rr({typeName:"ZodRef",uri:t}),"create");var ws=Rr,Cr=class tt extends O{dereference(e){return new tt(f(c({},this._def),{valueType:this._def.valueType.dereference(e)}))}getReferences(){return this._def.valueType.getReferences()}clone(){return new tt(f(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:m.invalid_type,expected:_.set,received:n.parsedType}),x;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(v(n,{code:m.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:m.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(d){let u=new Set;for(let g of d){if(g.status==="aborted")return x;g.status==="dirty"&&r.dirty(),u.add(g.value)}return{status:r.value,value:u}}a(o,"finalizeSet");let l=[...n.data.values()].map((d,u)=>i._parse(new oe(n,d,n.path,u)));return n.common.async?Promise.all(l).then(d=>o(d)):o(l)}min(e,r){return new tt(f(c({},this._def),{minSize:{value:e,message:P.toString(r)}}))}max(e,r){return new tt(f(c({},this._def),{maxSize:{value:e,message:P.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 tt))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 d=(s=this._def.maxSize)==null?void 0:s.value,u=(i=e._def.maxSize)==null?void 0:i.value;return d!==u?!1:this._def.valueType.isEqual(e._def.valueType)}};a(Cr,"ZodSet");Cr.create=a((t,e)=>new Cr(c({valueType:t,minSize:null,maxSize:null,typeName:"ZodSet"},S(e))),"create");var Ps=Cr,xs=/^c[^\s-]{8,}$/i,ks=/^[a-z][a-z0-9]*$/,Ss=/^[0-9A-HJKMNP-TV-Z]{26}$/,Es=/^[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,Os=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,rc="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",nc=a(t=>t===rc,"isEmojiRegex"),Nn,Zs=/^(((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}))$/,Is=/^(([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 sc(t,e){return!!((e==="v4"||!e)&&Zs.test(t)||(e==="v6"||!e)&&Is.test(t))}a(sc,"isValidIP");var Dr=class rt 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:m.invalid_type,expected:_.string,received:i.parsedType}),x}let n=new re,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:m.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:m.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:m.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):l&&v(s,{code:m.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")Os.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"email",code:m.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")Nn||(Nn=new RegExp(rc,"u")),Nn.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"emoji",code:m.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")Es.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"uuid",code:m.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")xs.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"cuid",code:m.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")ks.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"cuid2",code:m.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")Ss.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"ulid",code:m.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:m.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:m.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:m.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:m.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:m.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?Il(i).test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{code:m.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="ip"?sc(e.data,i.version)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"ip",code:m.invalid_string,message:i.message}),n.dirty()):I.assertNever(i);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),c({validation:r,code:m.invalid_string},P.errToObj(n)))}_addCheck(e){return new rt(f(c({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(c({kind:"email"},P.errToObj(e)))}url(e){return this._addCheck(c({kind:"url"},P.errToObj(e)))}emoji(e){return this._addCheck(c({kind:"emoji"},P.errToObj(e)))}uuid(e){return this._addCheck(c({kind:"uuid"},P.errToObj(e)))}cuid(e){return this._addCheck(c({kind:"cuid"},P.errToObj(e)))}cuid2(e){return this._addCheck(c({kind:"cuid2"},P.errToObj(e)))}ulid(e){return this._addCheck(c({kind:"ulid"},P.errToObj(e)))}ip(e){return this._addCheck(c({kind:"ip"},P.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},P.errToObj(e?.message)))}regex(e,r){return this._addCheck(c({kind:"regex",regex:e},P.errToObj(r)))}includes(e,r){return this._addCheck(c({kind:"includes",value:e,position:r?.position},P.errToObj(r?.message)))}startsWith(e,r){return this._addCheck(c({kind:"startsWith",value:e},P.errToObj(r)))}endsWith(e,r){return this._addCheck(c({kind:"endsWith",value:e},P.errToObj(r)))}min(e,r){return this._addCheck(c({kind:"min",value:e},P.errToObj(r)))}max(e,r){return this._addCheck(c({kind:"max",value:e},P.errToObj(r)))}length(e,r){return this._addCheck(c({kind:"length",value:e},P.errToObj(r)))}nonempty(e){return this.min(1,P.errToObj(e))}trim(){return new rt(f(c({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}secret(){return this._def[w]=f(c({},this._def[w]),{secret:!0}),this}toLowerCase(){return new rt(f(c({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new rt(f(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 rt))return!1;let r=new U(this._def.checks),n=new U(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},S(f(c({},t),{supportsExtensions:["secret"]}))))},"create");var J=Dr,Hr=class ic extends O{_parse(e){if(this._getType(e)!==_.symbol){let n=this._getOrReturnCtx(e);return v(n,{code:m.invalid_type,expected:_.symbol,received:n.parsedType}),x}return G(e.data)}isEqual(e){return e instanceof ic}};a(Hr,"ZodSymbol");Hr.create=a(t=>new Hr(c({typeName:"ZodSymbol"},S(t))),"create");var Bs=Hr,ut=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(f(c({},this._def),{schema:this._def.schema.dereference(e)}))}getReferences(){return this._def.schema.getReferences()}clone(){return new Ot(f(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 d=await this._def.schema._parseAsync({data:l,path:n.path,parent:n});return d.status==="aborted"?x:d.status==="dirty"||r.value==="dirty"?Ne(d.value):d});{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"?Ne(l.value):l}}if(s.type==="refinement"){let o=a(l=>{let d=s.refinement(l,i);if(n.common.async)return Promise.resolve(d);if(d 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(!lt(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=>lt(o)?Promise.resolve(s.transform(o.value,i)).then(l=>({status:r.value,value:l})):o);I.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:I.compareFunctions(this._def.effect.refinement,e._def.effect.refinement):this._def.effect.type==="transform"?e._def.effect.type!=="transform"?!1:I.compareFunctions(this._def.effect.transform,e._def.effect.transform):this._def.effect.type==="preprocess"?e._def.effect.type!=="preprocess"?!1:I.compareFunctions(this._def.effect.transform,e._def.effect.transform):!1}naked(){return this._def.schema.naked()}mandatory(){return new Ot(f(c({},this._def),{schema:this._def.schema.mandatory()}))}};a(ut,"ZodEffects");ut.create=a((t,e,r)=>new ut(c({schema:t,typeName:"ZodEffects",effect:e},S(r))),"create");ut.createWithPreprocess=a((t,e,r)=>new ut(c({schema:e,effect:{type:"preprocess",transform:t},typeName:"ZodEffects"},S(r))),"createWithPreprocess");var Se=ut,Nr=class Zt 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 Zt(f(c({},this._def),{items:r,rest:n}))}getReferences(){return Te([...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 Zt(f(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:m.invalid_type,expected:_.array,received:n.parsedType}),x;if(n.data.length<this._def.items.length)return v(n,{code:m.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:m.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...n.data].map((o,l)=>{let d=this._def.items[l]||this._def.rest;return d?d._parse(new oe(n,o,n.path,l)):null}).filter(o=>!!o);return n.common.async?Promise.all(i).then(o=>re.mergeArray(r,o)):re.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new Zt(f(c({},this._def),{rest:e}))}isEqual(e){if(!(e instanceof Zt)||!this._restEquals(e))return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new U(this._def.items,{compare:r}),s=new U(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},S(e)))},"create");var Ke=Nr,Mr=class ac extends O{_parse(e){if(this._getType(e)!==_.undefined){let n=this._getOrReturnCtx(e);return v(n,{code:m.invalid_type,expected:_.undefined,received:n.parsedType}),x}return G(e.data)}isEqual(e){return e instanceof ac}mandatory(){return ft.create(c({},this._def))}};a(Mr,"ZodUndefined");Mr.create=a(t=>new Mr(c({typeName:"ZodUndefined"},S(t))),"create");var qt=Mr,$r=class It extends O{dereference(e){let r=this._def.options.map(n=>n.dereference(e));return new It(f(c({},this._def),{options:r}))}getReferences(){return Te(this._def.options.reduce((e,r)=>[...e,...r.getReferences()],[]))}clone(){let e=this._def.options.map(r=>r.clone());return new It(f(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 pe(l.ctx.common.issues));return v(r,{code:m.invalid_union,unionErrors:o}),x}if(a(s,"handleResults"),r.common.async)return Promise.all(n.map(async i=>{let o=f(c({},r),{common:f(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 d of n){let u=f(c({},r),{common:f(c({},r.common),{issues:[]}),parent:null}),g=d._parseSync({data:r.data,path:r.path,parent:u});if(g.status==="valid")return g;g.status==="dirty"&&!i&&(i={result:g,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let l=o.map(d=>new pe(d));return v(r,{code:m.invalid_union,unionErrors:l}),x}}get options(){return this._def.options}isEqual(e){if(!(e instanceof It))return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new U([...this._def.options],{compare:r}),s=new U([...e._def.options],{compare:r});return n.isEqual(s)}mandatory(){let e=this._def.options.filter(i=>!(i instanceof qt)).map(i=>i.mandatory()),[r,n,...s]=e;return r?n?new It(f(c({},this._def),{options:[r,n,...s]})):r:ft.create(c({},this._def))}};a($r,"ZodUnion");$r.create=a((t,e)=>new $r(c({options:t,typeName:"ZodUnion"},S(e))),"create");var fn=$r,jr=class oc extends O{constructor(){super(...arguments),this._unknown=!0}_parse(e){return G(e.data)}isEqual(e){return e instanceof oc}};a(jr,"ZodUnknown");jr.create=a(t=>new jr(c({typeName:"ZodUnknown"},S(t))),"create");var it=jr,Kr=class lc extends O{_parse(e){if(this._getType(e)!==_.undefined){let n=this._getOrReturnCtx(e);return v(n,{code:m.invalid_type,expected:_.void,received:n.parsedType}),x}return G(e.data)}isEqual(e){return e instanceof lc}};a(Kr,"ZodVoid");Kr.create=a(t=>new Kr(c({typeName:"ZodVoid"},S(t))),"create");var As=Kr,hh=["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"],Bv=Ge.create(["any","string","number","boolean","object","pattern","date","array","target","time","enum"]),cc=a(t=>J.create().displayAs({id:"variable",params:c({type:t?.type||"any"},t?.params)}),"variable"),dc=a(t=>J.create().displayAs({id:"conversation",params:c({},t?.params)}),"conversation"),uc=a(t=>J.create().displayAs({id:"user",params:c({},t?.params)}),"user"),pc=a(t=>J.create().displayAs({id:"message",params:c({},t?.params)}),"message"),fc=a(t=>J.create().displayAs({id:"agent",params:c({},t?.params)}),"agent"),gc=a(t=>J.create().displayAs({id:"event",params:c({},t?.params)}),"event"),mc=a(t=>J.create().displayAs({id:"table",params:c({},t?.params)}),"table"),hc=a(t=>J.create().displayAs({id:"tablerow",params:c({},t?.params)}),"tablerow"),yc=a(t=>J.create().displayAs({id:"intent",params:c({},t?.params)}),"intent"),vc=a(()=>Ge.create(hh).displayAs({id:"dropdown",params:{}}),"aimodel"),_c=a(t=>J.create().displayAs({id:"datasource",params:c({},t)}),"datasource"),Tc=a(t=>J.create().displayAs({id:"knowledgebase",params:c({},t)}),"knowledgebase"),bc={object:je.lazycreate},wc=a((t,e={message:`Input not instance of ${t.name}`})=>ms(r=>r instanceof t,e),"instanceOfType"),Rs=J.create,Cs=un.create,Pc=Ts.create,xc=en.create,Ds=tn.create,kc=sn.create,Sc=Bs.create,Ec=qt.create,Oc=dn.create,Zc=ct.create,Ic=it.create,Bc=ft.create,Ac=As.create,Rc=dt.create,Cc=je.create,Dc=je.strictCreate,Hc=fn.create,Nc=hs.create,Mc=an.create,$c=Ke.create,jc=bs.create,Kc=ws.create,Uc=Lt.create,zc=_s.create,Fc=Ps.create,Wc=vs.create,Lc=on.create,qc=ln.create,Vc=Ge.create,Gc=cn.create,Jc=Wt.create,Vn=Se.create,Yc=ye.create,Xc=$e.create,yh=zt.create,Qc=Se.createWithPreprocess,ed=pn.create,td=a(()=>Rs().optional(),"ostring"),rd=a(()=>Cs().optional(),"onumber"),nd=a(()=>Ds().optional(),"oboolean"),sd={string:a(t=>J.create(f(c({},t),{coerce:!0})),"string"),number:a(t=>un.create(f(c({},t),{coerce:!0})),"number"),boolean:a(t=>tn.create(f(c({},t),{coerce:!0})),"boolean"),bigint:a(t=>en.create(f(c({},t),{coerce:!0})),"bigint"),date:a(t=>sn.create(f(c({},t),{coerce:!0})),"date")},id=x,p=y,ad=a((t,e)=>t.anyOf.length?t.anyOf.length===1?L(t.anyOf[0],f(c({},e),{path:[...e.path,"anyOf",0]})):`z.union([${t.anyOf.map((r,n)=>L(r,f(c({},e),{path:[...e.path,"anyOf",n]}))).join(", ")}])`:"z.any()","parseAnyOf"),vh=a(t=>{var e;return(e=t[w])!=null&&e.coerce?"z.coerce.boolean()":"z.boolean()"},"parseBoolean"),_h=a(t=>"z.any()","parseDefault"),Th=a((t,e)=>`z.union([${t.type.map(r=>L(f(c({},t),{type:r}),e)).join(", ")}])`,"parseMultipleType"),bh=a((t,e)=>`z.any().refine((value) => !${L(t.not,f(c({},e),{path:[...e.path,"not"]}))}.safeParse(value).success, "Invalid input: Should NOT be valid against schema")`,"parseNot"),wh=a(t=>"z.null()","parseNull"),Ph=a(t=>[t.slice(0,t.length/2),t.slice(t.length/2)],"half"),xh=a((t,...e)=>Object.keys(t).reduce((r,n)=>(e.includes(n)||(r[n]=t[n]),r),{}),"omit");function V(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],d=o.length===3?o[1]:"",u=o.length===3?o[2]:o[1];i+=l,((n=t.errorMessage)==null?void 0:n[e])!==void 0&&(i+=d+JSON.stringify(t.errorMessage[e])),i+=u}}return i}a(V,"withMessage");var Bt=Symbol("Original index"),kh=a(t=>{let e=[];for(let r=0;r<t.length;r++){let n=t[r];if(typeof n=="boolean")e.push(n?{[Bt]:r}:{[Bt]:r,not:{}});else{if(Bt in n)return t;e.push(f(c({},n),{[Bt]:r}))}}return e},"ensureOriginalIndex");function Kt(t,e){if(t.allOf.length===0)return"z.never()";if(t.allOf.length===1){let r=t.allOf[0];return L(r,f(c({},e),{path:[...e.path,"allOf",r[Bt]]}))}else{let[r,n]=Ph(kh(t.allOf));return`z.intersection(${Kt({allOf:r},e)}, ${Kt({allOf:n},e)})`}}a(Kt,"parseAllOf");var Sh=a((t,e)=>{if(Array.isArray(t.items))return`z.tuple([${t.items.map((n,s)=>L(n,f(c({},e),{path:[...e.path,"items",s]})))}])`;let r=t.items?`z.array(${L(t.items,f(c({},e),{path:[...e.path,"items"]}))})`:"z.array(z.any())";return r+=V(t,"minItems",({json:n})=>[`.min(${n}`,", ",")"]),r+=V(t,"maxItems",({json:n})=>[`.max(${n}`,", ",")"]),r},"parseArray"),Eh=a(t=>`z.literal(${JSON.stringify(t.const)})`,"parseConst"),Oh=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"),Zh=a((t,e)=>{let r=L(t.if,f(c({},e),{path:[...e.path,"if"]})),n=L(t.then,f(c({},e),{path:[...e.path,"then"]})),s=L(t.else,f(c({},e),{path:[...e.path,"else"]}));return`z.union([${n}, ${s}]).superRefine((value,ctx) => {
17
- const result = ${r}.safeParse(value).success
18
- ? ${n}.safeParse(value)
19
- : ${s}.safeParse(value);
7
+ */`},"getMultilineComment");function Ws(t){if(typeof t!="string")return"";let n=String.raw`${t}`.replace(/\\/g,"\\\\").replace(/\n/g,"\\n").replace(/"/g,'\\"').replace(/'/g,"\\'");return n.includes("`")?`"${n}"`:n.includes("'")?`"${n}"`:`'${n}'`}o(Ws,"escapeString");var Ls={};Gn(Ls,{JSONSchemaToZuiError:()=>Jn,ObjectToZuiError:()=>zr,UnrepresentableGenericError:()=>Wr,UnsupportedJSONSchemaToZuiError:()=>Ie,UnsupportedZuiCheckToJSONSchemaError:()=>Qs,UnsupportedZuiToJSONSchemaError:()=>te,UnsupportedZuiToTypescriptSchemaError:()=>De,UnsupportedZuiToTypescriptTypeError:()=>aa,UntitledDeclarationError:()=>la,ZuiToJSONSchemaError:()=>Yn,ZuiToTypescriptSchemaError:()=>na,ZuiToTypescriptTypeError:()=>Xn,ZuiTransformError:()=>ht});var Vs=class extends Error{constructor(e,n){super(n),this.transform=e}};o(Vs,"ZuiTransformError");var ht=Vs,qs=class extends ht{constructor(e){super("json-schema-to-zui",e)}};o(qs,"JSONSchemaToZuiError");var Jn=qs,Gs=class extends ht{constructor(e){super("object-to-zui",e)}};o(Gs,"ObjectToZuiError");var zr=Gs,Js=class extends ht{constructor(e){super("zui-to-json-schema",e)}};o(Js,"ZuiToJSONSchemaError");var Yn=Js,Ys=class extends Yn{constructor(e,{suggestedAlternative:n}={}){super(`Zod type ${e} cannot be transformed to JSON Schema.`+(n?` Suggested alternative: ${n}`:""))}};o(Ys,"UnsupportedZuiToJSONSchemaError");var te=Ys,Xs=class extends Yn{constructor({zodType:e,checkKind:n}){super(`Zod check .${n}() of type ${e} cannot be transformed to JSON Schema.`)}};o(Xs,"UnsupportedZuiCheckToJSONSchemaError");var Qs=Xs,ea=class extends Jn{constructor(e){super(`JSON Schema ${JSON.stringify(e)} cannot be transformed to ZUI type.`)}};o(ea,"UnsupportedJSONSchemaToZuiError");var Ie=ea,ta=class extends ht{constructor(e){super("zui-to-typescript-schema",e)}};o(ta,"ZuiToTypescriptSchemaError");var na=ta,ra=class extends na{constructor(e){super(`Zod type ${e} cannot be transformed to TypeScript schema.`)}};o(ra,"UnsupportedZuiToTypescriptSchemaError");var De=ra,ia=class extends ht{constructor(e){super("zui-to-typescript-type",e)}};o(ia,"ZuiToTypescriptTypeError");var Xn=ia,sa=class extends Xn{constructor(e){super(`Zod type ${e} cannot be transformed to TypeScript type.`)}};o(sa,"UnsupportedZuiToTypescriptTypeError");var aa=sa,oa=class extends Xn{constructor(){super("Schema must have a title to be transformed to a TypeScript type with a declaration.")}};o(oa,"UntitledDeclarationError");var la=oa,ca=class extends Xn{constructor(){super('ZodRef can only be transformed to a TypeScript type with a "type" declaration.')}};o(ca,"UnrepresentableGenericError");var Wr=ca,ua=["string","number","boolean","unknown","void","any","null","undefined","never","bigint","symbol","object"],Rd=5,Dd=o(t=>ua.includes(t),"isPrimitive"),Hd=o(t=>ua.map(e=>`${e}[]`).includes(t),"isArrayOfPrimitives"),Hr=o(t=>t.replace(/ +/g," ").trim(),"stripSpaces"),da=class{constructor(e,n){this.key=e,this.value=n}};o(da,"KeyValue");var nn=da,pa=class{constructor(e){this.schema=e}};o(pa,"FnParameters");var rs=pa,fa=class{constructor(e){this.schema=e}};o(fa,"FnReturn");var is=fa,ga=class{constructor(e){this.props=e}};o(ga,"Declaration");var Mt=ga;function ri(t,e={}){let n=$d(t,e),r=B(n,e);return e.formatter&&(r=e.formatter(r)),r}o(ri,"toTypescriptType");var ss=o(t=>t.endsWith("?")?t:`${t}?`,"_optionalKey");function B(t,e){var n,r,i;let s=f(u({},e),{declaration:!1,parent:t});if(t===null)return"";if(t instanceof Mt)return Nd(t,s);if(t instanceof nn){let c;if(t.value instanceof p.ZodOptional?c=t.value:t.value instanceof p.ZodDefault&&e.treatDefaultAsOptional&&(c=t.value._def.innerType.optional()),c){let k=c._def.innerType;return k instanceof p.Schema&&!k.description&&c.description&&(k=k?.describe(c.description)),B(new nn(ss(t.key),k),s)}let d=F(t.value._def.description||t.value.description),g=d?.trim().length>0?`
8
+ `:"",m=t.value.describe(""),I=t.value instanceof p.ZodAny?ss(t.key):t.key;return`${g}${d}${g}${I}: ${B(m,s)}${g}`}if(t instanceof rs){if(t.schema instanceof p.ZodTuple){let m="";for(let T=0;T<t.schema.items.length;T++){let I=(i=(r=(n=t.schema.items[T])==null?void 0:n.ui)==null?void 0:r.title)!=null?i:`arg${T}`,k=t.schema.items[T];m+=`${B(new nn(Fr(I),k),s)}${T<t.schema.items.length-1?", ":""} `}return m}let c=t.schema.naked()instanceof p.ZodLiteral,d=B(t.schema,s).trim();return d.startsWith("{")&&d.endsWith("}")||d.startsWith("[")&&d.endsWith("]")||d.startsWith("(")&&d.endsWith(")")||d.startsWith("Array<")&&d.endsWith(">")||d.startsWith("Record<")&&d.endsWith(">")||Hd(d)||c?`args: ${d}`:d}if(t instanceof is)return t.schema instanceof p.ZodOptional?`${B(t.schema.unwrap(),s)} | undefined`:B(t.schema,s);let a=t,l=a._def;switch(l.typeName){case p.ZodFirstPartyTypeKind.ZodString:return`${F(a.description)} string`.trim();case p.ZodFirstPartyTypeKind.ZodNumber:case p.ZodFirstPartyTypeKind.ZodNaN:case p.ZodFirstPartyTypeKind.ZodBigInt:return`${F(a.description)} number`.trim();case p.ZodFirstPartyTypeKind.ZodBoolean:return`${F(a.description)} boolean`.trim();case p.ZodFirstPartyTypeKind.ZodDate:return`${F(a.description)} Date`.trim();case p.ZodFirstPartyTypeKind.ZodUndefined:return`${F(a.description)} undefined`.trim();case p.ZodFirstPartyTypeKind.ZodNull:return`${F(a.description)} null`.trim();case p.ZodFirstPartyTypeKind.ZodAny:return`${F(a.description)} any`.trim();case p.ZodFirstPartyTypeKind.ZodUnknown:return`${F(a.description)} unknown`.trim();case p.ZodFirstPartyTypeKind.ZodNever:return`${F(a.description)} never`.trim();case p.ZodFirstPartyTypeKind.ZodVoid:return`${F(a.description)} void`.trim();case p.ZodFirstPartyTypeKind.ZodArray:let c=B(l.type,s);return Dd(c)?`${c}[]`:`Array<${c}>`;case p.ZodFirstPartyTypeKind.ZodObject:return`{ ${Object.entries(l.shape()).map(([ee,Rr])=>Rr instanceof p.Schema?B(new nn(Fr(ee),Rr),s):`${ee}: unknown`).join("; ")} }`;case p.ZodFirstPartyTypeKind.ZodUnion:let g=l.options.map(ee=>B(ee,s));return`${F(a.description)}
9
+ ${g.join(" | ")}`;case p.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:let m=l.options.map(ee=>B(ee,s));return`${F(a.description)}
10
+ ${m.join(" | ")}`;case p.ZodFirstPartyTypeKind.ZodIntersection:return`${B(l.left,s)} & ${B(l.right,s)}`;case p.ZodFirstPartyTypeKind.ZodTuple:return l.items.length===0?"[]":`[${l.items.map(ee=>B(ee,s)).join(", ")}]`;case p.ZodFirstPartyTypeKind.ZodRecord:let I=B(l.keyType,s),k=B(l.valueType,s);return`${F(a.description)} { [key: ${I}]: ${k} }`;case p.ZodFirstPartyTypeKind.ZodMap:return`Map<${B(l.keyType,s)}, ${B(l.valueType,s)}>`;case p.ZodFirstPartyTypeKind.ZodSet:return`Set<${B(l.valueType,s)}>`;case p.ZodFirstPartyTypeKind.ZodFunction:let K=B(new rs(l.args),s),z=B(new is(l.returns),s),Q=e?.parent instanceof Mt&&e?.parent.props.type==="type";return e?.declaration&&!Q?`${F(a.description)}
11
+ (${K}): ${z}`:`${F(a.description)}
12
+ (${K}) => ${z}`;case p.ZodFirstPartyTypeKind.ZodLazy:return B(l.getter(),s);case p.ZodFirstPartyTypeKind.ZodLiteral:let ae=Us(l.value);return`${F(a.description)}
13
+ ${ae}`.trim();case p.ZodFirstPartyTypeKind.ZodEnum:return l.values.map(b).join(" | ");case p.ZodFirstPartyTypeKind.ZodEffects:return B(l.schema,s);case p.ZodFirstPartyTypeKind.ZodNativeEnum:throw new aa(p.ZodFirstPartyTypeKind.ZodNativeEnum);case p.ZodFirstPartyTypeKind.ZodOptional:return`${B(l.innerType,s)} | undefined`;case p.ZodFirstPartyTypeKind.ZodNullable:return`${B(l.innerType,s)} | null`;case p.ZodFirstPartyTypeKind.ZodDefault:let oe=e.treatDefaultAsOptional?l.innerType.optional():l.innerType;return B(oe,s);case p.ZodFirstPartyTypeKind.ZodCatch:return B(l.innerType,s);case p.ZodFirstPartyTypeKind.ZodPromise:return`Promise<${B(l.type,s)}>`;case p.ZodFirstPartyTypeKind.ZodBranded:return B(l.type,s);case p.ZodFirstPartyTypeKind.ZodPipeline:return B(l.in,s);case p.ZodFirstPartyTypeKind.ZodSymbol:return`${F(a.description)} symbol`.trim();case p.ZodFirstPartyTypeKind.ZodReadonly:return`Readonly<${B(l.innerType,s)}>`;case p.ZodFirstPartyTypeKind.ZodRef:return zs(l.uri);default:Z.assertNever(l)}}o(B,"sUnwrapZod");var Nd=o((t,e)=>{if(t.props.type==="none")return B(t.props.schema,e);let{schema:n,identifier:r}=t.props,i=F(n.description),s=n.describe(""),a=B(s,f(u({},e),{declaration:!0})),c=a.split(`
14
+ `).length>=Rd&&e.includeClosingTags?`// end of ${r}`:"";if(t.props.type!=="type"&&n instanceof p.ZodFunction)return Hr(`${i}
15
+ declare function ${r}${a};${c}`);if(t.props.type==="variable")return Hr(`${i}declare const ${r}: ${a};${c}`);let d=t.props.args.length>0?`<${t.props.args.map(zs).join(", ")}>`:"";return Hr(`${i}type ${t.props.identifier}${d} = ${a};${c}`)},"unwrapDeclaration"),Md=o(t=>t.declaration?t.declaration===!0?"variable":t.declaration:"none","getDeclarationType"),$d=o((t,e)=>{let n=Md(e),r=t.getReferences();if(n==="none"){if(r.length>0)throw new Wr;return new Mt({type:"none",schema:t})}let i="title"in t.ui?t.ui.title:null;if(!i)throw new la;if(n==="variable"){if(r.length>0)throw new Wr;return new Mt({type:"variable",identifier:i,schema:t})}return new Mt({type:"type",identifier:i,schema:t,args:r})},"getDeclarationProps"),jd=typeof global=="object"&&global&&global.Object===Object&&global,ma=jd,Kd=typeof self=="object"&&self&&self.Object===Object&&self,Ud=ma||Kd||Function("return this")(),ke=Ud,Fd=ke.Symbol,Ze=Fd,ha=Object.prototype,zd=ha.hasOwnProperty,Wd=ha.toString,xt=Ze?Ze.toStringTag:void 0;function ya(t){var e=zd.call(t,xt),n=t[xt];try{t[xt]=void 0;var r=!0}catch{}var i=Wd.call(t);return r&&(e?t[xt]=n:delete t[xt]),i}o(ya,"getRawTag");var Ld=ya,Vd=Object.prototype,qd=Vd.toString;function va(t){return qd.call(t)}o(va,"objectToString");var Gd=va,Jd="[object Null]",Yd="[object Undefined]",as=Ze?Ze.toStringTag:void 0;function _a(t){return t==null?t===void 0?Yd:Jd:as&&as in Object(t)?Ld(t):Gd(t)}o(_a,"baseGetTag");var Le=_a;function Ta(t){return t!=null&&typeof t=="object"}o(Ta,"isObjectLike");var Ue=Ta,Xd="[object Symbol]";function ba(t){return typeof t=="symbol"||Ue(t)&&Le(t)==Xd}o(ba,"isSymbol");var ii=ba;function wa(t,e){for(var n=-1,r=t==null?0:t.length,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i}o(wa,"arrayMap");var Pa=wa,Qd=Array.isArray,xe=Qd,ep=1/0,os=Ze?Ze.prototype:void 0,ls=os?os.toString:void 0;function si(t){if(typeof t=="string")return t;if(xe(t))return Pa(t,si)+"";if(ii(t))return ls?ls.call(t):"";var e=t+"";return e=="0"&&1/t==-ep?"-0":e}o(si,"baseToString");var tp=si;function xa(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}o(xa,"isObject");var ut=xa;function ka(t){return t}o(ka,"identity");var np=ka,rp="[object AsyncFunction]",ip="[object Function]",sp="[object GeneratorFunction]",ap="[object Proxy]";function Sa(t){if(!ut(t))return!1;var e=Le(t);return e==ip||e==sp||e==rp||e==ap}o(Sa,"isFunction");var Ea=Sa,op=ke["__core-js_shared__"],Nr=op,cs=(function(){var t=/[^.]+$/.exec(Nr&&Nr.keys&&Nr.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function Oa(t){return!!cs&&cs in t}o(Oa,"isMasked");var lp=Oa,cp=Function.prototype,up=cp.toString;function Ia(t){if(t!=null){try{return up.call(t)}catch{}try{return t+""}catch{}}return""}o(Ia,"toSource");var Ve=Ia,dp=/[\\^$.*+?()[\]{}|]/g,pp=/^\[object .+?Constructor\]$/,fp=Function.prototype,gp=Object.prototype,mp=fp.toString,hp=gp.hasOwnProperty,yp=RegExp("^"+mp.call(hp).replace(dp,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Za(t){if(!ut(t)||lp(t))return!1;var e=Ea(t)?yp:pp;return e.test(Ve(t))}o(Za,"baseIsNative");var vp=Za;function Ba(t,e){return t?.[e]}o(Ba,"getValue");var _p=Ba;function Aa(t,e){var n=_p(t,e);return vp(n)?n:void 0}o(Aa,"getNative");var qe=Aa,Tp=qe(ke,"WeakMap"),Lr=Tp,bp=(function(){try{var t=qe(Object,"defineProperty");return t({},"",{}),t}catch{}})(),us=bp,wp=9007199254740991,Pp=/^(?:0|[1-9]\d*)$/;function Ca(t,e){var n=typeof t;return e=e??wp,!!e&&(n=="number"||n!="symbol"&&Pp.test(t))&&t>-1&&t%1==0&&t<e}o(Ca,"isIndex");var ai=Ca;function Ra(t,e,n){e=="__proto__"&&us?us(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}o(Ra,"baseAssignValue");var Da=Ra;function Ha(t,e){return t===e||t!==t&&e!==e}o(Ha,"eq");var oi=Ha,xp=Object.prototype,kp=xp.hasOwnProperty;function Na(t,e,n){var r=t[e];(!(kp.call(t,e)&&oi(r,n))||n===void 0&&!(e in t))&&Da(t,e,n)}o(Na,"assignValue");var Sp=Na,Ep=9007199254740991;function Ma(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Ep}o(Ma,"isLength");var li=Ma;function $a(t){return t!=null&&li(t.length)&&!Ea(t)}o($a,"isArrayLike");var ja=$a,Op=Object.prototype;function Ka(t){var e=t&&t.constructor,n=typeof e=="function"&&e.prototype||Op;return t===n}o(Ka,"isPrototype");var Ua=Ka;function Fa(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}o(Fa,"baseTimes");var Ip=Fa,Zp="[object Arguments]";function za(t){return Ue(t)&&Le(t)==Zp}o(za,"baseIsArguments");var ds=za,Wa=Object.prototype,Bp=Wa.hasOwnProperty,Ap=Wa.propertyIsEnumerable,Cp=ds((function(){return arguments})())?ds:function(t){return Ue(t)&&Bp.call(t,"callee")&&!Ap.call(t,"callee")},La=Cp;function Va(){return!1}o(Va,"stubFalse");var Rp=Va,qa=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ps=qa&&typeof module=="object"&&module&&!module.nodeType&&module,Dp=ps&&ps.exports===qa,fs=Dp?ke.Buffer:void 0,Hp=fs?fs.isBuffer:void 0,Np=Hp||Rp,Vr=Np,Mp="[object Arguments]",$p="[object Array]",jp="[object Boolean]",Kp="[object Date]",Up="[object Error]",Fp="[object Function]",zp="[object Map]",Wp="[object Number]",Lp="[object Object]",Vp="[object RegExp]",qp="[object Set]",Gp="[object String]",Jp="[object WeakMap]",Yp="[object ArrayBuffer]",Xp="[object DataView]",Qp="[object Float32Array]",ef="[object Float64Array]",tf="[object Int8Array]",nf="[object Int16Array]",rf="[object Int32Array]",sf="[object Uint8Array]",af="[object Uint8ClampedArray]",of="[object Uint16Array]",lf="[object Uint32Array]",H={};H[Qp]=H[ef]=H[tf]=H[nf]=H[rf]=H[sf]=H[af]=H[of]=H[lf]=!0;H[Mp]=H[$p]=H[Yp]=H[jp]=H[Xp]=H[Kp]=H[Up]=H[Fp]=H[zp]=H[Wp]=H[Lp]=H[Vp]=H[qp]=H[Gp]=H[Jp]=!1;function Ga(t){return Ue(t)&&li(t.length)&&!!H[Le(t)]}o(Ga,"baseIsTypedArray");var cf=Ga;function Ja(t){return function(e){return t(e)}}o(Ja,"baseUnary");var uf=Ja,Ya=typeof exports=="object"&&exports&&!exports.nodeType&&exports,$t=Ya&&typeof module=="object"&&module&&!module.nodeType&&module,df=$t&&$t.exports===Ya,Mr=df&&ma.process,pf=(function(){try{var t=$t&&$t.require&&$t.require("util").types;return t||Mr&&Mr.binding&&Mr.binding("util")}catch{}})(),gs=pf,ms=gs&&gs.isTypedArray,ff=ms?uf(ms):cf,Xa=ff,gf=Object.prototype,mf=gf.hasOwnProperty;function Qa(t,e){var n=xe(t),r=!n&&La(t),i=!n&&!r&&Vr(t),s=!n&&!r&&!i&&Xa(t),a=n||r||i||s,l=a?Ip(t.length,String):[],c=l.length;for(var d in t)(e||mf.call(t,d))&&!(a&&(d=="length"||i&&(d=="offset"||d=="parent")||s&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||ai(d,c)))&&l.push(d);return l}o(Qa,"arrayLikeKeys");var eo=Qa;function to(t,e){return function(n){return t(e(n))}}o(to,"overArg");var no=to,hf=no(Object.keys,Object),yf=hf,vf=Object.prototype,_f=vf.hasOwnProperty;function ro(t){if(!Ua(t))return yf(t);var e=[];for(var n in Object(t))_f.call(t,n)&&n!="constructor"&&e.push(n);return e}o(ro,"baseKeys");var Tf=ro;function io(t){return ja(t)?eo(t):Tf(t)}o(io,"keys");var ci=io;function so(t){var e=[];if(t!=null)for(var n in Object(t))e.push(n);return e}o(so,"nativeKeysIn");var bf=so,wf=Object.prototype,Pf=wf.hasOwnProperty;function ao(t){if(!ut(t))return bf(t);var e=Ua(t),n=[];for(var r in t)r=="constructor"&&(e||!Pf.call(t,r))||n.push(r);return n}o(ao,"baseKeysIn");var xf=ao;function oo(t){return ja(t)?eo(t,!0):xf(t)}o(oo,"keysIn");var kf=oo,Sf=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ef=/^\w*$/;function lo(t,e){if(xe(t))return!1;var n=typeof t;return n=="number"||n=="symbol"||n=="boolean"||t==null||ii(t)?!0:Ef.test(t)||!Sf.test(t)||e!=null&&t in Object(e)}o(lo,"isKey");var ui=lo,Of=qe(Object,"create"),Kt=Of;function co(){this.__data__=Kt?Kt(null):{},this.size=0}o(co,"hashClear");var If=co;function uo(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}o(uo,"hashDelete");var Zf=uo,Bf="__lodash_hash_undefined__",Af=Object.prototype,Cf=Af.hasOwnProperty;function po(t){var e=this.__data__;if(Kt){var n=e[t];return n===Bf?void 0:n}return Cf.call(e,t)?e[t]:void 0}o(po,"hashGet");var Rf=po,Df=Object.prototype,Hf=Df.hasOwnProperty;function fo(t){var e=this.__data__;return Kt?e[t]!==void 0:Hf.call(e,t)}o(fo,"hashHas");var Nf=fo,Mf="__lodash_hash_undefined__";function go(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=Kt&&e===void 0?Mf:e,this}o(go,"hashSet");var $f=go;function Ge(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}o(Ge,"Hash");Ge.prototype.clear=If;Ge.prototype.delete=Zf;Ge.prototype.get=Rf;Ge.prototype.has=Nf;Ge.prototype.set=$f;var hs=Ge;function mo(){this.__data__=[],this.size=0}o(mo,"listCacheClear");var jf=mo;function ho(t,e){for(var n=t.length;n--;)if(oi(t[n][0],e))return n;return-1}o(ho,"assocIndexOf");var Qn=ho,Kf=Array.prototype,Uf=Kf.splice;function yo(t){var e=this.__data__,n=Qn(e,t);if(n<0)return!1;var r=e.length-1;return n==r?e.pop():Uf.call(e,n,1),--this.size,!0}o(yo,"listCacheDelete");var Ff=yo;function vo(t){var e=this.__data__,n=Qn(e,t);return n<0?void 0:e[n][1]}o(vo,"listCacheGet");var zf=vo;function _o(t){return Qn(this.__data__,t)>-1}o(_o,"listCacheHas");var Wf=_o;function To(t,e){var n=this.__data__,r=Qn(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}o(To,"listCacheSet");var Lf=To;function Je(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}o(Je,"ListCache");Je.prototype.clear=jf;Je.prototype.delete=Ff;Je.prototype.get=zf;Je.prototype.has=Wf;Je.prototype.set=Lf;var er=Je,Vf=qe(ke,"Map"),Ut=Vf;function bo(){this.size=0,this.__data__={hash:new hs,map:new(Ut||er),string:new hs}}o(bo,"mapCacheClear");var qf=bo;function wo(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}o(wo,"isKeyable");var Gf=wo;function Po(t,e){var n=t.__data__;return Gf(e)?n[typeof e=="string"?"string":"hash"]:n.map}o(Po,"getMapData");var tr=Po;function xo(t){var e=tr(this,t).delete(t);return this.size-=e?1:0,e}o(xo,"mapCacheDelete");var Jf=xo;function ko(t){return tr(this,t).get(t)}o(ko,"mapCacheGet");var Yf=ko;function So(t){return tr(this,t).has(t)}o(So,"mapCacheHas");var Xf=So;function Eo(t,e){var n=tr(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this}o(Eo,"mapCacheSet");var Qf=Eo;function Ye(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}o(Ye,"MapCache");Ye.prototype.clear=qf;Ye.prototype.delete=Jf;Ye.prototype.get=Yf;Ye.prototype.has=Xf;Ye.prototype.set=Qf;var nr=Ye,eg="Expected a function";function rr(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(eg);var n=o(function(){var r=arguments,i=e?e.apply(this,r):r[0],s=n.cache;if(s.has(i))return s.get(i);var a=t.apply(this,r);return n.cache=s.set(i,a)||s,a},"memoized");return n.cache=new(rr.Cache||nr),n}o(rr,"memoize");rr.Cache=nr;var tg=rr,ng=500;function Oo(t){var e=tg(t,function(r){return n.size===ng&&n.clear(),r}),n=e.cache;return e}o(Oo,"memoizeCapped");var rg=Oo,ig=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,sg=/\\(\\)?/g,ag=rg(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(ig,function(n,r,i,s){e.push(i?s.replace(sg,"$1"):r||n)}),e}),og=ag;function Io(t){return t==null?"":tp(t)}o(Io,"toString");var lg=Io;function Zo(t,e){return xe(t)?t:ui(t,e)?[t]:og(lg(t))}o(Zo,"castPath");var ir=Zo,cg=1/0;function Bo(t){if(typeof t=="string"||ii(t))return t;var e=t+"";return e=="0"&&1/t==-cg?"-0":e}o(Bo,"toKey");var Vt=Bo;function Ao(t,e){e=ir(e,t);for(var n=0,r=e.length;t!=null&&n<r;)t=t[Vt(e[n++])];return n&&n==r?t:void 0}o(Ao,"baseGet");var di=Ao;function Co(t,e,n){var r=t==null?void 0:di(t,e);return r===void 0?n:r}o(Co,"get");var ug=Co;function Ro(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t}o(Ro,"arrayPush");var Do=Ro,dg=no(Object.getPrototypeOf,Object),Ho=dg,pg="[object Object]",fg=Function.prototype,gg=Object.prototype,No=fg.toString,mg=gg.hasOwnProperty,hg=No.call(Object);function Mo(t){if(!Ue(t)||Le(t)!=pg)return!1;var e=Ho(t);if(e===null)return!0;var n=mg.call(e,"constructor")&&e.constructor;return typeof n=="function"&&n instanceof n&&No.call(n)==hg}o(Mo,"isPlainObject");var ys=Mo;function $o(){this.__data__=new er,this.size=0}o($o,"stackClear");var yg=$o;function jo(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}o(jo,"stackDelete");var vg=jo;function Ko(t){return this.__data__.get(t)}o(Ko,"stackGet");var _g=Ko;function Uo(t){return this.__data__.has(t)}o(Uo,"stackHas");var Tg=Uo,bg=200;function Fo(t,e){var n=this.__data__;if(n instanceof er){var r=n.__data__;if(!Ut||r.length<bg-1)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new nr(r)}return n.set(t,e),this.size=n.size,this}o(Fo,"stackSet");var wg=Fo;function Xe(t){var e=this.__data__=new er(t);this.size=e.size}o(Xe,"Stack");Xe.prototype.clear=yg;Xe.prototype.delete=vg;Xe.prototype.get=_g;Xe.prototype.has=Tg;Xe.prototype.set=wg;var sn=Xe;function zo(t,e){for(var n=-1,r=t==null?0:t.length,i=0,s=[];++n<r;){var a=t[n];e(a,n,t)&&(s[i++]=a)}return s}o(zo,"arrayFilter");var Pg=zo;function Wo(){return[]}o(Wo,"stubArray");var Lo=Wo,xg=Object.prototype,kg=xg.propertyIsEnumerable,vs=Object.getOwnPropertySymbols,Sg=vs?function(t){return t==null?[]:(t=Object(t),Pg(vs(t),function(e){return kg.call(t,e)}))}:Lo,Vo=Sg,Eg=Object.getOwnPropertySymbols,Og=Eg?function(t){for(var e=[];t;)Do(e,Vo(t)),t=Ho(t);return e}:Lo,Ig=Og;function qo(t,e,n){var r=e(t);return xe(t)?r:Do(r,n(t))}o(qo,"baseGetAllKeys");var Go=qo;function Jo(t){return Go(t,ci,Vo)}o(Jo,"getAllKeys");var _s=Jo;function Yo(t){return Go(t,kf,Ig)}o(Yo,"getAllKeysIn");var Zg=Yo,Bg=qe(ke,"DataView"),qr=Bg,Ag=qe(ke,"Promise"),Gr=Ag,Cg=qe(ke,"Set"),Jr=Cg,Ts="[object Map]",Rg="[object Object]",bs="[object Promise]",ws="[object Set]",Ps="[object WeakMap]",xs="[object DataView]",Dg=Ve(qr),Hg=Ve(Ut),Ng=Ve(Gr),Mg=Ve(Jr),$g=Ve(Lr),He=Le;(qr&&He(new qr(new ArrayBuffer(1)))!=xs||Ut&&He(new Ut)!=Ts||Gr&&He(Gr.resolve())!=bs||Jr&&He(new Jr)!=ws||Lr&&He(new Lr)!=Ps)&&(He=o(function(t){var e=Le(t),n=e==Rg?t.constructor:void 0,r=n?Ve(n):"";if(r)switch(r){case Dg:return xs;case Hg:return Ts;case Ng:return bs;case Mg:return ws;case $g:return Ps}return e},"getTag"));var ks=He,jg=ke.Uint8Array,Ss=jg,Kg="__lodash_hash_undefined__";function Xo(t){return this.__data__.set(t,Kg),this}o(Xo,"setCacheAdd");var Ug=Xo;function Qo(t){return this.__data__.has(t)}o(Qo,"setCacheHas");var Fg=Qo;function Ft(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new nr;++e<n;)this.add(t[e])}o(Ft,"SetCache");Ft.prototype.add=Ft.prototype.push=Ug;Ft.prototype.has=Fg;var zg=Ft;function el(t,e){for(var n=-1,r=t==null?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}o(el,"arraySome");var Wg=el;function tl(t,e){return t.has(e)}o(tl,"cacheHas");var Lg=tl,Vg=1,qg=2;function nl(t,e,n,r,i,s){var a=n&Vg,l=t.length,c=e.length;if(l!=c&&!(a&&c>l))return!1;var d=s.get(t),g=s.get(e);if(d&&g)return d==e&&g==t;var m=-1,T=!0,I=n&qg?new zg:void 0;for(s.set(t,e),s.set(e,t);++m<l;){var k=t[m],K=e[m];if(r)var z=a?r(K,k,m,e,t,s):r(k,K,m,t,e,s);if(z!==void 0){if(z)continue;T=!1;break}if(I){if(!Wg(e,function(Q,ae){if(!Lg(I,ae)&&(k===Q||i(k,Q,n,r,s)))return I.push(ae)})){T=!1;break}}else if(!(k===K||i(k,K,n,r,s))){T=!1;break}}return s.delete(t),s.delete(e),T}o(nl,"equalArrays");var rl=nl;function il(t){var e=-1,n=Array(t.size);return t.forEach(function(r,i){n[++e]=[i,r]}),n}o(il,"mapToArray");var Gg=il;function sl(t){var e=-1,n=Array(t.size);return t.forEach(function(r){n[++e]=r}),n}o(sl,"setToArray");var Jg=sl,Yg=1,Xg=2,Qg="[object Boolean]",em="[object Date]",tm="[object Error]",nm="[object Map]",rm="[object Number]",im="[object RegExp]",sm="[object Set]",am="[object String]",om="[object Symbol]",lm="[object ArrayBuffer]",cm="[object DataView]",Es=Ze?Ze.prototype:void 0,$r=Es?Es.valueOf:void 0;function al(t,e,n,r,i,s,a){switch(n){case cm:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case lm:return!(t.byteLength!=e.byteLength||!s(new Ss(t),new Ss(e)));case Qg:case em:case rm:return oi(+t,+e);case tm:return t.name==e.name&&t.message==e.message;case im:case am:return t==e+"";case nm:var l=Gg;case sm:var c=r&Yg;if(l||(l=Jg),t.size!=e.size&&!c)return!1;var d=a.get(t);if(d)return d==e;r|=Xg,a.set(t,e);var g=rl(l(t),l(e),r,i,s,a);return a.delete(t),g;case om:if($r)return $r.call(t)==$r.call(e)}return!1}o(al,"equalByTag");var um=al,dm=1,pm=Object.prototype,fm=pm.hasOwnProperty;function ol(t,e,n,r,i,s){var a=n&dm,l=_s(t),c=l.length,d=_s(e),g=d.length;if(c!=g&&!a)return!1;for(var m=c;m--;){var T=l[m];if(!(a?T in e:fm.call(e,T)))return!1}var I=s.get(t),k=s.get(e);if(I&&k)return I==e&&k==t;var K=!0;s.set(t,e),s.set(e,t);for(var z=a;++m<c;){T=l[m];var Q=t[T],ae=e[T];if(r)var me=a?r(ae,Q,T,e,t,s):r(Q,ae,T,t,e,s);if(!(me===void 0?Q===ae||i(Q,ae,n,r,s):me)){K=!1;break}z||(z=T=="constructor")}if(K&&!z){var oe=t.constructor,ee=e.constructor;oe!=ee&&"constructor"in t&&"constructor"in e&&!(typeof oe=="function"&&oe instanceof oe&&typeof ee=="function"&&ee instanceof ee)&&(K=!1)}return s.delete(t),s.delete(e),K}o(ol,"equalObjects");var gm=ol,mm=1,Os="[object Arguments]",Is="[object Array]",rn="[object Object]",hm=Object.prototype,Zs=hm.hasOwnProperty;function ll(t,e,n,r,i,s){var a=xe(t),l=xe(e),c=a?Is:ks(t),d=l?Is:ks(e);c=c==Os?rn:c,d=d==Os?rn:d;var g=c==rn,m=d==rn,T=c==d;if(T&&Vr(t)){if(!Vr(e))return!1;a=!0,g=!1}if(T&&!g)return s||(s=new sn),a||Xa(t)?rl(t,e,n,r,i,s):um(t,e,c,n,r,i,s);if(!(n&mm)){var I=g&&Zs.call(t,"__wrapped__"),k=m&&Zs.call(e,"__wrapped__");if(I||k){var K=I?t.value():t,z=k?e.value():e;return s||(s=new sn),i(K,z,n,r,s)}}return T?(s||(s=new sn),gm(t,e,n,r,i,s)):!1}o(ll,"baseIsEqualDeep");var ym=ll;function pi(t,e,n,r,i){return t===e?!0:t==null||e==null||!Ue(t)&&!Ue(e)?t!==t&&e!==e:ym(t,e,n,r,pi,i)}o(pi,"baseIsEqual");var sr=pi,vm=1,_m=2;function cl(t,e,n,r){var i=n.length,s=i,a=!r;if(t==null)return!s;for(t=Object(t);i--;){var l=n[i];if(a&&l[2]?l[1]!==t[l[0]]:!(l[0]in t))return!1}for(;++i<s;){l=n[i];var c=l[0],d=t[c],g=l[1];if(a&&l[2]){if(d===void 0&&!(c in t))return!1}else{var m=new sn;if(r)var T=r(d,g,c,t,e,m);if(!(T===void 0?sr(g,d,vm|_m,r,m):T))return!1}}return!0}o(cl,"baseIsMatch");var Tm=cl;function ul(t){return t===t&&!ut(t)}o(ul,"isStrictComparable");var dl=ul;function pl(t){for(var e=ci(t),n=e.length;n--;){var r=e[n],i=t[r];e[n]=[r,i,dl(i)]}return e}o(pl,"getMatchData");var bm=pl;function fl(t,e){return function(n){return n==null?!1:n[t]===e&&(e!==void 0||t in Object(n))}}o(fl,"matchesStrictComparable");var gl=fl;function ml(t){var e=bm(t);return e.length==1&&e[0][2]?gl(e[0][0],e[0][1]):function(n){return n===t||Tm(n,t,e)}}o(ml,"baseMatches");var wm=ml;function hl(t,e){return t!=null&&e in Object(t)}o(hl,"baseHasIn");var Pm=hl;function yl(t,e,n){e=ir(e,t);for(var r=-1,i=e.length,s=!1;++r<i;){var a=Vt(e[r]);if(!(s=t!=null&&n(t,a)))break;t=t[a]}return s||++r!=i?s:(i=t==null?0:t.length,!!i&&li(i)&&ai(a,i)&&(xe(t)||La(t)))}o(yl,"hasPath");var xm=yl;function vl(t,e){return t!=null&&xm(t,e,Pm)}o(vl,"hasIn");var km=vl,Sm=1,Em=2;function _l(t,e){return ui(t)&&dl(e)?gl(Vt(t),e):function(n){var r=ug(n,t);return r===void 0&&r===e?km(n,t):sr(e,r,Sm|Em)}}o(_l,"baseMatchesProperty");var Om=_l;function Tl(t){return function(e){return e?.[t]}}o(Tl,"baseProperty");var Im=Tl;function bl(t){return function(e){return di(e,t)}}o(bl,"basePropertyDeep");var Zm=bl;function wl(t){return ui(t)?Im(Vt(t)):Zm(t)}o(wl,"property");var Bm=wl;function Pl(t){return typeof t=="function"?t:t==null?np:typeof t=="object"?xe(t)?Om(t[0],t[1]):wm(t):Bm(t)}o(Pl,"baseIteratee");var fi=Pl;function xl(t){return function(e,n,r){for(var i=-1,s=Object(e),a=r(e),l=a.length;l--;){var c=a[t?l:++i];if(n(s[c],c,s)===!1)break}return e}}o(xl,"createBaseFor");var Am=xl,Cm=Am(),Rm=Cm;function kl(t,e){return t&&Rm(t,e,ci)}o(kl,"baseForOwn");var Dm=kl;function Sl(t,e){return sr(t,e)}o(Sl,"isEqual");var lt=Sl;function El(t,e,n){n=typeof n=="function"?n:void 0;var r=n?n(t,e):void 0;return r===void 0?sr(t,e,void 0,n):!!r}o(El,"isEqualWith");var Hm=El;function Ol(t){return t===void 0}o(Ol,"isUndefined");var Bs=Ol;function Il(t,e){var n={};return e=fi(e,3),Dm(t,function(r,i,s){Da(n,i,e(r,i,s))}),n}o(Il,"mapValues");var Nm=Il,Mm="Expected a function";function Zl(t){if(typeof t!="function")throw new TypeError(Mm);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)}}o(Zl,"negate");var $m=Zl;function Bl(t,e,n,r){if(!ut(t))return t;e=ir(e,t);for(var i=-1,s=e.length,a=s-1,l=t;l!=null&&++i<s;){var c=Vt(e[i]),d=n;if(c==="__proto__"||c==="constructor"||c==="prototype")return t;if(i!=a){var g=l[c];d=r?r(g,c,l):void 0,d===void 0&&(d=ut(g)?g:ai(e[i+1])?[]:{})}Sp(l,c,d),l=l[c]}return t}o(Bl,"baseSet");var jm=Bl;function Al(t,e,n){for(var r=-1,i=e.length,s={};++r<i;){var a=e[r],l=di(t,a);n(l,a)&&jm(s,ir(a,t),l)}return s}o(Al,"basePickBy");var Km=Al;function Cl(t,e){if(t==null)return{};var n=Pa(Zg(t),function(r){return[r]});return e=fi(e),Km(t,n,function(r,i){return e(r,i[0])})}o(Cl,"pickBy");var Um=Cl;function Rl(t,e){return Um(t,$m(fi(e)))}o(Rl,"omitBy");var As=Rl,Fm=o(t=>{let e=t.checks;return e.length===0?"":e.map(zm).join("")},"generateStringChecks"),zm=o(t=>{switch(t.kind){case"min":return`.min(${b(t.value)}, ${b(t.message)})`;case"max":return`.max(${b(t.value)}, ${b(t.message)})`;case"length":return`.length(${b(t.value)}, ${b(t.message)})`;case"email":return`.email(${b(t.message)})`;case"url":return`.url(${b(t.message)})`;case"emoji":return`.emoji(${b(t.message)})`;case"uuid":return`.uuid(${b(t.message)})`;case"cuid":return`.cuid(${b(t.message)})`;case"cuid2":return`.cuid2(${b(t.message)})`;case"ulid":return`.ulid(${b(t.message)})`;case"includes":let e=ot({message:t.message,position:t.position});return`.includes(${b(t.value)}, ${e})`;case"startsWith":return`.startsWith(${b(t.value)}, ${b(t.message)})`;case"endsWith":return`.endsWith(${b(t.value)}, ${b(t.message)})`;case"regex":return`.regex(${String(t.regex)}, ${b(t.message)})`;case"trim":return".trim()";case"toLowerCase":return".toLowerCase()";case"toUpperCase":return".toUpperCase()";case"datetime":let r=t.precision===null?void 0:t.precision;return`.datetime(${ot({message:t.message,precision:r,offset:t.offset})})`;case"ip":return`.ip(${ot({message:t.message,version:t.version})})`;default:return""}},"_generateStringCheck"),Wm=o(t=>{let e=t.checks;return e.length===0?"":e.map(Lm).join("")},"generateNumberChecks"),Lm=o(t=>{switch(t.kind){case"min":return`.min(${b(t.value)}, ${b(t.message)})`;case"max":return`.max(${b(t.value)}, ${b(t.message)})`;case"int":return`.int(${b(t.message)})`;case"multipleOf":return`.multipleOf(${b(t.value)}, ${b(t.message)})`;case"finite":return`.finite(${b(t.message)})`;default:return""}},"_generateNumberCheck"),Vm=o(t=>{let e=t.checks;return e.length===0?"":e.map(qm).join("")},"generateBigIntChecks"),qm=o(t=>{switch(t.kind){case"min":return`.min(${b(t.value)}, ${b(t.message)})`;case"max":return`.max(${b(t.value)}, ${b(t.message)})`;case"multipleOf":return`.multipleOf(${b(t.value)}, ${b(t.message)})`;default:return""}},"_generateBigIntCheck"),Gm=o(t=>{let e=t.checks;return e.length===0?"":e.map(Jm).join("")},"generateDateChecks"),Jm=o(t=>{switch(t.kind){case"min":return`.min(${Cs(t.value)}, ${b(t.message)})`;case"max":return`.max(${Cs(t.value)}, ${b(t.message)})`;default:return""}},"_generateDateCheck"),Cs=o(t=>`new Date(${t})`,"dateTs"),Ym=o(t=>{let e=[];if(t.exactLength){let{value:n,message:r}=t.exactLength;e.push(`.length(${b(n)}, ${b(r)})`)}if(t.minLength){let{value:n,message:r}=t.minLength;e.push(`.min(${b(n)}, ${b(r)})`)}if(t.maxLength){let{value:n,message:r}=t.maxLength;e.push(`.max(${b(n)}, ${b(r)})`)}return e.join("")},"generateArrayChecks"),Xm=o(t=>{let e=[];if(t.minSize){let{value:n,message:r}=t.minSize;e.push(`.min(${b(n)}, ${b(r)})`)}if(t.maxSize){let{value:n,message:r}=t.maxSize;e.push(`.max(${b(n)}, ${b(r)})`)}return e.join("")},"generateSetChecks");function gi(t){return M(t)}o(gi,"toTypescriptSchema");function M(t){let n=t._def;switch(n.typeName){case p.ZodFirstPartyTypeKind.ZodString:return`z.string()${Fm(n)}${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodNumber:return`z.number()${Wm(n)}${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodNaN:return`z.nan()${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodBigInt:return`z.bigint()${Vm(n)}${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodBoolean:return`z.boolean()${R(n)}${C(t._def)}`.trim();case p.ZodFirstPartyTypeKind.ZodDate:return`z.date()${Gm(n)}${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodUndefined:return`z.undefined()${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodNull:return`z.null()${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodAny:return`z.any()${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodUnknown:return`z.unknown()${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodNever:return`z.never()${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodVoid:return`z.void()${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodArray:return`z.array(${M(n.type)})${Ym(n)}${R(n)}${C(n)}`;case p.ZodFirstPartyTypeKind.ZodObject:let r=Nm(n.shape(),M),i=t.additionalProperties(),s=i?`.catchall(${M(i)})`:"";return["z.object({",...Object.entries(r).map(([wd,Pd])=>` ${wd}: ${Pd},`),`})${s}${R(n)}${C(n)}`].join(`
16
+ `).trim();case p.ZodFirstPartyTypeKind.ZodUnion:return`z.union([${n.options.map(M).join(", ")}])${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:let l=n.options.map(M);return`z.discriminatedUnion(${b(n.discriminator)}, [${l.join(", ")}])${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodIntersection:let d=M(n.left),g=M(n.right);return`z.intersection(${d}, ${g})${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodTuple:return`z.tuple([${n.items.map(M).join(", ")}])${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodRecord:let T=M(n.keyType),I=M(n.valueType);return`z.record(${T}, ${I})${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodMap:let k=M(n.keyType),K=M(n.valueType);return`z.map(${k}, ${K})${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodSet:return`z.set(${M(n.valueType)})${Xm(n)}${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodFunction:let z=n.args.items.map(M),Q=z.length?`.args(${z.join(", ")})`:"",ae=M(n.returns);return`z.function()${Q}.returns(${ae})${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodLazy:return`z.lazy(() => ${M(n.getter())})${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodLiteral:return`z.literal(${b(n.value)})${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodEnum:return`z.enum([${n.values.map(b).join(", ")}])${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodEffects:throw new De(p.ZodFirstPartyTypeKind.ZodEffects);case p.ZodFirstPartyTypeKind.ZodNativeEnum:throw new De(p.ZodFirstPartyTypeKind.ZodNativeEnum);case p.ZodFirstPartyTypeKind.ZodOptional:return`z.optional(${M(n.innerType)})${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodNullable:return`z.nullable(${M(n.innerType)})${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodDefault:let ee=ot(n.defaultValue());return`z.default(${M(n.innerType)}, ${ee})${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodCatch:throw new De(p.ZodFirstPartyTypeKind.ZodCatch);case p.ZodFirstPartyTypeKind.ZodPromise:return`z.promise(${M(n.type)})${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodBranded:throw new De(p.ZodFirstPartyTypeKind.ZodBranded);case p.ZodFirstPartyTypeKind.ZodPipeline:throw new De(p.ZodFirstPartyTypeKind.ZodPipeline);case p.ZodFirstPartyTypeKind.ZodSymbol:throw new De(p.ZodFirstPartyTypeKind.ZodSymbol);case p.ZodFirstPartyTypeKind.ZodReadonly:return`z.readonly(${M(n.innerType)})${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodRef:return`z.ref(${b(n.uri)})${R(n)}${C(n)}`.trim();default:Z.assertNever(n)}}o(M,"sUnwrapZod");var C=o(t=>t.description?`.describe(${b(t.description)})`:"","_maybeDescribe"),R=o(t=>`${Qm(t)}${eh(t)}${th(t)}${nh(t)}${rh(t)}${ih(t)}${sh(t)}`,"_addZuiExtensions"),Qm=o(t=>{var e;return(e=t[w])!=null&&e.title?`.title(${b(t[w].title)})`:""},"_maybeTitle"),eh=o(t=>{var e;return(e=t[w])!=null&&e.displayAs?`.displayAs(${Fs({id:t[w].displayAs[0],params:t[w].displayAs[1]})})`:""},"_maybeDisplayAs"),th=o(t=>{var e;return(e=t[w])!=null&&e.disabled?`.disabled(${t[w].disabled})`:""},"_maybeDisabled"),nh=o(t=>{var e;return(e=t[w])!=null&&e.hidden?`.hidden(${t[w].hidden})`:""},"_maybeHidden"),rh=o(t=>{var e;return(e=t[w])!=null&&e.placeholder?`.placeholder(${b(t[w].placeholder)})`:""},"_maybePlaceholder"),ih=o(t=>{var e;return(e=t[w])!=null&&e.secret?".secret()":""},"_maybeSecret"),sh=o(t=>{var e;let n=["title","tooltip","displayAs","disabled","hidden","placeholder","secret","coerce"],r=Object.entries((e=t[w])!=null?e:{}).filter(([i])=>!n.includes(i));return r.length>0?`.metadata(${Fs(Object.fromEntries(r))})`:""},"_maybeSetMetadata"),ah=o(t=>{let e={type:"number",description:t.description,"x-zui":t._def["x-zui"]};t._def[w]&&(e[w]=t._def[w]);for(let n of t._def.checks)switch(n.kind){case"min":{let r=n.inclusive?"minimum":"exclusiveMinimum",i=n.inclusive?"exclusiveMinimum":"minimum";e[r]=n.value,delete e[i];break}case"max":{let r=n.inclusive?"maximum":"exclusiveMaximum",i=n.inclusive?"exclusiveMaximum":"maximum";e[r]=n.value,delete e[i];break}case"int":e.type="integer";break;case"finite":{e.format="finite";break}case"multipleOf":e.multipleOf=n.value;break;default:}return e},"zodNumberToJsonNumber"),Dl="\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}",Hl="(([+-]\\d{2}(:?\\d{2})?)|Z)",oh="Z",Nl="(\\.\\d+)?",Yr="\\.\\d{",lh="}",Ml=o(t=>{let e=t.precision?Yr+t.precision+lh:t.precision===0?"":Nl,n=t.offset?Hl:oh;return new RegExp(`^${Dl}${e}${n}$`)},"generateDatetimeRegex"),ch=o(t=>({precision:uh(t),offset:t.endsWith(`${Hl}$`)}),"extractPrecisionAndOffset"),uh=o(t=>{let e=t.slice(1+Dl.length);return e.startsWith(Nl)?null:e.startsWith(Yr)?parseInt(e.slice(Yr.length)):0},"_extractPrecision"),jt={};Gn(jt,{escapeSpecialChars:()=>dh});var dh=o(t=>t.replaceAll(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeSpecialChars");function mi(t,e,n,r){r?.errorMessages&&n&&(t.errorMessage=f(u({},t.errorMessage),{[e]:n}))}o(mi,"addErrorMessage");function D(t,e,n,r,i){t[e]=n,mi(t,e,r,i)}o(D,"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 hi(t,e){let n=u({type:"string"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{});function r(i){return e.patternStrategy==="escape"?jt.escapeSpecialChars(i):i}if(o(r,"processPattern"),t.checks)for(let i of t.checks)switch(i.kind){case"min":D(n,"minLength",typeof n.minLength=="number"?Math.max(n.minLength,i.value):i.value,i.message,e);break;case"max":D(n,"maxLength",typeof n.maxLength=="number"?Math.min(n.maxLength,i.value):i.value,i.message,e);break;case"email":switch(e.emailStrategy){case"format:email":Re(n,"email",i.message,e);break;case"format:idn-email":Re(n,"idn-email",i.message,e);break;case"pattern:zod":Te(n,j.email,i.message,e);break}break;case"url":Re(n,"uri",i.message,e);break;case"uuid":Re(n,"uuid",i.message,e);break;case"regex":Te(n,i.regex.source,i.message,e);break;case"cuid":Te(n,j.cuid,i.message,e);break;case"cuid2":Te(n,j.cuid2,i.message,e);break;case"startsWith":Te(n,"^"+r(i.value),i.message,e);break;case"endsWith":Te(n,r(i.value)+"$",i.message,e);break;case"datetime":Re(n,"date-time",i.message,e);break;case"length":D(n,"minLength",typeof n.minLength=="number"?Math.max(n.minLength,i.value):i.value,i.message,e),D(n,"maxLength",typeof n.maxLength=="number"?Math.min(n.maxLength,i.value):i.value,i.message,e);break;case"includes":{Te(n,r(i.value),i.message,e);break}case"ip":{i.version!=="v6"&&Re(n,"ipv4",i.message,e),i.version!=="v4"&&Re(n,"ipv6",i.message,e);break}case"emoji":Te(n,j.emoji,i.message,e);break;case"ulid":{Te(n,j.ulid,i.message,e);break}case"toLowerCase":case"toUpperCase":case"trim":break;default:}return n}o(hi,"parseStringDef");var Re=o((t,e,n,r)=>{var i;t.format||(i=t.anyOf)!=null&&i.some(s=>s.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push(u({format:t.format},t.errorMessage&&r.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(u({format:e},n&&r.errorMessages&&{errorMessage:{format:n}}))):D(t,"format",e,n,r)},"addFormat"),Te=o((t,e,n,r)=>{var i;t.pattern||(i=t.allOf)!=null&&i.some(s=>s.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push(u({pattern:t.pattern},t.errorMessage&&r.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(u({pattern:e},n&&r.errorMessages&&{errorMessage:{pattern:n}}))):D(t,"pattern",e,n,r)},"addPattern"),ph=o(t=>{let e={type:"string",description:t.description,"x-zui":t._def["x-zui"]};t._def[w]&&(e[w]=t._def[w]);for(let n of t._def.checks)switch(n.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=n.version==="v6"?"ipv6":"ipv4",e.pattern=n.version==="v6"?j.ipv6:j.ipv4;break;case"datetime":e.format="date-time",e.pattern=Ml(n).source,e[w]=f(u({},e[w]),{precision:n.precision,offset:n.offset});break;case"url":e.format="uri";break;case"endsWith":e.pattern=`${jt.escapeSpecialChars(n.value)}$`;break;case"startsWith":e.pattern=`^${jt.escapeSpecialChars(n.value)}`;break;case"includes":let r=n.position&&n.position>=1?`^(?:.{${n.position}}).*`:"";e.pattern=`${r}${jt.escapeSpecialChars(n.value)}`;break;case"regex":e.pattern=n.regex.source;break;case"length":e.minLength=e.maxLength=Math.max(0,n.value);break;case"min":e.minLength=Math.max(0,n.value);break;case"max":e.maxLength=Math.max(0,n.value);break;default:throw new Qs({zodType:p.ZodFirstPartyTypeKind.ZodString,checkKind:n.kind})}return e},"zodStringToJsonString"),fh=o((t,e)=>{let n={type:"array",description:t.description,items:e(t._def.type),"x-zui":t._def["x-zui"]};return t._def[w]&&(n[w]=t._def[w]),t._def.minLength&&(n.minItems=t._def.minLength.value),t._def.maxLength&&(n.maxItems=t._def.maxLength.value),t._def.exactLength&&(n.minItems=t._def.exactLength.value,n.maxItems=t._def.exactLength.value),n},"zodArrayToJsonArray"),gh=o((t,e)=>{let n={type:"array",description:t.description,uniqueItems:!0,items:e(t._def.valueType),"x-zui":t._def["x-zui"]};return t._def[w]&&(n[w]=t._def[w]),t._def.minSize&&(n.minItems=t._def.minSize.value),t._def.maxSize&&(n.maxItems=t._def.maxSize.value),n},"zodSetToJsonSet"),mh=o((t,e)=>{let n={type:"array",description:t.description,items:t._def.items.map(r=>e(r))};return t._def[w]&&(n[w]=t._def[w]),t._def.rest&&(n.additionalItems=e(t._def.rest)),n},"zodTupleToJsonTuple");function V(t){let e=t,n=e._def;switch(n.typeName){case p.ZodFirstPartyTypeKind.ZodString:return ph(e);case p.ZodFirstPartyTypeKind.ZodNumber:return ah(e);case p.ZodFirstPartyTypeKind.ZodNaN:throw new te(p.ZodFirstPartyTypeKind.ZodNaN);case p.ZodFirstPartyTypeKind.ZodBigInt:throw new te(p.ZodFirstPartyTypeKind.ZodBigInt,{suggestedAlternative:"serialize bigint to string"});case p.ZodFirstPartyTypeKind.ZodBoolean:return{type:"boolean",description:n.description,"x-zui":n["x-zui"]};case p.ZodFirstPartyTypeKind.ZodDate:throw new te(p.ZodFirstPartyTypeKind.ZodDate,{suggestedAlternative:"use z.string().datetime() instead"});case p.ZodFirstPartyTypeKind.ZodUndefined:return jr(n);case p.ZodFirstPartyTypeKind.ZodNull:return Kr(n);case p.ZodFirstPartyTypeKind.ZodAny:return{description:n.description,"x-zui":n["x-zui"]};case p.ZodFirstPartyTypeKind.ZodUnknown:return{description:n.description,"x-zui":f(u({},n["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodUnknown}})};case p.ZodFirstPartyTypeKind.ZodNever:return{not:!0,description:n.description,"x-zui":n["x-zui"]};case p.ZodFirstPartyTypeKind.ZodVoid:throw new te(p.ZodFirstPartyTypeKind.ZodVoid);case p.ZodFirstPartyTypeKind.ZodArray:return fh(e,V);case p.ZodFirstPartyTypeKind.ZodObject:let r=Object.entries(n.shape()),i=r.filter(([g,m])=>!m.isOptional()),s=i.length?i.map(([g])=>g):void 0,a=r.map(([g,m])=>[g,m.mandatory()]).map(([g,m])=>[g,V(m)]),l=!1;return n.unknownKeys instanceof p.ZodType?l=V(n.unknownKeys):n.unknownKeys==="passthrough"&&(l=!0),{type:"object",description:n.description,properties:Object.fromEntries(a),required:s,additionalProperties:l,"x-zui":n["x-zui"]};case p.ZodFirstPartyTypeKind.ZodUnion:return{description:n.description,anyOf:n.options.map(g=>V(g)),"x-zui":n["x-zui"]};case p.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:return{description:n.description,anyOf:n.options.map(g=>V(g)),"x-zui":n["x-zui"]};case p.ZodFirstPartyTypeKind.ZodIntersection:let c=V(n.left),d=V(n.right);return"additionalProperties"in c&&delete c.additionalProperties,"additionalProperties"in d&&delete d.additionalProperties,{description:n.description,allOf:[c,d],"x-zui":n["x-zui"]};case p.ZodFirstPartyTypeKind.ZodTuple:return mh(e,V);case p.ZodFirstPartyTypeKind.ZodRecord:return{type:"object",description:n.description,additionalProperties:V(n.valueType),"x-zui":n["x-zui"]};case p.ZodFirstPartyTypeKind.ZodMap:throw new te(p.ZodFirstPartyTypeKind.ZodMap);case p.ZodFirstPartyTypeKind.ZodSet:return gh(e,V);case p.ZodFirstPartyTypeKind.ZodFunction:throw new te(p.ZodFirstPartyTypeKind.ZodFunction);case p.ZodFirstPartyTypeKind.ZodLazy:throw new te(p.ZodFirstPartyTypeKind.ZodLazy);case p.ZodFirstPartyTypeKind.ZodLiteral:if(typeof n.value=="string")return{type:"string",description:n.description,const:n.value,"x-zui":n["x-zui"]};if(typeof n.value=="number")return{type:"number",description:n.description,const:n.value,"x-zui":n["x-zui"]};if(typeof n.value=="boolean")return{type:"boolean",description:n.description,const:n.value,"x-zui":n["x-zui"]};if(n.value===null)return Kr(n);if(n.value===void 0)return jr(n);{p.util.assertEqual(!0);let g=typeof n.value;throw new Yn(`Unsupported literal type: "${g}"`)}case p.ZodFirstPartyTypeKind.ZodEnum:return{type:"string",description:n.description,enum:n.values,"x-zui":n["x-zui"]};case p.ZodFirstPartyTypeKind.ZodEffects:throw new te(p.ZodFirstPartyTypeKind.ZodEffects);case p.ZodFirstPartyTypeKind.ZodNativeEnum:throw new te(p.ZodFirstPartyTypeKind.ZodNativeEnum);case p.ZodFirstPartyTypeKind.ZodOptional:return{description:n.description,anyOf:[V(n.innerType),jr()],"x-zui":f(u({},n["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodOptional}})};case p.ZodFirstPartyTypeKind.ZodNullable:return{anyOf:[V(n.innerType),Kr()],"x-zui":f(u({},n["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodNullable}})};case p.ZodFirstPartyTypeKind.ZodDefault:return f(u({},V(n.innerType)),{default:n.defaultValue()});case p.ZodFirstPartyTypeKind.ZodCatch:throw new te(p.ZodFirstPartyTypeKind.ZodCatch);case p.ZodFirstPartyTypeKind.ZodPromise:throw new te(p.ZodFirstPartyTypeKind.ZodPromise);case p.ZodFirstPartyTypeKind.ZodBranded:throw new te(p.ZodFirstPartyTypeKind.ZodBranded);case p.ZodFirstPartyTypeKind.ZodPipeline:throw new te(p.ZodFirstPartyTypeKind.ZodPipeline);case p.ZodFirstPartyTypeKind.ZodSymbol:throw new te(p.ZodFirstPartyTypeKind.ZodPipeline);case p.ZodFirstPartyTypeKind.ZodReadonly:return f(u({},V(n.innerType)),{readOnly:!0});case p.ZodFirstPartyTypeKind.ZodRef:return{$ref:n.uri,description:n.description,"x-zui":n["x-zui"]};default:p.util.assertNever(n)}}o(V,"toJSONSchema");var jr=o(t=>({not:!0,description:t?.description,"x-zui":f(u({},t?.["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodUndefined}})}),"undefinedSchema"),Kr=o(t=>({type:"null",description:t?.description,"x-zui":t?.["x-zui"]}),"nullSchema"),$l=class{constructor(e,n,r,i){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=i}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}};o($l,"ParseInputLazyPath");var le=$l,Rs=o((t,e)=>{if(pt(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 n=new he(t.common.issues);return this._error=n,this._error}}},"handleResult"),jl=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(u({},this._def))}_getType(e){return we(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:we(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ne,ctx:{common:e.parent.common,data:e.data,parsedType:we(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(Wt(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){var r;let i={common:{issues:[],async:(r=n?.async)!=null?r:!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:we(e)},s=this._parseSync({data:e,path:i.path,parent:i});return Rs(i,s)}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:we(e)},i=this._parse({data:e,path:r.path,parent:r}),s=await(Wt(i)?i:Promise.resolve(i));return Rs(r,s)}refine(e,n){let r=o(i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n,"getIssueProperties");return this._refinement((i,s)=>{let a=e(i),l=o(()=>s.addIssue(u({code:h.custom},r(i))),"setError");return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(l(),!1)):a?!0:(l(),!1)})}refinement(e,n){return this._refinement((r,i)=>e(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(e){return new Ae({schema:this,typeName:"ZodEffects",effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Pe.create(this,this._def)}nullable(){return Fe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return gt.create(this,this._def)}promise(){return Jt.create(this,this._def)}mandatory(){return this}or(e){return vr.create([this,e],this._def)}and(e){return dr.create(this,e,this._def)}transform(e){return new Ae(f(u({},S(this._def)),{schema:this,typeName:"ZodEffects",effect:{type:"transform",transform:e}}))}default(e){let n=typeof e=="function"?e:()=>e;return new qt(f(u({},S(this._def)),{innerType:this,defaultValue:n,typeName:"ZodDefault"}))}brand(){return new lr(u({typeName:"ZodBranded",type:this},S(this._def)))}catch(e){let n=typeof e=="function"?e:()=>e;return new cr(f(u({},S(this._def)),{innerType:this,catchValue:n,typeName:"ZodCatch"}))}describe(e){let n=this.clone();return n._metadataRoot._def.description=e,n}pipe(e){return yr.create(this,e)}readonly(){return Yt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}metadata(e){var n,r,i;let s=this.clone(),a=s._metadataRoot;(i=(n=a._def)[r=w])!=null||(n[r]={});for(let[l,c]of Object.entries(e))a._def[w]=f(u({},a._def[w]),{[l]:c});return s}getMetadata(){return u({},this._metadataRoot._def[w])}setMetadata(e){this._metadataRoot._def[w]=u({},e)}get ui(){return u({},this._metadataRoot._def[w])}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 n;return e===void 0?n=!0:typeof e=="function"?n=e.toString():n=e,this.metadata({hidden:n})}disabled(e){let n;return e===void 0?n=!0:typeof e=="function"?n=e.toString():n=e,this.metadata({disabled:n})}placeholder(e){return this.metadata({placeholder:e})}toJSONSchema(){return V(this)}toTypescriptType(e){return ri(this,e)}toTypescriptSchema(){return gi(this)}naked(){return this}};o(jl,"ZodType");var O=jl,yi=(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))(yi||{}),Z;(t=>{t.assertEqual=o(i=>i,"assertEqual");function e(i){}t.assertIs=e,o(e,"assertIs");function n(i){throw new Error("assertNever called")}t.assertNever=n,o(n,"assertNever"),t.arrayToEnum=o(i=>{let s={};for(let a of i)s[a]=a;return s},"arrayToEnum"),t.getValidEnumValues=o(i=>{let s=(0,t.objectKeys)(i).filter(l=>typeof i[i[l]]!="number"),a={};for(let l of s)a[l]=i[l];return(0,t.objectValues)(a)},"getValidEnumValues"),t.objectValues=o(i=>(0,t.objectKeys)(i).map(function(s){return i[s]}),"objectValues"),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let s=[];for(let a in i)Object.prototype.hasOwnProperty.call(i,a)&&s.push(a);return s},t.find=o((i,s)=>{for(let a of i)if(s(a))return a},"find"),t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}t.joinValues=r,o(r,"joinValues"),t.jsonStringifyReplacer=o((i,s)=>typeof s=="bigint"?s.toString():s,"jsonStringifyReplacer"),t.compareFunctions=o((i,s)=>i.toString()===s.toString(),"compareFunctions"),t.mock=o(()=>({}),"mock")})(Z||(Z={}));var gn;(t=>{t.mergeShapes=o((e,n)=>u(u({},e),n),"mergeShapes")})(gn||(gn={}));var _=Z.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),we=o(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 S(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:i,supportsExtensions:s,[w]:a}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);let l=a?Object.fromEntries(Object.entries(a).filter(([d])=>d!=="secret"||s?.includes("secret"))):void 0;return e?{errorMap:e,description:i,[w]:l}:{errorMap:o((d,g)=>d.code!=="invalid_type"?{message:g.defaultError}:typeof g.data>"u"?{message:r??g.defaultError}:{message:n??g.defaultError},"customMap"),description:i,[w]:l}}o(S,"processCreateParams");var vi=o((t,e)=>{let n;switch(t.code){case h.invalid_type:t.received===_.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case h.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,Z.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:n=`Unrecognized key(s) in object: ${Z.joinValues(t.keys,", ")}`;break;case h.invalid_union:n="Invalid input";break;case h.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Z.joinValues(t.options)}`;break;case h.invalid_enum_value:n=`Invalid enum value. Expected ${Z.joinValues(t.options)}, received '${t.received}'`;break;case h.invalid_arguments:n="Invalid function arguments";break;case h.invalid_return_type:n="Invalid function return type";break;case h.invalid_date:n="Invalid date";break;case h.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:Z.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case h.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case h.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case h.custom:n="Invalid input";break;case h.invalid_intersection_types:n="Intersection results could not be merged";break;case h.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case h.not_finite:n="Number must be finite";break;case h.unresolved_reference:n="Unresolved reference";break;default:n=e.defaultError,Z.assertNever(t)}return{message:n}},"errorMap"),Ds=vi,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"]),Kl=o(t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),mn=class Ul extends Error{constructor(e){super(),this.issues=[],this.addIssue=o(r=>{this.issues=[...this.issues,r]},"addIssue"),this.addIssues=o((r=[])=>{this.issues=[...this.issues,...r]},"addIssues");let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let n=e||function(s){return s.message},r={_errors:[]},i=o(s=>{for(let a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let l=r,c=0;for(;c<a.path.length;){let d=a.path[c];c===a.path.length-1?(l[d]=l[d]||{_errors:[]},l[d]._errors.push(n(a))):l[d]=l[d]||{_errors:[]},l=l[d],c++}}},"processError");return i(this),r}static assert(e){if(!(e instanceof Ul))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=n=>n.message){let n={},r=[];for(let i of this.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(e(i))):r.push(e(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};o(mn,"ZodError");mn.create=o(t=>new mn(t),"create");var he=mn,Fl=vi;function _i(t){Fl=t}o(_i,"setErrorMap");function dt(){return Fl}o(dt,"getErrorMap");var zt=o(t=>{var e;let{data:n,path:r,errorMaps:i,issueData:s}=t,a=[...r,...s.path||[]],l=f(u({},s),{path:a}),c="",d=i.filter(g=>!!g).slice().reverse();for(let g of d)c=g(l,{data:n,defaultError:c}).message;return f(u({},s),{path:a,message:(e=s.message)!=null?e:c})},"makeIssue"),zl=[];function v(t,e){let n=zt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,dt(),vi].filter(r=>!!r)});t.common.issues.push(n)}o(v,"addIssueToContext");var Wl=class Ll{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let i of n){if(i.status==="aborted")return x;i.status==="dirty"&&e.dirty(),r.push(i.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let i of n)r.push({key:await i.key,value:await i.value});return Ll.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let i of n){let{key:s,value:a}=i;if(s.status==="aborted"||a.status==="aborted")return x;s.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(r[s.value]=a.value)}return{status:e.value,value:r}}};o(Wl,"ParseStatus");var ne=Wl,x=Object.freeze({status:"aborted"}),Ke=o(t=>({status:"dirty",value:t}),"DIRTY"),G=o(t=>({status:"valid",value:t}),"OK"),hn=o(t=>t.status==="aborted","isAborted"),yn=o(t=>t.status==="dirty","isDirty"),pt=o(t=>t.status==="valid","isValid"),Wt=o(t=>typeof Promise<"u"&&t instanceof Promise,"isAsync"),P;(t=>{t.errToObj=o(e=>typeof e=="string"?{message:e}:e||{},"errToObj"),t.toString=o(e=>typeof e=="string"?e:e?.message,"toString")})(P||(P={}));var vn=class Vl extends O{constructor(){super(...arguments),this._any=!0}_parse(e){return G(e.data)}isEqual(e){return e instanceof Vl}};o(vn,"ZodAny");vn.create=o(t=>new vn(u({typeName:"ZodAny"},S(t))),"create");var ft=vn,_n=class Ne extends O{dereference(e){return new Ne(f(u({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new Ne(f(u({},this._def),{type:this._def.type.clone()}))}isEqual(e){var n,r,i,s,a,l;return e instanceof Ne?lt((n=this._def.exactLength)==null?void 0:n.value,(r=e._def.exactLength)==null?void 0:r.value)&&lt((i=this._def.maxLength)==null?void 0:i.value,(s=e._def.maxLength)==null?void 0:s.value)&&lt((a=this._def.minLength)==null?void 0:a.value,(l=e._def.minLength)==null?void 0:l.value)&&this._def.type.isEqual(e._def.type):!1}_parse(e){let{ctx:n,status:r}=this._processInputParams(e),i=this._def;if(n.parsedType!==_.array)return v(n,{code:h.invalid_type,expected:_.array,received:n.parsedType}),x;if(i.exactLength!==null){let a=n.data.length>i.exactLength.value,l=n.data.length<i.exactLength.value;(a||l)&&(v(n,{code:a?h.too_big:h.too_small,minimum:l?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(v(n,{code:h.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(v(n,{code:h.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((a,l)=>i.type._parseAsync(new le(n,a,n.path,l)))).then(a=>ne.mergeArray(r,a));let s=[...n.data].map((a,l)=>i.type._parseSync(new le(n,a,n.path,l)));return ne.mergeArray(r,s)}get element(){return this._def.type}min(e,n){return new Ne(f(u({},this._def),{minLength:{value:e,message:P.toString(n)}}))}max(e,n){return new Ne(f(u({},this._def),{maxLength:{value:e,message:P.toString(n)}}))}length(e,n){return new Ne(f(u({},this._def),{exactLength:{value:e,message:P.toString(n)}}))}nonempty(e){return this.min(1,e)}};o(_n,"ZodArray");_n.create=o((t,e)=>new _n(u({type:t,minLength:null,maxLength:null,exactLength:null,typeName:"ZodArray"},S(e))),"create");var gt=_n,hh=o((t,e)=>ql(t,e,new WeakSet),"isEqual"),ql=o((t,e,n)=>Hm(t,e,yh(n)),"_isEqualWithVisitedTracking"),yh=o(t=>(e,n)=>{if(ys(e)&&!t.has(e)&&ys(n)&&!t.has(n)){let r=As(e,Bs),i=As(n,Bs);return t.add(r).add(i).add(e).add(n),ql(r,i,t)}},"_customizerWithVisitedTracking"),vh={compare:hh},Gl=class{constructor(e=[],n={}){this._options=u(u({},vh),n),this._items=[];for(let r of e)this.add(r)}get items(){return[...this._items]}get size(){return this._items.length}has(e){return this._items.some(n=>this._options.compare(n,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(n=>e.has(n))}};o(Gl,"CustomSet");var U=Gl,Tn=class an 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 s=this._getOrReturnCtx(e);return v(s,{code:h.invalid_type,expected:_.bigint,received:s.parsedType}),x}let r,i=new ne;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),v(r,{code:h.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),v(r,{code:h.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),v(r,{code:h.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):Z.assertNever(s);return{status:i.value,value:e.data}}isEqual(e){if(!(e instanceof an)||this._def.coerce!==e._def.coerce)return!1;let n=new U(this._def.checks),r=new U(e._def.checks);return n.isEqual(r)}gte(e,n){return this.setLimit("min",e,!0,P.toString(n))}gt(e,n){return this.setLimit("min",e,!1,P.toString(n))}lte(e,n){return this.setLimit("max",e,!0,P.toString(n))}lt(e,n){return this.setLimit("max",e,!1,P.toString(n))}setLimit(e,n,r,i){return new an(f(u({},this._def),{checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:P.toString(i)}]}))}_addCheck(e){return new an(f(u({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:P.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:P.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:P.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:P.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:P.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};o(Tn,"ZodBigInt");Tn.create=o(t=>{var e;return new Tn(u({checks:[],typeName:"ZodBigInt",coerce:(e=t?.coerce)!=null?e:!1},S(t)))},"create");var ar=Tn,bn=class Jl extends O{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==_.boolean){let r=this._getOrReturnCtx(e);return v(r,{code:h.invalid_type,expected:_.boolean,received:r.parsedType}),x}return G(e.data)}isEqual(e){return e instanceof Jl?this._def.coerce===e._def.coerce:!1}};o(bn,"ZodBoolean");bn.create=o(t=>new bn(u({typeName:"ZodBoolean",coerce:t?.coerce||!1},S(t))),"create");var or=bn,Yl=Symbol("zod_brand"),Xl=class St extends O{dereference(e){return new St(f(u({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new St(f(u({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}isEqual(e){return e instanceof St?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}mandatory(){return new St(f(u({},this._def),{type:this._def.type.mandatory()}))}};o(Xl,"ZodBranded");var lr=Xl,wn=class Et extends O{_parse(e){let{ctx:n}=this._processInputParams(e),r=f(u({},n),{common:f(u({},n.common),{issues:[]})}),i=this._def.innerType._parse({data:r.data,path:r.path,parent:u({},r)});return Wt(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new he(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new he(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}isEqual(e){return e instanceof Et?this._def.innerType.isEqual(e._def.innerType)&&Z.compareFunctions(this._def.catchValue,e._def.catchValue):!1}dereference(e){return new Et(f(u({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new Et(f(u({},this._def),{innerType:this._def.innerType.clone()}))}naked(){return this._def.innerType.naked()}mandatory(){return new Et(f(u({},this._def),{innerType:this._def.innerType.mandatory()}))}};o(wn,"ZodCatch");wn.create=o((t,e)=>new wn(u({innerType:t,typeName:"ZodCatch",catchValue:typeof e.catch=="function"?e.catch:()=>e.catch},S(e))),"create");var cr=wn,Ti=o((t,e={},n)=>t?ft.create().superRefine((r,i)=>{var s,a;if(!t(r)){let l=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e,c=(a=(s=l.fatal)!=null?s:n)!=null?a:!0,d=typeof l=="string"?{message:l}:l;i.addIssue(f(u({code:"custom"},d),{fatal:c}))}}):ft.create(),"custom"),Pn=class Xr extends O{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==_.date){let s=this._getOrReturnCtx(e);return v(s,{code:h.invalid_type,expected:_.date,received:s.parsedType}),x}if(isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return v(s,{code:h.invalid_date}),x}let r=new ne,i;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),v(i,{code:h.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),v(i,{code:h.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):Z.assertNever(s);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Xr(f(u({},this._def),{checks:[...this._def.checks,e]}))}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:P.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:P.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}isEqual(e){if(!(e instanceof Xr))return!1;let n=new U(this._def.checks),r=new U(e._def.checks);return n.isEqual(r)&&this._def.coerce===e._def.coerce}};o(Pn,"ZodDate");Pn.create=o(t=>new Pn(u({checks:[],coerce:t?.coerce||!1,typeName:"ZodDate"},S(t))),"create");var ur=Pn,xn=class Ot extends O{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===_.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}dereference(e){return new Ot(f(u({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new Ot(f(u({},this._def),{innerType:this._def.innerType.clone()}))}isEqual(e){return e instanceof Ot?this._def.innerType.isEqual(e._def.innerType)&&lt(this._def.defaultValue(),e._def.defaultValue()):!1}unwrap(){return this._def.innerType}naked(){return this._def.innerType.naked()}mandatory(){return new Ot(f(u({},this._def),{innerType:this._def.innerType.mandatory()}))}};o(xn,"ZodDefault");xn.create=o((t,e,n)=>new xn(u({innerType:t,typeName:"ZodDefault",defaultValue:typeof e=="function"?e:()=>e},S(n))),"create");var qt=xn,Se=o(t=>Array.from(new Set(t)),"unique"),be=o(t=>t instanceof pr?be(t.schema):t instanceof Ae?be(t.innerType()):t instanceof fr?[t.value]:t instanceof Qe?t.options:t instanceof gr?Z.objectValues(t.enum):t instanceof qt?be(t._def.innerType):t instanceof Xt?[void 0]:t instanceof mr?[null]:t instanceof Pe?[void 0,...be(t.unwrap())]:t instanceof Fe?[null,...be(t.unwrap())]:t instanceof lr||t instanceof Yt?be(t.unwrap()):t instanceof cr?be(t._def.innerType):[],"getDiscriminator"),Ql=class Me extends O{dereference(e){let n=this.options.map(i=>i.dereference(e)),r=Me._getOptionsMap(this.discriminator,n);return new Me(f(u({},this._def),{options:n,optionsMap:r}))}getReferences(){return Se(this.options.flatMap(e=>e.getReferences()))}clone(){let e=this.options.map(n=>n.clone());return new Me(f(u({},this._def),{options:e}))}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==_.object)return v(n,{code:h.invalid_type,expected:_.object,received:n.parsedType}),x;let r=this.discriminator,i=n.data[r],s=this.optionsMap.get(i);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(v(n,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),x)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let i=Me._getOptionsMap(e,n);return new Me(u({typeName:"ZodDiscriminatedUnion",discriminator:e,options:n,optionsMap:i},S(r)))}static _getOptionsMap(e,n){let r=new Map;for(let i of n){let s=be(i.shape[e]);if(!s.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of s){if(r.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);r.set(a,i)}}return r}isEqual(e){if(!(e instanceof Me)||this._def.discriminator!==e._def.discriminator)return!1;let n=o((s,a)=>s.isEqual(a),"compare"),r=new U(this._def.options,{compare:n}),i=new U(e._def.options,{compare:n});return r.isEqual(i)}};o(Ql,"ZodDiscriminatedUnion");var bi=Ql;function Gt(t,e){return new Qe(u({values:t,typeName:"ZodEnum"},S(e)))}o(Gt,"createZodEnum");var wi=class on extends O{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return v(n,{expected:Z.joinValues(r),received:n.parsedType,code:h.invalid_type}),x}if(this._def.values.indexOf(e.data)===-1){let n=this._getOrReturnCtx(e),r=this._def.values;return v(n,{received:n.data,code:h.invalid_enum_value,options:r}),x}return G(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return on.create(e,u(u({},this._def),n))}exclude(e,n=this._def){return on.create(this.options.filter(r=>!e.includes(r)),u(u({},this._def),n))}isEqual(e){if(!(e instanceof on))return!1;let n=new U(this._def.values),r=new U(e._def.values);return n.isEqual(r)}};o(wi,"ZodEnum");wi.create=Gt;var Qe=wi,ec=class $e extends O{constructor(){super(...arguments),this.validate=this.implement}dereference(e){let n=this._def.args.dereference(e),r=this._def.returns.dereference(e);return new $e(f(u({},this._def),{args:n,returns:r}))}getReferences(){return Se([...this._def.args.getReferences(),...this._def.returns.getReferences()])}clone(){return new $e(f(u({},this._def),{args:this._def.args.clone(),returns:this._def.returns.clone()}))}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==_.function)return v(n,{code:h.invalid_type,expected:_.function,received:n.parsedType}),x;function r(l,c){return zt({data:l,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,dt(),Ds].filter(d=>!!d),issueData:{code:h.invalid_arguments,argumentsError:c}})}o(r,"makeArgsIssue");function i(l,c){return zt({data:l,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,dt(),Ds].filter(d=>!!d),issueData:{code:h.invalid_return_type,returnTypeError:c}})}o(i,"makeReturnsIssue");let s={errorMap:n.common.contextualErrorMap},a=n.data;if(this._def.returns instanceof Jt){let l=this;return G(async function(...c){let d=new he([]),g=await l._def.args.parseAsync(c,s).catch(I=>{throw d.addIssue(r(c,I)),d}),m=await Reflect.apply(a,this,g);return await l._def.returns._def.type.parseAsync(m,s).catch(I=>{throw d.addIssue(i(m,I)),d})})}else{let l=this;return G(function(...c){let d=l._def.args.safeParse(c,s);if(!d.success)throw new he([r(c,d.error)]);let g=Reflect.apply(a,this,d.data),m=l._def.returns.safeParse(g,s);if(!m.success)throw new he([i(g,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new $e(f(u({},this._def),{args:We.create(e).rest(ct.create())}))}returns(e){return new $e(f(u({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new $e(u({args:e||We.create([]).rest(ct.create()),returns:n||ct.create(),typeName:"ZodFunction"},S(r)))}isEqual(e){return e instanceof $e&&this._def.args.isEqual(e._def.args)&&this._def.returns.isEqual(e._def.returns)}};o(ec,"ZodFunction");var Pi=ec;function kn(t,e){let n=we(t),r=we(e);if(t===e)return{valid:!0,data:t};if(n===_.object&&r===_.object){let i=Z.objectKeys(e),s=Z.objectKeys(t).filter(l=>i.indexOf(l)!==-1),a=u(u({},t),e);for(let l of s){let c=kn(t[l],e[l]);if(!c.valid)return{valid:!1};a[l]=c.data}return{valid:!0,data:a}}else if(n===_.array&&r===_.array){if(t.length!==e.length)return{valid:!1};let i=[];for(let s=0;s<t.length;s++){let a=t[s],l=e[s],c=kn(a,l);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return n===_.date&&r===_.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}o(kn,"mergeValues");var Sn=class ln extends O{dereference(e){return new ln(f(u({},this._def),{left:this._def.left.dereference(e),right:this._def.right.dereference(e)}))}getReferences(){return Se([...this._def.left.getReferences(),...this._def.right.getReferences()])}clone(){return new ln(f(u({},this._def),{left:this._def.left.clone(),right:this._def.right.clone()}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),i=o((s,a)=>{if(hn(s)||hn(a))return x;let l=kn(s.value,a.value);return l.valid?((yn(s)||yn(a))&&n.dirty(),{status:n.value,value:l.data}):(v(r,{code:h.invalid_intersection_types}),x)},"handleParsed");return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,a])=>i(s,a)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}isEqual(e){if(!(e instanceof ln))return!1;let n=o((s,a)=>s.isEqual(a),"compare"),r=new U([this._def.left,this._def.right],{compare:n}),i=new U([e._def.left,e._def.right],{compare:n});return r.isEqual(i)}};o(Sn,"ZodIntersection");Sn.create=o((t,e,n)=>new Sn(u({left:t,right:e,typeName:"ZodIntersection"},S(n))),"create");var dr=Sn,En=class It extends O{get schema(){return this._def.getter()}dereference(e){return new It(f(u({},this._def),{getter:o(()=>this._def.getter().dereference(e),"getter")}))}getReferences(){return this._def.getter().getReferences()}clone(){return new It(f(u({},this._def),{getter:o(()=>this._def.getter().clone(),"getter")}))}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}isEqual(e){return e instanceof It?this._def.getter().isEqual(e._def.getter()):!1}naked(){return this._def.getter().naked()}mandatory(){return new It(f(u({},this._def),{getter:o(()=>this._def.getter().mandatory(),"getter")}))}};o(En,"ZodLazy");En.create=o((t,e)=>new En(u({getter:t,typeName:"ZodLazy"},S(e))),"create");var pr=En,On=class tc extends O{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return v(n,{received:n.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 tc?lt(this._def.value,e._def.value):!1}};o(On,"ZodLiteral");On.create=o((t,e)=>new On(u({value:t,typeName:"ZodLiteral"},S(e))),"create");var fr=On,In=class cn extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}dereference(e){let n=this._def.keyType.dereference(e),r=this._def.valueType.dereference(e);return new cn(f(u({},this._def),{keyType:n,valueType:r}))}getReferences(){return Se([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new cn(f(u({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==_.map)return v(r,{code:h.invalid_type,expected:_.map,received:r.parsedType}),x;let i=this._def.keyType,s=this._def.valueType,a=[...r.data.entries()].map(([l,c],d)=>({key:i._parse(new le(r,l,r.path,[d,"key"])),value:s._parse(new le(r,c,r.path,[d,"value"]))}));if(r.common.async){let l=new Map;return Promise.resolve().then(async()=>{for(let c of a){let d=await c.key,g=await c.value;if(d.status==="aborted"||g.status==="aborted")return x;(d.status==="dirty"||g.status==="dirty")&&n.dirty(),l.set(d.value,g.value)}return{status:n.value,value:l}})}else{let l=new Map;for(let c of a){let d=c.key,g=c.value;if(d.status==="aborted"||g.status==="aborted")return x;(d.status==="dirty"||g.status==="dirty")&&n.dirty(),l.set(d.value,g.value)}return{status:n.value,value:l}}}isEqual(e){return!(!(e instanceof cn)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};o(In,"ZodMap");In.create=o((t,e,n)=>new In(u({valueType:e,keyType:t,typeName:"ZodMap"},S(n))),"create");var xi=In,Zn=class nc extends O{_parse(e){if(this._getType(e)!==_.nan){let r=this._getOrReturnCtx(e);return v(r,{code:h.invalid_type,expected:_.nan,received:r.parsedType}),x}return{status:"valid",value:e.data}}isEqual(e){return e instanceof nc}};o(Zn,"ZodNaN");Zn.create=o(t=>new Zn(u({typeName:"ZodNaN"},S(t))),"create");var ki=Zn,Bn=class rc extends O{_parse(e){let n=Z.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==_.string&&r.parsedType!==_.number){let i=Z.objectValues(n);return v(r,{expected:Z.joinValues(i),received:r.parsedType,code:h.invalid_type}),x}if(n.indexOf(e.data)===-1){let i=Z.objectValues(n);return v(r,{received:r.data,code:h.invalid_enum_value,options:i}),x}return G(e.data)}get enum(){return this._def.values}isEqual(e){return e instanceof rc?lt(this._def.values,e._def.values):!1}};o(Bn,"ZodNativeEnum");Bn.create=o((t,e)=>new Bn(u({values:t,typeName:"ZodNativeEnum"},S(e))),"create");var gr=Bn,An=class ic extends O{_parse(e){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.never,received:n.parsedType}),x}isEqual(e){return e instanceof ic}};o(An,"ZodNever");An.create=o(t=>new An(u({typeName:"ZodNever"},S(t))),"create");var yt=An,Cn=class sc extends O{_parse(e){if(this._getType(e)!==_.null){let r=this._getOrReturnCtx(e);return v(r,{code:h.invalid_type,expected:_.null,received:r.parsedType}),x}return G(e.data)}isEqual(e){return e instanceof sc}};o(Cn,"ZodNull");Cn.create=o(t=>new Cn(u({typeName:"ZodNull"},S(t))),"create");var mr=Cn,Rn=class Zt extends O{dereference(e){return new Zt(f(u({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new Zt(f(u({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)===_.null?G(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof Zt?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new Zt(f(u({},this._def),{innerType:this._def.innerType.mandatory()}))}};o(Rn,"ZodNullable");Rn.create=o((t,e)=>new Rn(u({innerType:t,typeName:"ZodNullable"},S(e))),"create");var Fe=Rn;function ac(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,i=n>r?n:r,s=parseInt(t.toFixed(i).replace(".","")),a=parseInt(e.toFixed(i).replace(".",""));return s%a/Math.pow(10,i)}o(ac,"floatSafeRemainder");var Dn=class un 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 s=this._getOrReturnCtx(e);return v(s,{code:h.invalid_type,expected:_.number,received:s.parsedType}),x}let r,i=new ne;for(let s of this._def.checks)s.kind==="int"?Z.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),v(r,{code:h.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),v(r,{code:h.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),v(r,{code:h.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?ac(e.data,s.value)!==0&&(r=this._getOrReturnCtx(e,r),v(r,{code:h.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),v(r,{code:h.not_finite,message:s.message}),i.dirty()):Z.assertNever(s);return{status:i.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,P.toString(n))}gt(e,n){return this.setLimit("min",e,!1,P.toString(n))}lte(e,n){return this.setLimit("max",e,!0,P.toString(n))}lt(e,n){return this.setLimit("max",e,!1,P.toString(n))}setLimit(e,n,r,i){return new un(f(u({},this._def),{checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:P.toString(i)}]}))}_addCheck(e){return new un(f(u({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:P.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:P.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:P.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:P.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:P.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:P.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:P.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:P.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:P.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.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,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}isEqual(e){if(!(e instanceof un))return!1;let n=new U(this._def.checks),r=new U(e._def.checks);return n.isEqual(r)}};o(Dn,"ZodNumber");Dn.create=o(t=>new Dn(u({checks:[],typeName:"ZodNumber",coerce:t?.coerce||!1},S(t))),"create");var hr=Dn;function je(t){if(t instanceof ze){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=Pe.create(je(r))}return new ze(f(u({},t._def),{shape:o(()=>e,"shape")}))}else return t instanceof gt?new gt(f(u({},t._def),{type:je(t.element)})):t instanceof Pe?Pe.create(je(t.unwrap())):t instanceof Fe?Fe.create(je(t.unwrap())):t instanceof We?We.create(t.items.map(e=>je(e))):t}o(je,"deepPartialify");var Be=class se 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(),n=Z.objectKeys(e);return this._cached={shape:e,keys:n}}dereference(e){let n=this._def.shape(),r={};for(let i in n)r[i]=n[i].dereference(e);return new se(f(u({},this._def),{shape:o(()=>r,"shape")}))}getReferences(){let e=this._def.shape(),n=[];for(let r in e)n.push(...e[r].getReferences());return Se(n)}clone(){let e={},n=this._def.shape();for(let[r,i]of Object.entries(n))e[r]=i.clone();return new se(f(u({},this._def),{shape:o(()=>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:r,ctx:i}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),l=[];if(this._def.unknownKeys!=="strip")for(let g in i.data)a.includes(g)||l.push(g);let c=[];for(let g of a){let m=s[g],T=i.data[g];c.push({key:{status:"valid",value:g},value:m._parse(new le(i,T,i.path,g)),alwaysSet:g in i.data})}let d=this._def.unknownKeys;if(d==="passthrough")for(let g of l)c.push({key:{status:"valid",value:g},value:{status:"valid",value:i.data[g]}});else if(d==="strict")l.length>0&&(v(i,{code:h.unrecognized_keys,keys:l}),r.dirty());else if(d!=="strip")for(let g of l){let m=i.data[g];c.push({key:{status:"valid",value:g},value:d._parse(new le(i,m,i.path,g)),alwaysSet:g in i.data})}return i.common.async?Promise.resolve().then(async()=>{let g=[];for(let m of c){let T=await m.key;g.push({key:T,value:await m.value,alwaysSet:m.alwaysSet})}return g}).then(g=>ne.mergeObjectSync(r,g)):ne.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return P.errToObj,new se(u(f(u({},this._def),{unknownKeys:"strict"}),e!==void 0?{errorMap:o((n,r)=>{var i,s,a,l;let c=(a=(s=(i=this._def).errorMap)==null?void 0:s.call(i,n,r).message)!=null?a:r.defaultError;return n.code==="unrecognized_keys"?{message:(l=P.errToObj(e).message)!=null?l:c}:{message:c}},"errorMap")}:{}))}strip(){return new se(f(u({},this._def),{unknownKeys:"strip"}))}passthrough(){return new se(f(u({},this._def),{unknownKeys:"passthrough"}))}additionalProperties(){if(this._def.unknownKeys instanceof O)return this._def.unknownKeys;if(this._def.unknownKeys==="passthrough")return ft.create();if(this._def.unknownKeys==="strict")return yt.create()}extend(e){return new se(f(u({},this._def),{shape:o(()=>u(u({},this._def.shape()),e),"shape")}))}merge(e){return new se({unknownKeys:e._def.unknownKeys,shape:o(()=>u(u({},this._def.shape()),e._def.shape()),"shape"),typeName:"ZodObject"})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new se(f(u({},this._def),{unknownKeys:e}))}pick(e){let n={};return Z.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(n[r]=this.shape[r])}),new se(f(u({},this._def),{shape:o(()=>n,"shape")}))}omit(e){let n={};return Z.objectKeys(this.shape).forEach(r=>{e[r]||(n[r]=this.shape[r])}),new se(f(u({},this._def),{shape:o(()=>n,"shape")}))}deepPartial(){return je(this)}partial(e){let n={};return Z.objectKeys(this.shape).forEach(r=>{let i=this.shape[r];e&&!e[r]?n[r]=i:n[r]=i?.optional()}),new se(f(u({},this._def),{shape:o(()=>n,"shape")}))}required(e){let n={};return Z.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof Pe;)s=s._def.innerType;n[r]=s}}),new se(f(u({},this._def),{shape:o(()=>n,"shape")}))}keyof(){return Gt(Z.objectKeys(this.shape))}isEqual(e){if(!(e instanceof se)||!this._unknownKeysEqual(e))return!1;let n=this._def.shape(),r=e._def.shape(),i=o((l,c)=>l[0]===c[0]&&l[1].isEqual(c[1]),"compare"),s=new U(Object.entries(n),{compare:i}),a=new U(Object.entries(r),{compare:i});return s.isEqual(a)}_unknownKeysEqual(e){let n=this.additionalProperties(),r=e.additionalProperties();return n===void 0||r===void 0?n===r:n.isEqual(r)}};o(Be,"ZodObject");Be.create=o((t,e)=>new Be(u({shape:o(()=>t,"shape"),unknownKeys:"strip",typeName:"ZodObject"},S(e))),"create");Be.strictCreate=o((t,e)=>new Be(u({shape:o(()=>t,"shape"),unknownKeys:"strict",typeName:"ZodObject"},S(e))),"strictCreate");Be.lazycreate=o((t,e)=>new Be(u({shape:t,unknownKeys:"strip",typeName:"ZodObject"},S(e))),"lazycreate");var ze=Be,Hn=class dn extends O{dereference(e){return new dn(f(u({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new dn(f(u({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)===_.undefined?G(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof dn?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return this._def.innerType.mandatory()}};o(Hn,"ZodOptional");Hn.create=o((t,e)=>new Hn(u({innerType:t,typeName:"ZodOptional"},S(e))),"create");var Pe=Hn,oc=class Bt extends O{dereference(e){return new Bt(f(u({},this._def),{in:this._def.in.dereference(e),out:this._def.out.dereference(e)}))}getReferences(){return Se([...this._def.in.getReferences(),...this._def.out.getReferences()])}clone(){return new Bt(f(u({},this._def),{in:this._def.in.clone(),out:this._def.out.clone()}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return o(async()=>{let s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?x:s.status==="dirty"?(n.dirty(),Ke(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})},"handleAsync")();{let i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?x:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(e,n){return new Bt({in:e,out:n,typeName:"ZodPipeline"})}isEqual(e){return!(!(e instanceof Bt)||!this._def.in.isEqual(e._def.in)||!this._def.out.isEqual(e._def.out))}};o(oc,"ZodPipeline");var yr=oc,Nn=class pn extends O{unwrap(){return this._def.type}dereference(e){return new pn(f(u({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new pn(f(u({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==_.promise&&n.common.async===!1)return v(n,{code:h.invalid_type,expected:_.promise,received:n.parsedType}),x;let r=n.parsedType===_.promise?n.data:Promise.resolve(n.data);return G(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}isEqual(e){return e instanceof pn?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}};o(Nn,"ZodPromise");Nn.create=o((t,e)=>new Nn(u({type:t,typeName:"ZodPromise"},S(e))),"create");var Jt=Nn,Mn=class At extends O{dereference(e){return new At(f(u({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new At(f(u({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){let n=this._def.innerType._parse(e);return pt(n)&&(n.value=Object.freeze(n.value)),n}unwrap(){return this._def.innerType}isEqual(e){return e instanceof At?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new At(f(u({},this._def),{innerType:this._def.innerType.mandatory()}))}};o(Mn,"ZodReadonly");Mn.create=o((t,e)=>new Mn(u({innerType:t,typeName:"ZodReadonly"},S(e))),"create");var Yt=Mn,lc=class it extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}dereference(e){let n=this._def.keyType.dereference(e),r=this._def.valueType.dereference(e);return new it(f(u({},this._def),{keyType:n,valueType:r}))}getReferences(){return Se([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new it(f(u({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==_.object)return v(r,{code:h.invalid_type,expected:_.object,received:r.parsedType}),x;let i=[],s=this._def.keyType,a=this._def.valueType;for(let l in r.data)i.push({key:s._parse(new le(r,l,r.path,l)),value:a._parse(new le(r,r.data[l],r.path,l))});return r.common.async?ne.mergeObjectAsync(n,i):ne.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof O?new it(u({keyType:e,valueType:n,typeName:"ZodRecord"},S(r))):new it(u({keyType:J.create(),valueType:e,typeName:"ZodRecord"},S(n)))}isEqual(e){return!(!(e instanceof it)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};o(lc,"ZodRecord");var Si=lc,$n=class cc extends O{dereference(e){let n=e[this._def.uri];return n||this}getReferences(){return[this._def.uri]}_parse(e){let n=this._getOrReturnCtx(e);return v(n,{code:h.unresolved_reference}),x}isOptional(){return!1}isNullable(){return!1}isEqual(e){return e instanceof cc?this._def.uri===e._def.uri:!1}};o($n,"ZodRef");$n.create=o(t=>new $n({typeName:"ZodRef",uri:t}),"create");var Ei=$n,jn=class st extends O{dereference(e){return new st(f(u({},this._def),{valueType:this._def.valueType.dereference(e)}))}getReferences(){return this._def.valueType.getReferences()}clone(){return new st(f(u({},this._def),{valueType:this._def.valueType.clone()}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==_.set)return v(r,{code:h.invalid_type,expected:_.set,received:r.parsedType}),x;let i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(v(r,{code:h.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(v(r,{code:h.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());let s=this._def.valueType;function a(c){let d=new Set;for(let g of c){if(g.status==="aborted")return x;g.status==="dirty"&&n.dirty(),d.add(g.value)}return{status:n.value,value:d}}o(a,"finalizeSet");let l=[...r.data.values()].map((c,d)=>s._parse(new le(r,c,r.path,d)));return r.common.async?Promise.all(l).then(c=>a(c)):a(l)}min(e,n){return new st(f(u({},this._def),{minSize:{value:e,message:P.toString(n)}}))}max(e,n){return new st(f(u({},this._def),{maxSize:{value:e,message:P.toString(n)}}))}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}isEqual(e){var n,r,i,s;if(!(e instanceof st))return!1;let a=(n=this._def.minSize)==null?void 0:n.value,l=(r=e._def.minSize)==null?void 0:r.value;if(a!==l)return!1;let c=(i=this._def.maxSize)==null?void 0:i.value,d=(s=e._def.maxSize)==null?void 0:s.value;return c!==d?!1:this._def.valueType.isEqual(e._def.valueType)}};o(jn,"ZodSet");jn.create=o((t,e)=>new jn(u({valueType:t,minSize:null,maxSize:null,typeName:"ZodSet"},S(e))),"create");var Oi=jn,Ii=/^c[^\s-]{8,}$/i,Zi=/^[a-z][a-z0-9]*$/,Bi=/^[0-9A-HJKMNP-TV-Z]{26}$/,Ai=/^[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,Ci=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,uc="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",dc=o(t=>t===uc,"isEmojiRegex"),Ur,Ri=/^(((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}))$/,Di=/^(([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 pc(t,e){return!!((e==="v4"||!e)&&Ri.test(t)||(e==="v6"||!e)&&Di.test(t))}o(pc,"isValidIP");var Kn=class at extends O{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==_.string){let s=this._getOrReturnCtx(e);return v(s,{code:h.invalid_type,expected:_.string,received:s.parsedType}),x}let r=new ne,i;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),v(i,{code:h.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),v(i,{code:h.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){let a=e.data.length>s.value,l=e.data.length<s.value;(a||l)&&(i=this._getOrReturnCtx(e,i),a?v(i,{code:h.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):l&&v(i,{code:h.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")Ci.test(e.data)||(i=this._getOrReturnCtx(e,i),v(i,{validation:"email",code:h.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")Ur||(Ur=new RegExp(uc,"u")),Ur.test(e.data)||(i=this._getOrReturnCtx(e,i),v(i,{validation:"emoji",code:h.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")Ai.test(e.data)||(i=this._getOrReturnCtx(e,i),v(i,{validation:"uuid",code:h.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")Ii.test(e.data)||(i=this._getOrReturnCtx(e,i),v(i,{validation:"cuid",code:h.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")Zi.test(e.data)||(i=this._getOrReturnCtx(e,i),v(i,{validation:"cuid2",code:h.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")Bi.test(e.data)||(i=this._getOrReturnCtx(e,i),v(i,{validation:"ulid",code:h.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),v(i,{validation:"url",code:h.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),v(i,{validation:"regex",code:h.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),v(i,{code:h.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),v(i,{code:h.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),v(i,{code:h.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?Ml(s).test(e.data)||(i=this._getOrReturnCtx(e,i),v(i,{code:h.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="ip"?pc(e.data,s.version)||(i=this._getOrReturnCtx(e,i),v(i,{validation:"ip",code:h.invalid_string,message:s.message}),r.dirty()):Z.assertNever(s);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(i=>e.test(i),u({validation:n,code:h.invalid_string},P.errToObj(r)))}_addCheck(e){return new at(f(u({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(u({kind:"email"},P.errToObj(e)))}url(e){return this._addCheck(u({kind:"url"},P.errToObj(e)))}emoji(e){return this._addCheck(u({kind:"emoji"},P.errToObj(e)))}uuid(e){return this._addCheck(u({kind:"uuid"},P.errToObj(e)))}cuid(e){return this._addCheck(u({kind:"cuid"},P.errToObj(e)))}cuid2(e){return this._addCheck(u({kind:"cuid2"},P.errToObj(e)))}ulid(e){return this._addCheck(u({kind:"ulid"},P.errToObj(e)))}ip(e){return this._addCheck(u({kind:"ip"},P.errToObj(e)))}datetime(e){var n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck(u({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(n=e?.offset)!=null?n:!1},P.errToObj(e?.message)))}regex(e,n){return this._addCheck(u({kind:"regex",regex:e},P.errToObj(n)))}includes(e,n){return this._addCheck(u({kind:"includes",value:e,position:n?.position},P.errToObj(n?.message)))}startsWith(e,n){return this._addCheck(u({kind:"startsWith",value:e},P.errToObj(n)))}endsWith(e,n){return this._addCheck(u({kind:"endsWith",value:e},P.errToObj(n)))}min(e,n){return this._addCheck(u({kind:"min",value:e},P.errToObj(n)))}max(e,n){return this._addCheck(u({kind:"max",value:e},P.errToObj(n)))}length(e,n){return this._addCheck(u({kind:"length",value:e},P.errToObj(n)))}nonempty(e){return this.min(1,P.errToObj(e))}trim(){return new at(f(u({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}secret(){return this._def[w]=f(u({},this._def[w]),{secret:!0}),this}toLowerCase(){return new at(f(u({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new at(f(u({},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 n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}isEqual(e){if(!(e instanceof at))return!1;let n=new U(this._def.checks),r=new U(e._def.checks);return n.isEqual(r)}};o(Kn,"ZodString");Kn.create=o(t=>{var e;return new Kn(u({checks:[],typeName:"ZodString",coerce:(e=t?.coerce)!=null?e:!1},S(f(u({},t),{supportsExtensions:["secret"]}))))},"create");var J=Kn,Un=class fc extends O{_parse(e){if(this._getType(e)!==_.symbol){let r=this._getOrReturnCtx(e);return v(r,{code:h.invalid_type,expected:_.symbol,received:r.parsedType}),x}return G(e.data)}isEqual(e){return e instanceof fc}};o(Un,"ZodSymbol");Un.create=o(t=>new Un(u({typeName:"ZodSymbol"},S(t))),"create");var Hi=Un,mt=class Ct 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 Ct(f(u({},this._def),{schema:this._def.schema.dereference(e)}))}getReferences(){return this._def.schema.getReferences()}clone(){return new Ct(f(u({},this._def),{schema:this._def.schema.clone()}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:o(a=>{v(r,a),a.fatal?n.abort():n.dirty()},"addIssue"),get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){let a=i.transform(r.data,s);if(r.common.async)return Promise.resolve(a).then(async l=>{if(n.value==="aborted")return x;let c=await this._def.schema._parseAsync({data:l,path:r.path,parent:r});return c.status==="aborted"?x:c.status==="dirty"||n.value==="dirty"?Ke(c.value):c});{if(n.value==="aborted")return x;let l=this._def.schema._parseSync({data:a,path:r.path,parent:r});return l.status==="aborted"?x:l.status==="dirty"||n.value==="dirty"?Ke(l.value):l}}if(i.type==="refinement"){let a=o(l=>{let c=i.refinement(l,s);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return l},"executeRefinement");if(r.common.async===!1){let l=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return l.status==="aborted"?x:(l.status==="dirty"&&n.dirty(),a(l.value),{status:n.value,value:l.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(l=>l.status==="aborted"?x:(l.status==="dirty"&&n.dirty(),a(l.value).then(()=>({status:n.value,value:l.value}))))}if(i.type==="transform")if(r.common.async===!1){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!pt(a))return a;let l=i.transform(a.value,s);if(l instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:l}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>pt(a)?Promise.resolve(i.transform(a.value,s)).then(l=>({status:n.value,value:l})):a);Z.assertNever(i)}isEqual(e){return!(e instanceof Ct)||!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 Ct(f(u({},this._def),{schema:this._def.schema.mandatory()}))}};o(mt,"ZodEffects");mt.create=o((t,e,n)=>new mt(u({schema:t,typeName:"ZodEffects",effect:e},S(n))),"create");mt.createWithPreprocess=o((t,e,n)=>new mt(u({schema:e,effect:{type:"preprocess",transform:t},typeName:"ZodEffects"},S(n))),"createWithPreprocess");var Ae=mt,Fn=class Rt extends O{dereference(e){let n=this._def.items.map(i=>i.dereference(e)),r=this._def.rest?this._def.rest.dereference(e):null;return new Rt(f(u({},this._def),{items:n,rest:r}))}getReferences(){return Se([...this._def.items.flatMap(e=>e.getReferences()),...this._def.rest?this._def.rest.getReferences():[]])}clone(){let e=this._def.items.map(r=>r.clone()),n=this._def.rest?this._def.rest.clone():null;return new Rt(f(u({},this._def),{items:e,rest:n}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==_.array)return v(r,{code:h.invalid_type,expected:_.array,received:r.parsedType}),x;if(r.data.length<this._def.items.length)return v(r,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),x;!this._def.rest&&r.data.length>this._def.items.length&&(v(r,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let s=[...r.data].map((a,l)=>{let c=this._def.items[l]||this._def.rest;return c?c._parse(new le(r,a,r.path,l)):null}).filter(a=>!!a);return r.common.async?Promise.all(s).then(a=>ne.mergeArray(n,a)):ne.mergeArray(n,s)}get items(){return this._def.items}rest(e){return new Rt(f(u({},this._def),{rest:e}))}isEqual(e){if(!(e instanceof Rt)||!this._restEquals(e))return!1;let n=o((s,a)=>s.isEqual(a),"compare"),r=new U(this._def.items,{compare:n}),i=new U(e._def.items,{compare:n});return r.isEqual(i)}_restEquals(e){return this._def.rest===null?e._def.rest===null:e._def.rest!==null&&this._def.rest.isEqual(e._def.rest)}};o(Fn,"ZodTuple");Fn.create=o((t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Fn(u({items:t,typeName:"ZodTuple",rest:null},S(e)))},"create");var We=Fn,zn=class gc extends O{_parse(e){if(this._getType(e)!==_.undefined){let r=this._getOrReturnCtx(e);return v(r,{code:h.invalid_type,expected:_.undefined,received:r.parsedType}),x}return G(e.data)}isEqual(e){return e instanceof gc}mandatory(){return yt.create(u({},this._def))}};o(zn,"ZodUndefined");zn.create=o(t=>new zn(u({typeName:"ZodUndefined"},S(t))),"create");var Xt=zn,Wn=class Dt extends O{dereference(e){let n=this._def.options.map(r=>r.dereference(e));return new Dt(f(u({},this._def),{options:n}))}getReferences(){return Se(this._def.options.reduce((e,n)=>[...e,...n.getReferences()],[]))}clone(){let e=this._def.options.map(n=>n.clone());return new Dt(f(u({},this._def),{options:e}))}_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function i(s){for(let l of s)if(l.result.status==="valid")return l.result;for(let l of s)if(l.result.status==="dirty")return n.common.issues.push(...l.ctx.common.issues),l.result;let a=s.map(l=>new he(l.ctx.common.issues));return v(n,{code:h.invalid_union,unionErrors:a}),x}if(o(i,"handleResults"),n.common.async)return Promise.all(r.map(async s=>{let a=f(u({},n),{common:f(u({},n.common),{issues:[]}),parent:null});return{result:await s._parseAsync({data:n.data,path:n.path,parent:a}),ctx:a}})).then(i);{let s,a=[];for(let c of r){let d=f(u({},n),{common:f(u({},n.common),{issues:[]}),parent:null}),g=c._parseSync({data:n.data,path:n.path,parent:d});if(g.status==="valid")return g;g.status==="dirty"&&!s&&(s={result:g,ctx:d}),d.common.issues.length&&a.push(d.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;let l=a.map(c=>new he(c));return v(n,{code:h.invalid_union,unionErrors:l}),x}}get options(){return this._def.options}isEqual(e){if(!(e instanceof Dt))return!1;let n=o((s,a)=>s.isEqual(a),"compare"),r=new U([...this._def.options],{compare:n}),i=new U([...e._def.options],{compare:n});return r.isEqual(i)}mandatory(){let e=this._def.options.filter(s=>!(s instanceof Xt)).map(s=>s.mandatory()),[n,r,...i]=e;return n?r?new Dt(f(u({},this._def),{options:[n,r,...i]})):n:yt.create(u({},this._def))}};o(Wn,"ZodUnion");Wn.create=o((t,e)=>new Wn(u({options:t,typeName:"ZodUnion"},S(e))),"create");var vr=Wn,Ln=class mc extends O{constructor(){super(...arguments),this._unknown=!0}_parse(e){return G(e.data)}isEqual(e){return e instanceof mc}};o(Ln,"ZodUnknown");Ln.create=o(t=>new Ln(u({typeName:"ZodUnknown"},S(t))),"create");var ct=Ln,Vn=class hc extends O{_parse(e){if(this._getType(e)!==_.undefined){let r=this._getOrReturnCtx(e);return v(r,{code:h.invalid_type,expected:_.void,received:r.parsedType}),x}return G(e.data)}isEqual(e){return e instanceof hc}};o(Vn,"ZodVoid");Vn.create=o(t=>new Vn(u({typeName:"ZodVoid"},S(t))),"create");var Ni=Vn,_h=["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"],Cv=Qe.create(["any","string","number","boolean","object","pattern","date","array","target","time","enum"]),yc=o(t=>J.create().displayAs({id:"variable",params:u({type:t?.type||"any"},t?.params)}),"variable"),vc=o(t=>J.create().displayAs({id:"conversation",params:u({},t?.params)}),"conversation"),_c=o(t=>J.create().displayAs({id:"user",params:u({},t?.params)}),"user"),Tc=o(t=>J.create().displayAs({id:"message",params:u({},t?.params)}),"message"),bc=o(t=>J.create().displayAs({id:"agent",params:u({},t?.params)}),"agent"),wc=o(t=>J.create().displayAs({id:"event",params:u({},t?.params)}),"event"),Pc=o(t=>J.create().displayAs({id:"table",params:u({},t?.params)}),"table"),xc=o(t=>J.create().displayAs({id:"tablerow",params:u({},t?.params)}),"tablerow"),kc=o(t=>J.create().displayAs({id:"intent",params:u({},t?.params)}),"intent"),Sc=o(()=>Qe.create(_h).displayAs({id:"dropdown",params:{}}),"aimodel"),Ec=o(t=>J.create().displayAs({id:"datasource",params:u({},t)}),"datasource"),Oc=o(t=>J.create().displayAs({id:"knowledgebase",params:u({},t)}),"knowledgebase"),Ic={object:ze.lazycreate},Zc=o((t,e={message:`Input not instance of ${t.name}`})=>Ti(n=>n instanceof t,e),"instanceOfType"),Mi=J.create,$i=hr.create,Bc=ki.create,Ac=ar.create,ji=or.create,Cc=ur.create,Rc=Hi.create,Dc=Xt.create,Hc=mr.create,Nc=ft.create,Mc=ct.create,$c=yt.create,jc=Ni.create,Kc=gt.create,Uc=ze.create,Fc=ze.strictCreate,zc=vr.create,Wc=bi.create,Lc=dr.create,Vc=We.create,qc=Si.create,Gc=Ei.create,Jc=Yt.create,Yc=xi.create,Xc=Oi.create,Qc=Pi.create,eu=pr.create,tu=fr.create,nu=Qe.create,ru=gr.create,iu=Jt.create,Qr=Ae.create,su=Pe.create,au=Fe.create,Th=qt.create,ou=Ae.createWithPreprocess,lu=yr.create,cu=o(()=>Mi().optional(),"ostring"),uu=o(()=>$i().optional(),"onumber"),du=o(()=>ji().optional(),"oboolean"),pu={string:o(t=>J.create(f(u({},t),{coerce:!0})),"string"),number:o(t=>hr.create(f(u({},t),{coerce:!0})),"number"),boolean:o(t=>or.create(f(u({},t),{coerce:!0})),"boolean"),bigint:o(t=>ar.create(f(u({},t),{coerce:!0})),"bigint"),date:o(t=>ur.create(f(u({},t),{coerce:!0})),"date")},fu=x,p=y,gu=o((t,e)=>t.anyOf.length?t.anyOf.length===1?L(t.anyOf[0],f(u({},e),{path:[...e.path,"anyOf",0]})):`z.union([${t.anyOf.map((n,r)=>L(n,f(u({},e),{path:[...e.path,"anyOf",r]}))).join(", ")}])`:"z.any()","parseAnyOf"),bh=o(t=>{var e;return(e=t[w])!=null&&e.coerce?"z.coerce.boolean()":"z.boolean()"},"parseBoolean"),wh=o(t=>"z.any()","parseDefault"),Ph=o((t,e)=>`z.union([${t.type.map(n=>L(f(u({},t),{type:n}),e)).join(", ")}])`,"parseMultipleType"),xh=o((t,e)=>`z.any().refine((value) => !${L(t.not,f(u({},e),{path:[...e.path,"not"]}))}.safeParse(value).success, "Invalid input: Should NOT be valid against schema")`,"parseNot"),kh=o(t=>"z.null()","parseNull"),Sh=o(t=>[t.slice(0,t.length/2),t.slice(t.length/2)],"half"),Eh=o((t,...e)=>Object.keys(t).reduce((n,r)=>(e.includes(r)||(n[r]=t[r]),n),{}),"omit");function q(t,e,n){var r;let i=t[e],s="";if(i!==void 0){let a=n({value:i,json:JSON.stringify(i)});if(a){let l=a[0],c=a.length===3?a[1]:"",d=a.length===3?a[2]:a[1];s+=l,((r=t.errorMessage)==null?void 0:r[e])!==void 0&&(s+=c+JSON.stringify(t.errorMessage[e])),s+=d}}return s}o(q,"withMessage");var Ht=Symbol("Original index"),Oh=o(t=>{let e=[];for(let n=0;n<t.length;n++){let r=t[n];if(typeof r=="boolean")e.push(r?{[Ht]:n}:{[Ht]:n,not:{}});else{if(Ht in r)return t;e.push(f(u({},r),{[Ht]:n}))}}return e},"ensureOriginalIndex");function Lt(t,e){if(t.allOf.length===0)return"z.never()";if(t.allOf.length===1){let n=t.allOf[0];return L(n,f(u({},e),{path:[...e.path,"allOf",n[Ht]]}))}else{let[n,r]=Sh(Oh(t.allOf));return`z.intersection(${Lt({allOf:n},e)}, ${Lt({allOf:r},e)})`}}o(Lt,"parseAllOf");var Ih=o((t,e)=>{if(Array.isArray(t.items))return`z.tuple([${t.items.map((r,i)=>L(r,f(u({},e),{path:[...e.path,"items",i]})))}])`;let n=t.items?`z.array(${L(t.items,f(u({},e),{path:[...e.path,"items"]}))})`:"z.array(z.any())";return n+=q(t,"minItems",({json:r})=>[`.min(${r}`,", ",")"]),n+=q(t,"maxItems",({json:r})=>[`.max(${r}`,", ",")"]),n},"parseArray"),Zh=o(t=>`z.literal(${JSON.stringify(t.const)})`,"parseConst"),Bh=o(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"),Ah=o((t,e)=>{let n=L(t.if,f(u({},e),{path:[...e.path,"if"]})),r=L(t.then,f(u({},e),{path:[...e.path,"then"]})),i=L(t.else,f(u({},e),{path:[...e.path,"else"]}));return`z.union([${r}, ${i}]).superRefine((value,ctx) => {
17
+ const result = ${n}.safeParse(value).success
18
+ ? ${r}.safeParse(value)
19
+ : ${i}.safeParse(value);
20
20
  if (!result.success) {
21
21
  result.error.errors.forEach((error) => ctx.addIssue(error))
22
22
  }
23
- })`},"parseIfThenElse"),Ih=a(t=>{var e;let r="z.number()";return(e=t[w])!=null&&e.coerce&&(r="z.coerce.number()"),t.type==="integer"?r+=V(t,"type",()=>[".int(",")"]):r+=V(t,"format",({value:n})=>{if(n==="int64")return[".int(",")"]}),r+=V(t,"multipleOf",({value:n,json:s})=>n===1?r.startsWith("z.number().int(")?void 0:[".int(",")"]:[`.multipleOf(${s}`,", ",")"]),typeof t.minimum=="number"?t.exclusiveMinimum===!0?r+=V(t,"minimum",({json:n})=>[`.gt(${n}`,", ",")"]):r+=V(t,"minimum",({json:n})=>[`.gte(${n}`,", ",")"]):typeof t.exclusiveMinimum=="number"&&(r+=V(t,"exclusiveMinimum",({json:n})=>[`.gt(${n}`,", ",")"])),typeof t.maximum=="number"?t.exclusiveMaximum===!0?r+=V(t,"maximum",({json:n})=>[`.lt(${n}`,", ",")"]):r+=V(t,"maximum",({json:n})=>[`.lte(${n}`,", ",")"]):typeof t.exclusiveMaximum=="number"&&(r+=V(t,"exclusiveMaximum",({json:n})=>[`.lt(${n}`,", ",")"])),r},"parseNumber"),Hs=a((t,e)=>t.oneOf.length?t.oneOf.length===1?L(t.oneOf[0],f(c({},e),{path:[...e.path,"oneOf",0]})):`z.any().superRefine((x, ctx) => {
24
- const schemas = [${t.oneOf.map((r,n)=>L(r,f(c({},e),{path:[...e.path,"oneOf",n]}))).join(", ")}];
23
+ })`},"parseIfThenElse"),Ch=o(t=>{var e;let n="z.number()";return(e=t[w])!=null&&e.coerce&&(n="z.coerce.number()"),t.type==="integer"?n+=q(t,"type",()=>[".int(",")"]):n+=q(t,"format",({value:r})=>{if(r==="int64")return[".int(",")"]}),n+=q(t,"multipleOf",({value:r,json:i})=>r===1?n.startsWith("z.number().int(")?void 0:[".int(",")"]:[`.multipleOf(${i}`,", ",")"]),typeof t.minimum=="number"?t.exclusiveMinimum===!0?n+=q(t,"minimum",({json:r})=>[`.gt(${r}`,", ",")"]):n+=q(t,"minimum",({json:r})=>[`.gte(${r}`,", ",")"]):typeof t.exclusiveMinimum=="number"&&(n+=q(t,"exclusiveMinimum",({json:r})=>[`.gt(${r}`,", ",")"])),typeof t.maximum=="number"?t.exclusiveMaximum===!0?n+=q(t,"maximum",({json:r})=>[`.lt(${r}`,", ",")"]):n+=q(t,"maximum",({json:r})=>[`.lte(${r}`,", ",")"]):typeof t.exclusiveMaximum=="number"&&(n+=q(t,"exclusiveMaximum",({json:r})=>[`.lt(${r}`,", ",")"])),n},"parseNumber"),Ki=o((t,e)=>t.oneOf.length?t.oneOf.length===1?L(t.oneOf[0],f(u({},e),{path:[...e.path,"oneOf",0]})):`z.any().superRefine((x, ctx) => {
24
+ const schemas = [${t.oneOf.map((n,r)=>L(n,f(u({},e),{path:[...e.path,"oneOf",r]}))).join(", ")}];
25
25
  const errors = schemas.reduce(
26
26
  (errors: z.ZodError[], schema) =>
27
27
  ((result) => ("error" in result ? [...errors, result.error] : errors))(
@@ -37,15 +37,15 @@ declare function ${n}${o};${d}`);if(t.props.type==="variable")return Bn(`${s}dec
37
37
  message: "Invalid input: Should pass single schema",
38
38
  });
39
39
  }
40
- })`:"z.any()","parseOneOf");function od(t,e){let r;t.properties&&(Object.keys(t.properties).length?(r="z.object({ ",r+=Object.keys(t.properties).map(o=>{let l=t.properties[o],d=`${JSON.stringify(o)}: ${L(l,f(c({},e),{path:[...e.path,"properties",o]}))}`,u=typeof l=="object"&&l.default!==void 0||typeof t.default=="object"&&t.default!==null&&o in t.default,g=Array.isArray(t.required)?t.required.includes(o):typeof l=="object"&&l.required===!0;return!u&&!g?`${d}.optional()`:d}).join(", "),r+=" })"):r="z.object({})");let n=t.additionalProperties!==void 0?L(t.additionalProperties,f(c({},e),{path:[...e.path,"additionalProperties"]})):void 0,s;if(t.patternProperties){let o=Object.fromEntries(Object.entries(t.patternProperties).map(([l,d])=>[l,L(d,f(c({},e),{path:[...e.path,"patternProperties",l]}))],{}));s="",r?n?s+=`.catchall(z.union([${[...Object.values(o),n].join(", ")}]))`:Object.keys(o).length>1?s+=`.catchall(z.union([${Object.values(o).join(", ")}]))`:s+=`.catchall(${Object.values(o)})`:n?s+=`z.record(z.union([${[...Object.values(o),n].join(", ")}]))`:Object.keys(o).length>1?s+=`z.record(z.union([${Object.values(o).join(", ")}]))`:s+=`z.record(${Object.values(o)})`,s+=`.superRefine((value, ctx) => {
41
- `,s+=`for (const key in value) {
42
- `,n&&(t.properties?s+=`let evaluated = [${Object.keys(t.properties).map(l=>JSON.stringify(l)).join(", ")}].includes(key)
43
- `:s+=`let evaluated = false
44
- `);for(let l in t.patternProperties)s+="if (key.match(new RegExp("+JSON.stringify(l)+`))) {
45
- `,n&&(s+=`evaluated = true
46
- `),s+="const result = "+o[l]+`.safeParse(value[key])
47
- `,s+=`if (!result.success) {
48
- `,s+=`ctx.addIssue({
40
+ })`:"z.any()","parseOneOf");function mu(t,e){let n;t.properties&&(Object.keys(t.properties).length?(n="z.object({ ",n+=Object.keys(t.properties).map(a=>{let l=t.properties[a],c=`${JSON.stringify(a)}: ${L(l,f(u({},e),{path:[...e.path,"properties",a]}))}`,d=typeof l=="object"&&l.default!==void 0||typeof t.default=="object"&&t.default!==null&&a in t.default,g=Array.isArray(t.required)?t.required.includes(a):typeof l=="object"&&l.required===!0;return!d&&!g?`${c}.optional()`:c}).join(", "),n+=" })"):n="z.object({})");let r=t.additionalProperties!==void 0?L(t.additionalProperties,f(u({},e),{path:[...e.path,"additionalProperties"]})):void 0,i;if(t.patternProperties){let a=Object.fromEntries(Object.entries(t.patternProperties).map(([l,c])=>[l,L(c,f(u({},e),{path:[...e.path,"patternProperties",l]}))],{}));i="",n?r?i+=`.catchall(z.union([${[...Object.values(a),r].join(", ")}]))`:Object.keys(a).length>1?i+=`.catchall(z.union([${Object.values(a).join(", ")}]))`:i+=`.catchall(${Object.values(a)})`:r?i+=`z.record(z.union([${[...Object.values(a),r].join(", ")}]))`:Object.keys(a).length>1?i+=`z.record(z.union([${Object.values(a).join(", ")}]))`:i+=`z.record(${Object.values(a)})`,i+=`.superRefine((value, ctx) => {
41
+ `,i+=`for (const key in value) {
42
+ `,r&&(t.properties?i+=`let evaluated = [${Object.keys(t.properties).map(l=>JSON.stringify(l)).join(", ")}].includes(key)
43
+ `:i+=`let evaluated = false
44
+ `);for(let l in t.patternProperties)i+="if (key.match(new RegExp("+JSON.stringify(l)+`))) {
45
+ `,r&&(i+=`evaluated = true
46
+ `),i+="const result = "+a[l]+`.safeParse(value[key])
47
+ `,i+=`if (!result.success) {
48
+ `,i+=`ctx.addIssue({
49
49
  path: [...ctx.path, key],
50
50
  code: 'custom',
51
51
  message: \`Invalid input: Key matching regex /\${key}/ must match schema\`,
@@ -53,12 +53,12 @@ declare function ${n}${o};${d}`);if(t.props.type==="variable")return Bn(`${s}dec
53
53
  issues: result.error.issues
54
54
  }
55
55
  })
56
- `,s+=`}
57
- `,s+=`}
58
- `;n&&(s+=`if (!evaluated) {
59
- `,s+="const result = "+n+`.safeParse(value[key])
60
- `,s+=`if (!result.success) {
61
- `,s+=`ctx.addIssue({
56
+ `,i+=`}
57
+ `,i+=`}
58
+ `;r&&(i+=`if (!evaluated) {
59
+ `,i+="const result = "+r+`.safeParse(value[key])
60
+ `,i+=`if (!result.success) {
61
+ `,i+=`ctx.addIssue({
62
62
  path: [...ctx.path, key],
63
63
  code: 'custom',
64
64
  message: \`Invalid input: must match catchall schema\`,
@@ -66,10 +66,13 @@ declare function ${n}${o};${d}`);if(t.props.type==="variable")return Bn(`${s}dec
66
66
  issues: result.error.issues
67
67
  }
68
68
  })
69
- `,s+=`}
70
- `,s+=`}
71
- `),s+=`}
72
- `,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(${ad(f(c({},t),{anyOf:t.anyOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?f(c({},o),{type:"object"}):o)}),e)})`),$.a.oneOf(t)&&(i+=`.and(${Hs(f(c({},t),{oneOf:t.oneOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?f(c({},o),{type:"object"}):o)}),e)})`),$.an.allOf(t)&&(i+=`.and(${Kt(f(c({},t),{allOf:t.allOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?f(c({},o),{type:"object"}):o)}),e)})`),i}a(od,"parseObject");var Bh=a(t=>{var e;let r="z.string()";if((e=t[w])!=null&&e.coerce){if(t.format==="date-time")return"z.coerce.date()";r="z.coerce.string()"}return r+=V(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+=V(t,"pattern",({json:n})=>[`.regex(new RegExp(${n})`,", ",")"]),r+=V(t,"minLength",({json:n})=>[`.min(${n}`,", ",")"]),r+=V(t,"maxLength",({json:n})=>[`.max(${n}`,", ",")"]),r},"parseString"),Ah=a((t,e)=>`${L(xh(t,"nullable"),e,!0)}.nullable()`,"parseNullable"),Rh=a(t=>`z.ref('${t.$ref}')`,"parseRef"),Ch=a((t,e)=>{var r,n;if(t.oneOf.length<=1||!((r=t.discriminator)!=null&&r.propertyName))return Hs(t,e);let s=t.oneOf.map((i,o)=>L(i,f(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=Nh(t,e);return r||(s=Dh(t,s),e.withoutDefaults||(s=Hh(t,s))),n.r=s,s},"parseSchema"),Dh=a((t,e)=>(t.description&&(e+=`.describe(${JSON.stringify(t.description)})`),e),"addMeta"),Hh=a((t,e)=>(t.default!==void 0&&(e+=`.default(${JSON.stringify(t.default)})`),e),"addDefaults"),Nh=a((t,e)=>$.a.nullable(t)?Ah(t,e):$.an.object(t)?od(t,e):$.an.array(t)?Sh(t,e):$.an.anyOf(t)?ad(t,e):$.an.allOf(t)?Kt(t,e):$.a.discriminator(t)?Ch(t,e):$.a.oneOf(t)?Hs(t,e):$.a.not(t)?bh(t,e):$.an.enum(t)?Oh(t):$.a.const(t)?Eh(t):$.a.multipleType(t)?Th(t,e):$.a.primitive(t,"string")?Bh(t):$.a.primitive(t,"number")||$.a.primitive(t,"integer")?Ih(t):$.a.primitive(t,"boolean")?vh(t):$.a.primitive(t,"null")?wh(t):$.a.conditional(t)?Zh(t,e):$.a.ref(t)?Rh(t):_h(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")}},Mh=a(t=>{let e;try{e=new Function("z",`return ${t}`)(p)}catch(r){return{sucess:!1,error:`Failed to evaluate schema: ${(r instanceof Error?r:new Error(String(r))).message}`}}return e instanceof p.ZodType?{sucess:!0,value:e}:{sucess:!1,error:`String "${t}" does not evaluate to a Zod schema`}},"evalZuiString"),$h=a(t=>L(t,{seen:new Map,path:[]}),"jsonSchemaToZodStr"),jh=a(t=>{let e=$h(t);e=e.replaceAll("errors: z.ZodError[]","errors");let r=Mh(e);if(!r.sucess)throw new Fr(r.error);return r.value},"jsonSchemaToZod"),At=a((t,e)=>{var r,n;if(e[w]&&t._def&&(t.naked()._def[w]=e[w]),((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]&&At(o[s],i)}),((n=t._def)==null?void 0:n.typeName)==="ZodRecord"&&e.type==="object"&&e.additionalProperties&&At(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&&At(i,s)}else Array.isArray(s)&&s.forEach((i,o)=>{let l=t._def;l.typeName===y.ZodFirstPartyTypeKind.ZodTuple&&At(l.items[o],i)})}},"applyZuiPropsRecursively"),Kh=a(t=>{let e=jh(t);return At(e,t),e},"fromJSONSchemaLegacy"),Uh=a(t=>{var e,r;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(n=>typeof n!="boolean"&&ld(n))&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===p.ZodFirstPartyTypeKind.ZodOptional},"isOptionalSchema"),zh=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)===p.ZodFirstPartyTypeKind.ZodNullable},"isNullableSchema"),ld=a(t=>{var e,r;return t.not===!0&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===p.ZodFirstPartyTypeKind.ZodUndefined},"isUndefinedSchema"),Fh=a(t=>{var e,r;return!t.not&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===p.ZodFirstPartyTypeKind.ZodUnknown},"isUnknownSchema"),Wh=a(({type:t,minimum:e,exclusiveMinimum:r,maximum:n,exclusiveMaximum:s,multipleOf:i,format:o})=>{let l=p.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"),Lh=a(({format:t,pattern:e,minLength:r,maxLength:n})=>{let s=p.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?ah(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"),Tt=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 Lh(e);if(t==="number"&&(e.type==="number"||e.type==="integer"))return Wh(e);if(t==="boolean")return p.boolean();if(t==="null")return p.null();throw new Fr(`Unknown primitive type: "${t}"`)}if(n.length===1)return p.literal(s);let i=n.map(o=>p.literal(o));return p.union(i)},"toZuiPrimitive"),qh=a((t,e)=>Vh(t)?Jh(t,e):Gh(t)?Yh(t,e):Xh(t,e),"arrayJSONSchemaToZuiArray"),Vh=a(t=>Array.isArray(t.items),"_isTuple"),Gh=a(t=>t.items!==void 0&&t.uniqueItems,"_isSet"),Jh=a(({items:t,additionalItems:e},r)=>{let n=t.map(r),s=p.tuple(n);return e!==void 0&&(s=s.rest(r(e))),s},"_handleTuple"),Yh=a(({items:t,minItems:e,maxItems:r},n)=>{let s=p.set(n(t));return e&&(s=s.min(e)),r&&(s=s.max(r)),s},"_handleSet"),Xh=a(({minItems:t,maxItems:e,items:r},n)=>{let s=p.array(n(r));return t&&t===e?s.length(t):(t&&(s=s.min(t)),e&&(s=s.max(e)),s)},"_handleArray"),Qe=p.any();function cd(t){return W(t)}a(cd,"fromJSONSchema");function W(t){var e;if(t===void 0)return Qe;if(t===!0)return p.any();if(t===!1)return p.never();if(t.default!==void 0)return W(f(c({},t),{default:void 0})).default(t.default);if(t.readOnly)return W(f(c({},t),{readOnly:void 0})).readonly();if(t.oneOf!==void 0)throw new Pe({oneOf:t.oneOf});if(t.patternProperties!==void 0)throw new Pe({patternProperties:t.patternProperties});if(t.propertyNames!==void 0)throw new Pe({propertyNames:t.propertyNames});if(t.if!==void 0)throw new Pe({if:t.if});if(t.then!==void 0)throw new Pe({then:t.then});if(t.else!==void 0)throw new Pe({else:t.else});if(t.$ref!==void 0)return p.ref(t.$ref);if(t.not!==void 0){if(ld(t))return p.undefined();if(t.not===!0)return p.never();throw new Pe({not:t.not})}if(Array.isArray(t.type)){if(t.type.length===0)return Qe;if(t.type.length===1)return W(f(c({},t),{type:t.type[0]}));let r=t,{type:n}=r,s=Ai(r,["type"]),i=t.type.map(o=>W(f(c({},s),{type:o})));return p.union(i)}if(t.type==="string")return t.enum&&t.enum.length>0?p.enum(t.enum):Tt("string",t);if(t.type==="integer"){let r=Tt("number",t);return r instanceof p.ZodNumber?r.int():r}if(t.type==="number")return Tt("number",t);if(t.type==="boolean")return Tt("boolean",t);if(t.type==="null")return Tt("null",t);if(t.type==="array")return qh(t,W);if(t.type==="object"){if(t.additionalProperties!==void 0&&t.properties!==void 0){let r=W(t.additionalProperties);return W(f(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=W(s),o=(e=t.required)!=null?e:[];r[n]=o.includes(n)?i:i.optional()}return p.object(r)}if(t.additionalProperties!==void 0){let r=W(t.additionalProperties);return p.record(r)}return p.record(Qe)}if(t.anyOf!==void 0){if(t.anyOf.length===0)return Qe;if(t.anyOf.length===1)return W(t.anyOf[0]);if(Uh(t))return W(t.anyOf[0]).optional();if(zh(t))return W(t.anyOf[0]).nullable();let r=t.anyOf.map(W);return p.union(r)}if(t.allOf!==void 0){if(t.allOf.length===0)return Qe;if(t.allOf.length===1)return W(t.allOf[0]);let[r,...n]=t.allOf,s=W(r),i=W({allOf:n});return p.intersection(s,i)}return Fh(t)?p.unknown():Qe}a(W,"_fromJSONSchema");var Qh=/^\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))?$/,Gn=a((t,e,r=!0)=>{if(typeof t!="object")throw new $n("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,d])=>{if(d===null)o[l]=n(y.null());else switch(typeof d){case"string":o[l]=Qh.test(d)?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(d)?d.length===0?o[l]=n(y.array(y.unknown())):typeof d[0]=="object"?o[l]=n(y.array(Gn(d[0],e,!1))):["string","number","boolean"].includes(typeof d[0])&&(o[l]=n(y.array(y[typeof d[0]]()))):o[l]=n(Gn(d,e,!1));break;default:throw new $n(`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 dd(){return{}}a(dd,"parseAnyDef");function ud(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=A(t.type._def,f(c({},e),{currentPath:[...e.currentPath,"items"]}))),t.minLength&&D(s,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&D(s,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(D(s,"minItems",t.exactLength.value,t.exactLength.message,e),D(s,"maxItems",t.exactLength.value,t.exactLength.message,e)),s}a(ud,"parseArrayDef");function pd(t,e){let r=c({type:"integer",format:"int64"},t.coerce?{[w]:{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?D(r,"minimum",n.value,n.message,e):D(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),D(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?D(r,"maximum",n.value,n.message,e):D(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),D(r,"maximum",n.value,n.message,e));break;case"multipleOf":D(r,"multipleOf",n.value,n.message,e);break}return r}a(pd,"parseBigintDef");function fd(t){return c({type:"boolean"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{})}a(fd,"parseBooleanDef");function gd(t,e){return A(t.type._def,e)}a(gd,"parseBrandedDef");var ey=a((t,e)=>A(t.innerType._def,e),"parseCatchDef");function md(t,e){return e.dateStrategy=="integer"?ty(t,e):c({type:"string",format:"date-time"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{})}a(md,"parseDateDef");var ty=a((t,e)=>{let r=c({type:"integer",format:"unix-time"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{});for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"&&D(r,"minimum",n.value,n.message,e);break;case"max":e.target==="jsonSchema7"&&D(r,"maximum",n.value,n.message,e);break}return r},"integerDateParser");function hd(t,e){return f(c({},A(t.innerType._def,e)),{default:t.defaultValue()})}a(hd,"parseDefaultDef");function yd(t,e){return e.effectStrategy==="input"?A(t.schema._def,e):{}}a(yd,"parseEffectsDef");function vd(t){return{type:"string",enum:t.values}}a(vd,"parseEnumDef");var ry=a(t=>"type"in t&&t.type==="string"?!1:"allOf"in t,"isJsonSchema7AllOfType");function _d(t,e){let r=[A(t.left._def,f(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),A(t.right._def,f(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(ry(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:d}=l;o=Ai(l,["additionalProperties"])}else n=void 0;s.push(o)}}),s.length?c({allOf:s},n):void 0}a(_d,"parseIntersectionDef");function Td(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(Td,"parseLiteralDef");function Ns(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((d,u)=>{var g;return f(c({},d),{[u]:(g=A(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"properties",u]})))!=null?g:{}})},{}),additionalProperties:!1};let l={type:"object",additionalProperties:(n=A(t.valueType._def,f(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 d=Object.entries(us(t.keyType._def,e)).reduce((u,[g,h])=>g==="type"?u:f(c({},u),{[g]:h}),{});return f(c({},l),{propertyNames:d})}else if(((o=t.keyType)==null?void 0:o._def.typeName)==="ZodEnum")return f(c({},l),{propertyNames:{enum:t.keyType._def.values}});return l}a(Ns,"parseRecordDef");function bd(t,e){if(e.mapStrategy==="record")return Ns(t,e);let r=A(t.keyType._def,f(c({},e),{currentPath:[...e.currentPath,"items","items","0"]}))||{},n=A(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"items","items","1"]}))||{};return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}a(bd,"parseMapDef");function wd(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(wd,"parseNativeEnumDef");function Pd(){return{not:{}}}a(Pd,"parseNeverDef");function xd(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}a(xd,"parseNullDef");var Ur={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function kd(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 Ur&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((s,i)=>{let o=Ur[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(kd,"parseUnionDef");var Oi=a((t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((s,i)=>A(s._def,f(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 Sd(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:Ur[n._def.typeName],nullable:!0};return Jn(n._def,e,i)}let s={type:[Ur[n._def.typeName],"null"]};return Jn(n._def,e,s)}if(e.target==="openApi3"){let n=A(t.innerType._def,f(c({},e),{currentPath:[...e.currentPath]}));return n&&f(c({},n),{nullable:!0})}let r=A(t.innerType._def,f(c({},e),{currentPath:[...e.currentPath,"anyOf","0"]}));return r&&{anyOf:[r,{type:"null"}]}}a(Sd,"parseNullableDef");function Ed(t,e){let r=c({type:"number"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"int":r.type="integer",ds(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?D(r,"minimum",n.value,n.message,e):D(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),D(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?D(r,"maximum",n.value,n.message,e):D(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),D(r,"maximum",n.value,n.message,e));break;case"multipleOf":D(r,"multipleOf",n.value,n.message,e);break}return r}a(Ed,"parseNumberDef");var ny=a((t,e)=>{var r;return t.unknownKeys instanceof O?(r=A(t.unknownKeys._def,f(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?r:!0:t.unknownKeys==="passthrough"},"getAdditionalProperties");function Od(t,e){let r=f(c({type:"object"},Object.entries(t.shape()).reduce((n,[s,i])=>{if(i===void 0||i._def===void 0)return n;let o=A(i._def,f(c({},e),{currentPath:[...e.currentPath,"properties",s],propertyPath:[...e.currentPath,"properties",s]}));return o===void 0?n:{properties:f(c({},n.properties),{[s]:o}),required:i.isOptional()?n.required:[...n.required,s]}},{properties:{},required:[]})),{additionalProperties:ny(t,e)});return r.required.length||delete r.required,r}a(Od,"parseObjectDef");var sy=a((t,e)=>{var r;if(e.currentPath.toString()===((r=e.propertyPath)==null?void 0:r.toString()))return A(t.innerType._def,e);let n=A(t.innerType._def,f(c({},e),{currentPath:[...e.currentPath,"anyOf","1"]}));return n?{anyOf:[{not:{}},n]}:{}},"parseOptionalDef"),iy=a((t,e)=>{if(e.pipeStrategy==="input")return A(t.in._def,e);if(e.pipeStrategy==="output")return A(t.out._def,e);let r=A(t.in._def,f(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),n=A(t.out._def,f(c({},e),{currentPath:[...e.currentPath,"allOf",r?"1":"0"]}));return{allOf:[r,n].filter(s=>s!==void 0)}},"parsePipelineDef");function Zd(t,e){return A(t.type._def,e)}a(Zd,"parsePromiseDef");function Id(t,e){let n={type:"array",uniqueItems:!0,items:A(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"items"]}))};return t.minSize&&D(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&D(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}a(Id,"parseSetDef");function Bd(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>A(r._def,f(c({},e),{currentPath:[...e.currentPath,"items",`${n}`]}))).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:A(t.rest._def,f(c({},e),{currentPath:[...e.currentPath,"additionalItems"]}))}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>A(r._def,f(c({},e),{currentPath:[...e.currentPath,"items",`${n}`]}))).reduce((r,n)=>n===void 0?r:[...r,n],[])}}a(Bd,"parseTupleDef");function Ad(){return{not:{}}}a(Ad,"parseUndefinedDef");function Rd(){return{}}a(Rd,"parseUnknownDef");var ay=a((t,e)=>A(t.innerType._def,e),"parseReadonlyDef");function Cd(t){return{$ref:t.uri}}a(Cd,"parseRefDef");function A(t,e,r=!1){let n=e.seen.get(t);if(n&&!r){let o=oy(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=cy(t,t.typeName,e);return i&&Jn(t,e,i),s.jsonSchema=i,i}a(A,"parseDef");var oy=a((t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:ly(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"),ly=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"),cy=a((t,e,r)=>{switch(e){case"ZodString":return us(t,r);case"ZodNumber":return Ed(t,r);case"ZodObject":return Od(t,r);case"ZodBigInt":return pd(t,r);case"ZodBoolean":return fd(t);case"ZodDate":return md(t,r);case"ZodUndefined":return Ad();case"ZodNull":return xd(r);case"ZodArray":return ud(t,r);case"ZodUnion":case"ZodDiscriminatedUnion":return kd(t,r);case"ZodIntersection":return _d(t,r);case"ZodTuple":return Bd(t,r);case"ZodRecord":return Ns(t,r);case"ZodRef":return Cd(t);case"ZodLiteral":return Td(t,r);case"ZodEnum":return vd(t);case"ZodNativeEnum":return wd(t);case"ZodNullable":return Sd(t,r);case"ZodOptional":return sy(t,r);case"ZodMap":return bd(t,r);case"ZodSet":return Id(t,r);case"ZodLazy":return A(t.getter()._def,r);case"ZodPromise":return Zd(t,r);case"ZodNaN":case"ZodNever":return Pd();case"ZodEffects":return yd(t,r);case"ZodAny":return dd();case"ZodUnknown":return Rd();case"ZodDefault":return hd(t,r);case"ZodBranded":return gd(t,r);case"ZodReadonly":return ay(t,r);case"ZodCatch":return ey(t,r);case"ZodPipeline":return iy(t,r);case"ZodFunction":case"ZodVoid":case"ZodSymbol":return;default:return(n=>{})(e)}},"selectParser"),Jn=a((t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),Object.assign(r,{[w]:c(c({},t[w]),r[w])}),r),"addMeta"),Zi={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"},dy=a(t=>typeof t=="string"?f(c({},Zi),{name:t}):c(c({},Zi),t),"getDefaultOptions"),uy=a(t=>{let e=dy(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return f(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"),py=a((t,e)=>{var r;let n=uy(e),s=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((d,[u,g])=>{var h;return f(c({},d),{[u]:(h=A(g._def,f(c({},n),{currentPath:[...n.basePath,n.definitionPath,u]}),!0))!=null?h:{}})},{}):void 0,i=typeof e=="string"?e:e?.name,o=(r=A(t._def,i===void 0?n:f(c({},n),{currentPath:[...n.basePath,n.definitionPath,i]}),!1))!=null?r:{},l=i===void 0?s?f(c({},o),{[n.definitionPath]:s}):o:{$ref:[...n.$refStrategy==="relative"?[]:n.basePath,n.definitionPath,i].join("/"),[n.definitionPath]:f(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"),fy=a((t,e={target:"openApi3"})=>{let r=py(t,e);return e.$schemaUrl===!1?delete r.$schema:typeof e.$schemaUrl=="string"&&(r.$schema=e.$schemaUrl),r},"toJSONSchemaLegacy");var gt=(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")},Dd=y;var ne=y.string().min(1),Nd=y.object({text:ne}),Md=y.object({markdown:ne}),$d=y.object({imageUrl:ne}),jd=y.object({audioUrl:ne}),Kd=y.object({videoUrl:ne}),Ud=y.object({fileUrl:ne,title:ne.optional()}),zd=y.object({latitude:y.number(),longitude:y.number(),address:y.string().optional(),title:y.string().optional()}),Fd=y.object({title:ne,subtitle:ne.optional(),imageUrl:ne.optional(),actions:y.array(y.object({action:y.enum(["postback","url","say"]),label:ne,value:ne}))}),Hd=y.object({text:ne,options:y.array(y.object({label:ne,value:ne}))}),gy=y.object({items:y.array(Fd)}),Wd=y.union([y.object({type:y.literal("text"),payload:Nd}),y.object({type:y.literal("image"),payload:$d}),y.object({type:y.literal("audio"),payload:jd}),y.object({type:y.literal("video"),payload:Kd}),y.object({type:y.literal("file"),payload:Ud}),y.object({type:y.literal("location"),payload:zd})]),my=y.object({items:y.array(Wd)}),hy={schema:Md},yy={schema:y.object({items:y.array(y.union([...Wd.options,y.object({type:y.literal("markdown"),payload:Md})]))})},vy={text:{schema:Nd},image:{schema:$d},audio:{schema:jd},video:{schema:Kd},file:{schema:Ud},location:{schema:zd},carousel:{schema:gy},card:{schema:Fd},dropdown:{schema:Hd},choice:{schema:Hd},bloc:{schema:my}};var _y={HIDDEN_IN_STUDIO:{bpActionHiddenInStudio:"true"},AWAIT_RETURN:{bpActionAwaitReturn:"true"}};var Ld=require("browser-or-node");var $s=console;function le(t){if(!t.body)throw new Error("Missing body");return JSON.parse(t.body)}async function Vt(t,e=8072,r=Py){if(!Ld.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 Ty(i);if(l.path==="/health"){o.writeHead(200).end("ok");return}let d=await t(l);o.writeHead(d?.status??200,d?.headers??{}).end(d?.body??"{}")}catch(l){let d=l instanceof Error?l.message:String(l);$s.error("Error while handling request",{error:d??"Internal error occured"}),o.writeHead(500).end(JSON.stringify({error:d??"Internal error occured"}))}});return s.listen(e,()=>r(e)),s}async function Ty(t){let e=await wy(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:by(n.search,"?"),headers:r,method:t.method?.toUpperCase()??"GET"}}function by(t,e){return t.indexOf(e)===0?t.slice(e.length):t}async function wy(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 Py(t){$s.info(`Listening on port ${t}`)}var On=require("@botpress/client");var N={};Xe(N,{mapKeys:()=>Sy,mapValues:()=>ky,mergeRecords:()=>Oy,pairs:()=>gn,stripUndefinedProps:()=>Ey,values:()=>xy});var gn=t=>Object.entries(t),xy=t=>Object.values(t),ky=(t,e)=>Object.fromEntries(gn(t).map(([r,n])=>[r,e(n,r)])),Sy=(t,e)=>Object.fromEntries(gn(t).map(([r,n])=>[e(r),n])),Ey=t=>Object.fromEntries(gn(t).filter(([,e])=>e!==void 0)),Oy=(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],d=e[o];l&&d?i[o]=r(l,d):l?i[o]=l:d&&(i[o]=d)}return i};var E={};Xe(E,{safePush:()=>Zy,unique:()=>Iy});var Zy=(t,...e)=>t?[...t,...e]:[...e],Iy=t=>Array.from(new Set(t));var Y={};Xe(Y,{setName:()=>By});var By=(t,e)=>(Object.defineProperty(t,"name",{value:e}),t);var qd=t=>{let{name:e,version:r}=t,n={actions:{},events:{},channels:{}},s={name:e,version:r,entities:N.mapValues(t.entities,o=>({name:o.name})),actions:{},events:{},channels:{}},i=N.mapValues(t.entities,o=>o.schema);for(let[o,l]of Object.entries(t.definition.actions??{})){let d=l.input.schema.dereference(i),u=l.output.schema.dereference(i),g=t.actions?.[o]?.name??o;n.actions[g]={...l,...t.actions?.[o]??{},input:{schema:d},output:{schema:u}},s.actions[o]={name:g}}for(let[o,l]of Object.entries(t.definition.events??{})){let d=l.schema.dereference(i),u=t.events?.[o]?.name??o;n.events[u]={...l,...t.events?.[o]??{},schema:d},s.events[o]={name:u}}for(let[o,l]of Object.entries(t.definition.channels??{})){let d={};for(let[g,h]of Object.entries(l.messages)){let T=h.schema.dereference(i);d[g]={...h,schema:T}}let u=t.channels?.[o]?.name??o;n.channels[u]={...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:d},s.channels[o]={name:u}}return{resolved:n,statement:s}};var Vd="4.21.0";var Ee=Vd;var mn=Symbol("schemaName"),Gd=t=>t?N.mapValues(t,(r,n)=>({...r,[mn]:n})):{},Jd=t=>mn in t&&t[mn]!==void 0,Yd=t=>t[mn];var hn=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;get metadata(){return{sdkVersion:Ee}}extend(e,r){let{entities:n,actions:s,events:i,channels:o}=this._callBuilder(e,r),l=this;l.interfaces??={};let d=Object.values(n).map(T=>T.name),u=d.length===0?e.name:`${e.name}<${d.join(",")}>`,{resolved:g,statement:h}=qd({...e,entities:n,actions:N.stripUndefinedProps(s),events:N.stripUndefinedProps(i),channels:N.stripUndefinedProps(o)});return l.actions=N.mergeRecords(l.actions??{},g.actions,this._mergeActions),l.channels=N.mergeRecords(l.channels??{},g.channels,this._mergeChannels),l.events=N.mergeRecords(l.events??{},g.events,this._mergeEvents),l.interfaces[u]={id:e.id,...h},this}_callBuilder(e,r){let s={entities:Gd(this.entities)},i=r(s),o=N.pairs(i.entities).find(([d,u])=>!Jd(u));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:N.mapValues(i.entities,d=>({name:Yd(d),schema:d.schema})),actions:i.actions??{},events:i.events??{},channels:i.channels??{}}}_mergeActions=(e,r)=>({...e,...r,input:{schema:gt(e.input.schema,r.input.schema)},output:{schema:gt(e.output.schema,r.output.schema)}});_mergeEvents=(e,r)=>({...e,...r,schema:gt(e.schema,r.schema)});_mergeChannels=(e,r)=>{let n=N.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:gt(e.schema,r.schema)})};var be=require("@botpress/client");var Xd=In(require("@botpress/client")),yn={retries:3,retryCondition:t=>Xd.axiosRetry.isNetworkOrIdempotentRequestError(t)||[429,502].includes(t.response?.status??0),retryDelay:(t,e)=>(Ry(e.response?.headers??{})??t)*1e3},Ry=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 Cy(String(n))}},Cy=t=>{let e=Dy(t)?Hy(t):t.length>0?parseInt(t,10):void 0;return e===void 0||isNaN(e)?void 0:e},Dy=t=>t.includes(" "),Hy=t=>{let e=Ny(t);if(!e)return;let r=new Date;return Math.max(0,Math.floor((e.getTime()-r.getTime())/1e3))},Ny=t=>{let e=new Date(t);return isNaN(e.getTime())?void 0:e};var mt=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 vn=class{_cost=0;get cost(){return this._cost}setCost(e){this._cost=e}toJSON(){return{cost:this.cost}}};var Oe="#",_n="x-bot-id",Qd="x-bot-user-id",eu="x-integration-id",tu="x-integration-alias",ru="x-webhook-id",nu="x-bp-configuration-type",Tn="x-bp-configuration",bn="x-bp-operation",su="x-bp-type";var ce=t=>{throw t instanceof Error?t:new Error(t)};var u_=y.enum(["webhook_received","message_created","action_triggered","register","unregister","ping","create_user","create_conversation"]),iu=t=>({botId:t[_n]||ce("Missing bot header"),botUserId:t[Qd]||ce("Missing bot user header"),integrationId:t[eu]||ce("Missing integration header"),integrationAlias:t[tu]||ce("Missing integration alias header"),webhookId:t[ru]||ce("Missing webhook header"),operation:t[bn]||ce("Missing operation header"),configurationType:t[nu]??null,configuration:JSON.parse(Buffer.from(t[Tn]||ce("Missing configuration header"),"base64").toString("utf-8"))});var au=In(require("util")),ht=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=au.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 yt=class t extends ht{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 My=t=>["traceparent","tracestate","sentry-trace"].reduce((e,r)=>(t[r]&&(e[r]=t[r]),e),{}),$y=(t,e,r)=>{let[,n]=(e.headers.traceparent||"").split("-"),s=new be.Client({botId:t.botId,integrationId:t.integrationId,integrationAlias:t.integrationAlias,retry:yn,headers:My(e.headers)}),i=new mt(s),o=new yt({traceId:n});return{ctx:t,req:e,client:i,logger:o,instance:r}},jy=async t=>{let{ctx:e}=t;switch(e.operation){case"webhook_received":return await Uy(t);case"register":return await zy(t);case"unregister":return await Fy(t);case"message_created":return await qy(t);case"action_triggered":return await Vy(t);case"ping":return await Ky(t);case"create_user":return await Wy(t);case"create_conversation":return await Ly(t);default:throw new be.InvalidPayloadError(`Unknown operation ${e.operation}`)}},ou=t=>async e=>{let r=iu(e.headers),n=$y(r,e,t),{logger:s}=n;try{let i;return i=await Gy(n),i?{...i,status:i.status??200}:(i=await jy(n),i?{...i,status:i.status??200}:{status:200})}catch(i){if((0,be.isApiError)(i)){let l=i.type==="Runtime"?i:new be.RuntimeError(i.message,i);return s.forBot().error(l.message),{status:l.code,body:JSON.stringify(l.toJSON())}}console.error(i);let o=new be.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())}}},Ky=async t=>{},Uy=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{let{req:i}=le(r);return s.webhook({client:t,ctx:e,req:i,logger:n})},zy=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.register)return;let{webhookUrl:i}=le(r);await s.register({client:t,ctx:e,webhookUrl:i,logger:n})},Fy=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.unregister)return;let{webhookUrl:i}=le(r);await s.unregister({ctx:e,webhookUrl:i,client:t,logger:n})},Wy=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.createUser)return;let{tags:i}=le(r);return await s.createUser({ctx:e,client:t,tags:i,logger:n})},Ly=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.createConversation)return;let{channel:i,tags:o}=le(r);return await s.createConversation({ctx:e,client:t,channel:i,tags:o,logger:n})},qy=async({ctx:t,req:e,client:r,logger:n,instance:s})=>{let{conversation:i,user:o,type:l,payload:d,message:u}=le(e),g=s.channels[i.channel];if(!g)throw new Error(`Channel ${i.channel} not found`);let h=g.messages[l];if(!h)throw new Error(`Message of type ${l} not found in channel ${i.channel}`);await h({ctx:t,conversation:i,message:u,user:o,type:l,client:r,payload:d,ack:async({tags:Z})=>{await r.updateMessage({id:u.id,tags:Z})},logger:n})},Vy=async({req:t,ctx:e,client:r,logger:n,instance:s})=>{let{input:i,type:o}=le(t);if(!o)throw new Error("Missing action type");let l=s.actions[o];if(!l)throw new Error(`Action ${o} not found`);let d=new vn,g={output:await l({ctx:e,input:i,client:r,type:o,logger:n,metadata:d}),meta:d.toJSON()};return{body:JSON.stringify(g)}},Gy=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 wn=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=ou(this);start=e=>Vt(this.handler,e)};var Pn=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.__advanced=e.__advanced,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;__advanced;withPlugins;get metadata(){return{sdkVersion:Ee}}addIntegration(e,r){let n=this;n.integrations||(n.integrations={});let s=r?.alias??e.name;if(n.integrations[s])throw new Error(`Another integration with alias "${s}" is already installed in the bot`);return n.integrations[s]={...e,alias:s,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;if(n.plugins[s])throw new Error(`Another plugin with alias "${s}" is already installed in the bot`);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)=>N.mapKeys(e??{},n=>`${r}${Oe}${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 d=this.integrations?.[l.name];if(!d)throw new Error(`Interface with alias "${o}" of plugin with alias "${n}" references integration "${l.name}" which is not installed`);let u=Object.entries(l.entities??{});for(let[g,{name:h}]of u){let T=d.definition.entities?.[h]?.schema;if(!T)throw new Error(`Interface entity "${h}" does not exist in integration "${d.name}"`);e[`interface:${o}/entities/${g}`]=T}}}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 Ye=require("@botpress/client");var vt=class t extends ht{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 fe=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));getOrCreateWorkflow=(e=>this._run("getOrCreateWorkflow",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 Jy=y.enum(["event_received","register","unregister","ping","action_triggered"]),lu=t=>({botId:t[_n]||ce("Missing bot id header"),operation:Jy.parse(t[bn]),type:t[su]||ce("Missing type header"),configuration:JSON.parse(Buffer.from(t[Tn]||ce("Missing configuration header"),"base64").toString("utf-8"))});var X={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 Yy=["child_workflow_deleted","child_workflow_finished","workflow_timedout","workflow_started","workflow_continued"],cu=async(t,e)=>{if(t.ctx.type!=="workflow_update"||!Yy.includes(e.payload.type))throw new Error("Unexpected event type");let r={...t,logger:Xy(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),X;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 Qy(r,e);default:e.payload.type}return X},Xy=(t,e)=>t.logger.with({eventId:e.id,workflowId:e.payload.workflow.id,conversationId:e.payload.conversation?.id,userId:e.payload.user?.id}),Qy=async(t,e)=>{let r=Ks(e.payload.type),n=t.self.workflowHandlers[r]?.[e.payload.workflow.name];if(!n||n.length===0)return t.logger.warn(`No ${r} handler found for workflow "${e.payload.workflow.name}"`),X;let{updatedWorkflow:s}=await ev(t,e);return s.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. `),X},ev=async(t,e)=>{let r=Ks(e.payload.type),n=t.self.workflowHandlers[r]?.[e.payload.workflow.name],s=structuredClone(e.payload.workflow);for(let i of n??[])s=await i({...t,event:e,conversation:e.payload.conversation,user:e.payload.user,workflow:s});return{updatedWorkflow:s}};var du=t=>async e=>{let r=lu(e.headers),n=new vt,s=new Ye.Client({botId:r.botId,retry:yn}),i=new fe(s,{before:{createMessage:async l=>{let d=t.hookHandlers.before_outgoing_message[l.type]??[];for(let u of d){let g=new fe(s);l=(await u({client:g,ctx:r,logger:n.with({conversationId:l.conversationId,userId:l.userId}),data:l}))?.data??l}return l},callAction:async l=>{let d=t.hookHandlers.before_outgoing_call_action[l.type]??[];for(let u of d){let g=new fe(s);l=(await u({client:g,ctx:r,logger:n,data:l}))?.data??l}return l}},after:{createMessage:async l=>{let d=t.hookHandlers.after_outgoing_message[l.message.type]??[];for(let u of d){let g=new fe(s);l=(await u({client:g,ctx:r,logger:n.with({messageId:l.message.id,conversationId:l.message.conversationId,userId:l.message.userId}),data:l}))?.data??l}return l},callAction:async(l,d)=>{let{type:u}=d,g=t.hookHandlers.after_outgoing_call_action[u]??[];for(let h of g){let T=new fe(s);l=(await h({client:T,ctx:r,logger:n,data:{type:u,...l}}))?.data??l}return l}}}),o={req:e,ctx:r,logger:n,client:i,self:t};try{switch(r.operation){case"action_triggered":return await iv(o);case"event_received":return await sv(o);case"register":return await rv(o);case"unregister":return await nv(o);case"ping":return await tv(o);default:throw new Error(`Unknown operation ${r.operation}`)}}catch(l){let d=l instanceof Error?l:new Error(String(l));if((0,Ye.isApiError)(d)){let g=d.type==="Runtime"?d:new Ye.RuntimeError(d.message,d);return n.error(g.message),{status:g.code,body:JSON.stringify(g.toJSON())}}let u=new Ye.RuntimeError("An unexpected error occurred in the bot.",d);return n.error(u.message,d),{status:u.code,body:JSON.stringify(u.toJSON())}}},tv=async t=>X,rv=async t=>X,nv=async t=>X,sv=async t=>{let{ctx:e,logger:r,req:n,client:s,self:i}=t,o={client:s,ctx:e,logger:r},l=le(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 cu(t,l.event);if(e.type==="message_created"){let Z=l.event,k=Z.payload.message;o.logger=o.logger.with({messageId:k.id,conversationId:k.conversationId,userId:k.userId});let K=i.hookHandlers.before_incoming_message[k.type]??[];for(let ue of K){let ae=await ue({...o,data:k});if(k=ae?.data??k,ae?.stop)return X}let F={...o,user:Z.payload.user,conversation:Z.payload.conversation,message:k,event:Z},Q=i.messageHandlers[k.type]??[];for(let ue of Q)await ue(F);let ie=i.hookHandlers.after_incoming_message[k.type]??[];for(let ue of ie){let ae=await ue({...o,data:k});if(k=ae?.data??k,ae?.stop)return X}return X}if(e.type==="state_expired"){let k=l.event.payload.state,K={...o,state:k},F=i.stateExpiredHandlers[k.name]??[];for(let Q of F)await Q(K);return X}let d=l.event,u=i.hookHandlers.before_incoming_event[d.type]??[];for(let Z of u){let k=await Z({...o,data:d});if(d=k?.data??d,k?.stop)return X}let g={...o,event:d},h=i.eventHandlers[d.type]??[];for(let Z of h)await Z(g);let T=i.hookHandlers.after_incoming_event[d.type]??[];for(let Z of T){let k=await Z({...o,data:d});if(d=k?.data??d,k?.stop)return X}return X},iv=async({ctx:t,logger:e,req:r,client:n,self:s})=>{let{input:i,type:o}=le(r);if(!o)throw new Error("Missing action type");let l=s.hookHandlers.before_incoming_call_action[o]??[];for(let T of l){let Z=await T({ctx:t,logger:e,client:n,data:{type:o,input:i}});i=Z?.data?.input??i,o=Z?.data?.type??o}let d=s.actionHandlers[o];if(!d)throw new Error(`Action ${o} not found`);let u=await d({ctx:t,logger:e,input:i,client:n,type:o}),g=s.hookHandlers.after_incoming_call_action[o]??[];for(let T of g){let Z=await T({ctx:t,logger:e,client:n,data:{type:o,output:u}});o=Z?.data?.type??o,u=Z?.data?.output??u}return{status:200,body:JSON.stringify({output:u})}};var we=t=>new Proxy({},{get:(e,r)=>({listInstances:{all:n=>Ze({workflowName:r,client:t,input:n}),running:n=>Ze({workflowName:r,client:t,input:n,statuses:["in_progress"]}),scheduled:n=>Ze({workflowName:r,client:t,input:n,statuses:["pending","listening"]}),allFinished:n=>Ze({workflowName:r,client:t,input:n,statuses:["completed","cancelled","failed","timedout"]}),cancelled:n=>Ze({workflowName:r,client:t,input:n,statuses:["cancelled"]}),failed:n=>Ze({workflowName:r,client:t,input:n,statuses:["failed"]}),succeeded:n=>Ze({workflowName:r,client:t,input:n,statuses:["completed"]}),timedOut:n=>Ze({workflowName:r,client:t,input:n,statuses:["timedout"]})},startNewInstance:async n=>{let{workflow:s}=await t.createWorkflow({name:r,status:"pending",...n});return{workflow:de({client:t,workflow:s})}}})}),Ze=async t=>{let e=await t.client.listWorkflows({name:t.workflowName,statuses:t.statuses,...t.input});return{...e,workflows:e.workflows.map(r=>de({client:t.client,workflow:r}))}},de=t=>{let e=!1;return{...t.workflow,async update(r){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,...r});return await t.onWorkflowUpdate?.(n),{workflow:de({...t,workflow:n})}},async acknowledgeStartOfProcessing(){if(!t.event||t.workflow.status!=="pending"||e)return{workflow:de(t)};let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,status:"in_progress",eventId:t.event.id});return e=!0,await t.onWorkflowUpdate?.(r),{workflow:de({...t,workflow:r})}},async setFailed({failureReason:r}){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,status:"failed",failureReason:r});return await t.onWorkflowUpdate?.(n),{workflow:de({...t,workflow:n})}},async setCompleted({output:r}={}){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,status:"completed",output:r});return await t.onWorkflowUpdate?.(n),{workflow:de({...t,workflow:n})}},async cancel(){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,status:"cancelled"});return await t.onWorkflowUpdate?.(r),{workflow:de({...t,workflow:r})}}}};var xn=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(Oe);if(!(o!==s||!l)&&(n=i.actionHandlers[l],n))return Y.setName(d=>n({...d,workflows:we(d.client)}),n.name)}}})}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,d)=>l.order-d.order).map(({handler:l})=>l);return E.unique([...n,...o]).map(l=>Y.setName(d=>l({...d,workflows:we(d.client)}),l.name))}})}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,d)=>l.order-d.order).map(({handler:l})=>l);return E.unique([...n,...o]).map(l=>Y.setName(d=>l({...d,workflows:we(d.client)}),l.name))}})}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,d)=>l.order-d.order).map(({handler:l})=>l);return E.unique([...n,...o]).map(l=>Y.setName(d=>l({...d,workflows:we(d.client)}),l.name))}})}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(h=>h.hookHandlers[r]?.[i]??[]),l=this._hookHandlers[r]??{},d=l[i]??[],u=l["*"]??[],g=[...d,...u].sort((h,T)=>h.order-T.order).map(({handler:h})=>h);return E.unique([...o,...g]).map(h=>Y.setName(T=>h({...T,workflows:we(T.client)}),h.name))}})}})}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((d,u)=>d.order-u.order).map(({handler:d})=>d)??[],l=Object.values(this._plugins).flatMap(d=>d.workflowHandlers[r]?.[i]??[]);return E.unique([...o,...l]).map(d=>Y.setName(async u=>{let g=u.workflow;return await d({...u,workflow:de({...u,onWorkflowUpdate(h){g=h}}),workflows:we(u.client)}),g},d.name))}})}})}on={message:(e,r)=>{this._messageHandlers[e]=E.safePush(this._messageHandlers[e],{handler:r,order:this._registerOrder++})},event:(e,r)=>{this._eventHandlers[e]=E.safePush(this._eventHandlers[e],{handler:r,order:this._registerOrder++})},stateExpired:(e,r)=>{this._stateExpiredHandlers[e]=E.safePush(this._stateExpiredHandlers[e],{handler:r,order:this._registerOrder++})},beforeIncomingEvent:(e,r)=>{this._hookHandlers.before_incoming_event[e]=E.safePush(this._hookHandlers.before_incoming_event[e],{handler:r,order:this._registerOrder++})},beforeIncomingMessage:(e,r)=>{this._hookHandlers.before_incoming_message[e]=E.safePush(this._hookHandlers.before_incoming_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingMessage:(e,r)=>{this._hookHandlers.before_outgoing_message[e]=E.safePush(this._hookHandlers.before_outgoing_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingCallAction:(e,r)=>{this._hookHandlers.before_outgoing_call_action[e]=E.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},beforeIncomingCallAction:(e,r)=>{this._hookHandlers.before_incoming_call_action[e]=E.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingEvent:(e,r)=>{this._hookHandlers.after_incoming_event[e]=E.safePush(this._hookHandlers.after_incoming_event[e],{handler:r,order:this._registerOrder++})},afterIncomingMessage:(e,r)=>{this._hookHandlers.after_incoming_message[e]=E.safePush(this._hookHandlers.after_incoming_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingMessage:(e,r)=>{this._hookHandlers.after_outgoing_message[e]=E.safePush(this._hookHandlers.after_outgoing_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingCallAction:(e,r)=>{this._hookHandlers.after_outgoing_call_action[e]=E.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingCallAction:(e,r)=>{this._hookHandlers.after_incoming_call_action[e]=E.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:r,order:this._registerOrder++})},workflowStart:(e,r)=>{this._workflowHandlers.started[e]=E.safePush(this._workflowHandlers.started[e],{handler:r,order:this._registerOrder++})},workflowContinue:(e,r)=>{this._workflowHandlers.continued[e]=E.safePush(this._workflowHandlers.continued[e],{handler:r,order:this._registerOrder++})},workflowTimeout:(e,r)=>{this._workflowHandlers.timed_out[e]=E.safePush(this._workflowHandlers.timed_out[e],{handler:r,order:this._registerOrder++})}};handler=du(this);start=e=>Vt(this.handler,e)};var kn=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,this.__advanced=e.__advanced;let r=this._getEntityReference(this.entities),n=e.events===void 0?{}:N.mapValues(e.events,o=>({...o,schema:o.schema(r)})),s=e.actions===void 0?{}:N.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?{}:N.mapValues(e.channels,o=>({...o,messages:N.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;__advanced;get metadata(){return{sdkVersion:Ee}}_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=Dd.ref(n);i&&l.title(i),o&&l.describe(o),r[n]=l}return r}};var Sn=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.__advanced=e.__advanced,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;__advanced;get metadata(){return{sdkVersion:Ee}}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 uu=t=>{let[e,r]=t.split(Us);return!e||!r?null:{namespace:e,eventName:r}},pu=t=>`${t.namespace}${Us}${t.actionName}`,fu=t=>`${t.namespace}${Us}${t.eventName}`,gu=(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}},mu=(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 hu=(t,e)=>new Proxy({},{get:(r,n)=>new Proxy({},{get:(s,i)=>o=>av({client:t,interfaces:e.interfaces,integrationOrInterfaceName:n,methodName:i,input:o})})}),av=async({client:t,interfaces:e,integrationOrInterfaceName:r,methodName:n,input:s})=>{let i=gu({namespace:r,actionName:n},e),o=pu(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})}},yu=(t,e)=>new Proxy({},{get:(r,n)=>{let s=e.alias!==void 0?`${e.alias}${Oe}${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,n){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:r,expiry:n?.expiryMs})}async getOrSet(e,r,n){return await this._client.getOrSetState({type:this._stateType,name:this._stateName,id:e,payload:r,expiry:n?.expiryMs}).then(s=>s.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})}},vu=(t,e)=>new Proxy({},{get:(r,n)=>new Proxy({},{get:(s,i)=>{let o=e.alias!==void 0?`${e.alias}${Oe}${i}`:i;return new Fs(t,n,o)}})});var En=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=hu(e,this._runtime),o=vu(e,this._runtime),l=we(e),d=yu(e,this._runtime);return{configuration:r,interfaces:n,actions:i,states:o,alias:s,workflows:l,events:d}}get actionHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._actionHandlers[r];if(n)return Y.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 E.unique([...n,...s]).sort((o,l)=>o.order-l.order).map(({handler:o})=>Y.setName(l=>o({...l,message:l.message,...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 E.unique([...n,...s,...i]).sort((l,d)=>l.order-d.order).map(({handler:l})=>Y.setName(d=>l({...d,event:d.event,...this._getTools(d.client)}),l.name))}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._stateExpiredHandlers[r]??[],s=this._stateExpiredHandlers["*"]??[];return E.unique([...n,...s]).sort((o,l)=>o.order-l.order).map(({handler:o})=>Y.setName(l=>o({...l,state:l.state,...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??[]),d=n["*"]??[];return E.unique([...o,...l,...d]).sort((g,h)=>g.order-h.order).map(({handler:g})=>Y.setName(h=>g({...h,data:h.data,...this._getTools(h.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,d)=>l.order-d.order)??[]).map(({handler:l})=>Y.setName(async d=>{let u=d.workflow;return await l({...d,workflow:de({...d,onWorkflowUpdate(g){u=g}}),...this._getTools(d.client)}),u},l.name))})}})}on={message:(e,r)=>{this._messageHandlers[e]=E.safePush(this._messageHandlers[e],{handler:r,order:this._registerOrder++})},event:(e,r)=>{this._eventHandlers[e]=E.safePush(this._eventHandlers[e],{handler:r,order:this._registerOrder++})},stateExpired:(e,r)=>{this._stateExpiredHandlers[e]=E.safePush(this._stateExpiredHandlers[e],{handler:r,order:this._registerOrder++})},beforeIncomingEvent:(e,r)=>{this._hookHandlers.before_incoming_event[e]=E.safePush(this._hookHandlers.before_incoming_event[e],{handler:r,order:this._registerOrder++})},beforeIncomingMessage:(e,r)=>{this._hookHandlers.before_incoming_message[e]=E.safePush(this._hookHandlers.before_incoming_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingMessage:(e,r)=>{this._hookHandlers.before_outgoing_message[e]=E.safePush(this._hookHandlers.before_outgoing_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingCallAction:(e,r)=>{this._hookHandlers.before_outgoing_call_action[e]=E.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},beforeIncomingCallAction:(e,r)=>{this._hookHandlers.before_incoming_call_action[e]=E.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingEvent:(e,r)=>{this._hookHandlers.after_incoming_event[e]=E.safePush(this._hookHandlers.after_incoming_event[e],{handler:r,order:this._registerOrder++})},afterIncomingMessage:(e,r)=>{this._hookHandlers.after_incoming_message[e]=E.safePush(this._hookHandlers.after_incoming_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingMessage:(e,r)=>{this._hookHandlers.after_outgoing_message[e]=E.safePush(this._hookHandlers.after_outgoing_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingCallAction:(e,r)=>{this._hookHandlers.after_outgoing_call_action[e]=E.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingCallAction:(e,r)=>{this._hookHandlers.after_incoming_call_action[e]=E.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:r,order:this._registerOrder++})},workflowStart:(e,r)=>{this._workflowHandlers.started[e]=E.safePush(this._workflowHandlers.started[e],{handler:r,order:this._registerOrder++})},workflowContinue:(e,r)=>{this._workflowHandlers.continued[e]=E.safePush(this._workflowHandlers.continued[e],{handler:r,order:this._registerOrder++})},workflowTimeout:(e,r)=>{this._workflowHandlers.timed_out[e]=E.safePush(this._workflowHandlers.timed_out[e],{handler:r,order:this._registerOrder++})}};_eventResolvesTo=(e,r)=>{let n=uu(e);if(!n)return!1;let s=mu(n,this._runtime.interfaces);return fu(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}};var Ws={};Xe(Ws,{allWithinMajorOf:()=>ov,allWithinMinorOf:()=>lv});var Gt=In(require("semver"));function ov(t){let e=Gt.major(t.version);return{...t,version:`>=${e}.0.0 <${e+1}.0.0`}}function lv(t){let e=Gt.major(t.version),r=Gt.minor(t.version);return{...t,version:`>=${e}.${r}.0 <${e}.${r+1}.0`}}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,coerce,conversation,createZodEnum,cuid2Regex,cuidRegex,custom,datasource,date,discriminatedUnion,effect,emailRegex,enum:null,errorUtil,event,function:null,getErrorMap,getParsedType,instanceof:null,intent,intersection,ipv4Regex,ipv6Regex,isAborted,isApiError,isAsync,isDirty,isEmojiRegex,isValid,json,knowledgebase,late,lazy,literal,makeIssue,map,mergeObjectSchemas,message,messages,nan,nativeEnum,never,null:null,nullable,number,object,objectUtil,oboolean,onumber,optional,ostring,parseBody,pipeline,preprocess,processCreateParams,promise,quotelessJson,readonly,record,ref,serve,set,setErrorMap,strictObject,string,symbol,table,tablerow,transformer,transforms,tuple,ulidRegex,undefined,union,unknown,user,util,uuidRegex,variable,version,void:null,z});
69
+ `,i+=`}
70
+ `,i+=`}
71
+ `),i+=`}
72
+ `,i+="})"}let s=n?i?n+i:r?r==="z.never()"?n+".strict()":n+`.catchall(${r})`:n:i||(r?`z.record(${r})`:"z.record(z.any())");return $.an.anyOf(t)&&(s+=`.and(${gu(f(u({},t),{anyOf:t.anyOf.map(a=>typeof a=="object"&&!a.type&&(a.properties||a.additionalProperties||a.patternProperties)?f(u({},a),{type:"object"}):a)}),e)})`),$.a.oneOf(t)&&(s+=`.and(${Ki(f(u({},t),{oneOf:t.oneOf.map(a=>typeof a=="object"&&!a.type&&(a.properties||a.additionalProperties||a.patternProperties)?f(u({},a),{type:"object"}):a)}),e)})`),$.an.allOf(t)&&(s+=`.and(${Lt(f(u({},t),{allOf:t.allOf.map(a=>typeof a=="object"&&!a.type&&(a.properties||a.additionalProperties||a.patternProperties)?f(u({},a),{type:"object"}):a)}),e)})`),s}o(mu,"parseObject");var Rh=o(t=>{var e;let n="z.string()";if((e=t[w])!=null&&e.coerce){if(t.format==="date-time")return"z.coerce.date()";n="z.coerce.string()"}return n+=q(t,"format",({value:r})=>{switch(r){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(",")"]}}),n+=q(t,"pattern",({json:r})=>[`.regex(new RegExp(${r})`,", ",")"]),n+=q(t,"minLength",({json:r})=>[`.min(${r}`,", ",")"]),n+=q(t,"maxLength",({json:r})=>[`.max(${r}`,", ",")"]),n},"parseString"),Dh=o((t,e)=>`${L(Eh(t,"nullable"),e,!0)}.nullable()`,"parseNullable"),Hh=o(t=>`z.ref('${t.$ref}')`,"parseRef"),Nh=o((t,e)=>{var n,r;if(t.oneOf.length<=1||!((n=t.discriminator)!=null&&n.propertyName))return Ki(t,e);let i=t.oneOf.map((s,a)=>L(s,f(u({},e),{path:[...e.path,"oneOf",a]})));return`z.discriminatedUnion("${(r=t.discriminator)==null?void 0:r.propertyName}", [${i.join(", ")}])`},"parseDiscriminator"),L=o((t,e={seen:new Map,path:[]},n)=>{if(typeof t!="object")return t?"z.any()":"z.never()";if(e.parserOverride){let s=e.parserOverride(t,e);if(typeof s=="string")return s}let r=e.seen.get(t);if(r){if(r.r!==void 0)return r.r;if(e.depth===void 0||r.n>=e.depth)return"z.any()";r.n+=1}else r={r:void 0,n:0},e.seen.set(t,r);let i=jh(t,e);return n||(i=Mh(t,i),e.withoutDefaults||(i=$h(t,i))),r.r=i,i},"parseSchema"),Mh=o((t,e)=>(t.description&&(e+=`.describe(${JSON.stringify(t.description)})`),e),"addMeta"),$h=o((t,e)=>(t.default!==void 0&&(e+=`.default(${JSON.stringify(t.default)})`),e),"addDefaults"),jh=o((t,e)=>$.a.nullable(t)?Dh(t,e):$.an.object(t)?mu(t,e):$.an.array(t)?Ih(t,e):$.an.anyOf(t)?gu(t,e):$.an.allOf(t)?Lt(t,e):$.a.discriminator(t)?Nh(t,e):$.a.oneOf(t)?Ki(t,e):$.a.not(t)?xh(t,e):$.an.enum(t)?Bh(t):$.a.const(t)?Zh(t):$.a.multipleType(t)?Ph(t,e):$.a.primitive(t,"string")?Rh(t):$.a.primitive(t,"number")||$.a.primitive(t,"integer")?Ch(t):$.a.primitive(t,"boolean")?bh(t):$.a.primitive(t,"null")?kh(t):$.a.conditional(t)?Ah(t,e):$.a.ref(t)?Hh(t):wh(t),"selectParser"),$={an:{object:o(t=>t.type==="object","object"),array:o(t=>t.type==="array","array"),anyOf:o(t=>t.anyOf!==void 0,"anyOf"),allOf:o(t=>t.allOf!==void 0,"allOf"),enum:o(t=>t.enum!==void 0,"enum")},a:{nullable:o(t=>t.nullable===!0,"nullable"),multipleType:o(t=>Array.isArray(t.type),"multipleType"),not:o(t=>t.not!==void 0,"not"),const:o(t=>t.const!==void 0,"const"),primitive:o((t,e)=>t.type===e,"primitive"),conditional:o(t=>!!("if"in t&&t.if&&"then"in t&&"else"in t&&t.then&&t.else),"conditional"),discriminator:o(t=>{var e;return t.oneOf!==void 0&&((e=t.discriminator)==null?void 0:e.propertyName)!==void 0},"discriminator"),oneOf:o(t=>t.oneOf!==void 0,"oneOf"),ref:o(t=>t.$ref!==void 0,"ref")}},Kh=o(t=>{let e;try{e=new Function("z",`return ${t}`)(p)}catch(n){return{sucess:!1,error:`Failed to evaluate schema: ${(n instanceof Error?n:new Error(String(n))).message}`}}return e instanceof p.ZodType?{sucess:!0,value:e}:{sucess:!1,error:`String "${t}" does not evaluate to a Zod schema`}},"evalZuiString"),Uh=o(t=>L(t,{seen:new Map,path:[]}),"jsonSchemaToZodStr"),Fh=o(t=>{let e=Uh(t);e=e.replaceAll("errors: z.ZodError[]","errors");let n=Kh(e);if(!n.sucess)throw new Jn(n.error);return n.value},"jsonSchemaToZod"),Nt=o((t,e)=>{var n,r;if(e[w]&&t._def&&(t.naked()._def[w]=e[w]),((n=t._def)==null?void 0:n.typeName)==="ZodObject"&&e.type==="object"&&e.properties&&Object.entries(e.properties).forEach(([i,s])=>{let a=typeof t._def.shape=="function"?t._def.shape():t._def.shape;a[i]&&Nt(a[i],s)}),((r=t._def)==null?void 0:r.typeName)==="ZodRecord"&&e.type==="object"&&e.additionalProperties&&Nt(t._def.valueType,e.additionalProperties),e.type==="array"&&e.items){let i=e.items;if(typeof i=="object"&&!Array.isArray(i)){let s=t._def.type;s&&Nt(s,i)}else Array.isArray(i)&&i.forEach((s,a)=>{let l=t._def;l.typeName===y.ZodFirstPartyTypeKind.ZodTuple&&Nt(l.items[a],s)})}},"applyZuiPropsRecursively"),zh=o(t=>{let e=Fh(t);return Nt(e,t),e},"fromJSONSchemaLegacy"),Wh=o(t=>{var e,n;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(r=>typeof r!="boolean"&&hu(r))&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)===p.ZodFirstPartyTypeKind.ZodOptional},"isOptionalSchema"),Lh=o(t=>{var e,n;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(r=>typeof r!="boolean"&&r.type==="null")&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)===p.ZodFirstPartyTypeKind.ZodNullable},"isNullableSchema"),hu=o(t=>{var e,n;return t.not===!0&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)===p.ZodFirstPartyTypeKind.ZodUndefined},"isUndefinedSchema"),Vh=o(t=>{var e,n;return!t.not&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)===p.ZodFirstPartyTypeKind.ZodUnknown},"isUnknownSchema"),qh=o(({type:t,minimum:e,exclusiveMinimum:n,maximum:r,exclusiveMaximum:i,multipleOf:s,format:a})=>{let l=p.number();return t==="integer"&&(l=l.int()),a==="finite"&&(l=l.finite()),n!==void 0?l=l.gt(n):e!==void 0&&(l=l.gte(e)),i!==void 0?l=l.lt(i):r!==void 0&&(l=l.lte(r)),s!==void 0&&(l=l.multipleOf(s)),l},"numberJSONSchemaToZuiNumber"),Gh=o(({format:t,pattern:e,minLength:n,maxLength:r})=>{let i=p.string();if(n&&r&&n===r?i=i.length(n):(n&&(i=i.min(n)),r&&(i=i.max(r))),t==="cuid"||e===j.cuid)i=i.cuid();else if(t==="cuid2"||e===j.cuid2)i=i.cuid2();else if(t==="emoji"||e===j.emoji)i=i.emoji();else if(t==="ulid"||e===j.ulid)i=i.ulid();else if(t==="date-time"){let{precision:s,offset:a}=e?ch(e):{};i=i.datetime({precision:s,offset:a})}else t==="email"||e===j.email?i=i.email():t==="ipv4"||e===j.ipv4?i=i.ip():t==="ipv6"||e===j.ipv6?i=i.ip("v6"):t==="uri"?i=i.url():t==="uuid"||e===j.uuid?i=i.uuid():e&&(i=i.regex(new RegExp(e)));return i},"stringJSONSchemaToZuiString"),kt=o((t,e)=>{let n=[];e.enum!==void 0&&n.push(...e.enum),e.const!==void 0&&n.push(e.const);let r=n.filter(a=>typeof a===t),[i]=r;if(!i){if(t==="string"&&e.type==="string")return Gh(e);if(t==="number"&&(e.type==="number"||e.type==="integer"))return qh(e);if(t==="boolean")return p.boolean();if(t==="null")return p.null();throw new Jn(`Unknown primitive type: "${t}"`)}if(r.length===1)return p.literal(i);let s=r.map(a=>p.literal(a));return p.union(s)},"toZuiPrimitive"),Jh=o((t,e)=>Yh(t)?Qh(t,e):Xh(t)?ey(t,e):ty(t,e),"arrayJSONSchemaToZuiArray"),Yh=o(t=>Array.isArray(t.items),"_isTuple"),Xh=o(t=>t.items!==void 0&&t.uniqueItems,"_isSet"),Qh=o(({items:t,additionalItems:e},n)=>{let r=t.map(n),i=p.tuple(r);return e!==void 0&&(i=i.rest(n(e))),i},"_handleTuple"),ey=o(({items:t,minItems:e,maxItems:n},r)=>{let i=p.set(r(t));return e&&(i=i.min(e)),n&&(i=i.max(n)),i},"_handleSet"),ty=o(({minItems:t,maxItems:e,items:n},r)=>{let i=p.array(r(n));return t&&t===e?i.length(t):(t&&(i=i.min(t)),e&&(i=i.max(e)),i)},"_handleArray"),rt=p.any();function yu(t){return W(t)}o(yu,"fromJSONSchema");function W(t){var e;if(t===void 0)return rt;if(t===!0)return p.any();if(t===!1)return p.never();if(t.default!==void 0)return W(f(u({},t),{default:void 0})).default(t.default);if(t.readOnly)return W(f(u({},t),{readOnly:void 0})).readonly();if(t.oneOf!==void 0)throw new Ie({oneOf:t.oneOf});if(t.patternProperties!==void 0)throw new Ie({patternProperties:t.patternProperties});if(t.propertyNames!==void 0)throw new Ie({propertyNames:t.propertyNames});if(t.if!==void 0)throw new Ie({if:t.if});if(t.then!==void 0)throw new Ie({then:t.then});if(t.else!==void 0)throw new Ie({else:t.else});if(t.$ref!==void 0)return p.ref(t.$ref);if(t.not!==void 0){if(hu(t))return p.undefined();if(t.not===!0)return p.never();throw new Ie({not:t.not})}if(Array.isArray(t.type)){if(t.type.length===0)return rt;if(t.type.length===1)return W(f(u({},t),{type:t.type[0]}));let n=t,{type:r}=n,i=js(n,["type"]),s=t.type.map(a=>W(f(u({},i),{type:a})));return p.union(s)}if(t.type==="string")return t.enum&&t.enum.length>0?p.enum(t.enum):kt("string",t);if(t.type==="integer"){let n=kt("number",t);return n instanceof p.ZodNumber?n.int():n}if(t.type==="number")return kt("number",t);if(t.type==="boolean")return kt("boolean",t);if(t.type==="null")return kt("null",t);if(t.type==="array")return Jh(t,W);if(t.type==="object"){if(t.additionalProperties!==void 0&&t.properties!==void 0){let n=W(t.additionalProperties);return W(f(u({},t),{additionalProperties:void 0})).catchall(n)}if(t.properties!==void 0){let n={};for(let[r,i]of Object.entries(t.properties)){let s=W(i),a=(e=t.required)!=null?e:[];n[r]=a.includes(r)?s:s.optional()}return p.object(n)}if(t.additionalProperties!==void 0){let n=W(t.additionalProperties);return p.record(n)}return p.record(rt)}if(t.anyOf!==void 0){if(t.anyOf.length===0)return rt;if(t.anyOf.length===1)return W(t.anyOf[0]);if(Wh(t))return W(t.anyOf[0]).optional();if(Lh(t))return W(t.anyOf[0]).nullable();let n=t.anyOf.map(W);return p.union(n)}if(t.allOf!==void 0){if(t.allOf.length===0)return rt;if(t.allOf.length===1)return W(t.allOf[0]);let[n,...r]=t.allOf,i=W(n),s=W({allOf:r});return p.intersection(i,s)}return Vh(t)?p.unknown():rt}o(W,"_fromJSONSchema");var ny=/^\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))?$/,ei=o((t,e,n=!0)=>{if(typeof t!="object")throw new zr("Input must be an object");let r=o(a=>{let l=a;return e?.nullable&&(l=l.nullable()),e?.optional&&(l=l.optional()),e?.passtrough&&typeof l.passthrough=="function"&&(l=l.passthrough()),l},"applyOptions"),i=Object.entries(t).reduce((a,[l,c])=>{if(c===null)a[l]=r(y.null());else switch(typeof c){case"string":a[l]=ny.test(c)?r(y.string().datetime()):r(y.string());break;case"number":a[l]=r(y.number());break;case"boolean":a[l]=r(y.boolean());break;case"object":Array.isArray(c)?c.length===0?a[l]=r(y.array(y.unknown())):typeof c[0]=="object"?a[l]=r(y.array(ei(c[0],e,!1))):["string","number","boolean"].includes(typeof c[0])&&(a[l]=r(y.array(y[typeof c[0]]()))):a[l]=r(ei(c,e,!1));break;default:throw new zr(`Unsupported type for key ${l}`)}return a},{}),s=Object.keys(i).length>0;return e?.passtrough||!n&&!s?y.object(i).passthrough():y.object(i)},"fromObject");function vu(){return{}}o(vu,"parseAnyDef");function _u(t,e){var n,r;let i={type:"array"};return((r=(n=t.type)==null?void 0:n._def)==null?void 0:r.typeName)!=="ZodAny"&&(i.items=A(t.type._def,f(u({},e),{currentPath:[...e.currentPath,"items"]}))),t.minLength&&D(i,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&D(i,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(D(i,"minItems",t.exactLength.value,t.exactLength.message,e),D(i,"maxItems",t.exactLength.value,t.exactLength.message,e)),i}o(_u,"parseArrayDef");function Tu(t,e){let n=u({type:"integer",format:"int64"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return n;for(let r of t.checks)switch(r.kind){case"min":e.target==="jsonSchema7"?r.inclusive?D(n,"minimum",r.value,r.message,e):D(n,"exclusiveMinimum",r.value,r.message,e):(r.inclusive||(n.exclusiveMinimum=!0),D(n,"minimum",r.value,r.message,e));break;case"max":e.target==="jsonSchema7"?r.inclusive?D(n,"maximum",r.value,r.message,e):D(n,"exclusiveMaximum",r.value,r.message,e):(r.inclusive||(n.exclusiveMaximum=!0),D(n,"maximum",r.value,r.message,e));break;case"multipleOf":D(n,"multipleOf",r.value,r.message,e);break}return n}o(Tu,"parseBigintDef");function bu(t){return u({type:"boolean"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{})}o(bu,"parseBooleanDef");function wu(t,e){return A(t.type._def,e)}o(wu,"parseBrandedDef");var ry=o((t,e)=>A(t.innerType._def,e),"parseCatchDef");function Pu(t,e){return e.dateStrategy=="integer"?iy(t,e):u({type:"string",format:"date-time"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{})}o(Pu,"parseDateDef");var iy=o((t,e)=>{let n=u({type:"integer",format:"unix-time"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{});for(let r of t.checks)switch(r.kind){case"min":e.target==="jsonSchema7"&&D(n,"minimum",r.value,r.message,e);break;case"max":e.target==="jsonSchema7"&&D(n,"maximum",r.value,r.message,e);break}return n},"integerDateParser");function xu(t,e){return f(u({},A(t.innerType._def,e)),{default:t.defaultValue()})}o(xu,"parseDefaultDef");function ku(t,e){return e.effectStrategy==="input"?A(t.schema._def,e):{}}o(ku,"parseEffectsDef");function Su(t){return{type:"string",enum:t.values}}o(Su,"parseEnumDef");var sy=o(t=>"type"in t&&t.type==="string"?!1:"allOf"in t,"isJsonSchema7AllOfType");function Eu(t,e){let n=[A(t.left._def,f(u({},e),{currentPath:[...e.currentPath,"allOf","0"]})),A(t.right._def,f(u({},e),{currentPath:[...e.currentPath,"allOf","1"]}))].filter(s=>!!s),r=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,i=[];return n.forEach(s=>{if(sy(s))i.push(...s.allOf),s.unevaluatedProperties===void 0&&(r=void 0);else{let a=s;if("additionalProperties"in s&&s.additionalProperties===!1){let l=s,{additionalProperties:c}=l;a=js(l,["additionalProperties"])}else r=void 0;i.push(a)}}),i.length?u({allOf:i},r):void 0}o(Eu,"parseIntersectionDef");function Ou(t,e){let n=typeof t.value;return n!=="bigint"&&n!=="number"&&n!=="boolean"&&n!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:n==="bigint"?"integer":n,enum:[t.value]}:{type:n==="bigint"?"integer":n,const:t.value}}o(Ou,"parseLiteralDef");function Ui(t,e){var n,r,i,s,a;if(e.target==="openApi3"&&((n=t.keyType)==null?void 0:n._def.typeName)==="ZodEnum")return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((c,d)=>{var g;return f(u({},c),{[d]:(g=A(t.valueType._def,f(u({},e),{currentPath:[...e.currentPath,"properties",d]})))!=null?g:{}})},{}),additionalProperties:!1};let l={type:"object",additionalProperties:(r=A(t.valueType._def,f(u({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?r:{}};if(e.target==="openApi3")return l;if(((i=t.keyType)==null?void 0:i._def.typeName)==="ZodString"&&((s=t.keyType._def.checks)!=null&&s.length)){let c=Object.entries(hi(t.keyType._def,e)).reduce((d,[g,m])=>g==="type"?d:f(u({},d),{[g]:m}),{});return f(u({},l),{propertyNames:c})}else if(((a=t.keyType)==null?void 0:a._def.typeName)==="ZodEnum")return f(u({},l),{propertyNames:{enum:t.keyType._def.values}});return l}o(Ui,"parseRecordDef");function Iu(t,e){if(e.mapStrategy==="record")return Ui(t,e);let n=A(t.keyType._def,f(u({},e),{currentPath:[...e.currentPath,"items","items","0"]}))||{},r=A(t.valueType._def,f(u({},e),{currentPath:[...e.currentPath,"items","items","1"]}))||{};return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}o(Iu,"parseMapDef");function Zu(t){let e=t.values,r=Object.keys(t.values).filter(s=>typeof e[e[s]]!="number").map(s=>e[s]),i=Array.from(new Set(r.map(s=>typeof s)));return{type:i.length===1?i[0]==="string"?"string":"number":["string","number"],enum:r.filter(s=>typeof s=="string"||typeof s=="number")}}o(Zu,"parseNativeEnumDef");function Bu(){return{not:{}}}o(Bu,"parseNeverDef");function Au(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}o(Au,"parseNullDef");var qn={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function Cu(t,e){if(e.target==="openApi3")return Hs(t,e);let n=t.options instanceof Map?Array.from(t.options.values()):t.options;if(n.every(r=>r._def.typeName in qn&&(!r._def.checks||!r._def.checks.length))){let r=n.reduce((i,s)=>{let a=qn[s._def.typeName];return a&&!i.includes(a)?[...i,a]:i},[]);return{type:r.length>1?r:r[0]}}else if(n.every(r=>r._def.typeName==="ZodLiteral"&&!r.description)){let r=n.reduce((i,s)=>{let a=typeof s._def.value;switch(a){case"string":case"number":case"boolean":return[...i,a];case"bigint":return[...i,"integer"];case"object":if(s._def.value===null)return[...i,"null"];case"symbol":case"undefined":case"function":default:return i}},[]);if(r.length===n.length){let i=r.filter((s,a,l)=>l.indexOf(s)===a);return{type:i.length>1?i:i[0],enum:n.reduce((s,a)=>s.includes(a._def.value)?s:[...s,a._def.value],[])}}}else if(n.every(r=>r._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((r,i)=>[...r,...i._def.values.filter(s=>!r.includes(s))],[])};return Hs(t,e)}o(Cu,"parseUnionDef");var Hs=o((t,e)=>{let n=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((i,s)=>A(i._def,f(u({},e),{currentPath:[...e.currentPath,e.unionStrategy,`${s}`]}))).filter(i=>!!i&&(!e.strictUnions||typeof i=="object"&&Object.keys(i).length>0)),r=e.discriminator&&t.typeName==="ZodDiscriminatedUnion"&&typeof t.discriminator=="string"?{discriminator:{propertyName:t.discriminator}}:{};if(n.length)return e.unionStrategy==="anyOf"?u({anyOf:n},r):u({oneOf:n},r)},"asUnionOf");function Ru(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length)){let r=t.innerType;if(e.target==="openApi3"){let s={type:qn[r._def.typeName],nullable:!0};return ti(r._def,e,s)}let i={type:[qn[r._def.typeName],"null"]};return ti(r._def,e,i)}if(e.target==="openApi3"){let r=A(t.innerType._def,f(u({},e),{currentPath:[...e.currentPath]}));return r&&f(u({},r),{nullable:!0})}let n=A(t.innerType._def,f(u({},e),{currentPath:[...e.currentPath,"anyOf","0"]}));return n&&{anyOf:[n,{type:"null"}]}}o(Ru,"parseNullableDef");function Du(t,e){let n=u({type:"number"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return n;for(let r of t.checks)switch(r.kind){case"int":n.type="integer",mi(n,"type",r.message,e);break;case"min":e.target==="jsonSchema7"?r.inclusive?D(n,"minimum",r.value,r.message,e):D(n,"exclusiveMinimum",r.value,r.message,e):(r.inclusive||(n.exclusiveMinimum=!0),D(n,"minimum",r.value,r.message,e));break;case"max":e.target==="jsonSchema7"?r.inclusive?D(n,"maximum",r.value,r.message,e):D(n,"exclusiveMaximum",r.value,r.message,e):(r.inclusive||(n.exclusiveMaximum=!0),D(n,"maximum",r.value,r.message,e));break;case"multipleOf":D(n,"multipleOf",r.value,r.message,e);break}return n}o(Du,"parseNumberDef");var ay=o((t,e)=>{var n;return t.unknownKeys instanceof O?(n=A(t.unknownKeys._def,f(u({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?n:!0:t.unknownKeys==="passthrough"},"getAdditionalProperties");function Hu(t,e){let n=f(u({type:"object"},Object.entries(t.shape()).reduce((r,[i,s])=>{if(s===void 0||s._def===void 0)return r;let a=A(s._def,f(u({},e),{currentPath:[...e.currentPath,"properties",i],propertyPath:[...e.currentPath,"properties",i]}));return a===void 0?r:{properties:f(u({},r.properties),{[i]:a}),required:s.isOptional()?r.required:[...r.required,i]}},{properties:{},required:[]})),{additionalProperties:ay(t,e)});return n.required.length||delete n.required,n}o(Hu,"parseObjectDef");var oy=o((t,e)=>{var n;if(e.currentPath.toString()===((n=e.propertyPath)==null?void 0:n.toString()))return A(t.innerType._def,e);let r=A(t.innerType._def,f(u({},e),{currentPath:[...e.currentPath,"anyOf","1"]}));return r?{anyOf:[{not:{}},r]}:{}},"parseOptionalDef"),ly=o((t,e)=>{if(e.pipeStrategy==="input")return A(t.in._def,e);if(e.pipeStrategy==="output")return A(t.out._def,e);let n=A(t.in._def,f(u({},e),{currentPath:[...e.currentPath,"allOf","0"]})),r=A(t.out._def,f(u({},e),{currentPath:[...e.currentPath,"allOf",n?"1":"0"]}));return{allOf:[n,r].filter(i=>i!==void 0)}},"parsePipelineDef");function Nu(t,e){return A(t.type._def,e)}o(Nu,"parsePromiseDef");function Mu(t,e){let r={type:"array",uniqueItems:!0,items:A(t.valueType._def,f(u({},e),{currentPath:[...e.currentPath,"items"]}))};return t.minSize&&D(r,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&D(r,"maxItems",t.maxSize.value,t.maxSize.message,e),r}o(Mu,"parseSetDef");function $u(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((n,r)=>A(n._def,f(u({},e),{currentPath:[...e.currentPath,"items",`${r}`]}))).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:A(t.rest._def,f(u({},e),{currentPath:[...e.currentPath,"additionalItems"]}))}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((n,r)=>A(n._def,f(u({},e),{currentPath:[...e.currentPath,"items",`${r}`]}))).reduce((n,r)=>r===void 0?n:[...n,r],[])}}o($u,"parseTupleDef");function ju(){return{not:{}}}o(ju,"parseUndefinedDef");function Ku(){return{}}o(Ku,"parseUnknownDef");var cy=o((t,e)=>A(t.innerType._def,e),"parseReadonlyDef");function Uu(t){return{$ref:t.uri}}o(Uu,"parseRefDef");function A(t,e,n=!1){let r=e.seen.get(t);if(r&&!n){let a=uy(r,e);if(a!==void 0)return a}let i={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,i);let s=py(t,t.typeName,e);return s&&ti(t,e,s),i.jsonSchema=s,s}o(A,"parseDef");var uy=o((t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:dy(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((n,r)=>e.currentPath[r]===n)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),{}):e.$refStrategy==="seen"?{}:void 0}},"get$ref"),dy=o((t,e)=>{let n=0;for(;n<t.length&&n<e.length&&t[n]===e[n];n++);return[(t.length-n).toString(),...e.slice(n)].join("/")},"getRelativePath"),py=o((t,e,n)=>{switch(e){case"ZodString":return hi(t,n);case"ZodNumber":return Du(t,n);case"ZodObject":return Hu(t,n);case"ZodBigInt":return Tu(t,n);case"ZodBoolean":return bu(t);case"ZodDate":return Pu(t,n);case"ZodUndefined":return ju();case"ZodNull":return Au(n);case"ZodArray":return _u(t,n);case"ZodUnion":case"ZodDiscriminatedUnion":return Cu(t,n);case"ZodIntersection":return Eu(t,n);case"ZodTuple":return $u(t,n);case"ZodRecord":return Ui(t,n);case"ZodRef":return Uu(t);case"ZodLiteral":return Ou(t,n);case"ZodEnum":return Su(t);case"ZodNativeEnum":return Zu(t);case"ZodNullable":return Ru(t,n);case"ZodOptional":return oy(t,n);case"ZodMap":return Iu(t,n);case"ZodSet":return Mu(t,n);case"ZodLazy":return A(t.getter()._def,n);case"ZodPromise":return Nu(t,n);case"ZodNaN":case"ZodNever":return Bu();case"ZodEffects":return ku(t,n);case"ZodAny":return vu();case"ZodUnknown":return Ku();case"ZodDefault":return xu(t,n);case"ZodBranded":return wu(t,n);case"ZodReadonly":return cy(t,n);case"ZodCatch":return ry(t,n);case"ZodPipeline":return ly(t,n);case"ZodFunction":case"ZodVoid":case"ZodSymbol":return;default:return(r=>{})(e)}},"selectParser"),ti=o((t,e,n)=>(t.description&&(n.description=t.description,e.markdownDescription&&(n.markdownDescription=t.description)),Object.assign(n,{[w]:u(u({},t[w]),n[w])}),n),"addMeta"),Ns={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"},fy=o(t=>typeof t=="string"?f(u({},Ns),{name:t}):u(u({},Ns),t),"getDefaultOptions"),gy=o(t=>{let e=fy(t),n=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return f(u({},e),{currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([r,i])=>[i._def,{def:i._def,path:[...e.basePath,e.definitionPath,r],jsonSchema:void 0}]))})},"getRefs"),my=o((t,e)=>{var n;let r=gy(e),i=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[d,g])=>{var m;return f(u({},c),{[d]:(m=A(g._def,f(u({},r),{currentPath:[...r.basePath,r.definitionPath,d]}),!0))!=null?m:{}})},{}):void 0,s=typeof e=="string"?e:e?.name,a=(n=A(t._def,s===void 0?r:f(u({},r),{currentPath:[...r.basePath,r.definitionPath,s]}),!1))!=null?n:{},l=s===void 0?i?f(u({},a),{[r.definitionPath]:i}):a:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,s].join("/"),[r.definitionPath]:f(u({},i),{[s]:a})};return r.target==="jsonSchema7"?l.$schema="http://json-schema.org/draft-07/schema#":r.target==="jsonSchema2019-09"&&(l.$schema="https://json-schema.org/draft/2019-09/schema#"),l},"zodToJsonSchema"),hy=o((t,e={target:"openApi3"})=>{let n=my(t,e);return e.$schemaUrl===!1?delete n.$schema:typeof e.$schemaUrl=="string"&&(n.$schema=e.$schemaUrl),n},"toJSONSchemaLegacy");var vt=(t,e)=>{let n=t._def,r=e._def;if(n.typeName===y.ZodFirstPartyTypeKind.ZodObject&&r.typeName===y.ZodFirstPartyTypeKind.ZodObject){let i=n.shape(),s=r.shape();return y.object({...i,...s})}if(n.typeName===y.ZodFirstPartyTypeKind.ZodRecord&&r.typeName===y.ZodFirstPartyTypeKind.ZodRecord)return y.record(y.intersection(n.valueType,r.valueType));throw new Error("Cannot merge object schemas with record schemas")},Fu=y;var re=y.string().min(1),Wu=y.object({text:re}),Lu=y.object({markdown:re}),Vu=y.object({imageUrl:re}),qu=y.object({audioUrl:re}),Gu=y.object({videoUrl:re}),Ju=y.object({fileUrl:re,title:re.optional()}),Yu=y.object({latitude:y.number(),longitude:y.number(),address:y.string().optional(),title:y.string().optional()}),Xu=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}))}),zu=y.object({text:re,options:y.array(y.object({label:re,value:re}))}),yy=y.object({items:y.array(Xu)}),Qu=y.union([y.object({type:y.literal("text"),payload:Wu}),y.object({type:y.literal("image"),payload:Vu}),y.object({type:y.literal("audio"),payload:qu}),y.object({type:y.literal("video"),payload:Gu}),y.object({type:y.literal("file"),payload:Ju}),y.object({type:y.literal("location"),payload:Yu})]),vy=y.object({items:y.array(Qu)}),_y={schema:Lu},Ty={schema:y.object({items:y.array(y.union([...Qu.options,y.object({type:y.literal("markdown"),payload:Lu})]))})},by={text:{schema:Wu},image:{schema:Vu},audio:{schema:qu},video:{schema:Gu},file:{schema:Ju},location:{schema:Yu},carousel:{schema:yy},card:{schema:Xu},dropdown:{schema:zu},choice:{schema:zu},bloc:{schema:vy}};var wy={HIDDEN_IN_STUDIO:{bpActionHiddenInStudio:"true"},AWAIT_RETURN:{bpActionAwaitReturn:"true"}};var ed=require("browser-or-node");var zi=console;function ce(t){if(!t.body)throw new Error("Missing body");return JSON.parse(t.body)}async function Qt(t,e=8072,n=Sy){if(!ed.isNode)throw new Error("This function can only be called in Node.js");let i=require("http").createServer(async(s,a)=>{try{let l=await Py(s);if(l.path==="/health"){a.writeHead(200).end("ok");return}let c=await t(l);a.writeHead(c?.status??200,c?.headers??{}).end(c?.body??"{}")}catch(l){let c=l instanceof Error?l.message:String(l);zi.error("Error while handling request",{error:c??"Internal error occured"}),a.writeHead(500).end(JSON.stringify({error:c??"Internal error occured"}))}});return i.listen(e,()=>n(e)),i}async function Py(t){let e=await ky(t),n={};for(let i=0;i<t.rawHeaders.length;i+=2){let s=t.rawHeaders[i].toLowerCase(),a=t.rawHeaders[i+1];n[s]=a}let r=new URL(t.url??"",t.headers.host?`http://${t.headers.host}`:"http://botpress.cloud");return{body:e,path:r.pathname,query:xy(r.search,"?"),headers:n,method:t.method?.toUpperCase()??"GET"}}function xy(t,e){return t.indexOf(e)===0?t.slice(e.length):t}async function ky(t){return new Promise((e,n)=>{if(t.method!=="POST"&&t.method!=="PUT"&&t.method!=="PATCH")return e(void 0);let r="";t.on("data",i=>r+=i.toString()),t.on("error",i=>n(i)),t.on("end",()=>e(r))})}function Sy(t){zi.info(`Listening on port ${t}`)}var Cr=require("@botpress/client");var N={};nt(N,{mapKeys:()=>Iy,mapValues:()=>Oy,mergeRecords:()=>By,pairs:()=>_r,stripUndefinedProps:()=>Zy,values:()=>Ey});var _r=t=>Object.entries(t),Ey=t=>Object.values(t),Oy=(t,e)=>Object.fromEntries(_r(t).map(([n,r])=>[n,e(r,n)])),Iy=(t,e)=>Object.fromEntries(_r(t).map(([n,r])=>[e(n),r])),Zy=t=>Object.fromEntries(_r(t).filter(([,e])=>e!==void 0)),By=(t,e,n)=>{let r=[...Object.keys(t),...Object.keys(e)],i=[...new Set(r)],s={};for(let a of i){let l=t[a],c=e[a];l&&c?s[a]=n(l,c):l?s[a]=l:c&&(s[a]=c)}return s};var E={};nt(E,{safePush:()=>Ay,unique:()=>Cy});var Ay=(t,...e)=>t?[...t,...e]:[...e],Cy=t=>Array.from(new Set(t));var Y={};nt(Y,{setName:()=>Ry});var Ry=(t,e)=>(Object.defineProperty(t,"name",{value:e}),t);var td=t=>{let{name:e,version:n}=t,r={actions:{},events:{},channels:{}},i={name:e,version:n,entities:N.mapValues(t.entities,a=>({name:a.name})),actions:{},events:{},channels:{}},s=N.mapValues(t.entities,a=>a.schema);for(let[a,l]of Object.entries(t.definition.actions??{})){let c=l.input.schema.dereference(s),d=l.output.schema.dereference(s),g=t.actions?.[a]?.name??a;r.actions[g]={...l,...t.actions?.[a]??{},input:{schema:c},output:{schema:d}},i.actions[a]={name:g}}for(let[a,l]of Object.entries(t.definition.events??{})){let c=l.schema.dereference(s),d=t.events?.[a]?.name??a;r.events[d]={...l,...t.events?.[a]??{},schema:c},i.events[a]={name:d}}for(let[a,l]of Object.entries(t.definition.channels??{})){let c={};for(let[g,m]of Object.entries(l.messages)){let T=m.schema.dereference(s);c[g]={...m,schema:T}}let d=t.channels?.[a]?.name??a;r.channels[d]={...l,...t.channels?.[a]??{},message:{...l.message??{},tags:{...l.message?.tags??{},...t.channels?.[a]?.message?.tags??{}}},conversation:{...l.conversation??{},tags:{...l.conversation?.tags??{},...t.channels?.[a]?.conversation?.tags??{}}},messages:c},i.channels[a]={name:d}}return{resolved:r,statement:i}};var nd="5.0.0";var Ce=nd;var Tr=Symbol("schemaName"),rd=t=>t?N.mapValues(t,(n,r)=>({...n,[Tr]:r})):{},id=t=>Tr in t&&t[Tr]!==void 0,sd=t=>t[Tr];var br=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;get metadata(){return{sdkVersion:Ce}}extend(e,n){let{entities:r,actions:i,events:s,channels:a}=this._callBuilder(e,n),l=this;l.interfaces??={};let c=Object.values(r).map(T=>T.name),d=c.length===0?e.name:`${e.name}<${c.join(",")}>`,{resolved:g,statement:m}=td({...e,entities:r,actions:N.stripUndefinedProps(i),events:N.stripUndefinedProps(s),channels:N.stripUndefinedProps(a)});return l.actions=N.mergeRecords(l.actions??{},g.actions,this._mergeActions),l.channels=N.mergeRecords(l.channels??{},g.channels,this._mergeChannels),l.events=N.mergeRecords(l.events??{},g.events,this._mergeEvents),l.interfaces[d]={id:e.id,...m},this}_callBuilder(e,n){let i={entities:rd(this.entities)},s=n(i),a=N.pairs(s.entities).find(([c,d])=>!id(d));if(a)throw new Error(`Cannot extend interface "${e.name}" with entity "${a[0]}"; the provided schema is not part of the integration's entities.`);return{entities:N.mapValues(s.entities,c=>({name:sd(c),schema:c.schema})),actions:s.actions??{},events:s.events??{},channels:s.channels??{}}}_mergeActions=(e,n)=>({...e,...n,input:{schema:vt(e.input.schema,n.input.schema)},output:{schema:vt(e.output.schema,n.output.schema)}});_mergeEvents=(e,n)=>({...e,...n,schema:vt(e.schema,n.schema)});_mergeChannels=(e,n)=>{let r=N.mergeRecords(e.messages,n.messages,this._mergeMessage),i;(e.conversation||n.conversation)&&(i={tags:{...e.conversation?.tags,...n.conversation?.tags}});let s;return(e.message||n.message)&&(s={tags:{...e.message?.tags,...n.message?.tags}}),{...e,...n,messages:r,conversation:i,message:s}};_mergeMessage=(e,n)=>({schema:vt(e.schema,n.schema)})};var Ee=require("@botpress/client");var ad=Dr(require("@botpress/client")),wr={retries:3,retryCondition:t=>ad.axiosRetry.isNetworkOrIdempotentRequestError(t)||[429,502].includes(t.response?.status??0),retryDelay:(t,e)=>(Hy(e.response?.headers??{})??t)*1e3},Hy=t=>{let e=["RateLimit-Reset","X-RateLimit-Reset","Retry-After","ratelimit-reset","x-ratelimit-reset","retry-after"];for(let n of e){let r=t[n];if(r!==void 0)return Ny(String(r))}},Ny=t=>{let e=My(t)?$y(t):t.length>0?parseInt(t,10):void 0;return e===void 0||isNaN(e)?void 0:e},My=t=>t.includes(" "),$y=t=>{let e=jy(t);if(!e)return;let n=new Date;return Math.max(0,Math.floor((e.getTime()-n.getTime())/1e3))},jy=t=>{let e=new Date(t);return isNaN(e.getTime())?void 0:e};var _t=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(n=>n));updateMessage=(e=>this._client.updateMessage(e).then(n=>n));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 Pr=class{_cost=0;get cost(){return this._cost}setCost(e){this._cost=e}toJSON(){return{cost:this.cost}}};var fe="#",xr="x-bot-id",od="x-bot-user-id",ld="x-integration-id",cd="x-integration-alias",ud="x-webhook-id",dd="x-bp-configuration-type",kr="x-bp-configuration",Sr="x-bp-operation",pd="x-bp-type";var ue=t=>{throw t instanceof Error?t:new Error(t)};var f_=y.enum(["webhook_received","message_created","action_triggered","register","unregister","ping","create_user","create_conversation"]),fd=t=>({botId:t[xr]||ue("Missing bot header"),botUserId:t[od]||ue("Missing bot user header"),integrationId:t[ld]||ue("Missing integration header"),integrationAlias:t[cd]||ue("Missing integration alias header"),webhookId:t[ud]||ue("Missing webhook header"),operation:t[Sr]||ue("Missing operation header"),configurationType:t[dd]??null,configuration:JSON.parse(Buffer.from(t[kr]||ue("Missing configuration header"),"base64").toString("utf-8"))});var gd=Dr(require("util")),Tt=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,n){this._getConsoleMethod(e)(this._serializeMessage(n))}_serializeMessage(e){let n=gd.default.format(...e);return process.env.BP_LOG_FORMAT==="json"?this.getJsonMessage(n):n}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 bt=class t extends Tt{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,n)=>(t[n]&&(e[n]=t[n]),e),{}),Uy=(t,e,n)=>{let[,r]=(e.headers.traceparent||"").split("-"),i=new Ee.Client({botId:t.botId,integrationId:t.integrationId,integrationAlias:t.integrationAlias,retry:wr,headers:Ky(e.headers)}),s=new _t(i),a=new bt({traceId:r});return{ctx:t,req:e,client:s,logger:a,instance:n}},Fy=async t=>{let{ctx:e}=t;switch(e.operation){case"webhook_received":return await Wy(t);case"register":return await Ly(t);case"unregister":return await Vy(t);case"message_created":return await Jy(t);case"action_triggered":return await Yy(t);case"ping":return await zy(t);case"create_user":return await qy(t);case"create_conversation":return await Gy(t);default:throw new Ee.InvalidPayloadError(`Unknown operation ${e.operation}`)}},md=t=>async e=>{let n=fd(e.headers),r=Uy(n,e,t),{logger:i}=r;try{let s;return s=await Xy(r),s?{...s,status:s.status??200}:(s=await Fy(r),s?{...s,status:s.status??200}:{status:200})}catch(s){if((0,Ee.isApiError)(s)){let l=s.type==="Runtime"?s:new Ee.RuntimeError(s.message,s);return i.forBot().error(l.message),{status:l.code,body:JSON.stringify(l.toJSON())}}console.error(s);let a=new Ee.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 i.forBot().error(a.message),{status:a.code,body:JSON.stringify(a.toJSON())}}},zy=async t=>{},Wy=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{let{req:s}=ce(n);return i.webhook({client:t,ctx:e,req:s,logger:r})},Ly=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{if(!i.register)return;let{webhookUrl:s}=ce(n);await i.register({client:t,ctx:e,webhookUrl:s,logger:r})},Vy=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{if(!i.unregister)return;let{webhookUrl:s}=ce(n);await i.unregister({ctx:e,webhookUrl:s,client:t,logger:r})},qy=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{if(!i.createUser)return;let{tags:s}=ce(n);return await i.createUser({ctx:e,client:t,tags:s,logger:r})},Gy=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{if(!i.createConversation)return;let{channel:s,tags:a}=ce(n);return await i.createConversation({ctx:e,client:t,channel:s,tags:a,logger:r})},Jy=async({ctx:t,req:e,client:n,logger:r,instance:i})=>{let{conversation:s,user:a,type:l,payload:c,message:d}=ce(e),g=i.channels[s.channel];if(!g)throw new Error(`Channel ${s.channel} not found`);let m=g.messages[l];if(!m)throw new Error(`Message of type ${l} not found in channel ${s.channel}`);await m({ctx:t,conversation:s,message:d,user:a,type:l,client:n,payload:c,ack:async({tags:I})=>{await n.updateMessage({id:d.id,tags:I})},logger:r})},Yy=async({req:t,ctx:e,client:n,logger:r,instance:i})=>{let{input:s,type:a}=ce(t);if(!a)throw new Error("Missing action type");let l=i.actions[a];if(!l)throw new Error(`Action ${a} not found`);let c=new Pr,g={output:await l({ctx:e,input:s,client:n,type:a,logger:r,metadata:c}),meta:c.toJSON()};return{body:JSON.stringify(g)}},Xy=async({instance:t,client:e,ctx:n,logger:r,req:i})=>{let s=t.unknownOperationHandler;if(s)return await s({client:e,ctx:n,logger:r,req:i})};var Er=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=md(this);start=e=>Qt(this.handler,e)};var Or=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.__advanced=e.__advanced,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;__advanced;withPlugins;get metadata(){return{sdkVersion:Ce}}addIntegration(e,n){let r=this;r.integrations||(r.integrations={});let i=n?.alias??e.name;if(r.integrations[i])throw new Error(`Another integration with alias "${i}" is already installed in the bot`);return r.integrations[i]={...e,alias:i,enabled:n?.enabled,configurationType:n&&"configurationType"in n?n.configurationType:void 0,configuration:n&&"configuration"in n?n.configuration??{}:{},disabledChannels:n?.disabledChannels},this}addPlugin(e,n){let r=this;r.plugins||(r.plugins={});let i=n.alias??e.name;if(r.plugins[i])throw new Error(`Another plugin with alias "${i}" is already installed in the bot`);let s=Object.fromEntries(Object.entries(n.dependencies??{}).filter(([l,c])=>"integrationInterfaceAlias"in c).map(([l,c])=>{let d=this.integrations?.[c.integrationAlias];if(!d){let m=Object.keys(this.integrations??{}).join(", ")||"(none)";throw new Error(`Interface with alias "${l}" of plugin with alias "${i}" references integration with alias "${c.integrationAlias}" which is not installed. Please make sure to add the integration via addIntegration() before calling addPlugin().
73
+ Available integration aliases: ${m}`)}let g=d.definition.interfaces?.[c.integrationInterfaceAlias];if(!g){let m=Object.keys(d.definition.interfaces??{}).join(", ")||"(none)";throw new Error(`Interface with alias "${c.integrationInterfaceAlias}" does not exist in integration "${d.name}" referenced by interface with alias "${l}" of plugin with alias "${i}".
74
+ Available interface aliases: ${m}`)}return[l,{...g,id:d.id,name:d.name,version:d.version,...c}]})),a=Object.fromEntries(Object.entries(n.dependencies??{}).filter(([l,c])=>!("integrationInterfaceAlias"in c)).map(([l,c])=>{let d=this.integrations?.[c.integrationAlias];if(!d){let g=Object.keys(this.integrations??{}).join(", ")||"(none)";throw new Error(`Integration with alias "${l}" of plugin with alias "${i}" references integration with alias "${c.integrationAlias}" which is not installed. Please make sure to add the integration via addIntegration() before calling addPlugin().
75
+ Available integration aliases: ${g}`)}return[l,{...d,...c}]}));return r.plugins[i]={...e,alias:i,configuration:n.configuration??{},interfaces:s,integrations:a},r.withPlugins.user=this._mergeUser(r.withPlugins.user,e.definition.user),r.withPlugins.conversation=this._mergeConversation(r.withPlugins.conversation,e.definition.conversation),r.withPlugins.message=this._mergeMessage(r.withPlugins.message,e.definition.message),r.withPlugins.recurringEvents=this._mergeRecurringEvents(r.withPlugins.recurringEvents,e.definition.recurringEvents),r.withPlugins.tables=this._mergeTables(r.withPlugins.tables,e.definition.tables),r.withPlugins.workflows=this._mergeWorkflows(r.withPlugins.workflows,e.definition.workflows),r.withPlugins.states=this._mergeStates(r.withPlugins.states,this._prefixKeysWithPluginAlias(e.definition.states,i)),r.withPlugins.events=this._mergeEvents(r.withPlugins.events,this._prefixKeysWithPluginAlias(e.definition.events,i)),r.withPlugins.actions=this._mergeActions(r.withPlugins.actions,this._prefixKeysWithPluginAlias(e.definition.actions,i)),this}_mergeUser=(e,n)=>({tags:{...e?.tags,...n?.tags}});_mergeConversation=(e,n)=>({tags:{...e?.tags,...n?.tags}});_mergeMessage=(e,n)=>({tags:{...e?.tags,...n?.tags}});_mergeStates=(e,n)=>({...e,...n});_mergeEvents=(e,n)=>({...e,...n});_mergeRecurringEvents=(e,n)=>({...e,...n});_mergeActions=(e,n)=>({...e,...n});_mergeTables=(e,n)=>({...e,...n});_mergeWorkflows=(e,n)=>({...e,...n});_prefixKeysWithPluginAlias=(e,n)=>N.mapKeys(e??{},r=>`${n}${fe}${r}`);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(([n,r])=>[n,{...r,definition:{...r.definition,configuration:this._dereferenceDefinitionSchema(r.definition.configuration,e),events:this._dereferenceDefinitionSchemas(r.definition.events,e),states:this._dereferenceDefinitionSchemas(r.definition.states,e),tables:this._dereferenceDefinitionSchemas(r.definition.tables,e),actions:this._dereferenceActionDefinitionSchemas(r.definition.actions,e)}}]))}}_buildZuiReferenceMap(){let e={},n=Object.entries(this.plugins??{});for(let[r,i]of n){let s=Object.entries(i.interfaces??{});for(let[a,l]of s){let c=this.integrations?.[l.integrationAlias];if(!c)throw new Error(`Interface with alias "${a}" of plugin with alias "${r}" references integration "${l.name}" which is not installed`);let d=Object.entries(l.entities??{});for(let[g,{name:m}]of d){let T=c.definition.entities?.[m]?.schema;if(!T)throw new Error(`Interface entity "${m}" does not exist in integration "${c.name}"`);e[`interface:${a}/entities/${g}`]=T}}}return e}_dereferenceZuiSchema(e,n){return e.dereference(n)}_dereferenceDefinitionSchemas(e,n){return Object.fromEntries(Object.entries(e??{}).map(([r,i])=>[r,this._dereferenceDefinitionSchema(i,n)]))}_dereferenceDefinitionSchema(e,n){return e&&{...e,schema:this._dereferenceZuiSchema(e.schema,n)}}_dereferenceActionDefinitionSchemas(e,n){return Object.fromEntries(Object.entries(e??{}).map(([r,i])=>[r,{...i,input:{schema:this._dereferenceZuiSchema(i.input.schema,n)},output:{schema:this._dereferenceZuiSchema(i.output.schema,n)}}]))}};var tt=require("@botpress/client");var wt=class t extends Tt{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 ye=class{constructor(e,n={before:{},after:{}}){this._client=e;this._hooks=n}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));getOrCreateWorkflow=(e=>this._run("getOrCreateWorkflow",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,n)=>{let r=this._hooks.before[e];r&&(n=await r(n));let i=await this._client[e](n),s=this._hooks.after[e];return s&&(i=await s(i,n)),i}};var Qy=y.enum(["event_received","register","unregister","ping","action_triggered"]),hd=t=>({botId:t[xr]||ue("Missing bot id header"),operation:Qy.parse(t[Sr]),type:t[pd]||ue("Missing type header"),configuration:JSON.parse(Buffer.from(t[kr]||ue("Missing configuration header"),"base64").toString("utf-8"))});var X={status:200};var Li=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 ev=["child_workflow_deleted","child_workflow_finished","workflow_timedout","workflow_started","workflow_continued"],yd=async(t,e)=>{if(t.ctx.type!=="workflow_update"||!ev.includes(e.payload.type))throw new Error("Unexpected event type");let n={...t,logger:tv(t,e)};if(!e.payload.workflow.name)return n.logger.warn("Received workflow update event without a workflow name. Assuming this workflow was not defined by the bot.",e.payload.workflow),X;switch(e.payload.type){case"child_workflow_deleted":case"child_workflow_finished":n.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 nv(n,e);default:e.payload.type}return X},tv=(t,e)=>t.logger.with({eventId:e.id,workflowId:e.payload.workflow.id,conversationId:e.payload.conversation?.id,userId:e.payload.user?.id}),nv=async(t,e)=>{let n=Li(e.payload.type),r=t.self.workflowHandlers[n]?.[e.payload.workflow.name];if(!r||r.length===0)return t.logger.warn(`No ${n} handler found for workflow "${e.payload.workflow.name}"`),X;let{updatedWorkflow:i}=await rv(t,e);return i.status==="pending"&&t.logger.warn(`Workflow "${e.payload.workflow.name}" is still in pending status after processing "${n}" event. This may indicate that the workflow was not properly acknowledged or terminated by the handler. `),X},rv=async(t,e)=>{let n=Li(e.payload.type),r=t.self.workflowHandlers[n]?.[e.payload.workflow.name],i=structuredClone(e.payload.workflow);for(let s of r??[])i=await s({...t,event:e,conversation:e.payload.conversation,user:e.payload.user,workflow:i});return{updatedWorkflow:i}};var vd=t=>async e=>{let n=hd(e.headers),r=new wt,i=new tt.Client({botId:n.botId,retry:wr}),s=new ye(i,{before:{createMessage:async l=>{let c=t.hookHandlers.before_outgoing_message[l.type]??[];for(let d of c){let g=new ye(i);l=(await d({client:g,ctx:n,logger:r.with({conversationId:l.conversationId,userId:l.userId}),data:l}))?.data??l}return l},callAction:async l=>{let c=t.hookHandlers.before_outgoing_call_action[l.type]??[];for(let d of c){let g=new ye(i);l=(await d({client:g,ctx:n,logger:r,data:l}))?.data??l}return l}},after:{createMessage:async l=>{let c=t.hookHandlers.after_outgoing_message[l.message.type]??[];for(let d of c){let g=new ye(i);l=(await d({client:g,ctx:n,logger:r.with({messageId:l.message.id,conversationId:l.message.conversationId,userId:l.message.userId}),data:l}))?.data??l}return l},callAction:async(l,c)=>{let{type:d}=c,g=t.hookHandlers.after_outgoing_call_action[d]??[];for(let m of g){let T=new ye(i);l=(await m({client:T,ctx:n,logger:r,data:{type:d,...l}}))?.data??l}return l}}}),a={req:e,ctx:n,logger:r,client:s,self:t};try{switch(n.operation){case"action_triggered":return await lv(a);case"event_received":return await ov(a);case"register":return await sv(a);case"unregister":return await av(a);case"ping":return await iv(a);default:throw new Error(`Unknown operation ${n.operation}`)}}catch(l){let c=l instanceof Error?l:new Error(String(l));if((0,tt.isApiError)(c)){let g=c.type==="Runtime"?c:new tt.RuntimeError(c.message,c);return r.error(g.message),{status:g.code,body:JSON.stringify(g.toJSON())}}let d=new tt.RuntimeError("An unexpected error occurred in the bot.",c);return r.error(d.message,c),{status:d.code,body:JSON.stringify(d.toJSON())}}},iv=async t=>X,sv=async t=>X,av=async t=>X,ov=async t=>{let{ctx:e,logger:n,req:r,client:i,self:s}=t,a={client:i,ctx:e,logger:n},l=ce(r);if(a.logger=a.logger.with({eventId:l.event.id,messageId:l.event.messageId,conversationId:l.event.conversationId,userId:l.event.userId}),e.type==="workflow_update")return await yd(t,l.event);if(e.type==="message_created"){let I=l.event,k=I.payload.message;a.logger=a.logger.with({messageId:k.id,conversationId:k.conversationId,userId:k.userId});let K=s.hookHandlers.before_incoming_message[k.type]??[];for(let me of K){let oe=await me({...a,data:k});if(k=oe?.data??k,oe?.stop)return X}let z={...a,user:I.payload.user,conversation:I.payload.conversation,message:k,event:I},Q=s.messageHandlers[k.type]??[];for(let me of Q)await me(z);let ae=s.hookHandlers.after_incoming_message[k.type]??[];for(let me of ae){let oe=await me({...a,data:k});if(k=oe?.data??k,oe?.stop)return X}return X}if(e.type==="state_expired"){let k=l.event.payload.state,K={...a,state:k},z=s.stateExpiredHandlers[k.name]??[];for(let Q of z)await Q(K);return X}let c=l.event,d=s.hookHandlers.before_incoming_event[c.type]??[];for(let I of d){let k=await I({...a,data:c});if(c=k?.data??c,k?.stop)return X}let g={...a,event:c},m=s.eventHandlers[c.type]??[];for(let I of m)await I(g);let T=s.hookHandlers.after_incoming_event[c.type]??[];for(let I of T){let k=await I({...a,data:c});if(c=k?.data??c,k?.stop)return X}return X},lv=async({ctx:t,logger:e,req:n,client:r,self:i})=>{let{input:s,type:a}=ce(n);if(!a)throw new Error("Missing action type");let l=i.hookHandlers.before_incoming_call_action[a]??[];for(let T of l){let I=await T({ctx:t,logger:e,client:r,data:{type:a,input:s}});s=I?.data?.input??s,a=I?.data?.type??a}let c=i.actionHandlers[a];if(!c)throw new Error(`Action ${a} not found`);let d=await c({ctx:t,logger:e,input:s,client:r,type:a}),g=i.hookHandlers.after_incoming_call_action[a]??[];for(let T of g){let I=await T({ctx:t,logger:e,client:r,data:{type:a,output:d}});a=I?.data?.type??a,d=I?.data?.output??d}return{status:200,body:JSON.stringify({output:d})}};var ve=(t,{alias:e})=>{if(!("tags"in t)||!e)return t;let n=`${e}${fe}`,r=Object.fromEntries(Object.entries(t.tags??{}).flatMap(([i,s])=>i.startsWith(n)?[[i.slice(n.length),s]]:[]));return{...t,tags:r}},ie=(t,{alias:e})=>{if(!("tags"in t)||!e)return t;let n=`${e}${fe}`,r=Object.fromEntries(Object.entries(t.tags??{}).map(([i,s])=>[i.startsWith(n)?i:`${n}${i}`,s]));return{...t,tags:r}};var Vi=class{constructor(e){this._list=e}_nextToken;_elementsBuffer=[];_isExhausted=!1;[Symbol.asyncIterator](){return this}async next(){return this._bufferIsEmpty&&!this._isExhausted&&await this._fetchNextPageIntoBuffer(),this._bufferIsEmpty?{done:!0,value:void 0}:{done:!1,value:this._elementsBuffer.shift()}}async take(e){let n=[];for(let r=0;r<e;++r){let i=await this.next();if(i.done)break;n.push(i.value)}return n}async takePage(e){for(let r=0;r<e;++r)this._isExhausted||await this._fetchNextPageIntoBuffer();let n=[...this._elementsBuffer];return this._elementsBuffer.length=0,n}async takeAll(){return this.take(Number.POSITIVE_INFINITY)}get isExhausted(){return this._isExhausted}async _fetchNextPageIntoBuffer(){let{items:e,meta:n}=await this._list({nextToken:this._nextToken});this._elementsBuffer.push(...e),this._nextToken=n.nextToken,n.nextToken||(this._isExhausted=!0)}get _bufferIsEmpty(){return this._elementsBuffer.length===0}},de=t=>new Vi(t);var Oe=t=>new Proxy({},{get:(e,n)=>({listInstances:r=>de(({nextToken:i})=>t.client.listWorkflows({...r,name:n,nextToken:i}).then(({meta:s,workflows:a})=>({meta:s,items:a.map(l=>pe({...t,workflow:l}))}))),startNewInstance:async r=>{let{workflow:i}=await t.client.createWorkflow({name:n,status:"pending",...r,tags:r.tags&&t.pluginAlias?ie(r.tags,{alias:t.pluginAlias}):void 0});return{workflow:pe({...t,workflow:i})}}})}),pe=t=>{let e=!1;return{...t.pluginAlias?ve(t.workflow,{alias:t.pluginAlias}):t.workflow,async update(n){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,...n,tags:n.tags&&t.pluginAlias?ie(n.tags,{alias:t.pluginAlias}):void 0});return await t.onWorkflowUpdate?.(r),{workflow:pe({...t,workflow:r})}},async acknowledgeStartOfProcessing(){if(!t.event||t.workflow.status!=="pending"||e)return{workflow:pe(t)};let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,status:"in_progress",eventId:t.event.id});return e=!0,await t.onWorkflowUpdate?.(n),{workflow:pe({...t,workflow:n})}},async setFailed({failureReason:n}){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,status:"failed",failureReason:n});return await t.onWorkflowUpdate?.(r),{workflow:pe({...t,workflow:r})}},async setCompleted({output:n}={}){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,status:"completed",output:n});return await t.onWorkflowUpdate?.(r),{workflow:pe({...t,workflow:r})}},async cancel(){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,status:"cancelled"});return await t.onWorkflowUpdate?.(n),{workflow:pe({...t,workflow:n})}}}};var Ir=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,n)=>{let r=this._actionHandlers[n];if(r)return Y.setName(i=>r({...i,workflows:Oe(i)}),r.name);for(let[i,s]of Object.entries(this._plugins)){let[a,l]=n.split(fe);if(!(a!==i||!l))return s.actionHandlers[l]}}})}get messageHandlers(){return new Proxy({},{get:(e,n)=>{let r=Object.values(this._plugins).flatMap(l=>l.messageHandlers[n]??[]),i=n==="*"?[]:this._messageHandlers[n]??[],s=this._messageHandlers["*"]??[],a=[...i,...s].sort((l,c)=>l.order-c.order).map(({handler:l})=>Y.setName(c=>l({...c,workflows:Oe(c)}),l.name));return E.unique([...r,...a])}})}get eventHandlers(){return new Proxy({},{get:(e,n)=>{let r=Object.values(this._plugins).flatMap(l=>l.eventHandlers[n]??[]),i=n==="*"?[]:this._eventHandlers[n]??[],s=this._eventHandlers["*"]??[],a=[...i,...s].sort((l,c)=>l.order-c.order).map(({handler:l})=>Y.setName(c=>l({...c,workflows:Oe(c)}),l.name));return E.unique([...r,...a])}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,n)=>{let r=Object.values(this._plugins).flatMap(l=>l.stateExpiredHandlers[n]??[]),i=n==="*"?[]:this._stateExpiredHandlers[n]??[],s=this._stateExpiredHandlers["*"]??[],a=[...i,...s].sort((l,c)=>l.order-c.order).map(({handler:l})=>Y.setName(c=>l({...c,workflows:Oe(c)}),l.name));return E.unique([...r,...a])}})}get hookHandlers(){return new Proxy({},{get:(e,n)=>{if(this._hookHandlers[n])return new Proxy({},{get:(i,s)=>{let a=Object.values(this._plugins).flatMap(m=>m.hookHandlers[n]?.[s]??[]),l=this._hookHandlers[n]??{},c=s==="*"?[]:l[s]??[],d=l["*"]??[],g=[...c,...d].sort((m,T)=>m.order-T.order).map(({handler:m})=>Y.setName(T=>m({...T,workflows:Oe(T)}),m.name));return E.unique([...a,...g])}})}})}get workflowHandlers(){return new Proxy({},{get:(e,n)=>{let r=this._workflowHandlers[n];if(r)return new Proxy({},{get:(i,s)=>{let a=r[s]?.sort((c,d)=>c.order-d.order).map(({handler:c})=>Y.setName(async d=>{let g=d.workflow;return await c({...d,workflow:pe({...d,onWorkflowUpdate(m){g=m}}),workflows:Oe(d)}),g},c.name))??[],l=Object.values(this._plugins).flatMap(c=>c.workflowHandlers[n]?.[s]??[]);return E.unique([...a,...l])}})}})}on={message:(e,n)=>{this._messageHandlers[e]=E.safePush(this._messageHandlers[e],{handler:n,order:this._registerOrder++})},event:(e,n)=>{this._eventHandlers[e]=E.safePush(this._eventHandlers[e],{handler:n,order:this._registerOrder++})},stateExpired:(e,n)=>{this._stateExpiredHandlers[e]=E.safePush(this._stateExpiredHandlers[e],{handler:n,order:this._registerOrder++})},beforeIncomingEvent:(e,n)=>{this._hookHandlers.before_incoming_event[e]=E.safePush(this._hookHandlers.before_incoming_event[e],{handler:n,order:this._registerOrder++})},beforeIncomingMessage:(e,n)=>{this._hookHandlers.before_incoming_message[e]=E.safePush(this._hookHandlers.before_incoming_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingMessage:(e,n)=>{this._hookHandlers.before_outgoing_message[e]=E.safePush(this._hookHandlers.before_outgoing_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingCallAction:(e,n)=>{this._hookHandlers.before_outgoing_call_action[e]=E.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},beforeIncomingCallAction:(e,n)=>{this._hookHandlers.before_incoming_call_action[e]=E.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingEvent:(e,n)=>{this._hookHandlers.after_incoming_event[e]=E.safePush(this._hookHandlers.after_incoming_event[e],{handler:n,order:this._registerOrder++})},afterIncomingMessage:(e,n)=>{this._hookHandlers.after_incoming_message[e]=E.safePush(this._hookHandlers.after_incoming_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingMessage:(e,n)=>{this._hookHandlers.after_outgoing_message[e]=E.safePush(this._hookHandlers.after_outgoing_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingCallAction:(e,n)=>{this._hookHandlers.after_outgoing_call_action[e]=E.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingCallAction:(e,n)=>{this._hookHandlers.after_incoming_call_action[e]=E.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:n,order:this._registerOrder++})},workflowStart:(e,n)=>{this._workflowHandlers.started[e]=E.safePush(this._workflowHandlers.started[e],{handler:n,order:this._registerOrder++})},workflowContinue:(e,n)=>{this._workflowHandlers.continued[e]=E.safePush(this._workflowHandlers.continued[e],{handler:n,order:this._registerOrder++})},workflowTimeout:(e,n)=>{this._workflowHandlers.timed_out[e]=E.safePush(this._workflowHandlers.timed_out[e],{handler:n,order:this._registerOrder++})}};handler=vd(this);start=e=>Qt(this.handler,e)};var Zr=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,this.__advanced=e.__advanced;let n=this._getEntityReference(this.entities),r=e.events===void 0?{}:N.mapValues(e.events,a=>({...a,schema:a.schema(n)})),i=e.actions===void 0?{}:N.mapValues(e.actions,a=>({...a,input:{...a.input,schema:a.input.schema(n)},output:{...a.output,schema:a.output.schema(n)}})),s=e.channels===void 0?{}:N.mapValues(e.channels,a=>({...a,messages:N.mapValues(a.messages,l=>({...l,schema:l.schema(n)}))}));this.events=r,this.actions=i,this.channels=s}name;version;title;description;icon;readme;attributes;entities;events;actions;channels;__advanced;get metadata(){return{sdkVersion:Ce}}_getEntityReference=e=>{let n={};for(let[r,i]of Object.entries(e)){let s=i.schema._def["x-zui"]?.title,a=i.schema._def.description,l=Fu.ref(r);s&&l.title(s),a&&l.describe(a),n[r]=l}return n}};var Br=class{constructor(e){this.props=e;let n=Object.fromEntries(Object.entries(e.interfaces??{}).map(([i,s])=>[i,Object.fromEntries(Object.entries(s.definition.entities??{}).map(([a])=>[a,y.ref(`interface:${i}/entities/${a}`)]))]));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.__advanced=e.__advanced;let r=new Set;for(let i of[...Object.keys(e.integrations??{}),...Object.keys(e.interfaces??{})]){if(r.has(i))throw new Error(`Duplicate interface or integration alias detected in plugin definition: '${i}'. Please use unique aliases for each interface and integration.`);r.add(i)}this.configuration=e.configuration?{...e.configuration,schema:typeof e.configuration.schema=="object"?e.configuration.schema:e.configuration.schema({entities:n})}:void 0,this.states=Object.fromEntries(Object.entries(e.states??{}).map(([i,s])=>[i,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:n})}])),this.events=Object.fromEntries(Object.entries(e.events??{}).map(([i,s])=>[i,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:n})}])),this.actions=Object.fromEntries(Object.entries(e.actions??{}).map(([i,s])=>[i,{...s,input:{...s.input,schema:typeof s.input.schema=="object"?s.input.schema:s.input.schema({entities:n})},output:{...s.output,schema:typeof s.output.schema=="object"?s.output.schema:s.output.schema({entities:n})}}])),this.tables=Object.fromEntries(Object.entries(e.tables??{}).map(([i,s])=>[i,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:n})}]))}name;version;title;description;icon;readme;attributes;integrations;interfaces;user;conversation;message;states;configuration;events;recurringEvents;actions;tables;workflows;__advanced;get metadata(){return{sdkVersion:Ce}}dereferenceEntities({intersectWithUnknownRecord:e}={intersectWithUnknownRecord:!0}){let n=this._buildZuiReferenceMap(e);return{...this,configuration:this.configuration?{...this.configuration,schema:this._dereferenceZuiSchema(this.configuration.schema,n)}:void 0,events:this._dereferenceDefinitionSchemas(this.events,n),states:this._dereferenceDefinitionSchemas(this.states,n),tables:this._dereferenceDefinitionSchemas(this.tables,n),actions:this._dereferenceActionDefinitionSchemas(this.actions,n)}}_buildZuiReferenceMap(e){return Object.fromEntries(Object.entries(this.interfaces??{}).flatMap(([n,r])=>Object.entries(r.definition.entities??{}).map(([i,s])=>[`interface:${n}/entities/${i}`,e?s.schema.and(y.record(y.string(),y.unknown())):s.schema])))}_dereferenceZuiSchema(e,n){return e.dereference(n)}_dereferenceDefinitionSchemas(e,n){return Object.fromEntries(Object.entries(e??{}).map(([r,i])=>[r,{...i,schema:this._dereferenceZuiSchema(i.schema,n)}]))}_dereferenceActionDefinitionSchemas(e,n){return Object.fromEntries(Object.entries(e??{}).map(([r,i])=>[r,{...i,input:{schema:this._dereferenceZuiSchema(i.input.schema,n)},output:{schema:this._dereferenceZuiSchema(i.output.schema,n)}}]))}};var _d=(t,e)=>new Proxy({},{get:(n,r)=>new Proxy({},{get:(i,s)=>a=>{let l=(e.integrations[r]??e.interfaces[r])?.integrationAlias,c=e.interfaces[r]?.actions?.[s]?.name??s;return t.callAction({type:`${l}:${c}`,input:a})}})});var qi=t=>({async getById({id:e}){let n=await t.client.getMessage({id:e});return ge({...t,message:n.message})},list(e){return de(({nextToken:n})=>t.client.listMessages({...ie(e??{},{alias:t.plugin?.alias}),nextToken:n}).then(({meta:r,messages:i})=>({meta:r,items:i.map(s=>ge({...t,message:s}))})))}}),ge=t=>({...ve(t.message,{alias:t.plugin?.alias}),async delete(){await t.client.deleteMessage({id:t.message.id})},async update(e){let{message:n}=await t.client.updateMessage({...ie(e,{alias:t.plugin?.alias}),id:t.message.id});return ge({...t,message:n})}});var Gi=t=>({list(e){return de(({nextToken:n})=>t.client.listUsers({...ie(e??{},{alias:t.pluginAlias}),nextToken:n}).then(({meta:r,users:i})=>({meta:r,items:i.map(s=>_e({...t,conversationId:e?.conversationId,user:s}))})))},async getById({id:e}){let n=await t.client.getUser({id:e});return _e({...t,user:n.user,conversationId:void 0})}}),_e=t=>{let e={...ve(t.user,{alias:t.pluginAlias}),async update(n){let{user:r}=await t.client.updateUser({...ie(n,{alias:t.pluginAlias}),id:t.user.id});return _e({...t,user:r})}};return t.conversationId?{...e,async removeFromConversation(){return await t.client.removeParticipant({id:t.conversationId,userId:t.user.id}),_e({...t,conversationId:void 0})}}:{...e,async addToConversation({conversationId:n}){let{participant:r}=await t.client.addParticipant({id:n,userId:t.user.id});return _e({...t,user:r,conversationId:n})}}};var Ji=t=>new Proxy({},{get:(e,n)=>new Proxy({},{get:(r,i)=>({list(s){let a=t.plugin?.interfaces[n]?.integrationAlias??t.plugin?.integrations[n]?.integrationAlias,l=t.plugin?.interfaces[n]?.channels?.[i]?.name??i;return de(({nextToken:c})=>t.client.listConversations({...ie(s??{},{alias:t.plugin?.alias}),channel:l,integrationName:a,nextToken:c}).then(({meta:d,conversations:g})=>({meta:d,items:g.map(m=>Pt({...t,conversation:m}))})))},async getById({id:s}){let a=await t.client.getConversation({id:s});return Pt({...t,conversation:a.conversation})}})})}),Pt=t=>{let e=t.client;return{...ve(t.conversation,{alias:t.plugin?.alias}),async delete(){await e.deleteConversation({id:t.conversation.id})},async update(n){let{conversation:r}=await e.updateConversation({...ie(n,{alias:t.plugin?.alias}),id:t.conversation.id});return Pt({...t,conversation:r})},async getMessage({id:n}){let r=await e.getMessage({id:n});return ge({...t,message:r.message})},async getOrCreateMessage(n){let{message:r}=await e.getOrCreateMessage({...ie(n,{alias:t.plugin?.alias}),conversationId:t.conversation.id});return ge({...t,message:r})},async createMessage(n){let{message:r}=await e.createMessage({...ie(n,{alias:t.plugin?.alias}),conversationId:t.conversation.id});return ge({...t,message:r})},listMessages(n){return de(({nextToken:r})=>e.listMessages({...ie(n??{},{alias:t.plugin?.alias}),conversationId:t.conversation.id,nextToken:r}).then(({meta:i,messages:s})=>({meta:i,items:s.map(a=>ge({...t,message:a}))})))},listParticipants(){return de(({nextToken:n})=>e.listParticipants({id:t.conversation.id,nextToken:n}).then(({meta:r,participants:i})=>({meta:r,items:i.map(s=>_e({...t,user:s,conversationId:t.conversation.id}))})))}}};var Yi=class t{constructor(e){this._props=e}async emit(e){let{conversationId:n,userId:r,messageId:i}=this._props,{event:s}=await this._props.client.createEvent({type:this._props.eventName,payload:e,conversationId:n,userId:r,messageId:i});return s}async schedule(e,n){let{conversationId:r,userId:i,messageId:s}=this._props,{event:a}=await this._props.client.createEvent({type:this._props.eventName,payload:e,conversationId:r,userId:i,messageId:s,schedule:n});return a}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})}async getById(e){return(await this._props.client.getEvent({id:e.id})).event}list(e){return de(({nextToken:n})=>this._props.client.listEvents({...e,type:this._props.eventName,conversationId:this._props.conversationId,userId:this._props.userId,messageId:this._props.messageId,nextToken:n}).then(({meta:r,events:i})=>({meta:r,items:i})))}},Td=(t,e)=>new Proxy({},{get:(n,r)=>{let i=e.alias!==void 0?`${e.alias}${fe}${r}`:r;return new Yi({client:t,eventName:i})}});var Xi=class{constructor(e,n,r){this._client=e;this._stateType=n;this._stateName=r}async get(e){return await this._client.getState({type:this._stateType,name:this._stateName,id:e}).then(n=>n.state.payload)}async set(e,n,r){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:n,expiry:r?.expiryMs})}async getOrSet(e,n,r){return await this._client.getOrSetState({type:this._stateType,name:this._stateName,id:e,payload:n,expiry:r?.expiryMs}).then(i=>i.state.payload)}async delete(e){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:null})}async patch(e,n){await this._client.patchState({type:this._stateType,name:this._stateName,id:e,payload:n})}},bd=(t,e)=>new Proxy({},{get:(n,r)=>new Proxy({},{get:(i,s)=>{let a=e.alias!==void 0?`${e.alias}${fe}${s}`:s;return new Xi(t,r,a)}})});var Ar=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:n,interfaces:r,integrations:i,alias:s}=this._runtime,a=_d(e,this._runtime),l=bd(e,this._runtime),c=Oe({client:e}),d=Td(e,this._runtime),g=Gi({client:e,pluginAlias:this._runtime.alias}),m=Ji({client:e,plugin:this._runtime}),T=qi({client:e,plugin:this._runtime});return{configuration:n,interfaces:r,integrations:i,actions:a,states:l,alias:s,workflows:c,events:d,users:g,conversations:m,messages:T}}get actionHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=this._actionHandlers[n];if(r)return Y.setName(i=>r({...i,...this._getTools(i.client)}),r.name)}})}get messageHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=n==="*"?[]:this._messageHandlers[n]??[],i=this._messageHandlers["*"]??[];return E.unique([...r,...i]).sort((a,l)=>a.order-l.order).map(({handler:a})=>Y.setName(l=>a({...l,user:_e({...l,conversationId:l.conversation.id,pluginAlias:this._runtime.alias}),message:ge({...l,plugin:this._runtime,message:l.message}),conversation:Pt({...l,plugin:this._runtime,conversation:l.conversation}),...this._getTools(l.client)}),a.name))}})}get eventHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=n==="*"?[]:this._eventHandlers[n]??[],i=Object.entries(this._eventHandlers).filter(([l])=>this._eventResolvesTo(l,n)).flatMap(([,l])=>l??[]),s=this._eventHandlers["*"]??[];return E.unique([...r,...i,...s]).sort((l,c)=>l.order-c.order).map(({handler:l})=>Y.setName(c=>l({...c,...this._getTools(c.client)}),l.name))}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=n==="*"?[]:this._stateExpiredHandlers[n]??[],i=this._stateExpiredHandlers["*"]??[];return E.unique([...r,...i]).sort((a,l)=>a.order-l.order).map(({handler:a})=>Y.setName(l=>a({...l,...this._getTools(l.client)}),a.name))}})}get hookHandlers(){return new Proxy({},{get:(e,n)=>{let r=this._hookHandlers[n];if(r)return new Proxy({},{get:(i,s)=>{s=this._stripAliasPrefix(s);let a=s==="*"?[]:r[s]??[],l=Object.entries(r).filter(([g])=>this._eventResolvesTo(g,s)).flatMap(([,g])=>g??[]),c=r["*"]??[];return E.unique([...a,...l,...c]).sort((g,m)=>g.order-m.order).map(({handler:g})=>Y.setName(m=>g({...m,data:ve(m.data,{alias:this._runtime.alias}),...this._getTools(m.client)}),g.name))}})}})}get workflowHandlers(){return new Proxy({},{get:(e,n)=>{let r=this._workflowHandlers[n];if(r)return new Proxy({},{get:(i,s)=>(r[s]?.sort((l,c)=>l.order-c.order)??[]).map(({handler:l})=>Y.setName(async c=>{let d=c.workflow;return await l({...c,workflow:pe({...c,workflow:d,onWorkflowUpdate(g){d=g},pluginAlias:this._runtime.alias}),...this._getTools(c.client)}),d},l.name))})}})}on={message:(e,n)=>{this._messageHandlers[e]=E.safePush(this._messageHandlers[e],{handler:n,order:this._registerOrder++})},event:(e,n)=>{this._eventHandlers[e]=E.safePush(this._eventHandlers[e],{handler:n,order:this._registerOrder++})},stateExpired:(e,n)=>{this._stateExpiredHandlers[e]=E.safePush(this._stateExpiredHandlers[e],{handler:n,order:this._registerOrder++})},beforeIncomingEvent:(e,n)=>{this._hookHandlers.before_incoming_event[e]=E.safePush(this._hookHandlers.before_incoming_event[e],{handler:n,order:this._registerOrder++})},beforeIncomingMessage:(e,n)=>{this._hookHandlers.before_incoming_message[e]=E.safePush(this._hookHandlers.before_incoming_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingMessage:(e,n)=>{this._hookHandlers.before_outgoing_message[e]=E.safePush(this._hookHandlers.before_outgoing_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingCallAction:(e,n)=>{this._hookHandlers.before_outgoing_call_action[e]=E.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},beforeIncomingCallAction:(e,n)=>{this._hookHandlers.before_incoming_call_action[e]=E.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingEvent:(e,n)=>{this._hookHandlers.after_incoming_event[e]=E.safePush(this._hookHandlers.after_incoming_event[e],{handler:n,order:this._registerOrder++})},afterIncomingMessage:(e,n)=>{this._hookHandlers.after_incoming_message[e]=E.safePush(this._hookHandlers.after_incoming_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingMessage:(e,n)=>{this._hookHandlers.after_outgoing_message[e]=E.safePush(this._hookHandlers.after_outgoing_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingCallAction:(e,n)=>{this._hookHandlers.after_outgoing_call_action[e]=E.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingCallAction:(e,n)=>{this._hookHandlers.after_incoming_call_action[e]=E.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:n,order:this._registerOrder++})},workflowStart:(e,n)=>{this._workflowHandlers.started[e]=E.safePush(this._workflowHandlers.started[e],{handler:n,order:this._registerOrder++})},workflowContinue:(e,n)=>{this._workflowHandlers.continued[e]=E.safePush(this._workflowHandlers.continued[e],{handler:n,order:this._registerOrder++})},workflowTimeout:(e,n)=>{this._workflowHandlers.timed_out[e]=E.safePush(this._workflowHandlers.timed_out[e],{handler:n,order:this._registerOrder++})}};_eventResolvesTo=(e,n)=>{let[i,s]=e.split(":");if(!i||!s)return!1;let a=this._runtime.interfaces[i];if(a&&n===`${a.integrationAlias}:${a?.events?.[s]?.name}`)return!0;let l=this._runtime.integrations[i];return!!(l&&n===`${l.integrationAlias}:${s}`)};_stripAliasPrefix=e=>{let{alias:n}=this._runtime;if(!n)return e;let r=`${n}#`;return e.startsWith(r)?e.slice(r.length):e}};var Qi={};nt(Qi,{allWithinMajorOf:()=>cv,allWithinMinorOf:()=>uv});var en=Dr(require("semver"));function cv(t){let e=en.major(t.version);return{...t,version:`>=${e}.0.0 <${e+1}.0.0`}}function uv(t){let e=en.major(t.version),n=en.minor(t.version);return{...t,version:`>=${e}.${n}.0 <${e}.${n+1}.0`}}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,coerce,conversation,createZodEnum,cuid2Regex,cuidRegex,custom,datasource,date,discriminatedUnion,effect,emailRegex,enum:null,errorUtil,event,function:null,getErrorMap,getParsedType,instanceof:null,intent,intersection,ipv4Regex,ipv6Regex,isAborted,isApiError,isAsync,isDirty,isEmojiRegex,isValid,json,knowledgebase,late,lazy,literal,makeIssue,map,mergeObjectSchemas,message,messages,nan,nativeEnum,never,null:null,nullable,number,object,objectUtil,oboolean,onumber,optional,ostring,parseBody,pipeline,preprocess,processCreateParams,promise,quotelessJson,readonly,record,ref,serve,set,setErrorMap,strictObject,string,symbol,table,tablerow,transformer,transforms,tuple,ulidRegex,undefined,union,unknown,user,util,uuidRegex,variable,version,void:null,z});
73
76
  /*! Bundled license information:
74
77
 
75
78
  @bpinternal/zui/dist/index.js: