@botpress/sdk 5.1.0 → 5.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +5 -5
- package/dist/index.cjs +29 -33
- package/dist/index.cjs.map +4 -4
- package/dist/index.mjs +41 -43
- package/dist/index.mjs.map +4 -4
- package/dist/integration/server/integration-logger.d.ts +15 -0
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1,26 +1,19 @@
|
|
|
1
|
-
"use strict";var xd=Object.create;var tn=Object.defineProperty;var kd=Object.getOwnPropertyDescriptor;var Sd=Object.getOwnPropertyNames;var Od=Object.getPrototypeOf,Ed=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))!Ed.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(Od(t)):{},es(e||!t||!t.__esModule?tn(n,"default",{value:t,enumerable:!0}):n,t)),Id=t=>es(tn({},"__esModule",{value:!0}),t);var pv={};nt(pv,{BRAND:()=>Yl,Bot:()=>Ir,BotDefinition:()=>Er,BotLogger:()=>wt,BotSpecificClient:()=>ye,DIRTY:()=>Ke,EMPTY_PATH:()=>zl,INVALID:()=>x,Integration:()=>Or,IntegrationDefinition:()=>br,IntegrationLogger:()=>bt,IntegrationSpecificClient:()=>_t,InterfaceDefinition:()=>Zr,NEVER:()=>fu,OK:()=>G,ParseInputLazyPath:()=>le,ParseStatus:()=>ne,Plugin:()=>Ar,PluginDefinition:()=>Br,RuntimeError:()=>Cr.RuntimeError,Schema:()=>E,WELL_KNOWN_ATTRIBUTES:()=>Py,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:()=>Oi,ZodSchema:()=>E,ZodSet:()=>Ei,ZodString:()=>J,ZodSymbol:()=>Hi,ZodTransformer:()=>Ae,ZodTuple:()=>We,ZodType:()=>E,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:()=>Oc,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:()=>Ec,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(pv);var Fi={};nt(Fi,{defaults:()=>wy,markdown:()=>Ty,markdownBloc:()=>by});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)),l=(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:()=>yy,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:()=>E,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:()=>Oi,ZodSchema:()=>E,ZodSet:()=>Ei,ZodString:()=>J,ZodSymbol:()=>Hi,ZodTransformer:()=>Ae,ZodTuple:()=>We,ZodType:()=>E,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:()=>Oc,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:()=>Ec,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)}l(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)}l(b,"primitiveToTypescriptValue");function ot(t){return typeof t>"u"?"undefined":JSON.stringify(t)}l(ot,"unknownToTypescriptValue");var Fs=l((t,e)=>{let n=Object.entries(t),r=e?" as const":"";return`{ ${n.map(([i,s])=>`${Fr(i)}: ${ot(s)}`).join(", ")} }${r}`},"recordOfUnknownToTypescriptRecord"),Fr=l(t=>/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t)?t:b(t),"toPropertyKey"),Cd=l(t=>t.charAt(0).toUpperCase()+t.slice(1),"capitalize"),zs=l(t=>{let e=/[^a-zA-Z0-9_]/g;return t.split(e).map(Cd).filter(r=>!!r).join("")},"toTypeArgumentName"),ns=l(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=l(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 Od=Object.getPrototypeOf,Ed=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))!Ed.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(Od(t)):{},es(e||!t||!t.__esModule?tn(n,"default",{value:t,enumerable:!0}):n,t)),Id=t=>es(tn({},"__esModule",{value:!0}),t);var pv={};nt(pv,{BRAND:()=>Yl,Bot:()=>Ir,BotDefinition:()=>Er,BotLogger:()=>wt,BotSpecificClient:()=>ye,DIRTY:()=>Ke,EMPTY_PATH:()=>zl,INVALID:()=>x,Integration:()=>Or,IntegrationDefinition:()=>br,IntegrationLogger:()=>bt,IntegrationSpecificClient:()=>_t,InterfaceDefinition:()=>Zr,NEVER:()=>fu,OK:()=>G,ParseInputLazyPath:()=>le,ParseStatus:()=>ne,Plugin:()=>Ar,PluginDefinition:()=>Br,RuntimeError:()=>Cr.RuntimeError,Schema:()=>E,WELL_KNOWN_ATTRIBUTES:()=>Py,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:()=>Oi,ZodSchema:()=>E,ZodSet:()=>Ei,ZodString:()=>J,ZodSymbol:()=>Hi,ZodTransformer:()=>Ae,ZodTuple:()=>We,ZodType:()=>E,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:()=>Oc,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:()=>Ec,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(pv);var Fi={};nt(Fi,{defaults:()=>wy,markdown:()=>Ty,markdownBloc:()=>by});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)),l=(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:()=>Us,fromJSONSchema:()=>yu,fromJSONSchemaLegacy:()=>zh,fromObject:()=>ei,toJSONSchema:()=>V,toJSONSchemaLegacy:()=>yy,toTypescriptSchema:()=>mi,toTypescriptType:()=>hi});var w="x-zui",y={};Gn(y,{BRAND:()=>Yl,DIRTY:()=>Ke,EMPTY_PATH:()=>zl,INVALID:()=>x,NEVER:()=>fu,OK:()=>G,ParseInputLazyPath:()=>le,ParseStatus:()=>ne,Schema:()=>E,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:()=>Oi,ZodSchema:()=>E,ZodSet:()=>Ei,ZodString:()=>J,ZodSymbol:()=>Hi,ZodTransformer:()=>Ae,ZodTuple:()=>We,ZodType:()=>E,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:()=>Oc,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:()=>Ec,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 Us={};Gn(Us,{JSONSchemaToZuiError:()=>Jn,ObjectToZuiError:()=>Fr,UnrepresentableGenericError:()=>zr,UnsupportedJSONSchemaToZuiError:()=>Ie,UnsupportedZuiCheckToJSONSchemaError:()=>Gs,UnsupportedZuiToJSONSchemaError:()=>te,UnsupportedZuiToTypescriptSchemaError:()=>De,UnsupportedZuiToTypescriptTypeError:()=>na,UntitledDeclarationError:()=>ia,ZuiToJSONSchemaError:()=>Yn,ZuiToTypescriptSchemaError:()=>Xs,ZuiToTypescriptTypeError:()=>Xn,ZuiTransformError:()=>ht});var Fs=class extends Error{constructor(e,n){super(n),this.transform=e}};l(Fs,"ZuiTransformError");var ht=Fs,zs=class extends ht{constructor(e){super("json-schema-to-zui",e)}};l(zs,"JSONSchemaToZuiError");var Jn=zs,Ws=class extends ht{constructor(e){super("object-to-zui",e)}};l(Ws,"ObjectToZuiError");var Fr=Ws,Ls=class extends ht{constructor(e){super("zui-to-json-schema",e)}};l(Ls,"ZuiToJSONSchemaError");var Yn=Ls,Vs=class extends Yn{constructor(e,{suggestedAlternative:n}={}){super(`Zod type ${e} cannot be transformed to JSON Schema.`+(n?` Suggested alternative: ${n}`:""))}};l(Vs,"UnsupportedZuiToJSONSchemaError");var te=Vs,qs=class extends Yn{constructor({zodType:e,checkKind:n}){super(`Zod check .${n}() of type ${e} cannot be transformed to JSON Schema.`)}};l(qs,"UnsupportedZuiCheckToJSONSchemaError");var Gs=qs,Js=class extends Jn{constructor(e){super(`JSON Schema ${JSON.stringify(e)} cannot be transformed to ZUI type.`)}};l(Js,"UnsupportedJSONSchemaToZuiError");var Ie=Js,Ys=class extends ht{constructor(e){super("zui-to-typescript-schema",e)}};l(Ys,"ZuiToTypescriptSchemaError");var Xs=Ys,Qs=class extends Xs{constructor(e){super(`Zod type ${e} cannot be transformed to TypeScript schema.`)}};l(Qs,"UnsupportedZuiToTypescriptSchemaError");var De=Qs,ea=class extends ht{constructor(e){super("zui-to-typescript-type",e)}};l(ea,"ZuiToTypescriptTypeError");var Xn=ea,ta=class extends Xn{constructor(e){super(`Zod type ${e} cannot be transformed to TypeScript type.`)}};l(ta,"UnsupportedZuiToTypescriptTypeError");var na=ta,ra=class extends Xn{constructor(){super("Schema must have a title to be transformed to a TypeScript type with a declaration.")}};l(ra,"UntitledDeclarationError");var ia=ra,sa=class extends Xn{constructor(){super('ZodRef can only be transformed to a TypeScript type with a "type" declaration.')}};l(sa,"UnrepresentableGenericError");var zr=sa,Cd=l((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"),Rd=l(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"),Dd=l((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"),aa="\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}",oa="(([+-]\\d{2}(:?\\d{2})?)|Z)",Hd="Z",la="(\\.\\d+)?",Wr="\\.\\d{",Nd="}",ca=l(t=>{let e=t.precision?Wr+t.precision+Nd:t.precision===0?"":la,n=t.offset?oa:Hd;return new RegExp(`^${aa}${e}${n}$`)},"generateDatetimeRegex"),Md=l(t=>({precision:$d(t),offset:t.endsWith(`${oa}$`)}),"extractPrecisionAndOffset"),$d=l(t=>{let e=t.slice(1+aa.length);return e.startsWith(la)?null:e.startsWith(Wr)?parseInt(e.slice(Wr.length)):0},"_extractPrecision"),Mt={};Gn(Mt,{escapeSpecialChars:()=>jd});var jd=l(t=>t.replaceAll(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeSpecialChars");function ri(t,e,n,r){r?.errorMessages&&n&&(t.errorMessage=f(u({},t.errorMessage),{[e]:n}))}l(ri,"addErrorMessage");function D(t,e,n,r,i){t[e]=n,ri(t,e,r,i)}l(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 ii(t,e){let n=u({type:"string"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{});function r(i){return e.patternStrategy==="escape"?Mt.escapeSpecialChars(i):i}if(l(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}l(ii,"parseStringDef");var Re=l((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=l((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"),Kd=l(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",(n.precision!==null||n.offset)&&(e.pattern=ca(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=`${Mt.escapeSpecialChars(n.value)}$`;break;case"startsWith":e.pattern=`^${Mt.escapeSpecialChars(n.value)}`;break;case"includes":let r=n.position&&n.position>=1?`^(?:.{${n.position}}).*`:"";e.pattern=`${r}${Mt.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 Gs({zodType:p.ZodFirstPartyTypeKind.ZodString,checkKind:n.kind})}return e},"zodStringToJsonString"),Ud=l((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 Kd(e);case p.ZodFirstPartyTypeKind.ZodNumber:return Rd(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 Hr(n);case p.ZodFirstPartyTypeKind.ZodNull:return Nr(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 Cd(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)]),o=!1;return n.unknownKeys instanceof p.ZodType?o=V(n.unknownKeys):n.unknownKeys==="passthrough"&&(o=!0),{type:"object",description:n.description,properties:Object.fromEntries(a),required:s,additionalProperties:o,"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":f(u({},n["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodDiscriminatedUnion,discriminator:n.discriminator}})};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 Ud(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 Dd(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 Nr(n);if(n.value===void 0)return Hr(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),Hr()],"x-zui":f(u({},n["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodOptional}})};case p.ZodFirstPartyTypeKind.ZodNullable:return{anyOf:[V(n.innerType),Nr()],"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)}}l(V,"toJSONSchema");var Hr=l(t=>({not:!0,description:t?.description,"x-zui":f(u({},t?.["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodUndefined}})}),"undefinedSchema"),Nr=l(t=>({type:"null",description:t?.description,"x-zui":t?.["x-zui"]}),"nullSchema"),Fd=typeof global=="object"&&global&&global.Object===Object&&global,ua=Fd,zd=typeof self=="object"&&self&&self.Object===Object&&self,Wd=ua||zd||Function("return this")(),ke=Wd,Ld=ke.Symbol,Ze=Ld,da=Object.prototype,Vd=da.hasOwnProperty,qd=da.toString,xt=Ze?Ze.toStringTag:void 0;function pa(t){var e=Vd.call(t,xt),n=t[xt];try{t[xt]=void 0;var r=!0}catch{}var i=qd.call(t);return r&&(e?t[xt]=n:delete t[xt]),i}l(pa,"getRawTag");var Gd=pa,Jd=Object.prototype,Yd=Jd.toString;function fa(t){return Yd.call(t)}l(fa,"objectToString");var Xd=fa,Qd="[object Null]",ep="[object Undefined]",ns=Ze?Ze.toStringTag:void 0;function ga(t){return t==null?t===void 0?ep:Qd:ns&&ns in Object(t)?Gd(t):Xd(t)}l(ga,"baseGetTag");var Le=ga;function ma(t){return t!=null&&typeof t=="object"}l(ma,"isObjectLike");var Ue=ma,tp="[object Symbol]";function ha(t){return typeof t=="symbol"||Ue(t)&&Le(t)==tp}l(ha,"isSymbol");var si=ha;function ya(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}l(ya,"arrayMap");var va=ya,np=Array.isArray,xe=np,rp=1/0,rs=Ze?Ze.prototype:void 0,is=rs?rs.toString:void 0;function ai(t){if(typeof t=="string")return t;if(xe(t))return va(t,ai)+"";if(si(t))return is?is.call(t):"";var e=t+"";return e=="0"&&1/t==-rp?"-0":e}l(ai,"baseToString");var ip=ai;function _a(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}l(_a,"isObject");var ut=_a;function Ta(t){return t}l(Ta,"identity");var sp=Ta,ap="[object AsyncFunction]",op="[object Function]",lp="[object GeneratorFunction]",cp="[object Proxy]";function ba(t){if(!ut(t))return!1;var e=Le(t);return e==op||e==lp||e==ap||e==cp}l(ba,"isFunction");var wa=ba,up=ke["__core-js_shared__"],Mr=up,ss=(function(){var t=/[^.]+$/.exec(Mr&&Mr.keys&&Mr.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function Pa(t){return!!ss&&ss in t}l(Pa,"isMasked");var dp=Pa,pp=Function.prototype,fp=pp.toString;function xa(t){if(t!=null){try{return fp.call(t)}catch{}try{return t+""}catch{}}return""}l(xa,"toSource");var Ve=xa,gp=/[\\^$.*+?()[\]{}|]/g,mp=/^\[object .+?Constructor\]$/,hp=Function.prototype,yp=Object.prototype,vp=hp.toString,_p=yp.hasOwnProperty,Tp=RegExp("^"+vp.call(_p).replace(gp,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ka(t){if(!ut(t)||dp(t))return!1;var e=wa(t)?Tp:mp;return e.test(Ve(t))}l(ka,"baseIsNative");var bp=ka;function Sa(t,e){return t?.[e]}l(Sa,"getValue");var wp=Sa;function Oa(t,e){var n=wp(t,e);return bp(n)?n:void 0}l(Oa,"getNative");var qe=Oa,Pp=qe(ke,"WeakMap"),Lr=Pp,xp=(function(){try{var t=qe(Object,"defineProperty");return t({},"",{}),t}catch{}})(),as=xp,kp=9007199254740991,Sp=/^(?:0|[1-9]\d*)$/;function Ea(t,e){var n=typeof t;return e=e??kp,!!e&&(n=="number"||n!="symbol"&&Sp.test(t))&&t>-1&&t%1==0&&t<e}l(Ea,"isIndex");var oi=Ea;function Ia(t,e,n){e=="__proto__"&&as?as(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}l(Ia,"baseAssignValue");var Za=Ia;function Ba(t,e){return t===e||t!==t&&e!==e}l(Ba,"eq");var li=Ba,Op=Object.prototype,Ep=Op.hasOwnProperty;function Aa(t,e,n){var r=t[e];(!(Ep.call(t,e)&&li(r,n))||n===void 0&&!(e in t))&&Za(t,e,n)}l(Aa,"assignValue");var Ip=Aa,Zp=9007199254740991;function Ca(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Zp}l(Ca,"isLength");var ci=Ca;function Ra(t){return t!=null&&ci(t.length)&&!wa(t)}l(Ra,"isArrayLike");var Da=Ra,Bp=Object.prototype;function Ha(t){var e=t&&t.constructor,n=typeof e=="function"&&e.prototype||Bp;return t===n}l(Ha,"isPrototype");var Na=Ha;function Ma(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}l(Ma,"baseTimes");var Ap=Ma,Cp="[object Arguments]";function $a(t){return Ue(t)&&Le(t)==Cp}l($a,"baseIsArguments");var os=$a,ja=Object.prototype,Rp=ja.hasOwnProperty,Dp=ja.propertyIsEnumerable,Hp=os((function(){return arguments})())?os:function(t){return Ue(t)&&Rp.call(t,"callee")&&!Dp.call(t,"callee")},Ka=Hp;function Ua(){return!1}l(Ua,"stubFalse");var Np=Ua,Fa=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ls=Fa&&typeof module=="object"&&module&&!module.nodeType&&module,Mp=ls&&ls.exports===Fa,cs=Mp?ke.Buffer:void 0,$p=cs?cs.isBuffer:void 0,jp=$p||Np,Vr=jp,Kp="[object Arguments]",Up="[object Array]",Fp="[object Boolean]",zp="[object Date]",Wp="[object Error]",Lp="[object Function]",Vp="[object Map]",qp="[object Number]",Gp="[object Object]",Jp="[object RegExp]",Yp="[object Set]",Xp="[object String]",Qp="[object WeakMap]",ef="[object ArrayBuffer]",tf="[object DataView]",nf="[object Float32Array]",rf="[object Float64Array]",sf="[object Int8Array]",af="[object Int16Array]",of="[object Int32Array]",lf="[object Uint8Array]",cf="[object Uint8ClampedArray]",uf="[object Uint16Array]",df="[object Uint32Array]",H={};H[nf]=H[rf]=H[sf]=H[af]=H[of]=H[lf]=H[cf]=H[uf]=H[df]=!0;H[Kp]=H[Up]=H[ef]=H[Fp]=H[tf]=H[zp]=H[Wp]=H[Lp]=H[Vp]=H[qp]=H[Gp]=H[Jp]=H[Yp]=H[Xp]=H[Qp]=!1;function za(t){return Ue(t)&&ci(t.length)&&!!H[Le(t)]}l(za,"baseIsTypedArray");var pf=za;function Wa(t){return function(e){return t(e)}}l(Wa,"baseUnary");var ff=Wa,La=typeof exports=="object"&&exports&&!exports.nodeType&&exports,$t=La&&typeof module=="object"&&module&&!module.nodeType&&module,gf=$t&&$t.exports===La,$r=gf&&ua.process,mf=(function(){try{var t=$t&&$t.require&&$t.require("util").types;return t||$r&&$r.binding&&$r.binding("util")}catch{}})(),us=mf,ds=us&&us.isTypedArray,hf=ds?ff(ds):pf,Va=hf,yf=Object.prototype,vf=yf.hasOwnProperty;function qa(t,e){var n=xe(t),r=!n&&Ka(t),i=!n&&!r&&Vr(t),s=!n&&!r&&!i&&Va(t),a=n||r||i||s,o=a?Ap(t.length,String):[],c=o.length;for(var d in t)(e||vf.call(t,d))&&!(a&&(d=="length"||i&&(d=="offset"||d=="parent")||s&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||oi(d,c)))&&o.push(d);return o}l(qa,"arrayLikeKeys");var Ga=qa;function Ja(t,e){return function(n){return t(e(n))}}l(Ja,"overArg");var Ya=Ja,_f=Ya(Object.keys,Object),Tf=_f,bf=Object.prototype,wf=bf.hasOwnProperty;function Xa(t){if(!Na(t))return Tf(t);var e=[];for(var n in Object(t))wf.call(t,n)&&n!="constructor"&&e.push(n);return e}l(Xa,"baseKeys");var Pf=Xa;function Qa(t){return Da(t)?Ga(t):Pf(t)}l(Qa,"keys");var ui=Qa;function eo(t){var e=[];if(t!=null)for(var n in Object(t))e.push(n);return e}l(eo,"nativeKeysIn");var xf=eo,kf=Object.prototype,Sf=kf.hasOwnProperty;function to(t){if(!ut(t))return xf(t);var e=Na(t),n=[];for(var r in t)r=="constructor"&&(e||!Sf.call(t,r))||n.push(r);return n}l(to,"baseKeysIn");var Of=to;function no(t){return Da(t)?Ga(t,!0):Of(t)}l(no,"keysIn");var Ef=no,If=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Zf=/^\w*$/;function ro(t,e){if(xe(t))return!1;var n=typeof t;return n=="number"||n=="symbol"||n=="boolean"||t==null||si(t)?!0:Zf.test(t)||!If.test(t)||e!=null&&t in Object(e)}l(ro,"isKey");var di=ro,Bf=qe(Object,"create"),Kt=Bf;function io(){this.__data__=Kt?Kt(null):{},this.size=0}l(io,"hashClear");var Af=io;function so(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}l(so,"hashDelete");var Cf=so,Rf="__lodash_hash_undefined__",Df=Object.prototype,Hf=Df.hasOwnProperty;function ao(t){var e=this.__data__;if(Kt){var n=e[t];return n===Rf?void 0:n}return Hf.call(e,t)?e[t]:void 0}l(ao,"hashGet");var Nf=ao,Mf=Object.prototype,$f=Mf.hasOwnProperty;function oo(t){var e=this.__data__;return Kt?e[t]!==void 0:$f.call(e,t)}l(oo,"hashHas");var jf=oo,Kf="__lodash_hash_undefined__";function lo(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=Kt&&e===void 0?Kf:e,this}l(lo,"hashSet");var Uf=lo;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])}}l(Ge,"Hash");Ge.prototype.clear=Af;Ge.prototype.delete=Cf;Ge.prototype.get=Nf;Ge.prototype.has=jf;Ge.prototype.set=Uf;var ps=Ge;function co(){this.__data__=[],this.size=0}l(co,"listCacheClear");var Ff=co;function uo(t,e){for(var n=t.length;n--;)if(li(t[n][0],e))return n;return-1}l(uo,"assocIndexOf");var Qn=uo,zf=Array.prototype,Wf=zf.splice;function po(t){var e=this.__data__,n=Qn(e,t);if(n<0)return!1;var r=e.length-1;return n==r?e.pop():Wf.call(e,n,1),--this.size,!0}l(po,"listCacheDelete");var Lf=po;function fo(t){var e=this.__data__,n=Qn(e,t);return n<0?void 0:e[n][1]}l(fo,"listCacheGet");var Vf=fo;function go(t){return Qn(this.__data__,t)>-1}l(go,"listCacheHas");var qf=go;function mo(t,e){var n=this.__data__,r=Qn(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}l(mo,"listCacheSet");var Gf=mo;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])}}l(Je,"ListCache");Je.prototype.clear=Ff;Je.prototype.delete=Lf;Je.prototype.get=Vf;Je.prototype.has=qf;Je.prototype.set=Gf;var er=Je,Jf=qe(ke,"Map"),Ut=Jf;function ho(){this.size=0,this.__data__={hash:new ps,map:new(Ut||er),string:new ps}}l(ho,"mapCacheClear");var Yf=ho;function yo(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}l(yo,"isKeyable");var Xf=yo;function vo(t,e){var n=t.__data__;return Xf(e)?n[typeof e=="string"?"string":"hash"]:n.map}l(vo,"getMapData");var tr=vo;function _o(t){var e=tr(this,t).delete(t);return this.size-=e?1:0,e}l(_o,"mapCacheDelete");var Qf=_o;function To(t){return tr(this,t).get(t)}l(To,"mapCacheGet");var eg=To;function bo(t){return tr(this,t).has(t)}l(bo,"mapCacheHas");var tg=bo;function wo(t,e){var n=tr(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this}l(wo,"mapCacheSet");var ng=wo;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])}}l(Ye,"MapCache");Ye.prototype.clear=Yf;Ye.prototype.delete=Qf;Ye.prototype.get=eg;Ye.prototype.has=tg;Ye.prototype.set=ng;var nr=Ye,rg="Expected a function";function rr(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(rg);var n=l(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}l(rr,"memoize");rr.Cache=nr;var ig=rr,sg=500;function Po(t){var e=ig(t,function(r){return n.size===sg&&n.clear(),r}),n=e.cache;return e}l(Po,"memoizeCapped");var ag=Po,og=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,lg=/\\(\\)?/g,cg=ag(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(og,function(n,r,i,s){e.push(i?s.replace(lg,"$1"):r||n)}),e}),ug=cg;function xo(t){return t==null?"":ip(t)}l(xo,"toString");var dg=xo;function ko(t,e){return xe(t)?t:di(t,e)?[t]:ug(dg(t))}l(ko,"castPath");var ir=ko,pg=1/0;function So(t){if(typeof t=="string"||si(t))return t;var e=t+"";return e=="0"&&1/t==-pg?"-0":e}l(So,"toKey");var Vt=So;function Oo(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}l(Oo,"baseGet");var pi=Oo;function Eo(t,e,n){var r=t==null?void 0:pi(t,e);return r===void 0?n:r}l(Eo,"get");var fg=Eo;function Io(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t}l(Io,"arrayPush");var Zo=Io,gg=Ya(Object.getPrototypeOf,Object),Bo=gg,mg="[object Object]",hg=Function.prototype,yg=Object.prototype,Ao=hg.toString,vg=yg.hasOwnProperty,_g=Ao.call(Object);function Co(t){if(!Ue(t)||Le(t)!=mg)return!1;var e=Bo(t);if(e===null)return!0;var n=vg.call(e,"constructor")&&e.constructor;return typeof n=="function"&&n instanceof n&&Ao.call(n)==_g}l(Co,"isPlainObject");var fs=Co;function Ro(){this.__data__=new er,this.size=0}l(Ro,"stackClear");var Tg=Ro;function Do(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}l(Do,"stackDelete");var bg=Do;function Ho(t){return this.__data__.get(t)}l(Ho,"stackGet");var wg=Ho;function No(t){return this.__data__.has(t)}l(No,"stackHas");var Pg=No,xg=200;function Mo(t,e){var n=this.__data__;if(n instanceof er){var r=n.__data__;if(!Ut||r.length<xg-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}l(Mo,"stackSet");var kg=Mo;function Xe(t){var e=this.__data__=new er(t);this.size=e.size}l(Xe,"Stack");Xe.prototype.clear=Tg;Xe.prototype.delete=bg;Xe.prototype.get=wg;Xe.prototype.has=Pg;Xe.prototype.set=kg;var sn=Xe;function $o(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}l($o,"arrayFilter");var Sg=$o;function jo(){return[]}l(jo,"stubArray");var Ko=jo,Og=Object.prototype,Eg=Og.propertyIsEnumerable,gs=Object.getOwnPropertySymbols,Ig=gs?function(t){return t==null?[]:(t=Object(t),Sg(gs(t),function(e){return Eg.call(t,e)}))}:Ko,Uo=Ig,Zg=Object.getOwnPropertySymbols,Bg=Zg?function(t){for(var e=[];t;)Zo(e,Uo(t)),t=Bo(t);return e}:Ko,Ag=Bg;function Fo(t,e,n){var r=e(t);return xe(t)?r:Zo(r,n(t))}l(Fo,"baseGetAllKeys");var zo=Fo;function Wo(t){return zo(t,ui,Uo)}l(Wo,"getAllKeys");var ms=Wo;function Lo(t){return zo(t,Ef,Ag)}l(Lo,"getAllKeysIn");var Cg=Lo,Rg=qe(ke,"DataView"),qr=Rg,Dg=qe(ke,"Promise"),Gr=Dg,Hg=qe(ke,"Set"),Jr=Hg,hs="[object Map]",Ng="[object Object]",ys="[object Promise]",vs="[object Set]",_s="[object WeakMap]",Ts="[object DataView]",Mg=Ve(qr),$g=Ve(Ut),jg=Ve(Gr),Kg=Ve(Jr),Ug=Ve(Lr),He=Le;(qr&&He(new qr(new ArrayBuffer(1)))!=Ts||Ut&&He(new Ut)!=hs||Gr&&He(Gr.resolve())!=ys||Jr&&He(new Jr)!=vs||Lr&&He(new Lr)!=_s)&&(He=l(function(t){var e=Le(t),n=e==Ng?t.constructor:void 0,r=n?Ve(n):"";if(r)switch(r){case Mg:return Ts;case $g:return hs;case jg:return ys;case Kg:return vs;case Ug:return _s}return e},"getTag"));var bs=He,Fg=ke.Uint8Array,ws=Fg,zg="__lodash_hash_undefined__";function Vo(t){return this.__data__.set(t,zg),this}l(Vo,"setCacheAdd");var Wg=Vo;function qo(t){return this.__data__.has(t)}l(qo,"setCacheHas");var Lg=qo;function Ft(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new nr;++e<n;)this.add(t[e])}l(Ft,"SetCache");Ft.prototype.add=Ft.prototype.push=Wg;Ft.prototype.has=Lg;var Vg=Ft;function Go(t,e){for(var n=-1,r=t==null?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}l(Go,"arraySome");var qg=Go;function Jo(t,e){return t.has(e)}l(Jo,"cacheHas");var Gg=Jo,Jg=1,Yg=2;function Yo(t,e,n,r,i,s){var a=n&Jg,o=t.length,c=e.length;if(o!=c&&!(a&&c>o))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&Yg?new Vg:void 0;for(s.set(t,e),s.set(e,t);++m<o;){var k=t[m],K=e[m];if(r)var W=a?r(K,k,m,e,t,s):r(k,K,m,t,e,s);if(W!==void 0){if(W)continue;T=!1;break}if(I){if(!qg(e,function(Q,ae){if(!Gg(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}l(Yo,"equalArrays");var Xo=Yo;function Qo(t){var e=-1,n=Array(t.size);return t.forEach(function(r,i){n[++e]=[i,r]}),n}l(Qo,"mapToArray");var Xg=Qo;function el(t){var e=-1,n=Array(t.size);return t.forEach(function(r){n[++e]=r}),n}l(el,"setToArray");var Qg=el,em=1,tm=2,nm="[object Boolean]",rm="[object Date]",im="[object Error]",sm="[object Map]",am="[object Number]",om="[object RegExp]",lm="[object Set]",cm="[object String]",um="[object Symbol]",dm="[object ArrayBuffer]",pm="[object DataView]",Ps=Ze?Ze.prototype:void 0,jr=Ps?Ps.valueOf:void 0;function tl(t,e,n,r,i,s,a){switch(n){case pm:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case dm:return!(t.byteLength!=e.byteLength||!s(new ws(t),new ws(e)));case nm:case rm:case am:return li(+t,+e);case im:return t.name==e.name&&t.message==e.message;case om:case cm:return t==e+"";case sm:var o=Xg;case lm:var c=r&em;if(o||(o=Qg),t.size!=e.size&&!c)return!1;var d=a.get(t);if(d)return d==e;r|=tm,a.set(t,e);var g=Xo(o(t),o(e),r,i,s,a);return a.delete(t),g;case um:if(jr)return jr.call(t)==jr.call(e)}return!1}l(tl,"equalByTag");var fm=tl,gm=1,mm=Object.prototype,hm=mm.hasOwnProperty;function nl(t,e,n,r,i,s){var a=n&gm,o=ms(t),c=o.length,d=ms(e),g=d.length;if(c!=g&&!a)return!1;for(var m=c;m--;){var T=o[m];if(!(a?T in e:hm.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 W=a;++m<c;){T=o[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}W||(W=T=="constructor")}if(K&&!W){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}l(nl,"equalObjects");var ym=nl,vm=1,xs="[object Arguments]",ks="[object Array]",nn="[object Object]",_m=Object.prototype,Ss=_m.hasOwnProperty;function rl(t,e,n,r,i,s){var a=xe(t),o=xe(e),c=a?ks:bs(t),d=o?ks:bs(e);c=c==xs?nn:c,d=d==xs?nn:d;var g=c==nn,m=d==nn,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||Va(t)?Xo(t,e,n,r,i,s):fm(t,e,c,n,r,i,s);if(!(n&vm)){var I=g&&Ss.call(t,"__wrapped__"),k=m&&Ss.call(e,"__wrapped__");if(I||k){var K=I?t.value():t,W=k?e.value():e;return s||(s=new sn),i(K,W,n,r,s)}}return T?(s||(s=new sn),ym(t,e,n,r,i,s)):!1}l(rl,"baseIsEqualDeep");var Tm=rl;function fi(t,e,n,r,i){return t===e?!0:t==null||e==null||!Ue(t)&&!Ue(e)?t!==t&&e!==e:Tm(t,e,n,r,fi,i)}l(fi,"baseIsEqual");var sr=fi,bm=1,wm=2;function il(t,e,n,r){var i=n.length,s=i,a=!r;if(t==null)return!s;for(t=Object(t);i--;){var o=n[i];if(a&&o[2]?o[1]!==t[o[0]]:!(o[0]in t))return!1}for(;++i<s;){o=n[i];var c=o[0],d=t[c],g=o[1];if(a&&o[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,bm|wm,r,m):T))return!1}}return!0}l(il,"baseIsMatch");var Pm=il;function sl(t){return t===t&&!ut(t)}l(sl,"isStrictComparable");var al=sl;function ol(t){for(var e=ui(t),n=e.length;n--;){var r=e[n],i=t[r];e[n]=[r,i,al(i)]}return e}l(ol,"getMatchData");var xm=ol;function ll(t,e){return function(n){return n==null?!1:n[t]===e&&(e!==void 0||t in Object(n))}}l(ll,"matchesStrictComparable");var cl=ll;function ul(t){var e=xm(t);return e.length==1&&e[0][2]?cl(e[0][0],e[0][1]):function(n){return n===t||Pm(n,t,e)}}l(ul,"baseMatches");var km=ul;function dl(t,e){return t!=null&&e in Object(t)}l(dl,"baseHasIn");var Sm=dl;function pl(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&&ci(i)&&oi(a,i)&&(xe(t)||Ka(t)))}l(pl,"hasPath");var Om=pl;function fl(t,e){return t!=null&&Om(t,e,Sm)}l(fl,"hasIn");var Em=fl,Im=1,Zm=2;function gl(t,e){return di(t)&&al(e)?cl(Vt(t),e):function(n){var r=fg(n,t);return r===void 0&&r===e?Em(n,t):sr(e,r,Im|Zm)}}l(gl,"baseMatchesProperty");var Bm=gl;function ml(t){return function(e){return e?.[t]}}l(ml,"baseProperty");var Am=ml;function hl(t){return function(e){return pi(e,t)}}l(hl,"basePropertyDeep");var Cm=hl;function yl(t){return di(t)?Am(Vt(t)):Cm(t)}l(yl,"property");var Rm=yl;function vl(t){return typeof t=="function"?t:t==null?sp:typeof t=="object"?xe(t)?Bm(t[0],t[1]):km(t):Rm(t)}l(vl,"baseIteratee");var gi=vl;function _l(t){return function(e,n,r){for(var i=-1,s=Object(e),a=r(e),o=a.length;o--;){var c=a[t?o:++i];if(n(s[c],c,s)===!1)break}return e}}l(_l,"createBaseFor");var Dm=_l,Hm=Dm(),Nm=Hm;function Tl(t,e){return t&&Nm(t,e,ui)}l(Tl,"baseForOwn");var Mm=Tl;function bl(t,e){return sr(t,e)}l(bl,"isEqual");var ot=bl;function wl(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}l(wl,"isEqualWith");var $m=wl;function Pl(t){return t===void 0}l(Pl,"isUndefined");var Os=Pl;function xl(t,e){var n={};return e=gi(e,3),Mm(t,function(r,i,s){Za(n,i,e(r,i,s))}),n}l(xl,"mapValues");var jm=xl,Km="Expected a function";function kl(t){if(typeof t!="function")throw new TypeError(Km);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)}}l(kl,"negate");var Um=kl;function Sl(t,e,n,r){if(!ut(t))return t;e=ir(e,t);for(var i=-1,s=e.length,a=s-1,o=t;o!=null&&++i<s;){var c=Vt(e[i]),d=n;if(c==="__proto__"||c==="constructor"||c==="prototype")return t;if(i!=a){var g=o[c];d=r?r(g,c,o):void 0,d===void 0&&(d=ut(g)?g:oi(e[i+1])?[]:{})}Ip(o,c,d),o=o[c]}return t}l(Sl,"baseSet");var Fm=Sl;function Ol(t,e,n){for(var r=-1,i=e.length,s={};++r<i;){var a=e[r],o=pi(t,a);n(o,a)&&Fm(s,ir(a,t),o)}return s}l(Ol,"basePickBy");var zm=Ol;function El(t,e){if(t==null)return{};var n=va(Cg(t),function(r){return[r]});return e=gi(e),zm(t,n,function(r,i){return e(r,i[0])})}l(El,"pickBy");var Wm=El;function Il(t,e){return Wm(t,Um(gi(e)))}l(Il,"omitBy");var Es=Il;function Zl(t){return typeof t=="symbol"?"symbol":typeof t=="bigint"?`${t.toString()}n`:b(t)}l(Zl,"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"?Cl(t):JSON.stringify(t)}l(b,"primitiveToTypescriptValue");function lt(t){return typeof t>"u"?"undefined":JSON.stringify(t)}l(lt,"unknownToTypescriptValue");var Bl=l((t,e)=>{let n=Object.entries(t),r=e?" as const":"";return`{ ${n.map(([i,s])=>`${Yr(i)}: ${lt(s)}`).join(", ")} }${r}`},"recordOfUnknownToTypescriptRecord"),Yr=l(t=>/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t)?t:b(t),"toPropertyKey"),Lm=l(t=>t.charAt(0).toUpperCase()+t.slice(1),"capitalize"),Al=l(t=>{let e=/[^a-zA-Z0-9_]/g;return t.split(e).map(Lm).filter(r=>!!r).join("")},"toTypeArgumentName"),Is=l(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=l(t=>{t=t?.replace(/(\n(\s*)?){3,}/g,`
|
|
2
2
|
|
|
3
3
|
`);let e=l(i=>i.startsWith("* ")?` ${i}`:` * ${i}`,"ensureLineStartsWithAsterisk"),n=l(i=>i.replace(/\*\//g,"*\\/"),"escapeCommentEnd"),r=(t??"").split(`
|
|
4
|
-
`).map(i=>i.trim());return
|
|
4
|
+
`).map(i=>i.trim());return Is(r),r.length&&(r[0]=r[0].replace(/^\/\*\*?/,""),r[r.length-1]=r[r.length-1].replace(/\*\/$/,"")),Is(r),r.length===0?"":r.length===1?`/** ${n(r[0])} */`:`/**
|
|
5
5
|
${r.map(e).map(n).join(`
|
|
6
6
|
`)}
|
|
7
|
-
*/`},"getMultilineComment");function
|
|
8
|
-
|
|
7
|
+
*/`},"getMultilineComment");function Cl(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}'`}l(Cl,"escapeString");var Vm=l(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"),qm=l(t=>{let e=t.checks;return e.length===0?"":e.map(Gm).join("")},"generateBigIntChecks"),Gm=l(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"),Jm=l(t=>{let e=t.checks;return e.length===0?"":e.map(Ym).join("")},"generateDateChecks"),Ym=l(t=>{switch(t.kind){case"min":return`.min(${Zs(t.value)}, ${b(t.message)})`;case"max":return`.max(${Zs(t.value)}, ${b(t.message)})`;default:return""}},"_generateDateCheck"),Zs=l(t=>`new Date(${t})`,"dateTs"),Xm=l(t=>{let e=t.checks;return e.length===0?"":e.map(Qm).join("")},"generateNumberChecks"),Qm=l(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"),eh=l(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"),th=l(t=>{let e=t.checks;return e.length===0?"":e.map(nh).join("")},"generateStringChecks"),nh=l(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=lt({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(${lt({message:t.message,precision:r,offset:t.offset})})`;case"ip":return`.ip(${lt({message:t.message,version:t.version})})`;default:return""}},"_generateStringCheck");function mi(t){return M(t)}l(mi,"toTypescriptSchema");function M(t){let n=t._def;switch(n.typeName){case p.ZodFirstPartyTypeKind.ZodString:return`z.string()${th(n)}${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodNumber:return`z.number()${Xm(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()${qm(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()${Jm(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)})${Vm(n)}${R(n)}${C(n)}`;case p.ZodFirstPartyTypeKind.ZodObject:let r=jm(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(`
|
|
8
|
+
`).trim();case p.ZodFirstPartyTypeKind.ZodUnion:return`z.union([${n.options.map(M).join(", ")}])${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:let o=n.options.map(M);return`z.discriminatedUnion(${b(n.discriminator)}, [${o.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)})${eh(n)}${R(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodFunction:let W=n.args.items.map(M),Q=W.length?`.args(${W.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=lt(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)}}l(M,"sUnwrapZod");var C=l(t=>t.description?`.describe(${b(t.description)})`:"","_maybeDescribe"),R=l(t=>`${rh(t)}${ih(t)}${sh(t)}${ah(t)}${oh(t)}${lh(t)}${ch(t)}`,"_addZuiExtensions"),rh=l(t=>{var e;return(e=t[w])!=null&&e.title?`.title(${b(t[w].title)})`:""},"_maybeTitle"),ih=l(t=>{var e;return(e=t[w])!=null&&e.displayAs?`.displayAs(${Bl({id:t[w].displayAs[0],params:t[w].displayAs[1]})})`:""},"_maybeDisplayAs"),sh=l(t=>{var e;return(e=t[w])!=null&&e.disabled?`.disabled(${t[w].disabled})`:""},"_maybeDisabled"),ah=l(t=>{var e;return(e=t[w])!=null&&e.hidden?`.hidden(${t[w].hidden})`:""},"_maybeHidden"),oh=l(t=>{var e;return(e=t[w])!=null&&e.placeholder?`.placeholder(${b(t[w].placeholder)})`:""},"_maybePlaceholder"),lh=l(t=>{var e;return(e=t[w])!=null&&e.secret?".secret()":""},"_maybeSecret"),ch=l(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(${Bl(Object.fromEntries(r))})`:""},"_maybeSetMetadata"),Rl=["string","number","boolean","unknown","void","any","null","undefined","never","bigint","symbol","object"],uh=5,dh=l(t=>Rl.includes(t),"isPrimitive"),ph=l(t=>Rl.map(e=>`${e}[]`).includes(t),"isArrayOfPrimitives"),Kr=l(t=>t.replace(/ +/g," ").trim(),"stripSpaces"),Dl=class{constructor(e,n){this.key=e,this.value=n}};l(Dl,"KeyValue");var rn=Dl,Hl=class{constructor(e){this.schema=e}};l(Hl,"FnParameters");var Bs=Hl,Nl=class{constructor(e){this.schema=e}};l(Nl,"FnReturn");var As=Nl,Ml=class{constructor(e){this.props=e}};l(Ml,"Declaration");var jt=Ml;function hi(t,e={}){let n=mh(t,e),r=B(n,e);return e.formatter&&(r=e.formatter(r)),r}l(hi,"toTypescriptType");var Cs=l(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 jt)return fh(t,s);if(t instanceof rn){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 rn(Cs(t.key),k),s)}let d=z(t.value._def.description||t.value.description),g=d?.trim().length>0?`
|
|
9
|
+
`:"",m=t.value.describe(""),I=t.value instanceof p.ZodAny?Cs(t.key):t.key;return`${g}${d}${g}${I}: ${B(m,s)}${g}`}if(t instanceof Bs){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 rn(Yr(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(">")||ph(d)||c?`args: ${d}`:d}if(t instanceof As)return t.schema instanceof p.ZodOptional?`${B(t.schema.unwrap(),s)} | undefined`:B(t.schema,s);let a=t,o=a._def;switch(o.typeName){case p.ZodFirstPartyTypeKind.ZodString:return`${z(a.description)} string`.trim();case p.ZodFirstPartyTypeKind.ZodNumber:case p.ZodFirstPartyTypeKind.ZodNaN:case p.ZodFirstPartyTypeKind.ZodBigInt:return`${z(a.description)} number`.trim();case p.ZodFirstPartyTypeKind.ZodBoolean:return`${z(a.description)} boolean`.trim();case p.ZodFirstPartyTypeKind.ZodDate:return`${z(a.description)} Date`.trim();case p.ZodFirstPartyTypeKind.ZodUndefined:return`${z(a.description)} undefined`.trim();case p.ZodFirstPartyTypeKind.ZodNull:return`${z(a.description)} null`.trim();case p.ZodFirstPartyTypeKind.ZodAny:return`${z(a.description)} any`.trim();case p.ZodFirstPartyTypeKind.ZodUnknown:return`${z(a.description)} unknown`.trim();case p.ZodFirstPartyTypeKind.ZodNever:return`${z(a.description)} never`.trim();case p.ZodFirstPartyTypeKind.ZodVoid:return`${z(a.description)} void`.trim();case p.ZodFirstPartyTypeKind.ZodArray:let c=B(o.type,s);return dh(c)?`${c}[]`:`Array<${c}>`;case p.ZodFirstPartyTypeKind.ZodObject:return`{ ${Object.entries(o.shape()).map(([ee,Rr])=>Rr instanceof p.Schema?B(new rn(Yr(ee),Rr),s):`${ee}: unknown`).join("; ")} }`;case p.ZodFirstPartyTypeKind.ZodUnion:let g=o.options.map(ee=>B(ee,s));return`${z(a.description)}
|
|
9
10
|
${g.join(" | ")}`;case p.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:let m=o.options.map(ee=>B(ee,s));return`${z(a.description)}
|
|
10
|
-
${m.join(" | ")}`;case p.ZodFirstPartyTypeKind.ZodIntersection:return`${B(o.left,s)} & ${B(o.right,s)}`;case p.ZodFirstPartyTypeKind.ZodTuple:return o.items.length===0?"[]":`[${o.items.map(ee=>B(ee,s)).join(", ")}]`;case p.ZodFirstPartyTypeKind.ZodRecord:let I=B(o.keyType,s),k=B(o.valueType,s);return`${z(a.description)} { [key: ${I}]: ${k} }`;case p.ZodFirstPartyTypeKind.ZodMap:return`Map<${B(o.keyType,s)}, ${B(o.valueType,s)}>`;case p.ZodFirstPartyTypeKind.ZodSet:return`Set<${B(o.valueType,s)}>`;case p.ZodFirstPartyTypeKind.ZodFunction:let K=B(new
|
|
11
|
+
${m.join(" | ")}`;case p.ZodFirstPartyTypeKind.ZodIntersection:return`${B(o.left,s)} & ${B(o.right,s)}`;case p.ZodFirstPartyTypeKind.ZodTuple:return o.items.length===0?"[]":`[${o.items.map(ee=>B(ee,s)).join(", ")}]`;case p.ZodFirstPartyTypeKind.ZodRecord:let I=B(o.keyType,s),k=B(o.valueType,s);return`${z(a.description)} { [key: ${I}]: ${k} }`;case p.ZodFirstPartyTypeKind.ZodMap:return`Map<${B(o.keyType,s)}, ${B(o.valueType,s)}>`;case p.ZodFirstPartyTypeKind.ZodSet:return`Set<${B(o.valueType,s)}>`;case p.ZodFirstPartyTypeKind.ZodFunction:let K=B(new Bs(o.args),s),W=B(new As(o.returns),s),Q=e?.parent instanceof jt&&e?.parent.props.type==="type";return e?.declaration&&!Q?`${z(a.description)}
|
|
11
12
|
(${K}): ${W}`:`${z(a.description)}
|
|
12
|
-
(${K}) => ${W}`;case p.ZodFirstPartyTypeKind.ZodLazy:return B(o.getter(),s);case p.ZodFirstPartyTypeKind.ZodLiteral:let ae=
|
|
13
|
-
${ae}`.trim();case p.ZodFirstPartyTypeKind.ZodEnum:return o.values.map(b).join(" | ");case p.ZodFirstPartyTypeKind.ZodEffects:return B(o.schema,s);case p.ZodFirstPartyTypeKind.ZodNativeEnum:throw new
|
|
14
|
-
`).length>=
|
|
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=l(t=>t.declaration?t.declaration===!0?"variable":t.declaration:"none","getDeclarationType"),$d=l((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}l(ya,"getRawTag");var Ld=ya,Vd=Object.prototype,qd=Vd.toString;function va(t){return qd.call(t)}l(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)}l(_a,"baseGetTag");var Le=_a;function Ta(t){return t!=null&&typeof t=="object"}l(Ta,"isObjectLike");var Ue=Ta,Xd="[object Symbol]";function ba(t){return typeof t=="symbol"||Ue(t)&&Le(t)==Xd}l(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}l(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}l(si,"baseToString");var tp=si;function xa(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}l(xa,"isObject");var ut=xa;function ka(t){return t}l(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}l(Sa,"isFunction");var Oa=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 Ea(t){return!!cs&&cs in t}l(Ea,"isMasked");var lp=Ea,cp=Function.prototype,up=cp.toString;function Ia(t){if(t!=null){try{return up.call(t)}catch{}try{return t+""}catch{}}return""}l(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=Oa(t)?yp:pp;return e.test(Ve(t))}l(Za,"baseIsNative");var vp=Za;function Ba(t,e){return t?.[e]}l(Ba,"getValue");var _p=Ba;function Aa(t,e){var n=_p(t,e);return vp(n)?n:void 0}l(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}l(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}l(Ra,"baseAssignValue");var Da=Ra;function Ha(t,e){return t===e||t!==t&&e!==e}l(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)}l(Na,"assignValue");var Sp=Na,Op=9007199254740991;function Ma(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Op}l(Ma,"isLength");var li=Ma;function $a(t){return t!=null&&li(t.length)&&!Oa(t)}l($a,"isArrayLike");var ja=$a,Ep=Object.prototype;function Ka(t){var e=t&&t.constructor,n=typeof e=="function"&&e.prototype||Ep;return t===n}l(Ka,"isPrototype");var Ua=Ka;function Fa(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}l(Fa,"baseTimes");var Ip=Fa,Zp="[object Arguments]";function za(t){return Ue(t)&&Le(t)==Zp}l(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}l(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)]}l(Ga,"baseIsTypedArray");var cf=Ga;function Ja(t){return function(e){return t(e)}}l(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,o=a?Ip(t.length,String):[],c=o.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)))&&o.push(d);return o}l(Qa,"arrayLikeKeys");var eo=Qa;function to(t,e){return function(n){return t(e(n))}}l(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}l(ro,"baseKeys");var Tf=ro;function io(t){return ja(t)?eo(t):Tf(t)}l(io,"keys");var ci=io;function so(t){var e=[];if(t!=null)for(var n in Object(t))e.push(n);return e}l(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}l(ao,"baseKeysIn");var xf=ao;function oo(t){return ja(t)?eo(t,!0):xf(t)}l(oo,"keysIn");var kf=oo,Sf=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Of=/^\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:Of.test(t)||!Sf.test(t)||e!=null&&t in Object(e)}l(lo,"isKey");var ui=lo,Ef=qe(Object,"create"),Kt=Ef;function co(){this.__data__=Kt?Kt(null):{},this.size=0}l(co,"hashClear");var If=co;function uo(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}l(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}l(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)}l(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}l(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])}}l(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}l(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}l(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}l(yo,"listCacheDelete");var Ff=yo;function vo(t){var e=this.__data__,n=Qn(e,t);return n<0?void 0:e[n][1]}l(vo,"listCacheGet");var zf=vo;function _o(t){return Qn(this.__data__,t)>-1}l(_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}l(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])}}l(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}}l(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}l(wo,"isKeyable");var Gf=wo;function Po(t,e){var n=t.__data__;return Gf(e)?n[typeof e=="string"?"string":"hash"]:n.map}l(Po,"getMapData");var tr=Po;function xo(t){var e=tr(this,t).delete(t);return this.size-=e?1:0,e}l(xo,"mapCacheDelete");var Jf=xo;function ko(t){return tr(this,t).get(t)}l(ko,"mapCacheGet");var Yf=ko;function So(t){return tr(this,t).has(t)}l(So,"mapCacheHas");var Xf=So;function Oo(t,e){var n=tr(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this}l(Oo,"mapCacheSet");var Qf=Oo;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])}}l(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=l(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}l(rr,"memoize");rr.Cache=nr;var tg=rr,ng=500;function Eo(t){var e=tg(t,function(r){return n.size===ng&&n.clear(),r}),n=e.cache;return e}l(Eo,"memoizeCapped");var rg=Eo,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)}l(Io,"toString");var lg=Io;function Zo(t,e){return xe(t)?t:ui(t,e)?[t]:og(lg(t))}l(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}l(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}l(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}l(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}l(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}l(Mo,"isPlainObject");var ys=Mo;function $o(){this.__data__=new er,this.size=0}l($o,"stackClear");var yg=$o;function jo(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}l(jo,"stackDelete");var vg=jo;function Ko(t){return this.__data__.get(t)}l(Ko,"stackGet");var _g=Ko;function Uo(t){return this.__data__.has(t)}l(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}l(Fo,"stackSet");var wg=Fo;function Xe(t){var e=this.__data__=new er(t);this.size=e.size}l(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}l(zo,"arrayFilter");var Pg=zo;function Wo(){return[]}l(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,Og=Object.getOwnPropertySymbols,Eg=Og?function(t){for(var e=[];t;)Do(e,Vo(t)),t=Ho(t);return e}:Lo,Ig=Eg;function qo(t,e,n){var r=e(t);return xe(t)?r:Do(r,n(t))}l(qo,"baseGetAllKeys");var Go=qo;function Jo(t){return Go(t,ci,Vo)}l(Jo,"getAllKeys");var _s=Jo;function Yo(t){return Go(t,kf,Ig)}l(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=l(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}l(Xo,"setCacheAdd");var Ug=Xo;function Qo(t){return this.__data__.has(t)}l(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])}l(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}l(el,"arraySome");var Wg=el;function tl(t,e){return t.has(e)}l(tl,"cacheHas");var Lg=tl,Vg=1,qg=2;function nl(t,e,n,r,i,s){var a=n&Vg,o=t.length,c=e.length;if(o!=c&&!(a&&c>o))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<o;){var k=t[m],K=e[m];if(r)var W=a?r(K,k,m,e,t,s):r(k,K,m,t,e,s);if(W!==void 0){if(W)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}l(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}l(il,"mapToArray");var Gg=il;function sl(t){var e=-1,n=Array(t.size);return t.forEach(function(r){n[++e]=r}),n}l(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]",Os=Ze?Ze.prototype:void 0,$r=Os?Os.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 o=Gg;case sm:var c=r&Yg;if(o||(o=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(o(t),o(e),r,i,s,a);return a.delete(t),g;case om:if($r)return $r.call(t)==$r.call(e)}return!1}l(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,o=_s(t),c=o.length,d=_s(e),g=d.length;if(c!=g&&!a)return!1;for(var m=c;m--;){var T=o[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 W=a;++m<c;){T=o[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}W||(W=T=="constructor")}if(K&&!W){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}l(ol,"equalObjects");var gm=ol,mm=1,Es="[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),o=xe(e),c=a?Is:ks(t),d=o?Is:ks(e);c=c==Es?rn:c,d=d==Es?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,W=k?e.value():e;return s||(s=new sn),i(K,W,n,r,s)}}return T?(s||(s=new sn),gm(t,e,n,r,i,s)):!1}l(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)}l(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 o=n[i];if(a&&o[2]?o[1]!==t[o[0]]:!(o[0]in t))return!1}for(;++i<s;){o=n[i];var c=o[0],d=t[c],g=o[1];if(a&&o[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}l(cl,"baseIsMatch");var Tm=cl;function ul(t){return t===t&&!ut(t)}l(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}l(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))}}l(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)}}l(ml,"baseMatches");var wm=ml;function hl(t,e){return t!=null&&e in Object(t)}l(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)))}l(yl,"hasPath");var xm=yl;function vl(t,e){return t!=null&&xm(t,e,Pm)}l(vl,"hasIn");var km=vl,Sm=1,Om=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|Om)}}l(_l,"baseMatchesProperty");var Em=_l;function Tl(t){return function(e){return e?.[t]}}l(Tl,"baseProperty");var Im=Tl;function bl(t){return function(e){return di(e,t)}}l(bl,"basePropertyDeep");var Zm=bl;function wl(t){return ui(t)?Im(Vt(t)):Zm(t)}l(wl,"property");var Bm=wl;function Pl(t){return typeof t=="function"?t:t==null?np:typeof t=="object"?xe(t)?Em(t[0],t[1]):wm(t):Bm(t)}l(Pl,"baseIteratee");var fi=Pl;function xl(t){return function(e,n,r){for(var i=-1,s=Object(e),a=r(e),o=a.length;o--;){var c=a[t?o:++i];if(n(s[c],c,s)===!1)break}return e}}l(xl,"createBaseFor");var Am=xl,Cm=Am(),Rm=Cm;function kl(t,e){return t&&Rm(t,e,ci)}l(kl,"baseForOwn");var Dm=kl;function Sl(t,e){return sr(t,e)}l(Sl,"isEqual");var lt=Sl;function Ol(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}l(Ol,"isEqualWith");var Hm=Ol;function El(t){return t===void 0}l(El,"isUndefined");var Bs=El;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}l(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)}}l(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,o=t;o!=null&&++i<s;){var c=Vt(e[i]),d=n;if(c==="__proto__"||c==="constructor"||c==="prototype")return t;if(i!=a){var g=o[c];d=r?r(g,c,o):void 0,d===void 0&&(d=ut(g)?g:ai(e[i+1])?[]:{})}Sp(o,c,d),o=o[c]}return t}l(Bl,"baseSet");var jm=Bl;function Al(t,e,n){for(var r=-1,i=e.length,s={};++r<i;){var a=e[r],o=di(t,a);n(o,a)&&jm(s,ir(a,t),o)}return s}l(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])})}l(Cl,"pickBy");var Um=Cl;function Rl(t,e){return Um(t,$m(fi(e)))}l(Rl,"omitBy");var As=Rl,Fm=l(t=>{let e=t.checks;return e.length===0?"":e.map(zm).join("")},"generateStringChecks"),zm=l(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=l(t=>{let e=t.checks;return e.length===0?"":e.map(Lm).join("")},"generateNumberChecks"),Lm=l(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=l(t=>{let e=t.checks;return e.length===0?"":e.map(qm).join("")},"generateBigIntChecks"),qm=l(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=l(t=>{let e=t.checks;return e.length===0?"":e.map(Jm).join("")},"generateDateChecks"),Jm=l(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=l(t=>`new Date(${t})`,"dateTs"),Ym=l(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=l(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)}l(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 o=n.options.map(M);return`z.discriminatedUnion(${b(n.discriminator)}, [${o.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 W=n.args.items.map(M),Q=W.length?`.args(${W.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)}}l(M,"sUnwrapZod");var C=l(t=>t.description?`.describe(${b(t.description)})`:"","_maybeDescribe"),R=l(t=>`${Qm(t)}${eh(t)}${th(t)}${nh(t)}${rh(t)}${ih(t)}${sh(t)}`,"_addZuiExtensions"),Qm=l(t=>{var e;return(e=t[w])!=null&&e.title?`.title(${b(t[w].title)})`:""},"_maybeTitle"),eh=l(t=>{var e;return(e=t[w])!=null&&e.displayAs?`.displayAs(${Fs({id:t[w].displayAs[0],params:t[w].displayAs[1]})})`:""},"_maybeDisplayAs"),th=l(t=>{var e;return(e=t[w])!=null&&e.disabled?`.disabled(${t[w].disabled})`:""},"_maybeDisabled"),nh=l(t=>{var e;return(e=t[w])!=null&&e.hidden?`.hidden(${t[w].hidden})`:""},"_maybeHidden"),rh=l(t=>{var e;return(e=t[w])!=null&&e.placeholder?`.placeholder(${b(t[w].placeholder)})`:""},"_maybePlaceholder"),ih=l(t=>{var e;return(e=t[w])!=null&&e.secret?".secret()":""},"_maybeSecret"),sh=l(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=l(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=l(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=l(t=>({precision:uh(t),offset:t.endsWith(`${Hl}$`)}),"extractPrecisionAndOffset"),uh=l(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=l(t=>t.replaceAll(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeSpecialChars");function mi(t,e,n,r){r?.errorMessages&&n&&(t.errorMessage=f(u({},t.errorMessage),{[e]:n}))}l(mi,"addErrorMessage");function D(t,e,n,r,i){t[e]=n,mi(t,e,r,i)}l(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(l(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}l(hi,"parseStringDef");var Re=l((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=l((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=l(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",(n.precision!==null||n.offset)&&(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=l((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=l((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=l((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)]),o=!1;return n.unknownKeys instanceof p.ZodType?o=V(n.unknownKeys):n.unknownKeys==="passthrough"&&(o=!0),{type:"object",description:n.description,properties:Object.fromEntries(a),required:s,additionalProperties:o,"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":f(u({},n["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodDiscriminatedUnion,discriminator:n.discriminator}})};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)}}l(V,"toJSONSchema");var jr=l(t=>({not:!0,description:t?.description,"x-zui":f(u({},t?.["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodUndefined}})}),"undefinedSchema"),Kr=l(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}};l($l,"ParseInputLazyPath");var le=$l,Rs=l((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=l(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),o=l(()=>s.addIssue(u({code:h.custom},r(i))),"setError");return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!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[o,c]of Object.entries(e))a._def[w]=f(u({},a._def[w]),{[o]: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}};l(jl,"ZodType");var E=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=l(i=>i,"assertEqual");function e(i){}t.assertIs=e,l(e,"assertIs");function n(i){throw new Error("assertNever called")}t.assertNever=n,l(n,"assertNever"),t.arrayToEnum=l(i=>{let s={};for(let a of i)s[a]=a;return s},"arrayToEnum"),t.getValidEnumValues=l(i=>{let s=(0,t.objectKeys)(i).filter(o=>typeof i[i[o]]!="number"),a={};for(let o of s)a[o]=i[o];return(0,t.objectValues)(a)},"getValidEnumValues"),t.objectValues=l(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=l((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,l(r,"joinValues"),t.jsonStringifyReplacer=l((i,s)=>typeof s=="bigint"?s.toString():s,"jsonStringifyReplacer"),t.compareFunctions=l((i,s)=>i.toString()===s.toString(),"compareFunctions"),t.mock=l(()=>({}),"mock")})(Z||(Z={}));var gn;(t=>{t.mergeShapes=l((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=l(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 o=a?Object.fromEntries(Object.entries(a).filter(([d])=>d!=="secret"||s?.includes("secret"))):void 0;return e?{errorMap:e,description:i,[w]:o}:{errorMap:l((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]:o}}l(S,"processCreateParams");var vi=l((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=l(t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),mn=class Ul extends Error{constructor(e){super(),this.issues=[],this.addIssue=l(r=>{this.issues=[...this.issues,r]},"addIssue"),this.addIssues=l((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=l(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 o=r,c=0;for(;c<a.path.length;){let d=a.path[c];c===a.path.length-1?(o[d]=o[d]||{_errors:[]},o[d]._errors.push(n(a))):o[d]=o[d]||{_errors:[]},o=o[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()}};l(mn,"ZodError");mn.create=l(t=>new mn(t),"create");var he=mn,Fl=vi;function _i(t){Fl=t}l(_i,"setErrorMap");function dt(){return Fl}l(dt,"getErrorMap");var zt=l(t=>{var e;let{data:n,path:r,errorMaps:i,issueData:s}=t,a=[...r,...s.path||[]],o=f(u({},s),{path:a}),c="",d=i.filter(g=>!!g).slice().reverse();for(let g of d)c=g(o,{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)}l(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}}};l(Wl,"ParseStatus");var ne=Wl,x=Object.freeze({status:"aborted"}),Ke=l(t=>({status:"dirty",value:t}),"DIRTY"),G=l(t=>({status:"valid",value:t}),"OK"),hn=l(t=>t.status==="aborted","isAborted"),yn=l(t=>t.status==="dirty","isDirty"),pt=l(t=>t.status==="valid","isValid"),Wt=l(t=>typeof Promise<"u"&&t instanceof Promise,"isAsync"),P;(t=>{t.errToObj=l(e=>typeof e=="string"?{message:e}:e||{},"errToObj"),t.toString=l(e=>typeof e=="string"?e:e?.message,"toString")})(P||(P={}));var vn=class Vl extends E{constructor(){super(...arguments),this._any=!0}_parse(e){return G(e.data)}isEqual(e){return e instanceof Vl}};l(vn,"ZodAny");vn.create=l(t=>new vn(u({typeName:"ZodAny"},S(t))),"create");var ft=vn,_n=class Ne extends E{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,o;return e instanceof Ne?lt((n=this._def.exactLength)==null?void 0:n.value,(r=e._def.exactLength)==null?void 0:r.value)&<((i=this._def.maxLength)==null?void 0:i.value,(s=e._def.maxLength)==null?void 0:s.value)&<((a=this._def.minLength)==null?void 0:a.value,(o=e._def.minLength)==null?void 0:o.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,o=n.data.length<i.exactLength.value;(a||o)&&(v(n,{code:a?h.too_big:h.too_small,minimum:o?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,o)=>i.type._parseAsync(new le(n,a,n.path,o)))).then(a=>ne.mergeArray(r,a));let s=[...n.data].map((a,o)=>i.type._parseSync(new le(n,a,n.path,o)));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)}};l(_n,"ZodArray");_n.create=l((t,e)=>new _n(u({type:t,minLength:null,maxLength:null,exactLength:null,typeName:"ZodArray"},S(e))),"create");var gt=_n,hh=l((t,e)=>ql(t,e,new WeakSet),"isEqual"),ql=l((t,e,n)=>Hm(t,e,yh(n)),"_isEqualWithVisitedTracking"),yh=l(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))}};l(Gl,"CustomSet");var F=Gl,Tn=class an extends E{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 F(this._def.checks),r=new F(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}};l(Tn,"ZodBigInt");Tn.create=l(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 E{_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}};l(bn,"ZodBoolean");bn.create=l(t=>new bn(u({typeName:"ZodBoolean",coerce:t?.coerce||!1},S(t))),"create");var or=bn,Yl=Symbol("zod_brand"),Xl=class St extends E{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()}))}};l(Xl,"ZodBranded");var lr=Xl,wn=class Ot extends E{_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 Ot?this._def.innerType.isEqual(e._def.innerType)&&Z.compareFunctions(this._def.catchValue,e._def.catchValue):!1}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()}))}naked(){return this._def.innerType.naked()}mandatory(){return new Ot(f(u({},this._def),{innerType:this._def.innerType.mandatory()}))}};l(wn,"ZodCatch");wn.create=l((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=l((t,e={},n)=>t?ft.create().superRefine((r,i)=>{var s,a;if(!t(r)){let o=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e,c=(a=(s=o.fatal)!=null?s:n)!=null?a:!0,d=typeof o=="string"?{message:o}:o;i.addIssue(f(u({code:"custom"},d),{fatal:c}))}}):ft.create(),"custom"),Pn=class Xr extends E{_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 F(this._def.checks),r=new F(e._def.checks);return n.isEqual(r)&&this._def.coerce===e._def.coerce}};l(Pn,"ZodDate");Pn.create=l(t=>new Pn(u({checks:[],coerce:t?.coerce||!1,typeName:"ZodDate"},S(t))),"create");var ur=Pn,xn=class Et extends E{_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 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()}))}isEqual(e){return e instanceof Et?this._def.innerType.isEqual(e._def.innerType)&<(this._def.defaultValue(),e._def.defaultValue()):!1}unwrap(){return this._def.innerType}naked(){return this._def.innerType.naked()}mandatory(){return new Et(f(u({},this._def),{innerType:this._def.innerType.mandatory()}))}};l(xn,"ZodDefault");xn.create=l((t,e,n)=>new xn(u({innerType:t,typeName:"ZodDefault",defaultValue:typeof e=="function"?e:()=>e},S(n))),"create");var qt=xn,Se=l(t=>Array.from(new Set(t)),"unique"),be=l(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 E{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=l((s,a)=>s.isEqual(a),"compare"),r=new F(this._def.options,{compare:n}),i=new F(e._def.options,{compare:n});return r.isEqual(i)}};l(Ql,"ZodDiscriminatedUnion");var bi=Ql;function Gt(t,e){return new Qe(u({values:t,typeName:"ZodEnum"},S(e)))}l(Gt,"createZodEnum");var wi=class on extends E{_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 F(this._def.values),r=new F(e._def.values);return n.isEqual(r)}};l(wi,"ZodEnum");wi.create=Gt;var Qe=wi,ec=class $e extends E{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(o,c){return zt({data:o,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,dt(),Ds].filter(d=>!!d),issueData:{code:h.invalid_arguments,argumentsError:c}})}l(r,"makeArgsIssue");function i(o,c){return zt({data:o,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,dt(),Ds].filter(d=>!!d),issueData:{code:h.invalid_return_type,returnTypeError:c}})}l(i,"makeReturnsIssue");let s={errorMap:n.common.contextualErrorMap},a=n.data;if(this._def.returns instanceof Jt){let o=this;return G(async function(...c){let d=new he([]),g=await o._def.args.parseAsync(c,s).catch(I=>{throw d.addIssue(r(c,I)),d}),m=await Reflect.apply(a,this,g);return await o._def.returns._def.type.parseAsync(m,s).catch(I=>{throw d.addIssue(i(m,I)),d})})}else{let o=this;return G(function(...c){let d=o._def.args.safeParse(c,s);if(!d.success)throw new he([r(c,d.error)]);let g=Reflect.apply(a,this,d.data),m=o._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)}};l(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(o=>i.indexOf(o)!==-1),a=u(u({},t),e);for(let o of s){let c=kn(t[o],e[o]);if(!c.valid)return{valid:!1};a[o]=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],o=e[s],c=kn(a,o);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}}l(kn,"mergeValues");var Sn=class ln extends E{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=l((s,a)=>{if(hn(s)||hn(a))return x;let o=kn(s.value,a.value);return o.valid?((yn(s)||yn(a))&&n.dirty(),{status:n.value,value:o.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=l((s,a)=>s.isEqual(a),"compare"),r=new F([this._def.left,this._def.right],{compare:n}),i=new F([e._def.left,e._def.right],{compare:n});return r.isEqual(i)}};l(Sn,"ZodIntersection");Sn.create=l((t,e,n)=>new Sn(u({left:t,right:e,typeName:"ZodIntersection"},S(n))),"create");var dr=Sn,On=class It extends E{get schema(){return this._def.getter()}dereference(e){return new It(f(u({},this._def),{getter:l(()=>this._def.getter().dereference(e),"getter")}))}getReferences(){return this._def.getter().getReferences()}clone(){return new It(f(u({},this._def),{getter:l(()=>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:l(()=>this._def.getter().mandatory(),"getter")}))}};l(On,"ZodLazy");On.create=l((t,e)=>new On(u({getter:t,typeName:"ZodLazy"},S(e))),"create");var pr=On,En=class tc extends E{_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}};l(En,"ZodLiteral");En.create=l((t,e)=>new En(u({value:t,typeName:"ZodLiteral"},S(e))),"create");var fr=En,In=class cn extends E{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(([o,c],d)=>({key:i._parse(new le(r,o,r.path,[d,"key"])),value:s._parse(new le(r,c,r.path,[d,"value"]))}));if(r.common.async){let o=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(),o.set(d.value,g.value)}return{status:n.value,value:o}})}else{let o=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(),o.set(d.value,g.value)}return{status:n.value,value:o}}}isEqual(e){return!(!(e instanceof cn)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};l(In,"ZodMap");In.create=l((t,e,n)=>new In(u({valueType:e,keyType:t,typeName:"ZodMap"},S(n))),"create");var xi=In,Zn=class nc extends E{_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}};l(Zn,"ZodNaN");Zn.create=l(t=>new Zn(u({typeName:"ZodNaN"},S(t))),"create");var ki=Zn,Bn=class rc extends E{_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}};l(Bn,"ZodNativeEnum");Bn.create=l((t,e)=>new Bn(u({values:t,typeName:"ZodNativeEnum"},S(e))),"create");var gr=Bn,An=class ic extends E{_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}};l(An,"ZodNever");An.create=l(t=>new An(u({typeName:"ZodNever"},S(t))),"create");var yt=An,Cn=class sc extends E{_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}};l(Cn,"ZodNull");Cn.create=l(t=>new Cn(u({typeName:"ZodNull"},S(t))),"create");var mr=Cn,Rn=class Zt extends E{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()}))}};l(Rn,"ZodNullable");Rn.create=l((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)}l(ac,"floatSafeRemainder");var Dn=class un extends E{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 F(this._def.checks),r=new F(e._def.checks);return n.isEqual(r)}};l(Dn,"ZodNumber");Dn.create=l(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:l(()=>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}l(je,"deepPartialify");var Be=class se extends E{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:l(()=>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:l(()=>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(),o=[];if(this._def.unknownKeys!=="strip")for(let g in i.data)a.includes(g)||o.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 o)c.push({key:{status:"valid",value:g},value:{status:"valid",value:i.data[g]}});else if(d==="strict")o.length>0&&(v(i,{code:h.unrecognized_keys,keys:o}),r.dirty());else if(d!=="strip")for(let g of o){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:l((n,r)=>{var i,s,a,o;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:(o=P.errToObj(e).message)!=null?o: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 E)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:l(()=>u(u({},this._def.shape()),e),"shape")}))}merge(e){return new se({unknownKeys:e._def.unknownKeys,shape:l(()=>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:l(()=>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:l(()=>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:l(()=>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:l(()=>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=l((o,c)=>o[0]===c[0]&&o[1].isEqual(c[1]),"compare"),s=new F(Object.entries(n),{compare:i}),a=new F(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)}};l(Be,"ZodObject");Be.create=l((t,e)=>new Be(u({shape:l(()=>t,"shape"),unknownKeys:"strip",typeName:"ZodObject"},S(e))),"create");Be.strictCreate=l((t,e)=>new Be(u({shape:l(()=>t,"shape"),unknownKeys:"strict",typeName:"ZodObject"},S(e))),"strictCreate");Be.lazycreate=l((t,e)=>new Be(u({shape:t,unknownKeys:"strip",typeName:"ZodObject"},S(e))),"lazycreate");var ze=Be,Hn=class dn extends E{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()}};l(Hn,"ZodOptional");Hn.create=l((t,e)=>new Hn(u({innerType:t,typeName:"ZodOptional"},S(e))),"create");var Pe=Hn,oc=class Bt extends E{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 l(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))}};l(oc,"ZodPipeline");var yr=oc,Nn=class pn extends E{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()}};l(Nn,"ZodPromise");Nn.create=l((t,e)=>new Nn(u({type:t,typeName:"ZodPromise"},S(e))),"create");var Jt=Nn,Mn=class At extends E{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()}))}};l(Mn,"ZodReadonly");Mn.create=l((t,e)=>new Mn(u({innerType:t,typeName:"ZodReadonly"},S(e))),"create");var Yt=Mn,lc=class it extends E{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 o in r.data)i.push({key:s._parse(new le(r,o,r.path,o)),value:a._parse(new le(r,r.data[o],r.path,o))});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 E?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))}};l(lc,"ZodRecord");var Si=lc,$n=class cc extends E{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}};l($n,"ZodRef");$n.create=l(t=>new $n({typeName:"ZodRef",uri:t}),"create");var Oi=$n,jn=class st extends E{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}}l(a,"finalizeSet");let o=[...r.data.values()].map((c,d)=>s._parse(new le(r,c,r.path,d)));return r.common.async?Promise.all(o).then(c=>a(c)):a(o)}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,o=(r=e._def.minSize)==null?void 0:r.value;if(a!==o)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)}};l(jn,"ZodSet");jn.create=l((t,e)=>new jn(u({valueType:t,minSize:null,maxSize:null,typeName:"ZodSet"},S(e))),"create");var Ei=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=l(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))}l(pc,"isValidIP");var Kn=class at extends E{_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,o=e.data.length<s.value;(a||o)&&(i=this._getOrReturnCtx(e,i),a?v(i,{code:h.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&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 F(this._def.checks),r=new F(e._def.checks);return n.isEqual(r)}};l(Kn,"ZodString");Kn.create=l(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 E{_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}};l(Un,"ZodSymbol");Un.create=l(t=>new Un(u({typeName:"ZodSymbol"},S(t))),"create");var Hi=Un,mt=class Ct extends E{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:l(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 o=>{if(n.value==="aborted")return x;let c=await this._def.schema._parseAsync({data:o,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 o=this._def.schema._parseSync({data:a,path:r.path,parent:r});return o.status==="aborted"?x:o.status==="dirty"||n.value==="dirty"?Ke(o.value):o}}if(i.type==="refinement"){let a=l(o=>{let c=i.refinement(o,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 o},"executeRefinement");if(r.common.async===!1){let o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?x:(o.status==="dirty"&&n.dirty(),a(o.value),{status:n.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?x:(o.status==="dirty"&&n.dirty(),a(o.value).then(()=>({status:n.value,value:o.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 o=i.transform(a.value,s);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:o}}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(o=>({status:n.value,value:o})):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()}))}};l(mt,"ZodEffects");mt.create=l((t,e,n)=>new mt(u({schema:t,typeName:"ZodEffects",effect:e},S(n))),"create");mt.createWithPreprocess=l((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 E{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,o)=>{let c=this._def.items[o]||this._def.rest;return c?c._parse(new le(r,a,r.path,o)):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=l((s,a)=>s.isEqual(a),"compare"),r=new F(this._def.items,{compare:n}),i=new F(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)}};l(Fn,"ZodTuple");Fn.create=l((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 E{_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))}};l(zn,"ZodUndefined");zn.create=l(t=>new zn(u({typeName:"ZodUndefined"},S(t))),"create");var Xt=zn,Wn=class Dt extends E{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 o of s)if(o.result.status==="valid")return o.result;for(let o of s)if(o.result.status==="dirty")return n.common.issues.push(...o.ctx.common.issues),o.result;let a=s.map(o=>new he(o.ctx.common.issues));return v(n,{code:h.invalid_union,unionErrors:a}),x}if(l(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 o=a.map(c=>new he(c));return v(n,{code:h.invalid_union,unionErrors:o}),x}}get options(){return this._def.options}isEqual(e){if(!(e instanceof Dt))return!1;let n=l((s,a)=>s.isEqual(a),"compare"),r=new F([...this._def.options],{compare:n}),i=new F([...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))}};l(Wn,"ZodUnion");Wn.create=l((t,e)=>new Wn(u({options:t,typeName:"ZodUnion"},S(e))),"create");var vr=Wn,Ln=class mc extends E{constructor(){super(...arguments),this._unknown=!0}_parse(e){return G(e.data)}isEqual(e){return e instanceof mc}};l(Ln,"ZodUnknown");Ln.create=l(t=>new Ln(u({typeName:"ZodUnknown"},S(t))),"create");var ct=Ln,Vn=class hc extends E{_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}};l(Vn,"ZodVoid");Vn.create=l(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"],Rv=Qe.create(["any","string","number","boolean","object","pattern","date","array","target","time","enum"]),yc=l(t=>J.create().displayAs({id:"variable",params:u({type:t?.type||"any"},t?.params)}),"variable"),vc=l(t=>J.create().displayAs({id:"conversation",params:u({},t?.params)}),"conversation"),_c=l(t=>J.create().displayAs({id:"user",params:u({},t?.params)}),"user"),Tc=l(t=>J.create().displayAs({id:"message",params:u({},t?.params)}),"message"),bc=l(t=>J.create().displayAs({id:"agent",params:u({},t?.params)}),"agent"),wc=l(t=>J.create().displayAs({id:"event",params:u({},t?.params)}),"event"),Pc=l(t=>J.create().displayAs({id:"table",params:u({},t?.params)}),"table"),xc=l(t=>J.create().displayAs({id:"tablerow",params:u({},t?.params)}),"tablerow"),kc=l(t=>J.create().displayAs({id:"intent",params:u({},t?.params)}),"intent"),Sc=l(()=>Qe.create(_h).displayAs({id:"dropdown",params:{}}),"aimodel"),Oc=l(t=>J.create().displayAs({id:"datasource",params:u({},t)}),"datasource"),Ec=l(t=>J.create().displayAs({id:"knowledgebase",params:u({},t)}),"knowledgebase"),Ic={object:ze.lazycreate},Zc=l((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=Oi.create,Jc=Yt.create,Yc=xi.create,Xc=Ei.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=l(()=>Mi().optional(),"ostring"),uu=l(()=>$i().optional(),"onumber"),du=l(()=>ji().optional(),"oboolean"),pu={string:l(t=>J.create(f(u({},t),{coerce:!0})),"string"),number:l(t=>hr.create(f(u({},t),{coerce:!0})),"number"),boolean:l(t=>or.create(f(u({},t),{coerce:!0})),"boolean"),bigint:l(t=>ar.create(f(u({},t),{coerce:!0})),"bigint"),date:l(t=>ur.create(f(u({},t),{coerce:!0})),"date")},fu=x,p=y,gu=l((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=l(t=>{var e;return(e=t[w])!=null&&e.coerce?"z.coerce.boolean()":"z.boolean()"},"parseBoolean"),wh=l(t=>"z.any()","parseDefault"),Ph=l((t,e)=>`z.union([${t.type.map(n=>L(f(u({},t),{type:n}),e)).join(", ")}])`,"parseMultipleType"),xh=l((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=l(t=>"z.null()","parseNull"),Sh=l(t=>[t.slice(0,t.length/2),t.slice(t.length/2)],"half"),Oh=l((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 o=a[0],c=a.length===3?a[1]:"",d=a.length===3?a[2]:a[1];s+=o,((r=t.errorMessage)==null?void 0:r[e])!==void 0&&(s+=c+JSON.stringify(t.errorMessage[e])),s+=d}}return s}l(q,"withMessage");var Ht=Symbol("Original index"),Eh=l(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(Eh(t.allOf));return`z.intersection(${Lt({allOf:n},e)}, ${Lt({allOf:r},e)})`}}l(Lt,"parseAllOf");var Ih=l((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=l(t=>`z.literal(${JSON.stringify(t.const)})`,"parseConst"),Bh=l(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=l((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
|
-
if (!result.success) {
|
|
21
|
-
result.error.errors.forEach((error) => ctx.addIssue(error))
|
|
22
|
-
}
|
|
23
|
-
})`},"parseIfThenElse"),Ch=l(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=l((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) => {
|
|
13
|
+
(${K}) => ${W}`;case p.ZodFirstPartyTypeKind.ZodLazy:return B(o.getter(),s);case p.ZodFirstPartyTypeKind.ZodLiteral:let ae=Zl(o.value);return`${z(a.description)}
|
|
14
|
+
${ae}`.trim();case p.ZodFirstPartyTypeKind.ZodEnum:return o.values.map(b).join(" | ");case p.ZodFirstPartyTypeKind.ZodEffects:return B(o.schema,s);case p.ZodFirstPartyTypeKind.ZodNativeEnum:throw new na(p.ZodFirstPartyTypeKind.ZodNativeEnum);case p.ZodFirstPartyTypeKind.ZodOptional:return`${B(o.innerType,s)} | undefined`;case p.ZodFirstPartyTypeKind.ZodNullable:return`${B(o.innerType,s)} | null`;case p.ZodFirstPartyTypeKind.ZodDefault:let oe=e.treatDefaultAsOptional?o.innerType.optional():o.innerType;return B(oe,s);case p.ZodFirstPartyTypeKind.ZodCatch:return B(o.innerType,s);case p.ZodFirstPartyTypeKind.ZodPromise:return`Promise<${B(o.type,s)}>`;case p.ZodFirstPartyTypeKind.ZodBranded:return B(o.type,s);case p.ZodFirstPartyTypeKind.ZodPipeline:return B(o.in,s);case p.ZodFirstPartyTypeKind.ZodSymbol:return`${z(a.description)} symbol`.trim();case p.ZodFirstPartyTypeKind.ZodReadonly:return`Readonly<${B(o.innerType,s)}>`;case p.ZodFirstPartyTypeKind.ZodRef:return Al(o.uri);default:Z.assertNever(o)}}l(B,"sUnwrapZod");var fh=l((t,e)=>{if(t.props.type==="none")return B(t.props.schema,e);let{schema:n,identifier:r}=t.props,i=z(n.description),s=n.describe(""),a=B(s,f(u({},e),{declaration:!0})),c=a.split(`
|
|
15
|
+
`).length>=uh&&e.includeClosingTags?`// end of ${r}`:"";if(t.props.type!=="type"&&n instanceof p.ZodFunction)return Kr(`${i}
|
|
16
|
+
declare function ${r}${a};${c}`);if(t.props.type==="variable")return Kr(`${i}declare const ${r}: ${a};${c}`);let d=t.props.args.length>0?`<${t.props.args.map(Al).join(", ")}>`:"";return Kr(`${i}type ${t.props.identifier}${d} = ${a};${c}`)},"unwrapDeclaration"),gh=l(t=>t.declaration?t.declaration===!0?"variable":t.declaration:"none","getDeclarationType"),mh=l((t,e)=>{let n=gh(e),r=t.getReferences();if(n==="none"){if(r.length>0)throw new zr;return new jt({type:"none",schema:t})}let i="title"in t.ui?t.ui.title:null;if(!i)throw new ia;if(n==="variable"){if(r.length>0)throw new zr;return new jt({type:"variable",identifier:i,schema:t})}return new jt({type:"type",identifier:i,schema:t,args:r})},"getDeclarationProps"),$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}};l($l,"ParseInputLazyPath");var le=$l,Rs=l((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=l(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),o=l(()=>s.addIssue(u({code:h.custom},r(i))),"setError");return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!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[o,c]of Object.entries(e))a._def[w]=f(u({},a._def[w]),{[o]: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 hi(this,e)}toTypescriptSchema(){return mi(this)}naked(){return this}};l(jl,"ZodType");var E=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=l(i=>i,"assertEqual");function e(i){}t.assertIs=e,l(e,"assertIs");function n(i){throw new Error("assertNever called")}t.assertNever=n,l(n,"assertNever"),t.arrayToEnum=l(i=>{let s={};for(let a of i)s[a]=a;return s},"arrayToEnum"),t.getValidEnumValues=l(i=>{let s=(0,t.objectKeys)(i).filter(o=>typeof i[i[o]]!="number"),a={};for(let o of s)a[o]=i[o];return(0,t.objectValues)(a)},"getValidEnumValues"),t.objectValues=l(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=l((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,l(r,"joinValues"),t.jsonStringifyReplacer=l((i,s)=>typeof s=="bigint"?s.toString():s,"jsonStringifyReplacer"),t.compareFunctions=l((i,s)=>i.toString()===s.toString(),"compareFunctions"),t.mock=l(()=>({}),"mock")})(Z||(Z={}));var gn;(t=>{t.mergeShapes=l((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=l(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 o=a?Object.fromEntries(Object.entries(a).filter(([d])=>d!=="secret"||s?.includes("secret"))):void 0;return e?{errorMap:e,description:i,[w]:o}:{errorMap:l((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]:o}}l(S,"processCreateParams");var vi=l((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=l(t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),mn=class Ul extends Error{constructor(e){super(),this.issues=[],this.addIssue=l(r=>{this.issues=[...this.issues,r]},"addIssue"),this.addIssues=l((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=l(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 o=r,c=0;for(;c<a.path.length;){let d=a.path[c];c===a.path.length-1?(o[d]=o[d]||{_errors:[]},o[d]._errors.push(n(a))):o[d]=o[d]||{_errors:[]},o=o[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()}};l(mn,"ZodError");mn.create=l(t=>new mn(t),"create");var he=mn,Fl=vi;function _i(t){Fl=t}l(_i,"setErrorMap");function dt(){return Fl}l(dt,"getErrorMap");var zt=l(t=>{var e;let{data:n,path:r,errorMaps:i,issueData:s}=t,a=[...r,...s.path||[]],o=f(u({},s),{path:a}),c="",d=i.filter(g=>!!g).slice().reverse();for(let g of d)c=g(o,{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)}l(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}}};l(Wl,"ParseStatus");var ne=Wl,x=Object.freeze({status:"aborted"}),Ke=l(t=>({status:"dirty",value:t}),"DIRTY"),G=l(t=>({status:"valid",value:t}),"OK"),hn=l(t=>t.status==="aborted","isAborted"),yn=l(t=>t.status==="dirty","isDirty"),pt=l(t=>t.status==="valid","isValid"),Wt=l(t=>typeof Promise<"u"&&t instanceof Promise,"isAsync"),P;(t=>{t.errToObj=l(e=>typeof e=="string"?{message:e}:e||{},"errToObj"),t.toString=l(e=>typeof e=="string"?e:e?.message,"toString")})(P||(P={}));var vn=class Vl extends E{constructor(){super(...arguments),this._any=!0}_parse(e){return G(e.data)}isEqual(e){return e instanceof Vl}};l(vn,"ZodAny");vn.create=l(t=>new vn(u({typeName:"ZodAny"},S(t))),"create");var ft=vn,_n=class Ne extends E{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,o;return e instanceof Ne?ot((n=this._def.exactLength)==null?void 0:n.value,(r=e._def.exactLength)==null?void 0:r.value)&&ot((i=this._def.maxLength)==null?void 0:i.value,(s=e._def.maxLength)==null?void 0:s.value)&&ot((a=this._def.minLength)==null?void 0:a.value,(o=e._def.minLength)==null?void 0:o.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,o=n.data.length<i.exactLength.value;(a||o)&&(v(n,{code:a?h.too_big:h.too_small,minimum:o?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,o)=>i.type._parseAsync(new le(n,a,n.path,o)))).then(a=>ne.mergeArray(r,a));let s=[...n.data].map((a,o)=>i.type._parseSync(new le(n,a,n.path,o)));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)}};l(_n,"ZodArray");_n.create=l((t,e)=>new _n(u({type:t,minLength:null,maxLength:null,exactLength:null,typeName:"ZodArray"},S(e))),"create");var gt=_n,hh=l((t,e)=>ql(t,e,new WeakSet),"isEqual"),ql=l((t,e,n)=>$m(t,e,yh(n)),"_isEqualWithVisitedTracking"),yh=l(t=>(e,n)=>{if(fs(e)&&!t.has(e)&&fs(n)&&!t.has(n)){let r=Es(e,Os),i=Es(n,Os);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))}};l(Gl,"CustomSet");var F=Gl,Tn=class an extends E{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 F(this._def.checks),r=new F(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}};l(Tn,"ZodBigInt");Tn.create=l(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 E{_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}};l(bn,"ZodBoolean");bn.create=l(t=>new bn(u({typeName:"ZodBoolean",coerce:t?.coerce||!1},S(t))),"create");var or=bn,Yl=Symbol("zod_brand"),Xl=class St extends E{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()}))}};l(Xl,"ZodBranded");var lr=Xl,wn=class Ot extends E{_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 Ot?this._def.innerType.isEqual(e._def.innerType)&&Z.compareFunctions(this._def.catchValue,e._def.catchValue):!1}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()}))}naked(){return this._def.innerType.naked()}mandatory(){return new Ot(f(u({},this._def),{innerType:this._def.innerType.mandatory()}))}};l(wn,"ZodCatch");wn.create=l((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=l((t,e={},n)=>t?ft.create().superRefine((r,i)=>{var s,a;if(!t(r)){let o=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e,c=(a=(s=o.fatal)!=null?s:n)!=null?a:!0,d=typeof o=="string"?{message:o}:o;i.addIssue(f(u({code:"custom"},d),{fatal:c}))}}):ft.create(),"custom"),Pn=class Xr extends E{_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 F(this._def.checks),r=new F(e._def.checks);return n.isEqual(r)&&this._def.coerce===e._def.coerce}};l(Pn,"ZodDate");Pn.create=l(t=>new Pn(u({checks:[],coerce:t?.coerce||!1,typeName:"ZodDate"},S(t))),"create");var ur=Pn,xn=class Et extends E{_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 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()}))}isEqual(e){return e instanceof Et?this._def.innerType.isEqual(e._def.innerType)&&ot(this._def.defaultValue(),e._def.defaultValue()):!1}unwrap(){return this._def.innerType}naked(){return this._def.innerType.naked()}mandatory(){return new Et(f(u({},this._def),{innerType:this._def.innerType.mandatory()}))}};l(xn,"ZodDefault");xn.create=l((t,e,n)=>new xn(u({innerType:t,typeName:"ZodDefault",defaultValue:typeof e=="function"?e:()=>e},S(n))),"create");var qt=xn,Se=l(t=>Array.from(new Set(t)),"unique"),be=l(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 E{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=l((s,a)=>s.isEqual(a),"compare"),r=new F(this._def.options,{compare:n}),i=new F(e._def.options,{compare:n});return r.isEqual(i)}};l(Ql,"ZodDiscriminatedUnion");var bi=Ql;function Gt(t,e){return new Qe(u({values:t,typeName:"ZodEnum"},S(e)))}l(Gt,"createZodEnum");var wi=class on extends E{_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 F(this._def.values),r=new F(e._def.values);return n.isEqual(r)}};l(wi,"ZodEnum");wi.create=Gt;var Qe=wi,ec=class $e extends E{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(o,c){return zt({data:o,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,dt(),Ds].filter(d=>!!d),issueData:{code:h.invalid_arguments,argumentsError:c}})}l(r,"makeArgsIssue");function i(o,c){return zt({data:o,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,dt(),Ds].filter(d=>!!d),issueData:{code:h.invalid_return_type,returnTypeError:c}})}l(i,"makeReturnsIssue");let s={errorMap:n.common.contextualErrorMap},a=n.data;if(this._def.returns instanceof Jt){let o=this;return G(async function(...c){let d=new he([]),g=await o._def.args.parseAsync(c,s).catch(I=>{throw d.addIssue(r(c,I)),d}),m=await Reflect.apply(a,this,g);return await o._def.returns._def.type.parseAsync(m,s).catch(I=>{throw d.addIssue(i(m,I)),d})})}else{let o=this;return G(function(...c){let d=o._def.args.safeParse(c,s);if(!d.success)throw new he([r(c,d.error)]);let g=Reflect.apply(a,this,d.data),m=o._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)}};l(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(o=>i.indexOf(o)!==-1),a=u(u({},t),e);for(let o of s){let c=kn(t[o],e[o]);if(!c.valid)return{valid:!1};a[o]=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],o=e[s],c=kn(a,o);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}}l(kn,"mergeValues");var Sn=class ln extends E{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=l((s,a)=>{if(hn(s)||hn(a))return x;let o=kn(s.value,a.value);return o.valid?((yn(s)||yn(a))&&n.dirty(),{status:n.value,value:o.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=l((s,a)=>s.isEqual(a),"compare"),r=new F([this._def.left,this._def.right],{compare:n}),i=new F([e._def.left,e._def.right],{compare:n});return r.isEqual(i)}};l(Sn,"ZodIntersection");Sn.create=l((t,e,n)=>new Sn(u({left:t,right:e,typeName:"ZodIntersection"},S(n))),"create");var dr=Sn,On=class It extends E{get schema(){return this._def.getter()}dereference(e){return new It(f(u({},this._def),{getter:()=>this._def.getter().dereference(e)}))}getReferences(){return this._def.getter().getReferences()}clone(){return new It(f(u({},this._def),{getter:()=>this._def.getter().clone()}))}_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:()=>this._def.getter().mandatory()}))}};l(On,"ZodLazy");On.create=l((t,e)=>new On(u({getter:t,typeName:"ZodLazy"},S(e))),"create");var pr=On,En=class tc extends E{_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?ot(this._def.value,e._def.value):!1}};l(En,"ZodLiteral");En.create=l((t,e)=>new En(u({value:t,typeName:"ZodLiteral"},S(e))),"create");var fr=En,In=class cn extends E{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(([o,c],d)=>({key:i._parse(new le(r,o,r.path,[d,"key"])),value:s._parse(new le(r,c,r.path,[d,"value"]))}));if(r.common.async){let o=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(),o.set(d.value,g.value)}return{status:n.value,value:o}})}else{let o=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(),o.set(d.value,g.value)}return{status:n.value,value:o}}}isEqual(e){return!(!(e instanceof cn)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};l(In,"ZodMap");In.create=l((t,e,n)=>new In(u({valueType:e,keyType:t,typeName:"ZodMap"},S(n))),"create");var xi=In,Zn=class nc extends E{_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}};l(Zn,"ZodNaN");Zn.create=l(t=>new Zn(u({typeName:"ZodNaN"},S(t))),"create");var ki=Zn,Bn=class rc extends E{_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?ot(this._def.values,e._def.values):!1}};l(Bn,"ZodNativeEnum");Bn.create=l((t,e)=>new Bn(u({values:t,typeName:"ZodNativeEnum"},S(e))),"create");var gr=Bn,An=class ic extends E{_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}};l(An,"ZodNever");An.create=l(t=>new An(u({typeName:"ZodNever"},S(t))),"create");var yt=An,Cn=class sc extends E{_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}};l(Cn,"ZodNull");Cn.create=l(t=>new Cn(u({typeName:"ZodNull"},S(t))),"create");var mr=Cn,Rn=class Zt extends E{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()}))}};l(Rn,"ZodNullable");Rn.create=l((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)}l(ac,"floatSafeRemainder");var Dn=class un extends E{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 F(this._def.checks),r=new F(e._def.checks);return n.isEqual(r)}};l(Dn,"ZodNumber");Dn.create=l(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:()=>e}))}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}l(je,"deepPartialify");var Be=class se extends E{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:()=>r}))}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:()=>e}))}_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(),o=[];if(this._def.unknownKeys!=="strip")for(let g in i.data)a.includes(g)||o.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 o)c.push({key:{status:"valid",value:g},value:{status:"valid",value:i.data[g]}});else if(d==="strict")o.length>0&&(v(i,{code:h.unrecognized_keys,keys:o}),r.dirty());else if(d!=="strip")for(let g of o){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:(n,r)=>{var i,s,a,o;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:(o=P.errToObj(e).message)!=null?o:c}:{message:c}}}:{}))}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 E)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:()=>u(u({},this._def.shape()),e)}))}merge(e){return new se({unknownKeys:e._def.unknownKeys,shape:()=>u(u({},this._def.shape()),e._def.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:()=>n}))}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:()=>n}))}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:()=>n}))}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:()=>n}))}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=l((o,c)=>o[0]===c[0]&&o[1].isEqual(c[1]),"compare"),s=new F(Object.entries(n),{compare:i}),a=new F(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)}};l(Be,"ZodObject");Be.create=l((t,e)=>new Be(u({shape:()=>t,unknownKeys:"strip",typeName:"ZodObject"},S(e))),"create");Be.strictCreate=l((t,e)=>new Be(u({shape:()=>t,unknownKeys:"strict",typeName:"ZodObject"},S(e))),"strictCreate");Be.lazycreate=l((t,e)=>new Be(u({shape:t,unknownKeys:"strip",typeName:"ZodObject"},S(e))),"lazycreate");var ze=Be,Hn=class dn extends E{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()}};l(Hn,"ZodOptional");Hn.create=l((t,e)=>new Hn(u({innerType:t,typeName:"ZodOptional"},S(e))),"create");var Pe=Hn,oc=class Bt extends E{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 l(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))}};l(oc,"ZodPipeline");var yr=oc,Nn=class pn extends E{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()}};l(Nn,"ZodPromise");Nn.create=l((t,e)=>new Nn(u({type:t,typeName:"ZodPromise"},S(e))),"create");var Jt=Nn,Mn=class At extends E{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()}))}};l(Mn,"ZodReadonly");Mn.create=l((t,e)=>new Mn(u({innerType:t,typeName:"ZodReadonly"},S(e))),"create");var Yt=Mn,lc=class it extends E{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 o in r.data)i.push({key:s._parse(new le(r,o,r.path,o)),value:a._parse(new le(r,r.data[o],r.path,o))});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 E?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))}};l(lc,"ZodRecord");var Si=lc,$n=class cc extends E{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}};l($n,"ZodRef");$n.create=l(t=>new $n({typeName:"ZodRef",uri:t}),"create");var Oi=$n,jn=class st extends E{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}}l(a,"finalizeSet");let o=[...r.data.values()].map((c,d)=>s._parse(new le(r,c,r.path,d)));return r.common.async?Promise.all(o).then(c=>a(c)):a(o)}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,o=(r=e._def.minSize)==null?void 0:r.value;if(a!==o)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)}};l(jn,"ZodSet");jn.create=l((t,e)=>new jn(u({valueType:t,minSize:null,maxSize:null,typeName:"ZodSet"},S(e))),"create");var Ei=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=l(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))}l(pc,"isValidIP");var Kn=class at extends E{_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,o=e.data.length<s.value;(a||o)&&(i=this._getOrReturnCtx(e,i),a?v(i,{code:h.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&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"?ca(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 F(this._def.checks),r=new F(e._def.checks);return n.isEqual(r)}};l(Kn,"ZodString");Kn.create=l(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 E{_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}};l(Un,"ZodSymbol");Un.create=l(t=>new Un(u({typeName:"ZodSymbol"},S(t))),"create");var Hi=Un,mt=class Ct extends E{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:a=>{v(r,a),a.fatal?n.abort():n.dirty()},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 o=>{if(n.value==="aborted")return x;let c=await this._def.schema._parseAsync({data:o,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 o=this._def.schema._parseSync({data:a,path:r.path,parent:r});return o.status==="aborted"?x:o.status==="dirty"||n.value==="dirty"?Ke(o.value):o}}if(i.type==="refinement"){let a=l(o=>{let c=i.refinement(o,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 o},"executeRefinement");if(r.common.async===!1){let o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?x:(o.status==="dirty"&&n.dirty(),a(o.value),{status:n.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?x:(o.status==="dirty"&&n.dirty(),a(o.value).then(()=>({status:n.value,value:o.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 o=i.transform(a.value,s);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:o}}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(o=>({status:n.value,value:o})):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()}))}};l(mt,"ZodEffects");mt.create=l((t,e,n)=>new mt(u({schema:t,typeName:"ZodEffects",effect:e},S(n))),"create");mt.createWithPreprocess=l((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 E{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,o)=>{let c=this._def.items[o]||this._def.rest;return c?c._parse(new le(r,a,r.path,o)):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=l((s,a)=>s.isEqual(a),"compare"),r=new F(this._def.items,{compare:n}),i=new F(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)}};l(Fn,"ZodTuple");Fn.create=l((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 E{_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))}};l(zn,"ZodUndefined");zn.create=l(t=>new zn(u({typeName:"ZodUndefined"},S(t))),"create");var Xt=zn,Wn=class Dt extends E{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 o of s)if(o.result.status==="valid")return o.result;for(let o of s)if(o.result.status==="dirty")return n.common.issues.push(...o.ctx.common.issues),o.result;let a=s.map(o=>new he(o.ctx.common.issues));return v(n,{code:h.invalid_union,unionErrors:a}),x}if(l(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 o=a.map(c=>new he(c));return v(n,{code:h.invalid_union,unionErrors:o}),x}}get options(){return this._def.options}isEqual(e){if(!(e instanceof Dt))return!1;let n=l((s,a)=>s.isEqual(a),"compare"),r=new F([...this._def.options],{compare:n}),i=new F([...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))}};l(Wn,"ZodUnion");Wn.create=l((t,e)=>new Wn(u({options:t,typeName:"ZodUnion"},S(e))),"create");var vr=Wn,Ln=class mc extends E{constructor(){super(...arguments),this._unknown=!0}_parse(e){return G(e.data)}isEqual(e){return e instanceof mc}};l(Ln,"ZodUnknown");Ln.create=l(t=>new Ln(u({typeName:"ZodUnknown"},S(t))),"create");var ct=Ln,Vn=class hc extends E{_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}};l(Vn,"ZodVoid");Vn.create=l(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"],Rv=Qe.create(["any","string","number","boolean","object","pattern","date","array","target","time","enum"]),yc=l(t=>J.create().displayAs({id:"variable",params:u({type:t?.type||"any"},t?.params)}),"variable"),vc=l(t=>J.create().displayAs({id:"conversation",params:u({},t?.params)}),"conversation"),_c=l(t=>J.create().displayAs({id:"user",params:u({},t?.params)}),"user"),Tc=l(t=>J.create().displayAs({id:"message",params:u({},t?.params)}),"message"),bc=l(t=>J.create().displayAs({id:"agent",params:u({},t?.params)}),"agent"),wc=l(t=>J.create().displayAs({id:"event",params:u({},t?.params)}),"event"),Pc=l(t=>J.create().displayAs({id:"table",params:u({},t?.params)}),"table"),xc=l(t=>J.create().displayAs({id:"tablerow",params:u({},t?.params)}),"tablerow"),kc=l(t=>J.create().displayAs({id:"intent",params:u({},t?.params)}),"intent"),Sc=l(()=>Qe.create(_h).displayAs({id:"dropdown",params:{}}),"aimodel"),Oc=l(t=>J.create().displayAs({id:"datasource",params:u({},t)}),"datasource"),Ec=l(t=>J.create().displayAs({id:"knowledgebase",params:u({},t)}),"knowledgebase"),Ic={object:ze.lazycreate},Zc=l((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=Oi.create,Jc=Yt.create,Yc=xi.create,Xc=Ei.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=l(()=>Mi().optional(),"ostring"),uu=l(()=>$i().optional(),"onumber"),du=l(()=>ji().optional(),"oboolean"),pu={string:t=>J.create(f(u({},t),{coerce:!0})),number:t=>hr.create(f(u({},t),{coerce:!0})),boolean:t=>or.create(f(u({},t),{coerce:!0})),bigint:t=>ar.create(f(u({},t),{coerce:!0})),date:t=>ur.create(f(u({},t),{coerce:!0}))},fu=x,p=y,bh=l(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"),wh=l(t=>[t.slice(0,t.length/2),t.slice(t.length/2)],"half"),Ph=l((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 o=a[0],c=a.length===3?a[1]:"",d=a.length===3?a[2]:a[1];s+=o,((r=t.errorMessage)==null?void 0:r[e])!==void 0&&(s+=c+JSON.stringify(t.errorMessage[e])),s+=d}}return s}l(q,"withMessage");var Ht=Symbol("Original index"),xh=l(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]=wh(xh(t.allOf));return`z.intersection(${Lt({allOf:n},e)}, ${Lt({allOf:r},e)})`}}l(Lt,"parseAllOf");var gu=l((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"),kh=l((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"),Sh=l(t=>{var e;return(e=t[w])!=null&&e.coerce?"z.coerce.boolean()":"z.boolean()"},"parseBoolean"),Oh=l(t=>`z.literal(${JSON.stringify(t.const)})`,"parseConst"),Eh=l(t=>"z.any()","parseDefault"),Ki=l((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
17
|
const schemas = [${t.oneOf.map((n,r)=>L(n,f(u({},e),{path:[...e.path,"oneOf",r]}))).join(", ")}];
|
|
25
18
|
const errors = schemas.reduce(
|
|
26
19
|
(errors: z.ZodError[], schema) =>
|
|
@@ -37,7 +30,14 @@ declare function ${r}${a};${c}`);if(t.props.type==="variable")return Hr(`${i}dec
|
|
|
37
30
|
message: "Invalid input: Should pass single schema",
|
|
38
31
|
});
|
|
39
32
|
}
|
|
40
|
-
})`:"z.any()","parseOneOf")
|
|
33
|
+
})`:"z.any()","parseOneOf"),Ih=l((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"),Zh=l(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"),Bh=l((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) => {
|
|
34
|
+
const result = ${n}.safeParse(value).success
|
|
35
|
+
? ${r}.safeParse(value)
|
|
36
|
+
: ${i}.safeParse(value);
|
|
37
|
+
if (!result.success) {
|
|
38
|
+
result.error.errors.forEach((error) => ctx.addIssue(error))
|
|
39
|
+
}
|
|
40
|
+
})`},"parseIfThenElse"),Ah=l((t,e)=>`z.union([${t.type.map(n=>L(f(u({},t),{type:n}),e)).join(", ")}])`,"parseMultipleType"),Ch=l((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"),Rh=l(t=>"z.null()","parseNull"),Dh=l((t,e)=>`${L(Ph(t,"nullable"),e,!0)}.nullable()`,"parseNullable"),Hh=l(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");function mu(t,e){let n;t.properties&&(Object.keys(t.properties).length?(n="z.object({ ",n+=Object.keys(t.properties).map(a=>{let o=t.properties[a],c=`${JSON.stringify(a)}: ${L(o,f(u({},e),{path:[...e.path,"properties",a]}))}`,d=typeof o=="object"&&o.default!==void 0||typeof t.default=="object"&&t.default!==null&&a in t.default,g=Array.isArray(t.required)?t.required.includes(a):typeof o=="object"&&o.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(([o,c])=>[o,L(c,f(u({},e),{path:[...e.path,"patternProperties",o]}))],{}));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
41
|
`,i+=`for (const key in value) {
|
|
42
42
|
`,r&&(t.properties?i+=`let evaluated = [${Object.keys(t.properties).map(o=>JSON.stringify(o)).join(", ")}].includes(key)
|
|
43
43
|
`:i+=`let evaluated = false
|
|
@@ -69,25 +69,21 @@ declare function ${r}${a};${c}`);if(t.props.type==="variable")return Hr(`${i}dec
|
|
|
69
69
|
`,i+=`}
|
|
70
70
|
`,i+=`}
|
|
71
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}l(mu,"parseObject");var Rh=l(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=l((t,e)=>`${L(Oh(t,"nullable"),e,!0)}.nullable()`,"parseNullable"),Hh=l(t=>`z.ref('${t.$ref}')`,"parseRef"),Nh=l((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=l((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=l((t,e)=>(t.description&&(e+=`.describe(${JSON.stringify(t.description)})`),e),"addMeta"),$h=l((t,e)=>(t.default!==void 0&&(e+=`.default(${JSON.stringify(t.default)})`),e),"addDefaults"),jh=l((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:l(t=>t.type==="object","object"),array:l(t=>t.type==="array","array"),anyOf:l(t=>t.anyOf!==void 0,"anyOf"),allOf:l(t=>t.allOf!==void 0,"allOf"),enum:l(t=>t.enum!==void 0,"enum")},a:{nullable:l(t=>t.nullable===!0,"nullable"),multipleType:l(t=>Array.isArray(t.type),"multipleType"),not:l(t=>t.not!==void 0,"not"),const:l(t=>t.const!==void 0,"const"),primitive:l((t,e)=>t.type===e,"primitive"),conditional:l(t=>!!("if"in t&&t.if&&"then"in t&&"else"in t&&t.then&&t.else),"conditional"),discriminator:l(t=>{var e;return t.oneOf!==void 0&&((e=t.discriminator)==null?void 0:e.propertyName)!==void 0},"discriminator"),oneOf:l(t=>t.oneOf!==void 0,"oneOf"),ref:l(t=>t.$ref!==void 0,"ref")}},Kh=l(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=l(t=>L(t,{seen:new Map,path:[]}),"jsonSchemaToZodStr"),Fh=l(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=l((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 o=t._def;o.typeName===y.ZodFirstPartyTypeKind.ZodTuple&&Nt(o.items[a],s)})}},"applyZuiPropsRecursively"),zh=l(t=>{let e=Fh(t);return Nt(e,t),e},"fromJSONSchemaLegacy"),Wh=l(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=l(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=l(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=l(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=l(t=>{var e,n;return t.anyOf!==void 0&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)===p.ZodFirstPartyTypeKind.ZodDiscriminatedUnion},"isDiscriminatedUnionSchema"),Gh=l(({type:t,minimum:e,exclusiveMinimum:n,maximum:r,exclusiveMaximum:i,multipleOf:s,format:a})=>{let o=p.number();return t==="integer"&&(o=o.int()),a==="finite"&&(o=o.finite()),n!==void 0?o=o.gt(n):e!==void 0&&(o=o.gte(e)),i!==void 0?o=o.lt(i):r!==void 0&&(o=o.lte(r)),s!==void 0&&(o=o.multipleOf(s)),o},"numberJSONSchemaToZuiNumber"),Jh=l(({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=l((t,e)=>{let n=[];e.enum!==void 0&&n.push(...e.enum),e.const!==void 0&&n.push(e.const);let r,i=n.filter(a=>typeof a===t),[s]=i;if(s)if(i.length===1)r=p.literal(s);else{let a=i.map(o=>p.literal(o));r=p.union(a)}else if(t==="string"&&e.type==="string"&&(r=Jh(e)),t==="number"&&(e.type==="number"||e.type==="integer")&&(r=Gh(e)),t==="boolean"&&(r=p.boolean()),t==="null"&&(r=p.null()),!r)throw new Jn(`Unknown primitive type: "${t}"`);return e.description&&(r=r.describe(e.description)),r},"toZuiPrimitive"),Yh=l((t,e)=>Xh(t)?ey(t,e):Qh(t)?ty(t,e):ny(t,e),"arrayJSONSchemaToZuiArray"),Xh=l(t=>Array.isArray(t.items),"_isTuple"),Qh=l(t=>t.items!==void 0&&t.uniqueItems,"_isSet"),ey=l(({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"),ty=l(({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"),ny=l(({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 U(t)}l(yu,"fromJSONSchema");function U(t){var e,n,r;if(t===void 0)return rt;if(t===!0)return p.any();if(t===!1)return p.never();if(t.default!==void 0)return U(f(u({},t),{default:void 0})).default(t.default);if(t.readOnly)return U(f(u({},t),{readOnly:void 0})).readonly();if(t.description!==void 0)return U(f(u({},t),{description:void 0})).describe(t.description);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 U(f(u({},t),{type:t.type[0]}));let i=t,{type:s}=i,a=js(i,["type"]),o=t.type.map(c=>U(f(u({},a),{type:c})));return p.union(o)}if(t.type==="string")return t.enum&&t.enum.length>0?p.enum(t.enum):kt("string",t);if(t.type==="integer"){let i=kt("number",t);return i instanceof p.ZodNumber?i.int():i}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 Yh(t,U);if(t.type==="object"){if(t.additionalProperties!==void 0&&t.properties!==void 0){let i=U(t.additionalProperties);return U(f(u({},t),{additionalProperties:void 0})).catchall(i)}if(t.properties!==void 0){let i={};for(let[s,a]of Object.entries(t.properties)){let o=U(a),c=(e=t.required)!=null?e:[];i[s]=c.includes(s)||o.isOptional()?o:o.optional()}return p.object(i)}if(t.additionalProperties!==void 0){let i=U(t.additionalProperties);return p.record(i)}return p.record(rt)}if(t.anyOf!==void 0){if(t.anyOf.length===0)return rt;if(t.anyOf.length===1)return U(t.anyOf[0]);if(Wh(t))return U(t.anyOf[0]).optional();if(Lh(t))return U(t.anyOf[0]).nullable();if(qh(t)&&((r=(n=t["x-zui"])==null?void 0:n.def)!=null&&r.discriminator)){let{discriminator:s}=t["x-zui"].def,a=t.anyOf.map(U);return p.discriminatedUnion(s,a)}let i=t.anyOf.map(U);return p.union(i)}if(t.allOf!==void 0){if(t.allOf.length===0)return rt;if(t.allOf.length===1)return U(t.allOf[0]);let[i,...s]=t.allOf,a=U(i),o=U({allOf:s});return p.intersection(a,o)}return Vh(t)?p.unknown():rt}l(U,"_fromJSONSchema");var ry=/^\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=l((t,e,n=!0)=>{if(typeof t!="object")throw new zr("Input must be an object");let r=l(a=>{let o=a;return e?.nullable&&(o=o.nullable()),e?.optional&&(o=o.optional()),e?.passtrough&&typeof o.passthrough=="function"&&(o=o.passthrough()),o},"applyOptions"),i=Object.entries(t).reduce((a,[o,c])=>{if(c===null)a[o]=r(y.null());else switch(typeof c){case"string":a[o]=ry.test(c)?r(y.string().datetime()):r(y.string());break;case"number":a[o]=r(y.number());break;case"boolean":a[o]=r(y.boolean());break;case"object":Array.isArray(c)?c.length===0?a[o]=r(y.array(y.unknown())):typeof c[0]=="object"?a[o]=r(y.array(ei(c[0],e,!1))):["string","number","boolean"].includes(typeof c[0])&&(a[o]=r(y.array(y[typeof c[0]]()))):a[o]=r(ei(c,e,!1));break;default:throw new zr(`Unsupported type for key ${o}`)}return a},{}),s=Object.keys(i).length>0;return e?.passtrough||!n&&!s?y.object(i).passthrough():y.object(i)},"fromObject");function vu(){return{}}l(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}l(_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}l(Tu,"parseBigintDef");function bu(t){return u({type:"boolean"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{})}l(bu,"parseBooleanDef");function wu(t,e){return A(t.type._def,e)}l(wu,"parseBrandedDef");var iy=l((t,e)=>A(t.innerType._def,e),"parseCatchDef");function Pu(t,e){return e.dateStrategy=="integer"?sy(t,e):u({type:"string",format:"date-time"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{})}l(Pu,"parseDateDef");var sy=l((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()})}l(xu,"parseDefaultDef");function ku(t,e){return e.effectStrategy==="input"?A(t.schema._def,e):{}}l(ku,"parseEffectsDef");function Su(t){return{type:"string",enum:t.values}}l(Su,"parseEnumDef");var ay=l(t=>"type"in t&&t.type==="string"?!1:"allOf"in t,"isJsonSchema7AllOfType");function Ou(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(ay(s))i.push(...s.allOf),s.unevaluatedProperties===void 0&&(r=void 0);else{let a=s;if("additionalProperties"in s&&s.additionalProperties===!1){let o=s,{additionalProperties:c}=o;a=js(o,["additionalProperties"])}else r=void 0;i.push(a)}}),i.length?u({allOf:i},r):void 0}l(Ou,"parseIntersectionDef");function Eu(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}}l(Eu,"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 o={type:"object",additionalProperties:(r=A(t.valueType._def,f(u({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?r:{}};if(e.target==="openApi3")return o;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({},o),{propertyNames:c})}else if(((a=t.keyType)==null?void 0:a._def.typeName)==="ZodEnum")return f(u({},o),{propertyNames:{enum:t.keyType._def.values}});return o}l(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}}}l(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")}}l(Zu,"parseNativeEnumDef");function Bu(){return{not:{}}}l(Bu,"parseNeverDef");function Au(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}l(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,o)=>o.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)}l(Cu,"parseUnionDef");var Hs=l((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"}]}}l(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}l(Du,"parseNumberDef");var oy=l((t,e)=>{var n;return t.unknownKeys instanceof E?(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:oy(t,e)});return n.required.length||delete n.required,n}l(Hu,"parseObjectDef");var ly=l((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"),cy=l((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)}l(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}l(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],[])}}l($u,"parseTupleDef");function ju(){return{not:{}}}l(ju,"parseUndefinedDef");function Ku(){return{}}l(Ku,"parseUnknownDef");var uy=l((t,e)=>A(t.innerType._def,e),"parseReadonlyDef");function Uu(t){return{$ref:t.uri}}l(Uu,"parseRefDef");function A(t,e,n=!1){let r=e.seen.get(t);if(r&&!n){let a=dy(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=fy(t,t.typeName,e);return s&&ti(t,e,s),i.jsonSchema=s,s}l(A,"parseDef");var dy=l((t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:py(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"),py=l((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"),fy=l((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 Ou(t,n);case"ZodTuple":return $u(t,n);case"ZodRecord":return Ui(t,n);case"ZodRef":return Uu(t);case"ZodLiteral":return Eu(t,n);case"ZodEnum":return Su(t);case"ZodNativeEnum":return Zu(t);case"ZodNullable":return Ru(t,n);case"ZodOptional":return ly(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 uy(t,n);case"ZodCatch":return iy(t,n);case"ZodPipeline":return cy(t,n);case"ZodFunction":case"ZodVoid":case"ZodSymbol":return;default:return(r=>{})(e)}},"selectParser"),ti=l((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"},gy=l(t=>typeof t=="string"?f(u({},Ns),{name:t}):u(u({},Ns),t),"getDefaultOptions"),my=l(t=>{let e=gy(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"),hy=l((t,e)=>{var n;let r=my(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:{},o=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"?o.$schema="http://json-schema.org/draft-07/schema#":r.target==="jsonSchema2019-09"&&(o.$schema="https://json-schema.org/draft/2019-09/schema#"),o},"zodToJsonSchema"),yy=l((t,e={target:"openApi3"})=>{let n=hy(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}))}),vy=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})]),_y=y.object({items:y.array(Qu)}),Ty={schema:Lu},by={schema:y.object({items:y.array(y.union([...Qu.options,y.object({type:y.literal("markdown"),payload:Lu})]))})},wy={text:{schema:Wu},image:{schema:Vu},audio:{schema:qu},video:{schema:Gu},file:{schema:Ju},location:{schema:Yu},carousel:{schema:vy},card:{schema:Xu},dropdown:{schema:zu},choice:{schema:zu},bloc:{schema:_y}};var Py={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=Oy){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 o=await xy(s);if(o.path==="/health"){a.writeHead(200).end("ok");return}let c=await t(o);a.writeHead(c?.status??200,c?.headers??{}).end(c?.body??"{}")}catch(o){let c=o instanceof Error?o.message:String(o);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 xy(t){let e=await Sy(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:ky(r.search,"?"),headers:n,method:t.method?.toUpperCase()??"GET"}}function ky(t,e){return t.indexOf(e)===0?t.slice(e.length):t}async function Sy(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 Oy(t){zi.info(`Listening on port ${t}`)}var Cr=require("@botpress/client");var N={};nt(N,{mapKeys:()=>Zy,mapValues:()=>Iy,mergeRecords:()=>Ay,pairs:()=>_r,stripUndefinedProps:()=>By,values:()=>Ey});var _r=t=>Object.entries(t),Ey=t=>Object.values(t),Iy=(t,e)=>Object.fromEntries(_r(t).map(([n,r])=>[n,e(r,n)])),Zy=(t,e)=>Object.fromEntries(_r(t).map(([n,r])=>[e(n),r])),By=t=>Object.fromEntries(_r(t).filter(([,e])=>e!==void 0)),Ay=(t,e,n)=>{let r=[...Object.keys(t),...Object.keys(e)],i=[...new Set(r)],s={};for(let a of i){let o=t[a],c=e[a];o&&c?s[a]=n(o,c):o?s[a]=o:c&&(s[a]=c)}return s};var O={};nt(O,{safePush:()=>Cy,unique:()=>Ry});var Cy=(t,...e)=>t?[...t,...e]:[...e],Ry=t=>Array.from(new Set(t));var Y={};nt(Y,{setName:()=>Dy});var Dy=(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,o]of Object.entries(t.definition.actions??{})){let c=o.input.schema.dereference(s),d=o.output.schema.dereference(s),g=t.actions?.[a]?.name??a;r.actions[g]={...o,...t.actions?.[a]??{},input:{schema:c},output:{schema:d}},i.actions[a]={name:g}}for(let[a,o]of Object.entries(t.definition.events??{})){let c=o.schema.dereference(s),d=t.events?.[a]?.name??a;r.events[d]={...o,...t.events?.[a]??{},schema:c},i.events[a]={name:d}}for(let[a,o]of Object.entries(t.definition.channels??{})){let c={};for(let[g,m]of Object.entries(o.messages)){let T=m.schema.dereference(s);c[g]={...m,schema:T}}let d=t.channels?.[a]?.name??a;r.channels[d]={...o,...t.channels?.[a]??{},message:{...o.message??{},tags:{...o.message?.tags??{},...t.channels?.[a]?.message?.tags??{}}},conversation:{...o.conversation??{},tags:{...o.conversation?.tags??{},...t.channels?.[a]?.conversation?.tags??{}}},messages:c},i.channels[a]={name:d}}return{resolved:r,statement:i}};var nd="5.1.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),o=this;o.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 o.actions=N.mergeRecords(o.actions??{},g.actions,this._mergeActions),o.channels=N.mergeRecords(o.channels??{},g.channels,this._mergeChannels),o.events=N.mergeRecords(o.events??{},g.events,this._mergeEvents),o.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 Oe=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)=>(Ny(e.response?.headers??{})??t)*1e3},Ny=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 My(String(r))}},My=t=>{let e=$y(t)?jy(t):t.length>0?parseInt(t,10):void 0;return e===void 0||isNaN(e)?void 0:e},$y=t=>t.includes(" "),jy=t=>{let e=Ky(t);if(!e)return;let n=new Date;return Math.max(0,Math.floor((e.getTime()-n.getTime())/1e3))},Ky=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 g_=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 Uy=t=>["traceparent","tracestate","sentry-trace"].reduce((e,n)=>(t[n]&&(e[n]=t[n]),e),{}),Fy=(t,e,n)=>{let[,r]=(e.headers.traceparent||"").split("-"),i=new Oe.Client({botId:t.botId,integrationId:t.integrationId,integrationAlias:t.integrationAlias,retry:wr,headers:Uy(e.headers)}),s=new _t(i),a=new bt({traceId:r});return{ctx:t,req:e,client:s,logger:a,instance:n}},zy=async t=>{let{ctx:e}=t;switch(e.operation){case"webhook_received":return await Ly(t);case"register":return await Vy(t);case"unregister":return await qy(t);case"message_created":return await Yy(t);case"action_triggered":return await Xy(t);case"ping":return await Wy(t);case"create_user":return await Gy(t);case"create_conversation":return await Jy(t);default:throw new Oe.InvalidPayloadError(`Unknown operation ${e.operation}`)}},md=t=>async e=>{let n=fd(e.headers),r=Fy(n,e,t),{logger:i}=r;try{let s;return s=await Qy(r),s?{...s,status:s.status??200}:(s=await zy(r),s?{...s,status:s.status??200}:{status:200})}catch(s){if((0,Oe.isApiError)(s)){let o=s.type==="Runtime"?s:new Oe.RuntimeError(s.message,s);return i.forBot().error(o.message),{status:o.code,body:JSON.stringify(o.toJSON())}}console.error(s);let a=new Oe.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())}}},Wy=async t=>{},Ly=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})},Vy=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})},qy=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})},Gy=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})},Jy=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})},Yy=async({ctx:t,req:e,client:n,logger:r,instance:i})=>{let{conversation:s,user:a,type:o,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[o];if(!m)throw new Error(`Message of type ${o} not found in channel ${s.channel}`);await m({ctx:t,conversation:s,message:d,user:a,type:o,client:n,payload:c,ack:async({tags:I})=>{await n.updateMessage({id:d.id,tags:I})},logger:r})},Xy=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 o=i.actions[a];if(!o)throw new Error(`Action ${a} not found`);let c=new Pr,g={output:await o({ctx:e,input:s,client:n,type:a,logger:r,metadata:c}),meta:c.toJSON()};return{body:JSON.stringify(g)}},Qy=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 Or=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 Er=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(([o,c])=>"integrationInterfaceAlias"in c).map(([o,c])=>{let d=this.integrations?.[c.integrationAlias];if(!d){let m=Object.keys(this.integrations??{}).join(", ")||"(none)";throw new Error(`Interface with alias "${o}" 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().
|
|
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}l(mu,"parseObject");var Nh=l(t=>`z.ref('${t.$ref}')`,"parseRef"),Mh=l(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"),L=l((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=Kh(t,e);return n||(i=$h(t,i),e.withoutDefaults||(i=jh(t,i))),r.r=i,i},"parseSchema"),$h=l((t,e)=>(t.description&&(e+=`.describe(${JSON.stringify(t.description)})`),e),"addMeta"),jh=l((t,e)=>(t.default!==void 0&&(e+=`.default(${JSON.stringify(t.default)})`),e),"addDefaults"),Kh=l((t,e)=>$.a.nullable(t)?Dh(t,e):$.an.object(t)?mu(t,e):$.an.array(t)?kh(t,e):$.an.anyOf(t)?gu(t,e):$.an.allOf(t)?Lt(t,e):$.a.discriminator(t)?Ih(t,e):$.a.oneOf(t)?Ki(t,e):$.a.not(t)?Ch(t,e):$.an.enum(t)?Zh(t):$.a.const(t)?Oh(t):$.a.multipleType(t)?Ah(t,e):$.a.primitive(t,"string")?Mh(t):$.a.primitive(t,"number")||$.a.primitive(t,"integer")?Hh(t):$.a.primitive(t,"boolean")?Sh(t):$.a.primitive(t,"null")?Rh(t):$.a.conditional(t)?Bh(t,e):$.a.ref(t)?Nh(t):Eh(t),"selectParser"),$={an:{object:t=>t.type==="object",array:t=>t.type==="array",anyOf:t=>t.anyOf!==void 0,allOf:t=>t.allOf!==void 0,enum:t=>t.enum!==void 0},a:{nullable:t=>t.nullable===!0,multipleType:t=>Array.isArray(t.type),not:t=>t.not!==void 0,const:t=>t.const!==void 0,primitive:(t,e)=>t.type===e,conditional:t=>!!("if"in t&&t.if&&"then"in t&&"else"in t&&t.then&&t.else),discriminator:t=>{var e;return t.oneOf!==void 0&&((e=t.discriminator)==null?void 0:e.propertyName)!==void 0},oneOf:t=>t.oneOf!==void 0,ref:t=>t.$ref!==void 0}},Uh=l(t=>L(t,{seen:new Map,path:[]}),"jsonSchemaToZodStr"),Fh=l(t=>{let e=Uh(t);e=e.replaceAll("errors: z.ZodError[]","errors");let n=bh(e);if(!n.sucess)throw new Jn(n.error);return n.value},"jsonSchemaToZod"),Nt=l((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 o=t._def;o.typeName===y.ZodFirstPartyTypeKind.ZodTuple&&Nt(o.items[a],s)})}},"applyZuiPropsRecursively"),zh=l(t=>{let e=Fh(t);return Nt(e,t),e},"fromJSONSchemaLegacy"),Wh=l(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=l(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=l(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=l(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=l(t=>{var e,n;return t.anyOf!==void 0&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)===p.ZodFirstPartyTypeKind.ZodDiscriminatedUnion},"isDiscriminatedUnionSchema"),Gh=l((t,e)=>Jh(t)?Xh(t,e):Yh(t)?Qh(t,e):ey(t,e),"arrayJSONSchemaToZuiArray"),Jh=l(t=>Array.isArray(t.items),"_isTuple"),Yh=l(t=>t.items!==void 0&&t.uniqueItems,"_isSet"),Xh=l(({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"),Qh=l(({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"),ey=l(({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"),ty=l(({type:t,minimum:e,exclusiveMinimum:n,maximum:r,exclusiveMaximum:i,multipleOf:s,format:a})=>{let o=p.number();return t==="integer"&&(o=o.int()),a==="finite"&&(o=o.finite()),n!==void 0?o=o.gt(n):e!==void 0&&(o=o.gte(e)),i!==void 0?o=o.lt(i):r!==void 0&&(o=o.lte(r)),s!==void 0&&(o=o.multipleOf(s)),o},"numberJSONSchemaToZuiNumber"),ny=l(({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?Md(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=l((t,e)=>{let n=[];e.enum!==void 0&&n.push(...e.enum),e.const!==void 0&&n.push(e.const);let r,i=n.filter(a=>typeof a===t),[s]=i;if(s)if(i.length===1)r=p.literal(s);else{let a=i.map(o=>p.literal(o));r=p.union(a)}else if(t==="string"&&e.type==="string"&&(r=ny(e)),t==="number"&&(e.type==="number"||e.type==="integer")&&(r=ty(e)),t==="boolean"&&(r=p.boolean()),t==="null"&&(r=p.null()),!r)throw new Jn(`Unknown primitive type: "${t}"`);return e.description&&(r=r.describe(e.description)),r},"toZuiPrimitive"),rt=p.any();function yu(t){return U(t)}l(yu,"fromJSONSchema");function U(t){var e,n,r;if(t===void 0)return rt;if(t===!0)return p.any();if(t===!1)return p.never();if(t.default!==void 0)return U(f(u({},t),{default:void 0})).default(t.default);if(t.readOnly)return U(f(u({},t),{readOnly:void 0})).readonly();if(t.description!==void 0)return U(f(u({},t),{description:void 0})).describe(t.description);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 U(f(u({},t),{type:t.type[0]}));let i=t,{type:s}=i,a=js(i,["type"]),o=t.type.map(c=>U(f(u({},a),{type:c})));return p.union(o)}if(t.type==="string")return t.enum&&t.enum.length>0?p.enum(t.enum):kt("string",t);if(t.type==="integer"){let i=kt("number",t);return i instanceof p.ZodNumber?i.int():i}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 Gh(t,U);if(t.type==="object"){if(t.additionalProperties!==void 0&&t.properties!==void 0){let i=U(t.additionalProperties);return U(f(u({},t),{additionalProperties:void 0})).catchall(i)}if(t.properties!==void 0){let i={};for(let[s,a]of Object.entries(t.properties)){let o=U(a),c=(e=t.required)!=null?e:[];i[s]=c.includes(s)||o.isOptional()?o:o.optional()}return p.object(i)}if(t.additionalProperties!==void 0){let i=U(t.additionalProperties);return p.record(i)}return p.record(rt)}if(t.anyOf!==void 0){if(t.anyOf.length===0)return rt;if(t.anyOf.length===1)return U(t.anyOf[0]);if(Wh(t))return U(t.anyOf[0]).optional();if(Lh(t))return U(t.anyOf[0]).nullable();if(qh(t)&&((r=(n=t["x-zui"])==null?void 0:n.def)!=null&&r.discriminator)){let{discriminator:s}=t["x-zui"].def,a=t.anyOf.map(U);return p.discriminatedUnion(s,a)}let i=t.anyOf.map(U);return p.union(i)}if(t.allOf!==void 0){if(t.allOf.length===0)return rt;if(t.allOf.length===1)return U(t.allOf[0]);let[i,...s]=t.allOf,a=U(i),o=U({allOf:s});return p.intersection(a,o)}return Vh(t)?p.unknown():rt}l(U,"_fromJSONSchema");var ry=/^\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=l((t,e,n=!0)=>{if(typeof t!="object")throw new Fr("Input must be an object");let r=l(a=>{let o=a;return e?.nullable&&(o=o.nullable()),e?.optional&&(o=o.optional()),e?.passtrough&&typeof o.passthrough=="function"&&(o=o.passthrough()),o},"applyOptions"),i=Object.entries(t).reduce((a,[o,c])=>{if(c===null)a[o]=r(y.null());else switch(typeof c){case"string":a[o]=ry.test(c)?r(y.string().datetime()):r(y.string());break;case"number":a[o]=r(y.number());break;case"boolean":a[o]=r(y.boolean());break;case"object":Array.isArray(c)?c.length===0?a[o]=r(y.array(y.unknown())):typeof c[0]=="object"?a[o]=r(y.array(ei(c[0],e,!1))):["string","number","boolean"].includes(typeof c[0])&&(a[o]=r(y.array(y[typeof c[0]]()))):a[o]=r(ei(c,e,!1));break;default:throw new Fr(`Unsupported type for key ${o}`)}return a},{}),s=Object.keys(i).length>0;return e?.passtrough||!n&&!s?y.object(i).passthrough():y.object(i)},"fromObject");function vu(){return{}}l(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}l(_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}l(Tu,"parseBigintDef");function bu(t){return u({type:"boolean"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{})}l(bu,"parseBooleanDef");function wu(t,e){return A(t.type._def,e)}l(wu,"parseBrandedDef");var iy=l((t,e)=>A(t.innerType._def,e),"parseCatchDef");function Pu(t,e){return e.dateStrategy==="integer"?sy(t,e):u({type:"string",format:"date-time"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{})}l(Pu,"parseDateDef");var sy=l((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()})}l(xu,"parseDefaultDef");function ku(t,e){return e.effectStrategy==="input"?A(t.schema._def,e):{}}l(ku,"parseEffectsDef");function Su(t){return{type:"string",enum:t.values}}l(Su,"parseEnumDef");var ay=l(t=>"type"in t&&t.type==="string"?!1:"allOf"in t,"isJsonSchema7AllOfType");function Ou(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(ay(s))i.push(...s.allOf),s.unevaluatedProperties===void 0&&(r=void 0);else{let a=s;if("additionalProperties"in s&&s.additionalProperties===!1){let o=s,{additionalProperties:c}=o;a=js(o,["additionalProperties"])}else r=void 0;i.push(a)}}),i.length?u({allOf:i},r):void 0}l(Ou,"parseIntersectionDef");function Eu(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}}l(Eu,"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 o={type:"object",additionalProperties:(r=A(t.valueType._def,f(u({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?r:{}};if(e.target==="openApi3")return o;if(((i=t.keyType)==null?void 0:i._def.typeName)==="ZodString"&&((s=t.keyType._def.checks)!=null&&s.length)){let c=Object.entries(ii(t.keyType._def,e)).reduce((d,[g,m])=>g==="type"?d:f(u({},d),{[g]:m}),{});return f(u({},o),{propertyNames:c})}else if(((a=t.keyType)==null?void 0:a._def.typeName)==="ZodEnum")return f(u({},o),{propertyNames:{enum:t.keyType._def.values}});return o}l(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}}}l(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")}}l(Zu,"parseNativeEnumDef");function Bu(){return{not:{}}}l(Bu,"parseNeverDef");function Au(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}l(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,o)=>o.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)}l(Cu,"parseUnionDef");var Hs=l((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"}]}}l(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",ri(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}l(Du,"parseNumberDef");var oy=l((t,e)=>{var n;return t.unknownKeys instanceof E?(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:oy(t,e)});return n.required.length||delete n.required,n}l(Hu,"parseObjectDef");var ly=l((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"),cy=l((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)}l(Nu,"parsePromiseDef");var uy=l((t,e)=>A(t.innerType._def,e),"parseReadonlyDef");function Mu(t){return{$ref:t.uri}}l(Mu,"parseRefDef");function $u(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}l($u,"parseSetDef");function ju(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],[])}}l(ju,"parseTupleDef");function Ku(){return{not:{}}}l(Ku,"parseUndefinedDef");function Uu(){return{}}l(Uu,"parseUnknownDef");function A(t,e,n=!1){let r=e.seen.get(t);if(r&&!n){let a=dy(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=fy(t,t.typeName,e);return s&&ti(t,e,s),i.jsonSchema=s,s}l(A,"parseDef");var dy=l((t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:py(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"),py=l((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"),fy=l((t,e,n)=>{switch(e){case"ZodString":return ii(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 Ku();case"ZodNull":return Au(n);case"ZodArray":return _u(t,n);case"ZodUnion":case"ZodDiscriminatedUnion":return Cu(t,n);case"ZodIntersection":return Ou(t,n);case"ZodTuple":return ju(t,n);case"ZodRecord":return Ui(t,n);case"ZodRef":return Mu(t);case"ZodLiteral":return Eu(t,n);case"ZodEnum":return Su(t);case"ZodNativeEnum":return Zu(t);case"ZodNullable":return Ru(t,n);case"ZodOptional":return ly(t,n);case"ZodMap":return Iu(t,n);case"ZodSet":return $u(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 Uu();case"ZodDefault":return xu(t,n);case"ZodBranded":return wu(t,n);case"ZodReadonly":return uy(t,n);case"ZodCatch":return iy(t,n);case"ZodPipeline":return cy(t,n);case"ZodFunction":case"ZodVoid":case"ZodSymbol":return;default:return(r=>{})(e)}},"selectParser"),ti=l((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"},gy=l(t=>typeof t=="string"?f(u({},Ns),{name:t}):u(u({},Ns),t),"getDefaultOptions"),my=l(t=>{let e=gy(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"),hy=l((t,e)=>{var n;let r=my(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:{},o=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"?o.$schema="http://json-schema.org/draft-07/schema#":r.target==="jsonSchema2019-09"&&(o.$schema="https://json-schema.org/draft/2019-09/schema#"),o},"zodToJsonSchema"),yy=l((t,e={target:"openApi3"})=>{let n=hy(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}))}),vy=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})]),_y=y.object({items:y.array(Qu)}),Ty={schema:Lu},by={schema:y.object({items:y.array(y.union([...Qu.options,y.object({type:y.literal("markdown"),payload:Lu})]))})},wy={text:{schema:Wu},image:{schema:Vu},audio:{schema:qu},video:{schema:Gu},file:{schema:Ju},location:{schema:Yu},carousel:{schema:vy},card:{schema:Xu},dropdown:{schema:zu},choice:{schema:zu},bloc:{schema:_y}};var Py={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=Oy){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 o=await xy(s);if(o.path==="/health"){a.writeHead(200).end("ok");return}let c=await t(o);a.writeHead(c?.status??200,c?.headers??{}).end(c?.body??"{}")}catch(o){let c=o instanceof Error?o.message:String(o);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 xy(t){let e=await Sy(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:ky(r.search,"?"),headers:n,method:t.method?.toUpperCase()??"GET"}}function ky(t,e){return t.indexOf(e)===0?t.slice(e.length):t}async function Sy(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 Oy(t){zi.info(`Listening on port ${t}`)}var Cr=require("@botpress/client");var N={};nt(N,{mapKeys:()=>Zy,mapValues:()=>Iy,mergeRecords:()=>Ay,pairs:()=>_r,stripUndefinedProps:()=>By,values:()=>Ey});var _r=t=>Object.entries(t),Ey=t=>Object.values(t),Iy=(t,e)=>Object.fromEntries(_r(t).map(([n,r])=>[n,e(r,n)])),Zy=(t,e)=>Object.fromEntries(_r(t).map(([n,r])=>[e(n),r])),By=t=>Object.fromEntries(_r(t).filter(([,e])=>e!==void 0)),Ay=(t,e,n)=>{let r=[...Object.keys(t),...Object.keys(e)],i=[...new Set(r)],s={};for(let a of i){let o=t[a],c=e[a];o&&c?s[a]=n(o,c):o?s[a]=o:c&&(s[a]=c)}return s};var O={};nt(O,{safePush:()=>Cy,unique:()=>Ry});var Cy=(t,...e)=>t?[...t,...e]:[...e],Ry=t=>Array.from(new Set(t));var Y={};nt(Y,{setName:()=>Dy});var Dy=(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,o]of Object.entries(t.definition.actions??{})){let c=o.input.schema.dereference(s),d=o.output.schema.dereference(s),g=t.actions?.[a]?.name??a;r.actions[g]={...o,...t.actions?.[a]??{},input:{schema:c},output:{schema:d}},i.actions[a]={name:g}}for(let[a,o]of Object.entries(t.definition.events??{})){let c=o.schema.dereference(s),d=t.events?.[a]?.name??a;r.events[d]={...o,...t.events?.[a]??{},schema:c},i.events[a]={name:d}}for(let[a,o]of Object.entries(t.definition.channels??{})){let c={};for(let[g,m]of Object.entries(o.messages)){let T=m.schema.dereference(s);c[g]={...m,schema:T}}let d=t.channels?.[a]?.name??a;r.channels[d]={...o,...t.channels?.[a]??{},message:{...o.message??{},tags:{...o.message?.tags??{},...t.channels?.[a]?.message?.tags??{}}},conversation:{...o.conversation??{},tags:{...o.conversation?.tags??{},...t.channels?.[a]?.conversation?.tags??{}}},messages:c},i.channels[a]={name:d}}return{resolved:r,statement:i}};var nd="5.1.2";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),o=this;o.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 o.actions=N.mergeRecords(o.actions??{},g.actions,this._mergeActions),o.channels=N.mergeRecords(o.channels??{},g.channels,this._mergeChannels),o.events=N.mergeRecords(o.events??{},g.events,this._mergeEvents),o.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 Oe=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)=>(Ny(e.response?.headers??{})??t)*1e3},Ny=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 My(String(r))}},My=t=>{let e=$y(t)?jy(t):t.length>0?parseInt(t,10):void 0;return e===void 0||isNaN(e)?void 0:e},$y=t=>t.includes(" "),jy=t=>{let e=Ky(t);if(!e)return;let n=new Date;return Math.max(0,Math.floor((e.getTime()-n.getTime())/1e3))},Ky=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 g_=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:!1,hiddenToIntegrationOwners:!1,...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})}withHiddenToIntegrationOwners(e){return this.with({hiddenToIntegrationOwners:e})}forBot(){return this.with({hiddenToIntegrationOwners:!1,visibleToBotOwners:!0})}forBotOnly(){return this.with({hiddenToIntegrationOwners:!0,visibleToBotOwners:!0})}getJsonMessage(e){return JSON.stringify({msg:e,visible_to_bot_owner:this.defaultOptions.visibleToBotOwners,hidden_to_integration_owner:this.defaultOptions.hiddenToIntegrationOwners,options:this.defaultOptions})}};var Uy=t=>["traceparent","tracestate","sentry-trace"].reduce((e,n)=>(t[n]&&(e[n]=t[n]),e),{}),Fy=(t,e,n)=>{let[,r]=(e.headers.traceparent||"").split("-"),i=new Oe.Client({botId:t.botId,integrationId:t.integrationId,integrationAlias:t.integrationAlias,retry:wr,headers:Uy(e.headers)}),s=new _t(i),a=new bt({traceId:r});return{ctx:t,req:e,client:s,logger:a,instance:n}},zy=async t=>{let{ctx:e}=t;switch(e.operation){case"webhook_received":return await Ly(t);case"register":return await Vy(t);case"unregister":return await qy(t);case"message_created":return await Yy(t);case"action_triggered":return await Xy(t);case"ping":return await Wy(t);case"create_user":return await Gy(t);case"create_conversation":return await Jy(t);default:throw new Oe.InvalidPayloadError(`Unknown operation ${e.operation}`)}},md=t=>async e=>{let n=fd(e.headers),r=Fy(n,e,t),{logger:i}=r;try{let s;return s=await Qy(r),s?{...s,status:s.status??200}:(s=await zy(r),s?{...s,status:s.status??200}:{status:200})}catch(s){if((0,Oe.isApiError)(s)){let o=s.type==="Runtime"?s:new Oe.RuntimeError(s.message,s);return i.forBot().error(o.message),{status:o.code,body:JSON.stringify(o.toJSON())}}console.error(s);let a=new Oe.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())}}},Wy=async t=>{},Ly=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})},Vy=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})},qy=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})},Gy=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})},Jy=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})},Yy=async({ctx:t,req:e,client:n,logger:r,instance:i})=>{let{conversation:s,user:a,type:o,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[o];if(!m)throw new Error(`Message of type ${o} not found in channel ${s.channel}`);await m({ctx:t,conversation:s,message:d,user:a,type:o,client:n,payload:c,ack:async({tags:I})=>{await n.updateMessage({id:d.id,tags:I})},logger:r})},Xy=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 o=i.actions[a];if(!o)throw new Error(`Action ${a} not found`);let c=new Pr,g={output:await o({ctx:e,input:s,client:n,type:a,logger:r,metadata:c}),meta:c.toJSON()};return{body:JSON.stringify(g)}},Qy=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 Or=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 Er=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(([o,c])=>"integrationInterfaceAlias"in c).map(([o,c])=>{let d=this.integrations?.[c.integrationAlias];if(!d){let m=Object.keys(this.integrations??{}).join(", ")||"(none)";throw new Error(`Interface with alias "${o}" 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
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 "${o}" of plugin with alias "${i}".
|
|
74
74
|
Available interface aliases: ${m}`)}return[o,{...g,id:d.id,name:d.name,version:d.version,...c}]})),a=Object.fromEntries(Object.entries(n.dependencies??{}).filter(([o,c])=>!("integrationInterfaceAlias"in c)).map(([o,c])=>{let d=this.integrations?.[c.integrationAlias];if(!d){let g=Object.keys(this.integrations??{}).join(", ")||"(none)";throw new Error(`Integration with alias "${o}" 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
75
|
Available integration aliases: ${g}`)}return[o,{...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,o]of s){let c=this.integrations?.[o.integrationAlias];if(!c)throw new Error(`Interface with alias "${a}" of plugin with alias "${r}" references integration "${o.name}" which is not installed`);let d=Object.entries(o.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 ev=y.enum(["event_received","register","unregister","ping","action_triggered"]),hd=t=>({botId:t[xr]||ue("Missing bot id header"),operation:ev.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 tv=["child_workflow_deleted","child_workflow_finished","workflow_timedout","workflow_started","workflow_continued"],yd=async(t,e)=>{if(t.ctx.type!=="workflow_update"||!tv.includes(e.payload.type))throw new Error("Unexpected event type");let n={...t,logger:nv(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 rv(n,e);default:e.payload.type}return X},nv=(t,e)=>t.logger.with({eventId:e.id,workflowId:e.payload.workflow.id,conversationId:e.payload.conversation?.id,userId:e.payload.user?.id}),rv=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 iv(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},iv=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 o=>{let c=t.hookHandlers.before_outgoing_message[o.type]??[];for(let d of c){let g=new ye(i);o=(await d({client:g,ctx:n,logger:r.with({conversationId:o.conversationId,userId:o.userId}),data:o}))?.data??o}return o},callAction:async o=>{let c=t.hookHandlers.before_outgoing_call_action[o.type]??[];for(let d of c){let g=new ye(i);o=(await d({client:g,ctx:n,logger:r,data:o}))?.data??o}return o}},after:{createMessage:async o=>{let c=t.hookHandlers.after_outgoing_message[o.message.type]??[];for(let d of c){let g=new ye(i);o=(await d({client:g,ctx:n,logger:r.with({messageId:o.message.id,conversationId:o.message.conversationId,userId:o.message.userId}),data:o}))?.data??o}return o},callAction:async(o,c)=>{let{type:d}=c,g=t.hookHandlers.after_outgoing_call_action[d]??[];for(let m of g){let T=new ye(i);o=(await m({client:T,ctx:n,logger:r,data:{type:d,...o}}))?.data??o}return o}}}),a={req:e,ctx:n,logger:r,client:s,self:t};try{switch(n.operation){case"action_triggered":return await cv(a);case"event_received":return await lv(a);case"register":return await av(a);case"unregister":return await ov(a);case"ping":return await sv(a);default:throw new Error(`Unknown operation ${n.operation}`)}}catch(o){let c=o instanceof Error?o:new Error(String(o));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())}}},sv=async t=>X,av=async t=>(await t.self.registerHandler?.({client:t.client,ctx:t.ctx,logger:t.logger}),X),ov=async t=>X,lv=async t=>{let{ctx:e,logger:n,req:r,client:i,self:s}=t,a={client:i,ctx:e,logger:n},o=ce(r);if(a.logger=a.logger.with({eventId:o.event.id,messageId:o.event.messageId,conversationId:o.event.conversationId,userId:o.event.userId}),e.type==="workflow_update")return await yd(t,o.event);if(e.type==="message_created"){let I=o.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 W={...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(W);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=o.event.payload.state,K={...a,state:k},W=s.stateExpiredHandlers[k.name]??[];for(let Q of W)await Q(K);return X}let c=o.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},cv=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 o=i.hookHandlers.before_incoming_call_action[a]??[];for(let T of o){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 Ee=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(o=>pe({...t,workflow:o}))}))),startNewInstance:async r=>{let{workflow:i}=await t.client.createWorkflow({name:n,status:"pending",...ie(r,{alias:void 0})});return{workflow:pe({...t,workflow:i})}}})}),pe=t=>{let e=!1;return{...ve(t.workflow,{alias:void 0}),async update(n){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,...ie(n,{alias: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._registerHandler=e.register,this._actionHandlers=e.actions,this._plugins=e.plugins}_registerHandler;_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 registerHandler(){return this._registerHandler}get actionHandlers(){return new Proxy({},{get:(e,n)=>{let r=this._actionHandlers[n];if(r)return Y.setName(i=>r({...i,workflows:Ee(i)}),r.name);for(let[i,s]of Object.entries(this._plugins)){let[a,o]=n.split(fe);if(!(a!==i||!o))return s.actionHandlers[o]}}})}get messageHandlers(){return new Proxy({},{get:(e,n)=>{let r=Object.values(this._plugins).flatMap(o=>o.messageHandlers[n]??[]),i=n==="*"?[]:this._messageHandlers[n]??[],s=this._messageHandlers["*"]??[],a=[...i,...s].sort((o,c)=>o.order-c.order).map(({handler:o})=>Y.setName(c=>o({...c,workflows:Ee(c)}),o.name));return O.unique([...r,...a])}})}get eventHandlers(){return new Proxy({},{get:(e,n)=>{let r=Object.values(this._plugins).flatMap(o=>o.eventHandlers[n]??[]),i=n==="*"?[]:this._eventHandlers[n]??[],s=this._eventHandlers["*"]??[],a=[...i,...s].sort((o,c)=>o.order-c.order).map(({handler:o})=>Y.setName(c=>o({...c,workflows:Ee(c)}),o.name));return O.unique([...r,...a])}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,n)=>{let r=Object.values(this._plugins).flatMap(o=>o.stateExpiredHandlers[n]??[]),i=n==="*"?[]:this._stateExpiredHandlers[n]??[],s=this._stateExpiredHandlers["*"]??[],a=[...i,...s].sort((o,c)=>o.order-c.order).map(({handler:o})=>Y.setName(c=>o({...c,workflows:Ee(c)}),o.name));return O.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]??[]),o=this._hookHandlers[n]??{},c=s==="*"?[]:o[s]??[],d=o["*"]??[],g=[...c,...d].sort((m,T)=>m.order-T.order).map(({handler:m})=>Y.setName(T=>m({...T,workflows:Ee(T)}),m.name));return O.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:Ee(d)}),g},c.name))??[],o=Object.values(this._plugins).flatMap(c=>c.workflowHandlers[n]?.[s]??[]);return O.unique([...a,...o])}})}})}on={message:(e,n)=>{this._messageHandlers[e]=O.safePush(this._messageHandlers[e],{handler:n,order:this._registerOrder++})},event:(e,n)=>{this._eventHandlers[e]=O.safePush(this._eventHandlers[e],{handler:n,order:this._registerOrder++})},stateExpired:(e,n)=>{this._stateExpiredHandlers[e]=O.safePush(this._stateExpiredHandlers[e],{handler:n,order:this._registerOrder++})},beforeIncomingEvent:(e,n)=>{this._hookHandlers.before_incoming_event[e]=O.safePush(this._hookHandlers.before_incoming_event[e],{handler:n,order:this._registerOrder++})},beforeIncomingMessage:(e,n)=>{this._hookHandlers.before_incoming_message[e]=O.safePush(this._hookHandlers.before_incoming_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingMessage:(e,n)=>{this._hookHandlers.before_outgoing_message[e]=O.safePush(this._hookHandlers.before_outgoing_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingCallAction:(e,n)=>{this._hookHandlers.before_outgoing_call_action[e]=O.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},beforeIncomingCallAction:(e,n)=>{this._hookHandlers.before_incoming_call_action[e]=O.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingEvent:(e,n)=>{this._hookHandlers.after_incoming_event[e]=O.safePush(this._hookHandlers.after_incoming_event[e],{handler:n,order:this._registerOrder++})},afterIncomingMessage:(e,n)=>{this._hookHandlers.after_incoming_message[e]=O.safePush(this._hookHandlers.after_incoming_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingMessage:(e,n)=>{this._hookHandlers.after_outgoing_message[e]=O.safePush(this._hookHandlers.after_outgoing_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingCallAction:(e,n)=>{this._hookHandlers.after_outgoing_call_action[e]=O.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingCallAction:(e,n)=>{this._hookHandlers.after_incoming_call_action[e]=O.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:n,order:this._registerOrder++})},workflowStart:(e,n)=>{this._workflowHandlers.started[e]=O.safePush(this._workflowHandlers.started[e],{handler:n,order:this._registerOrder++})},workflowContinue:(e,n)=>{this._workflowHandlers.continued[e]=O.safePush(this._workflowHandlers.continued[e],{handler:n,order:this._registerOrder++})},workflowTimeout:(e,n)=>{this._workflowHandlers.timed_out[e]=O.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,o=>({...o,schema:o.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,o=Fu.ref(r);s&&o.title(s),a&&o.describe(a),n[r]=o}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 o=(e.integrations[r]??e.interfaces[r])?.integrationAlias,c=e.interfaces[r]?.actions?.[s]?.name??s;return t.callAction({type:`${o}:${c}`,input:a}).then(d=>d.output)}})});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,o=t.plugin?.interfaces[n]?.channels?.[i]?.name??i;return de(({nextToken:c})=>t.client.listConversations({...ie(s??{},{alias:t.plugin?.alias}),channel:o==="*"?void 0:o,integrationName:a==="*"?void 0: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),o=bd(e,this._runtime),c=Ee({client:e,pluginAlias:this._runtime.alias}),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:o,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 O.unique([...r,...i]).sort((a,o)=>a.order-o.order).map(({handler:a})=>Y.setName(o=>a({...o,user:_e({...o,conversationId:o.conversation.id,pluginAlias:this._runtime.alias}),message:ge({...o,plugin:this._runtime,message:o.message}),conversation:Pt({...o,plugin:this._runtime,conversation:o.conversation}),...this._getTools(o.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(([o])=>this._eventResolvesTo(o,n)).flatMap(([,o])=>o??[]),s=this._eventHandlers["*"]??[];return O.unique([...r,...i,...s]).sort((o,c)=>o.order-c.order).map(({handler:o})=>Y.setName(c=>o({...c,...this._getTools(c.client)}),o.name))}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=n==="*"?[]:this._stateExpiredHandlers[n]??[],i=this._stateExpiredHandlers["*"]??[];return O.unique([...r,...i]).sort((a,o)=>a.order-o.order).map(({handler:a})=>Y.setName(o=>a({...o,...this._getTools(o.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]??[],o=Object.entries(r).filter(([g])=>this._eventResolvesTo(g,s)).flatMap(([,g])=>g??[]),c=r["*"]??[];return O.unique([...a,...o,...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((o,c)=>o.order-c.order)??[]).map(({handler:o})=>Y.setName(async c=>{let d=c.workflow;return await o({...c,workflow:pe({...c,workflow:d,onWorkflowUpdate(g){d=g},pluginAlias:this._runtime.alias}),...this._getTools(c.client)}),d},o.name))})}})}on={message:(e,n)=>{this._messageHandlers[e]=O.safePush(this._messageHandlers[e],{handler:n,order:this._registerOrder++})},event:(e,n)=>{this._eventHandlers[e]=O.safePush(this._eventHandlers[e],{handler:n,order:this._registerOrder++})},stateExpired:(e,n)=>{this._stateExpiredHandlers[e]=O.safePush(this._stateExpiredHandlers[e],{handler:n,order:this._registerOrder++})},beforeIncomingEvent:(e,n)=>{this._hookHandlers.before_incoming_event[e]=O.safePush(this._hookHandlers.before_incoming_event[e],{handler:n,order:this._registerOrder++})},beforeIncomingMessage:(e,n)=>{this._hookHandlers.before_incoming_message[e]=O.safePush(this._hookHandlers.before_incoming_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingMessage:(e,n)=>{this._hookHandlers.before_outgoing_message[e]=O.safePush(this._hookHandlers.before_outgoing_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingCallAction:(e,n)=>{this._hookHandlers.before_outgoing_call_action[e]=O.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},beforeIncomingCallAction:(e,n)=>{this._hookHandlers.before_incoming_call_action[e]=O.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingEvent:(e,n)=>{this._hookHandlers.after_incoming_event[e]=O.safePush(this._hookHandlers.after_incoming_event[e],{handler:n,order:this._registerOrder++})},afterIncomingMessage:(e,n)=>{this._hookHandlers.after_incoming_message[e]=O.safePush(this._hookHandlers.after_incoming_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingMessage:(e,n)=>{this._hookHandlers.after_outgoing_message[e]=O.safePush(this._hookHandlers.after_outgoing_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingCallAction:(e,n)=>{this._hookHandlers.after_outgoing_call_action[e]=O.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingCallAction:(e,n)=>{this._hookHandlers.after_incoming_call_action[e]=O.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:n,order:this._registerOrder++})},workflowStart:(e,n)=>{this._workflowHandlers.started[e]=O.safePush(this._workflowHandlers.started[e],{handler:n,order:this._registerOrder++})},workflowContinue:(e,n)=>{this._workflowHandlers.continued[e]=O.safePush(this._workflowHandlers.continued[e],{handler:n,order:this._registerOrder++})},workflowTimeout:(e,n)=>{this._workflowHandlers.timed_out[e]=O.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 o=this._runtime.integrations[i];return!!(o&&n===`${o.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:()=>uv,allWithinMinorOf:()=>dv});var en=Dr(require("semver"));function uv(t){let e=en.major(t.version);return{...t,version:`>=${e}.0.0 <${e+1}.0.0`}}function dv(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});
|
|
76
76
|
/*! Bundled license information:
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
89
|
-
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
90
|
-
*)
|
|
91
|
-
*)
|
|
78
|
+
lodash-es/lodash.js:
|
|
79
|
+
(**
|
|
80
|
+
* @license
|
|
81
|
+
* Lodash (Custom Build) <https://lodash.com/>
|
|
82
|
+
* Build: `lodash modularize exports="es" -o ./`
|
|
83
|
+
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
84
|
+
* Released under MIT license <https://lodash.com/license>
|
|
85
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
86
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
87
|
+
*)
|
|
92
88
|
*/
|
|
93
89
|
//# sourceMappingURL=index.cjs.map
|