@botpress/sdk 4.20.1 → 4.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,26 +1,26 @@
1
- "use strict";var Tu=Object.create;var Jt=Object.defineProperty;var bu=Object.getOwnPropertyDescriptor;var wu=Object.getOwnPropertyNames;var Pu=Object.getPrototypeOf,xu=Object.prototype.hasOwnProperty;var Xe=(t,e)=>{for(var r in e)Jt(t,r,{get:e[r],enumerable:!0})},Ls=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of wu(e))!xu.call(t,s)&&s!==r&&Jt(t,s,{get:()=>e[s],enumerable:!(n=bu(e,s))||n.enumerable});return t};var In=(t,e,r)=>(r=t!=null?Tu(Pu(t)):{},Ls(e||!t||!t.__esModule?Jt(r,"default",{value:t,enumerable:!0}):r,t)),ku=t=>Ls(Jt({},"__esModule",{value:!0}),t);var lv={};Xe(lv,{BRAND:()=>zl,Bot:()=>xn,BotDefinition:()=>Pn,BotLogger:()=>vt,BotSpecificClient:()=>fe,DIRTY:()=>Ne,EMPTY_PATH:()=>Hl,INVALID:()=>x,Integration:()=>wn,IntegrationDefinition:()=>hn,IntegrationLogger:()=>yt,IntegrationSpecificClient:()=>mt,InterfaceDefinition:()=>kn,NEVER:()=>id,OK:()=>G,ParseInputLazyPath:()=>oe,ParseStatus:()=>re,Plugin:()=>En,PluginDefinition:()=>Sn,RuntimeError:()=>On.RuntimeError,Schema:()=>O,WELL_KNOWN_ATTRIBUTES:()=>vy,ZodAny:()=>ct,ZodArray:()=>dt,ZodBigInt:()=>en,ZodBoolean:()=>tn,ZodBranded:()=>rn,ZodCatch:()=>nn,ZodDate:()=>sn,ZodDefault:()=>zt,ZodDiscriminatedUnion:()=>hs,ZodEffects:()=>Se,ZodEnum:()=>Ge,ZodError:()=>pe,ZodFirstPartyTypeKind:()=>ps,ZodFunction:()=>vs,ZodIntersection:()=>an,ZodIssueCode:()=>m,ZodLazy:()=>on,ZodLiteral:()=>ln,ZodMap:()=>_s,ZodNaN:()=>Ts,ZodNativeEnum:()=>cn,ZodNever:()=>ft,ZodNull:()=>dn,ZodNullable:()=>$e,ZodNumber:()=>un,ZodObject:()=>je,ZodOptional:()=>ye,ZodParsedType:()=>_,ZodPipeline:()=>pn,ZodPromise:()=>Wt,ZodReadonly:()=>Lt,ZodRecord:()=>bs,ZodRef:()=>ws,ZodSchema:()=>O,ZodSet:()=>Ps,ZodString:()=>J,ZodSymbol:()=>Bs,ZodTransformer:()=>Se,ZodTuple:()=>Ke,ZodType:()=>O,ZodUndefined:()=>qt,ZodUnion:()=>fn,ZodUnknown:()=>it,ZodVoid:()=>As,addIssueToContext:()=>v,agent:()=>fc,aimodel:()=>vc,any:()=>Zc,array:()=>Rc,bigint:()=>xc,boolean:()=>Ds,coerce:()=>sd,conversation:()=>dc,createZodEnum:()=>Ft,cuid2Regex:()=>ks,cuidRegex:()=>xs,custom:()=>ms,datasource:()=>_c,date:()=>kc,discriminatedUnion:()=>Nc,effect:()=>Vn,emailRegex:()=>Os,enum:()=>Vc,errorUtil:()=>P,event:()=>gc,function:()=>Wc,getErrorMap:()=>ot,getParsedType:()=>he,instanceof:()=>wc,intent:()=>yc,intersection:()=>Mc,ipv4Regex:()=>Zs,ipv6Regex:()=>Is,isAborted:()=>dr,isApiError:()=>On.isApiError,isAsync:()=>jt,isDirty:()=>ur,isEmojiRegex:()=>nc,isValid:()=>lt,json:()=>Ou,knowledgebase:()=>Tc,late:()=>bc,lazy:()=>Lc,literal:()=>qc,makeIssue:()=>$t,map:()=>zc,mergeObjectSchemas:()=>gt,message:()=>pc,messages:()=>Ms,nan:()=>Pc,nativeEnum:()=>Gc,never:()=>Bc,null:()=>Oc,nullable:()=>Xc,number:()=>Cs,object:()=>Cc,objectUtil:()=>lr,oboolean:()=>nd,onumber:()=>rd,optional:()=>Yc,ostring:()=>td,parseBody:()=>le,pipeline:()=>ed,preprocess:()=>Qc,processCreateParams:()=>S,promise:()=>Jc,quotelessJson:()=>Rl,readonly:()=>Uc,record:()=>jc,ref:()=>Kc,serve:()=>Vt,set:()=>Fc,setErrorMap:()=>gs,strictObject:()=>Dc,string:()=>Rs,symbol:()=>Sc,table:()=>mc,tablerow:()=>hc,transformer:()=>Vn,transforms:()=>Ri,tuple:()=>$c,ulidRegex:()=>Ss,undefined:()=>Ec,union:()=>Hc,unknown:()=>Ic,user:()=>uc,util:()=>I,uuidRegex:()=>Es,variable:()=>cc,version:()=>Ws,void:()=>Ac,z:()=>y});module.exports=ku(lv);var Ms={};Xe(Ms,{defaults:()=>yy,markdown:()=>hy});var Yn=Object.defineProperty,Su=Object.defineProperties,Eu=Object.getOwnPropertyDescriptors,or=Object.getOwnPropertySymbols,Ii=Object.prototype.hasOwnProperty,Bi=Object.prototype.propertyIsEnumerable,qs=(t,e,r)=>e in t?Yn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,c=(t,e)=>{for(var r in e||(e={}))Ii.call(e,r)&&qs(t,r,e[r]);if(or)for(var r of or(e))Bi.call(e,r)&&qs(t,r,e[r]);return t},f=(t,e)=>Su(t,Eu(e)),a=(t,e)=>Yn(t,"name",{value:e,configurable:!0}),Ai=(t,e)=>{var r={};for(var n in t)Ii.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&or)for(var n of or(t))e.indexOf(n)<0&&Bi.call(t,n)&&(r[n]=t[n]);return r},zr=(t,e)=>{for(var r in e)Yn(t,r,{get:e[r],enumerable:!0})},Ou={},Ri={};zr(Ri,{errors:()=>Mi,fromJSONSchema:()=>cd,fromJSONSchemaLegacy:()=>jh,fromObject:()=>Gn,toJSONSchema:()=>q,toJSONSchemaLegacy:()=>py,toTypescriptSchema:()=>cs,toTypescriptType:()=>Xn});var y={};zr(y,{BRAND:()=>zl,DIRTY:()=>Ne,EMPTY_PATH:()=>Hl,INVALID:()=>x,NEVER:()=>id,OK:()=>G,ParseInputLazyPath:()=>oe,ParseStatus:()=>re,Schema:()=>O,ZodAny:()=>ct,ZodArray:()=>dt,ZodBigInt:()=>en,ZodBoolean:()=>tn,ZodBranded:()=>rn,ZodCatch:()=>nn,ZodDate:()=>sn,ZodDefault:()=>zt,ZodDiscriminatedUnion:()=>hs,ZodEffects:()=>Se,ZodEnum:()=>Ge,ZodError:()=>pe,ZodFirstPartyTypeKind:()=>ps,ZodFunction:()=>vs,ZodIntersection:()=>an,ZodIssueCode:()=>m,ZodLazy:()=>on,ZodLiteral:()=>ln,ZodMap:()=>_s,ZodNaN:()=>Ts,ZodNativeEnum:()=>cn,ZodNever:()=>ft,ZodNull:()=>dn,ZodNullable:()=>$e,ZodNumber:()=>un,ZodObject:()=>je,ZodOptional:()=>ye,ZodParsedType:()=>_,ZodPipeline:()=>pn,ZodPromise:()=>Wt,ZodReadonly:()=>Lt,ZodRecord:()=>bs,ZodRef:()=>ws,ZodSchema:()=>O,ZodSet:()=>Ps,ZodString:()=>J,ZodSymbol:()=>Bs,ZodTransformer:()=>Se,ZodTuple:()=>Ke,ZodType:()=>O,ZodUndefined:()=>qt,ZodUnion:()=>fn,ZodUnknown:()=>it,ZodVoid:()=>As,addIssueToContext:()=>v,agent:()=>fc,aimodel:()=>vc,any:()=>Zc,array:()=>Rc,bigint:()=>xc,boolean:()=>Ds,coerce:()=>sd,conversation:()=>dc,createZodEnum:()=>Ft,cuid2Regex:()=>ks,cuidRegex:()=>xs,custom:()=>ms,datasource:()=>_c,date:()=>kc,default:()=>hh,discriminatedUnion:()=>Nc,effect:()=>Vn,emailRegex:()=>Os,enum:()=>Vc,errorUtil:()=>P,event:()=>gc,function:()=>Wc,getErrorMap:()=>ot,getParsedType:()=>he,instanceof:()=>wc,intent:()=>yc,intersection:()=>Mc,ipv4Regex:()=>Zs,ipv6Regex:()=>Is,isAborted:()=>dr,isAsync:()=>jt,isDirty:()=>ur,isEmojiRegex:()=>nc,isValid:()=>lt,knowledgebase:()=>Tc,late:()=>bc,lazy:()=>Lc,literal:()=>qc,makeIssue:()=>$t,map:()=>zc,message:()=>pc,nan:()=>Pc,nativeEnum:()=>Gc,never:()=>Bc,null:()=>Oc,nullable:()=>Xc,number:()=>Cs,object:()=>Cc,objectUtil:()=>lr,oboolean:()=>nd,onumber:()=>rd,optional:()=>Yc,ostring:()=>td,pipeline:()=>ed,preprocess:()=>Qc,processCreateParams:()=>S,promise:()=>Jc,quotelessJson:()=>Rl,readonly:()=>Uc,record:()=>jc,ref:()=>Kc,set:()=>Fc,setErrorMap:()=>gs,strictObject:()=>Dc,string:()=>Rs,symbol:()=>Sc,table:()=>mc,tablerow:()=>hc,transformer:()=>Vn,tuple:()=>$c,ulidRegex:()=>Ss,undefined:()=>Ec,union:()=>Hc,unknown:()=>Ic,user:()=>uc,util:()=>I,uuidRegex:()=>Es,variable:()=>cc,void:()=>Ac});var w="x-zui";function Ci(t){return typeof t=="symbol"?"symbol":typeof t=="bigint"?`${t.toString()}n`:b(t)}a(Ci,"primitiveToTypscriptLiteralType");function b(t){return typeof t>"u"?"undefined":typeof t=="symbol"?t.description?`Symbol(${b(t.description)})`:"Symbol()":typeof t=="bigint"?`BigInt(${t.toString()})`:typeof t=="string"?Ni(t):JSON.stringify(t)}a(b,"primitiveToTypescriptValue");function nt(t){return typeof t>"u"?"undefined":JSON.stringify(t)}a(nt,"unknownToTypescriptValue");var Di=a((t,e)=>{let r=Object.entries(t),n=e?" as const":"";return`{ ${r.map(([s,i])=>`${Mn(s)}: ${nt(i)}`).join(", ")} }${n}`},"recordOfUnknownToTypescriptRecord"),Mn=a(t=>/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t)?t:b(t),"toPropertyKey"),Zu=a(t=>t.charAt(0).toUpperCase()+t.slice(1),"capitalize"),Hi=a(t=>{let e=/[^a-zA-Z0-9_]/g;return t.split(e).map(Zu).filter(n=>!!n).join("")},"toTypeArgumentName"),Vs=a(t=>{for(var e;t.length&&!((e=t[0])!=null&&e.trim());)t.shift();for(;t.length&&!t[t.length-1].trim();)t.pop()},"trimEmptyLinesInPlace"),z=a(t=>{t=t?.replace(/(\n(\s*)?){3,}/g,`
1
+ "use strict";var bu=Object.create;var Jt=Object.defineProperty;var wu=Object.getOwnPropertyDescriptor;var Pu=Object.getOwnPropertyNames;var xu=Object.getPrototypeOf,ku=Object.prototype.hasOwnProperty;var Xe=(t,e)=>{for(var r in e)Jt(t,r,{get:e[r],enumerable:!0})},Ls=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Pu(e))!ku.call(t,s)&&s!==r&&Jt(t,s,{get:()=>e[s],enumerable:!(n=wu(e,s))||n.enumerable});return t};var In=(t,e,r)=>(r=t!=null?bu(xu(t)):{},Ls(e||!t||!t.__esModule?Jt(r,"default",{value:t,enumerable:!0}):r,t)),Su=t=>Ls(Jt({},"__esModule",{value:!0}),t);var cv={};Xe(cv,{BRAND:()=>zl,Bot:()=>xn,BotDefinition:()=>Pn,BotLogger:()=>vt,BotSpecificClient:()=>fe,DIRTY:()=>Ne,EMPTY_PATH:()=>Hl,INVALID:()=>x,Integration:()=>wn,IntegrationDefinition:()=>hn,IntegrationLogger:()=>yt,IntegrationSpecificClient:()=>mt,InterfaceDefinition:()=>kn,NEVER:()=>id,OK:()=>G,ParseInputLazyPath:()=>oe,ParseStatus:()=>re,Plugin:()=>En,PluginDefinition:()=>Sn,RuntimeError:()=>On.RuntimeError,Schema:()=>O,WELL_KNOWN_ATTRIBUTES:()=>_y,ZodAny:()=>ct,ZodArray:()=>dt,ZodBigInt:()=>en,ZodBoolean:()=>tn,ZodBranded:()=>rn,ZodCatch:()=>nn,ZodDate:()=>sn,ZodDefault:()=>zt,ZodDiscriminatedUnion:()=>hs,ZodEffects:()=>Se,ZodEnum:()=>Ge,ZodError:()=>pe,ZodFirstPartyTypeKind:()=>ps,ZodFunction:()=>vs,ZodIntersection:()=>an,ZodIssueCode:()=>m,ZodLazy:()=>on,ZodLiteral:()=>ln,ZodMap:()=>_s,ZodNaN:()=>Ts,ZodNativeEnum:()=>cn,ZodNever:()=>ft,ZodNull:()=>dn,ZodNullable:()=>$e,ZodNumber:()=>un,ZodObject:()=>je,ZodOptional:()=>ye,ZodParsedType:()=>_,ZodPipeline:()=>pn,ZodPromise:()=>Wt,ZodReadonly:()=>Lt,ZodRecord:()=>bs,ZodRef:()=>ws,ZodSchema:()=>O,ZodSet:()=>Ps,ZodString:()=>J,ZodSymbol:()=>Bs,ZodTransformer:()=>Se,ZodTuple:()=>Ke,ZodType:()=>O,ZodUndefined:()=>qt,ZodUnion:()=>fn,ZodUnknown:()=>it,ZodVoid:()=>As,addIssueToContext:()=>v,agent:()=>fc,aimodel:()=>vc,any:()=>Zc,array:()=>Rc,bigint:()=>xc,boolean:()=>Ds,coerce:()=>sd,conversation:()=>dc,createZodEnum:()=>Ft,cuid2Regex:()=>ks,cuidRegex:()=>xs,custom:()=>ms,datasource:()=>_c,date:()=>kc,discriminatedUnion:()=>Nc,effect:()=>Vn,emailRegex:()=>Os,enum:()=>Vc,errorUtil:()=>P,event:()=>gc,function:()=>Wc,getErrorMap:()=>ot,getParsedType:()=>he,instanceof:()=>wc,intent:()=>yc,intersection:()=>Mc,ipv4Regex:()=>Zs,ipv6Regex:()=>Is,isAborted:()=>dr,isApiError:()=>On.isApiError,isAsync:()=>jt,isDirty:()=>ur,isEmojiRegex:()=>nc,isValid:()=>lt,json:()=>Zu,knowledgebase:()=>Tc,late:()=>bc,lazy:()=>Lc,literal:()=>qc,makeIssue:()=>$t,map:()=>zc,mergeObjectSchemas:()=>gt,message:()=>pc,messages:()=>Ms,nan:()=>Pc,nativeEnum:()=>Gc,never:()=>Bc,null:()=>Oc,nullable:()=>Xc,number:()=>Cs,object:()=>Cc,objectUtil:()=>lr,oboolean:()=>nd,onumber:()=>rd,optional:()=>Yc,ostring:()=>td,parseBody:()=>le,pipeline:()=>ed,preprocess:()=>Qc,processCreateParams:()=>S,promise:()=>Jc,quotelessJson:()=>Rl,readonly:()=>Uc,record:()=>jc,ref:()=>Kc,serve:()=>Vt,set:()=>Fc,setErrorMap:()=>gs,strictObject:()=>Dc,string:()=>Rs,symbol:()=>Sc,table:()=>mc,tablerow:()=>hc,transformer:()=>Vn,transforms:()=>Ri,tuple:()=>$c,ulidRegex:()=>Ss,undefined:()=>Ec,union:()=>Hc,unknown:()=>Ic,user:()=>uc,util:()=>I,uuidRegex:()=>Es,variable:()=>cc,version:()=>Ws,void:()=>Ac,z:()=>y});module.exports=Su(cv);var Ms={};Xe(Ms,{defaults:()=>vy,markdown:()=>hy,markdownBloc:()=>yy});var Yn=Object.defineProperty,Eu=Object.defineProperties,Ou=Object.getOwnPropertyDescriptors,or=Object.getOwnPropertySymbols,Ii=Object.prototype.hasOwnProperty,Bi=Object.prototype.propertyIsEnumerable,qs=(t,e,r)=>e in t?Yn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,c=(t,e)=>{for(var r in e||(e={}))Ii.call(e,r)&&qs(t,r,e[r]);if(or)for(var r of or(e))Bi.call(e,r)&&qs(t,r,e[r]);return t},f=(t,e)=>Eu(t,Ou(e)),a=(t,e)=>Yn(t,"name",{value:e,configurable:!0}),Ai=(t,e)=>{var r={};for(var n in t)Ii.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&or)for(var n of or(t))e.indexOf(n)<0&&Bi.call(t,n)&&(r[n]=t[n]);return r},zr=(t,e)=>{for(var r in e)Yn(t,r,{get:e[r],enumerable:!0})},Zu={},Ri={};zr(Ri,{errors:()=>Mi,fromJSONSchema:()=>cd,fromJSONSchemaLegacy:()=>Kh,fromObject:()=>Gn,toJSONSchema:()=>q,toJSONSchemaLegacy:()=>fy,toTypescriptSchema:()=>cs,toTypescriptType:()=>Xn});var y={};zr(y,{BRAND:()=>zl,DIRTY:()=>Ne,EMPTY_PATH:()=>Hl,INVALID:()=>x,NEVER:()=>id,OK:()=>G,ParseInputLazyPath:()=>oe,ParseStatus:()=>re,Schema:()=>O,ZodAny:()=>ct,ZodArray:()=>dt,ZodBigInt:()=>en,ZodBoolean:()=>tn,ZodBranded:()=>rn,ZodCatch:()=>nn,ZodDate:()=>sn,ZodDefault:()=>zt,ZodDiscriminatedUnion:()=>hs,ZodEffects:()=>Se,ZodEnum:()=>Ge,ZodError:()=>pe,ZodFirstPartyTypeKind:()=>ps,ZodFunction:()=>vs,ZodIntersection:()=>an,ZodIssueCode:()=>m,ZodLazy:()=>on,ZodLiteral:()=>ln,ZodMap:()=>_s,ZodNaN:()=>Ts,ZodNativeEnum:()=>cn,ZodNever:()=>ft,ZodNull:()=>dn,ZodNullable:()=>$e,ZodNumber:()=>un,ZodObject:()=>je,ZodOptional:()=>ye,ZodParsedType:()=>_,ZodPipeline:()=>pn,ZodPromise:()=>Wt,ZodReadonly:()=>Lt,ZodRecord:()=>bs,ZodRef:()=>ws,ZodSchema:()=>O,ZodSet:()=>Ps,ZodString:()=>J,ZodSymbol:()=>Bs,ZodTransformer:()=>Se,ZodTuple:()=>Ke,ZodType:()=>O,ZodUndefined:()=>qt,ZodUnion:()=>fn,ZodUnknown:()=>it,ZodVoid:()=>As,addIssueToContext:()=>v,agent:()=>fc,aimodel:()=>vc,any:()=>Zc,array:()=>Rc,bigint:()=>xc,boolean:()=>Ds,coerce:()=>sd,conversation:()=>dc,createZodEnum:()=>Ft,cuid2Regex:()=>ks,cuidRegex:()=>xs,custom:()=>ms,datasource:()=>_c,date:()=>kc,default:()=>yh,discriminatedUnion:()=>Nc,effect:()=>Vn,emailRegex:()=>Os,enum:()=>Vc,errorUtil:()=>P,event:()=>gc,function:()=>Wc,getErrorMap:()=>ot,getParsedType:()=>he,instanceof:()=>wc,intent:()=>yc,intersection:()=>Mc,ipv4Regex:()=>Zs,ipv6Regex:()=>Is,isAborted:()=>dr,isAsync:()=>jt,isDirty:()=>ur,isEmojiRegex:()=>nc,isValid:()=>lt,knowledgebase:()=>Tc,late:()=>bc,lazy:()=>Lc,literal:()=>qc,makeIssue:()=>$t,map:()=>zc,message:()=>pc,nan:()=>Pc,nativeEnum:()=>Gc,never:()=>Bc,null:()=>Oc,nullable:()=>Xc,number:()=>Cs,object:()=>Cc,objectUtil:()=>lr,oboolean:()=>nd,onumber:()=>rd,optional:()=>Yc,ostring:()=>td,pipeline:()=>ed,preprocess:()=>Qc,processCreateParams:()=>S,promise:()=>Jc,quotelessJson:()=>Rl,readonly:()=>Uc,record:()=>jc,ref:()=>Kc,set:()=>Fc,setErrorMap:()=>gs,strictObject:()=>Dc,string:()=>Rs,symbol:()=>Sc,table:()=>mc,tablerow:()=>hc,transformer:()=>Vn,tuple:()=>$c,ulidRegex:()=>Ss,undefined:()=>Ec,union:()=>Hc,unknown:()=>Ic,user:()=>uc,util:()=>I,uuidRegex:()=>Es,variable:()=>cc,void:()=>Ac});var w="x-zui";function Ci(t){return typeof t=="symbol"?"symbol":typeof t=="bigint"?`${t.toString()}n`:b(t)}a(Ci,"primitiveToTypscriptLiteralType");function b(t){return typeof t>"u"?"undefined":typeof t=="symbol"?t.description?`Symbol(${b(t.description)})`:"Symbol()":typeof t=="bigint"?`BigInt(${t.toString()})`:typeof t=="string"?Ni(t):JSON.stringify(t)}a(b,"primitiveToTypescriptValue");function nt(t){return typeof t>"u"?"undefined":JSON.stringify(t)}a(nt,"unknownToTypescriptValue");var Di=a((t,e)=>{let r=Object.entries(t),n=e?" as const":"";return`{ ${r.map(([s,i])=>`${Mn(s)}: ${nt(i)}`).join(", ")} }${n}`},"recordOfUnknownToTypescriptRecord"),Mn=a(t=>/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t)?t:b(t),"toPropertyKey"),Iu=a(t=>t.charAt(0).toUpperCase()+t.slice(1),"capitalize"),Hi=a(t=>{let e=/[^a-zA-Z0-9_]/g;return t.split(e).map(Iu).filter(n=>!!n).join("")},"toTypeArgumentName"),Vs=a(t=>{for(var e;t.length&&!((e=t[0])!=null&&e.trim());)t.shift();for(;t.length&&!t[t.length-1].trim();)t.pop()},"trimEmptyLinesInPlace"),z=a(t=>{t=t?.replace(/(\n(\s*)?){3,}/g,`
2
2
 
3
3
  `);let e=a(s=>s.startsWith("* ")?` ${s}`:` * ${s}`,"ensureLineStartsWithAsterisk"),r=a(s=>s.replace(/\*\//g,"*\\/"),"escapeCommentEnd"),n=(t??"").split(`
4
4
  `).map(s=>s.trim());return Vs(n),n.length&&(n[0]=n[0].replace(/^\/\*\*?/,""),n[n.length-1]=n[n.length-1].replace(/\*\/$/,"")),Vs(n),n.length===0?"":n.length===1?`/** ${r(n[0])} */`:`/**
5
5
  ${n.map(e).map(r).join(`
6
6
  `)}
7
- */`},"getMultilineComment");function Ni(t){if(typeof t!="string")return"";let r=String.raw`${t}`.replace(/\\/g,"\\\\").replace(/\n/g,"\\n").replace(/"/g,'\\"').replace(/'/g,"\\'");return r.includes("`")?`"${r}"`:r.includes("'")?`"${r}"`:`'${r}'`}a(Ni,"escapeString");var Mi={};zr(Mi,{JSONSchemaToZuiError:()=>Fr,ObjectToZuiError:()=>$n,UnrepresentableGenericError:()=>jn,UnsupportedJSONSchemaToZuiError:()=>Pe,UnsupportedZuiCheckToJSONSchemaError:()=>Wi,UnsupportedZuiToJSONSchemaError:()=>te,UnsupportedZuiToTypescriptSchemaError:()=>Be,UnsupportedZuiToTypescriptTypeError:()=>Xi,UntitledDeclarationError:()=>ea,ZuiToJSONSchemaError:()=>Wr,ZuiToTypescriptSchemaError:()=>Vi,ZuiToTypescriptTypeError:()=>Lr,ZuiTransformError:()=>pt});var $i=class extends Error{constructor(e,r){super(r),this.transform=e}};a($i,"ZuiTransformError");var pt=$i,ji=class extends pt{constructor(e){super("json-schema-to-zui",e)}};a(ji,"JSONSchemaToZuiError");var Fr=ji,Ki=class extends pt{constructor(e){super("object-to-zui",e)}};a(Ki,"ObjectToZuiError");var $n=Ki,Ui=class extends pt{constructor(e){super("zui-to-json-schema",e)}};a(Ui,"ZuiToJSONSchemaError");var Wr=Ui,zi=class extends Wr{constructor(e,{suggestedAlternative:r}={}){super(`Zod type ${e} cannot be transformed to JSON Schema.`+(r?` Suggested alternative: ${r}`:""))}};a(zi,"UnsupportedZuiToJSONSchemaError");var te=zi,Fi=class extends Wr{constructor({zodType:e,checkKind:r}){super(`Zod check .${r}() of type ${e} cannot be transformed to JSON Schema.`)}};a(Fi,"UnsupportedZuiCheckToJSONSchemaError");var Wi=Fi,Li=class extends Fr{constructor(e){super(`JSON Schema ${JSON.stringify(e)} cannot be transformed to ZUI type.`)}};a(Li,"UnsupportedJSONSchemaToZuiError");var Pe=Li,qi=class extends pt{constructor(e){super("zui-to-typescript-schema",e)}};a(qi,"ZuiToTypescriptSchemaError");var Vi=qi,Gi=class extends Vi{constructor(e){super(`Zod type ${e} cannot be transformed to TypeScript schema.`)}};a(Gi,"UnsupportedZuiToTypescriptSchemaError");var Be=Gi,Ji=class extends pt{constructor(e){super("zui-to-typescript-type",e)}};a(Ji,"ZuiToTypescriptTypeError");var Lr=Ji,Yi=class extends Lr{constructor(e){super(`Zod type ${e} cannot be transformed to TypeScript type.`)}};a(Yi,"UnsupportedZuiToTypescriptTypeError");var Xi=Yi,Qi=class extends Lr{constructor(){super("Schema must have a title to be transformed to a TypeScript type with a declaration.")}};a(Qi,"UntitledDeclarationError");var ea=Qi,ta=class extends Lr{constructor(){super('ZodRef can only be transformed to a TypeScript type with a "type" declaration.')}};a(ta,"UnrepresentableGenericError");var jn=ta,ra=["string","number","boolean","unknown","void","any","null","undefined","never","bigint","symbol","object"],Iu=5,Bu=a(t=>ra.includes(t),"isPrimitive"),Au=a(t=>ra.map(e=>`${e}[]`).includes(t),"isArrayOfPrimitives"),Bn=a(t=>t.replace(/ +/g," ").trim(),"stripSpaces"),na=class{constructor(e,r){this.key=e,this.value=r}};a(na,"KeyValue");var Yt=na,sa=class{constructor(e){this.schema=e}};a(sa,"FnParameters");var Gs=sa,ia=class{constructor(e){this.schema=e}};a(ia,"FnReturn");var Js=ia,aa=class{constructor(e){this.props=e}};a(aa,"Declaration");var Rt=aa;function Xn(t,e={}){let r=Du(t,e),n=B(r,e);return e.formatter&&(n=e.formatter(n)),n}a(Xn,"toTypescriptType");var Ys=a(t=>t.endsWith("?")?t:`${t}?`,"_optionalKey");function B(t,e){var r,n,s;let i=f(c({},e),{declaration:!1,parent:t});if(t===null)return"";if(t instanceof Rt)return Ru(t,i);if(t instanceof Yt){let d;if(t.value instanceof p.ZodOptional?d=t.value:t.value instanceof p.ZodDefault&&e.treatDefaultAsOptional&&(d=t.value._def.innerType.optional()),d){let k=d._def.innerType;return k instanceof p.Schema&&!k.description&&d.description&&(k=k?.describe(d.description)),B(new Yt(Ys(t.key),k),i)}let u=z(t.value._def.description||t.value.description),g=u?.trim().length>0?`
8
- `:"",h=t.value.describe(""),Z=t.value instanceof p.ZodAny?Ys(t.key):t.key;return`${g}${u}${g}${Z}: ${B(h,i)}${g}`}if(t instanceof Gs){if(t.schema instanceof p.ZodTuple){let h="";for(let T=0;T<t.schema.items.length;T++){let Z=(s=(n=(r=t.schema.items[T])==null?void 0:r.ui)==null?void 0:n.title)!=null?s:`arg${T}`,k=t.schema.items[T];h+=`${B(new Yt(Mn(Z),k),i)}${T<t.schema.items.length-1?", ":""} `}return h}let d=t.schema.naked()instanceof p.ZodLiteral,u=B(t.schema,i).trim();return u.startsWith("{")&&u.endsWith("}")||u.startsWith("[")&&u.endsWith("]")||u.startsWith("(")&&u.endsWith(")")||u.startsWith("Array<")&&u.endsWith(">")||u.startsWith("Record<")&&u.endsWith(">")||Au(u)||d?`args: ${u}`:u}if(t instanceof Js)return t.schema instanceof p.ZodOptional?`${B(t.schema.unwrap(),i)} | undefined`:B(t.schema,i);let o=t,l=o._def;switch(l.typeName){case p.ZodFirstPartyTypeKind.ZodString:return`${z(o.description)} string`.trim();case p.ZodFirstPartyTypeKind.ZodNumber:case p.ZodFirstPartyTypeKind.ZodNaN:case p.ZodFirstPartyTypeKind.ZodBigInt:return`${z(o.description)} number`.trim();case p.ZodFirstPartyTypeKind.ZodBoolean:return`${z(o.description)} boolean`.trim();case p.ZodFirstPartyTypeKind.ZodDate:return`${z(o.description)} Date`.trim();case p.ZodFirstPartyTypeKind.ZodUndefined:return`${z(o.description)} undefined`.trim();case p.ZodFirstPartyTypeKind.ZodNull:return`${z(o.description)} null`.trim();case p.ZodFirstPartyTypeKind.ZodAny:return`${z(o.description)} any`.trim();case p.ZodFirstPartyTypeKind.ZodUnknown:return`${z(o.description)} unknown`.trim();case p.ZodFirstPartyTypeKind.ZodNever:return`${z(o.description)} never`.trim();case p.ZodFirstPartyTypeKind.ZodVoid:return`${z(o.description)} void`.trim();case p.ZodFirstPartyTypeKind.ZodArray:let d=B(l.type,i);return Bu(d)?`${d}[]`:`Array<${d}>`;case p.ZodFirstPartyTypeKind.ZodObject:return`{ ${Object.entries(l.shape()).map(([ee,Zn])=>Zn instanceof p.Schema?B(new Yt(Mn(ee),Zn),i):`${ee}: unknown`).join("; ")} }`;case p.ZodFirstPartyTypeKind.ZodUnion:let g=l.options.map(ee=>B(ee,i));return`${z(o.description)}
7
+ */`},"getMultilineComment");function Ni(t){if(typeof t!="string")return"";let r=String.raw`${t}`.replace(/\\/g,"\\\\").replace(/\n/g,"\\n").replace(/"/g,'\\"').replace(/'/g,"\\'");return r.includes("`")?`"${r}"`:r.includes("'")?`"${r}"`:`'${r}'`}a(Ni,"escapeString");var Mi={};zr(Mi,{JSONSchemaToZuiError:()=>Fr,ObjectToZuiError:()=>$n,UnrepresentableGenericError:()=>jn,UnsupportedJSONSchemaToZuiError:()=>Pe,UnsupportedZuiCheckToJSONSchemaError:()=>Wi,UnsupportedZuiToJSONSchemaError:()=>te,UnsupportedZuiToTypescriptSchemaError:()=>Be,UnsupportedZuiToTypescriptTypeError:()=>Xi,UntitledDeclarationError:()=>ea,ZuiToJSONSchemaError:()=>Wr,ZuiToTypescriptSchemaError:()=>Vi,ZuiToTypescriptTypeError:()=>Lr,ZuiTransformError:()=>pt});var $i=class extends Error{constructor(e,r){super(r),this.transform=e}};a($i,"ZuiTransformError");var pt=$i,ji=class extends pt{constructor(e){super("json-schema-to-zui",e)}};a(ji,"JSONSchemaToZuiError");var Fr=ji,Ki=class extends pt{constructor(e){super("object-to-zui",e)}};a(Ki,"ObjectToZuiError");var $n=Ki,Ui=class extends pt{constructor(e){super("zui-to-json-schema",e)}};a(Ui,"ZuiToJSONSchemaError");var Wr=Ui,zi=class extends Wr{constructor(e,{suggestedAlternative:r}={}){super(`Zod type ${e} cannot be transformed to JSON Schema.`+(r?` Suggested alternative: ${r}`:""))}};a(zi,"UnsupportedZuiToJSONSchemaError");var te=zi,Fi=class extends Wr{constructor({zodType:e,checkKind:r}){super(`Zod check .${r}() of type ${e} cannot be transformed to JSON Schema.`)}};a(Fi,"UnsupportedZuiCheckToJSONSchemaError");var Wi=Fi,Li=class extends Fr{constructor(e){super(`JSON Schema ${JSON.stringify(e)} cannot be transformed to ZUI type.`)}};a(Li,"UnsupportedJSONSchemaToZuiError");var Pe=Li,qi=class extends pt{constructor(e){super("zui-to-typescript-schema",e)}};a(qi,"ZuiToTypescriptSchemaError");var Vi=qi,Gi=class extends Vi{constructor(e){super(`Zod type ${e} cannot be transformed to TypeScript schema.`)}};a(Gi,"UnsupportedZuiToTypescriptSchemaError");var Be=Gi,Ji=class extends pt{constructor(e){super("zui-to-typescript-type",e)}};a(Ji,"ZuiToTypescriptTypeError");var Lr=Ji,Yi=class extends Lr{constructor(e){super(`Zod type ${e} cannot be transformed to TypeScript type.`)}};a(Yi,"UnsupportedZuiToTypescriptTypeError");var Xi=Yi,Qi=class extends Lr{constructor(){super("Schema must have a title to be transformed to a TypeScript type with a declaration.")}};a(Qi,"UntitledDeclarationError");var ea=Qi,ta=class extends Lr{constructor(){super('ZodRef can only be transformed to a TypeScript type with a "type" declaration.')}};a(ta,"UnrepresentableGenericError");var jn=ta,ra=["string","number","boolean","unknown","void","any","null","undefined","never","bigint","symbol","object"],Bu=5,Au=a(t=>ra.includes(t),"isPrimitive"),Ru=a(t=>ra.map(e=>`${e}[]`).includes(t),"isArrayOfPrimitives"),Bn=a(t=>t.replace(/ +/g," ").trim(),"stripSpaces"),na=class{constructor(e,r){this.key=e,this.value=r}};a(na,"KeyValue");var Yt=na,sa=class{constructor(e){this.schema=e}};a(sa,"FnParameters");var Gs=sa,ia=class{constructor(e){this.schema=e}};a(ia,"FnReturn");var Js=ia,aa=class{constructor(e){this.props=e}};a(aa,"Declaration");var Rt=aa;function Xn(t,e={}){let r=Hu(t,e),n=B(r,e);return e.formatter&&(n=e.formatter(n)),n}a(Xn,"toTypescriptType");var Ys=a(t=>t.endsWith("?")?t:`${t}?`,"_optionalKey");function B(t,e){var r,n,s;let i=f(c({},e),{declaration:!1,parent:t});if(t===null)return"";if(t instanceof Rt)return Cu(t,i);if(t instanceof Yt){let d;if(t.value instanceof p.ZodOptional?d=t.value:t.value instanceof p.ZodDefault&&e.treatDefaultAsOptional&&(d=t.value._def.innerType.optional()),d){let k=d._def.innerType;return k instanceof p.Schema&&!k.description&&d.description&&(k=k?.describe(d.description)),B(new Yt(Ys(t.key),k),i)}let u=z(t.value._def.description||t.value.description),g=u?.trim().length>0?`
8
+ `:"",h=t.value.describe(""),Z=t.value instanceof p.ZodAny?Ys(t.key):t.key;return`${g}${u}${g}${Z}: ${B(h,i)}${g}`}if(t instanceof Gs){if(t.schema instanceof p.ZodTuple){let h="";for(let T=0;T<t.schema.items.length;T++){let Z=(s=(n=(r=t.schema.items[T])==null?void 0:r.ui)==null?void 0:n.title)!=null?s:`arg${T}`,k=t.schema.items[T];h+=`${B(new Yt(Mn(Z),k),i)}${T<t.schema.items.length-1?", ":""} `}return h}let d=t.schema.naked()instanceof p.ZodLiteral,u=B(t.schema,i).trim();return u.startsWith("{")&&u.endsWith("}")||u.startsWith("[")&&u.endsWith("]")||u.startsWith("(")&&u.endsWith(")")||u.startsWith("Array<")&&u.endsWith(">")||u.startsWith("Record<")&&u.endsWith(">")||Ru(u)||d?`args: ${u}`:u}if(t instanceof Js)return t.schema instanceof p.ZodOptional?`${B(t.schema.unwrap(),i)} | undefined`:B(t.schema,i);let o=t,l=o._def;switch(l.typeName){case p.ZodFirstPartyTypeKind.ZodString:return`${z(o.description)} string`.trim();case p.ZodFirstPartyTypeKind.ZodNumber:case p.ZodFirstPartyTypeKind.ZodNaN:case p.ZodFirstPartyTypeKind.ZodBigInt:return`${z(o.description)} number`.trim();case p.ZodFirstPartyTypeKind.ZodBoolean:return`${z(o.description)} boolean`.trim();case p.ZodFirstPartyTypeKind.ZodDate:return`${z(o.description)} Date`.trim();case p.ZodFirstPartyTypeKind.ZodUndefined:return`${z(o.description)} undefined`.trim();case p.ZodFirstPartyTypeKind.ZodNull:return`${z(o.description)} null`.trim();case p.ZodFirstPartyTypeKind.ZodAny:return`${z(o.description)} any`.trim();case p.ZodFirstPartyTypeKind.ZodUnknown:return`${z(o.description)} unknown`.trim();case p.ZodFirstPartyTypeKind.ZodNever:return`${z(o.description)} never`.trim();case p.ZodFirstPartyTypeKind.ZodVoid:return`${z(o.description)} void`.trim();case p.ZodFirstPartyTypeKind.ZodArray:let d=B(l.type,i);return Au(d)?`${d}[]`:`Array<${d}>`;case p.ZodFirstPartyTypeKind.ZodObject:return`{ ${Object.entries(l.shape()).map(([ee,Zn])=>Zn instanceof p.Schema?B(new Yt(Mn(ee),Zn),i):`${ee}: unknown`).join("; ")} }`;case p.ZodFirstPartyTypeKind.ZodUnion:let g=l.options.map(ee=>B(ee,i));return`${z(o.description)}
9
9
  ${g.join(" | ")}`;case p.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:let h=l.options.map(ee=>B(ee,i));return`${z(o.description)}
10
10
  ${h.join(" | ")}`;case p.ZodFirstPartyTypeKind.ZodIntersection:return`${B(l.left,i)} & ${B(l.right,i)}`;case p.ZodFirstPartyTypeKind.ZodTuple:return l.items.length===0?"[]":`[${l.items.map(ee=>B(ee,i)).join(", ")}]`;case p.ZodFirstPartyTypeKind.ZodRecord:let Z=B(l.keyType,i),k=B(l.valueType,i);return`${z(o.description)} { [key: ${Z}]: ${k} }`;case p.ZodFirstPartyTypeKind.ZodMap:return`Map<${B(l.keyType,i)}, ${B(l.valueType,i)}>`;case p.ZodFirstPartyTypeKind.ZodSet:return`Set<${B(l.valueType,i)}>`;case p.ZodFirstPartyTypeKind.ZodFunction:let K=B(new Gs(l.args),i),F=B(new Js(l.returns),i),Q=e?.parent instanceof Rt&&e?.parent.props.type==="type";return e?.declaration&&!Q?`${z(o.description)}
11
11
  (${K}): ${F}`:`${z(o.description)}
12
12
  (${K}) => ${F}`;case p.ZodFirstPartyTypeKind.ZodLazy:return B(l.getter(),i);case p.ZodFirstPartyTypeKind.ZodLiteral:let ie=Ci(l.value);return`${z(o.description)}
13
- ${ie}`.trim();case p.ZodFirstPartyTypeKind.ZodEnum:return l.values.map(b).join(" | ");case p.ZodFirstPartyTypeKind.ZodEffects:return B(l.schema,i);case p.ZodFirstPartyTypeKind.ZodNativeEnum:throw new Xi(p.ZodFirstPartyTypeKind.ZodNativeEnum);case p.ZodFirstPartyTypeKind.ZodOptional:return`${B(l.innerType,i)} | undefined`;case p.ZodFirstPartyTypeKind.ZodNullable:return`${B(l.innerType,i)} | null`;case p.ZodFirstPartyTypeKind.ZodDefault:let ae=e.treatDefaultAsOptional?l.innerType.optional():l.innerType;return B(ae,i);case p.ZodFirstPartyTypeKind.ZodCatch:return B(l.innerType,i);case p.ZodFirstPartyTypeKind.ZodPromise:return`Promise<${B(l.type,i)}>`;case p.ZodFirstPartyTypeKind.ZodBranded:return B(l.type,i);case p.ZodFirstPartyTypeKind.ZodPipeline:return B(l.in,i);case p.ZodFirstPartyTypeKind.ZodSymbol:return`${z(o.description)} symbol`.trim();case p.ZodFirstPartyTypeKind.ZodReadonly:return`Readonly<${B(l.innerType,i)}>`;case p.ZodFirstPartyTypeKind.ZodRef:return Hi(l.uri);default:I.assertNever(l)}}a(B,"sUnwrapZod");var Ru=a((t,e)=>{if(t.props.type==="none")return B(t.props.schema,e);let{schema:r,identifier:n}=t.props,s=z(r.description),i=r.describe(""),o=B(i,f(c({},e),{declaration:!0})),d=o.split(`
14
- `).length>=Iu&&e.includeClosingTags?`// end of ${n}`:"";if(t.props.type!=="type"&&r instanceof p.ZodFunction)return Bn(`${s}
15
- declare function ${n}${o};${d}`);if(t.props.type==="variable")return Bn(`${s}declare const ${n}: ${o};${d}`);let u=t.props.args.length>0?`<${t.props.args.map(Hi).join(", ")}>`:"";return Bn(`${s}type ${t.props.identifier}${u} = ${o};${d}`)},"unwrapDeclaration"),Cu=a(t=>t.declaration?t.declaration===!0?"variable":t.declaration:"none","getDeclarationType"),Du=a((t,e)=>{let r=Cu(e),n=t.getReferences();if(r==="none"){if(n.length>0)throw new jn;return new Rt({type:"none",schema:t})}let s="title"in t.ui?t.ui.title:null;if(!s)throw new ea;if(r==="variable"){if(n.length>0)throw new jn;return new Rt({type:"variable",identifier:s,schema:t})}return new Rt({type:"type",identifier:s,schema:t,args:n})},"getDeclarationProps"),Hu=typeof global=="object"&&global&&global.Object===Object&&global,oa=Hu,Nu=typeof self=="object"&&self&&self.Object===Object&&self,Mu=oa||Nu||Function("return this")(),_e=Mu,$u=_e.Symbol,xe=$u,la=Object.prototype,ju=la.hasOwnProperty,Ku=la.toString,_t=xe?xe.toStringTag:void 0;function ca(t){var e=ju.call(t,_t),r=t[_t];try{t[_t]=void 0;var n=!0}catch{}var s=Ku.call(t);return n&&(e?t[_t]=r:delete t[_t]),s}a(ca,"getRawTag");var Uu=ca,zu=Object.prototype,Fu=zu.toString;function da(t){return Fu.call(t)}a(da,"objectToString");var Wu=da,Lu="[object Null]",qu="[object Undefined]",Xs=xe?xe.toStringTag:void 0;function ua(t){return t==null?t===void 0?qu:Lu:Xs&&Xs in Object(t)?Uu(t):Wu(t)}a(ua,"baseGetTag");var Ue=ua;function pa(t){return t!=null&&typeof t=="object"}a(pa,"isObjectLike");var Me=pa,Vu="[object Symbol]";function fa(t){return typeof t=="symbol"||Me(t)&&Ue(t)==Vu}a(fa,"isSymbol");var Qn=fa;function ga(t,e){for(var r=-1,n=t==null?0:t.length,s=Array(n);++r<n;)s[r]=e(t[r],r,t);return s}a(ga,"arrayMap");var ma=ga,Gu=Array.isArray,ve=Gu,Ju=1/0,Qs=xe?xe.prototype:void 0,ei=Qs?Qs.toString:void 0;function es(t){if(typeof t=="string")return t;if(ve(t))return ma(t,es)+"";if(Qn(t))return ei?ei.call(t):"";var e=t+"";return e=="0"&&1/t==-Ju?"-0":e}a(es,"baseToString");var Yu=es;function ha(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}a(ha,"isObject");var at=ha;function ya(t){return t}a(ya,"identity");var Xu=ya,Qu="[object AsyncFunction]",ep="[object Function]",tp="[object GeneratorFunction]",rp="[object Proxy]";function va(t){if(!at(t))return!1;var e=Ue(t);return e==ep||e==tp||e==Qu||e==rp}a(va,"isFunction");var _a=va,np=_e["__core-js_shared__"],An=np,ti=(function(){var t=/[^.]+$/.exec(An&&An.keys&&An.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function Ta(t){return!!ti&&ti in t}a(Ta,"isMasked");var sp=Ta,ip=Function.prototype,ap=ip.toString;function ba(t){if(t!=null){try{return ap.call(t)}catch{}try{return t+""}catch{}}return""}a(ba,"toSource");var ze=ba,op=/[\\^$.*+?()[\]{}|]/g,lp=/^\[object .+?Constructor\]$/,cp=Function.prototype,dp=Object.prototype,up=cp.toString,pp=dp.hasOwnProperty,fp=RegExp("^"+up.call(pp).replace(op,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function wa(t){if(!at(t)||sp(t))return!1;var e=_a(t)?fp:lp;return e.test(ze(t))}a(wa,"baseIsNative");var gp=wa;function Pa(t,e){return t?.[e]}a(Pa,"getValue");var mp=Pa;function xa(t,e){var r=mp(t,e);return gp(r)?r:void 0}a(xa,"getNative");var Fe=xa,hp=Fe(_e,"WeakMap"),Kn=hp,yp=(function(){try{var t=Fe(Object,"defineProperty");return t({},"",{}),t}catch{}})(),ri=yp,vp=9007199254740991,_p=/^(?:0|[1-9]\d*)$/;function ka(t,e){var r=typeof t;return e=e??vp,!!e&&(r=="number"||r!="symbol"&&_p.test(t))&&t>-1&&t%1==0&&t<e}a(ka,"isIndex");var ts=ka;function Sa(t,e,r){e=="__proto__"&&ri?ri(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}a(Sa,"baseAssignValue");var Ea=Sa;function Oa(t,e){return t===e||t!==t&&e!==e}a(Oa,"eq");var rs=Oa,Tp=Object.prototype,bp=Tp.hasOwnProperty;function Za(t,e,r){var n=t[e];(!(bp.call(t,e)&&rs(n,r))||r===void 0&&!(e in t))&&Ea(t,e,r)}a(Za,"assignValue");var wp=Za,Pp=9007199254740991;function Ia(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Pp}a(Ia,"isLength");var ns=Ia;function Ba(t){return t!=null&&ns(t.length)&&!_a(t)}a(Ba,"isArrayLike");var Aa=Ba,xp=Object.prototype;function Ra(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||xp;return t===r}a(Ra,"isPrototype");var Ca=Ra;function Da(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}a(Da,"baseTimes");var kp=Da,Sp="[object Arguments]";function Ha(t){return Me(t)&&Ue(t)==Sp}a(Ha,"baseIsArguments");var ni=Ha,Na=Object.prototype,Ep=Na.hasOwnProperty,Op=Na.propertyIsEnumerable,Zp=ni((function(){return arguments})())?ni:function(t){return Me(t)&&Ep.call(t,"callee")&&!Op.call(t,"callee")},Ma=Zp;function $a(){return!1}a($a,"stubFalse");var Ip=$a,ja=typeof exports=="object"&&exports&&!exports.nodeType&&exports,si=ja&&typeof module=="object"&&module&&!module.nodeType&&module,Bp=si&&si.exports===ja,ii=Bp?_e.Buffer:void 0,Ap=ii?ii.isBuffer:void 0,Rp=Ap||Ip,Un=Rp,Cp="[object Arguments]",Dp="[object Array]",Hp="[object Boolean]",Np="[object Date]",Mp="[object Error]",$p="[object Function]",jp="[object Map]",Kp="[object Number]",Up="[object Object]",zp="[object RegExp]",Fp="[object Set]",Wp="[object String]",Lp="[object WeakMap]",qp="[object ArrayBuffer]",Vp="[object DataView]",Gp="[object Float32Array]",Jp="[object Float64Array]",Yp="[object Int8Array]",Xp="[object Int16Array]",Qp="[object Int32Array]",ef="[object Uint8Array]",tf="[object Uint8ClampedArray]",rf="[object Uint16Array]",nf="[object Uint32Array]",H={};H[Gp]=H[Jp]=H[Yp]=H[Xp]=H[Qp]=H[ef]=H[tf]=H[rf]=H[nf]=!0;H[Cp]=H[Dp]=H[qp]=H[Hp]=H[Vp]=H[Np]=H[Mp]=H[$p]=H[jp]=H[Kp]=H[Up]=H[zp]=H[Fp]=H[Wp]=H[Lp]=!1;function Ka(t){return Me(t)&&ns(t.length)&&!!H[Ue(t)]}a(Ka,"baseIsTypedArray");var sf=Ka;function Ua(t){return function(e){return t(e)}}a(Ua,"baseUnary");var af=Ua,za=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ct=za&&typeof module=="object"&&module&&!module.nodeType&&module,of=Ct&&Ct.exports===za,Rn=of&&oa.process,lf=(function(){try{var t=Ct&&Ct.require&&Ct.require("util").types;return t||Rn&&Rn.binding&&Rn.binding("util")}catch{}})(),ai=lf,oi=ai&&ai.isTypedArray,cf=oi?af(oi):sf,Fa=cf,df=Object.prototype,uf=df.hasOwnProperty;function Wa(t,e){var r=ve(t),n=!r&&Ma(t),s=!r&&!n&&Un(t),i=!r&&!n&&!s&&Fa(t),o=r||n||s||i,l=o?kp(t.length,String):[],d=l.length;for(var u in t)(e||uf.call(t,u))&&!(o&&(u=="length"||s&&(u=="offset"||u=="parent")||i&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||ts(u,d)))&&l.push(u);return l}a(Wa,"arrayLikeKeys");var La=Wa;function qa(t,e){return function(r){return t(e(r))}}a(qa,"overArg");var Va=qa,pf=Va(Object.keys,Object),ff=pf,gf=Object.prototype,mf=gf.hasOwnProperty;function Ga(t){if(!Ca(t))return ff(t);var e=[];for(var r in Object(t))mf.call(t,r)&&r!="constructor"&&e.push(r);return e}a(Ga,"baseKeys");var hf=Ga;function Ja(t){return Aa(t)?La(t):hf(t)}a(Ja,"keys");var ss=Ja;function Ya(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}a(Ya,"nativeKeysIn");var yf=Ya,vf=Object.prototype,_f=vf.hasOwnProperty;function Xa(t){if(!at(t))return yf(t);var e=Ca(t),r=[];for(var n in t)n=="constructor"&&(e||!_f.call(t,n))||r.push(n);return r}a(Xa,"baseKeysIn");var Tf=Xa;function Qa(t){return Aa(t)?La(t,!0):Tf(t)}a(Qa,"keysIn");var bf=Qa,wf=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Pf=/^\w*$/;function eo(t,e){if(ve(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||Qn(t)?!0:Pf.test(t)||!wf.test(t)||e!=null&&t in Object(e)}a(eo,"isKey");var is=eo,xf=Fe(Object,"create"),Ht=xf;function to(){this.__data__=Ht?Ht(null):{},this.size=0}a(to,"hashClear");var kf=to;function ro(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}a(ro,"hashDelete");var Sf=ro,Ef="__lodash_hash_undefined__",Of=Object.prototype,Zf=Of.hasOwnProperty;function no(t){var e=this.__data__;if(Ht){var r=e[t];return r===Ef?void 0:r}return Zf.call(e,t)?e[t]:void 0}a(no,"hashGet");var If=no,Bf=Object.prototype,Af=Bf.hasOwnProperty;function so(t){var e=this.__data__;return Ht?e[t]!==void 0:Af.call(e,t)}a(so,"hashHas");var Rf=so,Cf="__lodash_hash_undefined__";function io(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Ht&&e===void 0?Cf:e,this}a(io,"hashSet");var Df=io;function We(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}a(We,"Hash");We.prototype.clear=kf;We.prototype.delete=Sf;We.prototype.get=If;We.prototype.has=Rf;We.prototype.set=Df;var li=We;function ao(){this.__data__=[],this.size=0}a(ao,"listCacheClear");var Hf=ao;function oo(t,e){for(var r=t.length;r--;)if(rs(t[r][0],e))return r;return-1}a(oo,"assocIndexOf");var qr=oo,Nf=Array.prototype,Mf=Nf.splice;function lo(t){var e=this.__data__,r=qr(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():Mf.call(e,r,1),--this.size,!0}a(lo,"listCacheDelete");var $f=lo;function co(t){var e=this.__data__,r=qr(e,t);return r<0?void 0:e[r][1]}a(co,"listCacheGet");var jf=co;function uo(t){return qr(this.__data__,t)>-1}a(uo,"listCacheHas");var Kf=uo;function po(t,e){var r=this.__data__,n=qr(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this}a(po,"listCacheSet");var Uf=po;function Le(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}a(Le,"ListCache");Le.prototype.clear=Hf;Le.prototype.delete=$f;Le.prototype.get=jf;Le.prototype.has=Kf;Le.prototype.set=Uf;var Vr=Le,zf=Fe(_e,"Map"),Nt=zf;function fo(){this.size=0,this.__data__={hash:new li,map:new(Nt||Vr),string:new li}}a(fo,"mapCacheClear");var Ff=fo;function go(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}a(go,"isKeyable");var Wf=go;function mo(t,e){var r=t.__data__;return Wf(e)?r[typeof e=="string"?"string":"hash"]:r.map}a(mo,"getMapData");var Gr=mo;function ho(t){var e=Gr(this,t).delete(t);return this.size-=e?1:0,e}a(ho,"mapCacheDelete");var Lf=ho;function yo(t){return Gr(this,t).get(t)}a(yo,"mapCacheGet");var qf=yo;function vo(t){return Gr(this,t).has(t)}a(vo,"mapCacheHas");var Vf=vo;function _o(t,e){var r=Gr(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this}a(_o,"mapCacheSet");var Gf=_o;function qe(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}a(qe,"MapCache");qe.prototype.clear=Ff;qe.prototype.delete=Lf;qe.prototype.get=qf;qe.prototype.has=Vf;qe.prototype.set=Gf;var Jr=qe,Jf="Expected a function";function Yr(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(Jf);var r=a(function(){var n=arguments,s=e?e.apply(this,n):n[0],i=r.cache;if(i.has(s))return i.get(s);var o=t.apply(this,n);return r.cache=i.set(s,o)||i,o},"memoized");return r.cache=new(Yr.Cache||Jr),r}a(Yr,"memoize");Yr.Cache=Jr;var Yf=Yr,Xf=500;function To(t){var e=Yf(t,function(n){return r.size===Xf&&r.clear(),n}),r=e.cache;return e}a(To,"memoizeCapped");var Qf=To,eg=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,tg=/\\(\\)?/g,rg=Qf(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(eg,function(r,n,s,i){e.push(s?i.replace(tg,"$1"):n||r)}),e}),ng=rg;function bo(t){return t==null?"":Yu(t)}a(bo,"toString");var sg=bo;function wo(t,e){return ve(t)?t:is(t,e)?[t]:ng(sg(t))}a(wo,"castPath");var Xr=wo,ig=1/0;function Po(t){if(typeof t=="string"||Qn(t))return t;var e=t+"";return e=="0"&&1/t==-ig?"-0":e}a(Po,"toKey");var Ut=Po;function xo(t,e){e=Xr(e,t);for(var r=0,n=e.length;t!=null&&r<n;)t=t[Ut(e[r++])];return r&&r==n?t:void 0}a(xo,"baseGet");var as=xo;function ko(t,e,r){var n=t==null?void 0:as(t,e);return n===void 0?r:n}a(ko,"get");var ag=ko;function So(t,e){for(var r=-1,n=e.length,s=t.length;++r<n;)t[s+r]=e[r];return t}a(So,"arrayPush");var Eo=So,og=Va(Object.getPrototypeOf,Object),Oo=og,lg="[object Object]",cg=Function.prototype,dg=Object.prototype,Zo=cg.toString,ug=dg.hasOwnProperty,pg=Zo.call(Object);function Io(t){if(!Me(t)||Ue(t)!=lg)return!1;var e=Oo(t);if(e===null)return!0;var r=ug.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&Zo.call(r)==pg}a(Io,"isPlainObject");var ci=Io;function Bo(){this.__data__=new Vr,this.size=0}a(Bo,"stackClear");var fg=Bo;function Ao(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}a(Ao,"stackDelete");var gg=Ao;function Ro(t){return this.__data__.get(t)}a(Ro,"stackGet");var mg=Ro;function Co(t){return this.__data__.has(t)}a(Co,"stackHas");var hg=Co,yg=200;function Do(t,e){var r=this.__data__;if(r instanceof Vr){var n=r.__data__;if(!Nt||n.length<yg-1)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Jr(n)}return r.set(t,e),this.size=r.size,this}a(Do,"stackSet");var vg=Do;function Ve(t){var e=this.__data__=new Vr(t);this.size=e.size}a(Ve,"Stack");Ve.prototype.clear=fg;Ve.prototype.delete=gg;Ve.prototype.get=mg;Ve.prototype.has=hg;Ve.prototype.set=vg;var Qt=Ve;function Ho(t,e){for(var r=-1,n=t==null?0:t.length,s=0,i=[];++r<n;){var o=t[r];e(o,r,t)&&(i[s++]=o)}return i}a(Ho,"arrayFilter");var _g=Ho;function No(){return[]}a(No,"stubArray");var Mo=No,Tg=Object.prototype,bg=Tg.propertyIsEnumerable,di=Object.getOwnPropertySymbols,wg=di?function(t){return t==null?[]:(t=Object(t),_g(di(t),function(e){return bg.call(t,e)}))}:Mo,$o=wg,Pg=Object.getOwnPropertySymbols,xg=Pg?function(t){for(var e=[];t;)Eo(e,$o(t)),t=Oo(t);return e}:Mo,kg=xg;function jo(t,e,r){var n=e(t);return ve(t)?n:Eo(n,r(t))}a(jo,"baseGetAllKeys");var Ko=jo;function Uo(t){return Ko(t,ss,$o)}a(Uo,"getAllKeys");var ui=Uo;function zo(t){return Ko(t,bf,kg)}a(zo,"getAllKeysIn");var Sg=zo,Eg=Fe(_e,"DataView"),zn=Eg,Og=Fe(_e,"Promise"),Fn=Og,Zg=Fe(_e,"Set"),Wn=Zg,pi="[object Map]",Ig="[object Object]",fi="[object Promise]",gi="[object Set]",mi="[object WeakMap]",hi="[object DataView]",Bg=ze(zn),Ag=ze(Nt),Rg=ze(Fn),Cg=ze(Wn),Dg=ze(Kn),Ae=Ue;(zn&&Ae(new zn(new ArrayBuffer(1)))!=hi||Nt&&Ae(new Nt)!=pi||Fn&&Ae(Fn.resolve())!=fi||Wn&&Ae(new Wn)!=gi||Kn&&Ae(new Kn)!=mi)&&(Ae=a(function(t){var e=Ue(t),r=e==Ig?t.constructor:void 0,n=r?ze(r):"";if(n)switch(n){case Bg:return hi;case Ag:return pi;case Rg:return fi;case Cg:return gi;case Dg:return mi}return e},"getTag"));var yi=Ae,Hg=_e.Uint8Array,vi=Hg,Ng="__lodash_hash_undefined__";function Fo(t){return this.__data__.set(t,Ng),this}a(Fo,"setCacheAdd");var Mg=Fo;function Wo(t){return this.__data__.has(t)}a(Wo,"setCacheHas");var $g=Wo;function Mt(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new Jr;++e<r;)this.add(t[e])}a(Mt,"SetCache");Mt.prototype.add=Mt.prototype.push=Mg;Mt.prototype.has=$g;var jg=Mt;function Lo(t,e){for(var r=-1,n=t==null?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}a(Lo,"arraySome");var Kg=Lo;function qo(t,e){return t.has(e)}a(qo,"cacheHas");var Ug=qo,zg=1,Fg=2;function Vo(t,e,r,n,s,i){var o=r&zg,l=t.length,d=e.length;if(l!=d&&!(o&&d>l))return!1;var u=i.get(t),g=i.get(e);if(u&&g)return u==e&&g==t;var h=-1,T=!0,Z=r&Fg?new jg:void 0;for(i.set(t,e),i.set(e,t);++h<l;){var k=t[h],K=e[h];if(n)var F=o?n(K,k,h,e,t,i):n(k,K,h,t,e,i);if(F!==void 0){if(F)continue;T=!1;break}if(Z){if(!Kg(e,function(Q,ie){if(!Ug(Z,ie)&&(k===Q||s(k,Q,r,n,i)))return Z.push(ie)})){T=!1;break}}else if(!(k===K||s(k,K,r,n,i))){T=!1;break}}return i.delete(t),i.delete(e),T}a(Vo,"equalArrays");var Go=Vo;function Jo(t){var e=-1,r=Array(t.size);return t.forEach(function(n,s){r[++e]=[s,n]}),r}a(Jo,"mapToArray");var Wg=Jo;function Yo(t){var e=-1,r=Array(t.size);return t.forEach(function(n){r[++e]=n}),r}a(Yo,"setToArray");var Lg=Yo,qg=1,Vg=2,Gg="[object Boolean]",Jg="[object Date]",Yg="[object Error]",Xg="[object Map]",Qg="[object Number]",em="[object RegExp]",tm="[object Set]",rm="[object String]",nm="[object Symbol]",sm="[object ArrayBuffer]",im="[object DataView]",_i=xe?xe.prototype:void 0,Cn=_i?_i.valueOf:void 0;function Xo(t,e,r,n,s,i,o){switch(r){case im:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case sm:return!(t.byteLength!=e.byteLength||!i(new vi(t),new vi(e)));case Gg:case Jg:case Qg:return rs(+t,+e);case Yg:return t.name==e.name&&t.message==e.message;case em:case rm:return t==e+"";case Xg:var l=Wg;case tm:var d=n&qg;if(l||(l=Lg),t.size!=e.size&&!d)return!1;var u=o.get(t);if(u)return u==e;n|=Vg,o.set(t,e);var g=Go(l(t),l(e),n,s,i,o);return o.delete(t),g;case nm:if(Cn)return Cn.call(t)==Cn.call(e)}return!1}a(Xo,"equalByTag");var am=Xo,om=1,lm=Object.prototype,cm=lm.hasOwnProperty;function Qo(t,e,r,n,s,i){var o=r&om,l=ui(t),d=l.length,u=ui(e),g=u.length;if(d!=g&&!o)return!1;for(var h=d;h--;){var T=l[h];if(!(o?T in e:cm.call(e,T)))return!1}var Z=i.get(t),k=i.get(e);if(Z&&k)return Z==e&&k==t;var K=!0;i.set(t,e),i.set(e,t);for(var F=o;++h<d;){T=l[h];var Q=t[T],ie=e[T];if(n)var ue=o?n(ie,Q,T,e,t,i):n(Q,ie,T,t,e,i);if(!(ue===void 0?Q===ie||s(Q,ie,r,n,i):ue)){K=!1;break}F||(F=T=="constructor")}if(K&&!F){var ae=t.constructor,ee=e.constructor;ae!=ee&&"constructor"in t&&"constructor"in e&&!(typeof ae=="function"&&ae instanceof ae&&typeof ee=="function"&&ee instanceof ee)&&(K=!1)}return i.delete(t),i.delete(e),K}a(Qo,"equalObjects");var dm=Qo,um=1,Ti="[object Arguments]",bi="[object Array]",Xt="[object Object]",pm=Object.prototype,wi=pm.hasOwnProperty;function el(t,e,r,n,s,i){var o=ve(t),l=ve(e),d=o?bi:yi(t),u=l?bi:yi(e);d=d==Ti?Xt:d,u=u==Ti?Xt:u;var g=d==Xt,h=u==Xt,T=d==u;if(T&&Un(t)){if(!Un(e))return!1;o=!0,g=!1}if(T&&!g)return i||(i=new Qt),o||Fa(t)?Go(t,e,r,n,s,i):am(t,e,d,r,n,s,i);if(!(r&um)){var Z=g&&wi.call(t,"__wrapped__"),k=h&&wi.call(e,"__wrapped__");if(Z||k){var K=Z?t.value():t,F=k?e.value():e;return i||(i=new Qt),s(K,F,r,n,i)}}return T?(i||(i=new Qt),dm(t,e,r,n,s,i)):!1}a(el,"baseIsEqualDeep");var fm=el;function os(t,e,r,n,s){return t===e?!0:t==null||e==null||!Me(t)&&!Me(e)?t!==t&&e!==e:fm(t,e,r,n,os,s)}a(os,"baseIsEqual");var Qr=os,gm=1,mm=2;function tl(t,e,r,n){var s=r.length,i=s,o=!n;if(t==null)return!i;for(t=Object(t);s--;){var l=r[s];if(o&&l[2]?l[1]!==t[l[0]]:!(l[0]in t))return!1}for(;++s<i;){l=r[s];var d=l[0],u=t[d],g=l[1];if(o&&l[2]){if(u===void 0&&!(d in t))return!1}else{var h=new Qt;if(n)var T=n(u,g,d,t,e,h);if(!(T===void 0?Qr(g,u,gm|mm,n,h):T))return!1}}return!0}a(tl,"baseIsMatch");var hm=tl;function rl(t){return t===t&&!at(t)}a(rl,"isStrictComparable");var nl=rl;function sl(t){for(var e=ss(t),r=e.length;r--;){var n=e[r],s=t[n];e[r]=[n,s,nl(s)]}return e}a(sl,"getMatchData");var ym=sl;function il(t,e){return function(r){return r==null?!1:r[t]===e&&(e!==void 0||t in Object(r))}}a(il,"matchesStrictComparable");var al=il;function ol(t){var e=ym(t);return e.length==1&&e[0][2]?al(e[0][0],e[0][1]):function(r){return r===t||hm(r,t,e)}}a(ol,"baseMatches");var vm=ol;function ll(t,e){return t!=null&&e in Object(t)}a(ll,"baseHasIn");var _m=ll;function cl(t,e,r){e=Xr(e,t);for(var n=-1,s=e.length,i=!1;++n<s;){var o=Ut(e[n]);if(!(i=t!=null&&r(t,o)))break;t=t[o]}return i||++n!=s?i:(s=t==null?0:t.length,!!s&&ns(s)&&ts(o,s)&&(ve(t)||Ma(t)))}a(cl,"hasPath");var Tm=cl;function dl(t,e){return t!=null&&Tm(t,e,_m)}a(dl,"hasIn");var bm=dl,wm=1,Pm=2;function ul(t,e){return is(t)&&nl(e)?al(Ut(t),e):function(r){var n=ag(r,t);return n===void 0&&n===e?bm(r,t):Qr(e,n,wm|Pm)}}a(ul,"baseMatchesProperty");var xm=ul;function pl(t){return function(e){return e?.[t]}}a(pl,"baseProperty");var km=pl;function fl(t){return function(e){return as(e,t)}}a(fl,"basePropertyDeep");var Sm=fl;function gl(t){return is(t)?km(Ut(t)):Sm(t)}a(gl,"property");var Em=gl;function ml(t){return typeof t=="function"?t:t==null?Xu:typeof t=="object"?ve(t)?xm(t[0],t[1]):vm(t):Em(t)}a(ml,"baseIteratee");var ls=ml;function hl(t){return function(e,r,n){for(var s=-1,i=Object(e),o=n(e),l=o.length;l--;){var d=o[t?l:++s];if(r(i[d],d,i)===!1)break}return e}}a(hl,"createBaseFor");var Om=hl,Zm=Om(),Im=Zm;function yl(t,e){return t&&Im(t,e,ss)}a(yl,"baseForOwn");var Bm=yl;function vl(t,e){return Qr(t,e)}a(vl,"isEqual");var st=vl;function _l(t,e,r){r=typeof r=="function"?r:void 0;var n=r?r(t,e):void 0;return n===void 0?Qr(t,e,void 0,r):!!n}a(_l,"isEqualWith");var Am=_l;function Tl(t){return t===void 0}a(Tl,"isUndefined");var Pi=Tl;function bl(t,e){var r={};return e=ls(e,3),Bm(t,function(n,s,i){Ea(r,s,e(n,s,i))}),r}a(bl,"mapValues");var Rm=bl,Cm="Expected a function";function wl(t){if(typeof t!="function")throw new TypeError(Cm);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}a(wl,"negate");var Dm=wl;function Pl(t,e,r,n){if(!at(t))return t;e=Xr(e,t);for(var s=-1,i=e.length,o=i-1,l=t;l!=null&&++s<i;){var d=Ut(e[s]),u=r;if(d==="__proto__"||d==="constructor"||d==="prototype")return t;if(s!=o){var g=l[d];u=n?n(g,d,l):void 0,u===void 0&&(u=at(g)?g:ts(e[s+1])?[]:{})}wp(l,d,u),l=l[d]}return t}a(Pl,"baseSet");var Hm=Pl;function xl(t,e,r){for(var n=-1,s=e.length,i={};++n<s;){var o=e[n],l=as(t,o);r(l,o)&&Hm(i,Xr(o,t),l)}return i}a(xl,"basePickBy");var Nm=xl;function kl(t,e){if(t==null)return{};var r=ma(Sg(t),function(n){return[n]});return e=ls(e),Nm(t,r,function(n,s){return e(n,s[0])})}a(kl,"pickBy");var Mm=kl;function Sl(t,e){return Mm(t,Dm(ls(e)))}a(Sl,"omitBy");var xi=Sl,$m=a(t=>{let e=t.checks;return e.length===0?"":e.map(jm).join("")},"generateStringChecks"),jm=a(t=>{switch(t.kind){case"min":return`.min(${b(t.value)}, ${b(t.message)})`;case"max":return`.max(${b(t.value)}, ${b(t.message)})`;case"length":return`.length(${b(t.value)}, ${b(t.message)})`;case"email":return`.email(${b(t.message)})`;case"url":return`.url(${b(t.message)})`;case"emoji":return`.emoji(${b(t.message)})`;case"uuid":return`.uuid(${b(t.message)})`;case"cuid":return`.cuid(${b(t.message)})`;case"cuid2":return`.cuid2(${b(t.message)})`;case"ulid":return`.ulid(${b(t.message)})`;case"includes":let e=nt({message:t.message,position:t.position});return`.includes(${b(t.value)}, ${e})`;case"startsWith":return`.startsWith(${b(t.value)}, ${b(t.message)})`;case"endsWith":return`.endsWith(${b(t.value)}, ${b(t.message)})`;case"regex":return`.regex(${String(t.regex)}, ${b(t.message)})`;case"trim":return".trim()";case"toLowerCase":return".toLowerCase()";case"toUpperCase":return".toUpperCase()";case"datetime":let n=t.precision===null?void 0:t.precision;return`.datetime(${nt({message:t.message,precision:n,offset:t.offset})})`;case"ip":return`.ip(${nt({message:t.message,version:t.version})})`;default:return""}},"_generateStringCheck"),Km=a(t=>{let e=t.checks;return e.length===0?"":e.map(Um).join("")},"generateNumberChecks"),Um=a(t=>{switch(t.kind){case"min":return`.min(${b(t.value)}, ${b(t.message)})`;case"max":return`.max(${b(t.value)}, ${b(t.message)})`;case"int":return`.int(${b(t.message)})`;case"multipleOf":return`.multipleOf(${b(t.value)}, ${b(t.message)})`;case"finite":return`.finite(${b(t.message)})`;default:return""}},"_generateNumberCheck"),zm=a(t=>{let e=t.checks;return e.length===0?"":e.map(Fm).join("")},"generateBigIntChecks"),Fm=a(t=>{switch(t.kind){case"min":return`.min(${b(t.value)}, ${b(t.message)})`;case"max":return`.max(${b(t.value)}, ${b(t.message)})`;case"multipleOf":return`.multipleOf(${b(t.value)}, ${b(t.message)})`;default:return""}},"_generateBigIntCheck"),Wm=a(t=>{let e=t.checks;return e.length===0?"":e.map(Lm).join("")},"generateDateChecks"),Lm=a(t=>{switch(t.kind){case"min":return`.min(${ki(t.value)}, ${b(t.message)})`;case"max":return`.max(${ki(t.value)}, ${b(t.message)})`;default:return""}},"_generateDateCheck"),ki=a(t=>`new Date(${t})`,"dateTs"),qm=a(t=>{let e=[];if(t.exactLength){let{value:r,message:n}=t.exactLength;e.push(`.length(${b(r)}, ${b(n)})`)}if(t.minLength){let{value:r,message:n}=t.minLength;e.push(`.min(${b(r)}, ${b(n)})`)}if(t.maxLength){let{value:r,message:n}=t.maxLength;e.push(`.max(${b(r)}, ${b(n)})`)}return e.join("")},"generateArrayChecks"),Vm=a(t=>{let e=[];if(t.minSize){let{value:r,message:n}=t.minSize;e.push(`.min(${b(r)}, ${b(n)})`)}if(t.maxSize){let{value:r,message:n}=t.maxSize;e.push(`.max(${b(r)}, ${b(n)})`)}return e.join("")},"generateSetChecks");function cs(t){return M(t)}a(cs,"toTypescriptSchema");function M(t){let r=t._def;switch(r.typeName){case p.ZodFirstPartyTypeKind.ZodString:return`z.string()${$m(r)}${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodNumber:return`z.number()${Km(r)}${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodNaN:return`z.nan()${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodBigInt:return`z.bigint()${zm(r)}${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodBoolean:return`z.boolean()${C(r)}${R(t._def)}`.trim();case p.ZodFirstPartyTypeKind.ZodDate:return`z.date()${Wm(r)}${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodUndefined:return`z.undefined()${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodNull:return`z.null()${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodAny:return`z.any()${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodUnknown:return`z.unknown()${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodNever:return`z.never()${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodVoid:return`z.void()${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodArray:return`z.array(${M(r.type)})${qm(r)}${C(r)}${R(r)}`;case p.ZodFirstPartyTypeKind.ZodObject:let n=Rm(r.shape(),M),s=t.additionalProperties(),i=s?`.catchall(${M(s)})`:"";return["z.object({",...Object.entries(n).map(([vu,_u])=>` ${vu}: ${_u},`),`})${i}${C(r)}${R(r)}`].join(`
16
- `).trim();case p.ZodFirstPartyTypeKind.ZodUnion:return`z.union([${r.options.map(M).join(", ")}])${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:let l=r.options.map(M);return`z.discriminatedUnion(${b(r.discriminator)}, [${l.join(", ")}])${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodIntersection:let u=M(r.left),g=M(r.right);return`z.intersection(${u}, ${g})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodTuple:return`z.tuple([${r.items.map(M).join(", ")}])${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodRecord:let T=M(r.keyType),Z=M(r.valueType);return`z.record(${T}, ${Z})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodMap:let k=M(r.keyType),K=M(r.valueType);return`z.map(${k}, ${K})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodSet:return`z.set(${M(r.valueType)})${Vm(r)}${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodFunction:let F=r.args.items.map(M),Q=F.length?`.args(${F.join(", ")})`:"",ie=M(r.returns);return`z.function()${Q}.returns(${ie})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodLazy:return`z.lazy(() => ${M(r.getter())})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodLiteral:return`z.literal(${b(r.value)})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodEnum:return`z.enum([${r.values.map(b).join(", ")}])${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodEffects:throw new Be(p.ZodFirstPartyTypeKind.ZodEffects);case p.ZodFirstPartyTypeKind.ZodNativeEnum:throw new Be(p.ZodFirstPartyTypeKind.ZodNativeEnum);case p.ZodFirstPartyTypeKind.ZodOptional:return`z.optional(${M(r.innerType)})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodNullable:return`z.nullable(${M(r.innerType)})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodDefault:let ee=nt(r.defaultValue());return`z.default(${M(r.innerType)}, ${ee})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodCatch:throw new Be(p.ZodFirstPartyTypeKind.ZodCatch);case p.ZodFirstPartyTypeKind.ZodPromise:return`z.promise(${M(r.type)})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodBranded:throw new Be(p.ZodFirstPartyTypeKind.ZodBranded);case p.ZodFirstPartyTypeKind.ZodPipeline:throw new Be(p.ZodFirstPartyTypeKind.ZodPipeline);case p.ZodFirstPartyTypeKind.ZodSymbol:throw new Be(p.ZodFirstPartyTypeKind.ZodSymbol);case p.ZodFirstPartyTypeKind.ZodReadonly:return`z.readonly(${M(r.innerType)})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodRef:return`z.ref(${b(r.uri)})${C(r)}${R(r)}`.trim();default:I.assertNever(r)}}a(M,"sUnwrapZod");var R=a(t=>t.description?`.describe(${b(t.description)})`:"","_maybeDescribe"),C=a(t=>`${Gm(t)}${Jm(t)}${Ym(t)}${Xm(t)}${Qm(t)}${eh(t)}${th(t)}`,"_addZuiExtensions"),Gm=a(t=>{var e;return(e=t[w])!=null&&e.title?`.title(${b(t[w].title)})`:""},"_maybeTitle"),Jm=a(t=>{var e;return(e=t[w])!=null&&e.displayAs?`.displayAs(${Di({id:t[w].displayAs[0],params:t[w].displayAs[1]})})`:""},"_maybeDisplayAs"),Ym=a(t=>{var e;return(e=t[w])!=null&&e.disabled?`.disabled(${t[w].disabled})`:""},"_maybeDisabled"),Xm=a(t=>{var e;return(e=t[w])!=null&&e.hidden?`.hidden(${t[w].hidden})`:""},"_maybeHidden"),Qm=a(t=>{var e;return(e=t[w])!=null&&e.placeholder?`.placeholder(${b(t[w].placeholder)})`:""},"_maybePlaceholder"),eh=a(t=>{var e;return(e=t[w])!=null&&e.secret?".secret()":""},"_maybeSecret"),th=a(t=>{var e;let r=["title","tooltip","displayAs","disabled","hidden","placeholder","secret","coerce"],n=Object.entries((e=t[w])!=null?e:{}).filter(([s])=>!r.includes(s));return n.length>0?`.metadata(${Di(Object.fromEntries(n))})`:""},"_maybeSetMetadata"),rh=a(t=>{let e={type:"number",description:t.description,"x-zui":t._def["x-zui"]};t._def[w]&&(e[w]=t._def[w]);for(let r of t._def.checks)switch(r.kind){case"min":{let n=r.inclusive?"minimum":"exclusiveMinimum",s=r.inclusive?"exclusiveMinimum":"minimum";e[n]=r.value,delete e[s];break}case"max":{let n=r.inclusive?"maximum":"exclusiveMaximum",s=r.inclusive?"exclusiveMaximum":"maximum";e[n]=r.value,delete e[s];break}case"int":e.type="integer";break;case"finite":{e.format="finite";break}case"multipleOf":e.multipleOf=r.value;break;default:}return e},"zodNumberToJsonNumber"),El="\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}",Ol="(([+-]\\d{2}(:?\\d{2})?)|Z)",nh="Z",Zl="(\\.\\d+)?",Ln="\\.\\d{",sh="}",Il=a(t=>{let e=t.precision?Ln+t.precision+sh:t.precision===0?"":Zl,r=t.offset?Ol:nh;return new RegExp(`^${El}${e}${r}$`)},"generateDatetimeRegex"),ih=a(t=>({precision:ah(t),offset:t.endsWith(`${Ol}$`)}),"extractPrecisionAndOffset"),ah=a(t=>{let e=t.slice(1+El.length);return e.startsWith(Zl)?null:e.startsWith(Ln)?parseInt(e.slice(Ln.length)):0},"_extractPrecision"),Dt={};zr(Dt,{escapeSpecialChars:()=>oh});var oh=a(t=>t.replaceAll(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeSpecialChars");function ds(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage=f(c({},t.errorMessage),{[e]:r}))}a(ds,"addErrorMessage");function D(t,e,r,n,s){t[e]=r,ds(t,e,n,s)}a(D,"setResponseValueAndErrors");var j={cuid:"^[cC][^\\s-]{8,}$",cuid2:"^[a-z][a-z0-9]*$",ulid:"^[0-9A-HJKMNP-TV-Z]{26}$",email:"^(?!\\.)(?!.*\\.\\.)([a-zA-Z0-9_+-\\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\\-]*\\.)+[a-zA-Z]{2,}$",emoji:"^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",uuid:"^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$",ipv4:"^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$",ipv6:"^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$"};function us(t,e){let r=c({type:"string"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{});function n(s){return e.patternStrategy==="escape"?Dt.escapeSpecialChars(s):s}if(a(n,"processPattern"),t.checks)for(let s of t.checks)switch(s.kind){case"min":D(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,s.value):s.value,s.message,e);break;case"max":D(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,s.value):s.value,s.message,e);break;case"email":switch(e.emailStrategy){case"format:email":Ie(r,"email",s.message,e);break;case"format:idn-email":Ie(r,"idn-email",s.message,e);break;case"pattern:zod":ge(r,j.email,s.message,e);break}break;case"url":Ie(r,"uri",s.message,e);break;case"uuid":Ie(r,"uuid",s.message,e);break;case"regex":ge(r,s.regex.source,s.message,e);break;case"cuid":ge(r,j.cuid,s.message,e);break;case"cuid2":ge(r,j.cuid2,s.message,e);break;case"startsWith":ge(r,"^"+n(s.value),s.message,e);break;case"endsWith":ge(r,n(s.value)+"$",s.message,e);break;case"datetime":Ie(r,"date-time",s.message,e);break;case"length":D(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,s.value):s.value,s.message,e),D(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,s.value):s.value,s.message,e);break;case"includes":{ge(r,n(s.value),s.message,e);break}case"ip":{s.version!=="v6"&&Ie(r,"ipv4",s.message,e),s.version!=="v4"&&Ie(r,"ipv6",s.message,e);break}case"emoji":ge(r,j.emoji,s.message,e);break;case"ulid":{ge(r,j.ulid,s.message,e);break}case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}a(us,"parseStringDef");var Ie=a((t,e,r,n)=>{var s;t.format||(s=t.anyOf)!=null&&s.some(i=>i.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push(c({format:t.format},t.errorMessage&&n.errorMessages&&{errorMessage:{format:t.errorMessage.format}})),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push(c({format:e},r&&n.errorMessages&&{errorMessage:{format:r}}))):D(t,"format",e,r,n)},"addFormat"),ge=a((t,e,r,n)=>{var s;t.pattern||(s=t.allOf)!=null&&s.some(i=>i.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push(c({pattern:t.pattern},t.errorMessage&&n.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}})),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push(c({pattern:e},r&&n.errorMessages&&{errorMessage:{pattern:r}}))):D(t,"pattern",e,r,n)},"addPattern"),lh=a(t=>{let e={type:"string",description:t.description,"x-zui":t._def["x-zui"]};t._def[w]&&(e[w]=t._def[w]);for(let r of t._def.checks)switch(r.kind){case"cuid":e.format="cuid",e.pattern=j.cuid;break;case"cuid2":e.format="cuid2",e.pattern=j.cuid2;break;case"ulid":e.format="ulid",e.pattern=j.ulid;break;case"uuid":e.format="uuid",e.pattern=j.uuid;break;case"emoji":e.format="emoji",e.pattern=j.emoji;break;case"email":e.format="email",e.pattern=j.email;break;case"ip":e.format=r.version==="v6"?"ipv6":"ipv4",e.pattern=r.version==="v6"?j.ipv6:j.ipv4;break;case"datetime":e.format="date-time",e.pattern=Il(r).source,e[w]=f(c({},e[w]),{precision:r.precision,offset:r.offset});break;case"url":e.format="uri";break;case"endsWith":e.pattern=`${Dt.escapeSpecialChars(r.value)}$`;break;case"startsWith":e.pattern=`^${Dt.escapeSpecialChars(r.value)}`;break;case"includes":let n=r.position&&r.position>=1?`^(?:.{${r.position}}).*`:"";e.pattern=`${n}${Dt.escapeSpecialChars(r.value)}`;break;case"regex":e.pattern=r.regex.source;break;case"length":e.minLength=e.maxLength=Math.max(0,r.value);break;case"min":e.minLength=Math.max(0,r.value);break;case"max":e.maxLength=Math.max(0,r.value);break;default:throw new Wi({zodType:p.ZodFirstPartyTypeKind.ZodString,checkKind:r.kind})}return e},"zodStringToJsonString"),ch=a((t,e)=>{let r={type:"array",description:t.description,items:e(t._def.type),"x-zui":t._def["x-zui"]};return t._def[w]&&(r[w]=t._def[w]),t._def.minLength&&(r.minItems=t._def.minLength.value),t._def.maxLength&&(r.maxItems=t._def.maxLength.value),t._def.exactLength&&(r.minItems=t._def.exactLength.value,r.maxItems=t._def.exactLength.value),r},"zodArrayToJsonArray"),dh=a((t,e)=>{let r={type:"array",description:t.description,uniqueItems:!0,items:e(t._def.valueType),"x-zui":t._def["x-zui"]};return t._def[w]&&(r[w]=t._def[w]),t._def.minSize&&(r.minItems=t._def.minSize.value),t._def.maxSize&&(r.maxItems=t._def.maxSize.value),r},"zodSetToJsonSet"),uh=a((t,e)=>{let r={type:"array",description:t.description,items:t._def.items.map(n=>e(n))};return t._def[w]&&(r[w]=t._def[w]),t._def.rest&&(r.additionalItems=e(t._def.rest)),r},"zodTupleToJsonTuple");function q(t){let e=t,r=e._def;switch(r.typeName){case p.ZodFirstPartyTypeKind.ZodString:return lh(e);case p.ZodFirstPartyTypeKind.ZodNumber:return rh(e);case p.ZodFirstPartyTypeKind.ZodNaN:throw new te(p.ZodFirstPartyTypeKind.ZodNaN);case p.ZodFirstPartyTypeKind.ZodBigInt:throw new te(p.ZodFirstPartyTypeKind.ZodBigInt,{suggestedAlternative:"serialize bigint to string"});case p.ZodFirstPartyTypeKind.ZodBoolean:return{type:"boolean",description:r.description,"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodDate:throw new te(p.ZodFirstPartyTypeKind.ZodDate,{suggestedAlternative:"use z.string().datetime() instead"});case p.ZodFirstPartyTypeKind.ZodUndefined:return Dn(r);case p.ZodFirstPartyTypeKind.ZodNull:return Hn(r);case p.ZodFirstPartyTypeKind.ZodAny:return{description:r.description,"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodUnknown:return{description:r.description,"x-zui":f(c({},r["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodUnknown}})};case p.ZodFirstPartyTypeKind.ZodNever:return{not:!0,description:r.description,"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodVoid:throw new te(p.ZodFirstPartyTypeKind.ZodVoid);case p.ZodFirstPartyTypeKind.ZodArray:return ch(e,q);case p.ZodFirstPartyTypeKind.ZodObject:let n=Object.entries(r.shape()),s=n.filter(([g,h])=>!h.isOptional()),i=s.length?s.map(([g])=>g):void 0,o=n.map(([g,h])=>[g,h.mandatory()]).map(([g,h])=>[g,q(h)]),l=!1;return r.unknownKeys instanceof p.ZodType?l=q(r.unknownKeys):r.unknownKeys==="passthrough"&&(l=!0),{type:"object",description:r.description,properties:Object.fromEntries(o),required:i,additionalProperties:l,"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodUnion:return{description:r.description,anyOf:r.options.map(g=>q(g)),"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:return{description:r.description,anyOf:r.options.map(g=>q(g)),"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodIntersection:let d=q(r.left),u=q(r.right);return"additionalProperties"in d&&delete d.additionalProperties,"additionalProperties"in u&&delete u.additionalProperties,{description:r.description,allOf:[d,u],"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodTuple:return uh(e,q);case p.ZodFirstPartyTypeKind.ZodRecord:return{type:"object",description:r.description,additionalProperties:q(r.valueType),"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodMap:throw new te(p.ZodFirstPartyTypeKind.ZodMap);case p.ZodFirstPartyTypeKind.ZodSet:return dh(e,q);case p.ZodFirstPartyTypeKind.ZodFunction:throw new te(p.ZodFirstPartyTypeKind.ZodFunction);case p.ZodFirstPartyTypeKind.ZodLazy:throw new te(p.ZodFirstPartyTypeKind.ZodLazy);case p.ZodFirstPartyTypeKind.ZodLiteral:if(typeof r.value=="string")return{type:"string",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(typeof r.value=="number")return{type:"number",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(typeof r.value=="boolean")return{type:"boolean",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(r.value===null)return Hn(r);if(r.value===void 0)return Dn(r);{p.util.assertEqual(!0);let g=typeof r.value;throw new Wr(`Unsupported literal type: "${g}"`)}case p.ZodFirstPartyTypeKind.ZodEnum:return{type:"string",description:r.description,enum:r.values,"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodEffects:throw new te(p.ZodFirstPartyTypeKind.ZodEffects);case p.ZodFirstPartyTypeKind.ZodNativeEnum:throw new te(p.ZodFirstPartyTypeKind.ZodNativeEnum);case p.ZodFirstPartyTypeKind.ZodOptional:return{description:r.description,anyOf:[q(r.innerType),Dn()],"x-zui":f(c({},r["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodOptional}})};case p.ZodFirstPartyTypeKind.ZodNullable:return{anyOf:[q(r.innerType),Hn()],"x-zui":f(c({},r["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodNullable}})};case p.ZodFirstPartyTypeKind.ZodDefault:return f(c({},q(r.innerType)),{default:r.defaultValue()});case p.ZodFirstPartyTypeKind.ZodCatch:throw new te(p.ZodFirstPartyTypeKind.ZodCatch);case p.ZodFirstPartyTypeKind.ZodPromise:throw new te(p.ZodFirstPartyTypeKind.ZodPromise);case p.ZodFirstPartyTypeKind.ZodBranded:throw new te(p.ZodFirstPartyTypeKind.ZodBranded);case p.ZodFirstPartyTypeKind.ZodPipeline:throw new te(p.ZodFirstPartyTypeKind.ZodPipeline);case p.ZodFirstPartyTypeKind.ZodSymbol:throw new te(p.ZodFirstPartyTypeKind.ZodPipeline);case p.ZodFirstPartyTypeKind.ZodReadonly:return f(c({},q(r.innerType)),{readOnly:!0});case p.ZodFirstPartyTypeKind.ZodRef:return{$ref:r.uri,description:r.description,"x-zui":r["x-zui"]};default:p.util.assertNever(r)}}a(q,"toJSONSchema");var Dn=a(t=>({not:!0,description:t?.description,"x-zui":f(c({},t?.["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodUndefined}})}),"undefinedSchema"),Hn=a(t=>({type:"null",description:t?.description,"x-zui":t?.["x-zui"]}),"nullSchema"),Bl=class{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};a(Bl,"ParseInputLazyPath");var oe=Bl,Si=a((t,e)=>{if(lt(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new pe(t.common.issues);return this._error=r,this._error}}},"handleResult"),Al=class{constructor(e){this.__type__="ZuiType",this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._metadataRoot._def.description}dereference(e){return this}getReferences(){return[]}clone(){let e=this.constructor;return new e(c({},this._def))}_getType(e){return he(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:he(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new re,ctx:{common:e.parent.common,data:e.data,parsedType:he(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(jt(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){var n;let s={common:{issues:[],async:(n=r?.async)!=null?n:!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:he(e)},i=this._parseSync({data:e,path:s.path,parent:s});return Si(s,i)}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:he(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(jt(s)?s:Promise.resolve(s));return Si(n,i)}refine(e,r){let n=a(s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r,"getIssueProperties");return this._refinement((s,i)=>{let o=e(s),l=a(()=>i.addIssue(c({code:m.custom},n(s))),"setError");return typeof Promise<"u"&&o instanceof Promise?o.then(d=>d?!0:(l(),!1)):o?!0:(l(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new Se({schema:this,typeName:"ZodEffects",effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ye.create(this,this._def)}nullable(){return $e.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return dt.create(this,this._def)}promise(){return Wt.create(this,this._def)}mandatory(){return this}or(e){return fn.create([this,e],this._def)}and(e){return an.create(this,e,this._def)}transform(e){return new Se(f(c({},S(this._def)),{schema:this,typeName:"ZodEffects",effect:{type:"transform",transform:e}}))}default(e){let r=typeof e=="function"?e:()=>e;return new zt(f(c({},S(this._def)),{innerType:this,defaultValue:r,typeName:"ZodDefault"}))}brand(){return new rn(c({typeName:"ZodBranded",type:this},S(this._def)))}catch(e){let r=typeof e=="function"?e:()=>e;return new nn(f(c({},S(this._def)),{innerType:this,catchValue:r,typeName:"ZodCatch"}))}describe(e){let r=this.clone();return r._metadataRoot._def.description=e,r}pipe(e){return pn.create(this,e)}readonly(){return Lt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}metadata(e){var r,n,s;let i=this.clone(),o=i._metadataRoot;(s=(r=o._def)[n=w])!=null||(r[n]={});for(let[l,d]of Object.entries(e))o._def[w]=f(c({},o._def[w]),{[l]:d});return i}getMetadata(){return c({},this._metadataRoot._def[w])}setMetadata(e){this._metadataRoot._def[w]=c({},e)}get ui(){return c({},this._metadataRoot._def[w])}get _metadataRoot(){return this.naked()}displayAs(e){return this.metadata({displayAs:[e.id,e.params]})}title(e){return this.metadata({title:e})}hidden(e){let r;return e===void 0?r=!0:typeof e=="function"?r=e.toString():r=e,this.metadata({hidden:r})}disabled(e){let r;return e===void 0?r=!0:typeof e=="function"?r=e.toString():r=e,this.metadata({disabled:r})}placeholder(e){return this.metadata({placeholder:e})}toJSONSchema(){return q(this)}toTypescriptType(e){return Xn(this,e)}toTypescriptSchema(){return cs(this)}naked(){return this}};a(Al,"ZodType");var O=Al,ps=(t=>(t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodRef="ZodRef",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly",t))(ps||{}),I;(t=>{t.assertEqual=a(s=>s,"assertEqual");function e(s){}t.assertIs=e,a(e,"assertIs");function r(s){throw new Error("assertNever called")}t.assertNever=r,a(r,"assertNever"),t.arrayToEnum=a(s=>{let i={};for(let o of s)i[o]=o;return i},"arrayToEnum"),t.getValidEnumValues=a(s=>{let i=(0,t.objectKeys)(s).filter(l=>typeof s[s[l]]!="number"),o={};for(let l of i)o[l]=s[l];return(0,t.objectValues)(o)},"getValidEnumValues"),t.objectValues=a(s=>(0,t.objectKeys)(s).map(function(i){return s[i]}),"objectValues"),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=a((s,i)=>{for(let o of s)if(i(o))return o},"find"),t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=n,a(n,"joinValues"),t.jsonStringifyReplacer=a((s,i)=>typeof i=="bigint"?i.toString():i,"jsonStringifyReplacer"),t.compareFunctions=a((s,i)=>s.toString()===i.toString(),"compareFunctions"),t.mock=a(()=>({}),"mock")})(I||(I={}));var lr;(t=>{t.mergeShapes=a((e,r)=>c(c({},e),r),"mergeShapes")})(lr||(lr={}));var _=I.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),he=a(t=>{switch(typeof t){case"undefined":return _.undefined;case"string":return _.string;case"number":return isNaN(t)?_.nan:_.number;case"boolean":return _.boolean;case"function":return _.function;case"bigint":return _.bigint;case"symbol":return _.symbol;case"object":return Array.isArray(t)?_.array:t===null?_.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?_.promise:typeof Map<"u"&&t instanceof Map?_.map:typeof Set<"u"&&t instanceof Set?_.set:typeof Date<"u"&&t instanceof Date?_.date:_.object;default:return _.unknown}},"getParsedType");function S(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s,supportsExtensions:i,[w]:o}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);let l=o?Object.fromEntries(Object.entries(o).filter(([u])=>u!=="secret"||i?.includes("secret"))):void 0;return e?{errorMap:e,description:s,[w]:l}:{errorMap:a((u,g)=>u.code!=="invalid_type"?{message:g.defaultError}:typeof g.data>"u"?{message:n??g.defaultError}:{message:r??g.defaultError},"customMap"),description:s,[w]:l}}a(S,"processCreateParams");var fs=a((t,e)=>{let r;switch(t.code){case m.invalid_type:t.received===_.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case m.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,I.jsonStringifyReplacer)}`;break;case m.unrecognized_keys:r=`Unrecognized key(s) in object: ${I.joinValues(t.keys,", ")}`;break;case m.invalid_union:r="Invalid input";break;case m.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${I.joinValues(t.options)}`;break;case m.invalid_enum_value:r=`Invalid enum value. Expected ${I.joinValues(t.options)}, received '${t.received}'`;break;case m.invalid_arguments:r="Invalid function arguments";break;case m.invalid_return_type:r="Invalid function return type";break;case m.invalid_date:r="Invalid date";break;case m.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:I.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case m.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case m.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case m.custom:r="Invalid input";break;case m.invalid_intersection_types:r="Intersection results could not be merged";break;case m.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case m.not_finite:r="Number must be finite";break;case m.unresolved_reference:r="Unresolved reference";break;default:r=e.defaultError,I.assertNever(t)}return{message:r}},"errorMap"),Ei=fs,m=I.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite","unresolved_reference"]),Rl=a(t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),cr=class Cl extends Error{constructor(e){super(),this.issues=[],this.addIssue=a(n=>{this.issues=[...this.issues,n]},"addIssue"),this.addIssues=a((n=[])=>{this.issues=[...this.issues,...n]},"addIssues");let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let r=e||function(i){return i.message},n={_errors:[]},s=a(i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)n._errors.push(r(o));else{let l=n,d=0;for(;d<o.path.length;){let u=o.path[d];d===o.path.length-1?(l[u]=l[u]||{_errors:[]},l[u]._errors.push(r(o))):l[u]=l[u]||{_errors:[]},l=l[u],d++}}},"processError");return s(this),n}static assert(e){if(!(e instanceof Cl))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,I.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};a(cr,"ZodError");cr.create=a(t=>new cr(t),"create");var pe=cr,Dl=fs;function gs(t){Dl=t}a(gs,"setErrorMap");function ot(){return Dl}a(ot,"getErrorMap");var $t=a(t=>{var e;let{data:r,path:n,errorMaps:s,issueData:i}=t,o=[...n,...i.path||[]],l=f(c({},i),{path:o}),d="",u=s.filter(g=>!!g).slice().reverse();for(let g of u)d=g(l,{data:r,defaultError:d}).message;return f(c({},i),{path:o,message:(e=i.message)!=null?e:d})},"makeIssue"),Hl=[];function v(t,e){let r=$t({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ot(),fs].filter(n=>!!n)});t.common.issues.push(r)}a(v,"addIssueToContext");var Nl=class Ml{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let s of r){if(s.status==="aborted")return x;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let s of r)n.push({key:await s.key,value:await s.value});return Ml.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return x;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(n[i.value]=o.value)}return{status:e.value,value:n}}};a(Nl,"ParseStatus");var re=Nl,x=Object.freeze({status:"aborted"}),Ne=a(t=>({status:"dirty",value:t}),"DIRTY"),G=a(t=>({status:"valid",value:t}),"OK"),dr=a(t=>t.status==="aborted","isAborted"),ur=a(t=>t.status==="dirty","isDirty"),lt=a(t=>t.status==="valid","isValid"),jt=a(t=>typeof Promise<"u"&&t instanceof Promise,"isAsync"),P;(t=>{t.errToObj=a(e=>typeof e=="string"?{message:e}:e||{},"errToObj"),t.toString=a(e=>typeof e=="string"?e:e?.message,"toString")})(P||(P={}));var pr=class $l extends O{constructor(){super(...arguments),this._any=!0}_parse(e){return G(e.data)}isEqual(e){return e instanceof $l}};a(pr,"ZodAny");pr.create=a(t=>new pr(c({typeName:"ZodAny"},S(t))),"create");var ct=pr,fr=class Re extends O{dereference(e){return new Re(f(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new Re(f(c({},this._def),{type:this._def.type.clone()}))}isEqual(e){var r,n,s,i,o,l;return e instanceof Re?st((r=this._def.exactLength)==null?void 0:r.value,(n=e._def.exactLength)==null?void 0:n.value)&&st((s=this._def.maxLength)==null?void 0:s.value,(i=e._def.maxLength)==null?void 0:i.value)&&st((o=this._def.minLength)==null?void 0:o.value,(l=e._def.minLength)==null?void 0:l.value)&&this._def.type.isEqual(e._def.type):!1}_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==_.array)return v(r,{code:m.invalid_type,expected:_.array,received:r.parsedType}),x;if(s.exactLength!==null){let o=r.data.length>s.exactLength.value,l=r.data.length<s.exactLength.value;(o||l)&&(v(r,{code:o?m.too_big:m.too_small,minimum:l?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(v(r,{code:m.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(v(r,{code:m.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((o,l)=>s.type._parseAsync(new oe(r,o,r.path,l)))).then(o=>re.mergeArray(n,o));let i=[...r.data].map((o,l)=>s.type._parseSync(new oe(r,o,r.path,l)));return re.mergeArray(n,i)}get element(){return this._def.type}min(e,r){return new Re(f(c({},this._def),{minLength:{value:e,message:P.toString(r)}}))}max(e,r){return new Re(f(c({},this._def),{maxLength:{value:e,message:P.toString(r)}}))}length(e,r){return new Re(f(c({},this._def),{exactLength:{value:e,message:P.toString(r)}}))}nonempty(e){return this.min(1,e)}};a(fr,"ZodArray");fr.create=a((t,e)=>new fr(c({type:t,minLength:null,maxLength:null,exactLength:null,typeName:"ZodArray"},S(e))),"create");var dt=fr,ph=a((t,e)=>jl(t,e,new WeakSet),"isEqual"),jl=a((t,e,r)=>Am(t,e,fh(r)),"_isEqualWithVisitedTracking"),fh=a(t=>(e,r)=>{if(ci(e)&&!t.has(e)&&ci(r)&&!t.has(r)){let n=xi(e,Pi),s=xi(r,Pi);return t.add(n).add(s).add(e).add(r),jl(n,s,t)}},"_customizerWithVisitedTracking"),gh={compare:ph},Kl=class{constructor(e=[],r={}){this._options=c(c({},gh),r),this._items=[];for(let n of e)this.add(n)}get items(){return[...this._items]}get size(){return this._items.length}has(e){return this._items.some(r=>this._options.compare(r,e))}add(e){this.has(e)||this._items.push(e)}isEqual(e){return this.size!==e.size?!1:this.isSubsetOf(e)&&e.isSubsetOf(this)}isSubsetOf(e){return this.size>e.size?!1:this._items.every(r=>e.has(r))}};a(Kl,"CustomSet");var U=Kl,gr=class er extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==_.bigint){let i=this._getOrReturnCtx(e);return v(i,{code:m.invalid_type,expected:_.bigint,received:i.parsedType}),x}let n,s=new re;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:m.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:m.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),v(n,{code:m.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):I.assertNever(i);return{status:s.value,value:e.data}}isEqual(e){if(!(e instanceof er)||this._def.coerce!==e._def.coerce)return!1;let r=new U(this._def.checks),n=new U(e._def.checks);return r.isEqual(n)}gte(e,r){return this.setLimit("min",e,!0,P.toString(r))}gt(e,r){return this.setLimit("min",e,!1,P.toString(r))}lte(e,r){return this.setLimit("max",e,!0,P.toString(r))}lt(e,r){return this.setLimit("max",e,!1,P.toString(r))}setLimit(e,r,n,s){return new er(f(c({},this._def),{checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:P.toString(s)}]}))}_addCheck(e){return new er(f(c({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:P.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:P.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:P.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:P.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:P.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};a(gr,"ZodBigInt");gr.create=a(t=>{var e;return new gr(c({checks:[],typeName:"ZodBigInt",coerce:(e=t?.coerce)!=null?e:!1},S(t)))},"create");var en=gr,mr=class Ul extends O{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==_.boolean){let n=this._getOrReturnCtx(e);return v(n,{code:m.invalid_type,expected:_.boolean,received:n.parsedType}),x}return G(e.data)}isEqual(e){return e instanceof Ul?this._def.coerce===e._def.coerce:!1}};a(mr,"ZodBoolean");mr.create=a(t=>new mr(c({typeName:"ZodBoolean",coerce:t?.coerce||!1},S(t))),"create");var tn=mr,zl=Symbol("zod_brand"),Fl=class bt extends O{dereference(e){return new bt(f(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new bt(f(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}isEqual(e){return e instanceof bt?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}mandatory(){return new bt(f(c({},this._def),{type:this._def.type.mandatory()}))}};a(Fl,"ZodBranded");var rn=Fl,hr=class wt extends O{_parse(e){let{ctx:r}=this._processInputParams(e),n=f(c({},r),{common:f(c({},r.common),{issues:[]})}),s=this._def.innerType._parse({data:n.data,path:n.path,parent:c({},n)});return jt(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new pe(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new pe(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}isEqual(e){return e instanceof wt?this._def.innerType.isEqual(e._def.innerType)&&I.compareFunctions(this._def.catchValue,e._def.catchValue):!1}dereference(e){return new wt(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new wt(f(c({},this._def),{innerType:this._def.innerType.clone()}))}naked(){return this._def.innerType.naked()}mandatory(){return new wt(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(hr,"ZodCatch");hr.create=a((t,e)=>new hr(c({innerType:t,typeName:"ZodCatch",catchValue:typeof e.catch=="function"?e.catch:()=>e.catch},S(e))),"create");var nn=hr,ms=a((t,e={},r)=>t?ct.create().superRefine((n,s)=>{var i,o;if(!t(n)){let l=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,d=(o=(i=l.fatal)!=null?i:r)!=null?o:!0,u=typeof l=="string"?{message:l}:l;s.addIssue(f(c({code:"custom"},u),{fatal:d}))}}):ct.create(),"custom"),yr=class qn extends O{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==_.date){let i=this._getOrReturnCtx(e);return v(i,{code:m.invalid_type,expected:_.date,received:i.parsedType}),x}if(isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return v(i,{code:m.invalid_date}),x}let n=new re,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:m.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:m.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):I.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new qn(f(c({},this._def),{checks:[...this._def.checks,e]}))}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:P.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:P.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}isEqual(e){if(!(e instanceof qn))return!1;let r=new U(this._def.checks),n=new U(e._def.checks);return r.isEqual(n)&&this._def.coerce===e._def.coerce}};a(yr,"ZodDate");yr.create=a(t=>new yr(c({checks:[],coerce:t?.coerce||!1,typeName:"ZodDate"},S(t))),"create");var sn=yr,vr=class Pt extends O{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===_.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}dereference(e){return new Pt(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new Pt(f(c({},this._def),{innerType:this._def.innerType.clone()}))}isEqual(e){return e instanceof Pt?this._def.innerType.isEqual(e._def.innerType)&&st(this._def.defaultValue(),e._def.defaultValue()):!1}unwrap(){return this._def.innerType}naked(){return this._def.innerType.naked()}mandatory(){return new Pt(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(vr,"ZodDefault");vr.create=a((t,e,r)=>new vr(c({innerType:t,typeName:"ZodDefault",defaultValue:typeof e=="function"?e:()=>e},S(r))),"create");var zt=vr,Te=a(t=>Array.from(new Set(t)),"unique"),me=a(t=>t instanceof on?me(t.schema):t instanceof Se?me(t.innerType()):t instanceof ln?[t.value]:t instanceof Ge?t.options:t instanceof cn?I.objectValues(t.enum):t instanceof zt?me(t._def.innerType):t instanceof qt?[void 0]:t instanceof dn?[null]:t instanceof ye?[void 0,...me(t.unwrap())]:t instanceof $e?[null,...me(t.unwrap())]:t instanceof rn||t instanceof Lt?me(t.unwrap()):t instanceof nn?me(t._def.innerType):[],"getDiscriminator"),Wl=class Ce extends O{dereference(e){let r=this.options.map(s=>s.dereference(e)),n=Ce._getOptionsMap(this.discriminator,r);return new Ce(f(c({},this._def),{options:r,optionsMap:n}))}getReferences(){return Te(this.options.flatMap(e=>e.getReferences()))}clone(){let e=this.options.map(r=>r.clone());return new Ce(f(c({},this._def),{options:e}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==_.object)return v(r,{code:m.invalid_type,expected:_.object,received:r.parsedType}),x;let n=this.discriminator,s=r.data[n],i=this.optionsMap.get(s);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(v(r,{code:m.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),x)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let s=Ce._getOptionsMap(e,r);return new Ce(c({typeName:"ZodDiscriminatedUnion",discriminator:e,options:r,optionsMap:s},S(n)))}static _getOptionsMap(e,r){let n=new Map;for(let s of r){let i=me(s.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of i){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,s)}}return n}isEqual(e){if(!(e instanceof Ce)||this._def.discriminator!==e._def.discriminator)return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new U(this._def.options,{compare:r}),s=new U(e._def.options,{compare:r});return n.isEqual(s)}};a(Wl,"ZodDiscriminatedUnion");var hs=Wl;function Ft(t,e){return new Ge(c({values:t,typeName:"ZodEnum"},S(e)))}a(Ft,"createZodEnum");var ys=class tr extends O{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return v(r,{expected:I.joinValues(n),received:r.parsedType,code:m.invalid_type}),x}if(this._def.values.indexOf(e.data)===-1){let r=this._getOrReturnCtx(e),n=this._def.values;return v(r,{received:r.data,code:m.invalid_enum_value,options:n}),x}return G(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return tr.create(e,c(c({},this._def),r))}exclude(e,r=this._def){return tr.create(this.options.filter(n=>!e.includes(n)),c(c({},this._def),r))}isEqual(e){if(!(e instanceof tr))return!1;let r=new U(this._def.values),n=new U(e._def.values);return r.isEqual(n)}};a(ys,"ZodEnum");ys.create=Ft;var Ge=ys,Ll=class De extends O{constructor(){super(...arguments),this.validate=this.implement}dereference(e){let r=this._def.args.dereference(e),n=this._def.returns.dereference(e);return new De(f(c({},this._def),{args:r,returns:n}))}getReferences(){return Te([...this._def.args.getReferences(),...this._def.returns.getReferences()])}clone(){return new De(f(c({},this._def),{args:this._def.args.clone(),returns:this._def.returns.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==_.function)return v(r,{code:m.invalid_type,expected:_.function,received:r.parsedType}),x;function n(l,d){return $t({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ot(),Ei].filter(u=>!!u),issueData:{code:m.invalid_arguments,argumentsError:d}})}a(n,"makeArgsIssue");function s(l,d){return $t({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ot(),Ei].filter(u=>!!u),issueData:{code:m.invalid_return_type,returnTypeError:d}})}a(s,"makeReturnsIssue");let i={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof Wt){let l=this;return G(async function(...d){let u=new pe([]),g=await l._def.args.parseAsync(d,i).catch(Z=>{throw u.addIssue(n(d,Z)),u}),h=await Reflect.apply(o,this,g);return await l._def.returns._def.type.parseAsync(h,i).catch(Z=>{throw u.addIssue(s(h,Z)),u})})}else{let l=this;return G(function(...d){let u=l._def.args.safeParse(d,i);if(!u.success)throw new pe([n(d,u.error)]);let g=Reflect.apply(o,this,u.data),h=l._def.returns.safeParse(g,i);if(!h.success)throw new pe([s(g,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new De(f(c({},this._def),{args:Ke.create(e).rest(it.create())}))}returns(e){return new De(f(c({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new De(c({args:e||Ke.create([]).rest(it.create()),returns:r||it.create(),typeName:"ZodFunction"},S(n)))}isEqual(e){return e instanceof De&&this._def.args.isEqual(e._def.args)&&this._def.returns.isEqual(e._def.returns)}};a(Ll,"ZodFunction");var vs=Ll;function _r(t,e){let r=he(t),n=he(e);if(t===e)return{valid:!0,data:t};if(r===_.object&&n===_.object){let s=I.objectKeys(e),i=I.objectKeys(t).filter(l=>s.indexOf(l)!==-1),o=c(c({},t),e);for(let l of i){let d=_r(t[l],e[l]);if(!d.valid)return{valid:!1};o[l]=d.data}return{valid:!0,data:o}}else if(r===_.array&&n===_.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let o=t[i],l=e[i],d=_r(o,l);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return r===_.date&&n===_.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}a(_r,"mergeValues");var Tr=class rr extends O{dereference(e){return new rr(f(c({},this._def),{left:this._def.left.dereference(e),right:this._def.right.dereference(e)}))}getReferences(){return Te([...this._def.left.getReferences(),...this._def.right.getReferences()])}clone(){return new rr(f(c({},this._def),{left:this._def.left.clone(),right:this._def.right.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=a((i,o)=>{if(dr(i)||dr(o))return x;let l=_r(i.value,o.value);return l.valid?((ur(i)||ur(o))&&r.dirty(),{status:r.value,value:l.data}):(v(n,{code:m.invalid_intersection_types}),x)},"handleParsed");return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}isEqual(e){if(!(e instanceof rr))return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new U([this._def.left,this._def.right],{compare:r}),s=new U([e._def.left,e._def.right],{compare:r});return n.isEqual(s)}};a(Tr,"ZodIntersection");Tr.create=a((t,e,r)=>new Tr(c({left:t,right:e,typeName:"ZodIntersection"},S(r))),"create");var an=Tr,br=class xt extends O{get schema(){return this._def.getter()}dereference(e){return new xt(f(c({},this._def),{getter:a(()=>this._def.getter().dereference(e),"getter")}))}getReferences(){return this._def.getter().getReferences()}clone(){return new xt(f(c({},this._def),{getter:a(()=>this._def.getter().clone(),"getter")}))}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}isEqual(e){return e instanceof xt?this._def.getter().isEqual(e._def.getter()):!1}naked(){return this._def.getter().naked()}mandatory(){return new xt(f(c({},this._def),{getter:a(()=>this._def.getter().mandatory(),"getter")}))}};a(br,"ZodLazy");br.create=a((t,e)=>new br(c({getter:t,typeName:"ZodLazy"},S(e))),"create");var on=br,wr=class ql extends O{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return v(r,{received:r.data,code:m.invalid_literal,expected:this._def.value}),x}return{status:"valid",value:e.data}}get value(){return this._def.value}isEqual(e){return e instanceof ql?st(this._def.value,e._def.value):!1}};a(wr,"ZodLiteral");wr.create=a((t,e)=>new wr(c({value:t,typeName:"ZodLiteral"},S(e))),"create");var ln=wr,Pr=class nr extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}dereference(e){let r=this._def.keyType.dereference(e),n=this._def.valueType.dereference(e);return new nr(f(c({},this._def),{keyType:r,valueType:n}))}getReferences(){return Te([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new nr(f(c({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.map)return v(n,{code:m.invalid_type,expected:_.map,received:n.parsedType}),x;let s=this._def.keyType,i=this._def.valueType,o=[...n.data.entries()].map(([l,d],u)=>({key:s._parse(new oe(n,l,n.path,[u,"key"])),value:i._parse(new oe(n,d,n.path,[u,"value"]))}));if(n.common.async){let l=new Map;return Promise.resolve().then(async()=>{for(let d of o){let u=await d.key,g=await d.value;if(u.status==="aborted"||g.status==="aborted")return x;(u.status==="dirty"||g.status==="dirty")&&r.dirty(),l.set(u.value,g.value)}return{status:r.value,value:l}})}else{let l=new Map;for(let d of o){let u=d.key,g=d.value;if(u.status==="aborted"||g.status==="aborted")return x;(u.status==="dirty"||g.status==="dirty")&&r.dirty(),l.set(u.value,g.value)}return{status:r.value,value:l}}}isEqual(e){return!(!(e instanceof nr)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};a(Pr,"ZodMap");Pr.create=a((t,e,r)=>new Pr(c({valueType:e,keyType:t,typeName:"ZodMap"},S(r))),"create");var _s=Pr,xr=class Vl extends O{_parse(e){if(this._getType(e)!==_.nan){let n=this._getOrReturnCtx(e);return v(n,{code:m.invalid_type,expected:_.nan,received:n.parsedType}),x}return{status:"valid",value:e.data}}isEqual(e){return e instanceof Vl}};a(xr,"ZodNaN");xr.create=a(t=>new xr(c({typeName:"ZodNaN"},S(t))),"create");var Ts=xr,kr=class Gl extends O{_parse(e){let r=I.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==_.string&&n.parsedType!==_.number){let s=I.objectValues(r);return v(n,{expected:I.joinValues(s),received:n.parsedType,code:m.invalid_type}),x}if(r.indexOf(e.data)===-1){let s=I.objectValues(r);return v(n,{received:n.data,code:m.invalid_enum_value,options:s}),x}return G(e.data)}get enum(){return this._def.values}isEqual(e){return e instanceof Gl?st(this._def.values,e._def.values):!1}};a(kr,"ZodNativeEnum");kr.create=a((t,e)=>new kr(c({values:t,typeName:"ZodNativeEnum"},S(e))),"create");var cn=kr,Sr=class Jl extends O{_parse(e){let r=this._getOrReturnCtx(e);return v(r,{code:m.invalid_type,expected:_.never,received:r.parsedType}),x}isEqual(e){return e instanceof Jl}};a(Sr,"ZodNever");Sr.create=a(t=>new Sr(c({typeName:"ZodNever"},S(t))),"create");var ft=Sr,Er=class Yl extends O{_parse(e){if(this._getType(e)!==_.null){let n=this._getOrReturnCtx(e);return v(n,{code:m.invalid_type,expected:_.null,received:n.parsedType}),x}return G(e.data)}isEqual(e){return e instanceof Yl}};a(Er,"ZodNull");Er.create=a(t=>new Er(c({typeName:"ZodNull"},S(t))),"create");var dn=Er,Or=class kt extends O{dereference(e){return new kt(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new kt(f(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)===_.null?G(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof kt?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new kt(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(Or,"ZodNullable");Or.create=a((t,e)=>new Or(c({innerType:t,typeName:"ZodNullable"},S(e))),"create");var $e=Or;function Xl(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,i=parseInt(t.toFixed(s).replace(".","")),o=parseInt(e.toFixed(s).replace(".",""));return i%o/Math.pow(10,s)}a(Xl,"floatSafeRemainder");var Zr=class sr extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==_.number){let i=this._getOrReturnCtx(e);return v(i,{code:m.invalid_type,expected:_.number,received:i.parsedType}),x}let n,s=new re;for(let i of this._def.checks)i.kind==="int"?I.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{code:m.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:m.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:m.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Xl(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),v(n,{code:m.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{code:m.not_finite,message:i.message}),s.dirty()):I.assertNever(i);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,P.toString(r))}gt(e,r){return this.setLimit("min",e,!1,P.toString(r))}lte(e,r){return this.setLimit("max",e,!0,P.toString(r))}lt(e,r){return this.setLimit("max",e,!1,P.toString(r))}setLimit(e,r,n,s){return new sr(f(c({},this._def),{checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:P.toString(s)}]}))}_addCheck(e){return new sr(f(c({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:P.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:P.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:P.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:P.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:P.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:P.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:P.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:P.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:P.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&I.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}isEqual(e){if(!(e instanceof sr))return!1;let r=new U(this._def.checks),n=new U(e._def.checks);return r.isEqual(n)}};a(Zr,"ZodNumber");Zr.create=a(t=>new Zr(c({checks:[],typeName:"ZodNumber",coerce:t?.coerce||!1},S(t))),"create");var un=Zr;function He(t){if(t instanceof je){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=ye.create(He(n))}return new je(f(c({},t._def),{shape:a(()=>e,"shape")}))}else return t instanceof dt?new dt(f(c({},t._def),{type:He(t.element)})):t instanceof ye?ye.create(He(t.unwrap())):t instanceof $e?$e.create(He(t.unwrap())):t instanceof Ke?Ke.create(t.items.map(e=>He(e))):t}a(He,"deepPartialify");var ke=class se extends O{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=I.objectKeys(e);return this._cached={shape:e,keys:r}}dereference(e){let r=this._def.shape(),n={};for(let s in r)n[s]=r[s].dereference(e);return new se(f(c({},this._def),{shape:a(()=>n,"shape")}))}getReferences(){let e=this._def.shape(),r=[];for(let n in e)r.push(...e[n].getReferences());return Te(r)}clone(){let e={},r=this._def.shape();for(let[n,s]of Object.entries(r))e[n]=s.clone();return new se(f(c({},this._def),{shape:a(()=>e,"shape")}))}_parse(e){if(this._getType(e)!==_.object){let g=this._getOrReturnCtx(e);return v(g,{code:m.invalid_type,expected:_.object,received:g.parsedType}),x}let{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),l=[];if(this._def.unknownKeys!=="strip")for(let g in s.data)o.includes(g)||l.push(g);let d=[];for(let g of o){let h=i[g],T=s.data[g];d.push({key:{status:"valid",value:g},value:h._parse(new oe(s,T,s.path,g)),alwaysSet:g in s.data})}let u=this._def.unknownKeys;if(u==="passthrough")for(let g of l)d.push({key:{status:"valid",value:g},value:{status:"valid",value:s.data[g]}});else if(u==="strict")l.length>0&&(v(s,{code:m.unrecognized_keys,keys:l}),n.dirty());else if(u!=="strip")for(let g of l){let h=s.data[g];d.push({key:{status:"valid",value:g},value:u._parse(new oe(s,h,s.path,g)),alwaysSet:g in s.data})}return s.common.async?Promise.resolve().then(async()=>{let g=[];for(let h of d){let T=await h.key;g.push({key:T,value:await h.value,alwaysSet:h.alwaysSet})}return g}).then(g=>re.mergeObjectSync(n,g)):re.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return P.errToObj,new se(c(f(c({},this._def),{unknownKeys:"strict"}),e!==void 0?{errorMap:a((r,n)=>{var s,i,o,l;let d=(o=(i=(s=this._def).errorMap)==null?void 0:i.call(s,r,n).message)!=null?o:n.defaultError;return r.code==="unrecognized_keys"?{message:(l=P.errToObj(e).message)!=null?l:d}:{message:d}},"errorMap")}:{}))}strip(){return new se(f(c({},this._def),{unknownKeys:"strip"}))}passthrough(){return new se(f(c({},this._def),{unknownKeys:"passthrough"}))}additionalProperties(){if(this._def.unknownKeys instanceof O)return this._def.unknownKeys;if(this._def.unknownKeys==="passthrough")return ct.create();if(this._def.unknownKeys==="strict")return ft.create()}extend(e){return new se(f(c({},this._def),{shape:a(()=>c(c({},this._def.shape()),e),"shape")}))}merge(e){return new se({unknownKeys:e._def.unknownKeys,shape:a(()=>c(c({},this._def.shape()),e._def.shape()),"shape"),typeName:"ZodObject"})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new se(f(c({},this._def),{unknownKeys:e}))}pick(e){let r={};return I.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new se(f(c({},this._def),{shape:a(()=>r,"shape")}))}omit(e){let r={};return I.objectKeys(this.shape).forEach(n=>{e[n]||(r[n]=this.shape[n])}),new se(f(c({},this._def),{shape:a(()=>r,"shape")}))}deepPartial(){return He(this)}partial(e){let r={};return I.objectKeys(this.shape).forEach(n=>{let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s?.optional()}),new se(f(c({},this._def),{shape:a(()=>r,"shape")}))}required(e){let r={};return I.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof ye;)i=i._def.innerType;r[n]=i}}),new se(f(c({},this._def),{shape:a(()=>r,"shape")}))}keyof(){return Ft(I.objectKeys(this.shape))}isEqual(e){if(!(e instanceof se)||!this._unknownKeysEqual(e))return!1;let r=this._def.shape(),n=e._def.shape(),s=a((l,d)=>l[0]===d[0]&&l[1].isEqual(d[1]),"compare"),i=new U(Object.entries(r),{compare:s}),o=new U(Object.entries(n),{compare:s});return i.isEqual(o)}_unknownKeysEqual(e){let r=this.additionalProperties(),n=e.additionalProperties();return r===void 0||n===void 0?r===n:r.isEqual(n)}};a(ke,"ZodObject");ke.create=a((t,e)=>new ke(c({shape:a(()=>t,"shape"),unknownKeys:"strip",typeName:"ZodObject"},S(e))),"create");ke.strictCreate=a((t,e)=>new ke(c({shape:a(()=>t,"shape"),unknownKeys:"strict",typeName:"ZodObject"},S(e))),"strictCreate");ke.lazycreate=a((t,e)=>new ke(c({shape:t,unknownKeys:"strip",typeName:"ZodObject"},S(e))),"lazycreate");var je=ke,Ir=class ir extends O{dereference(e){return new ir(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new ir(f(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)===_.undefined?G(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof ir?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return this._def.innerType.mandatory()}};a(Ir,"ZodOptional");Ir.create=a((t,e)=>new Ir(c({innerType:t,typeName:"ZodOptional"},S(e))),"create");var ye=Ir,Ql=class St extends O{dereference(e){return new St(f(c({},this._def),{in:this._def.in.dereference(e),out:this._def.out.dereference(e)}))}getReferences(){return Te([...this._def.in.getReferences(),...this._def.out.getReferences()])}clone(){return new St(f(c({},this._def),{in:this._def.in.clone(),out:this._def.out.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return a(async()=>{let i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?x:i.status==="dirty"?(r.dirty(),Ne(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})},"handleAsync")();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?x:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new St({in:e,out:r,typeName:"ZodPipeline"})}isEqual(e){return!(!(e instanceof St)||!this._def.in.isEqual(e._def.in)||!this._def.out.isEqual(e._def.out))}};a(Ql,"ZodPipeline");var pn=Ql,Br=class ar extends O{unwrap(){return this._def.type}dereference(e){return new ar(f(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new ar(f(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==_.promise&&r.common.async===!1)return v(r,{code:m.invalid_type,expected:_.promise,received:r.parsedType}),x;let n=r.parsedType===_.promise?r.data:Promise.resolve(r.data);return G(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}isEqual(e){return e instanceof ar?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}};a(Br,"ZodPromise");Br.create=a((t,e)=>new Br(c({type:t,typeName:"ZodPromise"},S(e))),"create");var Wt=Br,Ar=class Et extends O{dereference(e){return new Et(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new Et(f(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){let r=this._def.innerType._parse(e);return lt(r)&&(r.value=Object.freeze(r.value)),r}unwrap(){return this._def.innerType}isEqual(e){return e instanceof Et?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new Et(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(Ar,"ZodReadonly");Ar.create=a((t,e)=>new Ar(c({innerType:t,typeName:"ZodReadonly"},S(e))),"create");var Lt=Ar,ec=class et extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}dereference(e){let r=this._def.keyType.dereference(e),n=this._def.valueType.dereference(e);return new et(f(c({},this._def),{keyType:r,valueType:n}))}getReferences(){return Te([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new et(f(c({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.object)return v(n,{code:m.invalid_type,expected:_.object,received:n.parsedType}),x;let s=[],i=this._def.keyType,o=this._def.valueType;for(let l in n.data)s.push({key:i._parse(new oe(n,l,n.path,l)),value:o._parse(new oe(n,n.data[l],n.path,l))});return n.common.async?re.mergeObjectAsync(r,s):re.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof O?new et(c({keyType:e,valueType:r,typeName:"ZodRecord"},S(n))):new et(c({keyType:J.create(),valueType:e,typeName:"ZodRecord"},S(r)))}isEqual(e){return!(!(e instanceof et)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};a(ec,"ZodRecord");var bs=ec,Rr=class tc extends O{dereference(e){let r=e[this._def.uri];return r||this}getReferences(){return[this._def.uri]}_parse(e){let r=this._getOrReturnCtx(e);return v(r,{code:m.unresolved_reference}),x}isOptional(){return!1}isNullable(){return!1}isEqual(e){return e instanceof tc?this._def.uri===e._def.uri:!1}};a(Rr,"ZodRef");Rr.create=a(t=>new Rr({typeName:"ZodRef",uri:t}),"create");var ws=Rr,Cr=class tt extends O{dereference(e){return new tt(f(c({},this._def),{valueType:this._def.valueType.dereference(e)}))}getReferences(){return this._def.valueType.getReferences()}clone(){return new tt(f(c({},this._def),{valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.set)return v(n,{code:m.invalid_type,expected:_.set,received:n.parsedType}),x;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(v(n,{code:m.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(v(n,{code:m.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let i=this._def.valueType;function o(d){let u=new Set;for(let g of d){if(g.status==="aborted")return x;g.status==="dirty"&&r.dirty(),u.add(g.value)}return{status:r.value,value:u}}a(o,"finalizeSet");let l=[...n.data.values()].map((d,u)=>i._parse(new oe(n,d,n.path,u)));return n.common.async?Promise.all(l).then(d=>o(d)):o(l)}min(e,r){return new tt(f(c({},this._def),{minSize:{value:e,message:P.toString(r)}}))}max(e,r){return new tt(f(c({},this._def),{maxSize:{value:e,message:P.toString(r)}}))}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}isEqual(e){var r,n,s,i;if(!(e instanceof tt))return!1;let o=(r=this._def.minSize)==null?void 0:r.value,l=(n=e._def.minSize)==null?void 0:n.value;if(o!==l)return!1;let d=(s=this._def.maxSize)==null?void 0:s.value,u=(i=e._def.maxSize)==null?void 0:i.value;return d!==u?!1:this._def.valueType.isEqual(e._def.valueType)}};a(Cr,"ZodSet");Cr.create=a((t,e)=>new Cr(c({valueType:t,minSize:null,maxSize:null,typeName:"ZodSet"},S(e))),"create");var Ps=Cr,xs=/^c[^\s-]{8,}$/i,ks=/^[a-z][a-z0-9]*$/,Ss=/^[0-9A-HJKMNP-TV-Z]{26}$/,Es=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Os=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,rc="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",nc=a(t=>t===rc,"isEmojiRegex"),Nn,Zs=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,Is=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;function sc(t,e){return!!((e==="v4"||!e)&&Zs.test(t)||(e==="v6"||!e)&&Is.test(t))}a(sc,"isValidIP");var Dr=class rt extends O{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==_.string){let i=this._getOrReturnCtx(e);return v(i,{code:m.invalid_type,expected:_.string,received:i.parsedType}),x}let n=new re,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:m.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:m.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,l=e.data.length<i.value;(o||l)&&(s=this._getOrReturnCtx(e,s),o?v(s,{code:m.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):l&&v(s,{code:m.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")Os.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"email",code:m.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")Nn||(Nn=new RegExp(rc,"u")),Nn.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"emoji",code:m.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")Es.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"uuid",code:m.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")xs.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"cuid",code:m.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")ks.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"cuid2",code:m.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")Ss.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"ulid",code:m.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),v(s,{validation:"url",code:m.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"regex",code:m.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),v(s,{code:m.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),v(s,{code:m.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),v(s,{code:m.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?Il(i).test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{code:m.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="ip"?sc(e.data,i.version)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"ip",code:m.invalid_string,message:i.message}),n.dirty()):I.assertNever(i);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),c({validation:r,code:m.invalid_string},P.errToObj(n)))}_addCheck(e){return new rt(f(c({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(c({kind:"email"},P.errToObj(e)))}url(e){return this._addCheck(c({kind:"url"},P.errToObj(e)))}emoji(e){return this._addCheck(c({kind:"emoji"},P.errToObj(e)))}uuid(e){return this._addCheck(c({kind:"uuid"},P.errToObj(e)))}cuid(e){return this._addCheck(c({kind:"cuid"},P.errToObj(e)))}cuid2(e){return this._addCheck(c({kind:"cuid2"},P.errToObj(e)))}ulid(e){return this._addCheck(c({kind:"ulid"},P.errToObj(e)))}ip(e){return this._addCheck(c({kind:"ip"},P.errToObj(e)))}datetime(e){var r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck(c({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(r=e?.offset)!=null?r:!1},P.errToObj(e?.message)))}regex(e,r){return this._addCheck(c({kind:"regex",regex:e},P.errToObj(r)))}includes(e,r){return this._addCheck(c({kind:"includes",value:e,position:r?.position},P.errToObj(r?.message)))}startsWith(e,r){return this._addCheck(c({kind:"startsWith",value:e},P.errToObj(r)))}endsWith(e,r){return this._addCheck(c({kind:"endsWith",value:e},P.errToObj(r)))}min(e,r){return this._addCheck(c({kind:"min",value:e},P.errToObj(r)))}max(e,r){return this._addCheck(c({kind:"max",value:e},P.errToObj(r)))}length(e,r){return this._addCheck(c({kind:"length",value:e},P.errToObj(r)))}nonempty(e){return this.min(1,P.errToObj(e))}trim(){return new rt(f(c({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}secret(){return this._def[w]=f(c({},this._def[w]),{secret:!0}),this}toLowerCase(){return new rt(f(c({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new rt(f(c({},this._def),{checks:[...this._def.checks,{kind:"toUpperCase"}]}))}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}isEqual(e){if(!(e instanceof rt))return!1;let r=new U(this._def.checks),n=new U(e._def.checks);return r.isEqual(n)}};a(Dr,"ZodString");Dr.create=a(t=>{var e;return new Dr(c({checks:[],typeName:"ZodString",coerce:(e=t?.coerce)!=null?e:!1},S(f(c({},t),{supportsExtensions:["secret"]}))))},"create");var J=Dr,Hr=class ic extends O{_parse(e){if(this._getType(e)!==_.symbol){let n=this._getOrReturnCtx(e);return v(n,{code:m.invalid_type,expected:_.symbol,received:n.parsedType}),x}return G(e.data)}isEqual(e){return e instanceof ic}};a(Hr,"ZodSymbol");Hr.create=a(t=>new Hr(c({typeName:"ZodSymbol"},S(t))),"create");var Bs=Hr,ut=class Ot extends O{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName==="ZodEffects"?this._def.schema.sourceType():this._def.schema}dereference(e){return new Ot(f(c({},this._def),{schema:this._def.schema.dereference(e)}))}getReferences(){return this._def.schema.getReferences()}clone(){return new Ot(f(c({},this._def),{schema:this._def.schema.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a(o=>{v(n,o),o.fatal?r.abort():r.dirty()},"addIssue"),get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let o=s.transform(n.data,i);if(n.common.async)return Promise.resolve(o).then(async l=>{if(r.value==="aborted")return x;let d=await this._def.schema._parseAsync({data:l,path:n.path,parent:n});return d.status==="aborted"?x:d.status==="dirty"||r.value==="dirty"?Ne(d.value):d});{if(r.value==="aborted")return x;let l=this._def.schema._parseSync({data:o,path:n.path,parent:n});return l.status==="aborted"?x:l.status==="dirty"||r.value==="dirty"?Ne(l.value):l}}if(s.type==="refinement"){let o=a(l=>{let d=s.refinement(l,i);if(n.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return l},"executeRefinement");if(n.common.async===!1){let l=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return l.status==="aborted"?x:(l.status==="dirty"&&r.dirty(),o(l.value),{status:r.value,value:l.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(l=>l.status==="aborted"?x:(l.status==="dirty"&&r.dirty(),o(l.value).then(()=>({status:r.value,value:l.value}))))}if(s.type==="transform")if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!lt(o))return o;let l=s.transform(o.value,i);if(l instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:l}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>lt(o)?Promise.resolve(s.transform(o.value,i)).then(l=>({status:r.value,value:l})):o);I.assertNever(s)}isEqual(e){return!(e instanceof Ot)||!this._def.schema.isEqual(e._def.schema)?!1:this._def.effect.type==="refinement"?e._def.effect.type!=="refinement"?!1:I.compareFunctions(this._def.effect.refinement,e._def.effect.refinement):this._def.effect.type==="transform"?e._def.effect.type!=="transform"?!1:I.compareFunctions(this._def.effect.transform,e._def.effect.transform):this._def.effect.type==="preprocess"?e._def.effect.type!=="preprocess"?!1:I.compareFunctions(this._def.effect.transform,e._def.effect.transform):!1}naked(){return this._def.schema.naked()}mandatory(){return new Ot(f(c({},this._def),{schema:this._def.schema.mandatory()}))}};a(ut,"ZodEffects");ut.create=a((t,e,r)=>new ut(c({schema:t,typeName:"ZodEffects",effect:e},S(r))),"create");ut.createWithPreprocess=a((t,e,r)=>new ut(c({schema:e,effect:{type:"preprocess",transform:t},typeName:"ZodEffects"},S(r))),"createWithPreprocess");var Se=ut,Nr=class Zt extends O{dereference(e){let r=this._def.items.map(s=>s.dereference(e)),n=this._def.rest?this._def.rest.dereference(e):null;return new Zt(f(c({},this._def),{items:r,rest:n}))}getReferences(){return Te([...this._def.items.flatMap(e=>e.getReferences()),...this._def.rest?this._def.rest.getReferences():[]])}clone(){let e=this._def.items.map(n=>n.clone()),r=this._def.rest?this._def.rest.clone():null;return new Zt(f(c({},this._def),{items:e,rest:r}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.array)return v(n,{code:m.invalid_type,expected:_.array,received:n.parsedType}),x;if(n.data.length<this._def.items.length)return v(n,{code:m.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),x;!this._def.rest&&n.data.length>this._def.items.length&&(v(n,{code:m.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...n.data].map((o,l)=>{let d=this._def.items[l]||this._def.rest;return d?d._parse(new oe(n,o,n.path,l)):null}).filter(o=>!!o);return n.common.async?Promise.all(i).then(o=>re.mergeArray(r,o)):re.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new Zt(f(c({},this._def),{rest:e}))}isEqual(e){if(!(e instanceof Zt)||!this._restEquals(e))return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new U(this._def.items,{compare:r}),s=new U(e._def.items,{compare:r});return n.isEqual(s)}_restEquals(e){return this._def.rest===null?e._def.rest===null:e._def.rest!==null&&this._def.rest.isEqual(e._def.rest)}};a(Nr,"ZodTuple");Nr.create=a((t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Nr(c({items:t,typeName:"ZodTuple",rest:null},S(e)))},"create");var Ke=Nr,Mr=class ac extends O{_parse(e){if(this._getType(e)!==_.undefined){let n=this._getOrReturnCtx(e);return v(n,{code:m.invalid_type,expected:_.undefined,received:n.parsedType}),x}return G(e.data)}isEqual(e){return e instanceof ac}mandatory(){return ft.create(c({},this._def))}};a(Mr,"ZodUndefined");Mr.create=a(t=>new Mr(c({typeName:"ZodUndefined"},S(t))),"create");var qt=Mr,$r=class It extends O{dereference(e){let r=this._def.options.map(n=>n.dereference(e));return new It(f(c({},this._def),{options:r}))}getReferences(){return Te(this._def.options.reduce((e,r)=>[...e,...r.getReferences()],[]))}clone(){let e=this._def.options.map(r=>r.clone());return new It(f(c({},this._def),{options:e}))}_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function s(i){for(let l of i)if(l.result.status==="valid")return l.result;for(let l of i)if(l.result.status==="dirty")return r.common.issues.push(...l.ctx.common.issues),l.result;let o=i.map(l=>new pe(l.ctx.common.issues));return v(r,{code:m.invalid_union,unionErrors:o}),x}if(a(s,"handleResults"),r.common.async)return Promise.all(n.map(async i=>{let o=f(c({},r),{common:f(c({},r.common),{issues:[]}),parent:null});return{result:await i._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(s);{let i,o=[];for(let d of n){let u=f(c({},r),{common:f(c({},r.common),{issues:[]}),parent:null}),g=d._parseSync({data:r.data,path:r.path,parent:u});if(g.status==="valid")return g;g.status==="dirty"&&!i&&(i={result:g,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let l=o.map(d=>new pe(d));return v(r,{code:m.invalid_union,unionErrors:l}),x}}get options(){return this._def.options}isEqual(e){if(!(e instanceof It))return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new U([...this._def.options],{compare:r}),s=new U([...e._def.options],{compare:r});return n.isEqual(s)}mandatory(){let e=this._def.options.filter(i=>!(i instanceof qt)).map(i=>i.mandatory()),[r,n,...s]=e;return r?n?new It(f(c({},this._def),{options:[r,n,...s]})):r:ft.create(c({},this._def))}};a($r,"ZodUnion");$r.create=a((t,e)=>new $r(c({options:t,typeName:"ZodUnion"},S(e))),"create");var fn=$r,jr=class oc extends O{constructor(){super(...arguments),this._unknown=!0}_parse(e){return G(e.data)}isEqual(e){return e instanceof oc}};a(jr,"ZodUnknown");jr.create=a(t=>new jr(c({typeName:"ZodUnknown"},S(t))),"create");var it=jr,Kr=class lc extends O{_parse(e){if(this._getType(e)!==_.undefined){let n=this._getOrReturnCtx(e);return v(n,{code:m.invalid_type,expected:_.void,received:n.parsedType}),x}return G(e.data)}isEqual(e){return e instanceof lc}};a(Kr,"ZodVoid");Kr.create=a(t=>new Kr(c({typeName:"ZodVoid"},S(t))),"create");var As=Kr,mh=["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"],Iv=Ge.create(["any","string","number","boolean","object","pattern","date","array","target","time","enum"]),cc=a(t=>J.create().displayAs({id:"variable",params:c({type:t?.type||"any"},t?.params)}),"variable"),dc=a(t=>J.create().displayAs({id:"conversation",params:c({},t?.params)}),"conversation"),uc=a(t=>J.create().displayAs({id:"user",params:c({},t?.params)}),"user"),pc=a(t=>J.create().displayAs({id:"message",params:c({},t?.params)}),"message"),fc=a(t=>J.create().displayAs({id:"agent",params:c({},t?.params)}),"agent"),gc=a(t=>J.create().displayAs({id:"event",params:c({},t?.params)}),"event"),mc=a(t=>J.create().displayAs({id:"table",params:c({},t?.params)}),"table"),hc=a(t=>J.create().displayAs({id:"tablerow",params:c({},t?.params)}),"tablerow"),yc=a(t=>J.create().displayAs({id:"intent",params:c({},t?.params)}),"intent"),vc=a(()=>Ge.create(mh).displayAs({id:"dropdown",params:{}}),"aimodel"),_c=a(t=>J.create().displayAs({id:"datasource",params:c({},t)}),"datasource"),Tc=a(t=>J.create().displayAs({id:"knowledgebase",params:c({},t)}),"knowledgebase"),bc={object:je.lazycreate},wc=a((t,e={message:`Input not instance of ${t.name}`})=>ms(r=>r instanceof t,e),"instanceOfType"),Rs=J.create,Cs=un.create,Pc=Ts.create,xc=en.create,Ds=tn.create,kc=sn.create,Sc=Bs.create,Ec=qt.create,Oc=dn.create,Zc=ct.create,Ic=it.create,Bc=ft.create,Ac=As.create,Rc=dt.create,Cc=je.create,Dc=je.strictCreate,Hc=fn.create,Nc=hs.create,Mc=an.create,$c=Ke.create,jc=bs.create,Kc=ws.create,Uc=Lt.create,zc=_s.create,Fc=Ps.create,Wc=vs.create,Lc=on.create,qc=ln.create,Vc=Ge.create,Gc=cn.create,Jc=Wt.create,Vn=Se.create,Yc=ye.create,Xc=$e.create,hh=zt.create,Qc=Se.createWithPreprocess,ed=pn.create,td=a(()=>Rs().optional(),"ostring"),rd=a(()=>Cs().optional(),"onumber"),nd=a(()=>Ds().optional(),"oboolean"),sd={string:a(t=>J.create(f(c({},t),{coerce:!0})),"string"),number:a(t=>un.create(f(c({},t),{coerce:!0})),"number"),boolean:a(t=>tn.create(f(c({},t),{coerce:!0})),"boolean"),bigint:a(t=>en.create(f(c({},t),{coerce:!0})),"bigint"),date:a(t=>sn.create(f(c({},t),{coerce:!0})),"date")},id=x,p=y,ad=a((t,e)=>t.anyOf.length?t.anyOf.length===1?L(t.anyOf[0],f(c({},e),{path:[...e.path,"anyOf",0]})):`z.union([${t.anyOf.map((r,n)=>L(r,f(c({},e),{path:[...e.path,"anyOf",n]}))).join(", ")}])`:"z.any()","parseAnyOf"),yh=a(t=>{var e;return(e=t[w])!=null&&e.coerce?"z.coerce.boolean()":"z.boolean()"},"parseBoolean"),vh=a(t=>"z.any()","parseDefault"),_h=a((t,e)=>`z.union([${t.type.map(r=>L(f(c({},t),{type:r}),e)).join(", ")}])`,"parseMultipleType"),Th=a((t,e)=>`z.any().refine((value) => !${L(t.not,f(c({},e),{path:[...e.path,"not"]}))}.safeParse(value).success, "Invalid input: Should NOT be valid against schema")`,"parseNot"),bh=a(t=>"z.null()","parseNull"),wh=a(t=>[t.slice(0,t.length/2),t.slice(t.length/2)],"half"),Ph=a((t,...e)=>Object.keys(t).reduce((r,n)=>(e.includes(n)||(r[n]=t[n]),r),{}),"omit");function V(t,e,r){var n;let s=t[e],i="";if(s!==void 0){let o=r({value:s,json:JSON.stringify(s)});if(o){let l=o[0],d=o.length===3?o[1]:"",u=o.length===3?o[2]:o[1];i+=l,((n=t.errorMessage)==null?void 0:n[e])!==void 0&&(i+=d+JSON.stringify(t.errorMessage[e])),i+=u}}return i}a(V,"withMessage");var Bt=Symbol("Original index"),xh=a(t=>{let e=[];for(let r=0;r<t.length;r++){let n=t[r];if(typeof n=="boolean")e.push(n?{[Bt]:r}:{[Bt]:r,not:{}});else{if(Bt in n)return t;e.push(f(c({},n),{[Bt]:r}))}}return e},"ensureOriginalIndex");function Kt(t,e){if(t.allOf.length===0)return"z.never()";if(t.allOf.length===1){let r=t.allOf[0];return L(r,f(c({},e),{path:[...e.path,"allOf",r[Bt]]}))}else{let[r,n]=wh(xh(t.allOf));return`z.intersection(${Kt({allOf:r},e)}, ${Kt({allOf:n},e)})`}}a(Kt,"parseAllOf");var kh=a((t,e)=>{if(Array.isArray(t.items))return`z.tuple([${t.items.map((n,s)=>L(n,f(c({},e),{path:[...e.path,"items",s]})))}])`;let r=t.items?`z.array(${L(t.items,f(c({},e),{path:[...e.path,"items"]}))})`:"z.array(z.any())";return r+=V(t,"minItems",({json:n})=>[`.min(${n}`,", ",")"]),r+=V(t,"maxItems",({json:n})=>[`.max(${n}`,", ",")"]),r},"parseArray"),Sh=a(t=>`z.literal(${JSON.stringify(t.const)})`,"parseConst"),Eh=a(t=>t.enum.length===0?"z.never()":t.enum.length===1?`z.literal(${JSON.stringify(t.enum[0])})`:t.enum.every(e=>typeof e=="string")?`z.enum([${t.enum.map(e=>JSON.stringify(e))}])`:`z.union([${t.enum.map(e=>`z.literal(${JSON.stringify(e)})`).join(", ")}])`,"parseEnum"),Oh=a((t,e)=>{let r=L(t.if,f(c({},e),{path:[...e.path,"if"]})),n=L(t.then,f(c({},e),{path:[...e.path,"then"]})),s=L(t.else,f(c({},e),{path:[...e.path,"else"]}));return`z.union([${n}, ${s}]).superRefine((value,ctx) => {
13
+ ${ie}`.trim();case p.ZodFirstPartyTypeKind.ZodEnum:return l.values.map(b).join(" | ");case p.ZodFirstPartyTypeKind.ZodEffects:return B(l.schema,i);case p.ZodFirstPartyTypeKind.ZodNativeEnum:throw new Xi(p.ZodFirstPartyTypeKind.ZodNativeEnum);case p.ZodFirstPartyTypeKind.ZodOptional:return`${B(l.innerType,i)} | undefined`;case p.ZodFirstPartyTypeKind.ZodNullable:return`${B(l.innerType,i)} | null`;case p.ZodFirstPartyTypeKind.ZodDefault:let ae=e.treatDefaultAsOptional?l.innerType.optional():l.innerType;return B(ae,i);case p.ZodFirstPartyTypeKind.ZodCatch:return B(l.innerType,i);case p.ZodFirstPartyTypeKind.ZodPromise:return`Promise<${B(l.type,i)}>`;case p.ZodFirstPartyTypeKind.ZodBranded:return B(l.type,i);case p.ZodFirstPartyTypeKind.ZodPipeline:return B(l.in,i);case p.ZodFirstPartyTypeKind.ZodSymbol:return`${z(o.description)} symbol`.trim();case p.ZodFirstPartyTypeKind.ZodReadonly:return`Readonly<${B(l.innerType,i)}>`;case p.ZodFirstPartyTypeKind.ZodRef:return Hi(l.uri);default:I.assertNever(l)}}a(B,"sUnwrapZod");var Cu=a((t,e)=>{if(t.props.type==="none")return B(t.props.schema,e);let{schema:r,identifier:n}=t.props,s=z(r.description),i=r.describe(""),o=B(i,f(c({},e),{declaration:!0})),d=o.split(`
14
+ `).length>=Bu&&e.includeClosingTags?`// end of ${n}`:"";if(t.props.type!=="type"&&r instanceof p.ZodFunction)return Bn(`${s}
15
+ declare function ${n}${o};${d}`);if(t.props.type==="variable")return Bn(`${s}declare const ${n}: ${o};${d}`);let u=t.props.args.length>0?`<${t.props.args.map(Hi).join(", ")}>`:"";return Bn(`${s}type ${t.props.identifier}${u} = ${o};${d}`)},"unwrapDeclaration"),Du=a(t=>t.declaration?t.declaration===!0?"variable":t.declaration:"none","getDeclarationType"),Hu=a((t,e)=>{let r=Du(e),n=t.getReferences();if(r==="none"){if(n.length>0)throw new jn;return new Rt({type:"none",schema:t})}let s="title"in t.ui?t.ui.title:null;if(!s)throw new ea;if(r==="variable"){if(n.length>0)throw new jn;return new Rt({type:"variable",identifier:s,schema:t})}return new Rt({type:"type",identifier:s,schema:t,args:n})},"getDeclarationProps"),Nu=typeof global=="object"&&global&&global.Object===Object&&global,oa=Nu,Mu=typeof self=="object"&&self&&self.Object===Object&&self,$u=oa||Mu||Function("return this")(),_e=$u,ju=_e.Symbol,xe=ju,la=Object.prototype,Ku=la.hasOwnProperty,Uu=la.toString,_t=xe?xe.toStringTag:void 0;function ca(t){var e=Ku.call(t,_t),r=t[_t];try{t[_t]=void 0;var n=!0}catch{}var s=Uu.call(t);return n&&(e?t[_t]=r:delete t[_t]),s}a(ca,"getRawTag");var zu=ca,Fu=Object.prototype,Wu=Fu.toString;function da(t){return Wu.call(t)}a(da,"objectToString");var Lu=da,qu="[object Null]",Vu="[object Undefined]",Xs=xe?xe.toStringTag:void 0;function ua(t){return t==null?t===void 0?Vu:qu:Xs&&Xs in Object(t)?zu(t):Lu(t)}a(ua,"baseGetTag");var Ue=ua;function pa(t){return t!=null&&typeof t=="object"}a(pa,"isObjectLike");var Me=pa,Gu="[object Symbol]";function fa(t){return typeof t=="symbol"||Me(t)&&Ue(t)==Gu}a(fa,"isSymbol");var Qn=fa;function ga(t,e){for(var r=-1,n=t==null?0:t.length,s=Array(n);++r<n;)s[r]=e(t[r],r,t);return s}a(ga,"arrayMap");var ma=ga,Ju=Array.isArray,ve=Ju,Yu=1/0,Qs=xe?xe.prototype:void 0,ei=Qs?Qs.toString:void 0;function es(t){if(typeof t=="string")return t;if(ve(t))return ma(t,es)+"";if(Qn(t))return ei?ei.call(t):"";var e=t+"";return e=="0"&&1/t==-Yu?"-0":e}a(es,"baseToString");var Xu=es;function ha(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}a(ha,"isObject");var at=ha;function ya(t){return t}a(ya,"identity");var Qu=ya,ep="[object AsyncFunction]",tp="[object Function]",rp="[object GeneratorFunction]",np="[object Proxy]";function va(t){if(!at(t))return!1;var e=Ue(t);return e==tp||e==rp||e==ep||e==np}a(va,"isFunction");var _a=va,sp=_e["__core-js_shared__"],An=sp,ti=(function(){var t=/[^.]+$/.exec(An&&An.keys&&An.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function Ta(t){return!!ti&&ti in t}a(Ta,"isMasked");var ip=Ta,ap=Function.prototype,op=ap.toString;function ba(t){if(t!=null){try{return op.call(t)}catch{}try{return t+""}catch{}}return""}a(ba,"toSource");var ze=ba,lp=/[\\^$.*+?()[\]{}|]/g,cp=/^\[object .+?Constructor\]$/,dp=Function.prototype,up=Object.prototype,pp=dp.toString,fp=up.hasOwnProperty,gp=RegExp("^"+pp.call(fp).replace(lp,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function wa(t){if(!at(t)||ip(t))return!1;var e=_a(t)?gp:cp;return e.test(ze(t))}a(wa,"baseIsNative");var mp=wa;function Pa(t,e){return t?.[e]}a(Pa,"getValue");var hp=Pa;function xa(t,e){var r=hp(t,e);return mp(r)?r:void 0}a(xa,"getNative");var Fe=xa,yp=Fe(_e,"WeakMap"),Kn=yp,vp=(function(){try{var t=Fe(Object,"defineProperty");return t({},"",{}),t}catch{}})(),ri=vp,_p=9007199254740991,Tp=/^(?:0|[1-9]\d*)$/;function ka(t,e){var r=typeof t;return e=e??_p,!!e&&(r=="number"||r!="symbol"&&Tp.test(t))&&t>-1&&t%1==0&&t<e}a(ka,"isIndex");var ts=ka;function Sa(t,e,r){e=="__proto__"&&ri?ri(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}a(Sa,"baseAssignValue");var Ea=Sa;function Oa(t,e){return t===e||t!==t&&e!==e}a(Oa,"eq");var rs=Oa,bp=Object.prototype,wp=bp.hasOwnProperty;function Za(t,e,r){var n=t[e];(!(wp.call(t,e)&&rs(n,r))||r===void 0&&!(e in t))&&Ea(t,e,r)}a(Za,"assignValue");var Pp=Za,xp=9007199254740991;function Ia(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=xp}a(Ia,"isLength");var ns=Ia;function Ba(t){return t!=null&&ns(t.length)&&!_a(t)}a(Ba,"isArrayLike");var Aa=Ba,kp=Object.prototype;function Ra(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||kp;return t===r}a(Ra,"isPrototype");var Ca=Ra;function Da(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}a(Da,"baseTimes");var Sp=Da,Ep="[object Arguments]";function Ha(t){return Me(t)&&Ue(t)==Ep}a(Ha,"baseIsArguments");var ni=Ha,Na=Object.prototype,Op=Na.hasOwnProperty,Zp=Na.propertyIsEnumerable,Ip=ni((function(){return arguments})())?ni:function(t){return Me(t)&&Op.call(t,"callee")&&!Zp.call(t,"callee")},Ma=Ip;function $a(){return!1}a($a,"stubFalse");var Bp=$a,ja=typeof exports=="object"&&exports&&!exports.nodeType&&exports,si=ja&&typeof module=="object"&&module&&!module.nodeType&&module,Ap=si&&si.exports===ja,ii=Ap?_e.Buffer:void 0,Rp=ii?ii.isBuffer:void 0,Cp=Rp||Bp,Un=Cp,Dp="[object Arguments]",Hp="[object Array]",Np="[object Boolean]",Mp="[object Date]",$p="[object Error]",jp="[object Function]",Kp="[object Map]",Up="[object Number]",zp="[object Object]",Fp="[object RegExp]",Wp="[object Set]",Lp="[object String]",qp="[object WeakMap]",Vp="[object ArrayBuffer]",Gp="[object DataView]",Jp="[object Float32Array]",Yp="[object Float64Array]",Xp="[object Int8Array]",Qp="[object Int16Array]",ef="[object Int32Array]",tf="[object Uint8Array]",rf="[object Uint8ClampedArray]",nf="[object Uint16Array]",sf="[object Uint32Array]",H={};H[Jp]=H[Yp]=H[Xp]=H[Qp]=H[ef]=H[tf]=H[rf]=H[nf]=H[sf]=!0;H[Dp]=H[Hp]=H[Vp]=H[Np]=H[Gp]=H[Mp]=H[$p]=H[jp]=H[Kp]=H[Up]=H[zp]=H[Fp]=H[Wp]=H[Lp]=H[qp]=!1;function Ka(t){return Me(t)&&ns(t.length)&&!!H[Ue(t)]}a(Ka,"baseIsTypedArray");var af=Ka;function Ua(t){return function(e){return t(e)}}a(Ua,"baseUnary");var of=Ua,za=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ct=za&&typeof module=="object"&&module&&!module.nodeType&&module,lf=Ct&&Ct.exports===za,Rn=lf&&oa.process,cf=(function(){try{var t=Ct&&Ct.require&&Ct.require("util").types;return t||Rn&&Rn.binding&&Rn.binding("util")}catch{}})(),ai=cf,oi=ai&&ai.isTypedArray,df=oi?of(oi):af,Fa=df,uf=Object.prototype,pf=uf.hasOwnProperty;function Wa(t,e){var r=ve(t),n=!r&&Ma(t),s=!r&&!n&&Un(t),i=!r&&!n&&!s&&Fa(t),o=r||n||s||i,l=o?Sp(t.length,String):[],d=l.length;for(var u in t)(e||pf.call(t,u))&&!(o&&(u=="length"||s&&(u=="offset"||u=="parent")||i&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||ts(u,d)))&&l.push(u);return l}a(Wa,"arrayLikeKeys");var La=Wa;function qa(t,e){return function(r){return t(e(r))}}a(qa,"overArg");var Va=qa,ff=Va(Object.keys,Object),gf=ff,mf=Object.prototype,hf=mf.hasOwnProperty;function Ga(t){if(!Ca(t))return gf(t);var e=[];for(var r in Object(t))hf.call(t,r)&&r!="constructor"&&e.push(r);return e}a(Ga,"baseKeys");var yf=Ga;function Ja(t){return Aa(t)?La(t):yf(t)}a(Ja,"keys");var ss=Ja;function Ya(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}a(Ya,"nativeKeysIn");var vf=Ya,_f=Object.prototype,Tf=_f.hasOwnProperty;function Xa(t){if(!at(t))return vf(t);var e=Ca(t),r=[];for(var n in t)n=="constructor"&&(e||!Tf.call(t,n))||r.push(n);return r}a(Xa,"baseKeysIn");var bf=Xa;function Qa(t){return Aa(t)?La(t,!0):bf(t)}a(Qa,"keysIn");var wf=Qa,Pf=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,xf=/^\w*$/;function eo(t,e){if(ve(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||Qn(t)?!0:xf.test(t)||!Pf.test(t)||e!=null&&t in Object(e)}a(eo,"isKey");var is=eo,kf=Fe(Object,"create"),Ht=kf;function to(){this.__data__=Ht?Ht(null):{},this.size=0}a(to,"hashClear");var Sf=to;function ro(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}a(ro,"hashDelete");var Ef=ro,Of="__lodash_hash_undefined__",Zf=Object.prototype,If=Zf.hasOwnProperty;function no(t){var e=this.__data__;if(Ht){var r=e[t];return r===Of?void 0:r}return If.call(e,t)?e[t]:void 0}a(no,"hashGet");var Bf=no,Af=Object.prototype,Rf=Af.hasOwnProperty;function so(t){var e=this.__data__;return Ht?e[t]!==void 0:Rf.call(e,t)}a(so,"hashHas");var Cf=so,Df="__lodash_hash_undefined__";function io(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Ht&&e===void 0?Df:e,this}a(io,"hashSet");var Hf=io;function We(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}a(We,"Hash");We.prototype.clear=Sf;We.prototype.delete=Ef;We.prototype.get=Bf;We.prototype.has=Cf;We.prototype.set=Hf;var li=We;function ao(){this.__data__=[],this.size=0}a(ao,"listCacheClear");var Nf=ao;function oo(t,e){for(var r=t.length;r--;)if(rs(t[r][0],e))return r;return-1}a(oo,"assocIndexOf");var qr=oo,Mf=Array.prototype,$f=Mf.splice;function lo(t){var e=this.__data__,r=qr(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():$f.call(e,r,1),--this.size,!0}a(lo,"listCacheDelete");var jf=lo;function co(t){var e=this.__data__,r=qr(e,t);return r<0?void 0:e[r][1]}a(co,"listCacheGet");var Kf=co;function uo(t){return qr(this.__data__,t)>-1}a(uo,"listCacheHas");var Uf=uo;function po(t,e){var r=this.__data__,n=qr(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this}a(po,"listCacheSet");var zf=po;function Le(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}a(Le,"ListCache");Le.prototype.clear=Nf;Le.prototype.delete=jf;Le.prototype.get=Kf;Le.prototype.has=Uf;Le.prototype.set=zf;var Vr=Le,Ff=Fe(_e,"Map"),Nt=Ff;function fo(){this.size=0,this.__data__={hash:new li,map:new(Nt||Vr),string:new li}}a(fo,"mapCacheClear");var Wf=fo;function go(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}a(go,"isKeyable");var Lf=go;function mo(t,e){var r=t.__data__;return Lf(e)?r[typeof e=="string"?"string":"hash"]:r.map}a(mo,"getMapData");var Gr=mo;function ho(t){var e=Gr(this,t).delete(t);return this.size-=e?1:0,e}a(ho,"mapCacheDelete");var qf=ho;function yo(t){return Gr(this,t).get(t)}a(yo,"mapCacheGet");var Vf=yo;function vo(t){return Gr(this,t).has(t)}a(vo,"mapCacheHas");var Gf=vo;function _o(t,e){var r=Gr(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this}a(_o,"mapCacheSet");var Jf=_o;function qe(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}a(qe,"MapCache");qe.prototype.clear=Wf;qe.prototype.delete=qf;qe.prototype.get=Vf;qe.prototype.has=Gf;qe.prototype.set=Jf;var Jr=qe,Yf="Expected a function";function Yr(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(Yf);var r=a(function(){var n=arguments,s=e?e.apply(this,n):n[0],i=r.cache;if(i.has(s))return i.get(s);var o=t.apply(this,n);return r.cache=i.set(s,o)||i,o},"memoized");return r.cache=new(Yr.Cache||Jr),r}a(Yr,"memoize");Yr.Cache=Jr;var Xf=Yr,Qf=500;function To(t){var e=Xf(t,function(n){return r.size===Qf&&r.clear(),n}),r=e.cache;return e}a(To,"memoizeCapped");var eg=To,tg=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,rg=/\\(\\)?/g,ng=eg(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(tg,function(r,n,s,i){e.push(s?i.replace(rg,"$1"):n||r)}),e}),sg=ng;function bo(t){return t==null?"":Xu(t)}a(bo,"toString");var ig=bo;function wo(t,e){return ve(t)?t:is(t,e)?[t]:sg(ig(t))}a(wo,"castPath");var Xr=wo,ag=1/0;function Po(t){if(typeof t=="string"||Qn(t))return t;var e=t+"";return e=="0"&&1/t==-ag?"-0":e}a(Po,"toKey");var Ut=Po;function xo(t,e){e=Xr(e,t);for(var r=0,n=e.length;t!=null&&r<n;)t=t[Ut(e[r++])];return r&&r==n?t:void 0}a(xo,"baseGet");var as=xo;function ko(t,e,r){var n=t==null?void 0:as(t,e);return n===void 0?r:n}a(ko,"get");var og=ko;function So(t,e){for(var r=-1,n=e.length,s=t.length;++r<n;)t[s+r]=e[r];return t}a(So,"arrayPush");var Eo=So,lg=Va(Object.getPrototypeOf,Object),Oo=lg,cg="[object Object]",dg=Function.prototype,ug=Object.prototype,Zo=dg.toString,pg=ug.hasOwnProperty,fg=Zo.call(Object);function Io(t){if(!Me(t)||Ue(t)!=cg)return!1;var e=Oo(t);if(e===null)return!0;var r=pg.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&Zo.call(r)==fg}a(Io,"isPlainObject");var ci=Io;function Bo(){this.__data__=new Vr,this.size=0}a(Bo,"stackClear");var gg=Bo;function Ao(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}a(Ao,"stackDelete");var mg=Ao;function Ro(t){return this.__data__.get(t)}a(Ro,"stackGet");var hg=Ro;function Co(t){return this.__data__.has(t)}a(Co,"stackHas");var yg=Co,vg=200;function Do(t,e){var r=this.__data__;if(r instanceof Vr){var n=r.__data__;if(!Nt||n.length<vg-1)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Jr(n)}return r.set(t,e),this.size=r.size,this}a(Do,"stackSet");var _g=Do;function Ve(t){var e=this.__data__=new Vr(t);this.size=e.size}a(Ve,"Stack");Ve.prototype.clear=gg;Ve.prototype.delete=mg;Ve.prototype.get=hg;Ve.prototype.has=yg;Ve.prototype.set=_g;var Qt=Ve;function Ho(t,e){for(var r=-1,n=t==null?0:t.length,s=0,i=[];++r<n;){var o=t[r];e(o,r,t)&&(i[s++]=o)}return i}a(Ho,"arrayFilter");var Tg=Ho;function No(){return[]}a(No,"stubArray");var Mo=No,bg=Object.prototype,wg=bg.propertyIsEnumerable,di=Object.getOwnPropertySymbols,Pg=di?function(t){return t==null?[]:(t=Object(t),Tg(di(t),function(e){return wg.call(t,e)}))}:Mo,$o=Pg,xg=Object.getOwnPropertySymbols,kg=xg?function(t){for(var e=[];t;)Eo(e,$o(t)),t=Oo(t);return e}:Mo,Sg=kg;function jo(t,e,r){var n=e(t);return ve(t)?n:Eo(n,r(t))}a(jo,"baseGetAllKeys");var Ko=jo;function Uo(t){return Ko(t,ss,$o)}a(Uo,"getAllKeys");var ui=Uo;function zo(t){return Ko(t,wf,Sg)}a(zo,"getAllKeysIn");var Eg=zo,Og=Fe(_e,"DataView"),zn=Og,Zg=Fe(_e,"Promise"),Fn=Zg,Ig=Fe(_e,"Set"),Wn=Ig,pi="[object Map]",Bg="[object Object]",fi="[object Promise]",gi="[object Set]",mi="[object WeakMap]",hi="[object DataView]",Ag=ze(zn),Rg=ze(Nt),Cg=ze(Fn),Dg=ze(Wn),Hg=ze(Kn),Ae=Ue;(zn&&Ae(new zn(new ArrayBuffer(1)))!=hi||Nt&&Ae(new Nt)!=pi||Fn&&Ae(Fn.resolve())!=fi||Wn&&Ae(new Wn)!=gi||Kn&&Ae(new Kn)!=mi)&&(Ae=a(function(t){var e=Ue(t),r=e==Bg?t.constructor:void 0,n=r?ze(r):"";if(n)switch(n){case Ag:return hi;case Rg:return pi;case Cg:return fi;case Dg:return gi;case Hg:return mi}return e},"getTag"));var yi=Ae,Ng=_e.Uint8Array,vi=Ng,Mg="__lodash_hash_undefined__";function Fo(t){return this.__data__.set(t,Mg),this}a(Fo,"setCacheAdd");var $g=Fo;function Wo(t){return this.__data__.has(t)}a(Wo,"setCacheHas");var jg=Wo;function Mt(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new Jr;++e<r;)this.add(t[e])}a(Mt,"SetCache");Mt.prototype.add=Mt.prototype.push=$g;Mt.prototype.has=jg;var Kg=Mt;function Lo(t,e){for(var r=-1,n=t==null?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}a(Lo,"arraySome");var Ug=Lo;function qo(t,e){return t.has(e)}a(qo,"cacheHas");var zg=qo,Fg=1,Wg=2;function Vo(t,e,r,n,s,i){var o=r&Fg,l=t.length,d=e.length;if(l!=d&&!(o&&d>l))return!1;var u=i.get(t),g=i.get(e);if(u&&g)return u==e&&g==t;var h=-1,T=!0,Z=r&Wg?new Kg:void 0;for(i.set(t,e),i.set(e,t);++h<l;){var k=t[h],K=e[h];if(n)var F=o?n(K,k,h,e,t,i):n(k,K,h,t,e,i);if(F!==void 0){if(F)continue;T=!1;break}if(Z){if(!Ug(e,function(Q,ie){if(!zg(Z,ie)&&(k===Q||s(k,Q,r,n,i)))return Z.push(ie)})){T=!1;break}}else if(!(k===K||s(k,K,r,n,i))){T=!1;break}}return i.delete(t),i.delete(e),T}a(Vo,"equalArrays");var Go=Vo;function Jo(t){var e=-1,r=Array(t.size);return t.forEach(function(n,s){r[++e]=[s,n]}),r}a(Jo,"mapToArray");var Lg=Jo;function Yo(t){var e=-1,r=Array(t.size);return t.forEach(function(n){r[++e]=n}),r}a(Yo,"setToArray");var qg=Yo,Vg=1,Gg=2,Jg="[object Boolean]",Yg="[object Date]",Xg="[object Error]",Qg="[object Map]",em="[object Number]",tm="[object RegExp]",rm="[object Set]",nm="[object String]",sm="[object Symbol]",im="[object ArrayBuffer]",am="[object DataView]",_i=xe?xe.prototype:void 0,Cn=_i?_i.valueOf:void 0;function Xo(t,e,r,n,s,i,o){switch(r){case am:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case im:return!(t.byteLength!=e.byteLength||!i(new vi(t),new vi(e)));case Jg:case Yg:case em:return rs(+t,+e);case Xg:return t.name==e.name&&t.message==e.message;case tm:case nm:return t==e+"";case Qg:var l=Lg;case rm:var d=n&Vg;if(l||(l=qg),t.size!=e.size&&!d)return!1;var u=o.get(t);if(u)return u==e;n|=Gg,o.set(t,e);var g=Go(l(t),l(e),n,s,i,o);return o.delete(t),g;case sm:if(Cn)return Cn.call(t)==Cn.call(e)}return!1}a(Xo,"equalByTag");var om=Xo,lm=1,cm=Object.prototype,dm=cm.hasOwnProperty;function Qo(t,e,r,n,s,i){var o=r&lm,l=ui(t),d=l.length,u=ui(e),g=u.length;if(d!=g&&!o)return!1;for(var h=d;h--;){var T=l[h];if(!(o?T in e:dm.call(e,T)))return!1}var Z=i.get(t),k=i.get(e);if(Z&&k)return Z==e&&k==t;var K=!0;i.set(t,e),i.set(e,t);for(var F=o;++h<d;){T=l[h];var Q=t[T],ie=e[T];if(n)var ue=o?n(ie,Q,T,e,t,i):n(Q,ie,T,t,e,i);if(!(ue===void 0?Q===ie||s(Q,ie,r,n,i):ue)){K=!1;break}F||(F=T=="constructor")}if(K&&!F){var ae=t.constructor,ee=e.constructor;ae!=ee&&"constructor"in t&&"constructor"in e&&!(typeof ae=="function"&&ae instanceof ae&&typeof ee=="function"&&ee instanceof ee)&&(K=!1)}return i.delete(t),i.delete(e),K}a(Qo,"equalObjects");var um=Qo,pm=1,Ti="[object Arguments]",bi="[object Array]",Xt="[object Object]",fm=Object.prototype,wi=fm.hasOwnProperty;function el(t,e,r,n,s,i){var o=ve(t),l=ve(e),d=o?bi:yi(t),u=l?bi:yi(e);d=d==Ti?Xt:d,u=u==Ti?Xt:u;var g=d==Xt,h=u==Xt,T=d==u;if(T&&Un(t)){if(!Un(e))return!1;o=!0,g=!1}if(T&&!g)return i||(i=new Qt),o||Fa(t)?Go(t,e,r,n,s,i):om(t,e,d,r,n,s,i);if(!(r&pm)){var Z=g&&wi.call(t,"__wrapped__"),k=h&&wi.call(e,"__wrapped__");if(Z||k){var K=Z?t.value():t,F=k?e.value():e;return i||(i=new Qt),s(K,F,r,n,i)}}return T?(i||(i=new Qt),um(t,e,r,n,s,i)):!1}a(el,"baseIsEqualDeep");var gm=el;function os(t,e,r,n,s){return t===e?!0:t==null||e==null||!Me(t)&&!Me(e)?t!==t&&e!==e:gm(t,e,r,n,os,s)}a(os,"baseIsEqual");var Qr=os,mm=1,hm=2;function tl(t,e,r,n){var s=r.length,i=s,o=!n;if(t==null)return!i;for(t=Object(t);s--;){var l=r[s];if(o&&l[2]?l[1]!==t[l[0]]:!(l[0]in t))return!1}for(;++s<i;){l=r[s];var d=l[0],u=t[d],g=l[1];if(o&&l[2]){if(u===void 0&&!(d in t))return!1}else{var h=new Qt;if(n)var T=n(u,g,d,t,e,h);if(!(T===void 0?Qr(g,u,mm|hm,n,h):T))return!1}}return!0}a(tl,"baseIsMatch");var ym=tl;function rl(t){return t===t&&!at(t)}a(rl,"isStrictComparable");var nl=rl;function sl(t){for(var e=ss(t),r=e.length;r--;){var n=e[r],s=t[n];e[r]=[n,s,nl(s)]}return e}a(sl,"getMatchData");var vm=sl;function il(t,e){return function(r){return r==null?!1:r[t]===e&&(e!==void 0||t in Object(r))}}a(il,"matchesStrictComparable");var al=il;function ol(t){var e=vm(t);return e.length==1&&e[0][2]?al(e[0][0],e[0][1]):function(r){return r===t||ym(r,t,e)}}a(ol,"baseMatches");var _m=ol;function ll(t,e){return t!=null&&e in Object(t)}a(ll,"baseHasIn");var Tm=ll;function cl(t,e,r){e=Xr(e,t);for(var n=-1,s=e.length,i=!1;++n<s;){var o=Ut(e[n]);if(!(i=t!=null&&r(t,o)))break;t=t[o]}return i||++n!=s?i:(s=t==null?0:t.length,!!s&&ns(s)&&ts(o,s)&&(ve(t)||Ma(t)))}a(cl,"hasPath");var bm=cl;function dl(t,e){return t!=null&&bm(t,e,Tm)}a(dl,"hasIn");var wm=dl,Pm=1,xm=2;function ul(t,e){return is(t)&&nl(e)?al(Ut(t),e):function(r){var n=og(r,t);return n===void 0&&n===e?wm(r,t):Qr(e,n,Pm|xm)}}a(ul,"baseMatchesProperty");var km=ul;function pl(t){return function(e){return e?.[t]}}a(pl,"baseProperty");var Sm=pl;function fl(t){return function(e){return as(e,t)}}a(fl,"basePropertyDeep");var Em=fl;function gl(t){return is(t)?Sm(Ut(t)):Em(t)}a(gl,"property");var Om=gl;function ml(t){return typeof t=="function"?t:t==null?Qu:typeof t=="object"?ve(t)?km(t[0],t[1]):_m(t):Om(t)}a(ml,"baseIteratee");var ls=ml;function hl(t){return function(e,r,n){for(var s=-1,i=Object(e),o=n(e),l=o.length;l--;){var d=o[t?l:++s];if(r(i[d],d,i)===!1)break}return e}}a(hl,"createBaseFor");var Zm=hl,Im=Zm(),Bm=Im;function yl(t,e){return t&&Bm(t,e,ss)}a(yl,"baseForOwn");var Am=yl;function vl(t,e){return Qr(t,e)}a(vl,"isEqual");var st=vl;function _l(t,e,r){r=typeof r=="function"?r:void 0;var n=r?r(t,e):void 0;return n===void 0?Qr(t,e,void 0,r):!!n}a(_l,"isEqualWith");var Rm=_l;function Tl(t){return t===void 0}a(Tl,"isUndefined");var Pi=Tl;function bl(t,e){var r={};return e=ls(e,3),Am(t,function(n,s,i){Ea(r,s,e(n,s,i))}),r}a(bl,"mapValues");var Cm=bl,Dm="Expected a function";function wl(t){if(typeof t!="function")throw new TypeError(Dm);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}a(wl,"negate");var Hm=wl;function Pl(t,e,r,n){if(!at(t))return t;e=Xr(e,t);for(var s=-1,i=e.length,o=i-1,l=t;l!=null&&++s<i;){var d=Ut(e[s]),u=r;if(d==="__proto__"||d==="constructor"||d==="prototype")return t;if(s!=o){var g=l[d];u=n?n(g,d,l):void 0,u===void 0&&(u=at(g)?g:ts(e[s+1])?[]:{})}Pp(l,d,u),l=l[d]}return t}a(Pl,"baseSet");var Nm=Pl;function xl(t,e,r){for(var n=-1,s=e.length,i={};++n<s;){var o=e[n],l=as(t,o);r(l,o)&&Nm(i,Xr(o,t),l)}return i}a(xl,"basePickBy");var Mm=xl;function kl(t,e){if(t==null)return{};var r=ma(Eg(t),function(n){return[n]});return e=ls(e),Mm(t,r,function(n,s){return e(n,s[0])})}a(kl,"pickBy");var $m=kl;function Sl(t,e){return $m(t,Hm(ls(e)))}a(Sl,"omitBy");var xi=Sl,jm=a(t=>{let e=t.checks;return e.length===0?"":e.map(Km).join("")},"generateStringChecks"),Km=a(t=>{switch(t.kind){case"min":return`.min(${b(t.value)}, ${b(t.message)})`;case"max":return`.max(${b(t.value)}, ${b(t.message)})`;case"length":return`.length(${b(t.value)}, ${b(t.message)})`;case"email":return`.email(${b(t.message)})`;case"url":return`.url(${b(t.message)})`;case"emoji":return`.emoji(${b(t.message)})`;case"uuid":return`.uuid(${b(t.message)})`;case"cuid":return`.cuid(${b(t.message)})`;case"cuid2":return`.cuid2(${b(t.message)})`;case"ulid":return`.ulid(${b(t.message)})`;case"includes":let e=nt({message:t.message,position:t.position});return`.includes(${b(t.value)}, ${e})`;case"startsWith":return`.startsWith(${b(t.value)}, ${b(t.message)})`;case"endsWith":return`.endsWith(${b(t.value)}, ${b(t.message)})`;case"regex":return`.regex(${String(t.regex)}, ${b(t.message)})`;case"trim":return".trim()";case"toLowerCase":return".toLowerCase()";case"toUpperCase":return".toUpperCase()";case"datetime":let n=t.precision===null?void 0:t.precision;return`.datetime(${nt({message:t.message,precision:n,offset:t.offset})})`;case"ip":return`.ip(${nt({message:t.message,version:t.version})})`;default:return""}},"_generateStringCheck"),Um=a(t=>{let e=t.checks;return e.length===0?"":e.map(zm).join("")},"generateNumberChecks"),zm=a(t=>{switch(t.kind){case"min":return`.min(${b(t.value)}, ${b(t.message)})`;case"max":return`.max(${b(t.value)}, ${b(t.message)})`;case"int":return`.int(${b(t.message)})`;case"multipleOf":return`.multipleOf(${b(t.value)}, ${b(t.message)})`;case"finite":return`.finite(${b(t.message)})`;default:return""}},"_generateNumberCheck"),Fm=a(t=>{let e=t.checks;return e.length===0?"":e.map(Wm).join("")},"generateBigIntChecks"),Wm=a(t=>{switch(t.kind){case"min":return`.min(${b(t.value)}, ${b(t.message)})`;case"max":return`.max(${b(t.value)}, ${b(t.message)})`;case"multipleOf":return`.multipleOf(${b(t.value)}, ${b(t.message)})`;default:return""}},"_generateBigIntCheck"),Lm=a(t=>{let e=t.checks;return e.length===0?"":e.map(qm).join("")},"generateDateChecks"),qm=a(t=>{switch(t.kind){case"min":return`.min(${ki(t.value)}, ${b(t.message)})`;case"max":return`.max(${ki(t.value)}, ${b(t.message)})`;default:return""}},"_generateDateCheck"),ki=a(t=>`new Date(${t})`,"dateTs"),Vm=a(t=>{let e=[];if(t.exactLength){let{value:r,message:n}=t.exactLength;e.push(`.length(${b(r)}, ${b(n)})`)}if(t.minLength){let{value:r,message:n}=t.minLength;e.push(`.min(${b(r)}, ${b(n)})`)}if(t.maxLength){let{value:r,message:n}=t.maxLength;e.push(`.max(${b(r)}, ${b(n)})`)}return e.join("")},"generateArrayChecks"),Gm=a(t=>{let e=[];if(t.minSize){let{value:r,message:n}=t.minSize;e.push(`.min(${b(r)}, ${b(n)})`)}if(t.maxSize){let{value:r,message:n}=t.maxSize;e.push(`.max(${b(r)}, ${b(n)})`)}return e.join("")},"generateSetChecks");function cs(t){return M(t)}a(cs,"toTypescriptSchema");function M(t){let r=t._def;switch(r.typeName){case p.ZodFirstPartyTypeKind.ZodString:return`z.string()${jm(r)}${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodNumber:return`z.number()${Um(r)}${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodNaN:return`z.nan()${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodBigInt:return`z.bigint()${Fm(r)}${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodBoolean:return`z.boolean()${C(r)}${R(t._def)}`.trim();case p.ZodFirstPartyTypeKind.ZodDate:return`z.date()${Lm(r)}${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodUndefined:return`z.undefined()${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodNull:return`z.null()${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodAny:return`z.any()${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodUnknown:return`z.unknown()${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodNever:return`z.never()${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodVoid:return`z.void()${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodArray:return`z.array(${M(r.type)})${Vm(r)}${C(r)}${R(r)}`;case p.ZodFirstPartyTypeKind.ZodObject:let n=Cm(r.shape(),M),s=t.additionalProperties(),i=s?`.catchall(${M(s)})`:"";return["z.object({",...Object.entries(n).map(([_u,Tu])=>` ${_u}: ${Tu},`),`})${i}${C(r)}${R(r)}`].join(`
16
+ `).trim();case p.ZodFirstPartyTypeKind.ZodUnion:return`z.union([${r.options.map(M).join(", ")}])${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:let l=r.options.map(M);return`z.discriminatedUnion(${b(r.discriminator)}, [${l.join(", ")}])${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodIntersection:let u=M(r.left),g=M(r.right);return`z.intersection(${u}, ${g})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodTuple:return`z.tuple([${r.items.map(M).join(", ")}])${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodRecord:let T=M(r.keyType),Z=M(r.valueType);return`z.record(${T}, ${Z})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodMap:let k=M(r.keyType),K=M(r.valueType);return`z.map(${k}, ${K})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodSet:return`z.set(${M(r.valueType)})${Gm(r)}${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodFunction:let F=r.args.items.map(M),Q=F.length?`.args(${F.join(", ")})`:"",ie=M(r.returns);return`z.function()${Q}.returns(${ie})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodLazy:return`z.lazy(() => ${M(r.getter())})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodLiteral:return`z.literal(${b(r.value)})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodEnum:return`z.enum([${r.values.map(b).join(", ")}])${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodEffects:throw new Be(p.ZodFirstPartyTypeKind.ZodEffects);case p.ZodFirstPartyTypeKind.ZodNativeEnum:throw new Be(p.ZodFirstPartyTypeKind.ZodNativeEnum);case p.ZodFirstPartyTypeKind.ZodOptional:return`z.optional(${M(r.innerType)})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodNullable:return`z.nullable(${M(r.innerType)})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodDefault:let ee=nt(r.defaultValue());return`z.default(${M(r.innerType)}, ${ee})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodCatch:throw new Be(p.ZodFirstPartyTypeKind.ZodCatch);case p.ZodFirstPartyTypeKind.ZodPromise:return`z.promise(${M(r.type)})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodBranded:throw new Be(p.ZodFirstPartyTypeKind.ZodBranded);case p.ZodFirstPartyTypeKind.ZodPipeline:throw new Be(p.ZodFirstPartyTypeKind.ZodPipeline);case p.ZodFirstPartyTypeKind.ZodSymbol:throw new Be(p.ZodFirstPartyTypeKind.ZodSymbol);case p.ZodFirstPartyTypeKind.ZodReadonly:return`z.readonly(${M(r.innerType)})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodRef:return`z.ref(${b(r.uri)})${C(r)}${R(r)}`.trim();default:I.assertNever(r)}}a(M,"sUnwrapZod");var R=a(t=>t.description?`.describe(${b(t.description)})`:"","_maybeDescribe"),C=a(t=>`${Jm(t)}${Ym(t)}${Xm(t)}${Qm(t)}${eh(t)}${th(t)}${rh(t)}`,"_addZuiExtensions"),Jm=a(t=>{var e;return(e=t[w])!=null&&e.title?`.title(${b(t[w].title)})`:""},"_maybeTitle"),Ym=a(t=>{var e;return(e=t[w])!=null&&e.displayAs?`.displayAs(${Di({id:t[w].displayAs[0],params:t[w].displayAs[1]})})`:""},"_maybeDisplayAs"),Xm=a(t=>{var e;return(e=t[w])!=null&&e.disabled?`.disabled(${t[w].disabled})`:""},"_maybeDisabled"),Qm=a(t=>{var e;return(e=t[w])!=null&&e.hidden?`.hidden(${t[w].hidden})`:""},"_maybeHidden"),eh=a(t=>{var e;return(e=t[w])!=null&&e.placeholder?`.placeholder(${b(t[w].placeholder)})`:""},"_maybePlaceholder"),th=a(t=>{var e;return(e=t[w])!=null&&e.secret?".secret()":""},"_maybeSecret"),rh=a(t=>{var e;let r=["title","tooltip","displayAs","disabled","hidden","placeholder","secret","coerce"],n=Object.entries((e=t[w])!=null?e:{}).filter(([s])=>!r.includes(s));return n.length>0?`.metadata(${Di(Object.fromEntries(n))})`:""},"_maybeSetMetadata"),nh=a(t=>{let e={type:"number",description:t.description,"x-zui":t._def["x-zui"]};t._def[w]&&(e[w]=t._def[w]);for(let r of t._def.checks)switch(r.kind){case"min":{let n=r.inclusive?"minimum":"exclusiveMinimum",s=r.inclusive?"exclusiveMinimum":"minimum";e[n]=r.value,delete e[s];break}case"max":{let n=r.inclusive?"maximum":"exclusiveMaximum",s=r.inclusive?"exclusiveMaximum":"maximum";e[n]=r.value,delete e[s];break}case"int":e.type="integer";break;case"finite":{e.format="finite";break}case"multipleOf":e.multipleOf=r.value;break;default:}return e},"zodNumberToJsonNumber"),El="\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}",Ol="(([+-]\\d{2}(:?\\d{2})?)|Z)",sh="Z",Zl="(\\.\\d+)?",Ln="\\.\\d{",ih="}",Il=a(t=>{let e=t.precision?Ln+t.precision+ih:t.precision===0?"":Zl,r=t.offset?Ol:sh;return new RegExp(`^${El}${e}${r}$`)},"generateDatetimeRegex"),ah=a(t=>({precision:oh(t),offset:t.endsWith(`${Ol}$`)}),"extractPrecisionAndOffset"),oh=a(t=>{let e=t.slice(1+El.length);return e.startsWith(Zl)?null:e.startsWith(Ln)?parseInt(e.slice(Ln.length)):0},"_extractPrecision"),Dt={};zr(Dt,{escapeSpecialChars:()=>lh});var lh=a(t=>t.replaceAll(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeSpecialChars");function ds(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage=f(c({},t.errorMessage),{[e]:r}))}a(ds,"addErrorMessage");function D(t,e,r,n,s){t[e]=r,ds(t,e,n,s)}a(D,"setResponseValueAndErrors");var j={cuid:"^[cC][^\\s-]{8,}$",cuid2:"^[a-z][a-z0-9]*$",ulid:"^[0-9A-HJKMNP-TV-Z]{26}$",email:"^(?!\\.)(?!.*\\.\\.)([a-zA-Z0-9_+-\\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\\-]*\\.)+[a-zA-Z]{2,}$",emoji:"^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",uuid:"^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$",ipv4:"^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$",ipv6:"^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$"};function us(t,e){let r=c({type:"string"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{});function n(s){return e.patternStrategy==="escape"?Dt.escapeSpecialChars(s):s}if(a(n,"processPattern"),t.checks)for(let s of t.checks)switch(s.kind){case"min":D(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,s.value):s.value,s.message,e);break;case"max":D(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,s.value):s.value,s.message,e);break;case"email":switch(e.emailStrategy){case"format:email":Ie(r,"email",s.message,e);break;case"format:idn-email":Ie(r,"idn-email",s.message,e);break;case"pattern:zod":ge(r,j.email,s.message,e);break}break;case"url":Ie(r,"uri",s.message,e);break;case"uuid":Ie(r,"uuid",s.message,e);break;case"regex":ge(r,s.regex.source,s.message,e);break;case"cuid":ge(r,j.cuid,s.message,e);break;case"cuid2":ge(r,j.cuid2,s.message,e);break;case"startsWith":ge(r,"^"+n(s.value),s.message,e);break;case"endsWith":ge(r,n(s.value)+"$",s.message,e);break;case"datetime":Ie(r,"date-time",s.message,e);break;case"length":D(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,s.value):s.value,s.message,e),D(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,s.value):s.value,s.message,e);break;case"includes":{ge(r,n(s.value),s.message,e);break}case"ip":{s.version!=="v6"&&Ie(r,"ipv4",s.message,e),s.version!=="v4"&&Ie(r,"ipv6",s.message,e);break}case"emoji":ge(r,j.emoji,s.message,e);break;case"ulid":{ge(r,j.ulid,s.message,e);break}case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}a(us,"parseStringDef");var Ie=a((t,e,r,n)=>{var s;t.format||(s=t.anyOf)!=null&&s.some(i=>i.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push(c({format:t.format},t.errorMessage&&n.errorMessages&&{errorMessage:{format:t.errorMessage.format}})),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push(c({format:e},r&&n.errorMessages&&{errorMessage:{format:r}}))):D(t,"format",e,r,n)},"addFormat"),ge=a((t,e,r,n)=>{var s;t.pattern||(s=t.allOf)!=null&&s.some(i=>i.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push(c({pattern:t.pattern},t.errorMessage&&n.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}})),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push(c({pattern:e},r&&n.errorMessages&&{errorMessage:{pattern:r}}))):D(t,"pattern",e,r,n)},"addPattern"),ch=a(t=>{let e={type:"string",description:t.description,"x-zui":t._def["x-zui"]};t._def[w]&&(e[w]=t._def[w]);for(let r of t._def.checks)switch(r.kind){case"cuid":e.format="cuid",e.pattern=j.cuid;break;case"cuid2":e.format="cuid2",e.pattern=j.cuid2;break;case"ulid":e.format="ulid",e.pattern=j.ulid;break;case"uuid":e.format="uuid",e.pattern=j.uuid;break;case"emoji":e.format="emoji",e.pattern=j.emoji;break;case"email":e.format="email",e.pattern=j.email;break;case"ip":e.format=r.version==="v6"?"ipv6":"ipv4",e.pattern=r.version==="v6"?j.ipv6:j.ipv4;break;case"datetime":e.format="date-time",e.pattern=Il(r).source,e[w]=f(c({},e[w]),{precision:r.precision,offset:r.offset});break;case"url":e.format="uri";break;case"endsWith":e.pattern=`${Dt.escapeSpecialChars(r.value)}$`;break;case"startsWith":e.pattern=`^${Dt.escapeSpecialChars(r.value)}`;break;case"includes":let n=r.position&&r.position>=1?`^(?:.{${r.position}}).*`:"";e.pattern=`${n}${Dt.escapeSpecialChars(r.value)}`;break;case"regex":e.pattern=r.regex.source;break;case"length":e.minLength=e.maxLength=Math.max(0,r.value);break;case"min":e.minLength=Math.max(0,r.value);break;case"max":e.maxLength=Math.max(0,r.value);break;default:throw new Wi({zodType:p.ZodFirstPartyTypeKind.ZodString,checkKind:r.kind})}return e},"zodStringToJsonString"),dh=a((t,e)=>{let r={type:"array",description:t.description,items:e(t._def.type),"x-zui":t._def["x-zui"]};return t._def[w]&&(r[w]=t._def[w]),t._def.minLength&&(r.minItems=t._def.minLength.value),t._def.maxLength&&(r.maxItems=t._def.maxLength.value),t._def.exactLength&&(r.minItems=t._def.exactLength.value,r.maxItems=t._def.exactLength.value),r},"zodArrayToJsonArray"),uh=a((t,e)=>{let r={type:"array",description:t.description,uniqueItems:!0,items:e(t._def.valueType),"x-zui":t._def["x-zui"]};return t._def[w]&&(r[w]=t._def[w]),t._def.minSize&&(r.minItems=t._def.minSize.value),t._def.maxSize&&(r.maxItems=t._def.maxSize.value),r},"zodSetToJsonSet"),ph=a((t,e)=>{let r={type:"array",description:t.description,items:t._def.items.map(n=>e(n))};return t._def[w]&&(r[w]=t._def[w]),t._def.rest&&(r.additionalItems=e(t._def.rest)),r},"zodTupleToJsonTuple");function q(t){let e=t,r=e._def;switch(r.typeName){case p.ZodFirstPartyTypeKind.ZodString:return ch(e);case p.ZodFirstPartyTypeKind.ZodNumber:return nh(e);case p.ZodFirstPartyTypeKind.ZodNaN:throw new te(p.ZodFirstPartyTypeKind.ZodNaN);case p.ZodFirstPartyTypeKind.ZodBigInt:throw new te(p.ZodFirstPartyTypeKind.ZodBigInt,{suggestedAlternative:"serialize bigint to string"});case p.ZodFirstPartyTypeKind.ZodBoolean:return{type:"boolean",description:r.description,"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodDate:throw new te(p.ZodFirstPartyTypeKind.ZodDate,{suggestedAlternative:"use z.string().datetime() instead"});case p.ZodFirstPartyTypeKind.ZodUndefined:return Dn(r);case p.ZodFirstPartyTypeKind.ZodNull:return Hn(r);case p.ZodFirstPartyTypeKind.ZodAny:return{description:r.description,"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodUnknown:return{description:r.description,"x-zui":f(c({},r["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodUnknown}})};case p.ZodFirstPartyTypeKind.ZodNever:return{not:!0,description:r.description,"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodVoid:throw new te(p.ZodFirstPartyTypeKind.ZodVoid);case p.ZodFirstPartyTypeKind.ZodArray:return dh(e,q);case p.ZodFirstPartyTypeKind.ZodObject:let n=Object.entries(r.shape()),s=n.filter(([g,h])=>!h.isOptional()),i=s.length?s.map(([g])=>g):void 0,o=n.map(([g,h])=>[g,h.mandatory()]).map(([g,h])=>[g,q(h)]),l=!1;return r.unknownKeys instanceof p.ZodType?l=q(r.unknownKeys):r.unknownKeys==="passthrough"&&(l=!0),{type:"object",description:r.description,properties:Object.fromEntries(o),required:i,additionalProperties:l,"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodUnion:return{description:r.description,anyOf:r.options.map(g=>q(g)),"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:return{description:r.description,anyOf:r.options.map(g=>q(g)),"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodIntersection:let d=q(r.left),u=q(r.right);return"additionalProperties"in d&&delete d.additionalProperties,"additionalProperties"in u&&delete u.additionalProperties,{description:r.description,allOf:[d,u],"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodTuple:return ph(e,q);case p.ZodFirstPartyTypeKind.ZodRecord:return{type:"object",description:r.description,additionalProperties:q(r.valueType),"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodMap:throw new te(p.ZodFirstPartyTypeKind.ZodMap);case p.ZodFirstPartyTypeKind.ZodSet:return uh(e,q);case p.ZodFirstPartyTypeKind.ZodFunction:throw new te(p.ZodFirstPartyTypeKind.ZodFunction);case p.ZodFirstPartyTypeKind.ZodLazy:throw new te(p.ZodFirstPartyTypeKind.ZodLazy);case p.ZodFirstPartyTypeKind.ZodLiteral:if(typeof r.value=="string")return{type:"string",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(typeof r.value=="number")return{type:"number",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(typeof r.value=="boolean")return{type:"boolean",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(r.value===null)return Hn(r);if(r.value===void 0)return Dn(r);{p.util.assertEqual(!0);let g=typeof r.value;throw new Wr(`Unsupported literal type: "${g}"`)}case p.ZodFirstPartyTypeKind.ZodEnum:return{type:"string",description:r.description,enum:r.values,"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodEffects:throw new te(p.ZodFirstPartyTypeKind.ZodEffects);case p.ZodFirstPartyTypeKind.ZodNativeEnum:throw new te(p.ZodFirstPartyTypeKind.ZodNativeEnum);case p.ZodFirstPartyTypeKind.ZodOptional:return{description:r.description,anyOf:[q(r.innerType),Dn()],"x-zui":f(c({},r["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodOptional}})};case p.ZodFirstPartyTypeKind.ZodNullable:return{anyOf:[q(r.innerType),Hn()],"x-zui":f(c({},r["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodNullable}})};case p.ZodFirstPartyTypeKind.ZodDefault:return f(c({},q(r.innerType)),{default:r.defaultValue()});case p.ZodFirstPartyTypeKind.ZodCatch:throw new te(p.ZodFirstPartyTypeKind.ZodCatch);case p.ZodFirstPartyTypeKind.ZodPromise:throw new te(p.ZodFirstPartyTypeKind.ZodPromise);case p.ZodFirstPartyTypeKind.ZodBranded:throw new te(p.ZodFirstPartyTypeKind.ZodBranded);case p.ZodFirstPartyTypeKind.ZodPipeline:throw new te(p.ZodFirstPartyTypeKind.ZodPipeline);case p.ZodFirstPartyTypeKind.ZodSymbol:throw new te(p.ZodFirstPartyTypeKind.ZodPipeline);case p.ZodFirstPartyTypeKind.ZodReadonly:return f(c({},q(r.innerType)),{readOnly:!0});case p.ZodFirstPartyTypeKind.ZodRef:return{$ref:r.uri,description:r.description,"x-zui":r["x-zui"]};default:p.util.assertNever(r)}}a(q,"toJSONSchema");var Dn=a(t=>({not:!0,description:t?.description,"x-zui":f(c({},t?.["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodUndefined}})}),"undefinedSchema"),Hn=a(t=>({type:"null",description:t?.description,"x-zui":t?.["x-zui"]}),"nullSchema"),Bl=class{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};a(Bl,"ParseInputLazyPath");var oe=Bl,Si=a((t,e)=>{if(lt(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new pe(t.common.issues);return this._error=r,this._error}}},"handleResult"),Al=class{constructor(e){this.__type__="ZuiType",this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._metadataRoot._def.description}dereference(e){return this}getReferences(){return[]}clone(){let e=this.constructor;return new e(c({},this._def))}_getType(e){return he(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:he(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new re,ctx:{common:e.parent.common,data:e.data,parsedType:he(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(jt(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){var n;let s={common:{issues:[],async:(n=r?.async)!=null?n:!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:he(e)},i=this._parseSync({data:e,path:s.path,parent:s});return Si(s,i)}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:he(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(jt(s)?s:Promise.resolve(s));return Si(n,i)}refine(e,r){let n=a(s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r,"getIssueProperties");return this._refinement((s,i)=>{let o=e(s),l=a(()=>i.addIssue(c({code:m.custom},n(s))),"setError");return typeof Promise<"u"&&o instanceof Promise?o.then(d=>d?!0:(l(),!1)):o?!0:(l(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new Se({schema:this,typeName:"ZodEffects",effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ye.create(this,this._def)}nullable(){return $e.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return dt.create(this,this._def)}promise(){return Wt.create(this,this._def)}mandatory(){return this}or(e){return fn.create([this,e],this._def)}and(e){return an.create(this,e,this._def)}transform(e){return new Se(f(c({},S(this._def)),{schema:this,typeName:"ZodEffects",effect:{type:"transform",transform:e}}))}default(e){let r=typeof e=="function"?e:()=>e;return new zt(f(c({},S(this._def)),{innerType:this,defaultValue:r,typeName:"ZodDefault"}))}brand(){return new rn(c({typeName:"ZodBranded",type:this},S(this._def)))}catch(e){let r=typeof e=="function"?e:()=>e;return new nn(f(c({},S(this._def)),{innerType:this,catchValue:r,typeName:"ZodCatch"}))}describe(e){let r=this.clone();return r._metadataRoot._def.description=e,r}pipe(e){return pn.create(this,e)}readonly(){return Lt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}metadata(e){var r,n,s;let i=this.clone(),o=i._metadataRoot;(s=(r=o._def)[n=w])!=null||(r[n]={});for(let[l,d]of Object.entries(e))o._def[w]=f(c({},o._def[w]),{[l]:d});return i}getMetadata(){return c({},this._metadataRoot._def[w])}setMetadata(e){this._metadataRoot._def[w]=c({},e)}get ui(){return c({},this._metadataRoot._def[w])}get _metadataRoot(){return this.naked()}displayAs(e){return this.metadata({displayAs:[e.id,e.params]})}title(e){return this.metadata({title:e})}hidden(e){let r;return e===void 0?r=!0:typeof e=="function"?r=e.toString():r=e,this.metadata({hidden:r})}disabled(e){let r;return e===void 0?r=!0:typeof e=="function"?r=e.toString():r=e,this.metadata({disabled:r})}placeholder(e){return this.metadata({placeholder:e})}toJSONSchema(){return q(this)}toTypescriptType(e){return Xn(this,e)}toTypescriptSchema(){return cs(this)}naked(){return this}};a(Al,"ZodType");var O=Al,ps=(t=>(t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodRef="ZodRef",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly",t))(ps||{}),I;(t=>{t.assertEqual=a(s=>s,"assertEqual");function e(s){}t.assertIs=e,a(e,"assertIs");function r(s){throw new Error("assertNever called")}t.assertNever=r,a(r,"assertNever"),t.arrayToEnum=a(s=>{let i={};for(let o of s)i[o]=o;return i},"arrayToEnum"),t.getValidEnumValues=a(s=>{let i=(0,t.objectKeys)(s).filter(l=>typeof s[s[l]]!="number"),o={};for(let l of i)o[l]=s[l];return(0,t.objectValues)(o)},"getValidEnumValues"),t.objectValues=a(s=>(0,t.objectKeys)(s).map(function(i){return s[i]}),"objectValues"),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=a((s,i)=>{for(let o of s)if(i(o))return o},"find"),t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=n,a(n,"joinValues"),t.jsonStringifyReplacer=a((s,i)=>typeof i=="bigint"?i.toString():i,"jsonStringifyReplacer"),t.compareFunctions=a((s,i)=>s.toString()===i.toString(),"compareFunctions"),t.mock=a(()=>({}),"mock")})(I||(I={}));var lr;(t=>{t.mergeShapes=a((e,r)=>c(c({},e),r),"mergeShapes")})(lr||(lr={}));var _=I.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),he=a(t=>{switch(typeof t){case"undefined":return _.undefined;case"string":return _.string;case"number":return isNaN(t)?_.nan:_.number;case"boolean":return _.boolean;case"function":return _.function;case"bigint":return _.bigint;case"symbol":return _.symbol;case"object":return Array.isArray(t)?_.array:t===null?_.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?_.promise:typeof Map<"u"&&t instanceof Map?_.map:typeof Set<"u"&&t instanceof Set?_.set:typeof Date<"u"&&t instanceof Date?_.date:_.object;default:return _.unknown}},"getParsedType");function S(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s,supportsExtensions:i,[w]:o}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);let l=o?Object.fromEntries(Object.entries(o).filter(([u])=>u!=="secret"||i?.includes("secret"))):void 0;return e?{errorMap:e,description:s,[w]:l}:{errorMap:a((u,g)=>u.code!=="invalid_type"?{message:g.defaultError}:typeof g.data>"u"?{message:n??g.defaultError}:{message:r??g.defaultError},"customMap"),description:s,[w]:l}}a(S,"processCreateParams");var fs=a((t,e)=>{let r;switch(t.code){case m.invalid_type:t.received===_.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case m.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,I.jsonStringifyReplacer)}`;break;case m.unrecognized_keys:r=`Unrecognized key(s) in object: ${I.joinValues(t.keys,", ")}`;break;case m.invalid_union:r="Invalid input";break;case m.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${I.joinValues(t.options)}`;break;case m.invalid_enum_value:r=`Invalid enum value. Expected ${I.joinValues(t.options)}, received '${t.received}'`;break;case m.invalid_arguments:r="Invalid function arguments";break;case m.invalid_return_type:r="Invalid function return type";break;case m.invalid_date:r="Invalid date";break;case m.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:I.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case m.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case m.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case m.custom:r="Invalid input";break;case m.invalid_intersection_types:r="Intersection results could not be merged";break;case m.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case m.not_finite:r="Number must be finite";break;case m.unresolved_reference:r="Unresolved reference";break;default:r=e.defaultError,I.assertNever(t)}return{message:r}},"errorMap"),Ei=fs,m=I.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite","unresolved_reference"]),Rl=a(t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),cr=class Cl extends Error{constructor(e){super(),this.issues=[],this.addIssue=a(n=>{this.issues=[...this.issues,n]},"addIssue"),this.addIssues=a((n=[])=>{this.issues=[...this.issues,...n]},"addIssues");let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let r=e||function(i){return i.message},n={_errors:[]},s=a(i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)n._errors.push(r(o));else{let l=n,d=0;for(;d<o.path.length;){let u=o.path[d];d===o.path.length-1?(l[u]=l[u]||{_errors:[]},l[u]._errors.push(r(o))):l[u]=l[u]||{_errors:[]},l=l[u],d++}}},"processError");return s(this),n}static assert(e){if(!(e instanceof Cl))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,I.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};a(cr,"ZodError");cr.create=a(t=>new cr(t),"create");var pe=cr,Dl=fs;function gs(t){Dl=t}a(gs,"setErrorMap");function ot(){return Dl}a(ot,"getErrorMap");var $t=a(t=>{var e;let{data:r,path:n,errorMaps:s,issueData:i}=t,o=[...n,...i.path||[]],l=f(c({},i),{path:o}),d="",u=s.filter(g=>!!g).slice().reverse();for(let g of u)d=g(l,{data:r,defaultError:d}).message;return f(c({},i),{path:o,message:(e=i.message)!=null?e:d})},"makeIssue"),Hl=[];function v(t,e){let r=$t({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ot(),fs].filter(n=>!!n)});t.common.issues.push(r)}a(v,"addIssueToContext");var Nl=class Ml{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let s of r){if(s.status==="aborted")return x;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let s of r)n.push({key:await s.key,value:await s.value});return Ml.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return x;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(n[i.value]=o.value)}return{status:e.value,value:n}}};a(Nl,"ParseStatus");var re=Nl,x=Object.freeze({status:"aborted"}),Ne=a(t=>({status:"dirty",value:t}),"DIRTY"),G=a(t=>({status:"valid",value:t}),"OK"),dr=a(t=>t.status==="aborted","isAborted"),ur=a(t=>t.status==="dirty","isDirty"),lt=a(t=>t.status==="valid","isValid"),jt=a(t=>typeof Promise<"u"&&t instanceof Promise,"isAsync"),P;(t=>{t.errToObj=a(e=>typeof e=="string"?{message:e}:e||{},"errToObj"),t.toString=a(e=>typeof e=="string"?e:e?.message,"toString")})(P||(P={}));var pr=class $l extends O{constructor(){super(...arguments),this._any=!0}_parse(e){return G(e.data)}isEqual(e){return e instanceof $l}};a(pr,"ZodAny");pr.create=a(t=>new pr(c({typeName:"ZodAny"},S(t))),"create");var ct=pr,fr=class Re extends O{dereference(e){return new Re(f(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new Re(f(c({},this._def),{type:this._def.type.clone()}))}isEqual(e){var r,n,s,i,o,l;return e instanceof Re?st((r=this._def.exactLength)==null?void 0:r.value,(n=e._def.exactLength)==null?void 0:n.value)&&st((s=this._def.maxLength)==null?void 0:s.value,(i=e._def.maxLength)==null?void 0:i.value)&&st((o=this._def.minLength)==null?void 0:o.value,(l=e._def.minLength)==null?void 0:l.value)&&this._def.type.isEqual(e._def.type):!1}_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==_.array)return v(r,{code:m.invalid_type,expected:_.array,received:r.parsedType}),x;if(s.exactLength!==null){let o=r.data.length>s.exactLength.value,l=r.data.length<s.exactLength.value;(o||l)&&(v(r,{code:o?m.too_big:m.too_small,minimum:l?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(v(r,{code:m.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(v(r,{code:m.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((o,l)=>s.type._parseAsync(new oe(r,o,r.path,l)))).then(o=>re.mergeArray(n,o));let i=[...r.data].map((o,l)=>s.type._parseSync(new oe(r,o,r.path,l)));return re.mergeArray(n,i)}get element(){return this._def.type}min(e,r){return new Re(f(c({},this._def),{minLength:{value:e,message:P.toString(r)}}))}max(e,r){return new Re(f(c({},this._def),{maxLength:{value:e,message:P.toString(r)}}))}length(e,r){return new Re(f(c({},this._def),{exactLength:{value:e,message:P.toString(r)}}))}nonempty(e){return this.min(1,e)}};a(fr,"ZodArray");fr.create=a((t,e)=>new fr(c({type:t,minLength:null,maxLength:null,exactLength:null,typeName:"ZodArray"},S(e))),"create");var dt=fr,fh=a((t,e)=>jl(t,e,new WeakSet),"isEqual"),jl=a((t,e,r)=>Rm(t,e,gh(r)),"_isEqualWithVisitedTracking"),gh=a(t=>(e,r)=>{if(ci(e)&&!t.has(e)&&ci(r)&&!t.has(r)){let n=xi(e,Pi),s=xi(r,Pi);return t.add(n).add(s).add(e).add(r),jl(n,s,t)}},"_customizerWithVisitedTracking"),mh={compare:fh},Kl=class{constructor(e=[],r={}){this._options=c(c({},mh),r),this._items=[];for(let n of e)this.add(n)}get items(){return[...this._items]}get size(){return this._items.length}has(e){return this._items.some(r=>this._options.compare(r,e))}add(e){this.has(e)||this._items.push(e)}isEqual(e){return this.size!==e.size?!1:this.isSubsetOf(e)&&e.isSubsetOf(this)}isSubsetOf(e){return this.size>e.size?!1:this._items.every(r=>e.has(r))}};a(Kl,"CustomSet");var U=Kl,gr=class er extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==_.bigint){let i=this._getOrReturnCtx(e);return v(i,{code:m.invalid_type,expected:_.bigint,received:i.parsedType}),x}let n,s=new re;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:m.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:m.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),v(n,{code:m.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):I.assertNever(i);return{status:s.value,value:e.data}}isEqual(e){if(!(e instanceof er)||this._def.coerce!==e._def.coerce)return!1;let r=new U(this._def.checks),n=new U(e._def.checks);return r.isEqual(n)}gte(e,r){return this.setLimit("min",e,!0,P.toString(r))}gt(e,r){return this.setLimit("min",e,!1,P.toString(r))}lte(e,r){return this.setLimit("max",e,!0,P.toString(r))}lt(e,r){return this.setLimit("max",e,!1,P.toString(r))}setLimit(e,r,n,s){return new er(f(c({},this._def),{checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:P.toString(s)}]}))}_addCheck(e){return new er(f(c({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:P.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:P.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:P.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:P.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:P.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};a(gr,"ZodBigInt");gr.create=a(t=>{var e;return new gr(c({checks:[],typeName:"ZodBigInt",coerce:(e=t?.coerce)!=null?e:!1},S(t)))},"create");var en=gr,mr=class Ul extends O{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==_.boolean){let n=this._getOrReturnCtx(e);return v(n,{code:m.invalid_type,expected:_.boolean,received:n.parsedType}),x}return G(e.data)}isEqual(e){return e instanceof Ul?this._def.coerce===e._def.coerce:!1}};a(mr,"ZodBoolean");mr.create=a(t=>new mr(c({typeName:"ZodBoolean",coerce:t?.coerce||!1},S(t))),"create");var tn=mr,zl=Symbol("zod_brand"),Fl=class bt extends O{dereference(e){return new bt(f(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new bt(f(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}isEqual(e){return e instanceof bt?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}mandatory(){return new bt(f(c({},this._def),{type:this._def.type.mandatory()}))}};a(Fl,"ZodBranded");var rn=Fl,hr=class wt extends O{_parse(e){let{ctx:r}=this._processInputParams(e),n=f(c({},r),{common:f(c({},r.common),{issues:[]})}),s=this._def.innerType._parse({data:n.data,path:n.path,parent:c({},n)});return jt(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new pe(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new pe(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}isEqual(e){return e instanceof wt?this._def.innerType.isEqual(e._def.innerType)&&I.compareFunctions(this._def.catchValue,e._def.catchValue):!1}dereference(e){return new wt(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new wt(f(c({},this._def),{innerType:this._def.innerType.clone()}))}naked(){return this._def.innerType.naked()}mandatory(){return new wt(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(hr,"ZodCatch");hr.create=a((t,e)=>new hr(c({innerType:t,typeName:"ZodCatch",catchValue:typeof e.catch=="function"?e.catch:()=>e.catch},S(e))),"create");var nn=hr,ms=a((t,e={},r)=>t?ct.create().superRefine((n,s)=>{var i,o;if(!t(n)){let l=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,d=(o=(i=l.fatal)!=null?i:r)!=null?o:!0,u=typeof l=="string"?{message:l}:l;s.addIssue(f(c({code:"custom"},u),{fatal:d}))}}):ct.create(),"custom"),yr=class qn extends O{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==_.date){let i=this._getOrReturnCtx(e);return v(i,{code:m.invalid_type,expected:_.date,received:i.parsedType}),x}if(isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return v(i,{code:m.invalid_date}),x}let n=new re,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:m.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:m.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):I.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new qn(f(c({},this._def),{checks:[...this._def.checks,e]}))}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:P.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:P.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}isEqual(e){if(!(e instanceof qn))return!1;let r=new U(this._def.checks),n=new U(e._def.checks);return r.isEqual(n)&&this._def.coerce===e._def.coerce}};a(yr,"ZodDate");yr.create=a(t=>new yr(c({checks:[],coerce:t?.coerce||!1,typeName:"ZodDate"},S(t))),"create");var sn=yr,vr=class Pt extends O{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===_.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}dereference(e){return new Pt(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new Pt(f(c({},this._def),{innerType:this._def.innerType.clone()}))}isEqual(e){return e instanceof Pt?this._def.innerType.isEqual(e._def.innerType)&&st(this._def.defaultValue(),e._def.defaultValue()):!1}unwrap(){return this._def.innerType}naked(){return this._def.innerType.naked()}mandatory(){return new Pt(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(vr,"ZodDefault");vr.create=a((t,e,r)=>new vr(c({innerType:t,typeName:"ZodDefault",defaultValue:typeof e=="function"?e:()=>e},S(r))),"create");var zt=vr,Te=a(t=>Array.from(new Set(t)),"unique"),me=a(t=>t instanceof on?me(t.schema):t instanceof Se?me(t.innerType()):t instanceof ln?[t.value]:t instanceof Ge?t.options:t instanceof cn?I.objectValues(t.enum):t instanceof zt?me(t._def.innerType):t instanceof qt?[void 0]:t instanceof dn?[null]:t instanceof ye?[void 0,...me(t.unwrap())]:t instanceof $e?[null,...me(t.unwrap())]:t instanceof rn||t instanceof Lt?me(t.unwrap()):t instanceof nn?me(t._def.innerType):[],"getDiscriminator"),Wl=class Ce extends O{dereference(e){let r=this.options.map(s=>s.dereference(e)),n=Ce._getOptionsMap(this.discriminator,r);return new Ce(f(c({},this._def),{options:r,optionsMap:n}))}getReferences(){return Te(this.options.flatMap(e=>e.getReferences()))}clone(){let e=this.options.map(r=>r.clone());return new Ce(f(c({},this._def),{options:e}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==_.object)return v(r,{code:m.invalid_type,expected:_.object,received:r.parsedType}),x;let n=this.discriminator,s=r.data[n],i=this.optionsMap.get(s);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(v(r,{code:m.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),x)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let s=Ce._getOptionsMap(e,r);return new Ce(c({typeName:"ZodDiscriminatedUnion",discriminator:e,options:r,optionsMap:s},S(n)))}static _getOptionsMap(e,r){let n=new Map;for(let s of r){let i=me(s.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of i){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,s)}}return n}isEqual(e){if(!(e instanceof Ce)||this._def.discriminator!==e._def.discriminator)return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new U(this._def.options,{compare:r}),s=new U(e._def.options,{compare:r});return n.isEqual(s)}};a(Wl,"ZodDiscriminatedUnion");var hs=Wl;function Ft(t,e){return new Ge(c({values:t,typeName:"ZodEnum"},S(e)))}a(Ft,"createZodEnum");var ys=class tr extends O{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return v(r,{expected:I.joinValues(n),received:r.parsedType,code:m.invalid_type}),x}if(this._def.values.indexOf(e.data)===-1){let r=this._getOrReturnCtx(e),n=this._def.values;return v(r,{received:r.data,code:m.invalid_enum_value,options:n}),x}return G(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return tr.create(e,c(c({},this._def),r))}exclude(e,r=this._def){return tr.create(this.options.filter(n=>!e.includes(n)),c(c({},this._def),r))}isEqual(e){if(!(e instanceof tr))return!1;let r=new U(this._def.values),n=new U(e._def.values);return r.isEqual(n)}};a(ys,"ZodEnum");ys.create=Ft;var Ge=ys,Ll=class De extends O{constructor(){super(...arguments),this.validate=this.implement}dereference(e){let r=this._def.args.dereference(e),n=this._def.returns.dereference(e);return new De(f(c({},this._def),{args:r,returns:n}))}getReferences(){return Te([...this._def.args.getReferences(),...this._def.returns.getReferences()])}clone(){return new De(f(c({},this._def),{args:this._def.args.clone(),returns:this._def.returns.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==_.function)return v(r,{code:m.invalid_type,expected:_.function,received:r.parsedType}),x;function n(l,d){return $t({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ot(),Ei].filter(u=>!!u),issueData:{code:m.invalid_arguments,argumentsError:d}})}a(n,"makeArgsIssue");function s(l,d){return $t({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ot(),Ei].filter(u=>!!u),issueData:{code:m.invalid_return_type,returnTypeError:d}})}a(s,"makeReturnsIssue");let i={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof Wt){let l=this;return G(async function(...d){let u=new pe([]),g=await l._def.args.parseAsync(d,i).catch(Z=>{throw u.addIssue(n(d,Z)),u}),h=await Reflect.apply(o,this,g);return await l._def.returns._def.type.parseAsync(h,i).catch(Z=>{throw u.addIssue(s(h,Z)),u})})}else{let l=this;return G(function(...d){let u=l._def.args.safeParse(d,i);if(!u.success)throw new pe([n(d,u.error)]);let g=Reflect.apply(o,this,u.data),h=l._def.returns.safeParse(g,i);if(!h.success)throw new pe([s(g,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new De(f(c({},this._def),{args:Ke.create(e).rest(it.create())}))}returns(e){return new De(f(c({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new De(c({args:e||Ke.create([]).rest(it.create()),returns:r||it.create(),typeName:"ZodFunction"},S(n)))}isEqual(e){return e instanceof De&&this._def.args.isEqual(e._def.args)&&this._def.returns.isEqual(e._def.returns)}};a(Ll,"ZodFunction");var vs=Ll;function _r(t,e){let r=he(t),n=he(e);if(t===e)return{valid:!0,data:t};if(r===_.object&&n===_.object){let s=I.objectKeys(e),i=I.objectKeys(t).filter(l=>s.indexOf(l)!==-1),o=c(c({},t),e);for(let l of i){let d=_r(t[l],e[l]);if(!d.valid)return{valid:!1};o[l]=d.data}return{valid:!0,data:o}}else if(r===_.array&&n===_.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let o=t[i],l=e[i],d=_r(o,l);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return r===_.date&&n===_.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}a(_r,"mergeValues");var Tr=class rr extends O{dereference(e){return new rr(f(c({},this._def),{left:this._def.left.dereference(e),right:this._def.right.dereference(e)}))}getReferences(){return Te([...this._def.left.getReferences(),...this._def.right.getReferences()])}clone(){return new rr(f(c({},this._def),{left:this._def.left.clone(),right:this._def.right.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=a((i,o)=>{if(dr(i)||dr(o))return x;let l=_r(i.value,o.value);return l.valid?((ur(i)||ur(o))&&r.dirty(),{status:r.value,value:l.data}):(v(n,{code:m.invalid_intersection_types}),x)},"handleParsed");return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}isEqual(e){if(!(e instanceof rr))return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new U([this._def.left,this._def.right],{compare:r}),s=new U([e._def.left,e._def.right],{compare:r});return n.isEqual(s)}};a(Tr,"ZodIntersection");Tr.create=a((t,e,r)=>new Tr(c({left:t,right:e,typeName:"ZodIntersection"},S(r))),"create");var an=Tr,br=class xt extends O{get schema(){return this._def.getter()}dereference(e){return new xt(f(c({},this._def),{getter:a(()=>this._def.getter().dereference(e),"getter")}))}getReferences(){return this._def.getter().getReferences()}clone(){return new xt(f(c({},this._def),{getter:a(()=>this._def.getter().clone(),"getter")}))}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}isEqual(e){return e instanceof xt?this._def.getter().isEqual(e._def.getter()):!1}naked(){return this._def.getter().naked()}mandatory(){return new xt(f(c({},this._def),{getter:a(()=>this._def.getter().mandatory(),"getter")}))}};a(br,"ZodLazy");br.create=a((t,e)=>new br(c({getter:t,typeName:"ZodLazy"},S(e))),"create");var on=br,wr=class ql extends O{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return v(r,{received:r.data,code:m.invalid_literal,expected:this._def.value}),x}return{status:"valid",value:e.data}}get value(){return this._def.value}isEqual(e){return e instanceof ql?st(this._def.value,e._def.value):!1}};a(wr,"ZodLiteral");wr.create=a((t,e)=>new wr(c({value:t,typeName:"ZodLiteral"},S(e))),"create");var ln=wr,Pr=class nr extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}dereference(e){let r=this._def.keyType.dereference(e),n=this._def.valueType.dereference(e);return new nr(f(c({},this._def),{keyType:r,valueType:n}))}getReferences(){return Te([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new nr(f(c({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.map)return v(n,{code:m.invalid_type,expected:_.map,received:n.parsedType}),x;let s=this._def.keyType,i=this._def.valueType,o=[...n.data.entries()].map(([l,d],u)=>({key:s._parse(new oe(n,l,n.path,[u,"key"])),value:i._parse(new oe(n,d,n.path,[u,"value"]))}));if(n.common.async){let l=new Map;return Promise.resolve().then(async()=>{for(let d of o){let u=await d.key,g=await d.value;if(u.status==="aborted"||g.status==="aborted")return x;(u.status==="dirty"||g.status==="dirty")&&r.dirty(),l.set(u.value,g.value)}return{status:r.value,value:l}})}else{let l=new Map;for(let d of o){let u=d.key,g=d.value;if(u.status==="aborted"||g.status==="aborted")return x;(u.status==="dirty"||g.status==="dirty")&&r.dirty(),l.set(u.value,g.value)}return{status:r.value,value:l}}}isEqual(e){return!(!(e instanceof nr)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};a(Pr,"ZodMap");Pr.create=a((t,e,r)=>new Pr(c({valueType:e,keyType:t,typeName:"ZodMap"},S(r))),"create");var _s=Pr,xr=class Vl extends O{_parse(e){if(this._getType(e)!==_.nan){let n=this._getOrReturnCtx(e);return v(n,{code:m.invalid_type,expected:_.nan,received:n.parsedType}),x}return{status:"valid",value:e.data}}isEqual(e){return e instanceof Vl}};a(xr,"ZodNaN");xr.create=a(t=>new xr(c({typeName:"ZodNaN"},S(t))),"create");var Ts=xr,kr=class Gl extends O{_parse(e){let r=I.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==_.string&&n.parsedType!==_.number){let s=I.objectValues(r);return v(n,{expected:I.joinValues(s),received:n.parsedType,code:m.invalid_type}),x}if(r.indexOf(e.data)===-1){let s=I.objectValues(r);return v(n,{received:n.data,code:m.invalid_enum_value,options:s}),x}return G(e.data)}get enum(){return this._def.values}isEqual(e){return e instanceof Gl?st(this._def.values,e._def.values):!1}};a(kr,"ZodNativeEnum");kr.create=a((t,e)=>new kr(c({values:t,typeName:"ZodNativeEnum"},S(e))),"create");var cn=kr,Sr=class Jl extends O{_parse(e){let r=this._getOrReturnCtx(e);return v(r,{code:m.invalid_type,expected:_.never,received:r.parsedType}),x}isEqual(e){return e instanceof Jl}};a(Sr,"ZodNever");Sr.create=a(t=>new Sr(c({typeName:"ZodNever"},S(t))),"create");var ft=Sr,Er=class Yl extends O{_parse(e){if(this._getType(e)!==_.null){let n=this._getOrReturnCtx(e);return v(n,{code:m.invalid_type,expected:_.null,received:n.parsedType}),x}return G(e.data)}isEqual(e){return e instanceof Yl}};a(Er,"ZodNull");Er.create=a(t=>new Er(c({typeName:"ZodNull"},S(t))),"create");var dn=Er,Or=class kt extends O{dereference(e){return new kt(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new kt(f(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)===_.null?G(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof kt?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new kt(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(Or,"ZodNullable");Or.create=a((t,e)=>new Or(c({innerType:t,typeName:"ZodNullable"},S(e))),"create");var $e=Or;function Xl(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,i=parseInt(t.toFixed(s).replace(".","")),o=parseInt(e.toFixed(s).replace(".",""));return i%o/Math.pow(10,s)}a(Xl,"floatSafeRemainder");var Zr=class sr extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==_.number){let i=this._getOrReturnCtx(e);return v(i,{code:m.invalid_type,expected:_.number,received:i.parsedType}),x}let n,s=new re;for(let i of this._def.checks)i.kind==="int"?I.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{code:m.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:m.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:m.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Xl(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),v(n,{code:m.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{code:m.not_finite,message:i.message}),s.dirty()):I.assertNever(i);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,P.toString(r))}gt(e,r){return this.setLimit("min",e,!1,P.toString(r))}lte(e,r){return this.setLimit("max",e,!0,P.toString(r))}lt(e,r){return this.setLimit("max",e,!1,P.toString(r))}setLimit(e,r,n,s){return new sr(f(c({},this._def),{checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:P.toString(s)}]}))}_addCheck(e){return new sr(f(c({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:P.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:P.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:P.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:P.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:P.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:P.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:P.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:P.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:P.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&I.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}isEqual(e){if(!(e instanceof sr))return!1;let r=new U(this._def.checks),n=new U(e._def.checks);return r.isEqual(n)}};a(Zr,"ZodNumber");Zr.create=a(t=>new Zr(c({checks:[],typeName:"ZodNumber",coerce:t?.coerce||!1},S(t))),"create");var un=Zr;function He(t){if(t instanceof je){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=ye.create(He(n))}return new je(f(c({},t._def),{shape:a(()=>e,"shape")}))}else return t instanceof dt?new dt(f(c({},t._def),{type:He(t.element)})):t instanceof ye?ye.create(He(t.unwrap())):t instanceof $e?$e.create(He(t.unwrap())):t instanceof Ke?Ke.create(t.items.map(e=>He(e))):t}a(He,"deepPartialify");var ke=class se extends O{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=I.objectKeys(e);return this._cached={shape:e,keys:r}}dereference(e){let r=this._def.shape(),n={};for(let s in r)n[s]=r[s].dereference(e);return new se(f(c({},this._def),{shape:a(()=>n,"shape")}))}getReferences(){let e=this._def.shape(),r=[];for(let n in e)r.push(...e[n].getReferences());return Te(r)}clone(){let e={},r=this._def.shape();for(let[n,s]of Object.entries(r))e[n]=s.clone();return new se(f(c({},this._def),{shape:a(()=>e,"shape")}))}_parse(e){if(this._getType(e)!==_.object){let g=this._getOrReturnCtx(e);return v(g,{code:m.invalid_type,expected:_.object,received:g.parsedType}),x}let{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),l=[];if(this._def.unknownKeys!=="strip")for(let g in s.data)o.includes(g)||l.push(g);let d=[];for(let g of o){let h=i[g],T=s.data[g];d.push({key:{status:"valid",value:g},value:h._parse(new oe(s,T,s.path,g)),alwaysSet:g in s.data})}let u=this._def.unknownKeys;if(u==="passthrough")for(let g of l)d.push({key:{status:"valid",value:g},value:{status:"valid",value:s.data[g]}});else if(u==="strict")l.length>0&&(v(s,{code:m.unrecognized_keys,keys:l}),n.dirty());else if(u!=="strip")for(let g of l){let h=s.data[g];d.push({key:{status:"valid",value:g},value:u._parse(new oe(s,h,s.path,g)),alwaysSet:g in s.data})}return s.common.async?Promise.resolve().then(async()=>{let g=[];for(let h of d){let T=await h.key;g.push({key:T,value:await h.value,alwaysSet:h.alwaysSet})}return g}).then(g=>re.mergeObjectSync(n,g)):re.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return P.errToObj,new se(c(f(c({},this._def),{unknownKeys:"strict"}),e!==void 0?{errorMap:a((r,n)=>{var s,i,o,l;let d=(o=(i=(s=this._def).errorMap)==null?void 0:i.call(s,r,n).message)!=null?o:n.defaultError;return r.code==="unrecognized_keys"?{message:(l=P.errToObj(e).message)!=null?l:d}:{message:d}},"errorMap")}:{}))}strip(){return new se(f(c({},this._def),{unknownKeys:"strip"}))}passthrough(){return new se(f(c({},this._def),{unknownKeys:"passthrough"}))}additionalProperties(){if(this._def.unknownKeys instanceof O)return this._def.unknownKeys;if(this._def.unknownKeys==="passthrough")return ct.create();if(this._def.unknownKeys==="strict")return ft.create()}extend(e){return new se(f(c({},this._def),{shape:a(()=>c(c({},this._def.shape()),e),"shape")}))}merge(e){return new se({unknownKeys:e._def.unknownKeys,shape:a(()=>c(c({},this._def.shape()),e._def.shape()),"shape"),typeName:"ZodObject"})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new se(f(c({},this._def),{unknownKeys:e}))}pick(e){let r={};return I.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new se(f(c({},this._def),{shape:a(()=>r,"shape")}))}omit(e){let r={};return I.objectKeys(this.shape).forEach(n=>{e[n]||(r[n]=this.shape[n])}),new se(f(c({},this._def),{shape:a(()=>r,"shape")}))}deepPartial(){return He(this)}partial(e){let r={};return I.objectKeys(this.shape).forEach(n=>{let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s?.optional()}),new se(f(c({},this._def),{shape:a(()=>r,"shape")}))}required(e){let r={};return I.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof ye;)i=i._def.innerType;r[n]=i}}),new se(f(c({},this._def),{shape:a(()=>r,"shape")}))}keyof(){return Ft(I.objectKeys(this.shape))}isEqual(e){if(!(e instanceof se)||!this._unknownKeysEqual(e))return!1;let r=this._def.shape(),n=e._def.shape(),s=a((l,d)=>l[0]===d[0]&&l[1].isEqual(d[1]),"compare"),i=new U(Object.entries(r),{compare:s}),o=new U(Object.entries(n),{compare:s});return i.isEqual(o)}_unknownKeysEqual(e){let r=this.additionalProperties(),n=e.additionalProperties();return r===void 0||n===void 0?r===n:r.isEqual(n)}};a(ke,"ZodObject");ke.create=a((t,e)=>new ke(c({shape:a(()=>t,"shape"),unknownKeys:"strip",typeName:"ZodObject"},S(e))),"create");ke.strictCreate=a((t,e)=>new ke(c({shape:a(()=>t,"shape"),unknownKeys:"strict",typeName:"ZodObject"},S(e))),"strictCreate");ke.lazycreate=a((t,e)=>new ke(c({shape:t,unknownKeys:"strip",typeName:"ZodObject"},S(e))),"lazycreate");var je=ke,Ir=class ir extends O{dereference(e){return new ir(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new ir(f(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)===_.undefined?G(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof ir?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return this._def.innerType.mandatory()}};a(Ir,"ZodOptional");Ir.create=a((t,e)=>new Ir(c({innerType:t,typeName:"ZodOptional"},S(e))),"create");var ye=Ir,Ql=class St extends O{dereference(e){return new St(f(c({},this._def),{in:this._def.in.dereference(e),out:this._def.out.dereference(e)}))}getReferences(){return Te([...this._def.in.getReferences(),...this._def.out.getReferences()])}clone(){return new St(f(c({},this._def),{in:this._def.in.clone(),out:this._def.out.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return a(async()=>{let i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?x:i.status==="dirty"?(r.dirty(),Ne(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})},"handleAsync")();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?x:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new St({in:e,out:r,typeName:"ZodPipeline"})}isEqual(e){return!(!(e instanceof St)||!this._def.in.isEqual(e._def.in)||!this._def.out.isEqual(e._def.out))}};a(Ql,"ZodPipeline");var pn=Ql,Br=class ar extends O{unwrap(){return this._def.type}dereference(e){return new ar(f(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new ar(f(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==_.promise&&r.common.async===!1)return v(r,{code:m.invalid_type,expected:_.promise,received:r.parsedType}),x;let n=r.parsedType===_.promise?r.data:Promise.resolve(r.data);return G(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}isEqual(e){return e instanceof ar?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}};a(Br,"ZodPromise");Br.create=a((t,e)=>new Br(c({type:t,typeName:"ZodPromise"},S(e))),"create");var Wt=Br,Ar=class Et extends O{dereference(e){return new Et(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new Et(f(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){let r=this._def.innerType._parse(e);return lt(r)&&(r.value=Object.freeze(r.value)),r}unwrap(){return this._def.innerType}isEqual(e){return e instanceof Et?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new Et(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(Ar,"ZodReadonly");Ar.create=a((t,e)=>new Ar(c({innerType:t,typeName:"ZodReadonly"},S(e))),"create");var Lt=Ar,ec=class et extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}dereference(e){let r=this._def.keyType.dereference(e),n=this._def.valueType.dereference(e);return new et(f(c({},this._def),{keyType:r,valueType:n}))}getReferences(){return Te([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new et(f(c({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.object)return v(n,{code:m.invalid_type,expected:_.object,received:n.parsedType}),x;let s=[],i=this._def.keyType,o=this._def.valueType;for(let l in n.data)s.push({key:i._parse(new oe(n,l,n.path,l)),value:o._parse(new oe(n,n.data[l],n.path,l))});return n.common.async?re.mergeObjectAsync(r,s):re.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof O?new et(c({keyType:e,valueType:r,typeName:"ZodRecord"},S(n))):new et(c({keyType:J.create(),valueType:e,typeName:"ZodRecord"},S(r)))}isEqual(e){return!(!(e instanceof et)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};a(ec,"ZodRecord");var bs=ec,Rr=class tc extends O{dereference(e){let r=e[this._def.uri];return r||this}getReferences(){return[this._def.uri]}_parse(e){let r=this._getOrReturnCtx(e);return v(r,{code:m.unresolved_reference}),x}isOptional(){return!1}isNullable(){return!1}isEqual(e){return e instanceof tc?this._def.uri===e._def.uri:!1}};a(Rr,"ZodRef");Rr.create=a(t=>new Rr({typeName:"ZodRef",uri:t}),"create");var ws=Rr,Cr=class tt extends O{dereference(e){return new tt(f(c({},this._def),{valueType:this._def.valueType.dereference(e)}))}getReferences(){return this._def.valueType.getReferences()}clone(){return new tt(f(c({},this._def),{valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.set)return v(n,{code:m.invalid_type,expected:_.set,received:n.parsedType}),x;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(v(n,{code:m.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(v(n,{code:m.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let i=this._def.valueType;function o(d){let u=new Set;for(let g of d){if(g.status==="aborted")return x;g.status==="dirty"&&r.dirty(),u.add(g.value)}return{status:r.value,value:u}}a(o,"finalizeSet");let l=[...n.data.values()].map((d,u)=>i._parse(new oe(n,d,n.path,u)));return n.common.async?Promise.all(l).then(d=>o(d)):o(l)}min(e,r){return new tt(f(c({},this._def),{minSize:{value:e,message:P.toString(r)}}))}max(e,r){return new tt(f(c({},this._def),{maxSize:{value:e,message:P.toString(r)}}))}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}isEqual(e){var r,n,s,i;if(!(e instanceof tt))return!1;let o=(r=this._def.minSize)==null?void 0:r.value,l=(n=e._def.minSize)==null?void 0:n.value;if(o!==l)return!1;let d=(s=this._def.maxSize)==null?void 0:s.value,u=(i=e._def.maxSize)==null?void 0:i.value;return d!==u?!1:this._def.valueType.isEqual(e._def.valueType)}};a(Cr,"ZodSet");Cr.create=a((t,e)=>new Cr(c({valueType:t,minSize:null,maxSize:null,typeName:"ZodSet"},S(e))),"create");var Ps=Cr,xs=/^c[^\s-]{8,}$/i,ks=/^[a-z][a-z0-9]*$/,Ss=/^[0-9A-HJKMNP-TV-Z]{26}$/,Es=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Os=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,rc="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",nc=a(t=>t===rc,"isEmojiRegex"),Nn,Zs=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,Is=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;function sc(t,e){return!!((e==="v4"||!e)&&Zs.test(t)||(e==="v6"||!e)&&Is.test(t))}a(sc,"isValidIP");var Dr=class rt extends O{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==_.string){let i=this._getOrReturnCtx(e);return v(i,{code:m.invalid_type,expected:_.string,received:i.parsedType}),x}let n=new re,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:m.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:m.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,l=e.data.length<i.value;(o||l)&&(s=this._getOrReturnCtx(e,s),o?v(s,{code:m.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):l&&v(s,{code:m.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")Os.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"email",code:m.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")Nn||(Nn=new RegExp(rc,"u")),Nn.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"emoji",code:m.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")Es.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"uuid",code:m.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")xs.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"cuid",code:m.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")ks.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"cuid2",code:m.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")Ss.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"ulid",code:m.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),v(s,{validation:"url",code:m.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"regex",code:m.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),v(s,{code:m.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),v(s,{code:m.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),v(s,{code:m.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?Il(i).test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{code:m.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="ip"?sc(e.data,i.version)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"ip",code:m.invalid_string,message:i.message}),n.dirty()):I.assertNever(i);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),c({validation:r,code:m.invalid_string},P.errToObj(n)))}_addCheck(e){return new rt(f(c({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(c({kind:"email"},P.errToObj(e)))}url(e){return this._addCheck(c({kind:"url"},P.errToObj(e)))}emoji(e){return this._addCheck(c({kind:"emoji"},P.errToObj(e)))}uuid(e){return this._addCheck(c({kind:"uuid"},P.errToObj(e)))}cuid(e){return this._addCheck(c({kind:"cuid"},P.errToObj(e)))}cuid2(e){return this._addCheck(c({kind:"cuid2"},P.errToObj(e)))}ulid(e){return this._addCheck(c({kind:"ulid"},P.errToObj(e)))}ip(e){return this._addCheck(c({kind:"ip"},P.errToObj(e)))}datetime(e){var r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck(c({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(r=e?.offset)!=null?r:!1},P.errToObj(e?.message)))}regex(e,r){return this._addCheck(c({kind:"regex",regex:e},P.errToObj(r)))}includes(e,r){return this._addCheck(c({kind:"includes",value:e,position:r?.position},P.errToObj(r?.message)))}startsWith(e,r){return this._addCheck(c({kind:"startsWith",value:e},P.errToObj(r)))}endsWith(e,r){return this._addCheck(c({kind:"endsWith",value:e},P.errToObj(r)))}min(e,r){return this._addCheck(c({kind:"min",value:e},P.errToObj(r)))}max(e,r){return this._addCheck(c({kind:"max",value:e},P.errToObj(r)))}length(e,r){return this._addCheck(c({kind:"length",value:e},P.errToObj(r)))}nonempty(e){return this.min(1,P.errToObj(e))}trim(){return new rt(f(c({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}secret(){return this._def[w]=f(c({},this._def[w]),{secret:!0}),this}toLowerCase(){return new rt(f(c({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new rt(f(c({},this._def),{checks:[...this._def.checks,{kind:"toUpperCase"}]}))}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}isEqual(e){if(!(e instanceof rt))return!1;let r=new U(this._def.checks),n=new U(e._def.checks);return r.isEqual(n)}};a(Dr,"ZodString");Dr.create=a(t=>{var e;return new Dr(c({checks:[],typeName:"ZodString",coerce:(e=t?.coerce)!=null?e:!1},S(f(c({},t),{supportsExtensions:["secret"]}))))},"create");var J=Dr,Hr=class ic extends O{_parse(e){if(this._getType(e)!==_.symbol){let n=this._getOrReturnCtx(e);return v(n,{code:m.invalid_type,expected:_.symbol,received:n.parsedType}),x}return G(e.data)}isEqual(e){return e instanceof ic}};a(Hr,"ZodSymbol");Hr.create=a(t=>new Hr(c({typeName:"ZodSymbol"},S(t))),"create");var Bs=Hr,ut=class Ot extends O{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName==="ZodEffects"?this._def.schema.sourceType():this._def.schema}dereference(e){return new Ot(f(c({},this._def),{schema:this._def.schema.dereference(e)}))}getReferences(){return this._def.schema.getReferences()}clone(){return new Ot(f(c({},this._def),{schema:this._def.schema.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a(o=>{v(n,o),o.fatal?r.abort():r.dirty()},"addIssue"),get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let o=s.transform(n.data,i);if(n.common.async)return Promise.resolve(o).then(async l=>{if(r.value==="aborted")return x;let d=await this._def.schema._parseAsync({data:l,path:n.path,parent:n});return d.status==="aborted"?x:d.status==="dirty"||r.value==="dirty"?Ne(d.value):d});{if(r.value==="aborted")return x;let l=this._def.schema._parseSync({data:o,path:n.path,parent:n});return l.status==="aborted"?x:l.status==="dirty"||r.value==="dirty"?Ne(l.value):l}}if(s.type==="refinement"){let o=a(l=>{let d=s.refinement(l,i);if(n.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return l},"executeRefinement");if(n.common.async===!1){let l=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return l.status==="aborted"?x:(l.status==="dirty"&&r.dirty(),o(l.value),{status:r.value,value:l.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(l=>l.status==="aborted"?x:(l.status==="dirty"&&r.dirty(),o(l.value).then(()=>({status:r.value,value:l.value}))))}if(s.type==="transform")if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!lt(o))return o;let l=s.transform(o.value,i);if(l instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:l}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>lt(o)?Promise.resolve(s.transform(o.value,i)).then(l=>({status:r.value,value:l})):o);I.assertNever(s)}isEqual(e){return!(e instanceof Ot)||!this._def.schema.isEqual(e._def.schema)?!1:this._def.effect.type==="refinement"?e._def.effect.type!=="refinement"?!1:I.compareFunctions(this._def.effect.refinement,e._def.effect.refinement):this._def.effect.type==="transform"?e._def.effect.type!=="transform"?!1:I.compareFunctions(this._def.effect.transform,e._def.effect.transform):this._def.effect.type==="preprocess"?e._def.effect.type!=="preprocess"?!1:I.compareFunctions(this._def.effect.transform,e._def.effect.transform):!1}naked(){return this._def.schema.naked()}mandatory(){return new Ot(f(c({},this._def),{schema:this._def.schema.mandatory()}))}};a(ut,"ZodEffects");ut.create=a((t,e,r)=>new ut(c({schema:t,typeName:"ZodEffects",effect:e},S(r))),"create");ut.createWithPreprocess=a((t,e,r)=>new ut(c({schema:e,effect:{type:"preprocess",transform:t},typeName:"ZodEffects"},S(r))),"createWithPreprocess");var Se=ut,Nr=class Zt extends O{dereference(e){let r=this._def.items.map(s=>s.dereference(e)),n=this._def.rest?this._def.rest.dereference(e):null;return new Zt(f(c({},this._def),{items:r,rest:n}))}getReferences(){return Te([...this._def.items.flatMap(e=>e.getReferences()),...this._def.rest?this._def.rest.getReferences():[]])}clone(){let e=this._def.items.map(n=>n.clone()),r=this._def.rest?this._def.rest.clone():null;return new Zt(f(c({},this._def),{items:e,rest:r}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.array)return v(n,{code:m.invalid_type,expected:_.array,received:n.parsedType}),x;if(n.data.length<this._def.items.length)return v(n,{code:m.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),x;!this._def.rest&&n.data.length>this._def.items.length&&(v(n,{code:m.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...n.data].map((o,l)=>{let d=this._def.items[l]||this._def.rest;return d?d._parse(new oe(n,o,n.path,l)):null}).filter(o=>!!o);return n.common.async?Promise.all(i).then(o=>re.mergeArray(r,o)):re.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new Zt(f(c({},this._def),{rest:e}))}isEqual(e){if(!(e instanceof Zt)||!this._restEquals(e))return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new U(this._def.items,{compare:r}),s=new U(e._def.items,{compare:r});return n.isEqual(s)}_restEquals(e){return this._def.rest===null?e._def.rest===null:e._def.rest!==null&&this._def.rest.isEqual(e._def.rest)}};a(Nr,"ZodTuple");Nr.create=a((t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Nr(c({items:t,typeName:"ZodTuple",rest:null},S(e)))},"create");var Ke=Nr,Mr=class ac extends O{_parse(e){if(this._getType(e)!==_.undefined){let n=this._getOrReturnCtx(e);return v(n,{code:m.invalid_type,expected:_.undefined,received:n.parsedType}),x}return G(e.data)}isEqual(e){return e instanceof ac}mandatory(){return ft.create(c({},this._def))}};a(Mr,"ZodUndefined");Mr.create=a(t=>new Mr(c({typeName:"ZodUndefined"},S(t))),"create");var qt=Mr,$r=class It extends O{dereference(e){let r=this._def.options.map(n=>n.dereference(e));return new It(f(c({},this._def),{options:r}))}getReferences(){return Te(this._def.options.reduce((e,r)=>[...e,...r.getReferences()],[]))}clone(){let e=this._def.options.map(r=>r.clone());return new It(f(c({},this._def),{options:e}))}_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function s(i){for(let l of i)if(l.result.status==="valid")return l.result;for(let l of i)if(l.result.status==="dirty")return r.common.issues.push(...l.ctx.common.issues),l.result;let o=i.map(l=>new pe(l.ctx.common.issues));return v(r,{code:m.invalid_union,unionErrors:o}),x}if(a(s,"handleResults"),r.common.async)return Promise.all(n.map(async i=>{let o=f(c({},r),{common:f(c({},r.common),{issues:[]}),parent:null});return{result:await i._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(s);{let i,o=[];for(let d of n){let u=f(c({},r),{common:f(c({},r.common),{issues:[]}),parent:null}),g=d._parseSync({data:r.data,path:r.path,parent:u});if(g.status==="valid")return g;g.status==="dirty"&&!i&&(i={result:g,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let l=o.map(d=>new pe(d));return v(r,{code:m.invalid_union,unionErrors:l}),x}}get options(){return this._def.options}isEqual(e){if(!(e instanceof It))return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new U([...this._def.options],{compare:r}),s=new U([...e._def.options],{compare:r});return n.isEqual(s)}mandatory(){let e=this._def.options.filter(i=>!(i instanceof qt)).map(i=>i.mandatory()),[r,n,...s]=e;return r?n?new It(f(c({},this._def),{options:[r,n,...s]})):r:ft.create(c({},this._def))}};a($r,"ZodUnion");$r.create=a((t,e)=>new $r(c({options:t,typeName:"ZodUnion"},S(e))),"create");var fn=$r,jr=class oc extends O{constructor(){super(...arguments),this._unknown=!0}_parse(e){return G(e.data)}isEqual(e){return e instanceof oc}};a(jr,"ZodUnknown");jr.create=a(t=>new jr(c({typeName:"ZodUnknown"},S(t))),"create");var it=jr,Kr=class lc extends O{_parse(e){if(this._getType(e)!==_.undefined){let n=this._getOrReturnCtx(e);return v(n,{code:m.invalid_type,expected:_.void,received:n.parsedType}),x}return G(e.data)}isEqual(e){return e instanceof lc}};a(Kr,"ZodVoid");Kr.create=a(t=>new Kr(c({typeName:"ZodVoid"},S(t))),"create");var As=Kr,hh=["gpt-3.5-turbo","gpt-3.5-turbo-16k","gpt-4","gpt-4-1106-preview","gpt-4-vision-preview","gpt-4-0125-preview","gpt-4-turbo-preview","gpt-4-turbo","gpt-4o","gpt-3.5-turbo-0125","gpt-3.5-turbo-1106"],Bv=Ge.create(["any","string","number","boolean","object","pattern","date","array","target","time","enum"]),cc=a(t=>J.create().displayAs({id:"variable",params:c({type:t?.type||"any"},t?.params)}),"variable"),dc=a(t=>J.create().displayAs({id:"conversation",params:c({},t?.params)}),"conversation"),uc=a(t=>J.create().displayAs({id:"user",params:c({},t?.params)}),"user"),pc=a(t=>J.create().displayAs({id:"message",params:c({},t?.params)}),"message"),fc=a(t=>J.create().displayAs({id:"agent",params:c({},t?.params)}),"agent"),gc=a(t=>J.create().displayAs({id:"event",params:c({},t?.params)}),"event"),mc=a(t=>J.create().displayAs({id:"table",params:c({},t?.params)}),"table"),hc=a(t=>J.create().displayAs({id:"tablerow",params:c({},t?.params)}),"tablerow"),yc=a(t=>J.create().displayAs({id:"intent",params:c({},t?.params)}),"intent"),vc=a(()=>Ge.create(hh).displayAs({id:"dropdown",params:{}}),"aimodel"),_c=a(t=>J.create().displayAs({id:"datasource",params:c({},t)}),"datasource"),Tc=a(t=>J.create().displayAs({id:"knowledgebase",params:c({},t)}),"knowledgebase"),bc={object:je.lazycreate},wc=a((t,e={message:`Input not instance of ${t.name}`})=>ms(r=>r instanceof t,e),"instanceOfType"),Rs=J.create,Cs=un.create,Pc=Ts.create,xc=en.create,Ds=tn.create,kc=sn.create,Sc=Bs.create,Ec=qt.create,Oc=dn.create,Zc=ct.create,Ic=it.create,Bc=ft.create,Ac=As.create,Rc=dt.create,Cc=je.create,Dc=je.strictCreate,Hc=fn.create,Nc=hs.create,Mc=an.create,$c=Ke.create,jc=bs.create,Kc=ws.create,Uc=Lt.create,zc=_s.create,Fc=Ps.create,Wc=vs.create,Lc=on.create,qc=ln.create,Vc=Ge.create,Gc=cn.create,Jc=Wt.create,Vn=Se.create,Yc=ye.create,Xc=$e.create,yh=zt.create,Qc=Se.createWithPreprocess,ed=pn.create,td=a(()=>Rs().optional(),"ostring"),rd=a(()=>Cs().optional(),"onumber"),nd=a(()=>Ds().optional(),"oboolean"),sd={string:a(t=>J.create(f(c({},t),{coerce:!0})),"string"),number:a(t=>un.create(f(c({},t),{coerce:!0})),"number"),boolean:a(t=>tn.create(f(c({},t),{coerce:!0})),"boolean"),bigint:a(t=>en.create(f(c({},t),{coerce:!0})),"bigint"),date:a(t=>sn.create(f(c({},t),{coerce:!0})),"date")},id=x,p=y,ad=a((t,e)=>t.anyOf.length?t.anyOf.length===1?L(t.anyOf[0],f(c({},e),{path:[...e.path,"anyOf",0]})):`z.union([${t.anyOf.map((r,n)=>L(r,f(c({},e),{path:[...e.path,"anyOf",n]}))).join(", ")}])`:"z.any()","parseAnyOf"),vh=a(t=>{var e;return(e=t[w])!=null&&e.coerce?"z.coerce.boolean()":"z.boolean()"},"parseBoolean"),_h=a(t=>"z.any()","parseDefault"),Th=a((t,e)=>`z.union([${t.type.map(r=>L(f(c({},t),{type:r}),e)).join(", ")}])`,"parseMultipleType"),bh=a((t,e)=>`z.any().refine((value) => !${L(t.not,f(c({},e),{path:[...e.path,"not"]}))}.safeParse(value).success, "Invalid input: Should NOT be valid against schema")`,"parseNot"),wh=a(t=>"z.null()","parseNull"),Ph=a(t=>[t.slice(0,t.length/2),t.slice(t.length/2)],"half"),xh=a((t,...e)=>Object.keys(t).reduce((r,n)=>(e.includes(n)||(r[n]=t[n]),r),{}),"omit");function V(t,e,r){var n;let s=t[e],i="";if(s!==void 0){let o=r({value:s,json:JSON.stringify(s)});if(o){let l=o[0],d=o.length===3?o[1]:"",u=o.length===3?o[2]:o[1];i+=l,((n=t.errorMessage)==null?void 0:n[e])!==void 0&&(i+=d+JSON.stringify(t.errorMessage[e])),i+=u}}return i}a(V,"withMessage");var Bt=Symbol("Original index"),kh=a(t=>{let e=[];for(let r=0;r<t.length;r++){let n=t[r];if(typeof n=="boolean")e.push(n?{[Bt]:r}:{[Bt]:r,not:{}});else{if(Bt in n)return t;e.push(f(c({},n),{[Bt]:r}))}}return e},"ensureOriginalIndex");function Kt(t,e){if(t.allOf.length===0)return"z.never()";if(t.allOf.length===1){let r=t.allOf[0];return L(r,f(c({},e),{path:[...e.path,"allOf",r[Bt]]}))}else{let[r,n]=Ph(kh(t.allOf));return`z.intersection(${Kt({allOf:r},e)}, ${Kt({allOf:n},e)})`}}a(Kt,"parseAllOf");var Sh=a((t,e)=>{if(Array.isArray(t.items))return`z.tuple([${t.items.map((n,s)=>L(n,f(c({},e),{path:[...e.path,"items",s]})))}])`;let r=t.items?`z.array(${L(t.items,f(c({},e),{path:[...e.path,"items"]}))})`:"z.array(z.any())";return r+=V(t,"minItems",({json:n})=>[`.min(${n}`,", ",")"]),r+=V(t,"maxItems",({json:n})=>[`.max(${n}`,", ",")"]),r},"parseArray"),Eh=a(t=>`z.literal(${JSON.stringify(t.const)})`,"parseConst"),Oh=a(t=>t.enum.length===0?"z.never()":t.enum.length===1?`z.literal(${JSON.stringify(t.enum[0])})`:t.enum.every(e=>typeof e=="string")?`z.enum([${t.enum.map(e=>JSON.stringify(e))}])`:`z.union([${t.enum.map(e=>`z.literal(${JSON.stringify(e)})`).join(", ")}])`,"parseEnum"),Zh=a((t,e)=>{let r=L(t.if,f(c({},e),{path:[...e.path,"if"]})),n=L(t.then,f(c({},e),{path:[...e.path,"then"]})),s=L(t.else,f(c({},e),{path:[...e.path,"else"]}));return`z.union([${n}, ${s}]).superRefine((value,ctx) => {
17
17
  const result = ${r}.safeParse(value).success
18
18
  ? ${n}.safeParse(value)
19
19
  : ${s}.safeParse(value);
20
20
  if (!result.success) {
21
21
  result.error.errors.forEach((error) => ctx.addIssue(error))
22
22
  }
23
- })`},"parseIfThenElse"),Zh=a(t=>{var e;let r="z.number()";return(e=t[w])!=null&&e.coerce&&(r="z.coerce.number()"),t.type==="integer"?r+=V(t,"type",()=>[".int(",")"]):r+=V(t,"format",({value:n})=>{if(n==="int64")return[".int(",")"]}),r+=V(t,"multipleOf",({value:n,json:s})=>n===1?r.startsWith("z.number().int(")?void 0:[".int(",")"]:[`.multipleOf(${s}`,", ",")"]),typeof t.minimum=="number"?t.exclusiveMinimum===!0?r+=V(t,"minimum",({json:n})=>[`.gt(${n}`,", ",")"]):r+=V(t,"minimum",({json:n})=>[`.gte(${n}`,", ",")"]):typeof t.exclusiveMinimum=="number"&&(r+=V(t,"exclusiveMinimum",({json:n})=>[`.gt(${n}`,", ",")"])),typeof t.maximum=="number"?t.exclusiveMaximum===!0?r+=V(t,"maximum",({json:n})=>[`.lt(${n}`,", ",")"]):r+=V(t,"maximum",({json:n})=>[`.lte(${n}`,", ",")"]):typeof t.exclusiveMaximum=="number"&&(r+=V(t,"exclusiveMaximum",({json:n})=>[`.lt(${n}`,", ",")"])),r},"parseNumber"),Hs=a((t,e)=>t.oneOf.length?t.oneOf.length===1?L(t.oneOf[0],f(c({},e),{path:[...e.path,"oneOf",0]})):`z.any().superRefine((x, ctx) => {
23
+ })`},"parseIfThenElse"),Ih=a(t=>{var e;let r="z.number()";return(e=t[w])!=null&&e.coerce&&(r="z.coerce.number()"),t.type==="integer"?r+=V(t,"type",()=>[".int(",")"]):r+=V(t,"format",({value:n})=>{if(n==="int64")return[".int(",")"]}),r+=V(t,"multipleOf",({value:n,json:s})=>n===1?r.startsWith("z.number().int(")?void 0:[".int(",")"]:[`.multipleOf(${s}`,", ",")"]),typeof t.minimum=="number"?t.exclusiveMinimum===!0?r+=V(t,"minimum",({json:n})=>[`.gt(${n}`,", ",")"]):r+=V(t,"minimum",({json:n})=>[`.gte(${n}`,", ",")"]):typeof t.exclusiveMinimum=="number"&&(r+=V(t,"exclusiveMinimum",({json:n})=>[`.gt(${n}`,", ",")"])),typeof t.maximum=="number"?t.exclusiveMaximum===!0?r+=V(t,"maximum",({json:n})=>[`.lt(${n}`,", ",")"]):r+=V(t,"maximum",({json:n})=>[`.lte(${n}`,", ",")"]):typeof t.exclusiveMaximum=="number"&&(r+=V(t,"exclusiveMaximum",({json:n})=>[`.lt(${n}`,", ",")"])),r},"parseNumber"),Hs=a((t,e)=>t.oneOf.length?t.oneOf.length===1?L(t.oneOf[0],f(c({},e),{path:[...e.path,"oneOf",0]})):`z.any().superRefine((x, ctx) => {
24
24
  const schemas = [${t.oneOf.map((r,n)=>L(r,f(c({},e),{path:[...e.path,"oneOf",n]}))).join(", ")}];
25
25
  const errors = schemas.reduce(
26
26
  (errors: z.ZodError[], schema) =>
@@ -69,7 +69,7 @@ declare function ${n}${o};${d}`);if(t.props.type==="variable")return Bn(`${s}dec
69
69
  `,s+=`}
70
70
  `,s+=`}
71
71
  `),s+=`}
72
- `,s+="})"}let i=r?s?r+s:n?n==="z.never()"?r+".strict()":r+`.catchall(${n})`:r:s||(n?`z.record(${n})`:"z.record(z.any())");return $.an.anyOf(t)&&(i+=`.and(${ad(f(c({},t),{anyOf:t.anyOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?f(c({},o),{type:"object"}):o)}),e)})`),$.a.oneOf(t)&&(i+=`.and(${Hs(f(c({},t),{oneOf:t.oneOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?f(c({},o),{type:"object"}):o)}),e)})`),$.an.allOf(t)&&(i+=`.and(${Kt(f(c({},t),{allOf:t.allOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?f(c({},o),{type:"object"}):o)}),e)})`),i}a(od,"parseObject");var Ih=a(t=>{var e;let r="z.string()";if((e=t[w])!=null&&e.coerce){if(t.format==="date-time")return"z.coerce.date()";r="z.coerce.string()"}return r+=V(t,"format",({value:n})=>{switch(n){case"email":return[".email(",")"];case"ip":return[".ip(",")"];case"ipv4":return['.ip({ version: "v4"',", message: "," })"];case"ipv6":return['.ip({ version: "v6"',", message: "," })"];case"uri":return[".url(",")"];case"uuid":return[".uuid(",")"];case"date-time":return[".datetime(",")"]}}),r+=V(t,"pattern",({json:n})=>[`.regex(new RegExp(${n})`,", ",")"]),r+=V(t,"minLength",({json:n})=>[`.min(${n}`,", ",")"]),r+=V(t,"maxLength",({json:n})=>[`.max(${n}`,", ",")"]),r},"parseString"),Bh=a((t,e)=>`${L(Ph(t,"nullable"),e,!0)}.nullable()`,"parseNullable"),Ah=a(t=>`z.ref('${t.$ref}')`,"parseRef"),Rh=a((t,e)=>{var r,n;if(t.oneOf.length<=1||!((r=t.discriminator)!=null&&r.propertyName))return Hs(t,e);let s=t.oneOf.map((i,o)=>L(i,f(c({},e),{path:[...e.path,"oneOf",o]})));return`z.discriminatedUnion("${(n=t.discriminator)==null?void 0:n.propertyName}", [${s.join(", ")}])`},"parseDiscriminator"),L=a((t,e={seen:new Map,path:[]},r)=>{if(typeof t!="object")return t?"z.any()":"z.never()";if(e.parserOverride){let i=e.parserOverride(t,e);if(typeof i=="string")return i}let n=e.seen.get(t);if(n){if(n.r!==void 0)return n.r;if(e.depth===void 0||n.n>=e.depth)return"z.any()";n.n+=1}else n={r:void 0,n:0},e.seen.set(t,n);let s=Hh(t,e);return r||(s=Ch(t,s),e.withoutDefaults||(s=Dh(t,s))),n.r=s,s},"parseSchema"),Ch=a((t,e)=>(t.description&&(e+=`.describe(${JSON.stringify(t.description)})`),e),"addMeta"),Dh=a((t,e)=>(t.default!==void 0&&(e+=`.default(${JSON.stringify(t.default)})`),e),"addDefaults"),Hh=a((t,e)=>$.a.nullable(t)?Bh(t,e):$.an.object(t)?od(t,e):$.an.array(t)?kh(t,e):$.an.anyOf(t)?ad(t,e):$.an.allOf(t)?Kt(t,e):$.a.discriminator(t)?Rh(t,e):$.a.oneOf(t)?Hs(t,e):$.a.not(t)?Th(t,e):$.an.enum(t)?Eh(t):$.a.const(t)?Sh(t):$.a.multipleType(t)?_h(t,e):$.a.primitive(t,"string")?Ih(t):$.a.primitive(t,"number")||$.a.primitive(t,"integer")?Zh(t):$.a.primitive(t,"boolean")?yh(t):$.a.primitive(t,"null")?bh(t):$.a.conditional(t)?Oh(t,e):$.a.ref(t)?Ah(t):vh(t),"selectParser"),$={an:{object:a(t=>t.type==="object","object"),array:a(t=>t.type==="array","array"),anyOf:a(t=>t.anyOf!==void 0,"anyOf"),allOf:a(t=>t.allOf!==void 0,"allOf"),enum:a(t=>t.enum!==void 0,"enum")},a:{nullable:a(t=>t.nullable===!0,"nullable"),multipleType:a(t=>Array.isArray(t.type),"multipleType"),not:a(t=>t.not!==void 0,"not"),const:a(t=>t.const!==void 0,"const"),primitive:a((t,e)=>t.type===e,"primitive"),conditional:a(t=>!!("if"in t&&t.if&&"then"in t&&"else"in t&&t.then&&t.else),"conditional"),discriminator:a(t=>{var e;return t.oneOf!==void 0&&((e=t.discriminator)==null?void 0:e.propertyName)!==void 0},"discriminator"),oneOf:a(t=>t.oneOf!==void 0,"oneOf"),ref:a(t=>t.$ref!==void 0,"ref")}},Nh=a(t=>{let e;try{e=new Function("z",`return ${t}`)(p)}catch(r){return{sucess:!1,error:`Failed to evaluate schema: ${(r instanceof Error?r:new Error(String(r))).message}`}}return e instanceof p.ZodType?{sucess:!0,value:e}:{sucess:!1,error:`String "${t}" does not evaluate to a Zod schema`}},"evalZuiString"),Mh=a(t=>L(t,{seen:new Map,path:[]}),"jsonSchemaToZodStr"),$h=a(t=>{let e=Mh(t);e=e.replaceAll("errors: z.ZodError[]","errors");let r=Nh(e);if(!r.sucess)throw new Fr(r.error);return r.value},"jsonSchemaToZod"),At=a((t,e)=>{var r,n;if(e[w]&&t._def&&(t.naked()._def[w]=e[w]),((r=t._def)==null?void 0:r.typeName)==="ZodObject"&&e.type==="object"&&e.properties&&Object.entries(e.properties).forEach(([s,i])=>{let o=typeof t._def.shape=="function"?t._def.shape():t._def.shape;o[s]&&At(o[s],i)}),((n=t._def)==null?void 0:n.typeName)==="ZodRecord"&&e.type==="object"&&e.additionalProperties&&At(t._def.valueType,e.additionalProperties),e.type==="array"&&e.items){let s=e.items;if(typeof s=="object"&&!Array.isArray(s)){let i=t._def.type;i&&At(i,s)}else Array.isArray(s)&&s.forEach((i,o)=>{let l=t._def;l.typeName===y.ZodFirstPartyTypeKind.ZodTuple&&At(l.items[o],i)})}},"applyZuiPropsRecursively"),jh=a(t=>{let e=$h(t);return At(e,t),e},"fromJSONSchemaLegacy"),Kh=a(t=>{var e,r;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(n=>typeof n!="boolean"&&ld(n))&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===p.ZodFirstPartyTypeKind.ZodOptional},"isOptionalSchema"),Uh=a(t=>{var e,r;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(n=>typeof n!="boolean"&&n.type==="null")&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===p.ZodFirstPartyTypeKind.ZodNullable},"isNullableSchema"),ld=a(t=>{var e,r;return t.not===!0&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===p.ZodFirstPartyTypeKind.ZodUndefined},"isUndefinedSchema"),zh=a(t=>{var e,r;return!t.not&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===p.ZodFirstPartyTypeKind.ZodUnknown},"isUnknownSchema"),Fh=a(({type:t,minimum:e,exclusiveMinimum:r,maximum:n,exclusiveMaximum:s,multipleOf:i,format:o})=>{let l=p.number();return t==="integer"&&(l=l.int()),o==="finite"&&(l=l.finite()),r!==void 0?l=l.gt(r):e!==void 0&&(l=l.gte(e)),s!==void 0?l=l.lt(s):n!==void 0&&(l=l.lte(n)),i!==void 0&&(l=l.multipleOf(i)),l},"numberJSONSchemaToZuiNumber"),Wh=a(({format:t,pattern:e,minLength:r,maxLength:n})=>{let s=p.string();if(r&&n&&r===n?s=s.length(r):(r&&(s=s.min(r)),n&&(s=s.max(n))),t==="cuid"||e===j.cuid)s=s.cuid();else if(t==="cuid2"||e===j.cuid2)s=s.cuid2();else if(t==="emoji"||e===j.emoji)s=s.emoji();else if(t==="ulid"||e===j.ulid)s=s.ulid();else if(t==="date-time"){let{precision:i,offset:o}=e?ih(e):{};s=s.datetime({precision:i,offset:o})}else t==="email"||e===j.email?s=s.email():t==="ipv4"||e===j.ipv4?s=s.ip():t==="ipv6"||e===j.ipv6?s=s.ip("v6"):t==="uri"?s=s.url():t==="uuid"||e===j.uuid?s=s.uuid():e&&(s=s.regex(new RegExp(e)));return s},"stringJSONSchemaToZuiString"),Tt=a((t,e)=>{let r=[];e.enum!==void 0&&r.push(...e.enum),e.const!==void 0&&r.push(e.const);let n=r.filter(o=>typeof o===t),[s]=n;if(!s){if(t==="string"&&e.type==="string")return Wh(e);if(t==="number"&&(e.type==="number"||e.type==="integer"))return Fh(e);if(t==="boolean")return p.boolean();if(t==="null")return p.null();throw new Fr(`Unknown primitive type: "${t}"`)}if(n.length===1)return p.literal(s);let i=n.map(o=>p.literal(o));return p.union(i)},"toZuiPrimitive"),Lh=a((t,e)=>qh(t)?Gh(t,e):Vh(t)?Jh(t,e):Yh(t,e),"arrayJSONSchemaToZuiArray"),qh=a(t=>Array.isArray(t.items),"_isTuple"),Vh=a(t=>t.items!==void 0&&t.uniqueItems,"_isSet"),Gh=a(({items:t,additionalItems:e},r)=>{let n=t.map(r),s=p.tuple(n);return e!==void 0&&(s=s.rest(r(e))),s},"_handleTuple"),Jh=a(({items:t,minItems:e,maxItems:r},n)=>{let s=p.set(n(t));return e&&(s=s.min(e)),r&&(s=s.max(r)),s},"_handleSet"),Yh=a(({minItems:t,maxItems:e,items:r},n)=>{let s=p.array(n(r));return t&&t===e?s.length(t):(t&&(s=s.min(t)),e&&(s=s.max(e)),s)},"_handleArray"),Qe=p.any();function cd(t){return W(t)}a(cd,"fromJSONSchema");function W(t){var e;if(t===void 0)return Qe;if(t===!0)return p.any();if(t===!1)return p.never();if(t.default!==void 0)return W(f(c({},t),{default:void 0})).default(t.default);if(t.readOnly)return W(f(c({},t),{readOnly:void 0})).readonly();if(t.oneOf!==void 0)throw new Pe({oneOf:t.oneOf});if(t.patternProperties!==void 0)throw new Pe({patternProperties:t.patternProperties});if(t.propertyNames!==void 0)throw new Pe({propertyNames:t.propertyNames});if(t.if!==void 0)throw new Pe({if:t.if});if(t.then!==void 0)throw new Pe({then:t.then});if(t.else!==void 0)throw new Pe({else:t.else});if(t.$ref!==void 0)return p.ref(t.$ref);if(t.not!==void 0){if(ld(t))return p.undefined();if(t.not===!0)return p.never();throw new Pe({not:t.not})}if(Array.isArray(t.type)){if(t.type.length===0)return Qe;if(t.type.length===1)return W(f(c({},t),{type:t.type[0]}));let r=t,{type:n}=r,s=Ai(r,["type"]),i=t.type.map(o=>W(f(c({},s),{type:o})));return p.union(i)}if(t.type==="string")return t.enum&&t.enum.length>0?p.enum(t.enum):Tt("string",t);if(t.type==="integer"){let r=Tt("number",t);return r instanceof p.ZodNumber?r.int():r}if(t.type==="number")return Tt("number",t);if(t.type==="boolean")return Tt("boolean",t);if(t.type==="null")return Tt("null",t);if(t.type==="array")return Lh(t,W);if(t.type==="object"){if(t.additionalProperties!==void 0&&t.properties!==void 0){let r=W(t.additionalProperties);return W(f(c({},t),{additionalProperties:void 0})).catchall(r)}if(t.properties!==void 0){let r={};for(let[n,s]of Object.entries(t.properties)){let i=W(s),o=(e=t.required)!=null?e:[];r[n]=o.includes(n)?i:i.optional()}return p.object(r)}if(t.additionalProperties!==void 0){let r=W(t.additionalProperties);return p.record(r)}return p.record(Qe)}if(t.anyOf!==void 0){if(t.anyOf.length===0)return Qe;if(t.anyOf.length===1)return W(t.anyOf[0]);if(Kh(t))return W(t.anyOf[0]).optional();if(Uh(t))return W(t.anyOf[0]).nullable();let r=t.anyOf.map(W);return p.union(r)}if(t.allOf!==void 0){if(t.allOf.length===0)return Qe;if(t.allOf.length===1)return W(t.allOf[0]);let[r,...n]=t.allOf,s=W(r),i=W({allOf:n});return p.intersection(s,i)}return zh(t)?p.unknown():Qe}a(W,"_fromJSONSchema");var Xh=/^\d{4}-\d{2}-\d{2}(T|\s)?((\d{2}:\d{2}:\d{2}(\.\d{1,3})?)|(\d{2}:\d{2}))?(\s?([+-]\d{2}:\d{2}|Z))?$/,Gn=a((t,e,r=!0)=>{if(typeof t!="object")throw new $n("Input must be an object");let n=a(o=>{let l=o;return e?.nullable&&(l=l.nullable()),e?.optional&&(l=l.optional()),e?.passtrough&&typeof l.passthrough=="function"&&(l=l.passthrough()),l},"applyOptions"),s=Object.entries(t).reduce((o,[l,d])=>{if(d===null)o[l]=n(y.null());else switch(typeof d){case"string":o[l]=Xh.test(d)?n(y.string().datetime()):n(y.string());break;case"number":o[l]=n(y.number());break;case"boolean":o[l]=n(y.boolean());break;case"object":Array.isArray(d)?d.length===0?o[l]=n(y.array(y.unknown())):typeof d[0]=="object"?o[l]=n(y.array(Gn(d[0],e,!1))):["string","number","boolean"].includes(typeof d[0])&&(o[l]=n(y.array(y[typeof d[0]]()))):o[l]=n(Gn(d,e,!1));break;default:throw new $n(`Unsupported type for key ${l}`)}return o},{}),i=Object.keys(s).length>0;return e?.passtrough||!r&&!i?y.object(s).passthrough():y.object(s)},"fromObject");function dd(){return{}}a(dd,"parseAnyDef");function ud(t,e){var r,n;let s={type:"array"};return((n=(r=t.type)==null?void 0:r._def)==null?void 0:n.typeName)!=="ZodAny"&&(s.items=A(t.type._def,f(c({},e),{currentPath:[...e.currentPath,"items"]}))),t.minLength&&D(s,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&D(s,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(D(s,"minItems",t.exactLength.value,t.exactLength.message,e),D(s,"maxItems",t.exactLength.value,t.exactLength.message,e)),s}a(ud,"parseArrayDef");function pd(t,e){let r=c({type:"integer",format:"int64"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?D(r,"minimum",n.value,n.message,e):D(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),D(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?D(r,"maximum",n.value,n.message,e):D(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),D(r,"maximum",n.value,n.message,e));break;case"multipleOf":D(r,"multipleOf",n.value,n.message,e);break}return r}a(pd,"parseBigintDef");function fd(t){return c({type:"boolean"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{})}a(fd,"parseBooleanDef");function gd(t,e){return A(t.type._def,e)}a(gd,"parseBrandedDef");var Qh=a((t,e)=>A(t.innerType._def,e),"parseCatchDef");function md(t,e){return e.dateStrategy=="integer"?ey(t,e):c({type:"string",format:"date-time"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{})}a(md,"parseDateDef");var ey=a((t,e)=>{let r=c({type:"integer",format:"unix-time"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{});for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"&&D(r,"minimum",n.value,n.message,e);break;case"max":e.target==="jsonSchema7"&&D(r,"maximum",n.value,n.message,e);break}return r},"integerDateParser");function hd(t,e){return f(c({},A(t.innerType._def,e)),{default:t.defaultValue()})}a(hd,"parseDefaultDef");function yd(t,e){return e.effectStrategy==="input"?A(t.schema._def,e):{}}a(yd,"parseEffectsDef");function vd(t){return{type:"string",enum:t.values}}a(vd,"parseEnumDef");var ty=a(t=>"type"in t&&t.type==="string"?!1:"allOf"in t,"isJsonSchema7AllOfType");function _d(t,e){let r=[A(t.left._def,f(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),A(t.right._def,f(c({},e),{currentPath:[...e.currentPath,"allOf","1"]}))].filter(i=>!!i),n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,s=[];return r.forEach(i=>{if(ty(i))s.push(...i.allOf),i.unevaluatedProperties===void 0&&(n=void 0);else{let o=i;if("additionalProperties"in i&&i.additionalProperties===!1){let l=i,{additionalProperties:d}=l;o=Ai(l,["additionalProperties"])}else n=void 0;s.push(o)}}),s.length?c({allOf:s},n):void 0}a(_d,"parseIntersectionDef");function Td(t,e){let r=typeof t.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[t.value]}:{type:r==="bigint"?"integer":r,const:t.value}}a(Td,"parseLiteralDef");function Ns(t,e){var r,n,s,i,o;if(e.target==="openApi3"&&((r=t.keyType)==null?void 0:r._def.typeName)==="ZodEnum")return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((d,u)=>{var g;return f(c({},d),{[u]:(g=A(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"properties",u]})))!=null?g:{}})},{}),additionalProperties:!1};let l={type:"object",additionalProperties:(n=A(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?n:{}};if(e.target==="openApi3")return l;if(((s=t.keyType)==null?void 0:s._def.typeName)==="ZodString"&&((i=t.keyType._def.checks)!=null&&i.length)){let d=Object.entries(us(t.keyType._def,e)).reduce((u,[g,h])=>g==="type"?u:f(c({},u),{[g]:h}),{});return f(c({},l),{propertyNames:d})}else if(((o=t.keyType)==null?void 0:o._def.typeName)==="ZodEnum")return f(c({},l),{propertyNames:{enum:t.keyType._def.values}});return l}a(Ns,"parseRecordDef");function bd(t,e){if(e.mapStrategy==="record")return Ns(t,e);let r=A(t.keyType._def,f(c({},e),{currentPath:[...e.currentPath,"items","items","0"]}))||{},n=A(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"items","items","1"]}))||{};return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}a(bd,"parseMapDef");function wd(t){let e=t.values,n=Object.keys(t.values).filter(i=>typeof e[e[i]]!="number").map(i=>e[i]),s=Array.from(new Set(n.map(i=>typeof i)));return{type:s.length===1?s[0]==="string"?"string":"number":["string","number"],enum:n.filter(i=>typeof i=="string"||typeof i=="number")}}a(wd,"parseNativeEnumDef");function Pd(){return{not:{}}}a(Pd,"parseNeverDef");function xd(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}a(xd,"parseNullDef");var Ur={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function kd(t,e){if(e.target==="openApi3")return Oi(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in Ur&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((s,i)=>{let o=Ur[i._def.typeName];return o&&!s.includes(o)?[...s,o]:s},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((s,i)=>{let o=typeof i._def.value;switch(o){case"string":case"number":case"boolean":return[...s,o];case"bigint":return[...s,"integer"];case"object":if(i._def.value===null)return[...s,"null"];case"symbol":case"undefined":case"function":default:return s}},[]);if(n.length===r.length){let s=n.filter((i,o,l)=>l.indexOf(i)===o);return{type:s.length>1?s:s[0],enum:r.reduce((i,o)=>i.includes(o._def.value)?i:[...i,o._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,s)=>[...n,...s._def.values.filter(i=>!n.includes(i))],[])};return Oi(t,e)}a(kd,"parseUnionDef");var Oi=a((t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((s,i)=>A(s._def,f(c({},e),{currentPath:[...e.currentPath,e.unionStrategy,`${i}`]}))).filter(s=>!!s&&(!e.strictUnions||typeof s=="object"&&Object.keys(s).length>0)),n=e.discriminator&&t.typeName==="ZodDiscriminatedUnion"&&typeof t.discriminator=="string"?{discriminator:{propertyName:t.discriminator}}:{};if(r.length)return e.unionStrategy==="anyOf"?c({anyOf:r},n):c({oneOf:r},n)},"asUnionOf");function Sd(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length)){let n=t.innerType;if(e.target==="openApi3"){let i={type:Ur[n._def.typeName],nullable:!0};return Jn(n._def,e,i)}let s={type:[Ur[n._def.typeName],"null"]};return Jn(n._def,e,s)}if(e.target==="openApi3"){let n=A(t.innerType._def,f(c({},e),{currentPath:[...e.currentPath]}));return n&&f(c({},n),{nullable:!0})}let r=A(t.innerType._def,f(c({},e),{currentPath:[...e.currentPath,"anyOf","0"]}));return r&&{anyOf:[r,{type:"null"}]}}a(Sd,"parseNullableDef");function Ed(t,e){let r=c({type:"number"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"int":r.type="integer",ds(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?D(r,"minimum",n.value,n.message,e):D(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),D(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?D(r,"maximum",n.value,n.message,e):D(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),D(r,"maximum",n.value,n.message,e));break;case"multipleOf":D(r,"multipleOf",n.value,n.message,e);break}return r}a(Ed,"parseNumberDef");var ry=a((t,e)=>{var r;return t.unknownKeys instanceof O?(r=A(t.unknownKeys._def,f(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?r:!0:t.unknownKeys==="passthrough"},"getAdditionalProperties");function Od(t,e){let r=f(c({type:"object"},Object.entries(t.shape()).reduce((n,[s,i])=>{if(i===void 0||i._def===void 0)return n;let o=A(i._def,f(c({},e),{currentPath:[...e.currentPath,"properties",s],propertyPath:[...e.currentPath,"properties",s]}));return o===void 0?n:{properties:f(c({},n.properties),{[s]:o}),required:i.isOptional()?n.required:[...n.required,s]}},{properties:{},required:[]})),{additionalProperties:ry(t,e)});return r.required.length||delete r.required,r}a(Od,"parseObjectDef");var ny=a((t,e)=>{var r;if(e.currentPath.toString()===((r=e.propertyPath)==null?void 0:r.toString()))return A(t.innerType._def,e);let n=A(t.innerType._def,f(c({},e),{currentPath:[...e.currentPath,"anyOf","1"]}));return n?{anyOf:[{not:{}},n]}:{}},"parseOptionalDef"),sy=a((t,e)=>{if(e.pipeStrategy==="input")return A(t.in._def,e);if(e.pipeStrategy==="output")return A(t.out._def,e);let r=A(t.in._def,f(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),n=A(t.out._def,f(c({},e),{currentPath:[...e.currentPath,"allOf",r?"1":"0"]}));return{allOf:[r,n].filter(s=>s!==void 0)}},"parsePipelineDef");function Zd(t,e){return A(t.type._def,e)}a(Zd,"parsePromiseDef");function Id(t,e){let n={type:"array",uniqueItems:!0,items:A(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"items"]}))};return t.minSize&&D(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&D(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}a(Id,"parseSetDef");function Bd(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>A(r._def,f(c({},e),{currentPath:[...e.currentPath,"items",`${n}`]}))).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:A(t.rest._def,f(c({},e),{currentPath:[...e.currentPath,"additionalItems"]}))}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>A(r._def,f(c({},e),{currentPath:[...e.currentPath,"items",`${n}`]}))).reduce((r,n)=>n===void 0?r:[...r,n],[])}}a(Bd,"parseTupleDef");function Ad(){return{not:{}}}a(Ad,"parseUndefinedDef");function Rd(){return{}}a(Rd,"parseUnknownDef");var iy=a((t,e)=>A(t.innerType._def,e),"parseReadonlyDef");function Cd(t){return{$ref:t.uri}}a(Cd,"parseRefDef");function A(t,e,r=!1){let n=e.seen.get(t);if(n&&!r){let o=ay(n,e);if(o!==void 0)return o}let s={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,s);let i=ly(t,t.typeName,e);return i&&Jn(t,e,i),s.jsonSchema=i,i}a(A,"parseDef");var ay=a((t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:oy(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((r,n)=>e.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),{}):e.$refStrategy==="seen"?{}:void 0}},"get$ref"),oy=a((t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")},"getRelativePath"),ly=a((t,e,r)=>{switch(e){case"ZodString":return us(t,r);case"ZodNumber":return Ed(t,r);case"ZodObject":return Od(t,r);case"ZodBigInt":return pd(t,r);case"ZodBoolean":return fd(t);case"ZodDate":return md(t,r);case"ZodUndefined":return Ad();case"ZodNull":return xd(r);case"ZodArray":return ud(t,r);case"ZodUnion":case"ZodDiscriminatedUnion":return kd(t,r);case"ZodIntersection":return _d(t,r);case"ZodTuple":return Bd(t,r);case"ZodRecord":return Ns(t,r);case"ZodRef":return Cd(t);case"ZodLiteral":return Td(t,r);case"ZodEnum":return vd(t);case"ZodNativeEnum":return wd(t);case"ZodNullable":return Sd(t,r);case"ZodOptional":return ny(t,r);case"ZodMap":return bd(t,r);case"ZodSet":return Id(t,r);case"ZodLazy":return A(t.getter()._def,r);case"ZodPromise":return Zd(t,r);case"ZodNaN":case"ZodNever":return Pd();case"ZodEffects":return yd(t,r);case"ZodAny":return dd();case"ZodUnknown":return Rd();case"ZodDefault":return hd(t,r);case"ZodBranded":return gd(t,r);case"ZodReadonly":return iy(t,r);case"ZodCatch":return Qh(t,r);case"ZodPipeline":return sy(t,r);case"ZodFunction":case"ZodVoid":case"ZodSymbol":return;default:return(n=>{})(e)}},"selectParser"),Jn=a((t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),Object.assign(r,{[w]:c(c({},t[w]),r[w])}),r),"addMeta"),Zi={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"string",mapStrategy:"entries",definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",emailStrategy:"format:email",discriminator:!1,unionStrategy:"anyOf"},cy=a(t=>typeof t=="string"?f(c({},Zi),{name:t}):c(c({},Zi),t),"getDefaultOptions"),dy=a(t=>{let e=cy(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return f(c({},e),{currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([n,s])=>[s._def,{def:s._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))})},"getRefs"),uy=a((t,e)=>{var r;let n=dy(e),s=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((d,[u,g])=>{var h;return f(c({},d),{[u]:(h=A(g._def,f(c({},n),{currentPath:[...n.basePath,n.definitionPath,u]}),!0))!=null?h:{}})},{}):void 0,i=typeof e=="string"?e:e?.name,o=(r=A(t._def,i===void 0?n:f(c({},n),{currentPath:[...n.basePath,n.definitionPath,i]}),!1))!=null?r:{},l=i===void 0?s?f(c({},o),{[n.definitionPath]:s}):o:{$ref:[...n.$refStrategy==="relative"?[]:n.basePath,n.definitionPath,i].join("/"),[n.definitionPath]:f(c({},s),{[i]:o})};return n.target==="jsonSchema7"?l.$schema="http://json-schema.org/draft-07/schema#":n.target==="jsonSchema2019-09"&&(l.$schema="https://json-schema.org/draft/2019-09/schema#"),l},"zodToJsonSchema"),py=a((t,e={target:"openApi3"})=>{let r=uy(t,e);return e.$schemaUrl===!1?delete r.$schema:typeof e.$schemaUrl=="string"&&(r.$schema=e.$schemaUrl),r},"toJSONSchemaLegacy");var gt=(t,e)=>{let r=t._def,n=e._def;if(r.typeName===y.ZodFirstPartyTypeKind.ZodObject&&n.typeName===y.ZodFirstPartyTypeKind.ZodObject){let s=r.shape(),i=n.shape();return y.object({...s,...i})}if(r.typeName===y.ZodFirstPartyTypeKind.ZodRecord&&n.typeName===y.ZodFirstPartyTypeKind.ZodRecord)return y.record(y.intersection(r.valueType,n.valueType));throw new Error("Cannot merge object schemas with record schemas")},Dd=y;var ne=y.string().min(1),Nd=y.object({text:ne}),Md=y.object({markdown:ne}),$d=y.object({imageUrl:ne}),jd=y.object({audioUrl:ne}),Kd=y.object({videoUrl:ne}),Ud=y.object({fileUrl:ne,title:ne.optional()}),zd=y.object({latitude:y.number(),longitude:y.number(),address:y.string().optional(),title:y.string().optional()}),Fd=y.object({title:ne,subtitle:ne.optional(),imageUrl:ne.optional(),actions:y.array(y.object({action:y.enum(["postback","url","say"]),label:ne,value:ne}))}),Hd=y.object({text:ne,options:y.array(y.object({label:ne,value:ne}))}),fy=y.object({items:y.array(Fd)}),gy=y.union([y.object({type:y.literal("text"),payload:Nd}),y.object({type:y.literal("markdown"),payload:Md}),y.object({type:y.literal("image"),payload:$d}),y.object({type:y.literal("audio"),payload:jd}),y.object({type:y.literal("video"),payload:Kd}),y.object({type:y.literal("file"),payload:Ud}),y.object({type:y.literal("location"),payload:zd})]),my=y.object({items:y.array(gy)}),hy={schema:Md},yy={text:{schema:Nd},image:{schema:$d},audio:{schema:jd},video:{schema:Kd},file:{schema:Ud},location:{schema:zd},carousel:{schema:fy},card:{schema:Fd},dropdown:{schema:Hd},choice:{schema:Hd},bloc:{schema:my}};var vy={HIDDEN_IN_STUDIO:{bpActionHiddenInStudio:"true"},AWAIT_RETURN:{bpActionAwaitReturn:"true"}};var Wd=require("browser-or-node");var $s=console;function le(t){if(!t.body)throw new Error("Missing body");return JSON.parse(t.body)}async function Vt(t,e=8072,r=wy){if(!Wd.isNode)throw new Error("This function can only be called in Node.js");let s=require("http").createServer(async(i,o)=>{try{let l=await _y(i);if(l.path==="/health"){o.writeHead(200).end("ok");return}let d=await t(l);o.writeHead(d?.status??200,d?.headers??{}).end(d?.body??"{}")}catch(l){let d=l instanceof Error?l.message:String(l);$s.error("Error while handling request",{error:d??"Internal error occured"}),o.writeHead(500).end(JSON.stringify({error:d??"Internal error occured"}))}});return s.listen(e,()=>r(e)),s}async function _y(t){let e=await by(t),r={};for(let s=0;s<t.rawHeaders.length;s+=2){let i=t.rawHeaders[s].toLowerCase(),o=t.rawHeaders[s+1];r[i]=o}let n=new URL(t.url??"",t.headers.host?`http://${t.headers.host}`:"http://botpress.cloud");return{body:e,path:n.pathname,query:Ty(n.search,"?"),headers:r,method:t.method?.toUpperCase()??"GET"}}function Ty(t,e){return t.indexOf(e)===0?t.slice(e.length):t}async function by(t){return new Promise((e,r)=>{if(t.method!=="POST"&&t.method!=="PUT"&&t.method!=="PATCH")return e(void 0);let n="";t.on("data",s=>n+=s.toString()),t.on("error",s=>r(s)),t.on("end",()=>e(n))})}function wy(t){$s.info(`Listening on port ${t}`)}var On=require("@botpress/client");var N={};Xe(N,{mapKeys:()=>ky,mapValues:()=>xy,mergeRecords:()=>Ey,pairs:()=>gn,stripUndefinedProps:()=>Sy,values:()=>Py});var gn=t=>Object.entries(t),Py=t=>Object.values(t),xy=(t,e)=>Object.fromEntries(gn(t).map(([r,n])=>[r,e(n,r)])),ky=(t,e)=>Object.fromEntries(gn(t).map(([r,n])=>[e(r),n])),Sy=t=>Object.fromEntries(gn(t).filter(([,e])=>e!==void 0)),Ey=(t,e,r)=>{let n=[...Object.keys(t),...Object.keys(e)],s=[...new Set(n)],i={};for(let o of s){let l=t[o],d=e[o];l&&d?i[o]=r(l,d):l?i[o]=l:d&&(i[o]=d)}return i};var E={};Xe(E,{safePush:()=>Oy,unique:()=>Zy});var Oy=(t,...e)=>t?[...t,...e]:[...e],Zy=t=>Array.from(new Set(t));var Y={};Xe(Y,{setName:()=>Iy});var Iy=(t,e)=>(Object.defineProperty(t,"name",{value:e}),t);var Ld=t=>{let{name:e,version:r}=t,n={actions:{},events:{},channels:{}},s={name:e,version:r,entities:N.mapValues(t.entities,o=>({name:o.name})),actions:{},events:{},channels:{}},i=N.mapValues(t.entities,o=>o.schema);for(let[o,l]of Object.entries(t.definition.actions??{})){let d=l.input.schema.dereference(i),u=l.output.schema.dereference(i),g=t.actions?.[o]?.name??o;n.actions[g]={...l,...t.actions?.[o]??{},input:{schema:d},output:{schema:u}},s.actions[o]={name:g}}for(let[o,l]of Object.entries(t.definition.events??{})){let d=l.schema.dereference(i),u=t.events?.[o]?.name??o;n.events[u]={...l,...t.events?.[o]??{},schema:d},s.events[o]={name:u}}for(let[o,l]of Object.entries(t.definition.channels??{})){let d={};for(let[g,h]of Object.entries(l.messages)){let T=h.schema.dereference(i);d[g]={...h,schema:T}}let u=t.channels?.[o]?.name??o;n.channels[u]={...l,...t.channels?.[o]??{},message:{...l.message??{},tags:{...l.message?.tags??{},...t.channels?.[o]?.message?.tags??{}}},conversation:{...l.conversation??{},tags:{...l.conversation?.tags??{},...t.channels?.[o]?.conversation?.tags??{}}},messages:d},s.channels[o]={name:u}}return{resolved:n,statement:s}};var qd="4.20.1";var Ee=qd;var mn=Symbol("schemaName"),Vd=t=>t?N.mapValues(t,(r,n)=>({...r,[mn]:n})):{},Gd=t=>mn in t&&t[mn]!==void 0,Jd=t=>t[mn];var hn=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.readme=e.readme,this.title=e.title,this.identifier=e.identifier,this.description=e.description,this.configuration=e.configuration,this.configurations=e.configurations,this.events=e.events,this.actions=e.actions,this.channels=e.channels,this.states=e.states,this.user=e.user,this.secrets=e.secrets,this.entities=e.entities,this.interfaces=e.interfaces,this.__advanced=e.__advanced,this.attributes=e.attributes}name;version;title;description;icon;readme;configuration;configurations;events;actions;channels;states;user;secrets;identifier;entities;interfaces;__advanced;attributes;get metadata(){return{sdkVersion:Ee}}extend(e,r){let{entities:n,actions:s,events:i,channels:o}=this._callBuilder(e,r),l=this;l.interfaces??={};let d=Object.values(n).map(T=>T.name),u=d.length===0?e.name:`${e.name}<${d.join(",")}>`,{resolved:g,statement:h}=Ld({...e,entities:n,actions:N.stripUndefinedProps(s),events:N.stripUndefinedProps(i),channels:N.stripUndefinedProps(o)});return l.actions=N.mergeRecords(l.actions??{},g.actions,this._mergeActions),l.channels=N.mergeRecords(l.channels??{},g.channels,this._mergeChannels),l.events=N.mergeRecords(l.events??{},g.events,this._mergeEvents),l.interfaces[u]={id:e.id,...h},this}_callBuilder(e,r){let s={entities:Vd(this.entities)},i=r(s),o=N.pairs(i.entities).find(([d,u])=>!Gd(u));if(o)throw new Error(`Cannot extend interface "${e.name}" with entity "${o[0]}"; the provided schema is not part of the integration's entities.`);return{entities:N.mapValues(i.entities,d=>({name:Jd(d),schema:d.schema})),actions:i.actions??{},events:i.events??{},channels:i.channels??{}}}_mergeActions=(e,r)=>({...e,...r,input:{schema:gt(e.input.schema,r.input.schema)},output:{schema:gt(e.output.schema,r.output.schema)}});_mergeEvents=(e,r)=>({...e,...r,schema:gt(e.schema,r.schema)});_mergeChannels=(e,r)=>{let n=N.mergeRecords(e.messages,r.messages,this._mergeMessage),s;(e.conversation||r.conversation)&&(s={tags:{...e.conversation?.tags,...r.conversation?.tags}});let i;return(e.message||r.message)&&(i={tags:{...e.message?.tags,...r.message?.tags}}),{...e,...r,messages:n,conversation:s,message:i}};_mergeMessage=(e,r)=>({schema:gt(e.schema,r.schema)})};var be=require("@botpress/client");var Yd=In(require("@botpress/client")),yn={retries:3,retryCondition:t=>Yd.axiosRetry.isNetworkOrIdempotentRequestError(t)||[429,502].includes(t.response?.status??0),retryDelay:(t,e)=>(Ay(e.response?.headers??{})??t)*1e3},Ay=t=>{let e=["RateLimit-Reset","X-RateLimit-Reset","Retry-After","ratelimit-reset","x-ratelimit-reset","retry-after"];for(let r of e){let n=t[r];if(n!==void 0)return Ry(String(n))}},Ry=t=>{let e=Cy(t)?Dy(t):t.length>0?parseInt(t,10):void 0;return e===void 0||isNaN(e)?void 0:e},Cy=t=>t.includes(" "),Dy=t=>{let e=Hy(t);if(!e)return;let r=new Date;return Math.max(0,Math.floor((e.getTime()-r.getTime())/1e3))},Hy=t=>{let e=new Date(t);return isNaN(e.getTime())?void 0:e};var mt=class{constructor(e){this._client=e}get _inner(){return this._client}createConversation=(e=>this._client.createConversation(e));getConversation=(e=>this._client.getConversation(e));listConversations=(e=>this._client.listConversations(e));getOrCreateConversation=(e=>this._client.getOrCreateConversation(e));updateConversation=(e=>this._client.updateConversation(e));deleteConversation=(e=>this._client.deleteConversation(e));listParticipants=(e=>this._client.listParticipants(e));addParticipant=(e=>this._client.addParticipant(e));getParticipant=(e=>this._client.getParticipant(e));removeParticipant=(e=>this._client.removeParticipant(e));createEvent=(e=>this._client.createEvent(e));getEvent=(e=>this._client.getEvent(e));listEvents=(e=>this._client.listEvents(e));createMessage=(e=>this._client.createMessage(e));getOrCreateMessage=(e=>this._client.getOrCreateMessage(e));getMessage=(e=>this._client.getMessage(e).then(r=>r));updateMessage=(e=>this._client.updateMessage(e).then(r=>r));listMessages=(e=>this._client.listMessages(e));deleteMessage=(e=>this._client.deleteMessage(e));createUser=(e=>this._client.createUser(e));getUser=(e=>this._client.getUser(e));listUsers=e=>this._client.listUsers(e);getOrCreateUser=(e=>this._client.getOrCreateUser(e));updateUser=(e=>this._client.updateUser(e));deleteUser=e=>this._client.deleteUser(e);getState=(e=>this._client.getState(e));setState=(e=>this._client.setState(e));getOrSetState=(e=>this._client.getOrSetState(e));patchState=(e=>this._client.patchState(e));configureIntegration=e=>this._client.configureIntegration(e);uploadFile=e=>this._client.uploadFile(e);upsertFile=e=>this._client.upsertFile(e);deleteFile=e=>this._client.deleteFile(e);listFiles=e=>this._client.listFiles(e);getFile=e=>this._client.getFile(e);updateFileMetadata=e=>this._client.updateFileMetadata(e);trackAnalytics=e=>this._client.trackAnalytics(e)};var vn=class{_cost=0;get cost(){return this._cost}setCost(e){this._cost=e}toJSON(){return{cost:this.cost}}};var Oe="#",_n="x-bot-id",Xd="x-bot-user-id",Qd="x-integration-id",eu="x-integration-alias",tu="x-webhook-id",ru="x-bp-configuration-type",Tn="x-bp-configuration",bn="x-bp-operation",nu="x-bp-type";var ce=t=>{throw t instanceof Error?t:new Error(t)};var d_=y.enum(["webhook_received","message_created","action_triggered","register","unregister","ping","create_user","create_conversation"]),su=t=>({botId:t[_n]||ce("Missing bot header"),botUserId:t[Xd]||ce("Missing bot user header"),integrationId:t[Qd]||ce("Missing integration header"),integrationAlias:t[eu]||ce("Missing integration alias header"),webhookId:t[tu]||ce("Missing webhook header"),operation:t[bn]||ce("Missing operation header"),configurationType:t[ru]??null,configuration:JSON.parse(Buffer.from(t[Tn]||ce("Missing configuration header"),"base64").toString("utf-8"))});var iu=In(require("util")),ht=class{defaultOptions;constructor(e){this.defaultOptions=e}info(...e){this._log("info",e)}debug(...e){this._log("debug",e)}warn(...e){this._log("warn",e)}error(...e){this._log("error",e)}_log(e,r){this._getConsoleMethod(e)(this._serializeMessage(r))}_serializeMessage(e){let r=iu.default.format(...e);return process.env.BP_LOG_FORMAT==="json"?this.getJsonMessage(r):r}getJsonMessage(e){return JSON.stringify({msg:e,options:this.defaultOptions})}_getConsoleMethod(e){switch(e){case"debug":return console.debug;case"warn":return console.warn;case"error":return console.error;default:return console.info}}};var yt=class t extends ht{constructor(e){super({visibleToBotOwners:!0,...e})}with(e){return new t({...this.defaultOptions,...e})}withUserId(e){return this.with({userId:e})}withConversationId(e){return this.with({conversationId:e})}withVisibleToBotOwners(e){return this.with({visibleToBotOwners:e})}forBot(){return this.withVisibleToBotOwners(!0)}getJsonMessage(e){return JSON.stringify({msg:e,visible_to_bot_owner:this.defaultOptions.visibleToBotOwners,options:this.defaultOptions})}};var Ny=t=>["traceparent","tracestate","sentry-trace"].reduce((e,r)=>(t[r]&&(e[r]=t[r]),e),{}),My=(t,e,r)=>{let[,n]=(e.headers.traceparent||"").split("-"),s=new be.Client({botId:t.botId,integrationId:t.integrationId,integrationAlias:t.integrationAlias,retry:yn,headers:Ny(e.headers)}),i=new mt(s),o=new yt({traceId:n});return{ctx:t,req:e,client:i,logger:o,instance:r}},$y=async t=>{let{ctx:e}=t;switch(e.operation){case"webhook_received":return await Ky(t);case"register":return await Uy(t);case"unregister":return await zy(t);case"message_created":return await Ly(t);case"action_triggered":return await qy(t);case"ping":return await jy(t);case"create_user":return await Fy(t);case"create_conversation":return await Wy(t);default:throw new be.InvalidPayloadError(`Unknown operation ${e.operation}`)}},au=t=>async e=>{let r=su(e.headers),n=My(r,e,t),{logger:s}=n;try{let i;return i=await Vy(n),i?{...i,status:i.status??200}:(i=await $y(n),i?{...i,status:i.status??200}:{status:200})}catch(i){if((0,be.isApiError)(i)){let l=i.type==="Runtime"?i:new be.RuntimeError(i.message,i);return s.forBot().error(l.message),{status:l.code,body:JSON.stringify(l.toJSON())}}console.error(i);let o=new be.RuntimeError("An unexpected error occurred in the integration. Bot owners: Check logs for more informations. Integration owners: throw a RuntimeError to return a custom error message instead.");return s.forBot().error(o.message),{status:o.code,body:JSON.stringify(o.toJSON())}}},jy=async t=>{},Ky=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{let{req:i}=le(r);return s.webhook({client:t,ctx:e,req:i,logger:n})},Uy=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.register)return;let{webhookUrl:i}=le(r);await s.register({client:t,ctx:e,webhookUrl:i,logger:n})},zy=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.unregister)return;let{webhookUrl:i}=le(r);await s.unregister({ctx:e,webhookUrl:i,client:t,logger:n})},Fy=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.createUser)return;let{tags:i}=le(r);return await s.createUser({ctx:e,client:t,tags:i,logger:n})},Wy=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.createConversation)return;let{channel:i,tags:o}=le(r);return await s.createConversation({ctx:e,client:t,channel:i,tags:o,logger:n})},Ly=async({ctx:t,req:e,client:r,logger:n,instance:s})=>{let{conversation:i,user:o,type:l,payload:d,message:u}=le(e),g=s.channels[i.channel];if(!g)throw new Error(`Channel ${i.channel} not found`);let h=g.messages[l];if(!h)throw new Error(`Message of type ${l} not found in channel ${i.channel}`);await h({ctx:t,conversation:i,message:u,user:o,type:l,client:r,payload:d,ack:async({tags:Z})=>{await r.updateMessage({id:u.id,tags:Z})},logger:n})},qy=async({req:t,ctx:e,client:r,logger:n,instance:s})=>{let{input:i,type:o}=le(t);if(!o)throw new Error("Missing action type");let l=s.actions[o];if(!l)throw new Error(`Action ${o} not found`);let d=new vn,g={output:await l({ctx:e,input:i,client:r,type:o,logger:n,metadata:d}),meta:d.toJSON()};return{body:JSON.stringify(g)}},Vy=async({instance:t,client:e,ctx:r,logger:n,req:s})=>{let i=t.unknownOperationHandler;if(i)return await i({client:e,ctx:r,logger:n,req:s})};var wn=class{constructor(e){this.props=e;this.actions=e.actions,this.channels=e.channels,this.register=e.register,this.unregister=e.unregister,this.createUser=e.createUser,this.createConversation=e.createConversation,this.webhook=e.handler,this.unknownOperationHandler=e.__advanced?.unknownOperationHandler}actions;channels;register;unregister;createUser;createConversation;webhook;unknownOperationHandler;handler=au(this);start=e=>Vt(this.handler,e)};var Pn=class{constructor(e){this.props=e;this.integrations=e.integrations,this.plugins=e.plugins,this.user=e.user,this.conversation=e.conversation,this.message=e.message,this.states=e.states,this.configuration=e.configuration,this.events=e.events,this.recurringEvents=e.recurringEvents,this.actions=e.actions,this.tables=e.tables,this.workflows=e.workflows,this.attributes=e.attributes,this.__advanced=e.__advanced,this.withPlugins={user:e.user,conversation:e.conversation,message:e.message,states:e.states,events:e.events,recurringEvents:e.recurringEvents,actions:e.actions,tables:e.tables,workflows:e.workflows}}integrations;plugins;user;conversation;message;states;configuration;events;recurringEvents;actions;tables;workflows;attributes;__advanced;withPlugins;get metadata(){return{sdkVersion:Ee}}addIntegration(e,r){let n=this;n.integrations||(n.integrations={});let s=r?.alias??e.name.replace("/","-");if(n.integrations[s])throw new Error(`Another integration with alias "${s}" is already installed in the bot`);return n.integrations[s]={...e,alias:s,enabled:r?.enabled,configurationType:r?.configurationType,configuration:r?.configuration,disabledChannels:r?.disabledChannels},this}addPlugin(e,r){let n=this;n.plugins||(n.plugins={});let s=r.alias??e.name.replace("/","-");if(n.plugins[s])throw new Error(`Another plugin with alias "${s}" is already installed in the bot`);return n.plugins[s]={...e,alias:s,configuration:r.configuration,interfaces:r.interfaces},n.withPlugins.user=this._mergeUser(n.withPlugins.user,e.definition.user),n.withPlugins.conversation=this._mergeConversation(n.withPlugins.conversation,e.definition.conversation),n.withPlugins.message=this._mergeMessage(n.withPlugins.message,e.definition.message),n.withPlugins.recurringEvents=this._mergeRecurringEvents(n.withPlugins.recurringEvents,e.definition.recurringEvents),n.withPlugins.tables=this._mergeTables(n.withPlugins.tables,e.definition.tables),n.withPlugins.workflows=this._mergeWorkflows(n.withPlugins.workflows,e.definition.workflows),n.withPlugins.states=this._mergeStates(n.withPlugins.states,this._prefixKeysWithPluginAlias(e.definition.states,s)),n.withPlugins.events=this._mergeEvents(n.withPlugins.events,this._prefixKeysWithPluginAlias(e.definition.events,s)),n.withPlugins.actions=this._mergeActions(n.withPlugins.actions,this._prefixKeysWithPluginAlias(e.definition.actions,s)),this}_mergeUser=(e,r)=>({tags:{...e?.tags,...r?.tags}});_mergeConversation=(e,r)=>({tags:{...e?.tags,...r?.tags}});_mergeMessage=(e,r)=>({tags:{...e?.tags,...r?.tags}});_mergeStates=(e,r)=>({...e,...r});_mergeEvents=(e,r)=>({...e,...r});_mergeRecurringEvents=(e,r)=>({...e,...r});_mergeActions=(e,r)=>({...e,...r});_mergeTables=(e,r)=>({...e,...r});_mergeWorkflows=(e,r)=>({...e,...r});_prefixKeysWithPluginAlias=(e,r)=>N.mapKeys(e??{},n=>`${r}${Oe}${n}`);dereferencePluginEntities(){let e=this._buildZuiReferenceMap();return{...this,withPlugins:{...this.withPlugins,events:this._dereferenceDefinitionSchemas(this.withPlugins.events,e),states:this._dereferenceDefinitionSchemas(this.withPlugins.states,e),tables:this._dereferenceDefinitionSchemas(this.withPlugins.tables,e),actions:this._dereferenceActionDefinitionSchemas(this.withPlugins.actions,e)},plugins:Object.fromEntries(Object.entries(this.plugins??{}).map(([r,n])=>[r,{...n,definition:{...n.definition,configuration:this._dereferenceDefinitionSchema(n.definition.configuration,e),events:this._dereferenceDefinitionSchemas(n.definition.events,e),states:this._dereferenceDefinitionSchemas(n.definition.states,e),tables:this._dereferenceDefinitionSchemas(n.definition.tables,e),actions:this._dereferenceActionDefinitionSchemas(n.definition.actions,e)}}]))}}_buildZuiReferenceMap(){let e={},r=Object.entries(this.plugins??{});for(let[n,s]of r){let i=Object.entries(s.interfaces??{});for(let[o,l]of i){let d=this.integrations?.[l.name];if(!d)throw new Error(`Interface with alias "${o}" of plugin with alias "${n}" references integration "${l.name}" which is not installed`);let u=Object.entries(l.entities??{});for(let[g,{name:h}]of u){let T=d.definition.entities?.[h]?.schema;if(!T)throw new Error(`Interface entity "${h}" does not exist in integration "${d.name}"`);e[`interface:${o}/entities/${g}`]=T}}}return e}_dereferenceZuiSchema(e,r){return e.dereference(r)}_dereferenceDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,this._dereferenceDefinitionSchema(s,r)]))}_dereferenceDefinitionSchema(e,r){return e&&{...e,schema:this._dereferenceZuiSchema(e.schema,r)}}_dereferenceActionDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,{...s,input:{schema:this._dereferenceZuiSchema(s.input.schema,r)},output:{schema:this._dereferenceZuiSchema(s.output.schema,r)}}]))}};var Ye=require("@botpress/client");var vt=class t extends ht{constructor(e){super({...e})}with(e){return new t({...this.defaultOptions,...e})}withUserId(e){return this.with({userId:e})}withConversationId(e){return this.with({conversationId:e})}withWorkflowId(e){return this.with({workflowId:e})}withEventId(e){return this.with({eventId:e})}withMessageId(e){return this.with({messageId:e})}};var fe=class{constructor(e,r={before:{},after:{}}){this._client=e;this._hooks=r}get _inner(){return this._client}getConversation=(e=>this._run("getConversation",e));listConversations=(e=>this._run("listConversations",e));updateConversation=(e=>this._run("updateConversation",e));deleteConversation=(e=>this._run("deleteConversation",e));listParticipants=(e=>this._run("listParticipants",e));addParticipant=(e=>this._run("addParticipant",e));getParticipant=(e=>this._run("getParticipant",e));removeParticipant=(e=>this._run("removeParticipant",e));createEvent=(e=>this._run("createEvent",e));getEvent=(e=>this._run("getEvent",e));listEvents=(e=>this._run("listEvents",e));createMessage=(e=>this._run("createMessage",e));getOrCreateMessage=(e=>this._run("getOrCreateMessage",e));getMessage=(e=>this._run("getMessage",e));updateMessage=(e=>this._run("updateMessage",e));listMessages=(e=>this._run("listMessages",e));deleteMessage=(e=>this._run("deleteMessage",e));getUser=(e=>this._run("getUser",e));listUsers=(e=>this._run("listUsers",e));updateUser=(e=>this._run("updateUser",e));deleteUser=(e=>this._run("deleteUser",e));getState=(e=>this._run("getState",e));setState=(e=>this._run("setState",e));getOrSetState=(e=>this._run("getOrSetState",e));patchState=(e=>this._run("patchState",e));callAction=(e=>this._run("callAction",e));uploadFile=(e=>this._run("uploadFile",e));upsertFile=(e=>this._run("upsertFile",e));deleteFile=(e=>this._run("deleteFile",e));listFiles=(e=>this._run("listFiles",e));getFile=(e=>this._run("getFile",e));updateFileMetadata=(e=>this._run("updateFileMetadata",e));searchFiles=(e=>this._run("searchFiles",e));trackAnalytics=(e=>this._run("trackAnalytics",e));getTableRow=(e=>this._run("getTableRow",e));createTableRows=(e=>this._run("createTableRows",e));findTableRows=(e=>this._run("findTableRows",e));deleteTableRows=(e=>this._run("deleteTableRows",e));updateTableRows=(e=>this._run("updateTableRows",e));upsertTableRows=(e=>this._run("upsertTableRows",e));createWorkflow=(e=>this._run("createWorkflow",e));getOrCreateWorkflow=(e=>this._run("getOrCreateWorkflow",e));getWorkflow=(e=>this._run("getWorkflow",e));updateWorkflow=(e=>this._run("updateWorkflow",e));deleteWorkflow=(e=>this._run("deleteWorkflow",e));listWorkflows=(e=>this._run("listWorkflows",e));createConversation=e=>this._client.createConversation(e);getOrCreateConversation=e=>this._client.getOrCreateConversation(e);createUser=e=>this._client.createUser(e);getOrCreateUser=e=>this._client.getOrCreateUser(e);_run=async(e,r)=>{let n=this._hooks.before[e];n&&(r=await n(r));let s=await this._client[e](r),i=this._hooks.after[e];return i&&(s=await i(s,r)),s}};var Gy=y.enum(["event_received","register","unregister","ping","action_triggered"]),ou=t=>({botId:t[_n]||ce("Missing bot id header"),operation:Gy.parse(t[bn]),type:t[nu]||ce("Missing type header"),configuration:JSON.parse(Buffer.from(t[Tn]||ce("Missing configuration header"),"base64").toString("utf-8"))});var X={status:200};var Ks=t=>{switch(t){case"workflow_continued":return"continued";case"workflow_started":return"started";case"workflow_timedout":return"timed_out";default:throw new Error(`Unsupported workflow update type: ${t}`)}};var Jy=["child_workflow_deleted","child_workflow_finished","workflow_timedout","workflow_started","workflow_continued"],lu=async(t,e)=>{if(t.ctx.type!=="workflow_update"||!Jy.includes(e.payload.type))throw new Error("Unexpected event type");let r={...t,logger:Yy(t,e)};if(!e.payload.workflow.name)return r.logger.warn("Received workflow update event without a workflow name. Assuming this workflow was not defined by the bot.",e.payload.workflow),X;switch(e.payload.type){case"child_workflow_deleted":case"child_workflow_finished":r.logger.info(`Received child workflow event "${e.payload.type}", but child workflows are not yet supported`);break;case"workflow_timedout":case"workflow_started":case"workflow_continued":return await Xy(r,e);default:e.payload.type}return X},Yy=(t,e)=>t.logger.with({eventId:e.id,workflowId:e.payload.workflow.id,conversationId:e.payload.conversation?.id,userId:e.payload.user?.id}),Xy=async(t,e)=>{let r=Ks(e.payload.type),n=t.self.workflowHandlers[r]?.[e.payload.workflow.name];if(!n||n.length===0)return t.logger.warn(`No ${r} handler found for workflow "${e.payload.workflow.name}"`),X;let{updatedWorkflow:s}=await Qy(t,e);return s.status==="pending"&&t.logger.warn(`Workflow "${e.payload.workflow.name}" is still in pending status after processing "${r}" event. This may indicate that the workflow was not properly acknowledged or terminated by the handler. `),X},Qy=async(t,e)=>{let r=Ks(e.payload.type),n=t.self.workflowHandlers[r]?.[e.payload.workflow.name],s=structuredClone(e.payload.workflow);for(let i of n??[])s=await i({...t,event:e,conversation:e.payload.conversation,user:e.payload.user,workflow:s});return{updatedWorkflow:s}};var cu=t=>async e=>{let r=ou(e.headers),n=new vt,s=new Ye.Client({botId:r.botId,retry:yn}),i=new fe(s,{before:{createMessage:async l=>{let d=t.hookHandlers.before_outgoing_message[l.type]??[];for(let u of d){let g=new fe(s);l=(await u({client:g,ctx:r,logger:n.with({conversationId:l.conversationId,userId:l.userId}),data:l}))?.data??l}return l},callAction:async l=>{let d=t.hookHandlers.before_outgoing_call_action[l.type]??[];for(let u of d){let g=new fe(s);l=(await u({client:g,ctx:r,logger:n,data:l}))?.data??l}return l}},after:{createMessage:async l=>{let d=t.hookHandlers.after_outgoing_message[l.message.type]??[];for(let u of d){let g=new fe(s);l=(await u({client:g,ctx:r,logger:n.with({messageId:l.message.id,conversationId:l.message.conversationId,userId:l.message.userId}),data:l}))?.data??l}return l},callAction:async(l,d)=>{let{type:u}=d,g=t.hookHandlers.after_outgoing_call_action[u]??[];for(let h of g){let T=new fe(s);l=(await h({client:T,ctx:r,logger:n,data:{type:u,...l}}))?.data??l}return l}}}),o={req:e,ctx:r,logger:n,client:i,self:t};try{switch(r.operation){case"action_triggered":return await sv(o);case"event_received":return await nv(o);case"register":return await tv(o);case"unregister":return await rv(o);case"ping":return await ev(o);default:throw new Error(`Unknown operation ${r.operation}`)}}catch(l){let d=l instanceof Error?l:new Error(String(l));if((0,Ye.isApiError)(d)){let g=d.type==="Runtime"?d:new Ye.RuntimeError(d.message,d);return n.error(g.message),{status:g.code,body:JSON.stringify(g.toJSON())}}let u=new Ye.RuntimeError("An unexpected error occurred in the bot.",d);return n.error(u.message,d),{status:u.code,body:JSON.stringify(u.toJSON())}}},ev=async t=>X,tv=async t=>X,rv=async t=>X,nv=async t=>{let{ctx:e,logger:r,req:n,client:s,self:i}=t,o={client:s,ctx:e,logger:r},l=le(n);if(o.logger=o.logger.with({eventId:l.event.id,messageId:l.event.messageId,conversationId:l.event.conversationId,userId:l.event.userId}),e.type==="workflow_update")return await lu(t,l.event);if(e.type==="message_created"){let Z=l.event,k=Z.payload.message;o.logger=o.logger.with({messageId:k.id,conversationId:k.conversationId,userId:k.userId});let K=i.hookHandlers.before_incoming_message[k.type]??[];for(let ue of K){let ae=await ue({...o,data:k});if(k=ae?.data??k,ae?.stop)return X}let F={...o,user:Z.payload.user,conversation:Z.payload.conversation,message:k,event:Z},Q=i.messageHandlers[k.type]??[];for(let ue of Q)await ue(F);let ie=i.hookHandlers.after_incoming_message[k.type]??[];for(let ue of ie){let ae=await ue({...o,data:k});if(k=ae?.data??k,ae?.stop)return X}return X}if(e.type==="state_expired"){let k=l.event.payload.state,K={...o,state:k},F=i.stateExpiredHandlers[k.name]??[];for(let Q of F)await Q(K);return X}let d=l.event,u=i.hookHandlers.before_incoming_event[d.type]??[];for(let Z of u){let k=await Z({...o,data:d});if(d=k?.data??d,k?.stop)return X}let g={...o,event:d},h=i.eventHandlers[d.type]??[];for(let Z of h)await Z(g);let T=i.hookHandlers.after_incoming_event[d.type]??[];for(let Z of T){let k=await Z({...o,data:d});if(d=k?.data??d,k?.stop)return X}return X},sv=async({ctx:t,logger:e,req:r,client:n,self:s})=>{let{input:i,type:o}=le(r);if(!o)throw new Error("Missing action type");let l=s.hookHandlers.before_incoming_call_action[o]??[];for(let T of l){let Z=await T({ctx:t,logger:e,client:n,data:{type:o,input:i}});i=Z?.data?.input??i,o=Z?.data?.type??o}let d=s.actionHandlers[o];if(!d)throw new Error(`Action ${o} not found`);let u=await d({ctx:t,logger:e,input:i,client:n,type:o}),g=s.hookHandlers.after_incoming_call_action[o]??[];for(let T of g){let Z=await T({ctx:t,logger:e,client:n,data:{type:o,output:u}});o=Z?.data?.type??o,u=Z?.data?.output??u}return{status:200,body:JSON.stringify({output:u})}};var we=t=>new Proxy({},{get:(e,r)=>({listInstances:{all:n=>Ze({workflowName:r,client:t,input:n}),running:n=>Ze({workflowName:r,client:t,input:n,statuses:["in_progress"]}),scheduled:n=>Ze({workflowName:r,client:t,input:n,statuses:["pending","listening"]}),allFinished:n=>Ze({workflowName:r,client:t,input:n,statuses:["completed","cancelled","failed","timedout"]}),cancelled:n=>Ze({workflowName:r,client:t,input:n,statuses:["cancelled"]}),failed:n=>Ze({workflowName:r,client:t,input:n,statuses:["failed"]}),succeeded:n=>Ze({workflowName:r,client:t,input:n,statuses:["completed"]}),timedOut:n=>Ze({workflowName:r,client:t,input:n,statuses:["timedout"]})},startNewInstance:async n=>{let{workflow:s}=await t.createWorkflow({name:r,status:"pending",...n});return{workflow:de({client:t,workflow:s})}}})}),Ze=async t=>{let e=await t.client.listWorkflows({name:t.workflowName,statuses:t.statuses,...t.input});return{...e,workflows:e.workflows.map(r=>de({client:t.client,workflow:r}))}},de=t=>{let e=!1;return{...t.workflow,async update(r){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,...r});return await t.onWorkflowUpdate?.(n),{workflow:de({...t,workflow:n})}},async acknowledgeStartOfProcessing(){if(!t.event||t.workflow.status!=="pending"||e)return{workflow:de(t)};let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,status:"in_progress",eventId:t.event.id});return e=!0,await t.onWorkflowUpdate?.(r),{workflow:de({...t,workflow:r})}},async setFailed({failureReason:r}){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,status:"failed",failureReason:r});return await t.onWorkflowUpdate?.(n),{workflow:de({...t,workflow:n})}},async setCompleted({output:r}={}){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,status:"completed",output:r});return await t.onWorkflowUpdate?.(n),{workflow:de({...t,workflow:n})}},async cancel(){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,status:"cancelled"});return await t.onWorkflowUpdate?.(r),{workflow:de({...t,workflow:r})}}}};var xn=class{constructor(e){this.props=e;this._actionHandlers=e.actions,this._plugins=e.plugins}_actionHandlers;_messageHandlers={};_eventHandlers={};_stateExpiredHandlers={};_hookHandlers={before_incoming_event:{},before_incoming_message:{},before_outgoing_message:{},before_outgoing_call_action:{},before_incoming_call_action:{},after_incoming_event:{},after_incoming_message:{},after_outgoing_message:{},after_outgoing_call_action:{},after_incoming_call_action:{}};_workflowHandlers={started:{},continued:{},timed_out:{}};_plugins={};_registerOrder=0;get actionHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._actionHandlers[r];if(n)return n;for(let[s,i]of Object.entries(this._plugins)){let[o,l]=r.split(Oe);if(!(o!==s||!l)&&(n=i.actionHandlers[l],n))return Y.setName(d=>n({...d,workflows:we(d.client)}),n.name)}}})}get messageHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.messageHandlers[r]??[]),s=this._messageHandlers[r]??[],i=this._messageHandlers["*"]??[],o=[...s,...i].sort((l,d)=>l.order-d.order).map(({handler:l})=>l);return E.unique([...n,...o]).map(l=>Y.setName(d=>l({...d,workflows:we(d.client)}),l.name))}})}get eventHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.eventHandlers[r]??[]),s=this._eventHandlers[r]??[],i=this._eventHandlers["*"]??[],o=[...s,...i].sort((l,d)=>l.order-d.order).map(({handler:l})=>l);return E.unique([...n,...o]).map(l=>Y.setName(d=>l({...d,workflows:we(d.client)}),l.name))}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.stateExpiredHandlers[r]??[]),s=this._stateExpiredHandlers[r]??[],i=this._stateExpiredHandlers["*"]??[],o=[...s,...i].sort((l,d)=>l.order-d.order).map(({handler:l})=>l);return E.unique([...n,...o]).map(l=>Y.setName(d=>l({...d,workflows:we(d.client)}),l.name))}})}get hookHandlers(){return new Proxy({},{get:(e,r)=>{if(this._hookHandlers[r])return new Proxy({},{get:(s,i)=>{let o=Object.values(this._plugins).flatMap(h=>h.hookHandlers[r]?.[i]??[]),l=this._hookHandlers[r]??{},d=l[i]??[],u=l["*"]??[],g=[...d,...u].sort((h,T)=>h.order-T.order).map(({handler:h})=>h);return E.unique([...o,...g]).map(h=>Y.setName(T=>h({...T,workflows:we(T.client)}),h.name))}})}})}get workflowHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._workflowHandlers[r];if(n)return new Proxy({},{get:(s,i)=>{let o=n[i]?.sort((d,u)=>d.order-u.order).map(({handler:d})=>d)??[],l=Object.values(this._plugins).flatMap(d=>d.workflowHandlers[r]?.[i]??[]);return E.unique([...o,...l]).map(d=>Y.setName(async u=>{let g=u.workflow;return await d({...u,workflow:de({...u,onWorkflowUpdate(h){g=h}}),workflows:we(u.client)}),g},d.name))}})}})}on={message:(e,r)=>{this._messageHandlers[e]=E.safePush(this._messageHandlers[e],{handler:r,order:this._registerOrder++})},event:(e,r)=>{this._eventHandlers[e]=E.safePush(this._eventHandlers[e],{handler:r,order:this._registerOrder++})},stateExpired:(e,r)=>{this._stateExpiredHandlers[e]=E.safePush(this._stateExpiredHandlers[e],{handler:r,order:this._registerOrder++})},beforeIncomingEvent:(e,r)=>{this._hookHandlers.before_incoming_event[e]=E.safePush(this._hookHandlers.before_incoming_event[e],{handler:r,order:this._registerOrder++})},beforeIncomingMessage:(e,r)=>{this._hookHandlers.before_incoming_message[e]=E.safePush(this._hookHandlers.before_incoming_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingMessage:(e,r)=>{this._hookHandlers.before_outgoing_message[e]=E.safePush(this._hookHandlers.before_outgoing_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingCallAction:(e,r)=>{this._hookHandlers.before_outgoing_call_action[e]=E.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},beforeIncomingCallAction:(e,r)=>{this._hookHandlers.before_incoming_call_action[e]=E.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingEvent:(e,r)=>{this._hookHandlers.after_incoming_event[e]=E.safePush(this._hookHandlers.after_incoming_event[e],{handler:r,order:this._registerOrder++})},afterIncomingMessage:(e,r)=>{this._hookHandlers.after_incoming_message[e]=E.safePush(this._hookHandlers.after_incoming_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingMessage:(e,r)=>{this._hookHandlers.after_outgoing_message[e]=E.safePush(this._hookHandlers.after_outgoing_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingCallAction:(e,r)=>{this._hookHandlers.after_outgoing_call_action[e]=E.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingCallAction:(e,r)=>{this._hookHandlers.after_incoming_call_action[e]=E.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:r,order:this._registerOrder++})},workflowStart:(e,r)=>{this._workflowHandlers.started[e]=E.safePush(this._workflowHandlers.started[e],{handler:r,order:this._registerOrder++})},workflowContinue:(e,r)=>{this._workflowHandlers.continued[e]=E.safePush(this._workflowHandlers.continued[e],{handler:r,order:this._registerOrder++})},workflowTimeout:(e,r)=>{this._workflowHandlers.timed_out[e]=E.safePush(this._workflowHandlers.timed_out[e],{handler:r,order:this._registerOrder++})}};handler=cu(this);start=e=>Vt(this.handler,e)};var kn=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.title=e.title,this.description=e.description,this.readme=e.readme,this.entities=e.entities??{},this.attributes=e.attributes,this.__advanced=e.__advanced;let r=this._getEntityReference(this.entities),n=e.events===void 0?{}:N.mapValues(e.events,o=>({...o,schema:o.schema(r)})),s=e.actions===void 0?{}:N.mapValues(e.actions,o=>({...o,input:{...o.input,schema:o.input.schema(r)},output:{...o.output,schema:o.output.schema(r)}})),i=e.channels===void 0?{}:N.mapValues(e.channels,o=>({...o,messages:N.mapValues(o.messages,l=>({...l,schema:l.schema(r)}))}));this.events=n,this.actions=s,this.channels=i}name;version;title;description;icon;readme;attributes;entities;events;actions;channels;__advanced;get metadata(){return{sdkVersion:Ee}}_getEntityReference=e=>{let r={};for(let[n,s]of Object.entries(e)){let i=s.schema._def["x-zui"]?.title,o=s.schema._def.description,l=Dd.ref(n);i&&l.title(i),o&&l.describe(o),r[n]=l}return r}};var Sn=class{constructor(e){this.props=e;let r=Object.fromEntries(Object.entries(e.interfaces??{}).map(([n,s])=>[n,Object.fromEntries(Object.entries(s.definition.entities??{}).map(([i])=>[i,y.ref(`interface:${n}/entities/${i}`)]))]));this.name=e.name,this.version=e.version,this.icon=e.icon,this.readme=e.readme,this.title=e.title,this.description=e.description,this.integrations=e.integrations,this.interfaces=e.interfaces,this.user=e.user,this.conversation=e.conversation,this.message=e.message,this.recurringEvents=e.recurringEvents,this.workflows=e.workflows,this.attributes=e.attributes,this.__advanced=e.__advanced,this.configuration=e.configuration?{...e.configuration,schema:typeof e.configuration.schema=="object"?e.configuration.schema:e.configuration.schema({entities:r})}:void 0,this.states=Object.fromEntries(Object.entries(e.states??{}).map(([n,s])=>[n,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:r})}])),this.events=Object.fromEntries(Object.entries(e.events??{}).map(([n,s])=>[n,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:r})}])),this.actions=Object.fromEntries(Object.entries(e.actions??{}).map(([n,s])=>[n,{...s,input:{...s.input,schema:typeof s.input.schema=="object"?s.input.schema:s.input.schema({entities:r})},output:{...s.output,schema:typeof s.output.schema=="object"?s.output.schema:s.output.schema({entities:r})}}])),this.tables=Object.fromEntries(Object.entries(e.tables??{}).map(([n,s])=>[n,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:r})}]))}name;version;title;description;icon;readme;attributes;integrations;interfaces;user;conversation;message;states;configuration;events;recurringEvents;actions;tables;workflows;__advanced;get metadata(){return{sdkVersion:Ee}}dereferenceEntities({intersectWithUnknownRecord:e}={intersectWithUnknownRecord:!0}){let r=this._buildZuiReferenceMap(e);return{...this,configuration:this.configuration?{...this.configuration,schema:this._dereferenceZuiSchema(this.configuration.schema,r)}:void 0,events:this._dereferenceDefinitionSchemas(this.events,r),states:this._dereferenceDefinitionSchemas(this.states,r),tables:this._dereferenceDefinitionSchemas(this.tables,r),actions:this._dereferenceActionDefinitionSchemas(this.actions,r)}}_buildZuiReferenceMap(e){return Object.fromEntries(Object.entries(this.interfaces??{}).flatMap(([r,n])=>Object.entries(n.definition.entities??{}).map(([s,i])=>[`interface:${r}/entities/${s}`,e?i.schema.and(y.record(y.string(),y.unknown())):i.schema])))}_dereferenceZuiSchema(e,r){return e.dereference(r)}_dereferenceDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,{...s,schema:this._dereferenceZuiSchema(s.schema,r)}]))}_dereferenceActionDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,{...s,input:{schema:this._dereferenceZuiSchema(s.input.schema,r)},output:{schema:this._dereferenceZuiSchema(s.output.schema,r)}}]))}};var Us=":";var du=t=>{let[e,r]=t.split(Us);return!e||!r?null:{namespace:e,eventName:r}},uu=t=>`${t.namespace}${Us}${t.actionName}`,pu=t=>`${t.namespace}${Us}${t.eventName}`,fu=(t,e)=>{let r=e[t.namespace]??{name:t.namespace,version:"0.0.0",entities:{},actions:{},events:{},channels:{}},n=r.name,s=r.actions[t.actionName]?.name??t.actionName;return{namespace:n,actionName:s}},gu=(t,e)=>{let r=e[t.namespace]??{name:t.namespace,version:"0.0.0",entities:{},actions:{},events:{},channels:{}},n=r.name,s=r.events[t.eventName]?.name??t.eventName;return{namespace:n,eventName:s}};var mu=(t,e)=>new Proxy({},{get:(r,n)=>new Proxy({},{get:(s,i)=>o=>iv({client:t,interfaces:e.interfaces,integrationOrInterfaceName:n,methodName:i,input:o})})}),iv=async({client:t,interfaces:e,integrationOrInterfaceName:r,methodName:n,input:s})=>{let i=fu({namespace:r,actionName:n},e),o=uu(i);return(await t.callAction({type:o,input:s})).output};var zs=class t{constructor(e){this._props=e}async emit(e){let{conversationId:r,userId:n,messageId:s}=this._props;await this._props.client.createEvent({type:this._props.eventName,payload:e,conversationId:r,userId:n,messageId:s})}async schedule(e,r){let{conversationId:n,userId:s,messageId:i}=this._props;await this._props.client.createEvent({type:this._props.eventName,payload:e,conversationId:n,userId:s,messageId:i,schedule:r})}withConversationId(e){return new t({...this._props,conversationId:e})}withUserId(e){return new t({...this._props,userId:e})}withMessageId(e){return new t({...this._props,messageId:e})}},hu=(t,e)=>new Proxy({},{get:(r,n)=>{let s=e.alias!==void 0?`${e.alias}${Oe}${n}`:n;return new zs({client:t,eventName:s})}});var Fs=class{constructor(e,r,n){this._client=e;this._stateType=r;this._stateName=n}async get(e){return await this._client.getState({type:this._stateType,name:this._stateName,id:e}).then(r=>r.state.payload)}async set(e,r,n){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:r,expiry:n?.expiryMs})}async getOrSet(e,r,n){return await this._client.getOrSetState({type:this._stateType,name:this._stateName,id:e,payload:r,expiry:n?.expiryMs}).then(s=>s.state.payload)}async delete(e){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:null})}async patch(e,r){await this._client.patchState({type:this._stateType,name:this._stateName,id:e,payload:r})}},yu=(t,e)=>new Proxy({},{get:(r,n)=>new Proxy({},{get:(s,i)=>{let o=e.alias!==void 0?`${e.alias}${Oe}${i}`:i;return new Fs(t,n,o)}})});var En=class{constructor(e){this.props=e;this._actionHandlers=e.actions}_runtimeProps;_actionHandlers;_messageHandlers={};_eventHandlers={};_stateExpiredHandlers={};_hookHandlers={before_incoming_event:{},before_incoming_message:{},before_outgoing_message:{},before_outgoing_call_action:{},before_incoming_call_action:{},after_incoming_event:{},after_incoming_message:{},after_outgoing_message:{},after_outgoing_call_action:{},after_incoming_call_action:{}};_workflowHandlers={started:{},continued:{},timed_out:{}};_registerOrder=0;initialize(e){return this._runtimeProps=e,this}get _runtime(){if(!this._runtimeProps)throw new Error("Plugin not correctly initialized. This is likely because you access your plugin config outside of an handler.");return this._runtimeProps}_getTools(e){let{configuration:r,interfaces:n,alias:s}=this._runtime,i=mu(e,this._runtime),o=yu(e,this._runtime),l=we(e),d=hu(e,this._runtime);return{configuration:r,interfaces:n,actions:i,states:o,alias:s,workflows:l,events:d}}get actionHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._actionHandlers[r];if(n)return Y.setName(s=>n({...s,...this._getTools(s.client)}),n.name)}})}get messageHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._messageHandlers[r]??[],s=this._messageHandlers["*"]??[];return E.unique([...n,...s]).sort((o,l)=>o.order-l.order).map(({handler:o})=>Y.setName(l=>o({...l,message:l.message,...this._getTools(l.client)}),o.name))}})}get eventHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._eventHandlers[r]??[],s=Object.entries(this._eventHandlers).filter(([l])=>this._eventResolvesTo(l,r)).flatMap(([,l])=>l??[]),i=this._eventHandlers["*"]??[];return E.unique([...n,...s,...i]).sort((l,d)=>l.order-d.order).map(({handler:l})=>Y.setName(d=>l({...d,event:d.event,...this._getTools(d.client)}),l.name))}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._stateExpiredHandlers[r]??[],s=this._stateExpiredHandlers["*"]??[];return E.unique([...n,...s]).sort((o,l)=>o.order-l.order).map(({handler:o})=>Y.setName(l=>o({...l,state:l.state,...this._getTools(l.client)}),o.name))}})}get hookHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._hookHandlers[r];if(n)return new Proxy({},{get:(s,i)=>{i=this._stripAliasPrefix(i);let o=n[i]??[],l=Object.entries(n).filter(([g])=>this._eventResolvesTo(g,i)).flatMap(([,g])=>g??[]),d=n["*"]??[];return E.unique([...o,...l,...d]).sort((g,h)=>g.order-h.order).map(({handler:g})=>Y.setName(h=>g({...h,data:h.data,...this._getTools(h.client)}),g.name))}})}})}get workflowHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._workflowHandlers[r];if(n)return new Proxy({},{get:(s,i)=>(n[i]?.sort((l,d)=>l.order-d.order)??[]).map(({handler:l})=>Y.setName(async d=>{let u=d.workflow;return await l({...d,workflow:de({...d,onWorkflowUpdate(g){u=g}}),...this._getTools(d.client)}),u},l.name))})}})}on={message:(e,r)=>{this._messageHandlers[e]=E.safePush(this._messageHandlers[e],{handler:r,order:this._registerOrder++})},event:(e,r)=>{this._eventHandlers[e]=E.safePush(this._eventHandlers[e],{handler:r,order:this._registerOrder++})},stateExpired:(e,r)=>{this._stateExpiredHandlers[e]=E.safePush(this._stateExpiredHandlers[e],{handler:r,order:this._registerOrder++})},beforeIncomingEvent:(e,r)=>{this._hookHandlers.before_incoming_event[e]=E.safePush(this._hookHandlers.before_incoming_event[e],{handler:r,order:this._registerOrder++})},beforeIncomingMessage:(e,r)=>{this._hookHandlers.before_incoming_message[e]=E.safePush(this._hookHandlers.before_incoming_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingMessage:(e,r)=>{this._hookHandlers.before_outgoing_message[e]=E.safePush(this._hookHandlers.before_outgoing_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingCallAction:(e,r)=>{this._hookHandlers.before_outgoing_call_action[e]=E.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},beforeIncomingCallAction:(e,r)=>{this._hookHandlers.before_incoming_call_action[e]=E.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingEvent:(e,r)=>{this._hookHandlers.after_incoming_event[e]=E.safePush(this._hookHandlers.after_incoming_event[e],{handler:r,order:this._registerOrder++})},afterIncomingMessage:(e,r)=>{this._hookHandlers.after_incoming_message[e]=E.safePush(this._hookHandlers.after_incoming_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingMessage:(e,r)=>{this._hookHandlers.after_outgoing_message[e]=E.safePush(this._hookHandlers.after_outgoing_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingCallAction:(e,r)=>{this._hookHandlers.after_outgoing_call_action[e]=E.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingCallAction:(e,r)=>{this._hookHandlers.after_incoming_call_action[e]=E.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:r,order:this._registerOrder++})},workflowStart:(e,r)=>{this._workflowHandlers.started[e]=E.safePush(this._workflowHandlers.started[e],{handler:r,order:this._registerOrder++})},workflowContinue:(e,r)=>{this._workflowHandlers.continued[e]=E.safePush(this._workflowHandlers.continued[e],{handler:r,order:this._registerOrder++})},workflowTimeout:(e,r)=>{this._workflowHandlers.timed_out[e]=E.safePush(this._workflowHandlers.timed_out[e],{handler:r,order:this._registerOrder++})}};_eventResolvesTo=(e,r)=>{let n=du(e);if(!n)return!1;let s=gu(n,this._runtime.interfaces);return pu(s)===r};_stripAliasPrefix=e=>{let{alias:r}=this._runtime;if(!r)return e;let n=`${r}#`;return e.startsWith(n)?e.slice(n.length):e}};var Ws={};Xe(Ws,{allWithinMajorOf:()=>av,allWithinMinorOf:()=>ov});var Gt=In(require("semver"));function av(t){let e=Gt.major(t.version);return{...t,version:`>=${e}.0.0 <${e+1}.0.0`}}function ov(t){let e=Gt.major(t.version),r=Gt.minor(t.version);return{...t,version:`>=${e}.${r}.0 <${e}.${r+1}.0`}}0&&(module.exports={BRAND,Bot,BotDefinition,BotLogger,BotSpecificClient,DIRTY,EMPTY_PATH,INVALID,Integration,IntegrationDefinition,IntegrationLogger,IntegrationSpecificClient,InterfaceDefinition,NEVER,OK,ParseInputLazyPath,ParseStatus,Plugin,PluginDefinition,RuntimeError,Schema,WELL_KNOWN_ATTRIBUTES,ZodAny,ZodArray,ZodBigInt,ZodBoolean,ZodBranded,ZodCatch,ZodDate,ZodDefault,ZodDiscriminatedUnion,ZodEffects,ZodEnum,ZodError,ZodFirstPartyTypeKind,ZodFunction,ZodIntersection,ZodIssueCode,ZodLazy,ZodLiteral,ZodMap,ZodNaN,ZodNativeEnum,ZodNever,ZodNull,ZodNullable,ZodNumber,ZodObject,ZodOptional,ZodParsedType,ZodPipeline,ZodPromise,ZodReadonly,ZodRecord,ZodRef,ZodSchema,ZodSet,ZodString,ZodSymbol,ZodTransformer,ZodTuple,ZodType,ZodUndefined,ZodUnion,ZodUnknown,ZodVoid,addIssueToContext,agent,aimodel,any,array,bigint,boolean,coerce,conversation,createZodEnum,cuid2Regex,cuidRegex,custom,datasource,date,discriminatedUnion,effect,emailRegex,enum:null,errorUtil,event,function:null,getErrorMap,getParsedType,instanceof:null,intent,intersection,ipv4Regex,ipv6Regex,isAborted,isApiError,isAsync,isDirty,isEmojiRegex,isValid,json,knowledgebase,late,lazy,literal,makeIssue,map,mergeObjectSchemas,message,messages,nan,nativeEnum,never,null:null,nullable,number,object,objectUtil,oboolean,onumber,optional,ostring,parseBody,pipeline,preprocess,processCreateParams,promise,quotelessJson,readonly,record,ref,serve,set,setErrorMap,strictObject,string,symbol,table,tablerow,transformer,transforms,tuple,ulidRegex,undefined,union,unknown,user,util,uuidRegex,variable,version,void:null,z});
72
+ `,s+="})"}let i=r?s?r+s:n?n==="z.never()"?r+".strict()":r+`.catchall(${n})`:r:s||(n?`z.record(${n})`:"z.record(z.any())");return $.an.anyOf(t)&&(i+=`.and(${ad(f(c({},t),{anyOf:t.anyOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?f(c({},o),{type:"object"}):o)}),e)})`),$.a.oneOf(t)&&(i+=`.and(${Hs(f(c({},t),{oneOf:t.oneOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?f(c({},o),{type:"object"}):o)}),e)})`),$.an.allOf(t)&&(i+=`.and(${Kt(f(c({},t),{allOf:t.allOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?f(c({},o),{type:"object"}):o)}),e)})`),i}a(od,"parseObject");var Bh=a(t=>{var e;let r="z.string()";if((e=t[w])!=null&&e.coerce){if(t.format==="date-time")return"z.coerce.date()";r="z.coerce.string()"}return r+=V(t,"format",({value:n})=>{switch(n){case"email":return[".email(",")"];case"ip":return[".ip(",")"];case"ipv4":return['.ip({ version: "v4"',", message: "," })"];case"ipv6":return['.ip({ version: "v6"',", message: "," })"];case"uri":return[".url(",")"];case"uuid":return[".uuid(",")"];case"date-time":return[".datetime(",")"]}}),r+=V(t,"pattern",({json:n})=>[`.regex(new RegExp(${n})`,", ",")"]),r+=V(t,"minLength",({json:n})=>[`.min(${n}`,", ",")"]),r+=V(t,"maxLength",({json:n})=>[`.max(${n}`,", ",")"]),r},"parseString"),Ah=a((t,e)=>`${L(xh(t,"nullable"),e,!0)}.nullable()`,"parseNullable"),Rh=a(t=>`z.ref('${t.$ref}')`,"parseRef"),Ch=a((t,e)=>{var r,n;if(t.oneOf.length<=1||!((r=t.discriminator)!=null&&r.propertyName))return Hs(t,e);let s=t.oneOf.map((i,o)=>L(i,f(c({},e),{path:[...e.path,"oneOf",o]})));return`z.discriminatedUnion("${(n=t.discriminator)==null?void 0:n.propertyName}", [${s.join(", ")}])`},"parseDiscriminator"),L=a((t,e={seen:new Map,path:[]},r)=>{if(typeof t!="object")return t?"z.any()":"z.never()";if(e.parserOverride){let i=e.parserOverride(t,e);if(typeof i=="string")return i}let n=e.seen.get(t);if(n){if(n.r!==void 0)return n.r;if(e.depth===void 0||n.n>=e.depth)return"z.any()";n.n+=1}else n={r:void 0,n:0},e.seen.set(t,n);let s=Nh(t,e);return r||(s=Dh(t,s),e.withoutDefaults||(s=Hh(t,s))),n.r=s,s},"parseSchema"),Dh=a((t,e)=>(t.description&&(e+=`.describe(${JSON.stringify(t.description)})`),e),"addMeta"),Hh=a((t,e)=>(t.default!==void 0&&(e+=`.default(${JSON.stringify(t.default)})`),e),"addDefaults"),Nh=a((t,e)=>$.a.nullable(t)?Ah(t,e):$.an.object(t)?od(t,e):$.an.array(t)?Sh(t,e):$.an.anyOf(t)?ad(t,e):$.an.allOf(t)?Kt(t,e):$.a.discriminator(t)?Ch(t,e):$.a.oneOf(t)?Hs(t,e):$.a.not(t)?bh(t,e):$.an.enum(t)?Oh(t):$.a.const(t)?Eh(t):$.a.multipleType(t)?Th(t,e):$.a.primitive(t,"string")?Bh(t):$.a.primitive(t,"number")||$.a.primitive(t,"integer")?Ih(t):$.a.primitive(t,"boolean")?vh(t):$.a.primitive(t,"null")?wh(t):$.a.conditional(t)?Zh(t,e):$.a.ref(t)?Rh(t):_h(t),"selectParser"),$={an:{object:a(t=>t.type==="object","object"),array:a(t=>t.type==="array","array"),anyOf:a(t=>t.anyOf!==void 0,"anyOf"),allOf:a(t=>t.allOf!==void 0,"allOf"),enum:a(t=>t.enum!==void 0,"enum")},a:{nullable:a(t=>t.nullable===!0,"nullable"),multipleType:a(t=>Array.isArray(t.type),"multipleType"),not:a(t=>t.not!==void 0,"not"),const:a(t=>t.const!==void 0,"const"),primitive:a((t,e)=>t.type===e,"primitive"),conditional:a(t=>!!("if"in t&&t.if&&"then"in t&&"else"in t&&t.then&&t.else),"conditional"),discriminator:a(t=>{var e;return t.oneOf!==void 0&&((e=t.discriminator)==null?void 0:e.propertyName)!==void 0},"discriminator"),oneOf:a(t=>t.oneOf!==void 0,"oneOf"),ref:a(t=>t.$ref!==void 0,"ref")}},Mh=a(t=>{let e;try{e=new Function("z",`return ${t}`)(p)}catch(r){return{sucess:!1,error:`Failed to evaluate schema: ${(r instanceof Error?r:new Error(String(r))).message}`}}return e instanceof p.ZodType?{sucess:!0,value:e}:{sucess:!1,error:`String "${t}" does not evaluate to a Zod schema`}},"evalZuiString"),$h=a(t=>L(t,{seen:new Map,path:[]}),"jsonSchemaToZodStr"),jh=a(t=>{let e=$h(t);e=e.replaceAll("errors: z.ZodError[]","errors");let r=Mh(e);if(!r.sucess)throw new Fr(r.error);return r.value},"jsonSchemaToZod"),At=a((t,e)=>{var r,n;if(e[w]&&t._def&&(t.naked()._def[w]=e[w]),((r=t._def)==null?void 0:r.typeName)==="ZodObject"&&e.type==="object"&&e.properties&&Object.entries(e.properties).forEach(([s,i])=>{let o=typeof t._def.shape=="function"?t._def.shape():t._def.shape;o[s]&&At(o[s],i)}),((n=t._def)==null?void 0:n.typeName)==="ZodRecord"&&e.type==="object"&&e.additionalProperties&&At(t._def.valueType,e.additionalProperties),e.type==="array"&&e.items){let s=e.items;if(typeof s=="object"&&!Array.isArray(s)){let i=t._def.type;i&&At(i,s)}else Array.isArray(s)&&s.forEach((i,o)=>{let l=t._def;l.typeName===y.ZodFirstPartyTypeKind.ZodTuple&&At(l.items[o],i)})}},"applyZuiPropsRecursively"),Kh=a(t=>{let e=jh(t);return At(e,t),e},"fromJSONSchemaLegacy"),Uh=a(t=>{var e,r;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(n=>typeof n!="boolean"&&ld(n))&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===p.ZodFirstPartyTypeKind.ZodOptional},"isOptionalSchema"),zh=a(t=>{var e,r;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(n=>typeof n!="boolean"&&n.type==="null")&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===p.ZodFirstPartyTypeKind.ZodNullable},"isNullableSchema"),ld=a(t=>{var e,r;return t.not===!0&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===p.ZodFirstPartyTypeKind.ZodUndefined},"isUndefinedSchema"),Fh=a(t=>{var e,r;return!t.not&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===p.ZodFirstPartyTypeKind.ZodUnknown},"isUnknownSchema"),Wh=a(({type:t,minimum:e,exclusiveMinimum:r,maximum:n,exclusiveMaximum:s,multipleOf:i,format:o})=>{let l=p.number();return t==="integer"&&(l=l.int()),o==="finite"&&(l=l.finite()),r!==void 0?l=l.gt(r):e!==void 0&&(l=l.gte(e)),s!==void 0?l=l.lt(s):n!==void 0&&(l=l.lte(n)),i!==void 0&&(l=l.multipleOf(i)),l},"numberJSONSchemaToZuiNumber"),Lh=a(({format:t,pattern:e,minLength:r,maxLength:n})=>{let s=p.string();if(r&&n&&r===n?s=s.length(r):(r&&(s=s.min(r)),n&&(s=s.max(n))),t==="cuid"||e===j.cuid)s=s.cuid();else if(t==="cuid2"||e===j.cuid2)s=s.cuid2();else if(t==="emoji"||e===j.emoji)s=s.emoji();else if(t==="ulid"||e===j.ulid)s=s.ulid();else if(t==="date-time"){let{precision:i,offset:o}=e?ah(e):{};s=s.datetime({precision:i,offset:o})}else t==="email"||e===j.email?s=s.email():t==="ipv4"||e===j.ipv4?s=s.ip():t==="ipv6"||e===j.ipv6?s=s.ip("v6"):t==="uri"?s=s.url():t==="uuid"||e===j.uuid?s=s.uuid():e&&(s=s.regex(new RegExp(e)));return s},"stringJSONSchemaToZuiString"),Tt=a((t,e)=>{let r=[];e.enum!==void 0&&r.push(...e.enum),e.const!==void 0&&r.push(e.const);let n=r.filter(o=>typeof o===t),[s]=n;if(!s){if(t==="string"&&e.type==="string")return Lh(e);if(t==="number"&&(e.type==="number"||e.type==="integer"))return Wh(e);if(t==="boolean")return p.boolean();if(t==="null")return p.null();throw new Fr(`Unknown primitive type: "${t}"`)}if(n.length===1)return p.literal(s);let i=n.map(o=>p.literal(o));return p.union(i)},"toZuiPrimitive"),qh=a((t,e)=>Vh(t)?Jh(t,e):Gh(t)?Yh(t,e):Xh(t,e),"arrayJSONSchemaToZuiArray"),Vh=a(t=>Array.isArray(t.items),"_isTuple"),Gh=a(t=>t.items!==void 0&&t.uniqueItems,"_isSet"),Jh=a(({items:t,additionalItems:e},r)=>{let n=t.map(r),s=p.tuple(n);return e!==void 0&&(s=s.rest(r(e))),s},"_handleTuple"),Yh=a(({items:t,minItems:e,maxItems:r},n)=>{let s=p.set(n(t));return e&&(s=s.min(e)),r&&(s=s.max(r)),s},"_handleSet"),Xh=a(({minItems:t,maxItems:e,items:r},n)=>{let s=p.array(n(r));return t&&t===e?s.length(t):(t&&(s=s.min(t)),e&&(s=s.max(e)),s)},"_handleArray"),Qe=p.any();function cd(t){return W(t)}a(cd,"fromJSONSchema");function W(t){var e;if(t===void 0)return Qe;if(t===!0)return p.any();if(t===!1)return p.never();if(t.default!==void 0)return W(f(c({},t),{default:void 0})).default(t.default);if(t.readOnly)return W(f(c({},t),{readOnly:void 0})).readonly();if(t.oneOf!==void 0)throw new Pe({oneOf:t.oneOf});if(t.patternProperties!==void 0)throw new Pe({patternProperties:t.patternProperties});if(t.propertyNames!==void 0)throw new Pe({propertyNames:t.propertyNames});if(t.if!==void 0)throw new Pe({if:t.if});if(t.then!==void 0)throw new Pe({then:t.then});if(t.else!==void 0)throw new Pe({else:t.else});if(t.$ref!==void 0)return p.ref(t.$ref);if(t.not!==void 0){if(ld(t))return p.undefined();if(t.not===!0)return p.never();throw new Pe({not:t.not})}if(Array.isArray(t.type)){if(t.type.length===0)return Qe;if(t.type.length===1)return W(f(c({},t),{type:t.type[0]}));let r=t,{type:n}=r,s=Ai(r,["type"]),i=t.type.map(o=>W(f(c({},s),{type:o})));return p.union(i)}if(t.type==="string")return t.enum&&t.enum.length>0?p.enum(t.enum):Tt("string",t);if(t.type==="integer"){let r=Tt("number",t);return r instanceof p.ZodNumber?r.int():r}if(t.type==="number")return Tt("number",t);if(t.type==="boolean")return Tt("boolean",t);if(t.type==="null")return Tt("null",t);if(t.type==="array")return qh(t,W);if(t.type==="object"){if(t.additionalProperties!==void 0&&t.properties!==void 0){let r=W(t.additionalProperties);return W(f(c({},t),{additionalProperties:void 0})).catchall(r)}if(t.properties!==void 0){let r={};for(let[n,s]of Object.entries(t.properties)){let i=W(s),o=(e=t.required)!=null?e:[];r[n]=o.includes(n)?i:i.optional()}return p.object(r)}if(t.additionalProperties!==void 0){let r=W(t.additionalProperties);return p.record(r)}return p.record(Qe)}if(t.anyOf!==void 0){if(t.anyOf.length===0)return Qe;if(t.anyOf.length===1)return W(t.anyOf[0]);if(Uh(t))return W(t.anyOf[0]).optional();if(zh(t))return W(t.anyOf[0]).nullable();let r=t.anyOf.map(W);return p.union(r)}if(t.allOf!==void 0){if(t.allOf.length===0)return Qe;if(t.allOf.length===1)return W(t.allOf[0]);let[r,...n]=t.allOf,s=W(r),i=W({allOf:n});return p.intersection(s,i)}return Fh(t)?p.unknown():Qe}a(W,"_fromJSONSchema");var Qh=/^\d{4}-\d{2}-\d{2}(T|\s)?((\d{2}:\d{2}:\d{2}(\.\d{1,3})?)|(\d{2}:\d{2}))?(\s?([+-]\d{2}:\d{2}|Z))?$/,Gn=a((t,e,r=!0)=>{if(typeof t!="object")throw new $n("Input must be an object");let n=a(o=>{let l=o;return e?.nullable&&(l=l.nullable()),e?.optional&&(l=l.optional()),e?.passtrough&&typeof l.passthrough=="function"&&(l=l.passthrough()),l},"applyOptions"),s=Object.entries(t).reduce((o,[l,d])=>{if(d===null)o[l]=n(y.null());else switch(typeof d){case"string":o[l]=Qh.test(d)?n(y.string().datetime()):n(y.string());break;case"number":o[l]=n(y.number());break;case"boolean":o[l]=n(y.boolean());break;case"object":Array.isArray(d)?d.length===0?o[l]=n(y.array(y.unknown())):typeof d[0]=="object"?o[l]=n(y.array(Gn(d[0],e,!1))):["string","number","boolean"].includes(typeof d[0])&&(o[l]=n(y.array(y[typeof d[0]]()))):o[l]=n(Gn(d,e,!1));break;default:throw new $n(`Unsupported type for key ${l}`)}return o},{}),i=Object.keys(s).length>0;return e?.passtrough||!r&&!i?y.object(s).passthrough():y.object(s)},"fromObject");function dd(){return{}}a(dd,"parseAnyDef");function ud(t,e){var r,n;let s={type:"array"};return((n=(r=t.type)==null?void 0:r._def)==null?void 0:n.typeName)!=="ZodAny"&&(s.items=A(t.type._def,f(c({},e),{currentPath:[...e.currentPath,"items"]}))),t.minLength&&D(s,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&D(s,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(D(s,"minItems",t.exactLength.value,t.exactLength.message,e),D(s,"maxItems",t.exactLength.value,t.exactLength.message,e)),s}a(ud,"parseArrayDef");function pd(t,e){let r=c({type:"integer",format:"int64"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?D(r,"minimum",n.value,n.message,e):D(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),D(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?D(r,"maximum",n.value,n.message,e):D(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),D(r,"maximum",n.value,n.message,e));break;case"multipleOf":D(r,"multipleOf",n.value,n.message,e);break}return r}a(pd,"parseBigintDef");function fd(t){return c({type:"boolean"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{})}a(fd,"parseBooleanDef");function gd(t,e){return A(t.type._def,e)}a(gd,"parseBrandedDef");var ey=a((t,e)=>A(t.innerType._def,e),"parseCatchDef");function md(t,e){return e.dateStrategy=="integer"?ty(t,e):c({type:"string",format:"date-time"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{})}a(md,"parseDateDef");var ty=a((t,e)=>{let r=c({type:"integer",format:"unix-time"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{});for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"&&D(r,"minimum",n.value,n.message,e);break;case"max":e.target==="jsonSchema7"&&D(r,"maximum",n.value,n.message,e);break}return r},"integerDateParser");function hd(t,e){return f(c({},A(t.innerType._def,e)),{default:t.defaultValue()})}a(hd,"parseDefaultDef");function yd(t,e){return e.effectStrategy==="input"?A(t.schema._def,e):{}}a(yd,"parseEffectsDef");function vd(t){return{type:"string",enum:t.values}}a(vd,"parseEnumDef");var ry=a(t=>"type"in t&&t.type==="string"?!1:"allOf"in t,"isJsonSchema7AllOfType");function _d(t,e){let r=[A(t.left._def,f(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),A(t.right._def,f(c({},e),{currentPath:[...e.currentPath,"allOf","1"]}))].filter(i=>!!i),n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,s=[];return r.forEach(i=>{if(ry(i))s.push(...i.allOf),i.unevaluatedProperties===void 0&&(n=void 0);else{let o=i;if("additionalProperties"in i&&i.additionalProperties===!1){let l=i,{additionalProperties:d}=l;o=Ai(l,["additionalProperties"])}else n=void 0;s.push(o)}}),s.length?c({allOf:s},n):void 0}a(_d,"parseIntersectionDef");function Td(t,e){let r=typeof t.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[t.value]}:{type:r==="bigint"?"integer":r,const:t.value}}a(Td,"parseLiteralDef");function Ns(t,e){var r,n,s,i,o;if(e.target==="openApi3"&&((r=t.keyType)==null?void 0:r._def.typeName)==="ZodEnum")return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((d,u)=>{var g;return f(c({},d),{[u]:(g=A(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"properties",u]})))!=null?g:{}})},{}),additionalProperties:!1};let l={type:"object",additionalProperties:(n=A(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?n:{}};if(e.target==="openApi3")return l;if(((s=t.keyType)==null?void 0:s._def.typeName)==="ZodString"&&((i=t.keyType._def.checks)!=null&&i.length)){let d=Object.entries(us(t.keyType._def,e)).reduce((u,[g,h])=>g==="type"?u:f(c({},u),{[g]:h}),{});return f(c({},l),{propertyNames:d})}else if(((o=t.keyType)==null?void 0:o._def.typeName)==="ZodEnum")return f(c({},l),{propertyNames:{enum:t.keyType._def.values}});return l}a(Ns,"parseRecordDef");function bd(t,e){if(e.mapStrategy==="record")return Ns(t,e);let r=A(t.keyType._def,f(c({},e),{currentPath:[...e.currentPath,"items","items","0"]}))||{},n=A(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"items","items","1"]}))||{};return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}a(bd,"parseMapDef");function wd(t){let e=t.values,n=Object.keys(t.values).filter(i=>typeof e[e[i]]!="number").map(i=>e[i]),s=Array.from(new Set(n.map(i=>typeof i)));return{type:s.length===1?s[0]==="string"?"string":"number":["string","number"],enum:n.filter(i=>typeof i=="string"||typeof i=="number")}}a(wd,"parseNativeEnumDef");function Pd(){return{not:{}}}a(Pd,"parseNeverDef");function xd(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}a(xd,"parseNullDef");var Ur={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function kd(t,e){if(e.target==="openApi3")return Oi(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in Ur&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((s,i)=>{let o=Ur[i._def.typeName];return o&&!s.includes(o)?[...s,o]:s},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((s,i)=>{let o=typeof i._def.value;switch(o){case"string":case"number":case"boolean":return[...s,o];case"bigint":return[...s,"integer"];case"object":if(i._def.value===null)return[...s,"null"];case"symbol":case"undefined":case"function":default:return s}},[]);if(n.length===r.length){let s=n.filter((i,o,l)=>l.indexOf(i)===o);return{type:s.length>1?s:s[0],enum:r.reduce((i,o)=>i.includes(o._def.value)?i:[...i,o._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,s)=>[...n,...s._def.values.filter(i=>!n.includes(i))],[])};return Oi(t,e)}a(kd,"parseUnionDef");var Oi=a((t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((s,i)=>A(s._def,f(c({},e),{currentPath:[...e.currentPath,e.unionStrategy,`${i}`]}))).filter(s=>!!s&&(!e.strictUnions||typeof s=="object"&&Object.keys(s).length>0)),n=e.discriminator&&t.typeName==="ZodDiscriminatedUnion"&&typeof t.discriminator=="string"?{discriminator:{propertyName:t.discriminator}}:{};if(r.length)return e.unionStrategy==="anyOf"?c({anyOf:r},n):c({oneOf:r},n)},"asUnionOf");function Sd(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length)){let n=t.innerType;if(e.target==="openApi3"){let i={type:Ur[n._def.typeName],nullable:!0};return Jn(n._def,e,i)}let s={type:[Ur[n._def.typeName],"null"]};return Jn(n._def,e,s)}if(e.target==="openApi3"){let n=A(t.innerType._def,f(c({},e),{currentPath:[...e.currentPath]}));return n&&f(c({},n),{nullable:!0})}let r=A(t.innerType._def,f(c({},e),{currentPath:[...e.currentPath,"anyOf","0"]}));return r&&{anyOf:[r,{type:"null"}]}}a(Sd,"parseNullableDef");function Ed(t,e){let r=c({type:"number"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"int":r.type="integer",ds(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?D(r,"minimum",n.value,n.message,e):D(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),D(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?D(r,"maximum",n.value,n.message,e):D(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),D(r,"maximum",n.value,n.message,e));break;case"multipleOf":D(r,"multipleOf",n.value,n.message,e);break}return r}a(Ed,"parseNumberDef");var ny=a((t,e)=>{var r;return t.unknownKeys instanceof O?(r=A(t.unknownKeys._def,f(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?r:!0:t.unknownKeys==="passthrough"},"getAdditionalProperties");function Od(t,e){let r=f(c({type:"object"},Object.entries(t.shape()).reduce((n,[s,i])=>{if(i===void 0||i._def===void 0)return n;let o=A(i._def,f(c({},e),{currentPath:[...e.currentPath,"properties",s],propertyPath:[...e.currentPath,"properties",s]}));return o===void 0?n:{properties:f(c({},n.properties),{[s]:o}),required:i.isOptional()?n.required:[...n.required,s]}},{properties:{},required:[]})),{additionalProperties:ny(t,e)});return r.required.length||delete r.required,r}a(Od,"parseObjectDef");var sy=a((t,e)=>{var r;if(e.currentPath.toString()===((r=e.propertyPath)==null?void 0:r.toString()))return A(t.innerType._def,e);let n=A(t.innerType._def,f(c({},e),{currentPath:[...e.currentPath,"anyOf","1"]}));return n?{anyOf:[{not:{}},n]}:{}},"parseOptionalDef"),iy=a((t,e)=>{if(e.pipeStrategy==="input")return A(t.in._def,e);if(e.pipeStrategy==="output")return A(t.out._def,e);let r=A(t.in._def,f(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),n=A(t.out._def,f(c({},e),{currentPath:[...e.currentPath,"allOf",r?"1":"0"]}));return{allOf:[r,n].filter(s=>s!==void 0)}},"parsePipelineDef");function Zd(t,e){return A(t.type._def,e)}a(Zd,"parsePromiseDef");function Id(t,e){let n={type:"array",uniqueItems:!0,items:A(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"items"]}))};return t.minSize&&D(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&D(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}a(Id,"parseSetDef");function Bd(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>A(r._def,f(c({},e),{currentPath:[...e.currentPath,"items",`${n}`]}))).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:A(t.rest._def,f(c({},e),{currentPath:[...e.currentPath,"additionalItems"]}))}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>A(r._def,f(c({},e),{currentPath:[...e.currentPath,"items",`${n}`]}))).reduce((r,n)=>n===void 0?r:[...r,n],[])}}a(Bd,"parseTupleDef");function Ad(){return{not:{}}}a(Ad,"parseUndefinedDef");function Rd(){return{}}a(Rd,"parseUnknownDef");var ay=a((t,e)=>A(t.innerType._def,e),"parseReadonlyDef");function Cd(t){return{$ref:t.uri}}a(Cd,"parseRefDef");function A(t,e,r=!1){let n=e.seen.get(t);if(n&&!r){let o=oy(n,e);if(o!==void 0)return o}let s={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,s);let i=cy(t,t.typeName,e);return i&&Jn(t,e,i),s.jsonSchema=i,i}a(A,"parseDef");var oy=a((t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:ly(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((r,n)=>e.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),{}):e.$refStrategy==="seen"?{}:void 0}},"get$ref"),ly=a((t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")},"getRelativePath"),cy=a((t,e,r)=>{switch(e){case"ZodString":return us(t,r);case"ZodNumber":return Ed(t,r);case"ZodObject":return Od(t,r);case"ZodBigInt":return pd(t,r);case"ZodBoolean":return fd(t);case"ZodDate":return md(t,r);case"ZodUndefined":return Ad();case"ZodNull":return xd(r);case"ZodArray":return ud(t,r);case"ZodUnion":case"ZodDiscriminatedUnion":return kd(t,r);case"ZodIntersection":return _d(t,r);case"ZodTuple":return Bd(t,r);case"ZodRecord":return Ns(t,r);case"ZodRef":return Cd(t);case"ZodLiteral":return Td(t,r);case"ZodEnum":return vd(t);case"ZodNativeEnum":return wd(t);case"ZodNullable":return Sd(t,r);case"ZodOptional":return sy(t,r);case"ZodMap":return bd(t,r);case"ZodSet":return Id(t,r);case"ZodLazy":return A(t.getter()._def,r);case"ZodPromise":return Zd(t,r);case"ZodNaN":case"ZodNever":return Pd();case"ZodEffects":return yd(t,r);case"ZodAny":return dd();case"ZodUnknown":return Rd();case"ZodDefault":return hd(t,r);case"ZodBranded":return gd(t,r);case"ZodReadonly":return ay(t,r);case"ZodCatch":return ey(t,r);case"ZodPipeline":return iy(t,r);case"ZodFunction":case"ZodVoid":case"ZodSymbol":return;default:return(n=>{})(e)}},"selectParser"),Jn=a((t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),Object.assign(r,{[w]:c(c({},t[w]),r[w])}),r),"addMeta"),Zi={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"string",mapStrategy:"entries",definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",emailStrategy:"format:email",discriminator:!1,unionStrategy:"anyOf"},dy=a(t=>typeof t=="string"?f(c({},Zi),{name:t}):c(c({},Zi),t),"getDefaultOptions"),uy=a(t=>{let e=dy(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return f(c({},e),{currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([n,s])=>[s._def,{def:s._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))})},"getRefs"),py=a((t,e)=>{var r;let n=uy(e),s=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((d,[u,g])=>{var h;return f(c({},d),{[u]:(h=A(g._def,f(c({},n),{currentPath:[...n.basePath,n.definitionPath,u]}),!0))!=null?h:{}})},{}):void 0,i=typeof e=="string"?e:e?.name,o=(r=A(t._def,i===void 0?n:f(c({},n),{currentPath:[...n.basePath,n.definitionPath,i]}),!1))!=null?r:{},l=i===void 0?s?f(c({},o),{[n.definitionPath]:s}):o:{$ref:[...n.$refStrategy==="relative"?[]:n.basePath,n.definitionPath,i].join("/"),[n.definitionPath]:f(c({},s),{[i]:o})};return n.target==="jsonSchema7"?l.$schema="http://json-schema.org/draft-07/schema#":n.target==="jsonSchema2019-09"&&(l.$schema="https://json-schema.org/draft/2019-09/schema#"),l},"zodToJsonSchema"),fy=a((t,e={target:"openApi3"})=>{let r=py(t,e);return e.$schemaUrl===!1?delete r.$schema:typeof e.$schemaUrl=="string"&&(r.$schema=e.$schemaUrl),r},"toJSONSchemaLegacy");var gt=(t,e)=>{let r=t._def,n=e._def;if(r.typeName===y.ZodFirstPartyTypeKind.ZodObject&&n.typeName===y.ZodFirstPartyTypeKind.ZodObject){let s=r.shape(),i=n.shape();return y.object({...s,...i})}if(r.typeName===y.ZodFirstPartyTypeKind.ZodRecord&&n.typeName===y.ZodFirstPartyTypeKind.ZodRecord)return y.record(y.intersection(r.valueType,n.valueType));throw new Error("Cannot merge object schemas with record schemas")},Dd=y;var ne=y.string().min(1),Nd=y.object({text:ne}),Md=y.object({markdown:ne}),$d=y.object({imageUrl:ne}),jd=y.object({audioUrl:ne}),Kd=y.object({videoUrl:ne}),Ud=y.object({fileUrl:ne,title:ne.optional()}),zd=y.object({latitude:y.number(),longitude:y.number(),address:y.string().optional(),title:y.string().optional()}),Fd=y.object({title:ne,subtitle:ne.optional(),imageUrl:ne.optional(),actions:y.array(y.object({action:y.enum(["postback","url","say"]),label:ne,value:ne}))}),Hd=y.object({text:ne,options:y.array(y.object({label:ne,value:ne}))}),gy=y.object({items:y.array(Fd)}),Wd=y.union([y.object({type:y.literal("text"),payload:Nd}),y.object({type:y.literal("image"),payload:$d}),y.object({type:y.literal("audio"),payload:jd}),y.object({type:y.literal("video"),payload:Kd}),y.object({type:y.literal("file"),payload:Ud}),y.object({type:y.literal("location"),payload:zd})]),my=y.object({items:y.array(Wd)}),hy={schema:Md},yy={schema:y.object({items:y.array(y.union([...Wd.options,y.object({type:y.literal("markdown"),payload:Md})]))})},vy={text:{schema:Nd},image:{schema:$d},audio:{schema:jd},video:{schema:Kd},file:{schema:Ud},location:{schema:zd},carousel:{schema:gy},card:{schema:Fd},dropdown:{schema:Hd},choice:{schema:Hd},bloc:{schema:my}};var _y={HIDDEN_IN_STUDIO:{bpActionHiddenInStudio:"true"},AWAIT_RETURN:{bpActionAwaitReturn:"true"}};var Ld=require("browser-or-node");var $s=console;function le(t){if(!t.body)throw new Error("Missing body");return JSON.parse(t.body)}async function Vt(t,e=8072,r=Py){if(!Ld.isNode)throw new Error("This function can only be called in Node.js");let s=require("http").createServer(async(i,o)=>{try{let l=await Ty(i);if(l.path==="/health"){o.writeHead(200).end("ok");return}let d=await t(l);o.writeHead(d?.status??200,d?.headers??{}).end(d?.body??"{}")}catch(l){let d=l instanceof Error?l.message:String(l);$s.error("Error while handling request",{error:d??"Internal error occured"}),o.writeHead(500).end(JSON.stringify({error:d??"Internal error occured"}))}});return s.listen(e,()=>r(e)),s}async function Ty(t){let e=await wy(t),r={};for(let s=0;s<t.rawHeaders.length;s+=2){let i=t.rawHeaders[s].toLowerCase(),o=t.rawHeaders[s+1];r[i]=o}let n=new URL(t.url??"",t.headers.host?`http://${t.headers.host}`:"http://botpress.cloud");return{body:e,path:n.pathname,query:by(n.search,"?"),headers:r,method:t.method?.toUpperCase()??"GET"}}function by(t,e){return t.indexOf(e)===0?t.slice(e.length):t}async function wy(t){return new Promise((e,r)=>{if(t.method!=="POST"&&t.method!=="PUT"&&t.method!=="PATCH")return e(void 0);let n="";t.on("data",s=>n+=s.toString()),t.on("error",s=>r(s)),t.on("end",()=>e(n))})}function Py(t){$s.info(`Listening on port ${t}`)}var On=require("@botpress/client");var N={};Xe(N,{mapKeys:()=>Sy,mapValues:()=>ky,mergeRecords:()=>Oy,pairs:()=>gn,stripUndefinedProps:()=>Ey,values:()=>xy});var gn=t=>Object.entries(t),xy=t=>Object.values(t),ky=(t,e)=>Object.fromEntries(gn(t).map(([r,n])=>[r,e(n,r)])),Sy=(t,e)=>Object.fromEntries(gn(t).map(([r,n])=>[e(r),n])),Ey=t=>Object.fromEntries(gn(t).filter(([,e])=>e!==void 0)),Oy=(t,e,r)=>{let n=[...Object.keys(t),...Object.keys(e)],s=[...new Set(n)],i={};for(let o of s){let l=t[o],d=e[o];l&&d?i[o]=r(l,d):l?i[o]=l:d&&(i[o]=d)}return i};var E={};Xe(E,{safePush:()=>Zy,unique:()=>Iy});var Zy=(t,...e)=>t?[...t,...e]:[...e],Iy=t=>Array.from(new Set(t));var Y={};Xe(Y,{setName:()=>By});var By=(t,e)=>(Object.defineProperty(t,"name",{value:e}),t);var qd=t=>{let{name:e,version:r}=t,n={actions:{},events:{},channels:{}},s={name:e,version:r,entities:N.mapValues(t.entities,o=>({name:o.name})),actions:{},events:{},channels:{}},i=N.mapValues(t.entities,o=>o.schema);for(let[o,l]of Object.entries(t.definition.actions??{})){let d=l.input.schema.dereference(i),u=l.output.schema.dereference(i),g=t.actions?.[o]?.name??o;n.actions[g]={...l,...t.actions?.[o]??{},input:{schema:d},output:{schema:u}},s.actions[o]={name:g}}for(let[o,l]of Object.entries(t.definition.events??{})){let d=l.schema.dereference(i),u=t.events?.[o]?.name??o;n.events[u]={...l,...t.events?.[o]??{},schema:d},s.events[o]={name:u}}for(let[o,l]of Object.entries(t.definition.channels??{})){let d={};for(let[g,h]of Object.entries(l.messages)){let T=h.schema.dereference(i);d[g]={...h,schema:T}}let u=t.channels?.[o]?.name??o;n.channels[u]={...l,...t.channels?.[o]??{},message:{...l.message??{},tags:{...l.message?.tags??{},...t.channels?.[o]?.message?.tags??{}}},conversation:{...l.conversation??{},tags:{...l.conversation?.tags??{},...t.channels?.[o]?.conversation?.tags??{}}},messages:d},s.channels[o]={name:u}}return{resolved:n,statement:s}};var Vd="4.21.0";var Ee=Vd;var mn=Symbol("schemaName"),Gd=t=>t?N.mapValues(t,(r,n)=>({...r,[mn]:n})):{},Jd=t=>mn in t&&t[mn]!==void 0,Yd=t=>t[mn];var hn=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.readme=e.readme,this.title=e.title,this.identifier=e.identifier,this.description=e.description,this.configuration=e.configuration,this.configurations=e.configurations,this.events=e.events,this.actions=e.actions,this.channels=e.channels,this.states=e.states,this.user=e.user,this.secrets=e.secrets,this.entities=e.entities,this.interfaces=e.interfaces,this.__advanced=e.__advanced,this.attributes=e.attributes}name;version;title;description;icon;readme;configuration;configurations;events;actions;channels;states;user;secrets;identifier;entities;interfaces;__advanced;attributes;get metadata(){return{sdkVersion:Ee}}extend(e,r){let{entities:n,actions:s,events:i,channels:o}=this._callBuilder(e,r),l=this;l.interfaces??={};let d=Object.values(n).map(T=>T.name),u=d.length===0?e.name:`${e.name}<${d.join(",")}>`,{resolved:g,statement:h}=qd({...e,entities:n,actions:N.stripUndefinedProps(s),events:N.stripUndefinedProps(i),channels:N.stripUndefinedProps(o)});return l.actions=N.mergeRecords(l.actions??{},g.actions,this._mergeActions),l.channels=N.mergeRecords(l.channels??{},g.channels,this._mergeChannels),l.events=N.mergeRecords(l.events??{},g.events,this._mergeEvents),l.interfaces[u]={id:e.id,...h},this}_callBuilder(e,r){let s={entities:Gd(this.entities)},i=r(s),o=N.pairs(i.entities).find(([d,u])=>!Jd(u));if(o)throw new Error(`Cannot extend interface "${e.name}" with entity "${o[0]}"; the provided schema is not part of the integration's entities.`);return{entities:N.mapValues(i.entities,d=>({name:Yd(d),schema:d.schema})),actions:i.actions??{},events:i.events??{},channels:i.channels??{}}}_mergeActions=(e,r)=>({...e,...r,input:{schema:gt(e.input.schema,r.input.schema)},output:{schema:gt(e.output.schema,r.output.schema)}});_mergeEvents=(e,r)=>({...e,...r,schema:gt(e.schema,r.schema)});_mergeChannels=(e,r)=>{let n=N.mergeRecords(e.messages,r.messages,this._mergeMessage),s;(e.conversation||r.conversation)&&(s={tags:{...e.conversation?.tags,...r.conversation?.tags}});let i;return(e.message||r.message)&&(i={tags:{...e.message?.tags,...r.message?.tags}}),{...e,...r,messages:n,conversation:s,message:i}};_mergeMessage=(e,r)=>({schema:gt(e.schema,r.schema)})};var be=require("@botpress/client");var Xd=In(require("@botpress/client")),yn={retries:3,retryCondition:t=>Xd.axiosRetry.isNetworkOrIdempotentRequestError(t)||[429,502].includes(t.response?.status??0),retryDelay:(t,e)=>(Ry(e.response?.headers??{})??t)*1e3},Ry=t=>{let e=["RateLimit-Reset","X-RateLimit-Reset","Retry-After","ratelimit-reset","x-ratelimit-reset","retry-after"];for(let r of e){let n=t[r];if(n!==void 0)return Cy(String(n))}},Cy=t=>{let e=Dy(t)?Hy(t):t.length>0?parseInt(t,10):void 0;return e===void 0||isNaN(e)?void 0:e},Dy=t=>t.includes(" "),Hy=t=>{let e=Ny(t);if(!e)return;let r=new Date;return Math.max(0,Math.floor((e.getTime()-r.getTime())/1e3))},Ny=t=>{let e=new Date(t);return isNaN(e.getTime())?void 0:e};var mt=class{constructor(e){this._client=e}get _inner(){return this._client}createConversation=(e=>this._client.createConversation(e));getConversation=(e=>this._client.getConversation(e));listConversations=(e=>this._client.listConversations(e));getOrCreateConversation=(e=>this._client.getOrCreateConversation(e));updateConversation=(e=>this._client.updateConversation(e));deleteConversation=(e=>this._client.deleteConversation(e));listParticipants=(e=>this._client.listParticipants(e));addParticipant=(e=>this._client.addParticipant(e));getParticipant=(e=>this._client.getParticipant(e));removeParticipant=(e=>this._client.removeParticipant(e));createEvent=(e=>this._client.createEvent(e));getEvent=(e=>this._client.getEvent(e));listEvents=(e=>this._client.listEvents(e));createMessage=(e=>this._client.createMessage(e));getOrCreateMessage=(e=>this._client.getOrCreateMessage(e));getMessage=(e=>this._client.getMessage(e).then(r=>r));updateMessage=(e=>this._client.updateMessage(e).then(r=>r));listMessages=(e=>this._client.listMessages(e));deleteMessage=(e=>this._client.deleteMessage(e));createUser=(e=>this._client.createUser(e));getUser=(e=>this._client.getUser(e));listUsers=e=>this._client.listUsers(e);getOrCreateUser=(e=>this._client.getOrCreateUser(e));updateUser=(e=>this._client.updateUser(e));deleteUser=e=>this._client.deleteUser(e);getState=(e=>this._client.getState(e));setState=(e=>this._client.setState(e));getOrSetState=(e=>this._client.getOrSetState(e));patchState=(e=>this._client.patchState(e));configureIntegration=e=>this._client.configureIntegration(e);uploadFile=e=>this._client.uploadFile(e);upsertFile=e=>this._client.upsertFile(e);deleteFile=e=>this._client.deleteFile(e);listFiles=e=>this._client.listFiles(e);getFile=e=>this._client.getFile(e);updateFileMetadata=e=>this._client.updateFileMetadata(e);trackAnalytics=e=>this._client.trackAnalytics(e)};var vn=class{_cost=0;get cost(){return this._cost}setCost(e){this._cost=e}toJSON(){return{cost:this.cost}}};var Oe="#",_n="x-bot-id",Qd="x-bot-user-id",eu="x-integration-id",tu="x-integration-alias",ru="x-webhook-id",nu="x-bp-configuration-type",Tn="x-bp-configuration",bn="x-bp-operation",su="x-bp-type";var ce=t=>{throw t instanceof Error?t:new Error(t)};var u_=y.enum(["webhook_received","message_created","action_triggered","register","unregister","ping","create_user","create_conversation"]),iu=t=>({botId:t[_n]||ce("Missing bot header"),botUserId:t[Qd]||ce("Missing bot user header"),integrationId:t[eu]||ce("Missing integration header"),integrationAlias:t[tu]||ce("Missing integration alias header"),webhookId:t[ru]||ce("Missing webhook header"),operation:t[bn]||ce("Missing operation header"),configurationType:t[nu]??null,configuration:JSON.parse(Buffer.from(t[Tn]||ce("Missing configuration header"),"base64").toString("utf-8"))});var au=In(require("util")),ht=class{defaultOptions;constructor(e){this.defaultOptions=e}info(...e){this._log("info",e)}debug(...e){this._log("debug",e)}warn(...e){this._log("warn",e)}error(...e){this._log("error",e)}_log(e,r){this._getConsoleMethod(e)(this._serializeMessage(r))}_serializeMessage(e){let r=au.default.format(...e);return process.env.BP_LOG_FORMAT==="json"?this.getJsonMessage(r):r}getJsonMessage(e){return JSON.stringify({msg:e,options:this.defaultOptions})}_getConsoleMethod(e){switch(e){case"debug":return console.debug;case"warn":return console.warn;case"error":return console.error;default:return console.info}}};var yt=class t extends ht{constructor(e){super({visibleToBotOwners:!0,...e})}with(e){return new t({...this.defaultOptions,...e})}withUserId(e){return this.with({userId:e})}withConversationId(e){return this.with({conversationId:e})}withVisibleToBotOwners(e){return this.with({visibleToBotOwners:e})}forBot(){return this.withVisibleToBotOwners(!0)}getJsonMessage(e){return JSON.stringify({msg:e,visible_to_bot_owner:this.defaultOptions.visibleToBotOwners,options:this.defaultOptions})}};var My=t=>["traceparent","tracestate","sentry-trace"].reduce((e,r)=>(t[r]&&(e[r]=t[r]),e),{}),$y=(t,e,r)=>{let[,n]=(e.headers.traceparent||"").split("-"),s=new be.Client({botId:t.botId,integrationId:t.integrationId,integrationAlias:t.integrationAlias,retry:yn,headers:My(e.headers)}),i=new mt(s),o=new yt({traceId:n});return{ctx:t,req:e,client:i,logger:o,instance:r}},jy=async t=>{let{ctx:e}=t;switch(e.operation){case"webhook_received":return await Uy(t);case"register":return await zy(t);case"unregister":return await Fy(t);case"message_created":return await qy(t);case"action_triggered":return await Vy(t);case"ping":return await Ky(t);case"create_user":return await Wy(t);case"create_conversation":return await Ly(t);default:throw new be.InvalidPayloadError(`Unknown operation ${e.operation}`)}},ou=t=>async e=>{let r=iu(e.headers),n=$y(r,e,t),{logger:s}=n;try{let i;return i=await Gy(n),i?{...i,status:i.status??200}:(i=await jy(n),i?{...i,status:i.status??200}:{status:200})}catch(i){if((0,be.isApiError)(i)){let l=i.type==="Runtime"?i:new be.RuntimeError(i.message,i);return s.forBot().error(l.message),{status:l.code,body:JSON.stringify(l.toJSON())}}console.error(i);let o=new be.RuntimeError("An unexpected error occurred in the integration. Bot owners: Check logs for more informations. Integration owners: throw a RuntimeError to return a custom error message instead.");return s.forBot().error(o.message),{status:o.code,body:JSON.stringify(o.toJSON())}}},Ky=async t=>{},Uy=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{let{req:i}=le(r);return s.webhook({client:t,ctx:e,req:i,logger:n})},zy=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.register)return;let{webhookUrl:i}=le(r);await s.register({client:t,ctx:e,webhookUrl:i,logger:n})},Fy=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.unregister)return;let{webhookUrl:i}=le(r);await s.unregister({ctx:e,webhookUrl:i,client:t,logger:n})},Wy=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.createUser)return;let{tags:i}=le(r);return await s.createUser({ctx:e,client:t,tags:i,logger:n})},Ly=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.createConversation)return;let{channel:i,tags:o}=le(r);return await s.createConversation({ctx:e,client:t,channel:i,tags:o,logger:n})},qy=async({ctx:t,req:e,client:r,logger:n,instance:s})=>{let{conversation:i,user:o,type:l,payload:d,message:u}=le(e),g=s.channels[i.channel];if(!g)throw new Error(`Channel ${i.channel} not found`);let h=g.messages[l];if(!h)throw new Error(`Message of type ${l} not found in channel ${i.channel}`);await h({ctx:t,conversation:i,message:u,user:o,type:l,client:r,payload:d,ack:async({tags:Z})=>{await r.updateMessage({id:u.id,tags:Z})},logger:n})},Vy=async({req:t,ctx:e,client:r,logger:n,instance:s})=>{let{input:i,type:o}=le(t);if(!o)throw new Error("Missing action type");let l=s.actions[o];if(!l)throw new Error(`Action ${o} not found`);let d=new vn,g={output:await l({ctx:e,input:i,client:r,type:o,logger:n,metadata:d}),meta:d.toJSON()};return{body:JSON.stringify(g)}},Gy=async({instance:t,client:e,ctx:r,logger:n,req:s})=>{let i=t.unknownOperationHandler;if(i)return await i({client:e,ctx:r,logger:n,req:s})};var wn=class{constructor(e){this.props=e;this.actions=e.actions,this.channels=e.channels,this.register=e.register,this.unregister=e.unregister,this.createUser=e.createUser,this.createConversation=e.createConversation,this.webhook=e.handler,this.unknownOperationHandler=e.__advanced?.unknownOperationHandler}actions;channels;register;unregister;createUser;createConversation;webhook;unknownOperationHandler;handler=ou(this);start=e=>Vt(this.handler,e)};var Pn=class{constructor(e){this.props=e;this.integrations=e.integrations,this.plugins=e.plugins,this.user=e.user,this.conversation=e.conversation,this.message=e.message,this.states=e.states,this.configuration=e.configuration,this.events=e.events,this.recurringEvents=e.recurringEvents,this.actions=e.actions,this.tables=e.tables,this.workflows=e.workflows,this.attributes=e.attributes,this.__advanced=e.__advanced,this.withPlugins={user:e.user,conversation:e.conversation,message:e.message,states:e.states,events:e.events,recurringEvents:e.recurringEvents,actions:e.actions,tables:e.tables,workflows:e.workflows}}integrations;plugins;user;conversation;message;states;configuration;events;recurringEvents;actions;tables;workflows;attributes;__advanced;withPlugins;get metadata(){return{sdkVersion:Ee}}addIntegration(e,r){let n=this;n.integrations||(n.integrations={});let s=r?.alias??e.name;if(n.integrations[s])throw new Error(`Another integration with alias "${s}" is already installed in the bot`);return n.integrations[s]={...e,alias:s,enabled:r?.enabled,configurationType:r?.configurationType,configuration:r?.configuration,disabledChannels:r?.disabledChannels},this}addPlugin(e,r){let n=this;n.plugins||(n.plugins={});let s=r.alias??e.name;if(n.plugins[s])throw new Error(`Another plugin with alias "${s}" is already installed in the bot`);return n.plugins[s]={...e,alias:s,configuration:r.configuration,interfaces:r.interfaces},n.withPlugins.user=this._mergeUser(n.withPlugins.user,e.definition.user),n.withPlugins.conversation=this._mergeConversation(n.withPlugins.conversation,e.definition.conversation),n.withPlugins.message=this._mergeMessage(n.withPlugins.message,e.definition.message),n.withPlugins.recurringEvents=this._mergeRecurringEvents(n.withPlugins.recurringEvents,e.definition.recurringEvents),n.withPlugins.tables=this._mergeTables(n.withPlugins.tables,e.definition.tables),n.withPlugins.workflows=this._mergeWorkflows(n.withPlugins.workflows,e.definition.workflows),n.withPlugins.states=this._mergeStates(n.withPlugins.states,this._prefixKeysWithPluginAlias(e.definition.states,s)),n.withPlugins.events=this._mergeEvents(n.withPlugins.events,this._prefixKeysWithPluginAlias(e.definition.events,s)),n.withPlugins.actions=this._mergeActions(n.withPlugins.actions,this._prefixKeysWithPluginAlias(e.definition.actions,s)),this}_mergeUser=(e,r)=>({tags:{...e?.tags,...r?.tags}});_mergeConversation=(e,r)=>({tags:{...e?.tags,...r?.tags}});_mergeMessage=(e,r)=>({tags:{...e?.tags,...r?.tags}});_mergeStates=(e,r)=>({...e,...r});_mergeEvents=(e,r)=>({...e,...r});_mergeRecurringEvents=(e,r)=>({...e,...r});_mergeActions=(e,r)=>({...e,...r});_mergeTables=(e,r)=>({...e,...r});_mergeWorkflows=(e,r)=>({...e,...r});_prefixKeysWithPluginAlias=(e,r)=>N.mapKeys(e??{},n=>`${r}${Oe}${n}`);dereferencePluginEntities(){let e=this._buildZuiReferenceMap();return{...this,withPlugins:{...this.withPlugins,events:this._dereferenceDefinitionSchemas(this.withPlugins.events,e),states:this._dereferenceDefinitionSchemas(this.withPlugins.states,e),tables:this._dereferenceDefinitionSchemas(this.withPlugins.tables,e),actions:this._dereferenceActionDefinitionSchemas(this.withPlugins.actions,e)},plugins:Object.fromEntries(Object.entries(this.plugins??{}).map(([r,n])=>[r,{...n,definition:{...n.definition,configuration:this._dereferenceDefinitionSchema(n.definition.configuration,e),events:this._dereferenceDefinitionSchemas(n.definition.events,e),states:this._dereferenceDefinitionSchemas(n.definition.states,e),tables:this._dereferenceDefinitionSchemas(n.definition.tables,e),actions:this._dereferenceActionDefinitionSchemas(n.definition.actions,e)}}]))}}_buildZuiReferenceMap(){let e={},r=Object.entries(this.plugins??{});for(let[n,s]of r){let i=Object.entries(s.interfaces??{});for(let[o,l]of i){let d=this.integrations?.[l.name];if(!d)throw new Error(`Interface with alias "${o}" of plugin with alias "${n}" references integration "${l.name}" which is not installed`);let u=Object.entries(l.entities??{});for(let[g,{name:h}]of u){let T=d.definition.entities?.[h]?.schema;if(!T)throw new Error(`Interface entity "${h}" does not exist in integration "${d.name}"`);e[`interface:${o}/entities/${g}`]=T}}}return e}_dereferenceZuiSchema(e,r){return e.dereference(r)}_dereferenceDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,this._dereferenceDefinitionSchema(s,r)]))}_dereferenceDefinitionSchema(e,r){return e&&{...e,schema:this._dereferenceZuiSchema(e.schema,r)}}_dereferenceActionDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,{...s,input:{schema:this._dereferenceZuiSchema(s.input.schema,r)},output:{schema:this._dereferenceZuiSchema(s.output.schema,r)}}]))}};var Ye=require("@botpress/client");var vt=class t extends ht{constructor(e){super({...e})}with(e){return new t({...this.defaultOptions,...e})}withUserId(e){return this.with({userId:e})}withConversationId(e){return this.with({conversationId:e})}withWorkflowId(e){return this.with({workflowId:e})}withEventId(e){return this.with({eventId:e})}withMessageId(e){return this.with({messageId:e})}};var fe=class{constructor(e,r={before:{},after:{}}){this._client=e;this._hooks=r}get _inner(){return this._client}getConversation=(e=>this._run("getConversation",e));listConversations=(e=>this._run("listConversations",e));updateConversation=(e=>this._run("updateConversation",e));deleteConversation=(e=>this._run("deleteConversation",e));listParticipants=(e=>this._run("listParticipants",e));addParticipant=(e=>this._run("addParticipant",e));getParticipant=(e=>this._run("getParticipant",e));removeParticipant=(e=>this._run("removeParticipant",e));createEvent=(e=>this._run("createEvent",e));getEvent=(e=>this._run("getEvent",e));listEvents=(e=>this._run("listEvents",e));createMessage=(e=>this._run("createMessage",e));getOrCreateMessage=(e=>this._run("getOrCreateMessage",e));getMessage=(e=>this._run("getMessage",e));updateMessage=(e=>this._run("updateMessage",e));listMessages=(e=>this._run("listMessages",e));deleteMessage=(e=>this._run("deleteMessage",e));getUser=(e=>this._run("getUser",e));listUsers=(e=>this._run("listUsers",e));updateUser=(e=>this._run("updateUser",e));deleteUser=(e=>this._run("deleteUser",e));getState=(e=>this._run("getState",e));setState=(e=>this._run("setState",e));getOrSetState=(e=>this._run("getOrSetState",e));patchState=(e=>this._run("patchState",e));callAction=(e=>this._run("callAction",e));uploadFile=(e=>this._run("uploadFile",e));upsertFile=(e=>this._run("upsertFile",e));deleteFile=(e=>this._run("deleteFile",e));listFiles=(e=>this._run("listFiles",e));getFile=(e=>this._run("getFile",e));updateFileMetadata=(e=>this._run("updateFileMetadata",e));searchFiles=(e=>this._run("searchFiles",e));trackAnalytics=(e=>this._run("trackAnalytics",e));getTableRow=(e=>this._run("getTableRow",e));createTableRows=(e=>this._run("createTableRows",e));findTableRows=(e=>this._run("findTableRows",e));deleteTableRows=(e=>this._run("deleteTableRows",e));updateTableRows=(e=>this._run("updateTableRows",e));upsertTableRows=(e=>this._run("upsertTableRows",e));createWorkflow=(e=>this._run("createWorkflow",e));getOrCreateWorkflow=(e=>this._run("getOrCreateWorkflow",e));getWorkflow=(e=>this._run("getWorkflow",e));updateWorkflow=(e=>this._run("updateWorkflow",e));deleteWorkflow=(e=>this._run("deleteWorkflow",e));listWorkflows=(e=>this._run("listWorkflows",e));createConversation=e=>this._client.createConversation(e);getOrCreateConversation=e=>this._client.getOrCreateConversation(e);createUser=e=>this._client.createUser(e);getOrCreateUser=e=>this._client.getOrCreateUser(e);_run=async(e,r)=>{let n=this._hooks.before[e];n&&(r=await n(r));let s=await this._client[e](r),i=this._hooks.after[e];return i&&(s=await i(s,r)),s}};var Jy=y.enum(["event_received","register","unregister","ping","action_triggered"]),lu=t=>({botId:t[_n]||ce("Missing bot id header"),operation:Jy.parse(t[bn]),type:t[su]||ce("Missing type header"),configuration:JSON.parse(Buffer.from(t[Tn]||ce("Missing configuration header"),"base64").toString("utf-8"))});var X={status:200};var Ks=t=>{switch(t){case"workflow_continued":return"continued";case"workflow_started":return"started";case"workflow_timedout":return"timed_out";default:throw new Error(`Unsupported workflow update type: ${t}`)}};var Yy=["child_workflow_deleted","child_workflow_finished","workflow_timedout","workflow_started","workflow_continued"],cu=async(t,e)=>{if(t.ctx.type!=="workflow_update"||!Yy.includes(e.payload.type))throw new Error("Unexpected event type");let r={...t,logger:Xy(t,e)};if(!e.payload.workflow.name)return r.logger.warn("Received workflow update event without a workflow name. Assuming this workflow was not defined by the bot.",e.payload.workflow),X;switch(e.payload.type){case"child_workflow_deleted":case"child_workflow_finished":r.logger.info(`Received child workflow event "${e.payload.type}", but child workflows are not yet supported`);break;case"workflow_timedout":case"workflow_started":case"workflow_continued":return await Qy(r,e);default:e.payload.type}return X},Xy=(t,e)=>t.logger.with({eventId:e.id,workflowId:e.payload.workflow.id,conversationId:e.payload.conversation?.id,userId:e.payload.user?.id}),Qy=async(t,e)=>{let r=Ks(e.payload.type),n=t.self.workflowHandlers[r]?.[e.payload.workflow.name];if(!n||n.length===0)return t.logger.warn(`No ${r} handler found for workflow "${e.payload.workflow.name}"`),X;let{updatedWorkflow:s}=await ev(t,e);return s.status==="pending"&&t.logger.warn(`Workflow "${e.payload.workflow.name}" is still in pending status after processing "${r}" event. This may indicate that the workflow was not properly acknowledged or terminated by the handler. `),X},ev=async(t,e)=>{let r=Ks(e.payload.type),n=t.self.workflowHandlers[r]?.[e.payload.workflow.name],s=structuredClone(e.payload.workflow);for(let i of n??[])s=await i({...t,event:e,conversation:e.payload.conversation,user:e.payload.user,workflow:s});return{updatedWorkflow:s}};var du=t=>async e=>{let r=lu(e.headers),n=new vt,s=new Ye.Client({botId:r.botId,retry:yn}),i=new fe(s,{before:{createMessage:async l=>{let d=t.hookHandlers.before_outgoing_message[l.type]??[];for(let u of d){let g=new fe(s);l=(await u({client:g,ctx:r,logger:n.with({conversationId:l.conversationId,userId:l.userId}),data:l}))?.data??l}return l},callAction:async l=>{let d=t.hookHandlers.before_outgoing_call_action[l.type]??[];for(let u of d){let g=new fe(s);l=(await u({client:g,ctx:r,logger:n,data:l}))?.data??l}return l}},after:{createMessage:async l=>{let d=t.hookHandlers.after_outgoing_message[l.message.type]??[];for(let u of d){let g=new fe(s);l=(await u({client:g,ctx:r,logger:n.with({messageId:l.message.id,conversationId:l.message.conversationId,userId:l.message.userId}),data:l}))?.data??l}return l},callAction:async(l,d)=>{let{type:u}=d,g=t.hookHandlers.after_outgoing_call_action[u]??[];for(let h of g){let T=new fe(s);l=(await h({client:T,ctx:r,logger:n,data:{type:u,...l}}))?.data??l}return l}}}),o={req:e,ctx:r,logger:n,client:i,self:t};try{switch(r.operation){case"action_triggered":return await iv(o);case"event_received":return await sv(o);case"register":return await rv(o);case"unregister":return await nv(o);case"ping":return await tv(o);default:throw new Error(`Unknown operation ${r.operation}`)}}catch(l){let d=l instanceof Error?l:new Error(String(l));if((0,Ye.isApiError)(d)){let g=d.type==="Runtime"?d:new Ye.RuntimeError(d.message,d);return n.error(g.message),{status:g.code,body:JSON.stringify(g.toJSON())}}let u=new Ye.RuntimeError("An unexpected error occurred in the bot.",d);return n.error(u.message,d),{status:u.code,body:JSON.stringify(u.toJSON())}}},tv=async t=>X,rv=async t=>X,nv=async t=>X,sv=async t=>{let{ctx:e,logger:r,req:n,client:s,self:i}=t,o={client:s,ctx:e,logger:r},l=le(n);if(o.logger=o.logger.with({eventId:l.event.id,messageId:l.event.messageId,conversationId:l.event.conversationId,userId:l.event.userId}),e.type==="workflow_update")return await cu(t,l.event);if(e.type==="message_created"){let Z=l.event,k=Z.payload.message;o.logger=o.logger.with({messageId:k.id,conversationId:k.conversationId,userId:k.userId});let K=i.hookHandlers.before_incoming_message[k.type]??[];for(let ue of K){let ae=await ue({...o,data:k});if(k=ae?.data??k,ae?.stop)return X}let F={...o,user:Z.payload.user,conversation:Z.payload.conversation,message:k,event:Z},Q=i.messageHandlers[k.type]??[];for(let ue of Q)await ue(F);let ie=i.hookHandlers.after_incoming_message[k.type]??[];for(let ue of ie){let ae=await ue({...o,data:k});if(k=ae?.data??k,ae?.stop)return X}return X}if(e.type==="state_expired"){let k=l.event.payload.state,K={...o,state:k},F=i.stateExpiredHandlers[k.name]??[];for(let Q of F)await Q(K);return X}let d=l.event,u=i.hookHandlers.before_incoming_event[d.type]??[];for(let Z of u){let k=await Z({...o,data:d});if(d=k?.data??d,k?.stop)return X}let g={...o,event:d},h=i.eventHandlers[d.type]??[];for(let Z of h)await Z(g);let T=i.hookHandlers.after_incoming_event[d.type]??[];for(let Z of T){let k=await Z({...o,data:d});if(d=k?.data??d,k?.stop)return X}return X},iv=async({ctx:t,logger:e,req:r,client:n,self:s})=>{let{input:i,type:o}=le(r);if(!o)throw new Error("Missing action type");let l=s.hookHandlers.before_incoming_call_action[o]??[];for(let T of l){let Z=await T({ctx:t,logger:e,client:n,data:{type:o,input:i}});i=Z?.data?.input??i,o=Z?.data?.type??o}let d=s.actionHandlers[o];if(!d)throw new Error(`Action ${o} not found`);let u=await d({ctx:t,logger:e,input:i,client:n,type:o}),g=s.hookHandlers.after_incoming_call_action[o]??[];for(let T of g){let Z=await T({ctx:t,logger:e,client:n,data:{type:o,output:u}});o=Z?.data?.type??o,u=Z?.data?.output??u}return{status:200,body:JSON.stringify({output:u})}};var we=t=>new Proxy({},{get:(e,r)=>({listInstances:{all:n=>Ze({workflowName:r,client:t,input:n}),running:n=>Ze({workflowName:r,client:t,input:n,statuses:["in_progress"]}),scheduled:n=>Ze({workflowName:r,client:t,input:n,statuses:["pending","listening"]}),allFinished:n=>Ze({workflowName:r,client:t,input:n,statuses:["completed","cancelled","failed","timedout"]}),cancelled:n=>Ze({workflowName:r,client:t,input:n,statuses:["cancelled"]}),failed:n=>Ze({workflowName:r,client:t,input:n,statuses:["failed"]}),succeeded:n=>Ze({workflowName:r,client:t,input:n,statuses:["completed"]}),timedOut:n=>Ze({workflowName:r,client:t,input:n,statuses:["timedout"]})},startNewInstance:async n=>{let{workflow:s}=await t.createWorkflow({name:r,status:"pending",...n});return{workflow:de({client:t,workflow:s})}}})}),Ze=async t=>{let e=await t.client.listWorkflows({name:t.workflowName,statuses:t.statuses,...t.input});return{...e,workflows:e.workflows.map(r=>de({client:t.client,workflow:r}))}},de=t=>{let e=!1;return{...t.workflow,async update(r){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,...r});return await t.onWorkflowUpdate?.(n),{workflow:de({...t,workflow:n})}},async acknowledgeStartOfProcessing(){if(!t.event||t.workflow.status!=="pending"||e)return{workflow:de(t)};let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,status:"in_progress",eventId:t.event.id});return e=!0,await t.onWorkflowUpdate?.(r),{workflow:de({...t,workflow:r})}},async setFailed({failureReason:r}){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,status:"failed",failureReason:r});return await t.onWorkflowUpdate?.(n),{workflow:de({...t,workflow:n})}},async setCompleted({output:r}={}){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,status:"completed",output:r});return await t.onWorkflowUpdate?.(n),{workflow:de({...t,workflow:n})}},async cancel(){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,status:"cancelled"});return await t.onWorkflowUpdate?.(r),{workflow:de({...t,workflow:r})}}}};var xn=class{constructor(e){this.props=e;this._actionHandlers=e.actions,this._plugins=e.plugins}_actionHandlers;_messageHandlers={};_eventHandlers={};_stateExpiredHandlers={};_hookHandlers={before_incoming_event:{},before_incoming_message:{},before_outgoing_message:{},before_outgoing_call_action:{},before_incoming_call_action:{},after_incoming_event:{},after_incoming_message:{},after_outgoing_message:{},after_outgoing_call_action:{},after_incoming_call_action:{}};_workflowHandlers={started:{},continued:{},timed_out:{}};_plugins={};_registerOrder=0;get actionHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._actionHandlers[r];if(n)return n;for(let[s,i]of Object.entries(this._plugins)){let[o,l]=r.split(Oe);if(!(o!==s||!l)&&(n=i.actionHandlers[l],n))return Y.setName(d=>n({...d,workflows:we(d.client)}),n.name)}}})}get messageHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.messageHandlers[r]??[]),s=this._messageHandlers[r]??[],i=this._messageHandlers["*"]??[],o=[...s,...i].sort((l,d)=>l.order-d.order).map(({handler:l})=>l);return E.unique([...n,...o]).map(l=>Y.setName(d=>l({...d,workflows:we(d.client)}),l.name))}})}get eventHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.eventHandlers[r]??[]),s=this._eventHandlers[r]??[],i=this._eventHandlers["*"]??[],o=[...s,...i].sort((l,d)=>l.order-d.order).map(({handler:l})=>l);return E.unique([...n,...o]).map(l=>Y.setName(d=>l({...d,workflows:we(d.client)}),l.name))}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.stateExpiredHandlers[r]??[]),s=this._stateExpiredHandlers[r]??[],i=this._stateExpiredHandlers["*"]??[],o=[...s,...i].sort((l,d)=>l.order-d.order).map(({handler:l})=>l);return E.unique([...n,...o]).map(l=>Y.setName(d=>l({...d,workflows:we(d.client)}),l.name))}})}get hookHandlers(){return new Proxy({},{get:(e,r)=>{if(this._hookHandlers[r])return new Proxy({},{get:(s,i)=>{let o=Object.values(this._plugins).flatMap(h=>h.hookHandlers[r]?.[i]??[]),l=this._hookHandlers[r]??{},d=l[i]??[],u=l["*"]??[],g=[...d,...u].sort((h,T)=>h.order-T.order).map(({handler:h})=>h);return E.unique([...o,...g]).map(h=>Y.setName(T=>h({...T,workflows:we(T.client)}),h.name))}})}})}get workflowHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._workflowHandlers[r];if(n)return new Proxy({},{get:(s,i)=>{let o=n[i]?.sort((d,u)=>d.order-u.order).map(({handler:d})=>d)??[],l=Object.values(this._plugins).flatMap(d=>d.workflowHandlers[r]?.[i]??[]);return E.unique([...o,...l]).map(d=>Y.setName(async u=>{let g=u.workflow;return await d({...u,workflow:de({...u,onWorkflowUpdate(h){g=h}}),workflows:we(u.client)}),g},d.name))}})}})}on={message:(e,r)=>{this._messageHandlers[e]=E.safePush(this._messageHandlers[e],{handler:r,order:this._registerOrder++})},event:(e,r)=>{this._eventHandlers[e]=E.safePush(this._eventHandlers[e],{handler:r,order:this._registerOrder++})},stateExpired:(e,r)=>{this._stateExpiredHandlers[e]=E.safePush(this._stateExpiredHandlers[e],{handler:r,order:this._registerOrder++})},beforeIncomingEvent:(e,r)=>{this._hookHandlers.before_incoming_event[e]=E.safePush(this._hookHandlers.before_incoming_event[e],{handler:r,order:this._registerOrder++})},beforeIncomingMessage:(e,r)=>{this._hookHandlers.before_incoming_message[e]=E.safePush(this._hookHandlers.before_incoming_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingMessage:(e,r)=>{this._hookHandlers.before_outgoing_message[e]=E.safePush(this._hookHandlers.before_outgoing_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingCallAction:(e,r)=>{this._hookHandlers.before_outgoing_call_action[e]=E.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},beforeIncomingCallAction:(e,r)=>{this._hookHandlers.before_incoming_call_action[e]=E.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingEvent:(e,r)=>{this._hookHandlers.after_incoming_event[e]=E.safePush(this._hookHandlers.after_incoming_event[e],{handler:r,order:this._registerOrder++})},afterIncomingMessage:(e,r)=>{this._hookHandlers.after_incoming_message[e]=E.safePush(this._hookHandlers.after_incoming_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingMessage:(e,r)=>{this._hookHandlers.after_outgoing_message[e]=E.safePush(this._hookHandlers.after_outgoing_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingCallAction:(e,r)=>{this._hookHandlers.after_outgoing_call_action[e]=E.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingCallAction:(e,r)=>{this._hookHandlers.after_incoming_call_action[e]=E.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:r,order:this._registerOrder++})},workflowStart:(e,r)=>{this._workflowHandlers.started[e]=E.safePush(this._workflowHandlers.started[e],{handler:r,order:this._registerOrder++})},workflowContinue:(e,r)=>{this._workflowHandlers.continued[e]=E.safePush(this._workflowHandlers.continued[e],{handler:r,order:this._registerOrder++})},workflowTimeout:(e,r)=>{this._workflowHandlers.timed_out[e]=E.safePush(this._workflowHandlers.timed_out[e],{handler:r,order:this._registerOrder++})}};handler=du(this);start=e=>Vt(this.handler,e)};var kn=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.title=e.title,this.description=e.description,this.readme=e.readme,this.entities=e.entities??{},this.attributes=e.attributes,this.__advanced=e.__advanced;let r=this._getEntityReference(this.entities),n=e.events===void 0?{}:N.mapValues(e.events,o=>({...o,schema:o.schema(r)})),s=e.actions===void 0?{}:N.mapValues(e.actions,o=>({...o,input:{...o.input,schema:o.input.schema(r)},output:{...o.output,schema:o.output.schema(r)}})),i=e.channels===void 0?{}:N.mapValues(e.channels,o=>({...o,messages:N.mapValues(o.messages,l=>({...l,schema:l.schema(r)}))}));this.events=n,this.actions=s,this.channels=i}name;version;title;description;icon;readme;attributes;entities;events;actions;channels;__advanced;get metadata(){return{sdkVersion:Ee}}_getEntityReference=e=>{let r={};for(let[n,s]of Object.entries(e)){let i=s.schema._def["x-zui"]?.title,o=s.schema._def.description,l=Dd.ref(n);i&&l.title(i),o&&l.describe(o),r[n]=l}return r}};var Sn=class{constructor(e){this.props=e;let r=Object.fromEntries(Object.entries(e.interfaces??{}).map(([n,s])=>[n,Object.fromEntries(Object.entries(s.definition.entities??{}).map(([i])=>[i,y.ref(`interface:${n}/entities/${i}`)]))]));this.name=e.name,this.version=e.version,this.icon=e.icon,this.readme=e.readme,this.title=e.title,this.description=e.description,this.integrations=e.integrations,this.interfaces=e.interfaces,this.user=e.user,this.conversation=e.conversation,this.message=e.message,this.recurringEvents=e.recurringEvents,this.workflows=e.workflows,this.attributes=e.attributes,this.__advanced=e.__advanced,this.configuration=e.configuration?{...e.configuration,schema:typeof e.configuration.schema=="object"?e.configuration.schema:e.configuration.schema({entities:r})}:void 0,this.states=Object.fromEntries(Object.entries(e.states??{}).map(([n,s])=>[n,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:r})}])),this.events=Object.fromEntries(Object.entries(e.events??{}).map(([n,s])=>[n,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:r})}])),this.actions=Object.fromEntries(Object.entries(e.actions??{}).map(([n,s])=>[n,{...s,input:{...s.input,schema:typeof s.input.schema=="object"?s.input.schema:s.input.schema({entities:r})},output:{...s.output,schema:typeof s.output.schema=="object"?s.output.schema:s.output.schema({entities:r})}}])),this.tables=Object.fromEntries(Object.entries(e.tables??{}).map(([n,s])=>[n,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:r})}]))}name;version;title;description;icon;readme;attributes;integrations;interfaces;user;conversation;message;states;configuration;events;recurringEvents;actions;tables;workflows;__advanced;get metadata(){return{sdkVersion:Ee}}dereferenceEntities({intersectWithUnknownRecord:e}={intersectWithUnknownRecord:!0}){let r=this._buildZuiReferenceMap(e);return{...this,configuration:this.configuration?{...this.configuration,schema:this._dereferenceZuiSchema(this.configuration.schema,r)}:void 0,events:this._dereferenceDefinitionSchemas(this.events,r),states:this._dereferenceDefinitionSchemas(this.states,r),tables:this._dereferenceDefinitionSchemas(this.tables,r),actions:this._dereferenceActionDefinitionSchemas(this.actions,r)}}_buildZuiReferenceMap(e){return Object.fromEntries(Object.entries(this.interfaces??{}).flatMap(([r,n])=>Object.entries(n.definition.entities??{}).map(([s,i])=>[`interface:${r}/entities/${s}`,e?i.schema.and(y.record(y.string(),y.unknown())):i.schema])))}_dereferenceZuiSchema(e,r){return e.dereference(r)}_dereferenceDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,{...s,schema:this._dereferenceZuiSchema(s.schema,r)}]))}_dereferenceActionDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,{...s,input:{schema:this._dereferenceZuiSchema(s.input.schema,r)},output:{schema:this._dereferenceZuiSchema(s.output.schema,r)}}]))}};var Us=":";var uu=t=>{let[e,r]=t.split(Us);return!e||!r?null:{namespace:e,eventName:r}},pu=t=>`${t.namespace}${Us}${t.actionName}`,fu=t=>`${t.namespace}${Us}${t.eventName}`,gu=(t,e)=>{let r=e[t.namespace]??{name:t.namespace,version:"0.0.0",entities:{},actions:{},events:{},channels:{}},n=r.name,s=r.actions[t.actionName]?.name??t.actionName;return{namespace:n,actionName:s}},mu=(t,e)=>{let r=e[t.namespace]??{name:t.namespace,version:"0.0.0",entities:{},actions:{},events:{},channels:{}},n=r.name,s=r.events[t.eventName]?.name??t.eventName;return{namespace:n,eventName:s}};var hu=(t,e)=>new Proxy({},{get:(r,n)=>new Proxy({},{get:(s,i)=>o=>av({client:t,interfaces:e.interfaces,integrationOrInterfaceName:n,methodName:i,input:o})})}),av=async({client:t,interfaces:e,integrationOrInterfaceName:r,methodName:n,input:s})=>{let i=gu({namespace:r,actionName:n},e),o=pu(i);return(await t.callAction({type:o,input:s})).output};var zs=class t{constructor(e){this._props=e}async emit(e){let{conversationId:r,userId:n,messageId:s}=this._props;await this._props.client.createEvent({type:this._props.eventName,payload:e,conversationId:r,userId:n,messageId:s})}async schedule(e,r){let{conversationId:n,userId:s,messageId:i}=this._props;await this._props.client.createEvent({type:this._props.eventName,payload:e,conversationId:n,userId:s,messageId:i,schedule:r})}withConversationId(e){return new t({...this._props,conversationId:e})}withUserId(e){return new t({...this._props,userId:e})}withMessageId(e){return new t({...this._props,messageId:e})}},yu=(t,e)=>new Proxy({},{get:(r,n)=>{let s=e.alias!==void 0?`${e.alias}${Oe}${n}`:n;return new zs({client:t,eventName:s})}});var Fs=class{constructor(e,r,n){this._client=e;this._stateType=r;this._stateName=n}async get(e){return await this._client.getState({type:this._stateType,name:this._stateName,id:e}).then(r=>r.state.payload)}async set(e,r,n){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:r,expiry:n?.expiryMs})}async getOrSet(e,r,n){return await this._client.getOrSetState({type:this._stateType,name:this._stateName,id:e,payload:r,expiry:n?.expiryMs}).then(s=>s.state.payload)}async delete(e){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:null})}async patch(e,r){await this._client.patchState({type:this._stateType,name:this._stateName,id:e,payload:r})}},vu=(t,e)=>new Proxy({},{get:(r,n)=>new Proxy({},{get:(s,i)=>{let o=e.alias!==void 0?`${e.alias}${Oe}${i}`:i;return new Fs(t,n,o)}})});var En=class{constructor(e){this.props=e;this._actionHandlers=e.actions}_runtimeProps;_actionHandlers;_messageHandlers={};_eventHandlers={};_stateExpiredHandlers={};_hookHandlers={before_incoming_event:{},before_incoming_message:{},before_outgoing_message:{},before_outgoing_call_action:{},before_incoming_call_action:{},after_incoming_event:{},after_incoming_message:{},after_outgoing_message:{},after_outgoing_call_action:{},after_incoming_call_action:{}};_workflowHandlers={started:{},continued:{},timed_out:{}};_registerOrder=0;initialize(e){return this._runtimeProps=e,this}get _runtime(){if(!this._runtimeProps)throw new Error("Plugin not correctly initialized. This is likely because you access your plugin config outside of an handler.");return this._runtimeProps}_getTools(e){let{configuration:r,interfaces:n,alias:s}=this._runtime,i=hu(e,this._runtime),o=vu(e,this._runtime),l=we(e),d=yu(e,this._runtime);return{configuration:r,interfaces:n,actions:i,states:o,alias:s,workflows:l,events:d}}get actionHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._actionHandlers[r];if(n)return Y.setName(s=>n({...s,...this._getTools(s.client)}),n.name)}})}get messageHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._messageHandlers[r]??[],s=this._messageHandlers["*"]??[];return E.unique([...n,...s]).sort((o,l)=>o.order-l.order).map(({handler:o})=>Y.setName(l=>o({...l,message:l.message,...this._getTools(l.client)}),o.name))}})}get eventHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._eventHandlers[r]??[],s=Object.entries(this._eventHandlers).filter(([l])=>this._eventResolvesTo(l,r)).flatMap(([,l])=>l??[]),i=this._eventHandlers["*"]??[];return E.unique([...n,...s,...i]).sort((l,d)=>l.order-d.order).map(({handler:l})=>Y.setName(d=>l({...d,event:d.event,...this._getTools(d.client)}),l.name))}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._stateExpiredHandlers[r]??[],s=this._stateExpiredHandlers["*"]??[];return E.unique([...n,...s]).sort((o,l)=>o.order-l.order).map(({handler:o})=>Y.setName(l=>o({...l,state:l.state,...this._getTools(l.client)}),o.name))}})}get hookHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._hookHandlers[r];if(n)return new Proxy({},{get:(s,i)=>{i=this._stripAliasPrefix(i);let o=n[i]??[],l=Object.entries(n).filter(([g])=>this._eventResolvesTo(g,i)).flatMap(([,g])=>g??[]),d=n["*"]??[];return E.unique([...o,...l,...d]).sort((g,h)=>g.order-h.order).map(({handler:g})=>Y.setName(h=>g({...h,data:h.data,...this._getTools(h.client)}),g.name))}})}})}get workflowHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._workflowHandlers[r];if(n)return new Proxy({},{get:(s,i)=>(n[i]?.sort((l,d)=>l.order-d.order)??[]).map(({handler:l})=>Y.setName(async d=>{let u=d.workflow;return await l({...d,workflow:de({...d,onWorkflowUpdate(g){u=g}}),...this._getTools(d.client)}),u},l.name))})}})}on={message:(e,r)=>{this._messageHandlers[e]=E.safePush(this._messageHandlers[e],{handler:r,order:this._registerOrder++})},event:(e,r)=>{this._eventHandlers[e]=E.safePush(this._eventHandlers[e],{handler:r,order:this._registerOrder++})},stateExpired:(e,r)=>{this._stateExpiredHandlers[e]=E.safePush(this._stateExpiredHandlers[e],{handler:r,order:this._registerOrder++})},beforeIncomingEvent:(e,r)=>{this._hookHandlers.before_incoming_event[e]=E.safePush(this._hookHandlers.before_incoming_event[e],{handler:r,order:this._registerOrder++})},beforeIncomingMessage:(e,r)=>{this._hookHandlers.before_incoming_message[e]=E.safePush(this._hookHandlers.before_incoming_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingMessage:(e,r)=>{this._hookHandlers.before_outgoing_message[e]=E.safePush(this._hookHandlers.before_outgoing_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingCallAction:(e,r)=>{this._hookHandlers.before_outgoing_call_action[e]=E.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},beforeIncomingCallAction:(e,r)=>{this._hookHandlers.before_incoming_call_action[e]=E.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingEvent:(e,r)=>{this._hookHandlers.after_incoming_event[e]=E.safePush(this._hookHandlers.after_incoming_event[e],{handler:r,order:this._registerOrder++})},afterIncomingMessage:(e,r)=>{this._hookHandlers.after_incoming_message[e]=E.safePush(this._hookHandlers.after_incoming_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingMessage:(e,r)=>{this._hookHandlers.after_outgoing_message[e]=E.safePush(this._hookHandlers.after_outgoing_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingCallAction:(e,r)=>{this._hookHandlers.after_outgoing_call_action[e]=E.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingCallAction:(e,r)=>{this._hookHandlers.after_incoming_call_action[e]=E.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:r,order:this._registerOrder++})},workflowStart:(e,r)=>{this._workflowHandlers.started[e]=E.safePush(this._workflowHandlers.started[e],{handler:r,order:this._registerOrder++})},workflowContinue:(e,r)=>{this._workflowHandlers.continued[e]=E.safePush(this._workflowHandlers.continued[e],{handler:r,order:this._registerOrder++})},workflowTimeout:(e,r)=>{this._workflowHandlers.timed_out[e]=E.safePush(this._workflowHandlers.timed_out[e],{handler:r,order:this._registerOrder++})}};_eventResolvesTo=(e,r)=>{let n=uu(e);if(!n)return!1;let s=mu(n,this._runtime.interfaces);return fu(s)===r};_stripAliasPrefix=e=>{let{alias:r}=this._runtime;if(!r)return e;let n=`${r}#`;return e.startsWith(n)?e.slice(n.length):e}};var Ws={};Xe(Ws,{allWithinMajorOf:()=>ov,allWithinMinorOf:()=>lv});var Gt=In(require("semver"));function ov(t){let e=Gt.major(t.version);return{...t,version:`>=${e}.0.0 <${e+1}.0.0`}}function lv(t){let e=Gt.major(t.version),r=Gt.minor(t.version);return{...t,version:`>=${e}.${r}.0 <${e}.${r+1}.0`}}0&&(module.exports={BRAND,Bot,BotDefinition,BotLogger,BotSpecificClient,DIRTY,EMPTY_PATH,INVALID,Integration,IntegrationDefinition,IntegrationLogger,IntegrationSpecificClient,InterfaceDefinition,NEVER,OK,ParseInputLazyPath,ParseStatus,Plugin,PluginDefinition,RuntimeError,Schema,WELL_KNOWN_ATTRIBUTES,ZodAny,ZodArray,ZodBigInt,ZodBoolean,ZodBranded,ZodCatch,ZodDate,ZodDefault,ZodDiscriminatedUnion,ZodEffects,ZodEnum,ZodError,ZodFirstPartyTypeKind,ZodFunction,ZodIntersection,ZodIssueCode,ZodLazy,ZodLiteral,ZodMap,ZodNaN,ZodNativeEnum,ZodNever,ZodNull,ZodNullable,ZodNumber,ZodObject,ZodOptional,ZodParsedType,ZodPipeline,ZodPromise,ZodReadonly,ZodRecord,ZodRef,ZodSchema,ZodSet,ZodString,ZodSymbol,ZodTransformer,ZodTuple,ZodType,ZodUndefined,ZodUnion,ZodUnknown,ZodVoid,addIssueToContext,agent,aimodel,any,array,bigint,boolean,coerce,conversation,createZodEnum,cuid2Regex,cuidRegex,custom,datasource,date,discriminatedUnion,effect,emailRegex,enum:null,errorUtil,event,function:null,getErrorMap,getParsedType,instanceof:null,intent,intersection,ipv4Regex,ipv6Regex,isAborted,isApiError,isAsync,isDirty,isEmojiRegex,isValid,json,knowledgebase,late,lazy,literal,makeIssue,map,mergeObjectSchemas,message,messages,nan,nativeEnum,never,null:null,nullable,number,object,objectUtil,oboolean,onumber,optional,ostring,parseBody,pipeline,preprocess,processCreateParams,promise,quotelessJson,readonly,record,ref,serve,set,setErrorMap,strictObject,string,symbol,table,tablerow,transformer,transforms,tuple,ulidRegex,undefined,union,unknown,user,util,uuidRegex,variable,version,void:null,z});
73
73
  /*! Bundled license information:
74
74
 
75
75
  @bpinternal/zui/dist/index.js: