@botpress/sdk 4.15.11 → 4.16.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/.turbo/turbo-build.log +5 -5
- package/dist/bot/definition.d.ts +1 -0
- package/dist/bot/implementation.d.ts +8 -8
- package/dist/bot/server/types.d.ts +49 -13
- package/dist/consts.d.ts +9 -0
- package/dist/index.cjs +10 -10
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +15 -15
- package/dist/index.mjs.map +4 -4
- package/dist/integration/server/types.d.ts +1 -0
- package/dist/plugin/implementation.d.ts +2 -2
- package/dist/plugin/server/types.d.ts +48 -13
- package/dist/public-consts.d.ts +0 -8
- package/dist/utils/error-utils.d.ts +4 -0
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var pu=Object.create;var qt=Object.defineProperty;var fu=Object.getOwnPropertyDescriptor;var gu=Object.getOwnPropertyNames;var hu=Object.getPrototypeOf,mu=Object.prototype.hasOwnProperty;var yt=(t,e)=>{for(var r in e)qt(t,r,{get:e[r],enumerable:!0})},$s=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of gu(e))!mu.call(t,s)&&s!==r&&qt(t,s,{get:()=>e[s],enumerable:!(n=fu(e,s))||n.enumerable});return t};var Ks=(t,e,r)=>(r=t!=null?pu(hu(t)):{},$s(e||!t||!t.__esModule?qt(r,"default",{value:t,enumerable:!0}):r,t)),yu=t=>$s(qt({},"__esModule",{value:!0}),t);var Gy={};yt(Gy,{BRAND:()=>Dl,Bot:()=>wn,BotDefinition:()=>bn,BotLogger:()=>mt,BotSpecificClient:()=>pe,DIRTY:()=>He,EMPTY_PATH:()=>Zl,INVALID:()=>x,Integration:()=>Tn,IntegrationDefinition:()=>gn,IntegrationLogger:()=>ht,IntegrationSpecificClient:()=>ft,InterfaceDefinition:()=>Pn,NEVER:()=>Xc,OK:()=>J,ParseInputLazyPath:()=>oe,ParseStatus:()=>re,Plugin:()=>kn,PluginDefinition:()=>xn,RuntimeError:()=>Sn.RuntimeError,Schema:()=>E,WELL_KNOWN_ATTRIBUTES:()=>ly,ZodAny:()=>ot,ZodArray:()=>lt,ZodBigInt:()=>Xr,ZodBoolean:()=>Qr,ZodBranded:()=>en,ZodCatch:()=>tn,ZodDate:()=>rn,ZodDefault:()=>Kt,ZodDiscriminatedUnion:()=>us,ZodEffects:()=>ke,ZodEnum:()=>qe,ZodError:()=>ue,ZodFirstPartyTypeKind:()=>os,ZodFunction:()=>fs,ZodIntersection:()=>nn,ZodIssueCode:()=>h,ZodLazy:()=>sn,ZodLiteral:()=>an,ZodMap:()=>gs,ZodNaN:()=>hs,ZodNativeEnum:()=>on,ZodNever:()=>ut,ZodNull:()=>ln,ZodNullable:()=>Ne,ZodNumber:()=>cn,ZodObject:()=>Me,ZodOptional:()=>me,ZodParsedType:()=>_,ZodPipeline:()=>dn,ZodPromise:()=>zt,ZodReadonly:()=>Ft,ZodRecord:()=>ms,ZodRef:()=>ys,ZodSchema:()=>E,ZodSet:()=>vs,ZodString:()=>Y,ZodSymbol:()=>Ss,ZodTransformer:()=>ke,ZodTuple:()=>je,ZodType:()=>E,ZodUndefined:()=>Wt,ZodUnion:()=>un,ZodUnknown:()=>nt,ZodVoid:()=>Es,addIssueToContext:()=>v,agent:()=>ac,aimodel:()=>uc,any:()=>wc,array:()=>Sc,bigint:()=>yc,boolean:()=>Is,coerce:()=>Yc,conversation:()=>nc,createZodEnum:()=>Ut,cuid2Regex:()=>Ts,cuidRegex:()=>_s,custom:()=>ds,datasource:()=>pc,date:()=>vc,discriminatedUnion:()=>Ic,effect:()=>zn,emailRegex:()=>Ps,enum:()=>Kc,errorUtil:()=>w,event:()=>oc,function:()=>Mc,getErrorMap:()=>it,getParsedType:()=>he,instanceof:()=>hc,intent:()=>dc,intersection:()=>Bc,ipv4Regex:()=>xs,ipv6Regex:()=>ks,isAborted:()=>lr,isApiError:()=>Sn.isApiError,isAsync:()=>Mt,isDirty:()=>cr,isEmojiRegex:()=>Jl,isValid:()=>at,knowledgebase:()=>fc,late:()=>gc,lazy:()=>jc,literal:()=>$c,makeIssue:()=>Nt,map:()=>Dc,mergeObjectSchemas:()=>pt,message:()=>ic,messages:()=>Rs,nan:()=>mc,nativeEnum:()=>Uc,never:()=>xc,null:()=>bc,nullable:()=>Wc,number:()=>Zs,object:()=>Ec,objectUtil:()=>ar,oboolean:()=>Jc,onumber:()=>Gc,optional:()=>Fc,ostring:()=>Vc,parseBody:()=>le,pipeline:()=>qc,preprocess:()=>Lc,processCreateParams:()=>k,promise:()=>zc,quotelessJson:()=>Sl,readonly:()=>Hc,record:()=>Rc,ref:()=>Cc,serve:()=>Lt,set:()=>Nc,setErrorMap:()=>cs,strictObject:()=>Oc,string:()=>Os,symbol:()=>_c,table:()=>lc,tablerow:()=>cc,transformer:()=>zn,transforms:()=>Ei,tuple:()=>Ac,ulidRegex:()=>bs,undefined:()=>Tc,union:()=>Zc,unknown:()=>Pc,user:()=>sc,util:()=>Z,uuidRegex:()=>ws,variable:()=>rc,void:()=>kc,z:()=>y});module.exports=yu(Gy);var Rs={};yt(Rs,{defaults:()=>oy,markdown:()=>ay});var Ln=Object.defineProperty,vu=Object.defineProperties,_u=Object.getOwnPropertyDescriptors,ir=Object.getOwnPropertySymbols,xi=Object.prototype.hasOwnProperty,ki=Object.prototype.propertyIsEnumerable,Us=(t,e,r)=>e in t?Ln(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,c=(t,e)=>{for(var r in e||(e={}))xi.call(e,r)&&Us(t,r,e[r]);if(ir)for(var r of ir(e))ki.call(e,r)&&Us(t,r,e[r]);return t},p=(t,e)=>vu(t,_u(e)),a=(t,e)=>Ln(t,"name",{value:e,configurable:!0}),Si=(t,e)=>{var r={};for(var n in t)xi.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&ir)for(var n of ir(t))e.indexOf(n)<0&&ki.call(t,n)&&(r[n]=t[n]);return r},Kr=(t,e)=>{for(var r in e)Ln(t,r,{get:e[r],enumerable:!0})},Ei={};Kr(Ei,{errors:()=>Bi,fromJSONSchema:()=>rd,fromJSONSchemaLegacy:()=>Im,fromObject:()=>Fn,toJSONSchema:()=>V,toJSONSchemaLegacy:()=>ry,toTypescriptSchema:()=>ss,toTypescriptType:()=>qn});var y={};Kr(y,{BRAND:()=>Dl,DIRTY:()=>He,EMPTY_PATH:()=>Zl,INVALID:()=>x,NEVER:()=>Xc,OK:()=>J,ParseInputLazyPath:()=>oe,ParseStatus:()=>re,Schema:()=>E,ZodAny:()=>ot,ZodArray:()=>lt,ZodBigInt:()=>Xr,ZodBoolean:()=>Qr,ZodBranded:()=>en,ZodCatch:()=>tn,ZodDate:()=>rn,ZodDefault:()=>Kt,ZodDiscriminatedUnion:()=>us,ZodEffects:()=>ke,ZodEnum:()=>qe,ZodError:()=>ue,ZodFirstPartyTypeKind:()=>os,ZodFunction:()=>fs,ZodIntersection:()=>nn,ZodIssueCode:()=>h,ZodLazy:()=>sn,ZodLiteral:()=>an,ZodMap:()=>gs,ZodNaN:()=>hs,ZodNativeEnum:()=>on,ZodNever:()=>ut,ZodNull:()=>ln,ZodNullable:()=>Ne,ZodNumber:()=>cn,ZodObject:()=>Me,ZodOptional:()=>me,ZodParsedType:()=>_,ZodPipeline:()=>dn,ZodPromise:()=>zt,ZodReadonly:()=>Ft,ZodRecord:()=>ms,ZodRef:()=>ys,ZodSchema:()=>E,ZodSet:()=>vs,ZodString:()=>Y,ZodSymbol:()=>Ss,ZodTransformer:()=>ke,ZodTuple:()=>je,ZodType:()=>E,ZodUndefined:()=>Wt,ZodUnion:()=>un,ZodUnknown:()=>nt,ZodVoid:()=>Es,addIssueToContext:()=>v,agent:()=>ac,aimodel:()=>uc,any:()=>wc,array:()=>Sc,bigint:()=>yc,boolean:()=>Is,coerce:()=>Yc,conversation:()=>nc,createZodEnum:()=>Ut,cuid2Regex:()=>Ts,cuidRegex:()=>_s,custom:()=>ds,datasource:()=>pc,date:()=>vc,default:()=>am,discriminatedUnion:()=>Ic,effect:()=>zn,emailRegex:()=>Ps,enum:()=>Kc,errorUtil:()=>w,event:()=>oc,function:()=>Mc,getErrorMap:()=>it,getParsedType:()=>he,instanceof:()=>hc,intent:()=>dc,intersection:()=>Bc,ipv4Regex:()=>xs,ipv6Regex:()=>ks,isAborted:()=>lr,isAsync:()=>Mt,isDirty:()=>cr,isEmojiRegex:()=>Jl,isValid:()=>at,knowledgebase:()=>fc,late:()=>gc,lazy:()=>jc,literal:()=>$c,makeIssue:()=>Nt,map:()=>Dc,message:()=>ic,nan:()=>mc,nativeEnum:()=>Uc,never:()=>xc,null:()=>bc,nullable:()=>Wc,number:()=>Zs,object:()=>Ec,objectUtil:()=>ar,oboolean:()=>Jc,onumber:()=>Gc,optional:()=>Fc,ostring:()=>Vc,pipeline:()=>qc,preprocess:()=>Lc,processCreateParams:()=>k,promise:()=>zc,quotelessJson:()=>Sl,readonly:()=>Hc,record:()=>Rc,ref:()=>Cc,set:()=>Nc,setErrorMap:()=>cs,strictObject:()=>Oc,string:()=>Os,symbol:()=>_c,table:()=>lc,tablerow:()=>cc,transformer:()=>zn,tuple:()=>Ac,ulidRegex:()=>bs,undefined:()=>Tc,union:()=>Zc,unknown:()=>Pc,user:()=>sc,util:()=>Z,uuidRegex:()=>ws,variable:()=>rc,void:()=>kc});var b="x-zui";function Oi(t){return typeof t=="symbol"?"symbol":typeof t=="bigint"?`${t.toString()}n`:T(t)}a(Oi,"primitiveToTypscriptLiteralType");function T(t){return typeof t>"u"?"undefined":typeof t=="symbol"?t.description?`Symbol(${T(t.description)})`:"Symbol()":typeof t=="bigint"?`BigInt(${t.toString()})`:JSON.stringify(t)}a(T,"primitiveToTypescriptValue");function tt(t){return typeof t>"u"?"undefined":JSON.stringify(t)}a(tt,"unknownToTypescriptValue");var Zi=a((t,e)=>{let r=Object.entries(t),n=e?" as const":"";return`{ ${r.map(([s,i])=>`${Rn(s)}: ${tt(i)}`).join(", ")} }${n}`},"recordOfUnknownToTypescriptRecord"),Rn=a(t=>/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t)?t:T(t),"toPropertyKey"),Tu=a(t=>t.charAt(0).toUpperCase()+t.slice(1),"capitalize"),Ii=a(t=>{let e=/[^a-zA-Z0-9_]/g;return t.split(e).map(Tu).filter(n=>!!n).join("")},"toTypeArgumentName"),z=a(t=>{let e=(t??"").split(`
|
|
2
2
|
`).filter(r=>r.trim().length>0);return e.length===0?"":e.length===1?`/** ${e[0]} */`:`/**
|
|
3
3
|
* ${e.join(`
|
|
4
4
|
* `)}
|
|
5
|
-
*/`},"getMultilineComment"),
|
|
6
|
-
`:"",g=t.value.describe(""),P=t.optional||t.value.isOptional()?"?":"";return`${f}${d}${f}${t.key}${P}: ${B(g,i)}${f}`}if(t instanceof
|
|
5
|
+
*/`},"getMultilineComment"),Bi={};Kr(Bi,{JSONSchemaToZuiError:()=>Ur,ObjectToZuiError:()=>Cn,UnrepresentableGenericError:()=>Hn,UnsupportedJSONSchemaToZuiError:()=>we,UnsupportedZuiCheckToJSONSchemaError:()=>Mi,UnsupportedZuiToJSONSchemaError:()=>te,UnsupportedZuiToTypescriptSchemaError:()=>Ze,UnsupportedZuiToTypescriptTypeError:()=>Wi,UntitledDeclarationError:()=>qi,ZuiToJSONSchemaError:()=>zr,ZuiToTypescriptSchemaError:()=>Ki,ZuiToTypescriptTypeError:()=>Fr,ZuiTransformError:()=>dt});var Ai=class extends Error{constructor(e,r){super(r),this.transform=e}};a(Ai,"ZuiTransformError");var dt=Ai,Ri=class extends dt{constructor(e){super("json-schema-to-zui",e)}};a(Ri,"JSONSchemaToZuiError");var Ur=Ri,Ci=class extends dt{constructor(e){super("object-to-zui",e)}};a(Ci,"ObjectToZuiError");var Cn=Ci,Hi=class extends dt{constructor(e){super("zui-to-json-schema",e)}};a(Hi,"ZuiToJSONSchemaError");var zr=Hi,Di=class extends zr{constructor(e,{suggestedAlternative:r}={}){super(`Zod type ${e} cannot be transformed to JSON Schema.`+(r?` Suggested alternative: ${r}`:""))}};a(Di,"UnsupportedZuiToJSONSchemaError");var te=Di,Ni=class extends zr{constructor({zodType:e,checkKind:r}){super(`Zod check .${r}() of type ${e} cannot be transformed to JSON Schema.`)}};a(Ni,"UnsupportedZuiCheckToJSONSchemaError");var Mi=Ni,ji=class extends Ur{constructor(e){super(`JSON Schema ${JSON.stringify(e)} cannot be transformed to ZUI type.`)}};a(ji,"UnsupportedJSONSchemaToZuiError");var we=ji,$i=class extends dt{constructor(e){super("zui-to-typescript-schema",e)}};a($i,"ZuiToTypescriptSchemaError");var Ki=$i,Ui=class extends Ki{constructor(e){super(`Zod type ${e} cannot be transformed to TypeScript schema.`)}};a(Ui,"UnsupportedZuiToTypescriptSchemaError");var Ze=Ui,zi=class extends dt{constructor(e){super("zui-to-typescript-type",e)}};a(zi,"ZuiToTypescriptTypeError");var Fr=zi,Fi=class extends Fr{constructor(e){super(`Zod type ${e} cannot be transformed to TypeScript type.`)}};a(Fi,"UnsupportedZuiToTypescriptTypeError");var Wi=Fi,Li=class extends Fr{constructor(){super("Schema must have a title to be transformed to a TypeScript type with a declaration.")}};a(Li,"UntitledDeclarationError");var qi=Li,Vi=class extends Fr{constructor(){super('ZodRef can only be transformed to a TypeScript type with a "type" declaration.')}};a(Vi,"UnrepresentableGenericError");var Hn=Vi,Gi=["string","number","boolean","unknown","void","any","null","undefined","never","bigint","symbol","object"],bu=a(t=>Gi.includes(t),"isPrimitive"),wu=a(t=>Gi.map(e=>`${e}[]`).includes(t),"isArrayOfPrimitives"),zs=a(t=>t.replace(/ +/g," ").trim(),"stripSpaces"),Ji=class{constructor(e,r,n=!1){this.key=e,this.value=r,this.optional=n}};a(Ji,"KeyValue");var Vt=Ji,Yi=class{constructor(e){this.schema=e}};a(Yi,"FnParameters");var Fs=Yi,Xi=class{constructor(e){this.schema=e}};a(Xi,"FnReturn");var Ws=Xi,Qi=class{constructor(e){this.props=e}};a(Qi,"Declaration");var Jt=Qi;function qn(t,e={}){let r=ku(t,e),n=B(r,{});return e.formatter&&(n=e.formatter(n)),n}a(qn,"toTypescriptType");function B(t,e){var r,n,s;let i=p(c({},e),{parent:t});if(t===null)return"";if(t instanceof Jt)return Pu(t,i);if(t instanceof Vt){if(t.value instanceof u.ZodOptional){let O=t.value._def.innerType;return B(new Vt(t.key,O,!0),i)}let d=z(t.value.description),f=d?.trim().length>0?`
|
|
6
|
+
`:"",g=t.value.describe(""),P=t.optional||t.value.isOptional()?"?":"";return`${f}${d}${f}${t.key}${P}: ${B(g,i)}${f}`}if(t instanceof Fs){if(t.schema instanceof u.ZodTuple){let g="";for(let m=0;m<t.schema.items.length;m++){let P=(s=(n=(r=t.schema.items[m])==null?void 0:r.ui)==null?void 0:n.title)!=null?s:`arg${m}`,O=t.schema.items[m];g+=`${B(new Vt(Rn(P),O),i)}${m<t.schema.items.length-1?", ":""} `}return g}let d=B(t.schema,i);return d.startsWith("{")&&d.endsWith("}")||d.startsWith("[")&&d.endsWith("]")||d.startsWith("(")&&d.endsWith(")")||d.startsWith("Array<")&&d.endsWith(">")||d.startsWith("Record<")&&d.endsWith(">")||wu(d)?`args: ${d}`:d}if(t instanceof Ws)return t.schema instanceof u.ZodOptional?`${B(t.schema.unwrap(),i)} | undefined`:B(t.schema,i);let o=t,l=o._def;switch(l.typeName){case u.ZodFirstPartyTypeKind.ZodString:return`${z(o.description)} string`.trim();case u.ZodFirstPartyTypeKind.ZodNumber:case u.ZodFirstPartyTypeKind.ZodNaN:case u.ZodFirstPartyTypeKind.ZodBigInt:return`${z(o.description)} number`.trim();case u.ZodFirstPartyTypeKind.ZodBoolean:return`${z(o.description)} boolean`.trim();case u.ZodFirstPartyTypeKind.ZodDate:return`${z(o.description)} Date`.trim();case u.ZodFirstPartyTypeKind.ZodUndefined:return`${z(o.description)} undefined`.trim();case u.ZodFirstPartyTypeKind.ZodNull:return`${z(o.description)} null`.trim();case u.ZodFirstPartyTypeKind.ZodAny:return`${z(o.description)} any`.trim();case u.ZodFirstPartyTypeKind.ZodUnknown:return`${z(o.description)} unknown`.trim();case u.ZodFirstPartyTypeKind.ZodNever:return`${z(o.description)} never`.trim();case u.ZodFirstPartyTypeKind.ZodVoid:return`${z(o.description)} void`.trim();case u.ZodFirstPartyTypeKind.ZodArray:let d=B(l.type,i);return bu(d)?`${d}[]`:`Array<${d}>`;case u.ZodFirstPartyTypeKind.ZodObject:return`{ ${Object.entries(l.shape()).map(([q,ie])=>B(new Vt(Rn(q),ie),i)).join("; ")} }`;case u.ZodFirstPartyTypeKind.ZodUnion:let g=l.options.map(q=>B(q,i));return`${z(o.description)}
|
|
7
7
|
${g.join(" | ")}`;case u.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:let m=l.options.map(q=>B(q,i));return`${z(o.description)}
|
|
8
|
-
${m.join(" | ")}`;case u.ZodFirstPartyTypeKind.ZodIntersection:return`${B(l.left,i)} & ${B(l.right,i)}`;case u.ZodFirstPartyTypeKind.ZodTuple:return l.items.length===0?"":`[${l.items.map(q=>B(q,i)).join(", ")}]`;case u.ZodFirstPartyTypeKind.ZodRecord:let
|
|
9
|
-
(${U}) => ${L}`;case u.ZodFirstPartyTypeKind.ZodLazy:return B(l.getter(),i);case u.ZodFirstPartyTypeKind.ZodLiteral:let
|
|
10
|
-
${Q}`.trim();case u.ZodFirstPartyTypeKind.ZodEnum:return l.values.map(T).join(" | ");case u.ZodFirstPartyTypeKind.ZodEffects:return B(l.schema,i);case u.ZodFirstPartyTypeKind.ZodNativeEnum:throw new Ji(u.ZodFirstPartyTypeKind.ZodNativeEnum);case u.ZodFirstPartyTypeKind.ZodOptional:return`${B(l.innerType,i)} | undefined`;case u.ZodFirstPartyTypeKind.ZodNullable:return`${B(l.innerType,i)} | null`;case u.ZodFirstPartyTypeKind.ZodDefault:return B(l.innerType,i);case u.ZodFirstPartyTypeKind.ZodCatch:return B(l.innerType,i);case u.ZodFirstPartyTypeKind.ZodPromise:return`Promise<${B(l.type,i)}>`;case u.ZodFirstPartyTypeKind.ZodBranded:return B(l.type,i);case u.ZodFirstPartyTypeKind.ZodPipeline:return B(l.in,i);case u.ZodFirstPartyTypeKind.ZodSymbol:return`${z(o.description)} symbol`.trim();case u.ZodFirstPartyTypeKind.ZodReadonly:return`Readonly<${B(l.innerType,i)}>`;case u.ZodFirstPartyTypeKind.ZodRef:return Hi(l.uri);default:Z.assertNever(l)}}a(B,"sUnwrapZod");var wu=a((t,e)=>{if(t.props.type==="none")return B(t.props.schema,e);let r=z(t.props.schema.description),n=t.props.schema.describe(""),s=B(n,e);if(t.props.type==="variable")return Vs(`${r}declare const ${t.props.identifier}: ${s};`);let i=t.props.args.length>0?`<${t.props.args.map(Hi).join(", ")}>`:"";return Vs(`${r}type ${t.props.identifier}${i} = ${s};`)},"unwrapDeclaration"),Pu=a(t=>t.declaration?t.declaration===!0?"variable":t.declaration:"none","getDeclarationType"),xu=a((t,e)=>{let r=Pu(e),n=t.getReferences();if(r==="none"){if(n.length>0)throw new Hn;return new Qt({type:"none",schema:t})}let s="title"in t.ui?t.ui.title:null;if(!s)throw new Yi;if(r==="variable"){if(n.length>0)throw new Hn;return new Qt({type:"variable",identifier:s,schema:t})}return new Qt({type:"type",identifier:s,schema:t,args:n})},"getDeclarationProps"),ku=typeof global=="object"&&global&&global.Object===Object&&global,ia=ku,Su=typeof self=="object"&&self&&self.Object===Object&&self,Ou=ia||Su||Function("return this")(),me=Ou,Eu=me.Symbol,be=Eu,aa=Object.prototype,Zu=aa.hasOwnProperty,Iu=aa.toString,vt=be?be.toStringTag:void 0;function oa(t){var e=Zu.call(t,vt),r=t[vt];try{t[vt]=void 0;var n=!0}catch{}var s=Iu.call(t);return n&&(e?t[vt]=r:delete t[vt]),s}a(oa,"getRawTag");var Bu=oa,Cu=Object.prototype,Au=Cu.toString;function la(t){return Au.call(t)}a(la,"objectToString");var Ru=la,Hu="[object Null]",Du="[object Undefined]",Xs=be?be.toStringTag:void 0;function ca(t){return t==null?t===void 0?Du:Hu:Xs&&Xs in Object(t)?Bu(t):Ru(t)}a(ca,"baseGetTag");var $e=ca;function da(t){return t!=null&&typeof t=="object"}a(da,"isObjectLike");var He=da,Mu="[object Symbol]";function ua(t){return typeof t=="symbol"||He(t)&&$e(t)==Mu}a(ua,"isSymbol");var Vn=ua;function pa(t,e){for(var r=-1,n=t==null?0:t.length,s=Array(n);++r<n;)s[r]=e(t[r],r,t);return s}a(pa,"arrayMap");var fa=pa,Nu=Array.isArray,he=Nu,$u=1/0,Ys=be?be.prototype:void 0,Qs=Ys?Ys.toString:void 0;function Gn(t){if(typeof t=="string")return t;if(he(t))return fa(t,Gn)+"";if(Vn(t))return Qs?Qs.call(t):"";var e=t+"";return e=="0"&&1/t==-$u?"-0":e}a(Gn,"baseToString");var ju=Gn;function ga(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}a(ga,"isObject");var nt=ga;function ha(t){return t}a(ha,"identity");var Ku=ha,Uu="[object AsyncFunction]",zu="[object Function]",Fu="[object GeneratorFunction]",Wu="[object Proxy]";function ma(t){if(!nt(t))return!1;var e=$e(t);return e==zu||e==Fu||e==Uu||e==Wu}a(ma,"isFunction");var ya=ma,Lu=me["__core-js_shared__"],On=Lu,ei=(function(){var t=/[^.]+$/.exec(On&&On.keys&&On.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function va(t){return!!ei&&ei in t}a(va,"isMasked");var qu=va,Vu=Function.prototype,Gu=Vu.toString;function _a(t){if(t!=null){try{return Gu.call(t)}catch{}try{return t+""}catch{}}return""}a(_a,"toSource");var je=_a,Ju=/[\\^$.*+?()[\]{}|]/g,Xu=/^\[object .+?Constructor\]$/,Yu=Function.prototype,Qu=Object.prototype,ep=Yu.toString,tp=Qu.hasOwnProperty,rp=RegExp("^"+ep.call(tp).replace(Ju,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ta(t){if(!nt(t)||qu(t))return!1;var e=ya(t)?rp:Xu;return e.test(je(t))}a(Ta,"baseIsNative");var np=Ta;function ba(t,e){return t?.[e]}a(ba,"getValue");var sp=ba;function wa(t,e){var r=sp(t,e);return np(r)?r:void 0}a(wa,"getNative");var Ke=wa,ip=Ke(me,"WeakMap"),Dn=ip,ap=(function(){try{var t=Ke(Object,"defineProperty");return t({},"",{}),t}catch{}})(),ti=ap,op=9007199254740991,lp=/^(?:0|[1-9]\d*)$/;function Pa(t,e){var r=typeof t;return e=e??op,!!e&&(r=="number"||r!="symbol"&&lp.test(t))&&t>-1&&t%1==0&&t<e}a(Pa,"isIndex");var Jn=Pa;function xa(t,e,r){e=="__proto__"&&ti?ti(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}a(xa,"baseAssignValue");var ka=xa;function Sa(t,e){return t===e||t!==t&&e!==e}a(Sa,"eq");var Xn=Sa,cp=Object.prototype,dp=cp.hasOwnProperty;function Oa(t,e,r){var n=t[e];(!(dp.call(t,e)&&Xn(n,r))||r===void 0&&!(e in t))&&ka(t,e,r)}a(Oa,"assignValue");var up=Oa,pp=9007199254740991;function Ea(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=pp}a(Ea,"isLength");var Yn=Ea;function Za(t){return t!=null&&Yn(t.length)&&!ya(t)}a(Za,"isArrayLike");var Ia=Za,fp=Object.prototype;function Ba(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||fp;return t===r}a(Ba,"isPrototype");var Ca=Ba;function Aa(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}a(Aa,"baseTimes");var gp=Aa,hp="[object Arguments]";function Ra(t){return He(t)&&$e(t)==hp}a(Ra,"baseIsArguments");var ri=Ra,Ha=Object.prototype,mp=Ha.hasOwnProperty,yp=Ha.propertyIsEnumerable,vp=ri((function(){return arguments})())?ri:function(t){return He(t)&&mp.call(t,"callee")&&!yp.call(t,"callee")},Da=vp;function Ma(){return!1}a(Ma,"stubFalse");var _p=Ma,Na=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ni=Na&&typeof module=="object"&&module&&!module.nodeType&&module,Tp=ni&&ni.exports===Na,si=Tp?me.Buffer:void 0,bp=si?si.isBuffer:void 0,wp=bp||_p,Mn=wp,Pp="[object Arguments]",xp="[object Array]",kp="[object Boolean]",Sp="[object Date]",Op="[object Error]",Ep="[object Function]",Zp="[object Map]",Ip="[object Number]",Bp="[object Object]",Cp="[object RegExp]",Ap="[object Set]",Rp="[object String]",Hp="[object WeakMap]",Dp="[object ArrayBuffer]",Mp="[object DataView]",Np="[object Float32Array]",$p="[object Float64Array]",jp="[object Int8Array]",Kp="[object Int16Array]",Up="[object Int32Array]",zp="[object Uint8Array]",Fp="[object Uint8ClampedArray]",Wp="[object Uint16Array]",Lp="[object Uint32Array]",D={};D[Np]=D[$p]=D[jp]=D[Kp]=D[Up]=D[zp]=D[Fp]=D[Wp]=D[Lp]=!0;D[Pp]=D[xp]=D[Dp]=D[kp]=D[Mp]=D[Sp]=D[Op]=D[Ep]=D[Zp]=D[Ip]=D[Bp]=D[Cp]=D[Ap]=D[Rp]=D[Hp]=!1;function $a(t){return He(t)&&Yn(t.length)&&!!D[$e(t)]}a($a,"baseIsTypedArray");var qp=$a;function ja(t){return function(e){return t(e)}}a(ja,"baseUnary");var Vp=ja,Ka=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ct=Ka&&typeof module=="object"&&module&&!module.nodeType&&module,Gp=Ct&&Ct.exports===Ka,En=Gp&&ia.process,Jp=(function(){try{var t=Ct&&Ct.require&&Ct.require("util").types;return t||En&&En.binding&&En.binding("util")}catch{}})(),ii=Jp,ai=ii&&ii.isTypedArray,Xp=ai?Vp(ai):qp,Ua=Xp,Yp=Object.prototype,Qp=Yp.hasOwnProperty;function za(t,e){var r=he(t),n=!r&&Da(t),s=!r&&!n&&Mn(t),i=!r&&!n&&!s&&Ua(t),o=r||n||s||i,l=o?gp(t.length,String):[],d=l.length;for(var f in t)(e||Qp.call(t,f))&&!(o&&(f=="length"||s&&(f=="offset"||f=="parent")||i&&(f=="buffer"||f=="byteLength"||f=="byteOffset")||Jn(f,d)))&&l.push(f);return l}a(za,"arrayLikeKeys");var Fa=za;function Wa(t,e){return function(r){return t(e(r))}}a(Wa,"overArg");var La=Wa,ef=La(Object.keys,Object),tf=ef,rf=Object.prototype,nf=rf.hasOwnProperty;function qa(t){if(!Ca(t))return tf(t);var e=[];for(var r in Object(t))nf.call(t,r)&&r!="constructor"&&e.push(r);return e}a(qa,"baseKeys");var sf=qa;function Va(t){return Ia(t)?Fa(t):sf(t)}a(Va,"keys");var Qn=Va;function Ga(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}a(Ga,"nativeKeysIn");var af=Ga,of=Object.prototype,lf=of.hasOwnProperty;function Ja(t){if(!nt(t))return af(t);var e=Ca(t),r=[];for(var n in t)n=="constructor"&&(e||!lf.call(t,n))||r.push(n);return r}a(Ja,"baseKeysIn");var cf=Ja;function Xa(t){return Ia(t)?Fa(t,!0):cf(t)}a(Xa,"keysIn");var df=Xa,uf=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,pf=/^\w*$/;function Ya(t,e){if(he(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||Vn(t)?!0:pf.test(t)||!uf.test(t)||e!=null&&t in Object(e)}a(Ya,"isKey");var es=Ya,ff=Ke(Object,"create"),Rt=ff;function Qa(){this.__data__=Rt?Rt(null):{},this.size=0}a(Qa,"hashClear");var gf=Qa;function eo(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}a(eo,"hashDelete");var hf=eo,mf="__lodash_hash_undefined__",yf=Object.prototype,vf=yf.hasOwnProperty;function to(t){var e=this.__data__;if(Rt){var r=e[t];return r===mf?void 0:r}return vf.call(e,t)?e[t]:void 0}a(to,"hashGet");var _f=to,Tf=Object.prototype,bf=Tf.hasOwnProperty;function ro(t){var e=this.__data__;return Rt?e[t]!==void 0:bf.call(e,t)}a(ro,"hashHas");var wf=ro,Pf="__lodash_hash_undefined__";function no(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Rt&&e===void 0?Pf:e,this}a(no,"hashSet");var xf=no;function Ue(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}a(Ue,"Hash");Ue.prototype.clear=gf;Ue.prototype.delete=hf;Ue.prototype.get=_f;Ue.prototype.has=wf;Ue.prototype.set=xf;var oi=Ue;function so(){this.__data__=[],this.size=0}a(so,"listCacheClear");var kf=so;function io(t,e){for(var r=t.length;r--;)if(Xn(t[r][0],e))return r;return-1}a(io,"assocIndexOf");var Vr=io,Sf=Array.prototype,Of=Sf.splice;function ao(t){var e=this.__data__,r=Vr(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():Of.call(e,r,1),--this.size,!0}a(ao,"listCacheDelete");var Ef=ao;function oo(t){var e=this.__data__,r=Vr(e,t);return r<0?void 0:e[r][1]}a(oo,"listCacheGet");var Zf=oo;function lo(t){return Vr(this.__data__,t)>-1}a(lo,"listCacheHas");var If=lo;function co(t,e){var r=this.__data__,n=Vr(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this}a(co,"listCacheSet");var Bf=co;function ze(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}a(ze,"ListCache");ze.prototype.clear=kf;ze.prototype.delete=Ef;ze.prototype.get=Zf;ze.prototype.has=If;ze.prototype.set=Bf;var Gr=ze,Cf=Ke(me,"Map"),Ht=Cf;function uo(){this.size=0,this.__data__={hash:new oi,map:new(Ht||Gr),string:new oi}}a(uo,"mapCacheClear");var Af=uo;function po(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}a(po,"isKeyable");var Rf=po;function fo(t,e){var r=t.__data__;return Rf(e)?r[typeof e=="string"?"string":"hash"]:r.map}a(fo,"getMapData");var Jr=fo;function go(t){var e=Jr(this,t).delete(t);return this.size-=e?1:0,e}a(go,"mapCacheDelete");var Hf=go;function ho(t){return Jr(this,t).get(t)}a(ho,"mapCacheGet");var Df=ho;function mo(t){return Jr(this,t).has(t)}a(mo,"mapCacheHas");var Mf=mo;function yo(t,e){var r=Jr(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this}a(yo,"mapCacheSet");var Nf=yo;function Fe(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}a(Fe,"MapCache");Fe.prototype.clear=Af;Fe.prototype.delete=Hf;Fe.prototype.get=Df;Fe.prototype.has=Mf;Fe.prototype.set=Nf;var Xr=Fe,$f="Expected a function";function Yr(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError($f);var r=a(function(){var n=arguments,s=e?e.apply(this,n):n[0],i=r.cache;if(i.has(s))return i.get(s);var o=t.apply(this,n);return r.cache=i.set(s,o)||i,o},"memoized");return r.cache=new(Yr.Cache||Xr),r}a(Yr,"memoize");Yr.Cache=Xr;var jf=Yr,Kf=500;function vo(t){var e=jf(t,function(n){return r.size===Kf&&r.clear(),n}),r=e.cache;return e}a(vo,"memoizeCapped");var Uf=vo,zf=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ff=/\\(\\)?/g,Wf=Uf(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(zf,function(r,n,s,i){e.push(s?i.replace(Ff,"$1"):n||r)}),e}),Lf=Wf;function _o(t){return t==null?"":ju(t)}a(_o,"toString");var qf=_o;function To(t,e){return he(t)?t:es(t,e)?[t]:Lf(qf(t))}a(To,"castPath");var Qr=To,Vf=1/0;function bo(t){if(typeof t=="string"||Vn(t))return t;var e=t+"";return e=="0"&&1/t==-Vf?"-0":e}a(bo,"toKey");var jt=bo;function wo(t,e){e=Qr(e,t);for(var r=0,n=e.length;t!=null&&r<n;)t=t[jt(e[r++])];return r&&r==n?t:void 0}a(wo,"baseGet");var ts=wo;function Po(t,e,r){var n=t==null?void 0:ts(t,e);return n===void 0?r:n}a(Po,"get");var Gf=Po;function xo(t,e){for(var r=-1,n=e.length,s=t.length;++r<n;)t[s+r]=e[r];return t}a(xo,"arrayPush");var ko=xo,Jf=La(Object.getPrototypeOf,Object),So=Jf,Xf="[object Object]",Yf=Function.prototype,Qf=Object.prototype,Oo=Yf.toString,eg=Qf.hasOwnProperty,tg=Oo.call(Object);function Eo(t){if(!He(t)||$e(t)!=Xf)return!1;var e=So(t);if(e===null)return!0;var r=eg.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&Oo.call(r)==tg}a(Eo,"isPlainObject");var li=Eo;function Zo(){this.__data__=new Gr,this.size=0}a(Zo,"stackClear");var rg=Zo;function Io(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}a(Io,"stackDelete");var ng=Io;function Bo(t){return this.__data__.get(t)}a(Bo,"stackGet");var sg=Bo;function Co(t){return this.__data__.has(t)}a(Co,"stackHas");var ig=Co,ag=200;function Ao(t,e){var r=this.__data__;if(r instanceof Gr){var n=r.__data__;if(!Ht||n.length<ag-1)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Xr(n)}return r.set(t,e),this.size=r.size,this}a(Ao,"stackSet");var og=Ao;function We(t){var e=this.__data__=new Gr(t);this.size=e.size}a(We,"Stack");We.prototype.clear=rg;We.prototype.delete=ng;We.prototype.get=sg;We.prototype.has=ig;We.prototype.set=og;var er=We;function Ro(t,e){for(var r=-1,n=t==null?0:t.length,s=0,i=[];++r<n;){var o=t[r];e(o,r,t)&&(i[s++]=o)}return i}a(Ro,"arrayFilter");var lg=Ro;function Ho(){return[]}a(Ho,"stubArray");var Do=Ho,cg=Object.prototype,dg=cg.propertyIsEnumerable,ci=Object.getOwnPropertySymbols,ug=ci?function(t){return t==null?[]:(t=Object(t),lg(ci(t),function(e){return dg.call(t,e)}))}:Do,Mo=ug,pg=Object.getOwnPropertySymbols,fg=pg?function(t){for(var e=[];t;)ko(e,Mo(t)),t=So(t);return e}:Do,gg=fg;function No(t,e,r){var n=e(t);return he(t)?n:ko(n,r(t))}a(No,"baseGetAllKeys");var $o=No;function jo(t){return $o(t,Qn,Mo)}a(jo,"getAllKeys");var di=jo;function Ko(t){return $o(t,df,gg)}a(Ko,"getAllKeysIn");var hg=Ko,mg=Ke(me,"DataView"),Nn=mg,yg=Ke(me,"Promise"),$n=yg,vg=Ke(me,"Set"),jn=vg,ui="[object Map]",_g="[object Object]",pi="[object Promise]",fi="[object Set]",gi="[object WeakMap]",hi="[object DataView]",Tg=je(Nn),bg=je(Ht),wg=je($n),Pg=je(jn),xg=je(Dn),Ze=$e;(Nn&&Ze(new Nn(new ArrayBuffer(1)))!=hi||Ht&&Ze(new Ht)!=ui||$n&&Ze($n.resolve())!=pi||jn&&Ze(new jn)!=fi||Dn&&Ze(new Dn)!=gi)&&(Ze=a(function(t){var e=$e(t),r=e==_g?t.constructor:void 0,n=r?je(r):"";if(n)switch(n){case Tg:return hi;case bg:return ui;case wg:return pi;case Pg:return fi;case xg:return gi}return e},"getTag"));var mi=Ze,kg=me.Uint8Array,yi=kg,Sg="__lodash_hash_undefined__";function Uo(t){return this.__data__.set(t,Sg),this}a(Uo,"setCacheAdd");var Og=Uo;function zo(t){return this.__data__.has(t)}a(zo,"setCacheHas");var Eg=zo;function Dt(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new Xr;++e<r;)this.add(t[e])}a(Dt,"SetCache");Dt.prototype.add=Dt.prototype.push=Og;Dt.prototype.has=Eg;var Zg=Dt;function Fo(t,e){for(var r=-1,n=t==null?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}a(Fo,"arraySome");var Ig=Fo;function Wo(t,e){return t.has(e)}a(Wo,"cacheHas");var Bg=Wo,Cg=1,Ag=2;function Lo(t,e,r,n,s,i){var o=r&Cg,l=t.length,d=e.length;if(l!=d&&!(o&&d>l))return!1;var f=i.get(t),g=i.get(e);if(f&&g)return f==e&&g==t;var m=-1,P=!0,E=r&Ag?new Zg:void 0;for(i.set(t,e),i.set(e,t);++m<l;){var I=t[m],U=e[m];if(n)var L=o?n(U,I,m,e,t,i):n(I,U,m,t,e,i);if(L!==void 0){if(L)continue;P=!1;break}if(E){if(!Ig(e,function(Q,ie){if(!Bg(E,ie)&&(I===Q||s(I,Q,r,n,i)))return E.push(ie)})){P=!1;break}}else if(!(I===U||s(I,U,r,n,i))){P=!1;break}}return i.delete(t),i.delete(e),P}a(Lo,"equalArrays");var qo=Lo;function Vo(t){var e=-1,r=Array(t.size);return t.forEach(function(n,s){r[++e]=[s,n]}),r}a(Vo,"mapToArray");var Rg=Vo;function Go(t){var e=-1,r=Array(t.size);return t.forEach(function(n){r[++e]=n}),r}a(Go,"setToArray");var Hg=Go,Dg=1,Mg=2,Ng="[object Boolean]",$g="[object Date]",jg="[object Error]",Kg="[object Map]",Ug="[object Number]",zg="[object RegExp]",Fg="[object Set]",Wg="[object String]",Lg="[object Symbol]",qg="[object ArrayBuffer]",Vg="[object DataView]",vi=be?be.prototype:void 0,Zn=vi?vi.valueOf:void 0;function Jo(t,e,r,n,s,i,o){switch(r){case Vg:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case qg:return!(t.byteLength!=e.byteLength||!i(new yi(t),new yi(e)));case Ng:case $g:case Ug:return Xn(+t,+e);case jg:return t.name==e.name&&t.message==e.message;case zg:case Wg:return t==e+"";case Kg:var l=Rg;case Fg:var d=n&Dg;if(l||(l=Hg),t.size!=e.size&&!d)return!1;var f=o.get(t);if(f)return f==e;n|=Mg,o.set(t,e);var g=qo(l(t),l(e),n,s,i,o);return o.delete(t),g;case Lg:if(Zn)return Zn.call(t)==Zn.call(e)}return!1}a(Jo,"equalByTag");var Gg=Jo,Jg=1,Xg=Object.prototype,Yg=Xg.hasOwnProperty;function Xo(t,e,r,n,s,i){var o=r&Jg,l=di(t),d=l.length,f=di(e),g=f.length;if(d!=g&&!o)return!1;for(var m=d;m--;){var P=l[m];if(!(o?P in e:Yg.call(e,P)))return!1}var E=i.get(t),I=i.get(e);if(E&&I)return E==e&&I==t;var U=!0;i.set(t,e),i.set(e,t);for(var L=o;++m<d;){P=l[m];var Q=t[P],ie=e[P];if(n)var q=o?n(ie,Q,P,e,t,i):n(Q,ie,P,t,e,i);if(!(q===void 0?Q===ie||s(Q,ie,r,n,i):q)){U=!1;break}L||(L=P=="constructor")}if(U&&!L){var se=t.constructor,Ge=e.constructor;se!=Ge&&"constructor"in t&&"constructor"in e&&!(typeof se=="function"&&se instanceof se&&typeof Ge=="function"&&Ge instanceof Ge)&&(U=!1)}return i.delete(t),i.delete(e),U}a(Xo,"equalObjects");var Qg=Xo,eh=1,_i="[object Arguments]",Ti="[object Array]",Yt="[object Object]",th=Object.prototype,bi=th.hasOwnProperty;function Yo(t,e,r,n,s,i){var o=he(t),l=he(e),d=o?Ti:mi(t),f=l?Ti:mi(e);d=d==_i?Yt:d,f=f==_i?Yt:f;var g=d==Yt,m=f==Yt,P=d==f;if(P&&Mn(t)){if(!Mn(e))return!1;o=!0,g=!1}if(P&&!g)return i||(i=new er),o||Ua(t)?qo(t,e,r,n,s,i):Gg(t,e,d,r,n,s,i);if(!(r&eh)){var E=g&&bi.call(t,"__wrapped__"),I=m&&bi.call(e,"__wrapped__");if(E||I){var U=E?t.value():t,L=I?e.value():e;return i||(i=new er),s(U,L,r,n,i)}}return P?(i||(i=new er),Qg(t,e,r,n,s,i)):!1}a(Yo,"baseIsEqualDeep");var rh=Yo;function rs(t,e,r,n,s){return t===e?!0:t==null||e==null||!He(t)&&!He(e)?t!==t&&e!==e:rh(t,e,r,n,rs,s)}a(rs,"baseIsEqual");var en=rs,nh=1,sh=2;function Qo(t,e,r,n){var s=r.length,i=s,o=!n;if(t==null)return!i;for(t=Object(t);s--;){var l=r[s];if(o&&l[2]?l[1]!==t[l[0]]:!(l[0]in t))return!1}for(;++s<i;){l=r[s];var d=l[0],f=t[d],g=l[1];if(o&&l[2]){if(f===void 0&&!(d in t))return!1}else{var m=new er;if(n)var P=n(f,g,d,t,e,m);if(!(P===void 0?en(g,f,nh|sh,n,m):P))return!1}}return!0}a(Qo,"baseIsMatch");var ih=Qo;function el(t){return t===t&&!nt(t)}a(el,"isStrictComparable");var tl=el;function rl(t){for(var e=Qn(t),r=e.length;r--;){var n=e[r],s=t[n];e[r]=[n,s,tl(s)]}return e}a(rl,"getMatchData");var ah=rl;function nl(t,e){return function(r){return r==null?!1:r[t]===e&&(e!==void 0||t in Object(r))}}a(nl,"matchesStrictComparable");var sl=nl;function il(t){var e=ah(t);return e.length==1&&e[0][2]?sl(e[0][0],e[0][1]):function(r){return r===t||ih(r,t,e)}}a(il,"baseMatches");var oh=il;function al(t,e){return t!=null&&e in Object(t)}a(al,"baseHasIn");var lh=al;function ol(t,e,r){e=Qr(e,t);for(var n=-1,s=e.length,i=!1;++n<s;){var o=jt(e[n]);if(!(i=t!=null&&r(t,o)))break;t=t[o]}return i||++n!=s?i:(s=t==null?0:t.length,!!s&&Yn(s)&&Jn(o,s)&&(he(t)||Da(t)))}a(ol,"hasPath");var ch=ol;function ll(t,e){return t!=null&&ch(t,e,lh)}a(ll,"hasIn");var dh=ll,uh=1,ph=2;function cl(t,e){return es(t)&&tl(e)?sl(jt(t),e):function(r){var n=Gf(r,t);return n===void 0&&n===e?dh(r,t):en(e,n,uh|ph)}}a(cl,"baseMatchesProperty");var fh=cl;function dl(t){return function(e){return e?.[t]}}a(dl,"baseProperty");var gh=dl;function ul(t){return function(e){return ts(e,t)}}a(ul,"basePropertyDeep");var hh=ul;function pl(t){return es(t)?gh(jt(t)):hh(t)}a(pl,"property");var mh=pl;function fl(t){return typeof t=="function"?t:t==null?Ku:typeof t=="object"?he(t)?fh(t[0],t[1]):oh(t):mh(t)}a(fl,"baseIteratee");var ns=fl;function gl(t){return function(e,r,n){for(var s=-1,i=Object(e),o=n(e),l=o.length;l--;){var d=o[t?l:++s];if(r(i[d],d,i)===!1)break}return e}}a(gl,"createBaseFor");var yh=gl,vh=yh(),_h=vh;function hl(t,e){return t&&_h(t,e,Qn)}a(hl,"baseForOwn");var Th=hl;function ml(t,e){return en(t,e)}a(ml,"isEqual");var tt=ml;function yl(t,e,r){r=typeof r=="function"?r:void 0;var n=r?r(t,e):void 0;return n===void 0?en(t,e,void 0,r):!!n}a(yl,"isEqualWith");var bh=yl;function vl(t){return t===void 0}a(vl,"isUndefined");var wi=vl;function _l(t,e){var r={};return e=ns(e,3),Th(t,function(n,s,i){ka(r,s,e(n,s,i))}),r}a(_l,"mapValues");var wh=_l,Ph="Expected a function";function Tl(t){if(typeof t!="function")throw new TypeError(Ph);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}a(Tl,"negate");var xh=Tl;function bl(t,e,r,n){if(!nt(t))return t;e=Qr(e,t);for(var s=-1,i=e.length,o=i-1,l=t;l!=null&&++s<i;){var d=jt(e[s]),f=r;if(d==="__proto__"||d==="constructor"||d==="prototype")return t;if(s!=o){var g=l[d];f=n?n(g,d,l):void 0,f===void 0&&(f=nt(g)?g:Jn(e[s+1])?[]:{})}up(l,d,f),l=l[d]}return t}a(bl,"baseSet");var kh=bl;function wl(t,e,r){for(var n=-1,s=e.length,i={};++n<s;){var o=e[n],l=ts(t,o);r(l,o)&&kh(i,Qr(o,t),l)}return i}a(wl,"basePickBy");var Sh=wl;function Pl(t,e){if(t==null)return{};var r=fa(hg(t),function(n){return[n]});return e=ns(e),Sh(t,r,function(n,s){return e(n,s[0])})}a(Pl,"pickBy");var Oh=Pl;function xl(t,e){return Oh(t,xh(ns(e)))}a(xl,"omitBy");var Pi=xl,Eh=a(t=>{let e=t.checks;return e.length===0?"":e.map(Zh).join("")},"generateStringChecks"),Zh=a(t=>{switch(t.kind){case"min":return`.min(${T(t.value)}, ${T(t.message)})`;case"max":return`.max(${T(t.value)}, ${T(t.message)})`;case"length":return`.length(${T(t.value)}, ${T(t.message)})`;case"email":return`.email(${T(t.message)})`;case"url":return`.url(${T(t.message)})`;case"emoji":return`.emoji(${T(t.message)})`;case"uuid":return`.uuid(${T(t.message)})`;case"cuid":return`.cuid(${T(t.message)})`;case"cuid2":return`.cuid2(${T(t.message)})`;case"ulid":return`.ulid(${T(t.message)})`;case"includes":let e=et({message:t.message,position:t.position});return`.includes(${T(t.value)}, ${e})`;case"startsWith":return`.startsWith(${T(t.value)}, ${T(t.message)})`;case"endsWith":return`.endsWith(${T(t.value)}, ${T(t.message)})`;case"regex":return`.regex(${String(t.regex)}, ${T(t.message)})`;case"trim":return".trim()";case"toLowerCase":return".toLowerCase()";case"toUpperCase":return".toUpperCase()";case"datetime":let n=t.precision===null?void 0:t.precision;return`.datetime(${et({message:t.message,precision:n,offset:t.offset})})`;case"ip":return`.ip(${et({message:t.message,version:t.version})})`;default:return""}},"_generateStringCheck"),Ih=a(t=>{let e=t.checks;return e.length===0?"":e.map(Bh).join("")},"generateNumberChecks"),Bh=a(t=>{switch(t.kind){case"min":return`.min(${T(t.value)}, ${T(t.message)})`;case"max":return`.max(${T(t.value)}, ${T(t.message)})`;case"int":return`.int(${T(t.message)})`;case"multipleOf":return`.multipleOf(${T(t.value)}, ${T(t.message)})`;case"finite":return`.finite(${T(t.message)})`;default:return""}},"_generateNumberCheck"),Ch=a(t=>{let e=t.checks;return e.length===0?"":e.map(Ah).join("")},"generateBigIntChecks"),Ah=a(t=>{switch(t.kind){case"min":return`.min(${T(t.value)}, ${T(t.message)})`;case"max":return`.max(${T(t.value)}, ${T(t.message)})`;case"multipleOf":return`.multipleOf(${T(t.value)}, ${T(t.message)})`;default:return""}},"_generateBigIntCheck"),Rh=a(t=>{let e=t.checks;return e.length===0?"":e.map(Hh).join("")},"generateDateChecks"),Hh=a(t=>{switch(t.kind){case"min":return`.min(${xi(t.value)}, ${T(t.message)})`;case"max":return`.max(${xi(t.value)}, ${T(t.message)})`;default:return""}},"_generateDateCheck"),xi=a(t=>`new Date(${t})`,"dateTs"),Dh=a(t=>{let e=[];if(t.exactLength){let{value:r,message:n}=t.exactLength;e.push(`.length(${T(r)}, ${T(n)})`)}if(t.minLength){let{value:r,message:n}=t.minLength;e.push(`.min(${T(r)}, ${T(n)})`)}if(t.maxLength){let{value:r,message:n}=t.maxLength;e.push(`.max(${T(r)}, ${T(n)})`)}return e.join("")},"generateArrayChecks"),Mh=a(t=>{let e=[];if(t.minSize){let{value:r,message:n}=t.minSize;e.push(`.min(${T(r)}, ${T(n)})`)}if(t.maxSize){let{value:r,message:n}=t.maxSize;e.push(`.max(${T(r)}, ${T(n)})`)}return e.join("")},"generateSetChecks");function ss(t){return N(t)}a(ss,"toTypescriptSchema");function N(t){let r=t._def;switch(r.typeName){case u.ZodFirstPartyTypeKind.ZodString:return`z.string()${Eh(r)}${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNumber:return`z.number()${Ih(r)}${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNaN:return`z.nan()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodBigInt:return`z.bigint()${Ch(r)}${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodBoolean:return`z.boolean()${R(r)}${A(t._def)}`.trim();case u.ZodFirstPartyTypeKind.ZodDate:return`z.date()${Rh(r)}${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodUndefined:return`z.undefined()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNull:return`z.null()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodAny:return`z.any()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodUnknown:return`z.unknown()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNever:return`z.never()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodVoid:return`z.void()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodArray:return`z.array(${N(r.type)})${Dh(r)}${R(r)}${A(r)}`;case u.ZodFirstPartyTypeKind.ZodObject:let n=wh(r.shape(),N),s=t.additionalProperties(),i=s?`.catchall(${N(s)})`:"";return["z.object({",...Object.entries(n).map(([cu,du])=>` ${cu}: ${du},`),`})${i}${R(r)}${A(r)}`].join(`
|
|
11
|
-
`).trim();case u.ZodFirstPartyTypeKind.ZodUnion:return`z.union([${r.options.map(N).join(", ")}])${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:let l=r.options.map(N);return`z.discriminatedUnion(${T(r.discriminator)}, [${l.join(", ")}])${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodIntersection:let f=N(r.left),g=N(r.right);return`z.intersection(${f}, ${g})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodTuple:return`z.tuple([${r.items.map(N).join(", ")}])${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodRecord:let P=N(r.keyType),E=N(r.valueType);return`z.record(${P}, ${E})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodMap:let I=N(r.keyType),U=N(r.valueType);return`z.map(${I}, ${U})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodSet:return`z.set(${N(r.valueType)})${Mh(r)}${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodFunction:let L=r.args.items.map(N),Q=L.length?`.args(${L.join(", ")})`:"",ie=N(r.returns);return`z.function()${Q}.returns(${ie})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodLazy:return`z.lazy(() => ${N(r.getter())})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodLiteral:return`z.literal(${T(r.value)})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodEnum:return`z.enum([${r.values.map(T).join(", ")}])${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodEffects:throw new Ee(u.ZodFirstPartyTypeKind.ZodEffects);case u.ZodFirstPartyTypeKind.ZodNativeEnum:throw new Ee(u.ZodFirstPartyTypeKind.ZodNativeEnum);case u.ZodFirstPartyTypeKind.ZodOptional:return`z.optional(${N(r.innerType)})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNullable:return`z.nullable(${N(r.innerType)})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodDefault:let Ge=et(r.defaultValue());return`z.default(${N(r.innerType)}, ${Ge})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodCatch:throw new Ee(u.ZodFirstPartyTypeKind.ZodCatch);case u.ZodFirstPartyTypeKind.ZodPromise:return`z.promise(${N(r.type)})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodBranded:throw new Ee(u.ZodFirstPartyTypeKind.ZodBranded);case u.ZodFirstPartyTypeKind.ZodPipeline:throw new Ee(u.ZodFirstPartyTypeKind.ZodPipeline);case u.ZodFirstPartyTypeKind.ZodSymbol:throw new Ee(u.ZodFirstPartyTypeKind.ZodSymbol);case u.ZodFirstPartyTypeKind.ZodReadonly:return`z.readonly(${N(r.innerType)})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodRef:return`z.ref(${T(r.uri)})${R(r)}${A(r)}`.trim();default:Z.assertNever(r)}}a(N,"sUnwrapZod");var A=a(t=>t.description?`.describe(${T(t.description)})`:"","_maybeDescribe"),R=a(t=>`${Nh(t)}${$h(t)}${jh(t)}${Kh(t)}${Uh(t)}${zh(t)}${Fh(t)}`,"_addZuiExtensions"),Nh=a(t=>{var e;return(e=t[b])!=null&&e.title?`.title(${T(t[b].title)})`:""},"_maybeTitle"),$h=a(t=>{var e;return(e=t[b])!=null&&e.displayAs?`.displayAs(${Ri({id:t[b].displayAs[0],params:t[b].displayAs[1]})})`:""},"_maybeDisplayAs"),jh=a(t=>{var e;return(e=t[b])!=null&&e.disabled?`.disabled(${t[b].disabled})`:""},"_maybeDisabled"),Kh=a(t=>{var e;return(e=t[b])!=null&&e.hidden?`.hidden(${t[b].hidden})`:""},"_maybeHidden"),Uh=a(t=>{var e;return(e=t[b])!=null&&e.placeholder?`.placeholder(${T(t[b].placeholder)})`:""},"_maybePlaceholder"),zh=a(t=>{var e;return(e=t[b])!=null&&e.secret?".secret()":""},"_maybeSecret"),Fh=a(t=>{var e;let r=["title","tooltip","displayAs","disabled","hidden","placeholder","secret","coerce"],n=Object.entries((e=t[b])!=null?e:{}).filter(([s])=>!r.includes(s));return n.length>0?`.metadata(${Ri(Object.fromEntries(n))})`:""},"_maybeSetMetadata"),Wh=a(t=>{let e={type:"number",description:t.description,"x-zui":t._def["x-zui"]};t._def[b]&&(e[b]=t._def[b]);for(let r of t._def.checks)switch(r.kind){case"min":{let n=r.inclusive?"minimum":"exclusiveMinimum",s=r.inclusive?"exclusiveMinimum":"minimum";e[n]=r.value,delete e[s];break}case"max":{let n=r.inclusive?"maximum":"exclusiveMaximum",s=r.inclusive?"exclusiveMaximum":"maximum";e[n]=r.value,delete e[s];break}case"int":e.type="integer";break;case"finite":{e.format="finite";break}case"multipleOf":e.multipleOf=r.value;break;default:}return e},"zodNumberToJsonNumber"),kl="\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}",Sl="(([+-]\\d{2}(:?\\d{2})?)|Z)",Lh="Z",Ol="(\\.\\d+)?",Kn="\\.\\d{",qh="}",El=a(t=>{let e=t.precision?Kn+t.precision+qh:t.precision===0?"":Ol,r=t.offset?Sl:Lh;return new RegExp(`^${kl}${e}${r}$`)},"generateDatetimeRegex"),Vh=a(t=>({precision:Gh(t),offset:t.endsWith(`${Sl}$`)}),"extractPrecisionAndOffset"),Gh=a(t=>{let e=t.slice(1+kl.length);return e.startsWith(Ol)?null:e.startsWith(Kn)?parseInt(e.slice(Kn.length)):0},"_extractPrecision"),At={};Fr(At,{escapeSpecialChars:()=>Jh});var Jh=a(t=>t.replaceAll(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeSpecialChars");function is(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage=p(c({},t.errorMessage),{[e]:r}))}a(is,"addErrorMessage");function H(t,e,r,n,s){t[e]=r,is(t,e,n,s)}a(H,"setResponseValueAndErrors");var j={cuid:"^[cC][^\\s-]{8,}$",cuid2:"^[a-z][a-z0-9]*$",ulid:"^[0-9A-HJKMNP-TV-Z]{26}$",email:"^(?!\\.)(?!.*\\.\\.)([a-zA-Z0-9_+-\\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\\-]*\\.)+[a-zA-Z]{2,}$",emoji:"^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",uuid:"^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$",ipv4:"^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$",ipv6:"^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$"};function as(t,e){let r=c({type:"string"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});function n(s){return e.patternStrategy==="escape"?At.escapeSpecialChars(s):s}if(a(n,"processPattern"),t.checks)for(let s of t.checks)switch(s.kind){case"min":H(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,s.value):s.value,s.message,e);break;case"max":H(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,s.value):s.value,s.message,e);break;case"email":switch(e.emailStrategy){case"format:email":Oe(r,"email",s.message,e);break;case"format:idn-email":Oe(r,"idn-email",s.message,e);break;case"pattern:zod":ue(r,j.email,s.message,e);break}break;case"url":Oe(r,"uri",s.message,e);break;case"uuid":Oe(r,"uuid",s.message,e);break;case"regex":ue(r,s.regex.source,s.message,e);break;case"cuid":ue(r,j.cuid,s.message,e);break;case"cuid2":ue(r,j.cuid2,s.message,e);break;case"startsWith":ue(r,"^"+n(s.value),s.message,e);break;case"endsWith":ue(r,n(s.value)+"$",s.message,e);break;case"datetime":Oe(r,"date-time",s.message,e);break;case"length":H(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,s.value):s.value,s.message,e),H(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,s.value):s.value,s.message,e);break;case"includes":{ue(r,n(s.value),s.message,e);break}case"ip":{s.version!=="v6"&&Oe(r,"ipv4",s.message,e),s.version!=="v4"&&Oe(r,"ipv6",s.message,e);break}case"emoji":ue(r,j.emoji,s.message,e);break;case"ulid":{ue(r,j.ulid,s.message,e);break}case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}a(as,"parseStringDef");var Oe=a((t,e,r,n)=>{var s;t.format||(s=t.anyOf)!=null&&s.some(i=>i.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push(c({format:t.format},t.errorMessage&&n.errorMessages&&{errorMessage:{format:t.errorMessage.format}})),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push(c({format:e},r&&n.errorMessages&&{errorMessage:{format:r}}))):H(t,"format",e,r,n)},"addFormat"),ue=a((t,e,r,n)=>{var s;t.pattern||(s=t.allOf)!=null&&s.some(i=>i.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push(c({pattern:t.pattern},t.errorMessage&&n.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}})),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push(c({pattern:e},r&&n.errorMessages&&{errorMessage:{pattern:r}}))):H(t,"pattern",e,r,n)},"addPattern"),Xh=a(t=>{let e={type:"string",description:t.description,"x-zui":t._def["x-zui"]};t._def[b]&&(e[b]=t._def[b]);for(let r of t._def.checks)switch(r.kind){case"cuid":e.format="cuid",e.pattern=j.cuid;break;case"cuid2":e.format="cuid2",e.pattern=j.cuid2;break;case"ulid":e.format="ulid",e.pattern=j.ulid;break;case"uuid":e.format="uuid",e.pattern=j.uuid;break;case"emoji":e.format="emoji",e.pattern=j.emoji;break;case"email":e.format="email",e.pattern=j.email;break;case"ip":e.format=r.version==="v6"?"ipv6":"ipv4",e.pattern=r.version==="v6"?j.ipv6:j.ipv4;break;case"datetime":e.format="date-time",e.pattern=El(r).source,e[b]=p(c({},e[b]),{precision:r.precision,offset:r.offset});break;case"url":e.format="uri";break;case"endsWith":e.pattern=`${At.escapeSpecialChars(r.value)}$`;break;case"startsWith":e.pattern=`^${At.escapeSpecialChars(r.value)}`;break;case"includes":let n=r.position&&r.position>=1?`^(?:.{${r.position}}).*`:"";e.pattern=`${n}${At.escapeSpecialChars(r.value)}`;break;case"regex":e.pattern=r.regex.source;break;case"length":e.minLength=e.maxLength=Math.max(0,r.value);break;case"min":e.minLength=Math.max(0,r.value);break;case"max":e.maxLength=Math.max(0,r.value);break;default:throw new zi({zodType:u.ZodFirstPartyTypeKind.ZodString,checkKind:r.kind})}return e},"zodStringToJsonString"),Yh=a((t,e)=>{let r={type:"array",description:t.description,items:e(t._def.type),"x-zui":t._def["x-zui"]};return t._def[b]&&(r[b]=t._def[b]),t._def.minLength&&(r.minItems=t._def.minLength.value),t._def.maxLength&&(r.maxItems=t._def.maxLength.value),t._def.exactLength&&(r.minItems=t._def.exactLength.value,r.maxItems=t._def.exactLength.value),r},"zodArrayToJsonArray"),Qh=a((t,e)=>{let r={type:"array",description:t.description,uniqueItems:!0,items:e(t._def.valueType),"x-zui":t._def["x-zui"]};return t._def[b]&&(r[b]=t._def[b]),t._def.minSize&&(r.minItems=t._def.minSize.value),t._def.maxSize&&(r.maxItems=t._def.maxSize.value),r},"zodSetToJsonSet"),em=a((t,e)=>{let r={type:"array",description:t.description,items:t._def.items.map(n=>e(n))};return t._def[b]&&(r[b]=t._def[b]),t._def.rest&&(r.additionalItems=e(t._def.rest)),r},"zodTupleToJsonTuple");function V(t){let e=t,r=e._def;switch(r.typeName){case u.ZodFirstPartyTypeKind.ZodString:return Xh(e);case u.ZodFirstPartyTypeKind.ZodNumber:return Wh(e);case u.ZodFirstPartyTypeKind.ZodNaN:throw new ee(u.ZodFirstPartyTypeKind.ZodNaN);case u.ZodFirstPartyTypeKind.ZodBigInt:throw new ee(u.ZodFirstPartyTypeKind.ZodBigInt,{suggestedAlternative:"serialize bigint to string"});case u.ZodFirstPartyTypeKind.ZodBoolean:return{type:"boolean",description:r.description,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodDate:throw new ee(u.ZodFirstPartyTypeKind.ZodDate,{suggestedAlternative:"use z.string().datetime() instead"});case u.ZodFirstPartyTypeKind.ZodUndefined:return In(r);case u.ZodFirstPartyTypeKind.ZodNull:return Bn(r);case u.ZodFirstPartyTypeKind.ZodAny:return{description:r.description,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodUnknown:return{description:r.description,"x-zui":p(c({},r["x-zui"]),{def:{typeName:u.ZodFirstPartyTypeKind.ZodUnknown}})};case u.ZodFirstPartyTypeKind.ZodNever:return{not:!0,description:r.description,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodVoid:throw new ee(u.ZodFirstPartyTypeKind.ZodVoid);case u.ZodFirstPartyTypeKind.ZodArray:return Yh(e,V);case u.ZodFirstPartyTypeKind.ZodObject:let n=Object.entries(r.shape()),s=n.filter(([g,m])=>!m.isOptional()),i=s.length?s.map(([g])=>g):void 0,o=n.map(([g,m])=>[g,m.mandatory()]).map(([g,m])=>[g,V(m)]),l=!1;return r.unknownKeys instanceof u.ZodType?l=V(r.unknownKeys):r.unknownKeys==="passthrough"&&(l=!0),{type:"object",description:r.description,properties:Object.fromEntries(o),required:i,additionalProperties:l,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodUnion:return{description:r.description,anyOf:r.options.map(g=>V(g)),"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:return{description:r.description,anyOf:r.options.map(g=>V(g)),"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodIntersection:let d=V(r.left),f=V(r.right);return"additionalProperties"in d&&delete d.additionalProperties,"additionalProperties"in f&&delete f.additionalProperties,{description:r.description,allOf:[d,f],"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodTuple:return em(e,V);case u.ZodFirstPartyTypeKind.ZodRecord:return{type:"object",description:r.description,additionalProperties:V(r.valueType),"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodMap:throw new ee(u.ZodFirstPartyTypeKind.ZodMap);case u.ZodFirstPartyTypeKind.ZodSet:return Qh(e,V);case u.ZodFirstPartyTypeKind.ZodFunction:throw new ee(u.ZodFirstPartyTypeKind.ZodFunction);case u.ZodFirstPartyTypeKind.ZodLazy:throw new ee(u.ZodFirstPartyTypeKind.ZodLazy);case u.ZodFirstPartyTypeKind.ZodLiteral:if(typeof r.value=="string")return{type:"string",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(typeof r.value=="number")return{type:"number",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(typeof r.value=="boolean")return{type:"boolean",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(r.value===null)return Bn(r);if(r.value===void 0)return In(r);{u.util.assertEqual(!0);let g=typeof r.value;throw new Lr(`Unsupported literal type: "${g}"`)}case u.ZodFirstPartyTypeKind.ZodEnum:return{type:"string",description:r.description,enum:r.values,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodEffects:throw new ee(u.ZodFirstPartyTypeKind.ZodEffects);case u.ZodFirstPartyTypeKind.ZodNativeEnum:throw new ee(u.ZodFirstPartyTypeKind.ZodNativeEnum);case u.ZodFirstPartyTypeKind.ZodOptional:return{description:r.description,anyOf:[V(r.innerType),In()],"x-zui":p(c({},r["x-zui"]),{def:{typeName:u.ZodFirstPartyTypeKind.ZodOptional}})};case u.ZodFirstPartyTypeKind.ZodNullable:return{anyOf:[V(r.innerType),Bn()],"x-zui":p(c({},r["x-zui"]),{def:{typeName:u.ZodFirstPartyTypeKind.ZodNullable}})};case u.ZodFirstPartyTypeKind.ZodDefault:return p(c({},V(r.innerType)),{default:r.defaultValue()});case u.ZodFirstPartyTypeKind.ZodCatch:throw new ee(u.ZodFirstPartyTypeKind.ZodCatch);case u.ZodFirstPartyTypeKind.ZodPromise:throw new ee(u.ZodFirstPartyTypeKind.ZodPromise);case u.ZodFirstPartyTypeKind.ZodBranded:throw new ee(u.ZodFirstPartyTypeKind.ZodBranded);case u.ZodFirstPartyTypeKind.ZodPipeline:throw new ee(u.ZodFirstPartyTypeKind.ZodPipeline);case u.ZodFirstPartyTypeKind.ZodSymbol:throw new ee(u.ZodFirstPartyTypeKind.ZodPipeline);case u.ZodFirstPartyTypeKind.ZodReadonly:return p(c({},V(r.innerType)),{readOnly:!0});case u.ZodFirstPartyTypeKind.ZodRef:return{$ref:r.uri,description:r.description,"x-zui":r["x-zui"]};default:u.util.assertNever(r)}}a(V,"toJSONSchema");var In=a(t=>({not:!0,description:t?.description,"x-zui":p(c({},t?.["x-zui"]),{def:{typeName:u.ZodFirstPartyTypeKind.ZodUndefined}})}),"undefinedSchema"),Bn=a(t=>({type:"null",description:t?.description,"x-zui":t?.["x-zui"]}),"nullSchema"),Zl=class{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};a(Zl,"ParseInputLazyPath");var ae=Zl,ki=a((t,e)=>{if(it(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new le(t.common.issues);return this._error=r,this._error}}},"handleResult"),Il=class{constructor(e){this.__type__="ZuiType",this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._metadataRoot._def.description}dereference(e){return this}getReferences(){return[]}clone(){let e=this.constructor;return new e(c({},this._def))}_getType(e){return fe(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:fe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new te,ctx:{common:e.parent.common,data:e.data,parsedType:fe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Nt(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){var n;let s={common:{issues:[],async:(n=r?.async)!=null?n:!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:fe(e)},i=this._parseSync({data:e,path:s.path,parent:s});return ki(s,i)}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:fe(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(Nt(s)?s:Promise.resolve(s));return ki(n,i)}refine(e,r){let n=a(s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r,"getIssueProperties");return this._refinement((s,i)=>{let o=e(s),l=a(()=>i.addIssue(c({code:h.custom},n(s))),"setError");return typeof Promise<"u"&&o instanceof Promise?o.then(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 Pe({schema:this,typeName:"ZodEffects",effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ge.create(this,this._def)}nullable(){return De.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ot.create(this,this._def)}promise(){return zt.create(this,this._def)}mandatory(){return this}or(e){return gn.create([this,e],this._def)}and(e){return on.create(this,e,this._def)}transform(e){return new Pe(p(c({},k(this._def)),{schema:this,typeName:"ZodEffects",effect:{type:"transform",transform:e}}))}default(e){let r=typeof e=="function"?e:()=>e;return new Kt(p(c({},k(this._def)),{innerType:this,defaultValue:r,typeName:"ZodDefault"}))}brand(){return new nn(c({typeName:"ZodBranded",type:this},k(this._def)))}catch(e){let r=typeof e=="function"?e:()=>e;return new sn(p(c({},k(this._def)),{innerType:this,catchValue:r,typeName:"ZodCatch"}))}describe(e){let r=this.clone();return r._metadataRoot._def.description=e,r}pipe(e){return fn.create(this,e)}readonly(){return Ft.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}metadata(e){var r,n,s;let i=this.clone(),o=i._metadataRoot;(s=(r=o._def)[n=b])!=null||(r[n]={});for(let[l,d]of Object.entries(e))o._def[b]=p(c({},o._def[b]),{[l]:d});return i}getMetadata(){return c({},this._metadataRoot._def[b])}setMetadata(e){this._metadataRoot._def[b]=c({},e)}get ui(){return c({},this._metadataRoot._def[b])}get _metadataRoot(){return this.naked()}displayAs(e){return this.metadata({displayAs:[e.id,e.params]})}title(e){return this.metadata({title:e})}hidden(e){let r;return e===void 0?r=!0:typeof e=="function"?r=e.toString():r=e,this.metadata({hidden:r})}disabled(e){let r;return e===void 0?r=!0:typeof e=="function"?r=e.toString():r=e,this.metadata({disabled:r})}placeholder(e){return this.metadata({placeholder:e})}toJSONSchema(){return V(this)}toTypescriptType(e){return qn(this,e)}toTypescriptSchema(){return ss(this)}naked(){return this}};a(Il,"ZodType");var O=Il,os=(t=>(t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodRef="ZodRef",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly",t))(os||{}),Z;(t=>{t.assertEqual=a(s=>s,"assertEqual");function e(s){}t.assertIs=e,a(e,"assertIs");function r(s){throw new Error("assertNever called")}t.assertNever=r,a(r,"assertNever"),t.arrayToEnum=a(s=>{let i={};for(let o of s)i[o]=o;return i},"arrayToEnum"),t.getValidEnumValues=a(s=>{let i=(0,t.objectKeys)(s).filter(l=>typeof s[s[l]]!="number"),o={};for(let l of i)o[l]=s[l];return(0,t.objectValues)(o)},"getValidEnumValues"),t.objectValues=a(s=>(0,t.objectKeys)(s).map(function(i){return s[i]}),"objectValues"),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=a((s,i)=>{for(let o of s)if(i(o))return o},"find"),t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=n,a(n,"joinValues"),t.jsonStringifyReplacer=a((s,i)=>typeof i=="bigint"?i.toString():i,"jsonStringifyReplacer"),t.compareFunctions=a((s,i)=>s.toString()===i.toString(),"compareFunctions"),t.mock=a(()=>({}),"mock")})(Z||(Z={}));var cr;(t=>{t.mergeShapes=a((e,r)=>c(c({},e),r),"mergeShapes")})(cr||(cr={}));var _=Z.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),fe=a(t=>{switch(typeof t){case"undefined":return _.undefined;case"string":return _.string;case"number":return isNaN(t)?_.nan:_.number;case"boolean":return _.boolean;case"function":return _.function;case"bigint":return _.bigint;case"symbol":return _.symbol;case"object":return Array.isArray(t)?_.array:t===null?_.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?_.promise:typeof Map<"u"&&t instanceof Map?_.map:typeof Set<"u"&&t instanceof Set?_.set:typeof Date<"u"&&t instanceof Date?_.date:_.object;default:return _.unknown}},"getParsedType");function k(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s,supportsExtensions:i,[b]:o}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);let l=o?Object.fromEntries(Object.entries(o).filter(([f])=>f!=="secret"||i?.includes("secret"))):void 0;return e?{errorMap:e,description:s,[b]:l}:{errorMap:a((f,g)=>f.code!=="invalid_type"?{message:g.defaultError}:typeof g.data>"u"?{message:n??g.defaultError}:{message:r??g.defaultError},"customMap"),description:s,[b]:l}}a(k,"processCreateParams");var ls=a((t,e)=>{let r;switch(t.code){case h.invalid_type:t.received===_.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case h.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Z.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:r=`Unrecognized key(s) in object: ${Z.joinValues(t.keys,", ")}`;break;case h.invalid_union:r="Invalid input";break;case h.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Z.joinValues(t.options)}`;break;case h.invalid_enum_value:r=`Invalid enum value. Expected ${Z.joinValues(t.options)}, received '${t.received}'`;break;case h.invalid_arguments:r="Invalid function arguments";break;case h.invalid_return_type:r="Invalid function return type";break;case h.invalid_date:r="Invalid date";break;case h.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:Z.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case h.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case h.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case h.custom:r="Invalid input";break;case h.invalid_intersection_types:r="Intersection results could not be merged";break;case h.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case h.not_finite:r="Number must be finite";break;case h.unresolved_reference:r="Unresolved reference";break;default:r=e.defaultError,Z.assertNever(t)}return{message:r}},"errorMap"),Si=ls,h=Z.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite","unresolved_reference"]),Bl=a(t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),dr=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 f=o.path[d];d===o.path.length-1?(l[f]=l[f]||{_errors:[]},l[f]._errors.push(r(o))):l[f]=l[f]||{_errors:[]},l=l[f],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,Z.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};a(dr,"ZodError");dr.create=a(t=>new dr(t),"create");var le=dr,Al=ls;function cs(t){Al=t}a(cs,"setErrorMap");function st(){return Al}a(st,"getErrorMap");var Mt=a(t=>{var e;let{data:r,path:n,errorMaps:s,issueData:i}=t,o=[...n,...i.path||[]],l=p(c({},i),{path:o}),d="",f=s.filter(g=>!!g).slice().reverse();for(let g of f)d=g(l,{data:r,defaultError:d}).message;return p(c({},i),{path:o,message:(e=i.message)!=null?e:d})},"makeIssue"),Rl=[];function v(t,e){let r=Mt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,st(),ls].filter(n=>!!n)});t.common.issues.push(r)}a(v,"addIssueToContext");var Hl=class Dl{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let s of r){if(s.status==="aborted")return x;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let s of r)n.push({key:await s.key,value:await s.value});return Dl.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return x;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(n[i.value]=o.value)}return{status:e.value,value:n}}};a(Hl,"ParseStatus");var te=Hl,x=Object.freeze({status:"aborted"}),Re=a(t=>({status:"dirty",value:t}),"DIRTY"),J=a(t=>({status:"valid",value:t}),"OK"),ur=a(t=>t.status==="aborted","isAborted"),pr=a(t=>t.status==="dirty","isDirty"),it=a(t=>t.status==="valid","isValid"),Nt=a(t=>typeof Promise<"u"&&t instanceof Promise,"isAsync"),w;(t=>{t.errToObj=a(e=>typeof e=="string"?{message:e}:e||{},"errToObj"),t.toString=a(e=>typeof e=="string"?e:e?.message,"toString")})(w||(w={}));var fr=class Ml extends O{constructor(){super(...arguments),this._any=!0}_parse(e){return J(e.data)}isEqual(e){return e instanceof Ml}};a(fr,"ZodAny");fr.create=a(t=>new fr(c({typeName:"ZodAny"},k(t))),"create");var at=fr,gr=class Ie extends O{dereference(e){return new Ie(p(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new Ie(p(c({},this._def),{type:this._def.type.clone()}))}isEqual(e){var r,n,s,i,o,l;return e instanceof Ie?tt((r=this._def.exactLength)==null?void 0:r.value,(n=e._def.exactLength)==null?void 0:n.value)&&tt((s=this._def.maxLength)==null?void 0:s.value,(i=e._def.maxLength)==null?void 0:i.value)&&tt((o=this._def.minLength)==null?void 0:o.value,(l=e._def.minLength)==null?void 0:l.value)&&this._def.type.isEqual(e._def.type):!1}_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==_.array)return v(r,{code:h.invalid_type,expected:_.array,received:r.parsedType}),x;if(s.exactLength!==null){let o=r.data.length>s.exactLength.value,l=r.data.length<s.exactLength.value;(o||l)&&(v(r,{code:o?h.too_big:h.too_small,minimum:l?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(v(r,{code:h.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(v(r,{code:h.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((o,l)=>s.type._parseAsync(new ae(r,o,r.path,l)))).then(o=>te.mergeArray(n,o));let i=[...r.data].map((o,l)=>s.type._parseSync(new ae(r,o,r.path,l)));return te.mergeArray(n,i)}get element(){return this._def.type}min(e,r){return new Ie(p(c({},this._def),{minLength:{value:e,message:w.toString(r)}}))}max(e,r){return new Ie(p(c({},this._def),{maxLength:{value:e,message:w.toString(r)}}))}length(e,r){return new Ie(p(c({},this._def),{exactLength:{value:e,message:w.toString(r)}}))}nonempty(e){return this.min(1,e)}};a(gr,"ZodArray");gr.create=a((t,e)=>new gr(c({type:t,minLength:null,maxLength:null,exactLength:null,typeName:"ZodArray"},k(e))),"create");var ot=gr,tm=a((t,e)=>Nl(t,e,new WeakSet),"isEqual"),Nl=a((t,e,r)=>bh(t,e,rm(r)),"_isEqualWithVisitedTracking"),rm=a(t=>(e,r)=>{if(li(e)&&!t.has(e)&&li(r)&&!t.has(r)){let n=Pi(e,wi),s=Pi(r,wi);return t.add(n).add(s).add(e).add(r),Nl(n,s,t)}},"_customizerWithVisitedTracking"),nm={compare:tm},$l=class{constructor(e=[],r={}){this._options=c(c({},nm),r),this._items=[];for(let n of e)this.add(n)}get items(){return[...this._items]}get size(){return this._items.length}has(e){return this._items.some(r=>this._options.compare(r,e))}add(e){this.has(e)||this._items.push(e)}isEqual(e){return this.size!==e.size?!1:this.isSubsetOf(e)&&e.isSubsetOf(this)}isSubsetOf(e){return this.size>e.size?!1:this._items.every(r=>e.has(r))}};a($l,"CustomSet");var K=$l,hr=class tr extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==_.bigint){let i=this._getOrReturnCtx(e);return v(i,{code:h.invalid_type,expected:_.bigint,received:i.parsedType}),x}let n,s=new te;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Z.assertNever(i);return{status:s.value,value:e.data}}isEqual(e){if(!(e instanceof tr)||this._def.coerce!==e._def.coerce)return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)}gte(e,r){return this.setLimit("min",e,!0,w.toString(r))}gt(e,r){return this.setLimit("min",e,!1,w.toString(r))}lte(e,r){return this.setLimit("max",e,!0,w.toString(r))}lt(e,r){return this.setLimit("max",e,!1,w.toString(r))}setLimit(e,r,n,s){return new tr(p(c({},this._def),{checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:w.toString(s)}]}))}_addCheck(e){return new tr(p(c({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:w.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};a(hr,"ZodBigInt");hr.create=a(t=>{var e;return new hr(c({checks:[],typeName:"ZodBigInt",coerce:(e=t?.coerce)!=null?e:!1},k(t)))},"create");var tn=hr,mr=class jl extends O{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==_.boolean){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.boolean,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof jl?this._def.coerce===e._def.coerce:!1}};a(mr,"ZodBoolean");mr.create=a(t=>new mr(c({typeName:"ZodBoolean",coerce:t?.coerce||!1},k(t))),"create");var rn=mr,Kl=Symbol("zod_brand"),Ul=class Tt extends O{dereference(e){return new Tt(p(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new Tt(p(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}isEqual(e){return e instanceof Tt?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}mandatory(){return new Tt(p(c({},this._def),{type:this._def.type.mandatory()}))}};a(Ul,"ZodBranded");var nn=Ul,yr=class bt extends O{_parse(e){let{ctx:r}=this._processInputParams(e),n=p(c({},r),{common:p(c({},r.common),{issues:[]})}),s=this._def.innerType._parse({data:n.data,path:n.path,parent:c({},n)});return Nt(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new le(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new le(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}isEqual(e){return e instanceof bt?this._def.innerType.isEqual(e._def.innerType)&&Z.compareFunctions(this._def.catchValue,e._def.catchValue):!1}dereference(e){return new bt(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new bt(p(c({},this._def),{innerType:this._def.innerType.clone()}))}naked(){return this._def.innerType.naked()}mandatory(){return new bt(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(yr,"ZodCatch");yr.create=a((t,e)=>new yr(c({innerType:t,typeName:"ZodCatch",catchValue:typeof e.catch=="function"?e.catch:()=>e.catch},k(e))),"create");var sn=yr,ds=a((t,e={},r)=>t?at.create().superRefine((n,s)=>{var i,o;if(!t(n)){let l=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,d=(o=(i=l.fatal)!=null?i:r)!=null?o:!0,f=typeof l=="string"?{message:l}:l;s.addIssue(p(c({code:"custom"},f),{fatal:d}))}}):at.create(),"custom"),vr=class Un extends O{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==_.date){let i=this._getOrReturnCtx(e);return v(i,{code:h.invalid_type,expected:_.date,received:i.parsedType}),x}if(isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return v(i,{code:h.invalid_date}),x}let n=new te,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:h.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:h.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):Z.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Un(p(c({},this._def),{checks:[...this._def.checks,e]}))}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:w.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:w.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}isEqual(e){if(!(e instanceof Un))return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)&&this._def.coerce===e._def.coerce}};a(vr,"ZodDate");vr.create=a(t=>new vr(c({checks:[],coerce:t?.coerce||!1,typeName:"ZodDate"},k(t))),"create");var an=vr,_r=class wt extends O{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===_.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}dereference(e){return new wt(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new wt(p(c({},this._def),{innerType:this._def.innerType.clone()}))}isEqual(e){return e instanceof wt?this._def.innerType.isEqual(e._def.innerType)&&tt(this._def.defaultValue(),e._def.defaultValue()):!1}unwrap(){return this._def.innerType}naked(){return this._def.innerType.naked()}mandatory(){return new wt(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(_r,"ZodDefault");_r.create=a((t,e,r)=>new _r(c({innerType:t,typeName:"ZodDefault",defaultValue:typeof e=="function"?e:()=>e},k(r))),"create");var Kt=_r,ye=a(t=>Array.from(new Set(t)),"unique"),pe=a(t=>t instanceof ln?pe(t.schema):t instanceof Pe?pe(t.innerType()):t instanceof cn?[t.value]:t instanceof Le?t.options:t instanceof dn?Z.objectValues(t.enum):t instanceof Kt?pe(t._def.innerType):t instanceof Wt?[void 0]:t instanceof un?[null]:t instanceof ge?[void 0,...pe(t.unwrap())]:t instanceof De?[null,...pe(t.unwrap())]:t instanceof nn||t instanceof Ft?pe(t.unwrap()):t instanceof sn?pe(t._def.innerType):[],"getDiscriminator"),zl=class Be extends O{dereference(e){let r=this.options.map(s=>s.dereference(e)),n=Be._getOptionsMap(this.discriminator,r);return new Be(p(c({},this._def),{options:r,optionsMap:n}))}getReferences(){return ye(this.options.flatMap(e=>e.getReferences()))}clone(){let e=this.options.map(r=>r.clone());return new Be(p(c({},this._def),{options:e}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==_.object)return v(r,{code:h.invalid_type,expected:_.object,received:r.parsedType}),x;let n=this.discriminator,s=r.data[n],i=this.optionsMap.get(s);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(v(r,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),x)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let s=Be._getOptionsMap(e,r);return new Be(c({typeName:"ZodDiscriminatedUnion",discriminator:e,options:r,optionsMap:s},k(n)))}static _getOptionsMap(e,r){let n=new Map;for(let s of r){let i=pe(s.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of i){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,s)}}return n}isEqual(e){if(!(e instanceof Be)||this._def.discriminator!==e._def.discriminator)return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new K(this._def.options,{compare:r}),s=new K(e._def.options,{compare:r});return n.isEqual(s)}};a(zl,"ZodDiscriminatedUnion");var us=zl;function Ut(t,e){return new Le(c({values:t,typeName:"ZodEnum"},k(e)))}a(Ut,"createZodEnum");var ps=class rr extends O{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return v(r,{expected:Z.joinValues(n),received:r.parsedType,code:h.invalid_type}),x}if(this._def.values.indexOf(e.data)===-1){let r=this._getOrReturnCtx(e),n=this._def.values;return v(r,{received:r.data,code:h.invalid_enum_value,options:n}),x}return J(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return rr.create(e,c(c({},this._def),r))}exclude(e,r=this._def){return rr.create(this.options.filter(n=>!e.includes(n)),c(c({},this._def),r))}isEqual(e){if(!(e instanceof rr))return!1;let r=new K(this._def.values),n=new K(e._def.values);return r.isEqual(n)}};a(ps,"ZodEnum");ps.create=Ut;var Le=ps,Fl=class Ce extends O{constructor(){super(...arguments),this.validate=this.implement}dereference(e){let r=this._def.args.dereference(e),n=this._def.returns.dereference(e);return new Ce(p(c({},this._def),{args:r,returns:n}))}getReferences(){return ye([...this._def.args.getReferences(),...this._def.returns.getReferences()])}clone(){return new Ce(p(c({},this._def),{args:this._def.args.clone(),returns:this._def.returns.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==_.function)return v(r,{code:h.invalid_type,expected:_.function,received:r.parsedType}),x;function n(l,d){return Mt({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,st(),Si].filter(f=>!!f),issueData:{code:h.invalid_arguments,argumentsError:d}})}a(n,"makeArgsIssue");function s(l,d){return Mt({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,st(),Si].filter(f=>!!f),issueData:{code:h.invalid_return_type,returnTypeError:d}})}a(s,"makeReturnsIssue");let i={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof zt){let l=this;return J(async function(...d){let f=new le([]),g=await l._def.args.parseAsync(d,i).catch(E=>{throw f.addIssue(n(d,E)),f}),m=await Reflect.apply(o,this,g);return await l._def.returns._def.type.parseAsync(m,i).catch(E=>{throw f.addIssue(s(m,E)),f})})}else{let l=this;return J(function(...d){let f=l._def.args.safeParse(d,i);if(!f.success)throw new le([n(d,f.error)]);let g=Reflect.apply(o,this,f.data),m=l._def.returns.safeParse(g,i);if(!m.success)throw new le([s(g,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ce(p(c({},this._def),{args:Ne.create(e).rest(rt.create())}))}returns(e){return new Ce(p(c({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new Ce(c({args:e||Ne.create([]).rest(rt.create()),returns:r||rt.create(),typeName:"ZodFunction"},k(n)))}isEqual(e){return e instanceof Ce&&this._def.args.isEqual(e._def.args)&&this._def.returns.isEqual(e._def.returns)}};a(Fl,"ZodFunction");var fs=Fl;function Tr(t,e){let r=fe(t),n=fe(e);if(t===e)return{valid:!0,data:t};if(r===_.object&&n===_.object){let s=Z.objectKeys(e),i=Z.objectKeys(t).filter(l=>s.indexOf(l)!==-1),o=c(c({},t),e);for(let l of i){let d=Tr(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=Tr(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(Tr,"mergeValues");var br=class nr extends O{dereference(e){return new nr(p(c({},this._def),{left:this._def.left.dereference(e),right:this._def.right.dereference(e)}))}getReferences(){return ye([...this._def.left.getReferences(),...this._def.right.getReferences()])}clone(){return new nr(p(c({},this._def),{left:this._def.left.clone(),right:this._def.right.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=a((i,o)=>{if(ur(i)||ur(o))return x;let l=Tr(i.value,o.value);return l.valid?((pr(i)||pr(o))&&r.dirty(),{status:r.value,value:l.data}):(v(n,{code:h.invalid_intersection_types}),x)},"handleParsed");return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}isEqual(e){if(!(e instanceof nr))return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new K([this._def.left,this._def.right],{compare:r}),s=new K([e._def.left,e._def.right],{compare:r});return n.isEqual(s)}};a(br,"ZodIntersection");br.create=a((t,e,r)=>new br(c({left:t,right:e,typeName:"ZodIntersection"},k(r))),"create");var on=br,wr=class Pt extends O{get schema(){return this._def.getter()}dereference(e){return new Pt(p(c({},this._def),{getter:a(()=>this._def.getter().dereference(e),"getter")}))}getReferences(){return this._def.getter().getReferences()}clone(){return new Pt(p(c({},this._def),{getter:a(()=>this._def.getter().clone(),"getter")}))}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}isEqual(e){return e instanceof Pt?this._def.getter().isEqual(e._def.getter()):!1}naked(){return this._def.getter().naked()}mandatory(){return new Pt(p(c({},this._def),{getter:a(()=>this._def.getter().mandatory(),"getter")}))}};a(wr,"ZodLazy");wr.create=a((t,e)=>new wr(c({getter:t,typeName:"ZodLazy"},k(e))),"create");var ln=wr,Pr=class Wl extends O{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return v(r,{received:r.data,code:h.invalid_literal,expected:this._def.value}),x}return{status:"valid",value:e.data}}get value(){return this._def.value}isEqual(e){return e instanceof Wl?tt(this._def.value,e._def.value):!1}};a(Pr,"ZodLiteral");Pr.create=a((t,e)=>new Pr(c({value:t,typeName:"ZodLiteral"},k(e))),"create");var cn=Pr,xr=class sr extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}dereference(e){let r=this._def.keyType.dereference(e),n=this._def.valueType.dereference(e);return new sr(p(c({},this._def),{keyType:r,valueType:n}))}getReferences(){return ye([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new sr(p(c({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.map)return v(n,{code:h.invalid_type,expected:_.map,received:n.parsedType}),x;let s=this._def.keyType,i=this._def.valueType,o=[...n.data.entries()].map(([l,d],f)=>({key:s._parse(new ae(n,l,n.path,[f,"key"])),value:i._parse(new ae(n,d,n.path,[f,"value"]))}));if(n.common.async){let l=new Map;return Promise.resolve().then(async()=>{for(let d of o){let f=await d.key,g=await d.value;if(f.status==="aborted"||g.status==="aborted")return x;(f.status==="dirty"||g.status==="dirty")&&r.dirty(),l.set(f.value,g.value)}return{status:r.value,value:l}})}else{let l=new Map;for(let d of o){let f=d.key,g=d.value;if(f.status==="aborted"||g.status==="aborted")return x;(f.status==="dirty"||g.status==="dirty")&&r.dirty(),l.set(f.value,g.value)}return{status:r.value,value:l}}}isEqual(e){return!(!(e instanceof sr)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};a(xr,"ZodMap");xr.create=a((t,e,r)=>new xr(c({valueType:e,keyType:t,typeName:"ZodMap"},k(r))),"create");var gs=xr,kr=class Ll extends O{_parse(e){if(this._getType(e)!==_.nan){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.nan,received:n.parsedType}),x}return{status:"valid",value:e.data}}isEqual(e){return e instanceof Ll}};a(kr,"ZodNaN");kr.create=a(t=>new kr(c({typeName:"ZodNaN"},k(t))),"create");var hs=kr,Sr=class ql extends O{_parse(e){let r=Z.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==_.string&&n.parsedType!==_.number){let s=Z.objectValues(r);return v(n,{expected:Z.joinValues(s),received:n.parsedType,code:h.invalid_type}),x}if(r.indexOf(e.data)===-1){let s=Z.objectValues(r);return v(n,{received:n.data,code:h.invalid_enum_value,options:s}),x}return J(e.data)}get enum(){return this._def.values}isEqual(e){return e instanceof ql?tt(this._def.values,e._def.values):!1}};a(Sr,"ZodNativeEnum");Sr.create=a((t,e)=>new Sr(c({values:t,typeName:"ZodNativeEnum"},k(e))),"create");var dn=Sr,Or=class Vl extends O{_parse(e){let r=this._getOrReturnCtx(e);return v(r,{code:h.invalid_type,expected:_.never,received:r.parsedType}),x}isEqual(e){return e instanceof Vl}};a(Or,"ZodNever");Or.create=a(t=>new Or(c({typeName:"ZodNever"},k(t))),"create");var dt=Or,Er=class Gl extends O{_parse(e){if(this._getType(e)!==_.null){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.null,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof Gl}};a(Er,"ZodNull");Er.create=a(t=>new Er(c({typeName:"ZodNull"},k(t))),"create");var un=Er,Zr=class xt extends O{dereference(e){return new xt(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new xt(p(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)===_.null?J(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof xt?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new xt(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(Zr,"ZodNullable");Zr.create=a((t,e)=>new Zr(c({innerType:t,typeName:"ZodNullable"},k(e))),"create");var De=Zr;function Jl(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,i=parseInt(t.toFixed(s).replace(".","")),o=parseInt(e.toFixed(s).replace(".",""));return i%o/Math.pow(10,s)}a(Jl,"floatSafeRemainder");var Ir=class ir extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==_.number){let i=this._getOrReturnCtx(e);return v(i,{code:h.invalid_type,expected:_.number,received:i.parsedType}),x}let n,s=new te;for(let i of this._def.checks)i.kind==="int"?Z.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{code:h.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Jl(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{code:h.not_finite,message:i.message}),s.dirty()):Z.assertNever(i);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,w.toString(r))}gt(e,r){return this.setLimit("min",e,!1,w.toString(r))}lte(e,r){return this.setLimit("max",e,!0,w.toString(r))}lt(e,r){return this.setLimit("max",e,!1,w.toString(r))}setLimit(e,r,n,s){return new ir(p(c({},this._def),{checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:w.toString(s)}]}))}_addCheck(e){return new ir(p(c({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:w.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:w.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:w.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:w.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:w.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Z.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}isEqual(e){if(!(e instanceof ir))return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)}};a(Ir,"ZodNumber");Ir.create=a(t=>new Ir(c({checks:[],typeName:"ZodNumber",coerce:t?.coerce||!1},k(t))),"create");var pn=Ir;function Ae(t){if(t instanceof Me){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=ge.create(Ae(n))}return new Me(p(c({},t._def),{shape:a(()=>e,"shape")}))}else return t instanceof ot?new ot(p(c({},t._def),{type:Ae(t.element)})):t instanceof ge?ge.create(Ae(t.unwrap())):t instanceof De?De.create(Ae(t.unwrap())):t instanceof Ne?Ne.create(t.items.map(e=>Ae(e))):t}a(Ae,"deepPartialify");var we=class ne extends O{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=Z.objectKeys(e);return this._cached={shape:e,keys:r}}dereference(e){let r=this._def.shape(),n={};for(let s in r)n[s]=r[s].dereference(e);return new ne(p(c({},this._def),{shape:a(()=>n,"shape")}))}getReferences(){let e=this._def.shape(),r=[];for(let n in e)r.push(...e[n].getReferences());return ye(r)}clone(){let e={},r=this._def.shape();for(let[n,s]of Object.entries(r))e[n]=s.clone();return new ne(p(c({},this._def),{shape:a(()=>e,"shape")}))}_parse(e){if(this._getType(e)!==_.object){let g=this._getOrReturnCtx(e);return v(g,{code:h.invalid_type,expected:_.object,received:g.parsedType}),x}let{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),l=[];if(this._def.unknownKeys!=="strip")for(let g in s.data)o.includes(g)||l.push(g);let d=[];for(let g of o){let m=i[g],P=s.data[g];d.push({key:{status:"valid",value:g},value:m._parse(new ae(s,P,s.path,g)),alwaysSet:g in s.data})}let f=this._def.unknownKeys;if(f==="passthrough")for(let g of l)d.push({key:{status:"valid",value:g},value:{status:"valid",value:s.data[g]}});else if(f==="strict")l.length>0&&(v(s,{code:h.unrecognized_keys,keys:l}),n.dirty());else if(f!=="strip")for(let g of l){let m=s.data[g];d.push({key:{status:"valid",value:g},value:f._parse(new ae(s,m,s.path,g)),alwaysSet:g in s.data})}return s.common.async?Promise.resolve().then(async()=>{let g=[];for(let m of d){let P=await m.key;g.push({key:P,value:await m.value,alwaysSet:m.alwaysSet})}return g}).then(g=>te.mergeObjectSync(n,g)):te.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return w.errToObj,new ne(c(p(c({},this._def),{unknownKeys:"strict"}),e!==void 0?{errorMap:a((r,n)=>{var s,i,o,l;let 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=w.errToObj(e).message)!=null?l:d}:{message:d}},"errorMap")}:{}))}strip(){return new ne(p(c({},this._def),{unknownKeys:"strip"}))}passthrough(){return new ne(p(c({},this._def),{unknownKeys:"passthrough"}))}additionalProperties(){if(this._def.unknownKeys instanceof O)return this._def.unknownKeys;if(this._def.unknownKeys==="passthrough")return at.create();if(this._def.unknownKeys==="strict")return dt.create()}extend(e){return new ne(p(c({},this._def),{shape:a(()=>c(c({},this._def.shape()),e),"shape")}))}merge(e){return new ne({unknownKeys:e._def.unknownKeys,shape:a(()=>c(c({},this._def.shape()),e._def.shape()),"shape"),typeName:"ZodObject"})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new ne(p(c({},this._def),{unknownKeys:e}))}pick(e){let r={};return Z.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new ne(p(c({},this._def),{shape:a(()=>r,"shape")}))}omit(e){let r={};return Z.objectKeys(this.shape).forEach(n=>{e[n]||(r[n]=this.shape[n])}),new ne(p(c({},this._def),{shape:a(()=>r,"shape")}))}deepPartial(){return Ae(this)}partial(e){let r={};return Z.objectKeys(this.shape).forEach(n=>{let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s?.optional()}),new ne(p(c({},this._def),{shape:a(()=>r,"shape")}))}required(e){let r={};return Z.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof ge;)i=i._def.innerType;r[n]=i}}),new ne(p(c({},this._def),{shape:a(()=>r,"shape")}))}keyof(){return Ut(Z.objectKeys(this.shape))}isEqual(e){if(!(e instanceof ne)||!this._unknownKeysEqual(e))return!1;let r=this._def.shape(),n=e._def.shape(),s=a((l,d)=>l[0]===d[0]&&l[1].isEqual(d[1]),"compare"),i=new K(Object.entries(r),{compare:s}),o=new K(Object.entries(n),{compare:s});return i.isEqual(o)}_unknownKeysEqual(e){let r=this.additionalProperties(),n=e.additionalProperties();return r===void 0||n===void 0?r===n:r.isEqual(n)}};a(we,"ZodObject");we.create=a((t,e)=>new we(c({shape:a(()=>t,"shape"),unknownKeys:"strip",typeName:"ZodObject"},k(e))),"create");we.strictCreate=a((t,e)=>new we(c({shape:a(()=>t,"shape"),unknownKeys:"strict",typeName:"ZodObject"},k(e))),"strictCreate");we.lazycreate=a((t,e)=>new we(c({shape:t,unknownKeys:"strip",typeName:"ZodObject"},k(e))),"lazycreate");var Me=we,Br=class ar extends O{dereference(e){return new ar(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new ar(p(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)===_.undefined?J(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof ar?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return this._def.innerType.mandatory()}};a(Br,"ZodOptional");Br.create=a((t,e)=>new Br(c({innerType:t,typeName:"ZodOptional"},k(e))),"create");var ge=Br,Xl=class kt extends O{dereference(e){return new kt(p(c({},this._def),{in:this._def.in.dereference(e),out:this._def.out.dereference(e)}))}getReferences(){return ye([...this._def.in.getReferences(),...this._def.out.getReferences()])}clone(){return new kt(p(c({},this._def),{in:this._def.in.clone(),out:this._def.out.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return a(async()=>{let i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?x:i.status==="dirty"?(r.dirty(),Re(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})},"handleAsync")();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?x:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new kt({in:e,out:r,typeName:"ZodPipeline"})}isEqual(e){return!(!(e instanceof kt)||!this._def.in.isEqual(e._def.in)||!this._def.out.isEqual(e._def.out))}};a(Xl,"ZodPipeline");var fn=Xl,Cr=class or extends O{unwrap(){return this._def.type}dereference(e){return new or(p(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new or(p(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==_.promise&&r.common.async===!1)return v(r,{code:h.invalid_type,expected:_.promise,received:r.parsedType}),x;let n=r.parsedType===_.promise?r.data:Promise.resolve(r.data);return J(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}isEqual(e){return e instanceof or?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}};a(Cr,"ZodPromise");Cr.create=a((t,e)=>new Cr(c({type:t,typeName:"ZodPromise"},k(e))),"create");var zt=Cr,Ar=class St extends O{dereference(e){return new St(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new St(p(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){let r=this._def.innerType._parse(e);return it(r)&&(r.value=Object.freeze(r.value)),r}unwrap(){return this._def.innerType}isEqual(e){return e instanceof St?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new St(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(Ar,"ZodReadonly");Ar.create=a((t,e)=>new Ar(c({innerType:t,typeName:"ZodReadonly"},k(e))),"create");var Ft=Ar,Yl=class Xe extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}dereference(e){let r=this._def.keyType.dereference(e),n=this._def.valueType.dereference(e);return new Xe(p(c({},this._def),{keyType:r,valueType:n}))}getReferences(){return ye([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new Xe(p(c({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.object)return v(n,{code:h.invalid_type,expected:_.object,received:n.parsedType}),x;let s=[],i=this._def.keyType,o=this._def.valueType;for(let l in n.data)s.push({key:i._parse(new ae(n,l,n.path,l)),value:o._parse(new ae(n,n.data[l],n.path,l))});return n.common.async?te.mergeObjectAsync(r,s):te.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof O?new Xe(c({keyType:e,valueType:r,typeName:"ZodRecord"},k(n))):new Xe(c({keyType:X.create(),valueType:e,typeName:"ZodRecord"},k(r)))}isEqual(e){return!(!(e instanceof Xe)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};a(Yl,"ZodRecord");var ms=Yl,Rr=class Ql extends O{dereference(e){let r=e[this._def.uri];return r||this}getReferences(){return[this._def.uri]}_parse(e){let r=this._getOrReturnCtx(e);return v(r,{code:h.unresolved_reference}),x}isOptional(){return!1}isNullable(){return!1}isEqual(e){return e instanceof Ql?this._def.uri===e._def.uri:!1}};a(Rr,"ZodRef");Rr.create=a(t=>new Rr({typeName:"ZodRef",uri:t}),"create");var ys=Rr,Hr=class Ye extends O{dereference(e){return new Ye(p(c({},this._def),{valueType:this._def.valueType.dereference(e)}))}getReferences(){return this._def.valueType.getReferences()}clone(){return new Ye(p(c({},this._def),{valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.set)return v(n,{code:h.invalid_type,expected:_.set,received:n.parsedType}),x;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(v(n,{code:h.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(v(n,{code:h.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let i=this._def.valueType;function o(d){let f=new Set;for(let g of d){if(g.status==="aborted")return x;g.status==="dirty"&&r.dirty(),f.add(g.value)}return{status:r.value,value:f}}a(o,"finalizeSet");let l=[...n.data.values()].map((d,f)=>i._parse(new ae(n,d,n.path,f)));return n.common.async?Promise.all(l).then(d=>o(d)):o(l)}min(e,r){return new Ye(p(c({},this._def),{minSize:{value:e,message:w.toString(r)}}))}max(e,r){return new Ye(p(c({},this._def),{maxSize:{value:e,message:w.toString(r)}}))}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}isEqual(e){var r,n,s,i;if(!(e instanceof Ye))return!1;let o=(r=this._def.minSize)==null?void 0:r.value,l=(n=e._def.minSize)==null?void 0:n.value;if(o!==l)return!1;let d=(s=this._def.maxSize)==null?void 0:s.value,f=(i=e._def.maxSize)==null?void 0:i.value;return d!==f?!1:this._def.valueType.isEqual(e._def.valueType)}};a(Hr,"ZodSet");Hr.create=a((t,e)=>new Hr(c({valueType:t,minSize:null,maxSize:null,typeName:"ZodSet"},k(e))),"create");var vs=Hr,_s=/^c[^\s-]{8,}$/i,Ts=/^[a-z][a-z0-9]*$/,bs=/^[0-9A-HJKMNP-TV-Z]{26}$/,ws=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Ps=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ec="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",tc=a(t=>t===ec,"isEmojiRegex"),Cn,xs=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,ks=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;function rc(t,e){return!!((e==="v4"||!e)&&xs.test(t)||(e==="v6"||!e)&&ks.test(t))}a(rc,"isValidIP");var Dr=class Qe extends O{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==_.string){let i=this._getOrReturnCtx(e);return v(i,{code:h.invalid_type,expected:_.string,received:i.parsedType}),x}let n=new te,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:h.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:h.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,l=e.data.length<i.value;(o||l)&&(s=this._getOrReturnCtx(e,s),o?v(s,{code:h.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):l&&v(s,{code:h.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")Ps.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"email",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")Cn||(Cn=new RegExp(ec,"u")),Cn.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"emoji",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")ws.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"uuid",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")_s.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"cuid",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")Ts.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"cuid2",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")bs.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"ulid",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),v(s,{validation:"url",code:h.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"regex",code:h.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),v(s,{code:h.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),v(s,{code:h.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),v(s,{code:h.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?El(i).test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{code:h.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="ip"?rc(e.data,i.version)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"ip",code:h.invalid_string,message:i.message}),n.dirty()):Z.assertNever(i);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),c({validation:r,code:h.invalid_string},w.errToObj(n)))}_addCheck(e){return new Qe(p(c({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(c({kind:"email"},w.errToObj(e)))}url(e){return this._addCheck(c({kind:"url"},w.errToObj(e)))}emoji(e){return this._addCheck(c({kind:"emoji"},w.errToObj(e)))}uuid(e){return this._addCheck(c({kind:"uuid"},w.errToObj(e)))}cuid(e){return this._addCheck(c({kind:"cuid"},w.errToObj(e)))}cuid2(e){return this._addCheck(c({kind:"cuid2"},w.errToObj(e)))}ulid(e){return this._addCheck(c({kind:"ulid"},w.errToObj(e)))}ip(e){return this._addCheck(c({kind:"ip"},w.errToObj(e)))}datetime(e){var r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck(c({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(r=e?.offset)!=null?r:!1},w.errToObj(e?.message)))}regex(e,r){return this._addCheck(c({kind:"regex",regex:e},w.errToObj(r)))}includes(e,r){return this._addCheck(c({kind:"includes",value:e,position:r?.position},w.errToObj(r?.message)))}startsWith(e,r){return this._addCheck(c({kind:"startsWith",value:e},w.errToObj(r)))}endsWith(e,r){return this._addCheck(c({kind:"endsWith",value:e},w.errToObj(r)))}min(e,r){return this._addCheck(c({kind:"min",value:e},w.errToObj(r)))}max(e,r){return this._addCheck(c({kind:"max",value:e},w.errToObj(r)))}length(e,r){return this._addCheck(c({kind:"length",value:e},w.errToObj(r)))}nonempty(e){return this.min(1,w.errToObj(e))}trim(){return new Qe(p(c({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}secret(){return this._def[b]=p(c({},this._def[b]),{secret:!0}),this}toLowerCase(){return new Qe(p(c({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new Qe(p(c({},this._def),{checks:[...this._def.checks,{kind:"toUpperCase"}]}))}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}isEqual(e){if(!(e instanceof Qe))return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)}};a(Dr,"ZodString");Dr.create=a(t=>{var e;return new Dr(c({checks:[],typeName:"ZodString",coerce:(e=t?.coerce)!=null?e:!1},k(p(c({},t),{supportsExtensions:["secret"]}))))},"create");var X=Dr,Mr=class nc extends O{_parse(e){if(this._getType(e)!==_.symbol){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.symbol,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof nc}};a(Mr,"ZodSymbol");Mr.create=a(t=>new Mr(c({typeName:"ZodSymbol"},k(t))),"create");var Ss=Mr,lt=class Ot extends O{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName==="ZodEffects"?this._def.schema.sourceType():this._def.schema}dereference(e){return new Ot(p(c({},this._def),{schema:this._def.schema.dereference(e)}))}getReferences(){return this._def.schema.getReferences()}clone(){return new Ot(p(c({},this._def),{schema:this._def.schema.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a(o=>{v(n,o),o.fatal?r.abort():r.dirty()},"addIssue"),get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let o=s.transform(n.data,i);if(n.common.async)return Promise.resolve(o).then(async l=>{if(r.value==="aborted")return x;let d=await this._def.schema._parseAsync({data:l,path:n.path,parent:n});return d.status==="aborted"?x:d.status==="dirty"||r.value==="dirty"?Re(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"?Re(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(!it(o))return o;let l=s.transform(o.value,i);if(l instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:l}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>it(o)?Promise.resolve(s.transform(o.value,i)).then(l=>({status:r.value,value:l})):o);Z.assertNever(s)}isEqual(e){return!(e instanceof Ot)||!this._def.schema.isEqual(e._def.schema)?!1:this._def.effect.type==="refinement"?e._def.effect.type!=="refinement"?!1:Z.compareFunctions(this._def.effect.refinement,e._def.effect.refinement):this._def.effect.type==="transform"?e._def.effect.type!=="transform"?!1:Z.compareFunctions(this._def.effect.transform,e._def.effect.transform):this._def.effect.type==="preprocess"?e._def.effect.type!=="preprocess"?!1:Z.compareFunctions(this._def.effect.transform,e._def.effect.transform):!1}naked(){return this._def.schema.naked()}mandatory(){return new Ot(p(c({},this._def),{schema:this._def.schema.mandatory()}))}};a(lt,"ZodEffects");lt.create=a((t,e,r)=>new lt(c({schema:t,typeName:"ZodEffects",effect:e},k(r))),"create");lt.createWithPreprocess=a((t,e,r)=>new lt(c({schema:e,effect:{type:"preprocess",transform:t},typeName:"ZodEffects"},k(r))),"createWithPreprocess");var Pe=lt,Nr=class Et extends O{dereference(e){let r=this._def.items.map(s=>s.dereference(e)),n=this._def.rest?this._def.rest.dereference(e):null;return new Et(p(c({},this._def),{items:r,rest:n}))}getReferences(){return ye([...this._def.items.flatMap(e=>e.getReferences()),...this._def.rest?this._def.rest.getReferences():[]])}clone(){let e=this._def.items.map(n=>n.clone()),r=this._def.rest?this._def.rest.clone():null;return new Et(p(c({},this._def),{items:e,rest:r}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.array)return v(n,{code:h.invalid_type,expected:_.array,received:n.parsedType}),x;if(n.data.length<this._def.items.length)return v(n,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),x;!this._def.rest&&n.data.length>this._def.items.length&&(v(n,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...n.data].map((o,l)=>{let d=this._def.items[l]||this._def.rest;return d?d._parse(new ae(n,o,n.path,l)):null}).filter(o=>!!o);return n.common.async?Promise.all(i).then(o=>te.mergeArray(r,o)):te.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new Et(p(c({},this._def),{rest:e}))}isEqual(e){if(!(e instanceof Et)||!this._restEquals(e))return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new K(this._def.items,{compare:r}),s=new K(e._def.items,{compare:r});return n.isEqual(s)}_restEquals(e){return this._def.rest===null?e._def.rest===null:e._def.rest!==null&&this._def.rest.isEqual(e._def.rest)}};a(Nr,"ZodTuple");Nr.create=a((t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Nr(c({items:t,typeName:"ZodTuple",rest:null},k(e)))},"create");var Ne=Nr,$r=class sc extends O{_parse(e){if(this._getType(e)!==_.undefined){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.undefined,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof sc}mandatory(){return dt.create(c({},this._def))}};a($r,"ZodUndefined");$r.create=a(t=>new $r(c({typeName:"ZodUndefined"},k(t))),"create");var Wt=$r,jr=class Zt extends O{dereference(e){let r=this._def.options.map(n=>n.dereference(e));return new Zt(p(c({},this._def),{options:r}))}getReferences(){return ye(this._def.options.reduce((e,r)=>[...e,...r.getReferences()],[]))}clone(){let e=this._def.options.map(r=>r.clone());return new Zt(p(c({},this._def),{options:e}))}_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function s(i){for(let l of i)if(l.result.status==="valid")return l.result;for(let l of i)if(l.result.status==="dirty")return r.common.issues.push(...l.ctx.common.issues),l.result;let o=i.map(l=>new le(l.ctx.common.issues));return v(r,{code:h.invalid_union,unionErrors:o}),x}if(a(s,"handleResults"),r.common.async)return Promise.all(n.map(async i=>{let o=p(c({},r),{common:p(c({},r.common),{issues:[]}),parent:null});return{result:await i._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(s);{let i,o=[];for(let d of n){let f=p(c({},r),{common:p(c({},r.common),{issues:[]}),parent:null}),g=d._parseSync({data:r.data,path:r.path,parent:f});if(g.status==="valid")return g;g.status==="dirty"&&!i&&(i={result:g,ctx:f}),f.common.issues.length&&o.push(f.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let l=o.map(d=>new le(d));return v(r,{code:h.invalid_union,unionErrors:l}),x}}get options(){return this._def.options}isEqual(e){if(!(e instanceof Zt))return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new K([...this._def.options],{compare:r}),s=new K([...e._def.options],{compare:r});return n.isEqual(s)}mandatory(){let e=this._def.options.filter(i=>!(i instanceof Wt)).map(i=>i.mandatory()),[r,n,...s]=e;return r?n?new Zt(p(c({},this._def),{options:[r,n,...s]})):r:dt.create(c({},this._def))}};a(jr,"ZodUnion");jr.create=a((t,e)=>new jr(c({options:t,typeName:"ZodUnion"},k(e))),"create");var gn=jr,Kr=class ic extends O{constructor(){super(...arguments),this._unknown=!0}_parse(e){return J(e.data)}isEqual(e){return e instanceof ic}};a(Kr,"ZodUnknown");Kr.create=a(t=>new Kr(c({typeName:"ZodUnknown"},k(t))),"create");var rt=Kr,Ur=class ac extends O{_parse(e){if(this._getType(e)!==_.undefined){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.void,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof ac}};a(Ur,"ZodVoid");Ur.create=a(t=>new Ur(c({typeName:"ZodVoid"},k(t))),"create");var Os=Ur,sm=["gpt-3.5-turbo","gpt-3.5-turbo-16k","gpt-4","gpt-4-1106-preview","gpt-4-vision-preview","gpt-4-0125-preview","gpt-4-turbo-preview","gpt-4-turbo","gpt-4o","gpt-3.5-turbo-0125","gpt-3.5-turbo-1106"],yv=Le.create(["any","string","number","boolean","object","pattern","date","array","target","time","enum"]),oc=a(t=>X.create().displayAs({id:"variable",params:c({type:t?.type||"any"},t?.params)}),"variable"),lc=a(t=>X.create().displayAs({id:"conversation",params:c({},t?.params)}),"conversation"),cc=a(t=>X.create().displayAs({id:"user",params:c({},t?.params)}),"user"),dc=a(t=>X.create().displayAs({id:"message",params:c({},t?.params)}),"message"),uc=a(t=>X.create().displayAs({id:"agent",params:c({},t?.params)}),"agent"),pc=a(t=>X.create().displayAs({id:"event",params:c({},t?.params)}),"event"),fc=a(t=>X.create().displayAs({id:"table",params:c({},t?.params)}),"table"),gc=a(t=>X.create().displayAs({id:"tablerow",params:c({},t?.params)}),"tablerow"),hc=a(t=>X.create().displayAs({id:"intent",params:c({},t?.params)}),"intent"),mc=a(()=>Le.create(sm).displayAs({id:"dropdown",params:{}}),"aimodel"),yc=a(t=>X.create().displayAs({id:"datasource",params:c({},t)}),"datasource"),vc=a(t=>X.create().displayAs({id:"knowledgebase",params:c({},t)}),"knowledgebase"),_c={object:Me.lazycreate},Tc=a((t,e={message:`Input not instance of ${t.name}`})=>ds(r=>r instanceof t,e),"instanceOfType"),Es=X.create,Zs=pn.create,bc=hs.create,wc=tn.create,Is=rn.create,Pc=an.create,xc=Ss.create,kc=Wt.create,Sc=un.create,Oc=at.create,Ec=rt.create,Zc=dt.create,Ic=Os.create,Bc=ot.create,Cc=Me.create,Ac=Me.strictCreate,Rc=gn.create,Hc=us.create,Dc=on.create,Mc=Ne.create,Nc=ms.create,$c=ys.create,jc=Ft.create,Kc=gs.create,Uc=vs.create,zc=fs.create,Fc=ln.create,Wc=cn.create,Lc=Le.create,qc=dn.create,Vc=zt.create,zn=Pe.create,Gc=ge.create,Jc=De.create,im=Kt.create,Xc=Pe.createWithPreprocess,Yc=fn.create,Qc=a(()=>Es().optional(),"ostring"),ed=a(()=>Zs().optional(),"onumber"),td=a(()=>Is().optional(),"oboolean"),rd={string:a(t=>X.create(p(c({},t),{coerce:!0})),"string"),number:a(t=>pn.create(p(c({},t),{coerce:!0})),"number"),boolean:a(t=>rn.create(p(c({},t),{coerce:!0})),"boolean"),bigint:a(t=>tn.create(p(c({},t),{coerce:!0})),"bigint"),date:a(t=>an.create(p(c({},t),{coerce:!0})),"date")},nd=x,u=y,sd=a((t,e)=>t.anyOf.length?t.anyOf.length===1?W(t.anyOf[0],p(c({},e),{path:[...e.path,"anyOf",0]})):`z.union([${t.anyOf.map((r,n)=>W(r,p(c({},e),{path:[...e.path,"anyOf",n]}))).join(", ")}])`:"z.any()","parseAnyOf"),am=a(t=>{var e;return(e=t[b])!=null&&e.coerce?"z.coerce.boolean()":"z.boolean()"},"parseBoolean"),om=a(t=>"z.any()","parseDefault"),lm=a((t,e)=>`z.union([${t.type.map(r=>W(p(c({},t),{type:r}),e)).join(", ")}])`,"parseMultipleType"),cm=a((t,e)=>`z.any().refine((value) => !${W(t.not,p(c({},e),{path:[...e.path,"not"]}))}.safeParse(value).success, "Invalid input: Should NOT be valid against schema")`,"parseNot"),dm=a(t=>"z.null()","parseNull"),um=a(t=>[t.slice(0,t.length/2),t.slice(t.length/2)],"half"),pm=a((t,...e)=>Object.keys(t).reduce((r,n)=>(e.includes(n)||(r[n]=t[n]),r),{}),"omit");function G(t,e,r){var n;let s=t[e],i="";if(s!==void 0){let o=r({value:s,json:JSON.stringify(s)});if(o){let l=o[0],d=o.length===3?o[1]:"",f=o.length===3?o[2]:o[1];i+=l,((n=t.errorMessage)==null?void 0:n[e])!==void 0&&(i+=d+JSON.stringify(t.errorMessage[e])),i+=f}}return i}a(G,"withMessage");var It=Symbol("Original index"),fm=a(t=>{let e=[];for(let r=0;r<t.length;r++){let n=t[r];if(typeof n=="boolean")e.push(n?{[It]:r}:{[It]:r,not:{}});else{if(It in n)return t;e.push(p(c({},n),{[It]:r}))}}return e},"ensureOriginalIndex");function $t(t,e){if(t.allOf.length===0)return"z.never()";if(t.allOf.length===1){let r=t.allOf[0];return W(r,p(c({},e),{path:[...e.path,"allOf",r[It]]}))}else{let[r,n]=um(fm(t.allOf));return`z.intersection(${$t({allOf:r},e)}, ${$t({allOf:n},e)})`}}a($t,"parseAllOf");var gm=a((t,e)=>{if(Array.isArray(t.items))return`z.tuple([${t.items.map((n,s)=>W(n,p(c({},e),{path:[...e.path,"items",s]})))}])`;let r=t.items?`z.array(${W(t.items,p(c({},e),{path:[...e.path,"items"]}))})`:"z.array(z.any())";return r+=G(t,"minItems",({json:n})=>[`.min(${n}`,", ",")"]),r+=G(t,"maxItems",({json:n})=>[`.max(${n}`,", ",")"]),r},"parseArray"),hm=a(t=>`z.literal(${JSON.stringify(t.const)})`,"parseConst"),mm=a(t=>t.enum.length===0?"z.never()":t.enum.length===1?`z.literal(${JSON.stringify(t.enum[0])})`:t.enum.every(e=>typeof e=="string")?`z.enum([${t.enum.map(e=>JSON.stringify(e))}])`:`z.union([${t.enum.map(e=>`z.literal(${JSON.stringify(e)})`).join(", ")}])`,"parseEnum"),ym=a((t,e)=>{let r=W(t.if,p(c({},e),{path:[...e.path,"if"]})),n=W(t.then,p(c({},e),{path:[...e.path,"then"]})),s=W(t.else,p(c({},e),{path:[...e.path,"else"]}));return`z.union([${n}, ${s}]).superRefine((value,ctx) => {
|
|
8
|
+
${m.join(" | ")}`;case u.ZodFirstPartyTypeKind.ZodIntersection:return`${B(l.left,i)} & ${B(l.right,i)}`;case u.ZodFirstPartyTypeKind.ZodTuple:return l.items.length===0?"":`[${l.items.map(q=>B(q,i)).join(", ")}]`;case u.ZodFirstPartyTypeKind.ZodRecord:let O=B(l.keyType,i),I=B(l.valueType,i);return`${z(o.description)} { [key: ${O}]: ${I} }`;case u.ZodFirstPartyTypeKind.ZodMap:return`Map<${B(l.keyType,i)}, ${B(l.valueType,i)}>`;case u.ZodFirstPartyTypeKind.ZodSet:return`Set<${B(l.valueType,i)}>`;case u.ZodFirstPartyTypeKind.ZodFunction:let U=B(new Fs(l.args),i),L=B(new Ws(l.returns),i);return`${z(o.description)}
|
|
9
|
+
(${U}) => ${L}`;case u.ZodFirstPartyTypeKind.ZodLazy:return B(l.getter(),i);case u.ZodFirstPartyTypeKind.ZodLiteral:let ee=Oi(l.value);return`${z(o.description)}
|
|
10
|
+
${ee}`.trim();case u.ZodFirstPartyTypeKind.ZodEnum:return l.values.map(T).join(" | ");case u.ZodFirstPartyTypeKind.ZodEffects:return B(l.schema,i);case u.ZodFirstPartyTypeKind.ZodNativeEnum:throw new Wi(u.ZodFirstPartyTypeKind.ZodNativeEnum);case u.ZodFirstPartyTypeKind.ZodOptional:return`${B(l.innerType,i)} | undefined`;case u.ZodFirstPartyTypeKind.ZodNullable:return`${B(l.innerType,i)} | null`;case u.ZodFirstPartyTypeKind.ZodDefault:return B(l.innerType,i);case u.ZodFirstPartyTypeKind.ZodCatch:return B(l.innerType,i);case u.ZodFirstPartyTypeKind.ZodPromise:return`Promise<${B(l.type,i)}>`;case u.ZodFirstPartyTypeKind.ZodBranded:return B(l.type,i);case u.ZodFirstPartyTypeKind.ZodPipeline:return B(l.in,i);case u.ZodFirstPartyTypeKind.ZodSymbol:return`${z(o.description)} symbol`.trim();case u.ZodFirstPartyTypeKind.ZodReadonly:return`Readonly<${B(l.innerType,i)}>`;case u.ZodFirstPartyTypeKind.ZodRef:return Ii(l.uri);default:Z.assertNever(l)}}a(B,"sUnwrapZod");var Pu=a((t,e)=>{if(t.props.type==="none")return B(t.props.schema,e);let r=z(t.props.schema.description),n=t.props.schema.describe(""),s=B(n,e);if(t.props.type==="variable")return zs(`${r}declare const ${t.props.identifier}: ${s};`);let i=t.props.args.length>0?`<${t.props.args.map(Ii).join(", ")}>`:"";return zs(`${r}type ${t.props.identifier}${i} = ${s};`)},"unwrapDeclaration"),xu=a(t=>t.declaration?t.declaration===!0?"variable":t.declaration:"none","getDeclarationType"),ku=a((t,e)=>{let r=xu(e),n=t.getReferences();if(r==="none"){if(n.length>0)throw new Hn;return new Jt({type:"none",schema:t})}let s="title"in t.ui?t.ui.title:null;if(!s)throw new qi;if(r==="variable"){if(n.length>0)throw new Hn;return new Jt({type:"variable",identifier:s,schema:t})}return new Jt({type:"type",identifier:s,schema:t,args:n})},"getDeclarationProps"),Su=typeof global=="object"&&global&&global.Object===Object&&global,ea=Su,Eu=typeof self=="object"&&self&&self.Object===Object&&self,Ou=ea||Eu||Function("return this")(),ve=Ou,Zu=ve.Symbol,Pe=Zu,ta=Object.prototype,Iu=ta.hasOwnProperty,Bu=ta.toString,vt=Pe?Pe.toStringTag:void 0;function ra(t){var e=Iu.call(t,vt),r=t[vt];try{t[vt]=void 0;var n=!0}catch{}var s=Bu.call(t);return n&&(e?t[vt]=r:delete t[vt]),s}a(ra,"getRawTag");var Au=ra,Ru=Object.prototype,Cu=Ru.toString;function na(t){return Cu.call(t)}a(na,"objectToString");var Hu=na,Du="[object Null]",Nu="[object Undefined]",Ls=Pe?Pe.toStringTag:void 0;function sa(t){return t==null?t===void 0?Nu:Du:Ls&&Ls in Object(t)?Au(t):Hu(t)}a(sa,"baseGetTag");var $e=sa;function ia(t){return t!=null&&typeof t=="object"}a(ia,"isObjectLike");var De=ia,Mu="[object Symbol]";function aa(t){return typeof t=="symbol"||De(t)&&$e(t)==Mu}a(aa,"isSymbol");var Vn=aa;function oa(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(oa,"arrayMap");var la=oa,ju=Array.isArray,ye=ju,$u=1/0,qs=Pe?Pe.prototype:void 0,Vs=qs?qs.toString:void 0;function Gn(t){if(typeof t=="string")return t;if(ye(t))return la(t,Gn)+"";if(Vn(t))return Vs?Vs.call(t):"";var e=t+"";return e=="0"&&1/t==-$u?"-0":e}a(Gn,"baseToString");var Ku=Gn;function ca(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}a(ca,"isObject");var st=ca;function da(t){return t}a(da,"identity");var Uu=da,zu="[object AsyncFunction]",Fu="[object Function]",Wu="[object GeneratorFunction]",Lu="[object Proxy]";function ua(t){if(!st(t))return!1;var e=$e(t);return e==Fu||e==Wu||e==zu||e==Lu}a(ua,"isFunction");var pa=ua,qu=ve["__core-js_shared__"],En=qu,Gs=(function(){var t=/[^.]+$/.exec(En&&En.keys&&En.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function fa(t){return!!Gs&&Gs in t}a(fa,"isMasked");var Vu=fa,Gu=Function.prototype,Ju=Gu.toString;function ga(t){if(t!=null){try{return Ju.call(t)}catch{}try{return t+""}catch{}}return""}a(ga,"toSource");var Ke=ga,Yu=/[\\^$.*+?()[\]{}|]/g,Xu=/^\[object .+?Constructor\]$/,Qu=Function.prototype,ep=Object.prototype,tp=Qu.toString,rp=ep.hasOwnProperty,np=RegExp("^"+tp.call(rp).replace(Yu,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ha(t){if(!st(t)||Vu(t))return!1;var e=pa(t)?np:Xu;return e.test(Ke(t))}a(ha,"baseIsNative");var sp=ha;function ma(t,e){return t?.[e]}a(ma,"getValue");var ip=ma;function ya(t,e){var r=ip(t,e);return sp(r)?r:void 0}a(ya,"getNative");var Ue=ya,ap=Ue(ve,"WeakMap"),Dn=ap,op=(function(){try{var t=Ue(Object,"defineProperty");return t({},"",{}),t}catch{}})(),Js=op,lp=9007199254740991,cp=/^(?:0|[1-9]\d*)$/;function va(t,e){var r=typeof t;return e=e??lp,!!e&&(r=="number"||r!="symbol"&&cp.test(t))&&t>-1&&t%1==0&&t<e}a(va,"isIndex");var Jn=va;function _a(t,e,r){e=="__proto__"&&Js?Js(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}a(_a,"baseAssignValue");var Ta=_a;function ba(t,e){return t===e||t!==t&&e!==e}a(ba,"eq");var Yn=ba,dp=Object.prototype,up=dp.hasOwnProperty;function wa(t,e,r){var n=t[e];(!(up.call(t,e)&&Yn(n,r))||r===void 0&&!(e in t))&&Ta(t,e,r)}a(wa,"assignValue");var pp=wa,fp=9007199254740991;function Pa(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=fp}a(Pa,"isLength");var Xn=Pa;function xa(t){return t!=null&&Xn(t.length)&&!pa(t)}a(xa,"isArrayLike");var ka=xa,gp=Object.prototype;function Sa(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||gp;return t===r}a(Sa,"isPrototype");var Ea=Sa;function Oa(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}a(Oa,"baseTimes");var hp=Oa,mp="[object Arguments]";function Za(t){return De(t)&&$e(t)==mp}a(Za,"baseIsArguments");var Ys=Za,Ia=Object.prototype,yp=Ia.hasOwnProperty,vp=Ia.propertyIsEnumerable,_p=Ys((function(){return arguments})())?Ys:function(t){return De(t)&&yp.call(t,"callee")&&!vp.call(t,"callee")},Ba=_p;function Aa(){return!1}a(Aa,"stubFalse");var Tp=Aa,Ra=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Xs=Ra&&typeof module=="object"&&module&&!module.nodeType&&module,bp=Xs&&Xs.exports===Ra,Qs=bp?ve.Buffer:void 0,wp=Qs?Qs.isBuffer:void 0,Pp=wp||Tp,Nn=Pp,xp="[object Arguments]",kp="[object Array]",Sp="[object Boolean]",Ep="[object Date]",Op="[object Error]",Zp="[object Function]",Ip="[object Map]",Bp="[object Number]",Ap="[object Object]",Rp="[object RegExp]",Cp="[object Set]",Hp="[object String]",Dp="[object WeakMap]",Np="[object ArrayBuffer]",Mp="[object DataView]",jp="[object Float32Array]",$p="[object Float64Array]",Kp="[object Int8Array]",Up="[object Int16Array]",zp="[object Int32Array]",Fp="[object Uint8Array]",Wp="[object Uint8ClampedArray]",Lp="[object Uint16Array]",qp="[object Uint32Array]",D={};D[jp]=D[$p]=D[Kp]=D[Up]=D[zp]=D[Fp]=D[Wp]=D[Lp]=D[qp]=!0;D[xp]=D[kp]=D[Np]=D[Sp]=D[Mp]=D[Ep]=D[Op]=D[Zp]=D[Ip]=D[Bp]=D[Ap]=D[Rp]=D[Cp]=D[Hp]=D[Dp]=!1;function Ca(t){return De(t)&&Xn(t.length)&&!!D[$e(t)]}a(Ca,"baseIsTypedArray");var Vp=Ca;function Ha(t){return function(e){return t(e)}}a(Ha,"baseUnary");var Gp=Ha,Da=typeof exports=="object"&&exports&&!exports.nodeType&&exports,At=Da&&typeof module=="object"&&module&&!module.nodeType&&module,Jp=At&&At.exports===Da,On=Jp&&ea.process,Yp=(function(){try{var t=At&&At.require&&At.require("util").types;return t||On&&On.binding&&On.binding("util")}catch{}})(),ei=Yp,ti=ei&&ei.isTypedArray,Xp=ti?Gp(ti):Vp,Na=Xp,Qp=Object.prototype,ef=Qp.hasOwnProperty;function Ma(t,e){var r=ye(t),n=!r&&Ba(t),s=!r&&!n&&Nn(t),i=!r&&!n&&!s&&Na(t),o=r||n||s||i,l=o?hp(t.length,String):[],d=l.length;for(var f in t)(e||ef.call(t,f))&&!(o&&(f=="length"||s&&(f=="offset"||f=="parent")||i&&(f=="buffer"||f=="byteLength"||f=="byteOffset")||Jn(f,d)))&&l.push(f);return l}a(Ma,"arrayLikeKeys");var ja=Ma;function $a(t,e){return function(r){return t(e(r))}}a($a,"overArg");var Ka=$a,tf=Ka(Object.keys,Object),rf=tf,nf=Object.prototype,sf=nf.hasOwnProperty;function Ua(t){if(!Ea(t))return rf(t);var e=[];for(var r in Object(t))sf.call(t,r)&&r!="constructor"&&e.push(r);return e}a(Ua,"baseKeys");var af=Ua;function za(t){return ka(t)?ja(t):af(t)}a(za,"keys");var Qn=za;function Fa(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}a(Fa,"nativeKeysIn");var of=Fa,lf=Object.prototype,cf=lf.hasOwnProperty;function Wa(t){if(!st(t))return of(t);var e=Ea(t),r=[];for(var n in t)n=="constructor"&&(e||!cf.call(t,n))||r.push(n);return r}a(Wa,"baseKeysIn");var df=Wa;function La(t){return ka(t)?ja(t,!0):df(t)}a(La,"keysIn");var uf=La,pf=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ff=/^\w*$/;function qa(t,e){if(ye(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||Vn(t)?!0:ff.test(t)||!pf.test(t)||e!=null&&t in Object(e)}a(qa,"isKey");var es=qa,gf=Ue(Object,"create"),Ct=gf;function Va(){this.__data__=Ct?Ct(null):{},this.size=0}a(Va,"hashClear");var hf=Va;function Ga(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}a(Ga,"hashDelete");var mf=Ga,yf="__lodash_hash_undefined__",vf=Object.prototype,_f=vf.hasOwnProperty;function Ja(t){var e=this.__data__;if(Ct){var r=e[t];return r===yf?void 0:r}return _f.call(e,t)?e[t]:void 0}a(Ja,"hashGet");var Tf=Ja,bf=Object.prototype,wf=bf.hasOwnProperty;function Ya(t){var e=this.__data__;return Ct?e[t]!==void 0:wf.call(e,t)}a(Ya,"hashHas");var Pf=Ya,xf="__lodash_hash_undefined__";function Xa(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Ct&&e===void 0?xf:e,this}a(Xa,"hashSet");var kf=Xa;function ze(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}a(ze,"Hash");ze.prototype.clear=hf;ze.prototype.delete=mf;ze.prototype.get=Tf;ze.prototype.has=Pf;ze.prototype.set=kf;var ri=ze;function Qa(){this.__data__=[],this.size=0}a(Qa,"listCacheClear");var Sf=Qa;function eo(t,e){for(var r=t.length;r--;)if(Yn(t[r][0],e))return r;return-1}a(eo,"assocIndexOf");var Wr=eo,Ef=Array.prototype,Of=Ef.splice;function to(t){var e=this.__data__,r=Wr(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():Of.call(e,r,1),--this.size,!0}a(to,"listCacheDelete");var Zf=to;function ro(t){var e=this.__data__,r=Wr(e,t);return r<0?void 0:e[r][1]}a(ro,"listCacheGet");var If=ro;function no(t){return Wr(this.__data__,t)>-1}a(no,"listCacheHas");var Bf=no;function so(t,e){var r=this.__data__,n=Wr(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this}a(so,"listCacheSet");var Af=so;function Fe(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}a(Fe,"ListCache");Fe.prototype.clear=Sf;Fe.prototype.delete=Zf;Fe.prototype.get=If;Fe.prototype.has=Bf;Fe.prototype.set=Af;var Lr=Fe,Rf=Ue(ve,"Map"),Ht=Rf;function io(){this.size=0,this.__data__={hash:new ri,map:new(Ht||Lr),string:new ri}}a(io,"mapCacheClear");var Cf=io;function ao(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}a(ao,"isKeyable");var Hf=ao;function oo(t,e){var r=t.__data__;return Hf(e)?r[typeof e=="string"?"string":"hash"]:r.map}a(oo,"getMapData");var qr=oo;function lo(t){var e=qr(this,t).delete(t);return this.size-=e?1:0,e}a(lo,"mapCacheDelete");var Df=lo;function co(t){return qr(this,t).get(t)}a(co,"mapCacheGet");var Nf=co;function uo(t){return qr(this,t).has(t)}a(uo,"mapCacheHas");var Mf=uo;function po(t,e){var r=qr(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this}a(po,"mapCacheSet");var jf=po;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,"MapCache");We.prototype.clear=Cf;We.prototype.delete=Df;We.prototype.get=Nf;We.prototype.has=Mf;We.prototype.set=jf;var Vr=We,$f="Expected a function";function Gr(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError($f);var r=a(function(){var n=arguments,s=e?e.apply(this,n):n[0],i=r.cache;if(i.has(s))return i.get(s);var o=t.apply(this,n);return r.cache=i.set(s,o)||i,o},"memoized");return r.cache=new(Gr.Cache||Vr),r}a(Gr,"memoize");Gr.Cache=Vr;var Kf=Gr,Uf=500;function fo(t){var e=Kf(t,function(n){return r.size===Uf&&r.clear(),n}),r=e.cache;return e}a(fo,"memoizeCapped");var zf=fo,Ff=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Wf=/\\(\\)?/g,Lf=zf(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(Ff,function(r,n,s,i){e.push(s?i.replace(Wf,"$1"):n||r)}),e}),qf=Lf;function go(t){return t==null?"":Ku(t)}a(go,"toString");var Vf=go;function ho(t,e){return ye(t)?t:es(t,e)?[t]:qf(Vf(t))}a(ho,"castPath");var Jr=ho,Gf=1/0;function mo(t){if(typeof t=="string"||Vn(t))return t;var e=t+"";return e=="0"&&1/t==-Gf?"-0":e}a(mo,"toKey");var $t=mo;function yo(t,e){e=Jr(e,t);for(var r=0,n=e.length;t!=null&&r<n;)t=t[$t(e[r++])];return r&&r==n?t:void 0}a(yo,"baseGet");var ts=yo;function vo(t,e,r){var n=t==null?void 0:ts(t,e);return n===void 0?r:n}a(vo,"get");var Jf=vo;function _o(t,e){for(var r=-1,n=e.length,s=t.length;++r<n;)t[s+r]=e[r];return t}a(_o,"arrayPush");var To=_o,Yf=Ka(Object.getPrototypeOf,Object),bo=Yf,Xf="[object Object]",Qf=Function.prototype,eg=Object.prototype,wo=Qf.toString,tg=eg.hasOwnProperty,rg=wo.call(Object);function Po(t){if(!De(t)||$e(t)!=Xf)return!1;var e=bo(t);if(e===null)return!0;var r=tg.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&wo.call(r)==rg}a(Po,"isPlainObject");var ni=Po;function xo(){this.__data__=new Lr,this.size=0}a(xo,"stackClear");var ng=xo;function ko(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}a(ko,"stackDelete");var sg=ko;function So(t){return this.__data__.get(t)}a(So,"stackGet");var ig=So;function Eo(t){return this.__data__.has(t)}a(Eo,"stackHas");var ag=Eo,og=200;function Oo(t,e){var r=this.__data__;if(r instanceof Lr){var n=r.__data__;if(!Ht||n.length<og-1)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Vr(n)}return r.set(t,e),this.size=r.size,this}a(Oo,"stackSet");var lg=Oo;function Le(t){var e=this.__data__=new Lr(t);this.size=e.size}a(Le,"Stack");Le.prototype.clear=ng;Le.prototype.delete=sg;Le.prototype.get=ig;Le.prototype.has=ag;Le.prototype.set=lg;var Yt=Le;function Zo(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(Zo,"arrayFilter");var cg=Zo;function Io(){return[]}a(Io,"stubArray");var Bo=Io,dg=Object.prototype,ug=dg.propertyIsEnumerable,si=Object.getOwnPropertySymbols,pg=si?function(t){return t==null?[]:(t=Object(t),cg(si(t),function(e){return ug.call(t,e)}))}:Bo,Ao=pg,fg=Object.getOwnPropertySymbols,gg=fg?function(t){for(var e=[];t;)To(e,Ao(t)),t=bo(t);return e}:Bo,hg=gg;function Ro(t,e,r){var n=e(t);return ye(t)?n:To(n,r(t))}a(Ro,"baseGetAllKeys");var Co=Ro;function Ho(t){return Co(t,Qn,Ao)}a(Ho,"getAllKeys");var ii=Ho;function Do(t){return Co(t,uf,hg)}a(Do,"getAllKeysIn");var mg=Do,yg=Ue(ve,"DataView"),Mn=yg,vg=Ue(ve,"Promise"),jn=vg,_g=Ue(ve,"Set"),$n=_g,ai="[object Map]",Tg="[object Object]",oi="[object Promise]",li="[object Set]",ci="[object WeakMap]",di="[object DataView]",bg=Ke(Mn),wg=Ke(Ht),Pg=Ke(jn),xg=Ke($n),kg=Ke(Dn),Ie=$e;(Mn&&Ie(new Mn(new ArrayBuffer(1)))!=di||Ht&&Ie(new Ht)!=ai||jn&&Ie(jn.resolve())!=oi||$n&&Ie(new $n)!=li||Dn&&Ie(new Dn)!=ci)&&(Ie=a(function(t){var e=$e(t),r=e==Tg?t.constructor:void 0,n=r?Ke(r):"";if(n)switch(n){case bg:return di;case wg:return ai;case Pg:return oi;case xg:return li;case kg:return ci}return e},"getTag"));var ui=Ie,Sg=ve.Uint8Array,pi=Sg,Eg="__lodash_hash_undefined__";function No(t){return this.__data__.set(t,Eg),this}a(No,"setCacheAdd");var Og=No;function Mo(t){return this.__data__.has(t)}a(Mo,"setCacheHas");var Zg=Mo;function Dt(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new Vr;++e<r;)this.add(t[e])}a(Dt,"SetCache");Dt.prototype.add=Dt.prototype.push=Og;Dt.prototype.has=Zg;var Ig=Dt;function jo(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(jo,"arraySome");var Bg=jo;function $o(t,e){return t.has(e)}a($o,"cacheHas");var Ag=$o,Rg=1,Cg=2;function Ko(t,e,r,n,s,i){var o=r&Rg,l=t.length,d=e.length;if(l!=d&&!(o&&d>l))return!1;var f=i.get(t),g=i.get(e);if(f&&g)return f==e&&g==t;var m=-1,P=!0,O=r&Cg?new Ig:void 0;for(i.set(t,e),i.set(e,t);++m<l;){var I=t[m],U=e[m];if(n)var L=o?n(U,I,m,e,t,i):n(I,U,m,t,e,i);if(L!==void 0){if(L)continue;P=!1;break}if(O){if(!Bg(e,function(ee,ae){if(!Ag(O,ae)&&(I===ee||s(I,ee,r,n,i)))return O.push(ae)})){P=!1;break}}else if(!(I===U||s(I,U,r,n,i))){P=!1;break}}return i.delete(t),i.delete(e),P}a(Ko,"equalArrays");var Uo=Ko;function zo(t){var e=-1,r=Array(t.size);return t.forEach(function(n,s){r[++e]=[s,n]}),r}a(zo,"mapToArray");var Hg=zo;function Fo(t){var e=-1,r=Array(t.size);return t.forEach(function(n){r[++e]=n}),r}a(Fo,"setToArray");var Dg=Fo,Ng=1,Mg=2,jg="[object Boolean]",$g="[object Date]",Kg="[object Error]",Ug="[object Map]",zg="[object Number]",Fg="[object RegExp]",Wg="[object Set]",Lg="[object String]",qg="[object Symbol]",Vg="[object ArrayBuffer]",Gg="[object DataView]",fi=Pe?Pe.prototype:void 0,Zn=fi?fi.valueOf:void 0;function Wo(t,e,r,n,s,i,o){switch(r){case Gg:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case Vg:return!(t.byteLength!=e.byteLength||!i(new pi(t),new pi(e)));case jg:case $g:case zg:return Yn(+t,+e);case Kg:return t.name==e.name&&t.message==e.message;case Fg:case Lg:return t==e+"";case Ug:var l=Hg;case Wg:var d=n&Ng;if(l||(l=Dg),t.size!=e.size&&!d)return!1;var f=o.get(t);if(f)return f==e;n|=Mg,o.set(t,e);var g=Uo(l(t),l(e),n,s,i,o);return o.delete(t),g;case qg:if(Zn)return Zn.call(t)==Zn.call(e)}return!1}a(Wo,"equalByTag");var Jg=Wo,Yg=1,Xg=Object.prototype,Qg=Xg.hasOwnProperty;function Lo(t,e,r,n,s,i){var o=r&Yg,l=ii(t),d=l.length,f=ii(e),g=f.length;if(d!=g&&!o)return!1;for(var m=d;m--;){var P=l[m];if(!(o?P in e:Qg.call(e,P)))return!1}var O=i.get(t),I=i.get(e);if(O&&I)return O==e&&I==t;var U=!0;i.set(t,e),i.set(e,t);for(var L=o;++m<d;){P=l[m];var ee=t[P],ae=e[P];if(n)var q=o?n(ae,ee,P,e,t,i):n(ee,ae,P,t,e,i);if(!(q===void 0?ee===ae||s(ee,ae,r,n,i):q)){U=!1;break}L||(L=P=="constructor")}if(U&&!L){var ie=t.constructor,Je=e.constructor;ie!=Je&&"constructor"in t&&"constructor"in e&&!(typeof ie=="function"&&ie instanceof ie&&typeof Je=="function"&&Je instanceof Je)&&(U=!1)}return i.delete(t),i.delete(e),U}a(Lo,"equalObjects");var eh=Lo,th=1,gi="[object Arguments]",hi="[object Array]",Gt="[object Object]",rh=Object.prototype,mi=rh.hasOwnProperty;function qo(t,e,r,n,s,i){var o=ye(t),l=ye(e),d=o?hi:ui(t),f=l?hi:ui(e);d=d==gi?Gt:d,f=f==gi?Gt:f;var g=d==Gt,m=f==Gt,P=d==f;if(P&&Nn(t)){if(!Nn(e))return!1;o=!0,g=!1}if(P&&!g)return i||(i=new Yt),o||Na(t)?Uo(t,e,r,n,s,i):Jg(t,e,d,r,n,s,i);if(!(r&th)){var O=g&&mi.call(t,"__wrapped__"),I=m&&mi.call(e,"__wrapped__");if(O||I){var U=O?t.value():t,L=I?e.value():e;return i||(i=new Yt),s(U,L,r,n,i)}}return P?(i||(i=new Yt),eh(t,e,r,n,s,i)):!1}a(qo,"baseIsEqualDeep");var nh=qo;function rs(t,e,r,n,s){return t===e?!0:t==null||e==null||!De(t)&&!De(e)?t!==t&&e!==e:nh(t,e,r,n,rs,s)}a(rs,"baseIsEqual");var Yr=rs,sh=1,ih=2;function Vo(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],f=t[d],g=l[1];if(o&&l[2]){if(f===void 0&&!(d in t))return!1}else{var m=new Yt;if(n)var P=n(f,g,d,t,e,m);if(!(P===void 0?Yr(g,f,sh|ih,n,m):P))return!1}}return!0}a(Vo,"baseIsMatch");var ah=Vo;function Go(t){return t===t&&!st(t)}a(Go,"isStrictComparable");var Jo=Go;function Yo(t){for(var e=Qn(t),r=e.length;r--;){var n=e[r],s=t[n];e[r]=[n,s,Jo(s)]}return e}a(Yo,"getMatchData");var oh=Yo;function Xo(t,e){return function(r){return r==null?!1:r[t]===e&&(e!==void 0||t in Object(r))}}a(Xo,"matchesStrictComparable");var Qo=Xo;function el(t){var e=oh(t);return e.length==1&&e[0][2]?Qo(e[0][0],e[0][1]):function(r){return r===t||ah(r,t,e)}}a(el,"baseMatches");var lh=el;function tl(t,e){return t!=null&&e in Object(t)}a(tl,"baseHasIn");var ch=tl;function rl(t,e,r){e=Jr(e,t);for(var n=-1,s=e.length,i=!1;++n<s;){var o=$t(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&&Xn(s)&&Jn(o,s)&&(ye(t)||Ba(t)))}a(rl,"hasPath");var dh=rl;function nl(t,e){return t!=null&&dh(t,e,ch)}a(nl,"hasIn");var uh=nl,ph=1,fh=2;function sl(t,e){return es(t)&&Jo(e)?Qo($t(t),e):function(r){var n=Jf(r,t);return n===void 0&&n===e?uh(r,t):Yr(e,n,ph|fh)}}a(sl,"baseMatchesProperty");var gh=sl;function il(t){return function(e){return e?.[t]}}a(il,"baseProperty");var hh=il;function al(t){return function(e){return ts(e,t)}}a(al,"basePropertyDeep");var mh=al;function ol(t){return es(t)?hh($t(t)):mh(t)}a(ol,"property");var yh=ol;function ll(t){return typeof t=="function"?t:t==null?Uu:typeof t=="object"?ye(t)?gh(t[0],t[1]):lh(t):yh(t)}a(ll,"baseIteratee");var ns=ll;function cl(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(cl,"createBaseFor");var vh=cl,_h=vh(),Th=_h;function dl(t,e){return t&&Th(t,e,Qn)}a(dl,"baseForOwn");var bh=dl;function ul(t,e){return Yr(t,e)}a(ul,"isEqual");var rt=ul;function pl(t,e,r){r=typeof r=="function"?r:void 0;var n=r?r(t,e):void 0;return n===void 0?Yr(t,e,void 0,r):!!n}a(pl,"isEqualWith");var wh=pl;function fl(t){return t===void 0}a(fl,"isUndefined");var yi=fl;function gl(t,e){var r={};return e=ns(e,3),bh(t,function(n,s,i){Ta(r,s,e(n,s,i))}),r}a(gl,"mapValues");var Ph=gl,xh="Expected a function";function hl(t){if(typeof t!="function")throw new TypeError(xh);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(hl,"negate");var kh=hl;function ml(t,e,r,n){if(!st(t))return t;e=Jr(e,t);for(var s=-1,i=e.length,o=i-1,l=t;l!=null&&++s<i;){var d=$t(e[s]),f=r;if(d==="__proto__"||d==="constructor"||d==="prototype")return t;if(s!=o){var g=l[d];f=n?n(g,d,l):void 0,f===void 0&&(f=st(g)?g:Jn(e[s+1])?[]:{})}pp(l,d,f),l=l[d]}return t}a(ml,"baseSet");var Sh=ml;function yl(t,e,r){for(var n=-1,s=e.length,i={};++n<s;){var o=e[n],l=ts(t,o);r(l,o)&&Sh(i,Jr(o,t),l)}return i}a(yl,"basePickBy");var Eh=yl;function vl(t,e){if(t==null)return{};var r=la(mg(t),function(n){return[n]});return e=ns(e),Eh(t,r,function(n,s){return e(n,s[0])})}a(vl,"pickBy");var Oh=vl;function _l(t,e){return Oh(t,kh(ns(e)))}a(_l,"omitBy");var vi=_l,Zh=a(t=>{let e=t.checks;return e.length===0?"":e.map(Ih).join("")},"generateStringChecks"),Ih=a(t=>{switch(t.kind){case"min":return`.min(${T(t.value)}, ${T(t.message)})`;case"max":return`.max(${T(t.value)}, ${T(t.message)})`;case"length":return`.length(${T(t.value)}, ${T(t.message)})`;case"email":return`.email(${T(t.message)})`;case"url":return`.url(${T(t.message)})`;case"emoji":return`.emoji(${T(t.message)})`;case"uuid":return`.uuid(${T(t.message)})`;case"cuid":return`.cuid(${T(t.message)})`;case"cuid2":return`.cuid2(${T(t.message)})`;case"ulid":return`.ulid(${T(t.message)})`;case"includes":let e=tt({message:t.message,position:t.position});return`.includes(${T(t.value)}, ${e})`;case"startsWith":return`.startsWith(${T(t.value)}, ${T(t.message)})`;case"endsWith":return`.endsWith(${T(t.value)}, ${T(t.message)})`;case"regex":return`.regex(${String(t.regex)}, ${T(t.message)})`;case"trim":return".trim()";case"toLowerCase":return".toLowerCase()";case"toUpperCase":return".toUpperCase()";case"datetime":let n=t.precision===null?void 0:t.precision;return`.datetime(${tt({message:t.message,precision:n,offset:t.offset})})`;case"ip":return`.ip(${tt({message:t.message,version:t.version})})`;default:return""}},"_generateStringCheck"),Bh=a(t=>{let e=t.checks;return e.length===0?"":e.map(Ah).join("")},"generateNumberChecks"),Ah=a(t=>{switch(t.kind){case"min":return`.min(${T(t.value)}, ${T(t.message)})`;case"max":return`.max(${T(t.value)}, ${T(t.message)})`;case"int":return`.int(${T(t.message)})`;case"multipleOf":return`.multipleOf(${T(t.value)}, ${T(t.message)})`;case"finite":return`.finite(${T(t.message)})`;default:return""}},"_generateNumberCheck"),Rh=a(t=>{let e=t.checks;return e.length===0?"":e.map(Ch).join("")},"generateBigIntChecks"),Ch=a(t=>{switch(t.kind){case"min":return`.min(${T(t.value)}, ${T(t.message)})`;case"max":return`.max(${T(t.value)}, ${T(t.message)})`;case"multipleOf":return`.multipleOf(${T(t.value)}, ${T(t.message)})`;default:return""}},"_generateBigIntCheck"),Hh=a(t=>{let e=t.checks;return e.length===0?"":e.map(Dh).join("")},"generateDateChecks"),Dh=a(t=>{switch(t.kind){case"min":return`.min(${_i(t.value)}, ${T(t.message)})`;case"max":return`.max(${_i(t.value)}, ${T(t.message)})`;default:return""}},"_generateDateCheck"),_i=a(t=>`new Date(${t})`,"dateTs"),Nh=a(t=>{let e=[];if(t.exactLength){let{value:r,message:n}=t.exactLength;e.push(`.length(${T(r)}, ${T(n)})`)}if(t.minLength){let{value:r,message:n}=t.minLength;e.push(`.min(${T(r)}, ${T(n)})`)}if(t.maxLength){let{value:r,message:n}=t.maxLength;e.push(`.max(${T(r)}, ${T(n)})`)}return e.join("")},"generateArrayChecks"),Mh=a(t=>{let e=[];if(t.minSize){let{value:r,message:n}=t.minSize;e.push(`.min(${T(r)}, ${T(n)})`)}if(t.maxSize){let{value:r,message:n}=t.maxSize;e.push(`.max(${T(r)}, ${T(n)})`)}return e.join("")},"generateSetChecks");function ss(t){return M(t)}a(ss,"toTypescriptSchema");function M(t){let r=t._def;switch(r.typeName){case u.ZodFirstPartyTypeKind.ZodString:return`z.string()${Zh(r)}${C(r)}${R(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNumber:return`z.number()${Bh(r)}${C(r)}${R(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNaN:return`z.nan()${C(r)}${R(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodBigInt:return`z.bigint()${Rh(r)}${C(r)}${R(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodBoolean:return`z.boolean()${C(r)}${R(t._def)}`.trim();case u.ZodFirstPartyTypeKind.ZodDate:return`z.date()${Hh(r)}${C(r)}${R(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodUndefined:return`z.undefined()${C(r)}${R(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNull:return`z.null()${C(r)}${R(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodAny:return`z.any()${C(r)}${R(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodUnknown:return`z.unknown()${C(r)}${R(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNever:return`z.never()${C(r)}${R(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodVoid:return`z.void()${C(r)}${R(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodArray:return`z.array(${M(r.type)})${Nh(r)}${C(r)}${R(r)}`;case u.ZodFirstPartyTypeKind.ZodObject:let n=Ph(r.shape(),M),s=t.additionalProperties(),i=s?`.catchall(${M(s)})`:"";return["z.object({",...Object.entries(n).map(([du,uu])=>` ${du}: ${uu},`),`})${i}${C(r)}${R(r)}`].join(`
|
|
11
|
+
`).trim();case u.ZodFirstPartyTypeKind.ZodUnion:return`z.union([${r.options.map(M).join(", ")}])${C(r)}${R(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:let l=r.options.map(M);return`z.discriminatedUnion(${T(r.discriminator)}, [${l.join(", ")}])${C(r)}${R(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodIntersection:let f=M(r.left),g=M(r.right);return`z.intersection(${f}, ${g})${C(r)}${R(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodTuple:return`z.tuple([${r.items.map(M).join(", ")}])${C(r)}${R(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodRecord:let P=M(r.keyType),O=M(r.valueType);return`z.record(${P}, ${O})${C(r)}${R(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodMap:let I=M(r.keyType),U=M(r.valueType);return`z.map(${I}, ${U})${C(r)}${R(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodSet:return`z.set(${M(r.valueType)})${Mh(r)}${C(r)}${R(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodFunction:let L=r.args.items.map(M),ee=L.length?`.args(${L.join(", ")})`:"",ae=M(r.returns);return`z.function()${ee}.returns(${ae})${C(r)}${R(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodLazy:return`z.lazy(() => ${M(r.getter())})${C(r)}${R(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodLiteral:return`z.literal(${T(r.value)})${C(r)}${R(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodEnum:return`z.enum([${r.values.map(T).join(", ")}])${C(r)}${R(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodEffects:throw new Ze(u.ZodFirstPartyTypeKind.ZodEffects);case u.ZodFirstPartyTypeKind.ZodNativeEnum:throw new Ze(u.ZodFirstPartyTypeKind.ZodNativeEnum);case u.ZodFirstPartyTypeKind.ZodOptional:return`z.optional(${M(r.innerType)})${C(r)}${R(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNullable:return`z.nullable(${M(r.innerType)})${C(r)}${R(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodDefault:let Je=tt(r.defaultValue());return`z.default(${M(r.innerType)}, ${Je})${C(r)}${R(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodCatch:throw new Ze(u.ZodFirstPartyTypeKind.ZodCatch);case u.ZodFirstPartyTypeKind.ZodPromise:return`z.promise(${M(r.type)})${C(r)}${R(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodBranded:throw new Ze(u.ZodFirstPartyTypeKind.ZodBranded);case u.ZodFirstPartyTypeKind.ZodPipeline:throw new Ze(u.ZodFirstPartyTypeKind.ZodPipeline);case u.ZodFirstPartyTypeKind.ZodSymbol:throw new Ze(u.ZodFirstPartyTypeKind.ZodSymbol);case u.ZodFirstPartyTypeKind.ZodReadonly:return`z.readonly(${M(r.innerType)})${C(r)}${R(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodRef:return`z.ref(${T(r.uri)})${C(r)}${R(r)}`.trim();default:Z.assertNever(r)}}a(M,"sUnwrapZod");var R=a(t=>t.description?`.describe(${T(t.description)})`:"","_maybeDescribe"),C=a(t=>`${jh(t)}${$h(t)}${Kh(t)}${Uh(t)}${zh(t)}${Fh(t)}${Wh(t)}`,"_addZuiExtensions"),jh=a(t=>{var e;return(e=t[b])!=null&&e.title?`.title(${T(t[b].title)})`:""},"_maybeTitle"),$h=a(t=>{var e;return(e=t[b])!=null&&e.displayAs?`.displayAs(${Zi({id:t[b].displayAs[0],params:t[b].displayAs[1]})})`:""},"_maybeDisplayAs"),Kh=a(t=>{var e;return(e=t[b])!=null&&e.disabled?`.disabled(${t[b].disabled})`:""},"_maybeDisabled"),Uh=a(t=>{var e;return(e=t[b])!=null&&e.hidden?`.hidden(${t[b].hidden})`:""},"_maybeHidden"),zh=a(t=>{var e;return(e=t[b])!=null&&e.placeholder?`.placeholder(${T(t[b].placeholder)})`:""},"_maybePlaceholder"),Fh=a(t=>{var e;return(e=t[b])!=null&&e.secret?".secret()":""},"_maybeSecret"),Wh=a(t=>{var e;let r=["title","tooltip","displayAs","disabled","hidden","placeholder","secret","coerce"],n=Object.entries((e=t[b])!=null?e:{}).filter(([s])=>!r.includes(s));return n.length>0?`.metadata(${Zi(Object.fromEntries(n))})`:""},"_maybeSetMetadata"),Lh=a(t=>{let e={type:"number",description:t.description,"x-zui":t._def["x-zui"]};t._def[b]&&(e[b]=t._def[b]);for(let r of t._def.checks)switch(r.kind){case"min":{let n=r.inclusive?"minimum":"exclusiveMinimum",s=r.inclusive?"exclusiveMinimum":"minimum";e[n]=r.value,delete e[s];break}case"max":{let n=r.inclusive?"maximum":"exclusiveMaximum",s=r.inclusive?"exclusiveMaximum":"maximum";e[n]=r.value,delete e[s];break}case"int":e.type="integer";break;case"finite":{e.format="finite";break}case"multipleOf":e.multipleOf=r.value;break;default:}return e},"zodNumberToJsonNumber"),Tl="\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}",bl="(([+-]\\d{2}(:?\\d{2})?)|Z)",qh="Z",wl="(\\.\\d+)?",Kn="\\.\\d{",Vh="}",Pl=a(t=>{let e=t.precision?Kn+t.precision+Vh:t.precision===0?"":wl,r=t.offset?bl:qh;return new RegExp(`^${Tl}${e}${r}$`)},"generateDatetimeRegex"),Gh=a(t=>({precision:Jh(t),offset:t.endsWith(`${bl}$`)}),"extractPrecisionAndOffset"),Jh=a(t=>{let e=t.slice(1+Tl.length);return e.startsWith(wl)?null:e.startsWith(Kn)?parseInt(e.slice(Kn.length)):0},"_extractPrecision"),Rt={};Kr(Rt,{escapeSpecialChars:()=>Yh});var Yh=a(t=>t.replaceAll(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeSpecialChars");function is(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage=p(c({},t.errorMessage),{[e]:r}))}a(is,"addErrorMessage");function H(t,e,r,n,s){t[e]=r,is(t,e,n,s)}a(H,"setResponseValueAndErrors");var $={cuid:"^[cC][^\\s-]{8,}$",cuid2:"^[a-z][a-z0-9]*$",ulid:"^[0-9A-HJKMNP-TV-Z]{26}$",email:"^(?!\\.)(?!.*\\.\\.)([a-zA-Z0-9_+-\\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\\-]*\\.)+[a-zA-Z]{2,}$",emoji:"^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",uuid:"^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$",ipv4:"^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$",ipv6:"^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$"};function as(t,e){let r=c({type:"string"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});function n(s){return e.patternStrategy==="escape"?Rt.escapeSpecialChars(s):s}if(a(n,"processPattern"),t.checks)for(let s of t.checks)switch(s.kind){case"min":H(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,s.value):s.value,s.message,e);break;case"max":H(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,s.value):s.value,s.message,e);break;case"email":switch(e.emailStrategy){case"format:email":Oe(r,"email",s.message,e);break;case"format:idn-email":Oe(r,"idn-email",s.message,e);break;case"pattern:zod":fe(r,$.email,s.message,e);break}break;case"url":Oe(r,"uri",s.message,e);break;case"uuid":Oe(r,"uuid",s.message,e);break;case"regex":fe(r,s.regex.source,s.message,e);break;case"cuid":fe(r,$.cuid,s.message,e);break;case"cuid2":fe(r,$.cuid2,s.message,e);break;case"startsWith":fe(r,"^"+n(s.value),s.message,e);break;case"endsWith":fe(r,n(s.value)+"$",s.message,e);break;case"datetime":Oe(r,"date-time",s.message,e);break;case"length":H(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,s.value):s.value,s.message,e),H(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,s.value):s.value,s.message,e);break;case"includes":{fe(r,n(s.value),s.message,e);break}case"ip":{s.version!=="v6"&&Oe(r,"ipv4",s.message,e),s.version!=="v4"&&Oe(r,"ipv6",s.message,e);break}case"emoji":fe(r,$.emoji,s.message,e);break;case"ulid":{fe(r,$.ulid,s.message,e);break}case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}a(as,"parseStringDef");var Oe=a((t,e,r,n)=>{var s;t.format||(s=t.anyOf)!=null&&s.some(i=>i.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push(c({format:t.format},t.errorMessage&&n.errorMessages&&{errorMessage:{format:t.errorMessage.format}})),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push(c({format:e},r&&n.errorMessages&&{errorMessage:{format:r}}))):H(t,"format",e,r,n)},"addFormat"),fe=a((t,e,r,n)=>{var s;t.pattern||(s=t.allOf)!=null&&s.some(i=>i.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push(c({pattern:t.pattern},t.errorMessage&&n.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}})),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push(c({pattern:e},r&&n.errorMessages&&{errorMessage:{pattern:r}}))):H(t,"pattern",e,r,n)},"addPattern"),Xh=a(t=>{let e={type:"string",description:t.description,"x-zui":t._def["x-zui"]};t._def[b]&&(e[b]=t._def[b]);for(let r of t._def.checks)switch(r.kind){case"cuid":e.format="cuid",e.pattern=$.cuid;break;case"cuid2":e.format="cuid2",e.pattern=$.cuid2;break;case"ulid":e.format="ulid",e.pattern=$.ulid;break;case"uuid":e.format="uuid",e.pattern=$.uuid;break;case"emoji":e.format="emoji",e.pattern=$.emoji;break;case"email":e.format="email",e.pattern=$.email;break;case"ip":e.format=r.version==="v6"?"ipv6":"ipv4",e.pattern=r.version==="v6"?$.ipv6:$.ipv4;break;case"datetime":e.format="date-time",e.pattern=Pl(r).source,e[b]=p(c({},e[b]),{precision:r.precision,offset:r.offset});break;case"url":e.format="uri";break;case"endsWith":e.pattern=`${Rt.escapeSpecialChars(r.value)}$`;break;case"startsWith":e.pattern=`^${Rt.escapeSpecialChars(r.value)}`;break;case"includes":let n=r.position&&r.position>=1?`^(?:.{${r.position}}).*`:"";e.pattern=`${n}${Rt.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 Mi({zodType:u.ZodFirstPartyTypeKind.ZodString,checkKind:r.kind})}return e},"zodStringToJsonString"),Qh=a((t,e)=>{let r={type:"array",description:t.description,items:e(t._def.type),"x-zui":t._def["x-zui"]};return t._def[b]&&(r[b]=t._def[b]),t._def.minLength&&(r.minItems=t._def.minLength.value),t._def.maxLength&&(r.maxItems=t._def.maxLength.value),t._def.exactLength&&(r.minItems=t._def.exactLength.value,r.maxItems=t._def.exactLength.value),r},"zodArrayToJsonArray"),em=a((t,e)=>{let r={type:"array",description:t.description,uniqueItems:!0,items:e(t._def.valueType),"x-zui":t._def["x-zui"]};return t._def[b]&&(r[b]=t._def[b]),t._def.minSize&&(r.minItems=t._def.minSize.value),t._def.maxSize&&(r.maxItems=t._def.maxSize.value),r},"zodSetToJsonSet"),tm=a((t,e)=>{let r={type:"array",description:t.description,items:t._def.items.map(n=>e(n))};return t._def[b]&&(r[b]=t._def[b]),t._def.rest&&(r.additionalItems=e(t._def.rest)),r},"zodTupleToJsonTuple");function V(t){let e=t,r=e._def;switch(r.typeName){case u.ZodFirstPartyTypeKind.ZodString:return Xh(e);case u.ZodFirstPartyTypeKind.ZodNumber:return Lh(e);case u.ZodFirstPartyTypeKind.ZodNaN:throw new te(u.ZodFirstPartyTypeKind.ZodNaN);case u.ZodFirstPartyTypeKind.ZodBigInt:throw new te(u.ZodFirstPartyTypeKind.ZodBigInt,{suggestedAlternative:"serialize bigint to string"});case u.ZodFirstPartyTypeKind.ZodBoolean:return{type:"boolean",description:r.description,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodDate:throw new te(u.ZodFirstPartyTypeKind.ZodDate,{suggestedAlternative:"use z.string().datetime() instead"});case u.ZodFirstPartyTypeKind.ZodUndefined:return In(r);case u.ZodFirstPartyTypeKind.ZodNull:return Bn(r);case u.ZodFirstPartyTypeKind.ZodAny:return{description:r.description,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodUnknown:return{description:r.description,"x-zui":p(c({},r["x-zui"]),{def:{typeName:u.ZodFirstPartyTypeKind.ZodUnknown}})};case u.ZodFirstPartyTypeKind.ZodNever:return{not:!0,description:r.description,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodVoid:throw new te(u.ZodFirstPartyTypeKind.ZodVoid);case u.ZodFirstPartyTypeKind.ZodArray:return Qh(e,V);case u.ZodFirstPartyTypeKind.ZodObject:let n=Object.entries(r.shape()),s=n.filter(([g,m])=>!m.isOptional()),i=s.length?s.map(([g])=>g):void 0,o=n.map(([g,m])=>[g,m.mandatory()]).map(([g,m])=>[g,V(m)]),l=!1;return r.unknownKeys instanceof u.ZodType?l=V(r.unknownKeys):r.unknownKeys==="passthrough"&&(l=!0),{type:"object",description:r.description,properties:Object.fromEntries(o),required:i,additionalProperties:l,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodUnion:return{description:r.description,anyOf:r.options.map(g=>V(g)),"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:return{description:r.description,anyOf:r.options.map(g=>V(g)),"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodIntersection:let d=V(r.left),f=V(r.right);return"additionalProperties"in d&&delete d.additionalProperties,"additionalProperties"in f&&delete f.additionalProperties,{description:r.description,allOf:[d,f],"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodTuple:return tm(e,V);case u.ZodFirstPartyTypeKind.ZodRecord:return{type:"object",description:r.description,additionalProperties:V(r.valueType),"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodMap:throw new te(u.ZodFirstPartyTypeKind.ZodMap);case u.ZodFirstPartyTypeKind.ZodSet:return em(e,V);case u.ZodFirstPartyTypeKind.ZodFunction:throw new te(u.ZodFirstPartyTypeKind.ZodFunction);case u.ZodFirstPartyTypeKind.ZodLazy:throw new te(u.ZodFirstPartyTypeKind.ZodLazy);case u.ZodFirstPartyTypeKind.ZodLiteral:if(typeof r.value=="string")return{type:"string",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(typeof r.value=="number")return{type:"number",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(typeof r.value=="boolean")return{type:"boolean",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(r.value===null)return Bn(r);if(r.value===void 0)return In(r);{u.util.assertEqual(!0);let g=typeof r.value;throw new zr(`Unsupported literal type: "${g}"`)}case u.ZodFirstPartyTypeKind.ZodEnum:return{type:"string",description:r.description,enum:r.values,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodEffects:throw new te(u.ZodFirstPartyTypeKind.ZodEffects);case u.ZodFirstPartyTypeKind.ZodNativeEnum:throw new te(u.ZodFirstPartyTypeKind.ZodNativeEnum);case u.ZodFirstPartyTypeKind.ZodOptional:return{description:r.description,anyOf:[V(r.innerType),In()],"x-zui":p(c({},r["x-zui"]),{def:{typeName:u.ZodFirstPartyTypeKind.ZodOptional}})};case u.ZodFirstPartyTypeKind.ZodNullable:return{anyOf:[V(r.innerType),Bn()],"x-zui":p(c({},r["x-zui"]),{def:{typeName:u.ZodFirstPartyTypeKind.ZodNullable}})};case u.ZodFirstPartyTypeKind.ZodDefault:return p(c({},V(r.innerType)),{default:r.defaultValue()});case u.ZodFirstPartyTypeKind.ZodCatch:throw new te(u.ZodFirstPartyTypeKind.ZodCatch);case u.ZodFirstPartyTypeKind.ZodPromise:throw new te(u.ZodFirstPartyTypeKind.ZodPromise);case u.ZodFirstPartyTypeKind.ZodBranded:throw new te(u.ZodFirstPartyTypeKind.ZodBranded);case u.ZodFirstPartyTypeKind.ZodPipeline:throw new te(u.ZodFirstPartyTypeKind.ZodPipeline);case u.ZodFirstPartyTypeKind.ZodSymbol:throw new te(u.ZodFirstPartyTypeKind.ZodPipeline);case u.ZodFirstPartyTypeKind.ZodReadonly:return p(c({},V(r.innerType)),{readOnly:!0});case u.ZodFirstPartyTypeKind.ZodRef:return{$ref:r.uri,description:r.description,"x-zui":r["x-zui"]};default:u.util.assertNever(r)}}a(V,"toJSONSchema");var In=a(t=>({not:!0,description:t?.description,"x-zui":p(c({},t?.["x-zui"]),{def:{typeName:u.ZodFirstPartyTypeKind.ZodUndefined}})}),"undefinedSchema"),Bn=a(t=>({type:"null",description:t?.description,"x-zui":t?.["x-zui"]}),"nullSchema"),xl=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(xl,"ParseInputLazyPath");var oe=xl,Ti=a((t,e)=>{if(at(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 ue(t.common.issues);return this._error=r,this._error}}},"handleResult"),kl=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(Mt(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 Ti(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(Mt(s)?s:Promise.resolve(s));return Ti(n,i)}refine(e,r){let n=a(s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r,"getIssueProperties");return this._refinement((s,i)=>{let o=e(s),l=a(()=>i.addIssue(c({code:h.custom},n(s))),"setError");return typeof Promise<"u"&&o instanceof Promise?o.then(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 ke({schema:this,typeName:"ZodEffects",effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return me.create(this,this._def)}nullable(){return Ne.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return lt.create(this,this._def)}promise(){return zt.create(this,this._def)}mandatory(){return this}or(e){return un.create([this,e],this._def)}and(e){return nn.create(this,e,this._def)}transform(e){return new ke(p(c({},k(this._def)),{schema:this,typeName:"ZodEffects",effect:{type:"transform",transform:e}}))}default(e){let r=typeof e=="function"?e:()=>e;return new Kt(p(c({},k(this._def)),{innerType:this,defaultValue:r,typeName:"ZodDefault"}))}brand(){return new en(c({typeName:"ZodBranded",type:this},k(this._def)))}catch(e){let r=typeof e=="function"?e:()=>e;return new tn(p(c({},k(this._def)),{innerType:this,catchValue:r,typeName:"ZodCatch"}))}describe(e){let r=this.clone();return r._metadataRoot._def.description=e,r}pipe(e){return dn.create(this,e)}readonly(){return Ft.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}metadata(e){var r,n,s;let i=this.clone(),o=i._metadataRoot;(s=(r=o._def)[n=b])!=null||(r[n]={});for(let[l,d]of Object.entries(e))o._def[b]=p(c({},o._def[b]),{[l]:d});return i}getMetadata(){return c({},this._metadataRoot._def[b])}setMetadata(e){this._metadataRoot._def[b]=c({},e)}get ui(){return c({},this._metadataRoot._def[b])}get _metadataRoot(){return this.naked()}displayAs(e){return this.metadata({displayAs:[e.id,e.params]})}title(e){return this.metadata({title:e})}hidden(e){let r;return e===void 0?r=!0:typeof e=="function"?r=e.toString():r=e,this.metadata({hidden:r})}disabled(e){let r;return e===void 0?r=!0:typeof e=="function"?r=e.toString():r=e,this.metadata({disabled:r})}placeholder(e){return this.metadata({placeholder:e})}toJSONSchema(){return V(this)}toTypescriptType(e){return qn(this,e)}toTypescriptSchema(){return ss(this)}naked(){return this}};a(kl,"ZodType");var E=kl,os=(t=>(t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodRef="ZodRef",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly",t))(os||{}),Z;(t=>{t.assertEqual=a(s=>s,"assertEqual");function e(s){}t.assertIs=e,a(e,"assertIs");function r(s){throw new Error("assertNever called")}t.assertNever=r,a(r,"assertNever"),t.arrayToEnum=a(s=>{let i={};for(let o of s)i[o]=o;return i},"arrayToEnum"),t.getValidEnumValues=a(s=>{let i=(0,t.objectKeys)(s).filter(l=>typeof s[s[l]]!="number"),o={};for(let l of i)o[l]=s[l];return(0,t.objectValues)(o)},"getValidEnumValues"),t.objectValues=a(s=>(0,t.objectKeys)(s).map(function(i){return s[i]}),"objectValues"),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=a((s,i)=>{for(let o of s)if(i(o))return o},"find"),t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=n,a(n,"joinValues"),t.jsonStringifyReplacer=a((s,i)=>typeof i=="bigint"?i.toString():i,"jsonStringifyReplacer"),t.compareFunctions=a((s,i)=>s.toString()===i.toString(),"compareFunctions"),t.mock=a(()=>({}),"mock")})(Z||(Z={}));var ar;(t=>{t.mergeShapes=a((e,r)=>c(c({},e),r),"mergeShapes")})(ar||(ar={}));var _=Z.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 k(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s,supportsExtensions:i,[b]:o}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);let l=o?Object.fromEntries(Object.entries(o).filter(([f])=>f!=="secret"||i?.includes("secret"))):void 0;return e?{errorMap:e,description:s,[b]:l}:{errorMap:a((f,g)=>f.code!=="invalid_type"?{message:g.defaultError}:typeof g.data>"u"?{message:n??g.defaultError}:{message:r??g.defaultError},"customMap"),description:s,[b]:l}}a(k,"processCreateParams");var ls=a((t,e)=>{let r;switch(t.code){case h.invalid_type:t.received===_.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case h.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Z.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:r=`Unrecognized key(s) in object: ${Z.joinValues(t.keys,", ")}`;break;case h.invalid_union:r="Invalid input";break;case h.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Z.joinValues(t.options)}`;break;case h.invalid_enum_value:r=`Invalid enum value. Expected ${Z.joinValues(t.options)}, received '${t.received}'`;break;case h.invalid_arguments:r="Invalid function arguments";break;case h.invalid_return_type:r="Invalid function return type";break;case h.invalid_date:r="Invalid date";break;case h.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:Z.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case h.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case h.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case h.custom:r="Invalid input";break;case h.invalid_intersection_types:r="Intersection results could not be merged";break;case h.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case h.not_finite:r="Number must be finite";break;case h.unresolved_reference:r="Unresolved reference";break;default:r=e.defaultError,Z.assertNever(t)}return{message:r}},"errorMap"),bi=ls,h=Z.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite","unresolved_reference"]),Sl=a(t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),or=class El 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 f=o.path[d];d===o.path.length-1?(l[f]=l[f]||{_errors:[]},l[f]._errors.push(r(o))):l[f]=l[f]||{_errors:[]},l=l[f],d++}}},"processError");return s(this),n}static assert(e){if(!(e instanceof El))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Z.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};a(or,"ZodError");or.create=a(t=>new or(t),"create");var ue=or,Ol=ls;function cs(t){Ol=t}a(cs,"setErrorMap");function it(){return Ol}a(it,"getErrorMap");var Nt=a(t=>{var e;let{data:r,path:n,errorMaps:s,issueData:i}=t,o=[...n,...i.path||[]],l=p(c({},i),{path:o}),d="",f=s.filter(g=>!!g).slice().reverse();for(let g of f)d=g(l,{data:r,defaultError:d}).message;return p(c({},i),{path:o,message:(e=i.message)!=null?e:d})},"makeIssue"),Zl=[];function v(t,e){let r=Nt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,it(),ls].filter(n=>!!n)});t.common.issues.push(r)}a(v,"addIssueToContext");var Il=class Bl{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 Bl.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(Il,"ParseStatus");var re=Il,x=Object.freeze({status:"aborted"}),He=a(t=>({status:"dirty",value:t}),"DIRTY"),J=a(t=>({status:"valid",value:t}),"OK"),lr=a(t=>t.status==="aborted","isAborted"),cr=a(t=>t.status==="dirty","isDirty"),at=a(t=>t.status==="valid","isValid"),Mt=a(t=>typeof Promise<"u"&&t instanceof Promise,"isAsync"),w;(t=>{t.errToObj=a(e=>typeof e=="string"?{message:e}:e||{},"errToObj"),t.toString=a(e=>typeof e=="string"?e:e?.message,"toString")})(w||(w={}));var dr=class Al extends E{constructor(){super(...arguments),this._any=!0}_parse(e){return J(e.data)}isEqual(e){return e instanceof Al}};a(dr,"ZodAny");dr.create=a(t=>new dr(c({typeName:"ZodAny"},k(t))),"create");var ot=dr,ur=class Be extends E{dereference(e){return new Be(p(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new Be(p(c({},this._def),{type:this._def.type.clone()}))}isEqual(e){var r,n,s,i,o,l;return e instanceof Be?rt((r=this._def.exactLength)==null?void 0:r.value,(n=e._def.exactLength)==null?void 0:n.value)&&rt((s=this._def.maxLength)==null?void 0:s.value,(i=e._def.maxLength)==null?void 0:i.value)&&rt((o=this._def.minLength)==null?void 0:o.value,(l=e._def.minLength)==null?void 0:l.value)&&this._def.type.isEqual(e._def.type):!1}_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==_.array)return v(r,{code:h.invalid_type,expected:_.array,received:r.parsedType}),x;if(s.exactLength!==null){let o=r.data.length>s.exactLength.value,l=r.data.length<s.exactLength.value;(o||l)&&(v(r,{code:o?h.too_big:h.too_small,minimum:l?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(v(r,{code:h.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(v(r,{code:h.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((o,l)=>s.type._parseAsync(new 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 Be(p(c({},this._def),{minLength:{value:e,message:w.toString(r)}}))}max(e,r){return new Be(p(c({},this._def),{maxLength:{value:e,message:w.toString(r)}}))}length(e,r){return new Be(p(c({},this._def),{exactLength:{value:e,message:w.toString(r)}}))}nonempty(e){return this.min(1,e)}};a(ur,"ZodArray");ur.create=a((t,e)=>new ur(c({type:t,minLength:null,maxLength:null,exactLength:null,typeName:"ZodArray"},k(e))),"create");var lt=ur,rm=a((t,e)=>Rl(t,e,new WeakSet),"isEqual"),Rl=a((t,e,r)=>wh(t,e,nm(r)),"_isEqualWithVisitedTracking"),nm=a(t=>(e,r)=>{if(ni(e)&&!t.has(e)&&ni(r)&&!t.has(r)){let n=vi(e,yi),s=vi(r,yi);return t.add(n).add(s).add(e).add(r),Rl(n,s,t)}},"_customizerWithVisitedTracking"),sm={compare:rm},Cl=class{constructor(e=[],r={}){this._options=c(c({},sm),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(Cl,"CustomSet");var K=Cl,pr=class Xt extends E{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==_.bigint){let i=this._getOrReturnCtx(e);return v(i,{code:h.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:h.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Z.assertNever(i);return{status:s.value,value:e.data}}isEqual(e){if(!(e instanceof Xt)||this._def.coerce!==e._def.coerce)return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)}gte(e,r){return this.setLimit("min",e,!0,w.toString(r))}gt(e,r){return this.setLimit("min",e,!1,w.toString(r))}lte(e,r){return this.setLimit("max",e,!0,w.toString(r))}lt(e,r){return this.setLimit("max",e,!1,w.toString(r))}setLimit(e,r,n,s){return new Xt(p(c({},this._def),{checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:w.toString(s)}]}))}_addCheck(e){return new Xt(p(c({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:w.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};a(pr,"ZodBigInt");pr.create=a(t=>{var e;return new pr(c({checks:[],typeName:"ZodBigInt",coerce:(e=t?.coerce)!=null?e:!1},k(t)))},"create");var Xr=pr,fr=class Hl extends E{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==_.boolean){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.boolean,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof Hl?this._def.coerce===e._def.coerce:!1}};a(fr,"ZodBoolean");fr.create=a(t=>new fr(c({typeName:"ZodBoolean",coerce:t?.coerce||!1},k(t))),"create");var Qr=fr,Dl=Symbol("zod_brand"),Nl=class Tt extends E{dereference(e){return new Tt(p(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new Tt(p(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}isEqual(e){return e instanceof Tt?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}mandatory(){return new Tt(p(c({},this._def),{type:this._def.type.mandatory()}))}};a(Nl,"ZodBranded");var en=Nl,gr=class bt extends E{_parse(e){let{ctx:r}=this._processInputParams(e),n=p(c({},r),{common:p(c({},r.common),{issues:[]})}),s=this._def.innerType._parse({data:n.data,path:n.path,parent:c({},n)});return Mt(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new ue(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new ue(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}isEqual(e){return e instanceof bt?this._def.innerType.isEqual(e._def.innerType)&&Z.compareFunctions(this._def.catchValue,e._def.catchValue):!1}dereference(e){return new bt(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new bt(p(c({},this._def),{innerType:this._def.innerType.clone()}))}naked(){return this._def.innerType.naked()}mandatory(){return new bt(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(gr,"ZodCatch");gr.create=a((t,e)=>new gr(c({innerType:t,typeName:"ZodCatch",catchValue:typeof e.catch=="function"?e.catch:()=>e.catch},k(e))),"create");var tn=gr,ds=a((t,e={},r)=>t?ot.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,f=typeof l=="string"?{message:l}:l;s.addIssue(p(c({code:"custom"},f),{fatal:d}))}}):ot.create(),"custom"),hr=class Un extends E{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==_.date){let i=this._getOrReturnCtx(e);return v(i,{code:h.invalid_type,expected:_.date,received:i.parsedType}),x}if(isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return v(i,{code:h.invalid_date}),x}let n=new 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:h.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:h.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):Z.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Un(p(c({},this._def),{checks:[...this._def.checks,e]}))}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:w.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:w.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}isEqual(e){if(!(e instanceof Un))return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)&&this._def.coerce===e._def.coerce}};a(hr,"ZodDate");hr.create=a(t=>new hr(c({checks:[],coerce:t?.coerce||!1,typeName:"ZodDate"},k(t))),"create");var rn=hr,mr=class wt extends E{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===_.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}dereference(e){return new wt(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new wt(p(c({},this._def),{innerType:this._def.innerType.clone()}))}isEqual(e){return e instanceof wt?this._def.innerType.isEqual(e._def.innerType)&&rt(this._def.defaultValue(),e._def.defaultValue()):!1}unwrap(){return this._def.innerType}naked(){return this._def.innerType.naked()}mandatory(){return new wt(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(mr,"ZodDefault");mr.create=a((t,e,r)=>new mr(c({innerType:t,typeName:"ZodDefault",defaultValue:typeof e=="function"?e:()=>e},k(r))),"create");var Kt=mr,_e=a(t=>Array.from(new Set(t)),"unique"),ge=a(t=>t instanceof sn?ge(t.schema):t instanceof ke?ge(t.innerType()):t instanceof an?[t.value]:t instanceof qe?t.options:t instanceof on?Z.objectValues(t.enum):t instanceof Kt?ge(t._def.innerType):t instanceof Wt?[void 0]:t instanceof ln?[null]:t instanceof me?[void 0,...ge(t.unwrap())]:t instanceof Ne?[null,...ge(t.unwrap())]:t instanceof en||t instanceof Ft?ge(t.unwrap()):t instanceof tn?ge(t._def.innerType):[],"getDiscriminator"),Ml=class Ae extends E{dereference(e){let r=this.options.map(s=>s.dereference(e)),n=Ae._getOptionsMap(this.discriminator,r);return new Ae(p(c({},this._def),{options:r,optionsMap:n}))}getReferences(){return _e(this.options.flatMap(e=>e.getReferences()))}clone(){let e=this.options.map(r=>r.clone());return new Ae(p(c({},this._def),{options:e}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==_.object)return v(r,{code:h.invalid_type,expected:_.object,received:r.parsedType}),x;let n=this.discriminator,s=r.data[n],i=this.optionsMap.get(s);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(v(r,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),x)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let s=Ae._getOptionsMap(e,r);return new Ae(c({typeName:"ZodDiscriminatedUnion",discriminator:e,options:r,optionsMap:s},k(n)))}static _getOptionsMap(e,r){let n=new Map;for(let s of r){let i=ge(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 Ae)||this._def.discriminator!==e._def.discriminator)return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new K(this._def.options,{compare:r}),s=new K(e._def.options,{compare:r});return n.isEqual(s)}};a(Ml,"ZodDiscriminatedUnion");var us=Ml;function Ut(t,e){return new qe(c({values:t,typeName:"ZodEnum"},k(e)))}a(Ut,"createZodEnum");var ps=class Qt extends E{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return v(r,{expected:Z.joinValues(n),received:r.parsedType,code:h.invalid_type}),x}if(this._def.values.indexOf(e.data)===-1){let r=this._getOrReturnCtx(e),n=this._def.values;return v(r,{received:r.data,code:h.invalid_enum_value,options:n}),x}return J(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return Qt.create(e,c(c({},this._def),r))}exclude(e,r=this._def){return Qt.create(this.options.filter(n=>!e.includes(n)),c(c({},this._def),r))}isEqual(e){if(!(e instanceof Qt))return!1;let r=new K(this._def.values),n=new K(e._def.values);return r.isEqual(n)}};a(ps,"ZodEnum");ps.create=Ut;var qe=ps,jl=class Re extends E{constructor(){super(...arguments),this.validate=this.implement}dereference(e){let r=this._def.args.dereference(e),n=this._def.returns.dereference(e);return new Re(p(c({},this._def),{args:r,returns:n}))}getReferences(){return _e([...this._def.args.getReferences(),...this._def.returns.getReferences()])}clone(){return new Re(p(c({},this._def),{args:this._def.args.clone(),returns:this._def.returns.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==_.function)return v(r,{code:h.invalid_type,expected:_.function,received:r.parsedType}),x;function n(l,d){return Nt({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,it(),bi].filter(f=>!!f),issueData:{code:h.invalid_arguments,argumentsError:d}})}a(n,"makeArgsIssue");function s(l,d){return Nt({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,it(),bi].filter(f=>!!f),issueData:{code:h.invalid_return_type,returnTypeError:d}})}a(s,"makeReturnsIssue");let i={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof zt){let l=this;return J(async function(...d){let f=new ue([]),g=await l._def.args.parseAsync(d,i).catch(O=>{throw f.addIssue(n(d,O)),f}),m=await Reflect.apply(o,this,g);return await l._def.returns._def.type.parseAsync(m,i).catch(O=>{throw f.addIssue(s(m,O)),f})})}else{let l=this;return J(function(...d){let f=l._def.args.safeParse(d,i);if(!f.success)throw new ue([n(d,f.error)]);let g=Reflect.apply(o,this,f.data),m=l._def.returns.safeParse(g,i);if(!m.success)throw new ue([s(g,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Re(p(c({},this._def),{args:je.create(e).rest(nt.create())}))}returns(e){return new Re(p(c({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new Re(c({args:e||je.create([]).rest(nt.create()),returns:r||nt.create(),typeName:"ZodFunction"},k(n)))}isEqual(e){return e instanceof Re&&this._def.args.isEqual(e._def.args)&&this._def.returns.isEqual(e._def.returns)}};a(jl,"ZodFunction");var fs=jl;function yr(t,e){let r=he(t),n=he(e);if(t===e)return{valid:!0,data:t};if(r===_.object&&n===_.object){let s=Z.objectKeys(e),i=Z.objectKeys(t).filter(l=>s.indexOf(l)!==-1),o=c(c({},t),e);for(let l of i){let d=yr(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=yr(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(yr,"mergeValues");var vr=class er extends E{dereference(e){return new er(p(c({},this._def),{left:this._def.left.dereference(e),right:this._def.right.dereference(e)}))}getReferences(){return _e([...this._def.left.getReferences(),...this._def.right.getReferences()])}clone(){return new er(p(c({},this._def),{left:this._def.left.clone(),right:this._def.right.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=a((i,o)=>{if(lr(i)||lr(o))return x;let l=yr(i.value,o.value);return l.valid?((cr(i)||cr(o))&&r.dirty(),{status:r.value,value:l.data}):(v(n,{code:h.invalid_intersection_types}),x)},"handleParsed");return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}isEqual(e){if(!(e instanceof er))return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new K([this._def.left,this._def.right],{compare:r}),s=new K([e._def.left,e._def.right],{compare:r});return n.isEqual(s)}};a(vr,"ZodIntersection");vr.create=a((t,e,r)=>new vr(c({left:t,right:e,typeName:"ZodIntersection"},k(r))),"create");var nn=vr,_r=class Pt extends E{get schema(){return this._def.getter()}dereference(e){return new Pt(p(c({},this._def),{getter:a(()=>this._def.getter().dereference(e),"getter")}))}getReferences(){return this._def.getter().getReferences()}clone(){return new Pt(p(c({},this._def),{getter:a(()=>this._def.getter().clone(),"getter")}))}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}isEqual(e){return e instanceof Pt?this._def.getter().isEqual(e._def.getter()):!1}naked(){return this._def.getter().naked()}mandatory(){return new Pt(p(c({},this._def),{getter:a(()=>this._def.getter().mandatory(),"getter")}))}};a(_r,"ZodLazy");_r.create=a((t,e)=>new _r(c({getter:t,typeName:"ZodLazy"},k(e))),"create");var sn=_r,Tr=class $l extends E{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return v(r,{received:r.data,code:h.invalid_literal,expected:this._def.value}),x}return{status:"valid",value:e.data}}get value(){return this._def.value}isEqual(e){return e instanceof $l?rt(this._def.value,e._def.value):!1}};a(Tr,"ZodLiteral");Tr.create=a((t,e)=>new Tr(c({value:t,typeName:"ZodLiteral"},k(e))),"create");var an=Tr,br=class tr extends E{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 tr(p(c({},this._def),{keyType:r,valueType:n}))}getReferences(){return _e([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new tr(p(c({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.map)return v(n,{code:h.invalid_type,expected:_.map,received:n.parsedType}),x;let s=this._def.keyType,i=this._def.valueType,o=[...n.data.entries()].map(([l,d],f)=>({key:s._parse(new oe(n,l,n.path,[f,"key"])),value:i._parse(new oe(n,d,n.path,[f,"value"]))}));if(n.common.async){let l=new Map;return Promise.resolve().then(async()=>{for(let d of o){let f=await d.key,g=await d.value;if(f.status==="aborted"||g.status==="aborted")return x;(f.status==="dirty"||g.status==="dirty")&&r.dirty(),l.set(f.value,g.value)}return{status:r.value,value:l}})}else{let l=new Map;for(let d of o){let f=d.key,g=d.value;if(f.status==="aborted"||g.status==="aborted")return x;(f.status==="dirty"||g.status==="dirty")&&r.dirty(),l.set(f.value,g.value)}return{status:r.value,value:l}}}isEqual(e){return!(!(e instanceof tr)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};a(br,"ZodMap");br.create=a((t,e,r)=>new br(c({valueType:e,keyType:t,typeName:"ZodMap"},k(r))),"create");var gs=br,wr=class Kl extends E{_parse(e){if(this._getType(e)!==_.nan){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.nan,received:n.parsedType}),x}return{status:"valid",value:e.data}}isEqual(e){return e instanceof Kl}};a(wr,"ZodNaN");wr.create=a(t=>new wr(c({typeName:"ZodNaN"},k(t))),"create");var hs=wr,Pr=class Ul extends E{_parse(e){let r=Z.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==_.string&&n.parsedType!==_.number){let s=Z.objectValues(r);return v(n,{expected:Z.joinValues(s),received:n.parsedType,code:h.invalid_type}),x}if(r.indexOf(e.data)===-1){let s=Z.objectValues(r);return v(n,{received:n.data,code:h.invalid_enum_value,options:s}),x}return J(e.data)}get enum(){return this._def.values}isEqual(e){return e instanceof Ul?rt(this._def.values,e._def.values):!1}};a(Pr,"ZodNativeEnum");Pr.create=a((t,e)=>new Pr(c({values:t,typeName:"ZodNativeEnum"},k(e))),"create");var on=Pr,xr=class zl extends E{_parse(e){let r=this._getOrReturnCtx(e);return v(r,{code:h.invalid_type,expected:_.never,received:r.parsedType}),x}isEqual(e){return e instanceof zl}};a(xr,"ZodNever");xr.create=a(t=>new xr(c({typeName:"ZodNever"},k(t))),"create");var ut=xr,kr=class Fl extends E{_parse(e){if(this._getType(e)!==_.null){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.null,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof Fl}};a(kr,"ZodNull");kr.create=a(t=>new kr(c({typeName:"ZodNull"},k(t))),"create");var ln=kr,Sr=class xt extends E{dereference(e){return new xt(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new xt(p(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)===_.null?J(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof xt?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new xt(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(Sr,"ZodNullable");Sr.create=a((t,e)=>new Sr(c({innerType:t,typeName:"ZodNullable"},k(e))),"create");var Ne=Sr;function Wl(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(Wl,"floatSafeRemainder");var Er=class rr extends E{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==_.number){let i=this._getOrReturnCtx(e);return v(i,{code:h.invalid_type,expected:_.number,received:i.parsedType}),x}let n,s=new re;for(let i of this._def.checks)i.kind==="int"?Z.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{code:h.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Wl(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{code:h.not_finite,message:i.message}),s.dirty()):Z.assertNever(i);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,w.toString(r))}gt(e,r){return this.setLimit("min",e,!1,w.toString(r))}lte(e,r){return this.setLimit("max",e,!0,w.toString(r))}lt(e,r){return this.setLimit("max",e,!1,w.toString(r))}setLimit(e,r,n,s){return new rr(p(c({},this._def),{checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:w.toString(s)}]}))}_addCheck(e){return new rr(p(c({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:w.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:w.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:w.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:w.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:w.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Z.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}isEqual(e){if(!(e instanceof rr))return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)}};a(Er,"ZodNumber");Er.create=a(t=>new Er(c({checks:[],typeName:"ZodNumber",coerce:t?.coerce||!1},k(t))),"create");var cn=Er;function Ce(t){if(t instanceof Me){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=me.create(Ce(n))}return new Me(p(c({},t._def),{shape:a(()=>e,"shape")}))}else return t instanceof lt?new lt(p(c({},t._def),{type:Ce(t.element)})):t instanceof me?me.create(Ce(t.unwrap())):t instanceof Ne?Ne.create(Ce(t.unwrap())):t instanceof je?je.create(t.items.map(e=>Ce(e))):t}a(Ce,"deepPartialify");var xe=class se extends E{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=Z.objectKeys(e);return this._cached={shape:e,keys:r}}dereference(e){let r=this._def.shape(),n={};for(let s in r)n[s]=r[s].dereference(e);return new se(p(c({},this._def),{shape:a(()=>n,"shape")}))}getReferences(){let e=this._def.shape(),r=[];for(let n in e)r.push(...e[n].getReferences());return _e(r)}clone(){let e={},r=this._def.shape();for(let[n,s]of Object.entries(r))e[n]=s.clone();return new se(p(c({},this._def),{shape:a(()=>e,"shape")}))}_parse(e){if(this._getType(e)!==_.object){let g=this._getOrReturnCtx(e);return v(g,{code:h.invalid_type,expected:_.object,received:g.parsedType}),x}let{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),l=[];if(this._def.unknownKeys!=="strip")for(let g in s.data)o.includes(g)||l.push(g);let d=[];for(let g of o){let m=i[g],P=s.data[g];d.push({key:{status:"valid",value:g},value:m._parse(new oe(s,P,s.path,g)),alwaysSet:g in s.data})}let f=this._def.unknownKeys;if(f==="passthrough")for(let g of l)d.push({key:{status:"valid",value:g},value:{status:"valid",value:s.data[g]}});else if(f==="strict")l.length>0&&(v(s,{code:h.unrecognized_keys,keys:l}),n.dirty());else if(f!=="strip")for(let g of l){let m=s.data[g];d.push({key:{status:"valid",value:g},value:f._parse(new oe(s,m,s.path,g)),alwaysSet:g in s.data})}return s.common.async?Promise.resolve().then(async()=>{let g=[];for(let m of d){let P=await m.key;g.push({key:P,value:await m.value,alwaysSet:m.alwaysSet})}return g}).then(g=>re.mergeObjectSync(n,g)):re.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return w.errToObj,new se(c(p(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=w.errToObj(e).message)!=null?l:d}:{message:d}},"errorMap")}:{}))}strip(){return new se(p(c({},this._def),{unknownKeys:"strip"}))}passthrough(){return new se(p(c({},this._def),{unknownKeys:"passthrough"}))}additionalProperties(){if(this._def.unknownKeys instanceof E)return this._def.unknownKeys;if(this._def.unknownKeys==="passthrough")return ot.create();if(this._def.unknownKeys==="strict")return ut.create()}extend(e){return new se(p(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(p(c({},this._def),{unknownKeys:e}))}pick(e){let r={};return Z.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new se(p(c({},this._def),{shape:a(()=>r,"shape")}))}omit(e){let r={};return Z.objectKeys(this.shape).forEach(n=>{e[n]||(r[n]=this.shape[n])}),new se(p(c({},this._def),{shape:a(()=>r,"shape")}))}deepPartial(){return Ce(this)}partial(e){let r={};return Z.objectKeys(this.shape).forEach(n=>{let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s?.optional()}),new se(p(c({},this._def),{shape:a(()=>r,"shape")}))}required(e){let r={};return Z.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof me;)i=i._def.innerType;r[n]=i}}),new se(p(c({},this._def),{shape:a(()=>r,"shape")}))}keyof(){return Ut(Z.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 K(Object.entries(r),{compare:s}),o=new K(Object.entries(n),{compare:s});return i.isEqual(o)}_unknownKeysEqual(e){let r=this.additionalProperties(),n=e.additionalProperties();return r===void 0||n===void 0?r===n:r.isEqual(n)}};a(xe,"ZodObject");xe.create=a((t,e)=>new xe(c({shape:a(()=>t,"shape"),unknownKeys:"strip",typeName:"ZodObject"},k(e))),"create");xe.strictCreate=a((t,e)=>new xe(c({shape:a(()=>t,"shape"),unknownKeys:"strict",typeName:"ZodObject"},k(e))),"strictCreate");xe.lazycreate=a((t,e)=>new xe(c({shape:t,unknownKeys:"strip",typeName:"ZodObject"},k(e))),"lazycreate");var Me=xe,Or=class nr extends E{dereference(e){return new nr(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new nr(p(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)===_.undefined?J(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof nr?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return this._def.innerType.mandatory()}};a(Or,"ZodOptional");Or.create=a((t,e)=>new Or(c({innerType:t,typeName:"ZodOptional"},k(e))),"create");var me=Or,Ll=class kt extends E{dereference(e){return new kt(p(c({},this._def),{in:this._def.in.dereference(e),out:this._def.out.dereference(e)}))}getReferences(){return _e([...this._def.in.getReferences(),...this._def.out.getReferences()])}clone(){return new kt(p(c({},this._def),{in:this._def.in.clone(),out:this._def.out.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return a(async()=>{let i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?x:i.status==="dirty"?(r.dirty(),He(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})},"handleAsync")();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?x:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new kt({in:e,out:r,typeName:"ZodPipeline"})}isEqual(e){return!(!(e instanceof kt)||!this._def.in.isEqual(e._def.in)||!this._def.out.isEqual(e._def.out))}};a(Ll,"ZodPipeline");var dn=Ll,Zr=class sr extends E{unwrap(){return this._def.type}dereference(e){return new sr(p(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new sr(p(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==_.promise&&r.common.async===!1)return v(r,{code:h.invalid_type,expected:_.promise,received:r.parsedType}),x;let n=r.parsedType===_.promise?r.data:Promise.resolve(r.data);return J(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}isEqual(e){return e instanceof sr?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}};a(Zr,"ZodPromise");Zr.create=a((t,e)=>new Zr(c({type:t,typeName:"ZodPromise"},k(e))),"create");var zt=Zr,Ir=class St extends E{dereference(e){return new St(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new St(p(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){let r=this._def.innerType._parse(e);return at(r)&&(r.value=Object.freeze(r.value)),r}unwrap(){return this._def.innerType}isEqual(e){return e instanceof St?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new St(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(Ir,"ZodReadonly");Ir.create=a((t,e)=>new Ir(c({innerType:t,typeName:"ZodReadonly"},k(e))),"create");var Ft=Ir,ql=class Xe extends E{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}dereference(e){let r=this._def.keyType.dereference(e),n=this._def.valueType.dereference(e);return new Xe(p(c({},this._def),{keyType:r,valueType:n}))}getReferences(){return _e([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new Xe(p(c({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.object)return v(n,{code:h.invalid_type,expected:_.object,received:n.parsedType}),x;let s=[],i=this._def.keyType,o=this._def.valueType;for(let l in n.data)s.push({key:i._parse(new 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 E?new Xe(c({keyType:e,valueType:r,typeName:"ZodRecord"},k(n))):new Xe(c({keyType:Y.create(),valueType:e,typeName:"ZodRecord"},k(r)))}isEqual(e){return!(!(e instanceof Xe)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};a(ql,"ZodRecord");var ms=ql,Br=class Vl extends E{dereference(e){let r=e[this._def.uri];return r||this}getReferences(){return[this._def.uri]}_parse(e){let r=this._getOrReturnCtx(e);return v(r,{code:h.unresolved_reference}),x}isOptional(){return!1}isNullable(){return!1}isEqual(e){return e instanceof Vl?this._def.uri===e._def.uri:!1}};a(Br,"ZodRef");Br.create=a(t=>new Br({typeName:"ZodRef",uri:t}),"create");var ys=Br,Ar=class Qe extends E{dereference(e){return new Qe(p(c({},this._def),{valueType:this._def.valueType.dereference(e)}))}getReferences(){return this._def.valueType.getReferences()}clone(){return new Qe(p(c({},this._def),{valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.set)return v(n,{code:h.invalid_type,expected:_.set,received:n.parsedType}),x;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(v(n,{code:h.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(v(n,{code:h.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let i=this._def.valueType;function o(d){let f=new Set;for(let g of d){if(g.status==="aborted")return x;g.status==="dirty"&&r.dirty(),f.add(g.value)}return{status:r.value,value:f}}a(o,"finalizeSet");let l=[...n.data.values()].map((d,f)=>i._parse(new oe(n,d,n.path,f)));return n.common.async?Promise.all(l).then(d=>o(d)):o(l)}min(e,r){return new Qe(p(c({},this._def),{minSize:{value:e,message:w.toString(r)}}))}max(e,r){return new Qe(p(c({},this._def),{maxSize:{value:e,message:w.toString(r)}}))}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}isEqual(e){var r,n,s,i;if(!(e instanceof Qe))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,f=(i=e._def.maxSize)==null?void 0:i.value;return d!==f?!1:this._def.valueType.isEqual(e._def.valueType)}};a(Ar,"ZodSet");Ar.create=a((t,e)=>new Ar(c({valueType:t,minSize:null,maxSize:null,typeName:"ZodSet"},k(e))),"create");var vs=Ar,_s=/^c[^\s-]{8,}$/i,Ts=/^[a-z][a-z0-9]*$/,bs=/^[0-9A-HJKMNP-TV-Z]{26}$/,ws=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Ps=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Gl="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Jl=a(t=>t===Gl,"isEmojiRegex"),An,xs=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,ks=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;function Yl(t,e){return!!((e==="v4"||!e)&&xs.test(t)||(e==="v6"||!e)&&ks.test(t))}a(Yl,"isValidIP");var Rr=class et extends E{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==_.string){let i=this._getOrReturnCtx(e);return v(i,{code:h.invalid_type,expected:_.string,received:i.parsedType}),x}let n=new 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:h.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:h.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,l=e.data.length<i.value;(o||l)&&(s=this._getOrReturnCtx(e,s),o?v(s,{code:h.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):l&&v(s,{code:h.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")Ps.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"email",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")An||(An=new RegExp(Gl,"u")),An.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"emoji",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")ws.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"uuid",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")_s.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"cuid",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")Ts.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"cuid2",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")bs.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"ulid",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),v(s,{validation:"url",code:h.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"regex",code:h.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),v(s,{code:h.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),v(s,{code:h.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),v(s,{code:h.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?Pl(i).test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{code:h.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="ip"?Yl(e.data,i.version)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"ip",code:h.invalid_string,message:i.message}),n.dirty()):Z.assertNever(i);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),c({validation:r,code:h.invalid_string},w.errToObj(n)))}_addCheck(e){return new et(p(c({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(c({kind:"email"},w.errToObj(e)))}url(e){return this._addCheck(c({kind:"url"},w.errToObj(e)))}emoji(e){return this._addCheck(c({kind:"emoji"},w.errToObj(e)))}uuid(e){return this._addCheck(c({kind:"uuid"},w.errToObj(e)))}cuid(e){return this._addCheck(c({kind:"cuid"},w.errToObj(e)))}cuid2(e){return this._addCheck(c({kind:"cuid2"},w.errToObj(e)))}ulid(e){return this._addCheck(c({kind:"ulid"},w.errToObj(e)))}ip(e){return this._addCheck(c({kind:"ip"},w.errToObj(e)))}datetime(e){var r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck(c({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(r=e?.offset)!=null?r:!1},w.errToObj(e?.message)))}regex(e,r){return this._addCheck(c({kind:"regex",regex:e},w.errToObj(r)))}includes(e,r){return this._addCheck(c({kind:"includes",value:e,position:r?.position},w.errToObj(r?.message)))}startsWith(e,r){return this._addCheck(c({kind:"startsWith",value:e},w.errToObj(r)))}endsWith(e,r){return this._addCheck(c({kind:"endsWith",value:e},w.errToObj(r)))}min(e,r){return this._addCheck(c({kind:"min",value:e},w.errToObj(r)))}max(e,r){return this._addCheck(c({kind:"max",value:e},w.errToObj(r)))}length(e,r){return this._addCheck(c({kind:"length",value:e},w.errToObj(r)))}nonempty(e){return this.min(1,w.errToObj(e))}trim(){return new et(p(c({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}secret(){return this._def[b]=p(c({},this._def[b]),{secret:!0}),this}toLowerCase(){return new et(p(c({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new et(p(c({},this._def),{checks:[...this._def.checks,{kind:"toUpperCase"}]}))}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}isEqual(e){if(!(e instanceof et))return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)}};a(Rr,"ZodString");Rr.create=a(t=>{var e;return new Rr(c({checks:[],typeName:"ZodString",coerce:(e=t?.coerce)!=null?e:!1},k(p(c({},t),{supportsExtensions:["secret"]}))))},"create");var Y=Rr,Cr=class Xl extends E{_parse(e){if(this._getType(e)!==_.symbol){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.symbol,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof Xl}};a(Cr,"ZodSymbol");Cr.create=a(t=>new Cr(c({typeName:"ZodSymbol"},k(t))),"create");var Ss=Cr,ct=class Et extends E{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName==="ZodEffects"?this._def.schema.sourceType():this._def.schema}dereference(e){return new Et(p(c({},this._def),{schema:this._def.schema.dereference(e)}))}getReferences(){return this._def.schema.getReferences()}clone(){return new Et(p(c({},this._def),{schema:this._def.schema.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a(o=>{v(n,o),o.fatal?r.abort():r.dirty()},"addIssue"),get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let o=s.transform(n.data,i);if(n.common.async)return Promise.resolve(o).then(async l=>{if(r.value==="aborted")return x;let d=await this._def.schema._parseAsync({data:l,path:n.path,parent:n});return d.status==="aborted"?x:d.status==="dirty"||r.value==="dirty"?He(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"?He(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(!at(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=>at(o)?Promise.resolve(s.transform(o.value,i)).then(l=>({status:r.value,value:l})):o);Z.assertNever(s)}isEqual(e){return!(e instanceof Et)||!this._def.schema.isEqual(e._def.schema)?!1:this._def.effect.type==="refinement"?e._def.effect.type!=="refinement"?!1:Z.compareFunctions(this._def.effect.refinement,e._def.effect.refinement):this._def.effect.type==="transform"?e._def.effect.type!=="transform"?!1:Z.compareFunctions(this._def.effect.transform,e._def.effect.transform):this._def.effect.type==="preprocess"?e._def.effect.type!=="preprocess"?!1:Z.compareFunctions(this._def.effect.transform,e._def.effect.transform):!1}naked(){return this._def.schema.naked()}mandatory(){return new Et(p(c({},this._def),{schema:this._def.schema.mandatory()}))}};a(ct,"ZodEffects");ct.create=a((t,e,r)=>new ct(c({schema:t,typeName:"ZodEffects",effect:e},k(r))),"create");ct.createWithPreprocess=a((t,e,r)=>new ct(c({schema:e,effect:{type:"preprocess",transform:t},typeName:"ZodEffects"},k(r))),"createWithPreprocess");var ke=ct,Hr=class Ot extends E{dereference(e){let r=this._def.items.map(s=>s.dereference(e)),n=this._def.rest?this._def.rest.dereference(e):null;return new Ot(p(c({},this._def),{items:r,rest:n}))}getReferences(){return _e([...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 Ot(p(c({},this._def),{items:e,rest:r}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.array)return v(n,{code:h.invalid_type,expected:_.array,received:n.parsedType}),x;if(n.data.length<this._def.items.length)return v(n,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),x;!this._def.rest&&n.data.length>this._def.items.length&&(v(n,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...n.data].map((o,l)=>{let 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 Ot(p(c({},this._def),{rest:e}))}isEqual(e){if(!(e instanceof Ot)||!this._restEquals(e))return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new K(this._def.items,{compare:r}),s=new K(e._def.items,{compare:r});return n.isEqual(s)}_restEquals(e){return this._def.rest===null?e._def.rest===null:e._def.rest!==null&&this._def.rest.isEqual(e._def.rest)}};a(Hr,"ZodTuple");Hr.create=a((t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Hr(c({items:t,typeName:"ZodTuple",rest:null},k(e)))},"create");var je=Hr,Dr=class Ql extends E{_parse(e){if(this._getType(e)!==_.undefined){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.undefined,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof Ql}mandatory(){return ut.create(c({},this._def))}};a(Dr,"ZodUndefined");Dr.create=a(t=>new Dr(c({typeName:"ZodUndefined"},k(t))),"create");var Wt=Dr,Nr=class Zt extends E{dereference(e){let r=this._def.options.map(n=>n.dereference(e));return new Zt(p(c({},this._def),{options:r}))}getReferences(){return _e(this._def.options.reduce((e,r)=>[...e,...r.getReferences()],[]))}clone(){let e=this._def.options.map(r=>r.clone());return new Zt(p(c({},this._def),{options:e}))}_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function s(i){for(let l of i)if(l.result.status==="valid")return l.result;for(let l of i)if(l.result.status==="dirty")return r.common.issues.push(...l.ctx.common.issues),l.result;let o=i.map(l=>new ue(l.ctx.common.issues));return v(r,{code:h.invalid_union,unionErrors:o}),x}if(a(s,"handleResults"),r.common.async)return Promise.all(n.map(async i=>{let o=p(c({},r),{common:p(c({},r.common),{issues:[]}),parent:null});return{result:await i._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(s);{let i,o=[];for(let d of n){let f=p(c({},r),{common:p(c({},r.common),{issues:[]}),parent:null}),g=d._parseSync({data:r.data,path:r.path,parent:f});if(g.status==="valid")return g;g.status==="dirty"&&!i&&(i={result:g,ctx:f}),f.common.issues.length&&o.push(f.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let l=o.map(d=>new ue(d));return v(r,{code:h.invalid_union,unionErrors:l}),x}}get options(){return this._def.options}isEqual(e){if(!(e instanceof Zt))return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new K([...this._def.options],{compare:r}),s=new K([...e._def.options],{compare:r});return n.isEqual(s)}mandatory(){let e=this._def.options.filter(i=>!(i instanceof Wt)).map(i=>i.mandatory()),[r,n,...s]=e;return r?n?new Zt(p(c({},this._def),{options:[r,n,...s]})):r:ut.create(c({},this._def))}};a(Nr,"ZodUnion");Nr.create=a((t,e)=>new Nr(c({options:t,typeName:"ZodUnion"},k(e))),"create");var un=Nr,Mr=class ec extends E{constructor(){super(...arguments),this._unknown=!0}_parse(e){return J(e.data)}isEqual(e){return e instanceof ec}};a(Mr,"ZodUnknown");Mr.create=a(t=>new Mr(c({typeName:"ZodUnknown"},k(t))),"create");var nt=Mr,jr=class tc extends E{_parse(e){if(this._getType(e)!==_.undefined){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.void,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof tc}};a(jr,"ZodVoid");jr.create=a(t=>new jr(c({typeName:"ZodVoid"},k(t))),"create");var Es=jr,im=["gpt-3.5-turbo","gpt-3.5-turbo-16k","gpt-4","gpt-4-1106-preview","gpt-4-vision-preview","gpt-4-0125-preview","gpt-4-turbo-preview","gpt-4-turbo","gpt-4o","gpt-3.5-turbo-0125","gpt-3.5-turbo-1106"],vv=qe.create(["any","string","number","boolean","object","pattern","date","array","target","time","enum"]),rc=a(t=>Y.create().displayAs({id:"variable",params:c({type:t?.type||"any"},t?.params)}),"variable"),nc=a(t=>Y.create().displayAs({id:"conversation",params:c({},t?.params)}),"conversation"),sc=a(t=>Y.create().displayAs({id:"user",params:c({},t?.params)}),"user"),ic=a(t=>Y.create().displayAs({id:"message",params:c({},t?.params)}),"message"),ac=a(t=>Y.create().displayAs({id:"agent",params:c({},t?.params)}),"agent"),oc=a(t=>Y.create().displayAs({id:"event",params:c({},t?.params)}),"event"),lc=a(t=>Y.create().displayAs({id:"table",params:c({},t?.params)}),"table"),cc=a(t=>Y.create().displayAs({id:"tablerow",params:c({},t?.params)}),"tablerow"),dc=a(t=>Y.create().displayAs({id:"intent",params:c({},t?.params)}),"intent"),uc=a(()=>qe.create(im).displayAs({id:"dropdown",params:{}}),"aimodel"),pc=a(t=>Y.create().displayAs({id:"datasource",params:c({},t)}),"datasource"),fc=a(t=>Y.create().displayAs({id:"knowledgebase",params:c({},t)}),"knowledgebase"),gc={object:Me.lazycreate},hc=a((t,e={message:`Input not instance of ${t.name}`})=>ds(r=>r instanceof t,e),"instanceOfType"),Os=Y.create,Zs=cn.create,mc=hs.create,yc=Xr.create,Is=Qr.create,vc=rn.create,_c=Ss.create,Tc=Wt.create,bc=ln.create,wc=ot.create,Pc=nt.create,xc=ut.create,kc=Es.create,Sc=lt.create,Ec=Me.create,Oc=Me.strictCreate,Zc=un.create,Ic=us.create,Bc=nn.create,Ac=je.create,Rc=ms.create,Cc=ys.create,Hc=Ft.create,Dc=gs.create,Nc=vs.create,Mc=fs.create,jc=sn.create,$c=an.create,Kc=qe.create,Uc=on.create,zc=zt.create,zn=ke.create,Fc=me.create,Wc=Ne.create,am=Kt.create,Lc=ke.createWithPreprocess,qc=dn.create,Vc=a(()=>Os().optional(),"ostring"),Gc=a(()=>Zs().optional(),"onumber"),Jc=a(()=>Is().optional(),"oboolean"),Yc={string:a(t=>Y.create(p(c({},t),{coerce:!0})),"string"),number:a(t=>cn.create(p(c({},t),{coerce:!0})),"number"),boolean:a(t=>Qr.create(p(c({},t),{coerce:!0})),"boolean"),bigint:a(t=>Xr.create(p(c({},t),{coerce:!0})),"bigint"),date:a(t=>rn.create(p(c({},t),{coerce:!0})),"date")},Xc=x,u=y,Qc=a((t,e)=>t.anyOf.length?t.anyOf.length===1?W(t.anyOf[0],p(c({},e),{path:[...e.path,"anyOf",0]})):`z.union([${t.anyOf.map((r,n)=>W(r,p(c({},e),{path:[...e.path,"anyOf",n]}))).join(", ")}])`:"z.any()","parseAnyOf"),om=a(t=>{var e;return(e=t[b])!=null&&e.coerce?"z.coerce.boolean()":"z.boolean()"},"parseBoolean"),lm=a(t=>"z.any()","parseDefault"),cm=a((t,e)=>`z.union([${t.type.map(r=>W(p(c({},t),{type:r}),e)).join(", ")}])`,"parseMultipleType"),dm=a((t,e)=>`z.any().refine((value) => !${W(t.not,p(c({},e),{path:[...e.path,"not"]}))}.safeParse(value).success, "Invalid input: Should NOT be valid against schema")`,"parseNot"),um=a(t=>"z.null()","parseNull"),pm=a(t=>[t.slice(0,t.length/2),t.slice(t.length/2)],"half"),fm=a((t,...e)=>Object.keys(t).reduce((r,n)=>(e.includes(n)||(r[n]=t[n]),r),{}),"omit");function G(t,e,r){var n;let s=t[e],i="";if(s!==void 0){let o=r({value:s,json:JSON.stringify(s)});if(o){let l=o[0],d=o.length===3?o[1]:"",f=o.length===3?o[2]:o[1];i+=l,((n=t.errorMessage)==null?void 0:n[e])!==void 0&&(i+=d+JSON.stringify(t.errorMessage[e])),i+=f}}return i}a(G,"withMessage");var It=Symbol("Original index"),gm=a(t=>{let e=[];for(let r=0;r<t.length;r++){let n=t[r];if(typeof n=="boolean")e.push(n?{[It]:r}:{[It]:r,not:{}});else{if(It in n)return t;e.push(p(c({},n),{[It]:r}))}}return e},"ensureOriginalIndex");function jt(t,e){if(t.allOf.length===0)return"z.never()";if(t.allOf.length===1){let r=t.allOf[0];return W(r,p(c({},e),{path:[...e.path,"allOf",r[It]]}))}else{let[r,n]=pm(gm(t.allOf));return`z.intersection(${jt({allOf:r},e)}, ${jt({allOf:n},e)})`}}a(jt,"parseAllOf");var hm=a((t,e)=>{if(Array.isArray(t.items))return`z.tuple([${t.items.map((n,s)=>W(n,p(c({},e),{path:[...e.path,"items",s]})))}])`;let r=t.items?`z.array(${W(t.items,p(c({},e),{path:[...e.path,"items"]}))})`:"z.array(z.any())";return r+=G(t,"minItems",({json:n})=>[`.min(${n}`,", ",")"]),r+=G(t,"maxItems",({json:n})=>[`.max(${n}`,", ",")"]),r},"parseArray"),mm=a(t=>`z.literal(${JSON.stringify(t.const)})`,"parseConst"),ym=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"),vm=a((t,e)=>{let r=W(t.if,p(c({},e),{path:[...e.path,"if"]})),n=W(t.then,p(c({},e),{path:[...e.path,"then"]})),s=W(t.else,p(c({},e),{path:[...e.path,"else"]}));return`z.union([${n}, ${s}]).superRefine((value,ctx) => {
|
|
12
12
|
const result = ${r}.safeParse(value).success
|
|
13
13
|
? ${n}.safeParse(value)
|
|
14
14
|
: ${s}.safeParse(value);
|
|
15
15
|
if (!result.success) {
|
|
16
16
|
result.error.errors.forEach((error) => ctx.addIssue(error))
|
|
17
17
|
}
|
|
18
|
-
})`},"parseIfThenElse"),
|
|
18
|
+
})`},"parseIfThenElse"),_m=a(t=>{var e;let r="z.number()";return(e=t[b])!=null&&e.coerce&&(r="z.coerce.number()"),t.type==="integer"?r+=G(t,"type",()=>[".int(",")"]):r+=G(t,"format",({value:n})=>{if(n==="int64")return[".int(",")"]}),r+=G(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+=G(t,"minimum",({json:n})=>[`.gt(${n}`,", ",")"]):r+=G(t,"minimum",({json:n})=>[`.gte(${n}`,", ",")"]):typeof t.exclusiveMinimum=="number"&&(r+=G(t,"exclusiveMinimum",({json:n})=>[`.gt(${n}`,", ",")"])),typeof t.maximum=="number"?t.exclusiveMaximum===!0?r+=G(t,"maximum",({json:n})=>[`.lt(${n}`,", ",")"]):r+=G(t,"maximum",({json:n})=>[`.lte(${n}`,", ",")"]):typeof t.exclusiveMaximum=="number"&&(r+=G(t,"exclusiveMaximum",({json:n})=>[`.lt(${n}`,", ",")"])),r},"parseNumber"),Bs=a((t,e)=>t.oneOf.length?t.oneOf.length===1?W(t.oneOf[0],p(c({},e),{path:[...e.path,"oneOf",0]})):`z.any().superRefine((x, ctx) => {
|
|
19
19
|
const schemas = [${t.oneOf.map((r,n)=>W(r,p(c({},e),{path:[...e.path,"oneOf",n]}))).join(", ")}];
|
|
20
20
|
const errors = schemas.reduce(
|
|
21
21
|
(errors: z.ZodError[], schema) =>
|
|
@@ -32,7 +32,7 @@ ${Q}`.trim();case u.ZodFirstPartyTypeKind.ZodEnum:return l.values.map(T).join("
|
|
|
32
32
|
message: "Invalid input: Should pass single schema",
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
-
})`:"z.any()","parseOneOf");function
|
|
35
|
+
})`:"z.any()","parseOneOf");function ed(t,e){let r;t.properties&&(Object.keys(t.properties).length?(r="z.object({ ",r+=Object.keys(t.properties).map(o=>{let l=t.properties[o],d=`${JSON.stringify(o)}: ${W(l,p(c({},e),{path:[...e.path,"properties",o]}))}`,f=typeof l=="object"&&l.default!==void 0||typeof t.default=="object"&&t.default!==null&&o in t.default,g=Array.isArray(t.required)?t.required.includes(o):typeof l=="object"&&l.required===!0;return!f&&!g?`${d}.optional()`:d}).join(", "),r+=" })"):r="z.object({})");let n=t.additionalProperties!==void 0?W(t.additionalProperties,p(c({},e),{path:[...e.path,"additionalProperties"]})):void 0,s;if(t.patternProperties){let o=Object.fromEntries(Object.entries(t.patternProperties).map(([l,d])=>[l,W(d,p(c({},e),{path:[...e.path,"patternProperties",l]}))],{}));s="",r?n?s+=`.catchall(z.union([${[...Object.values(o),n].join(", ")}]))`:Object.keys(o).length>1?s+=`.catchall(z.union([${Object.values(o).join(", ")}]))`:s+=`.catchall(${Object.values(o)})`:n?s+=`z.record(z.union([${[...Object.values(o),n].join(", ")}]))`:Object.keys(o).length>1?s+=`z.record(z.union([${Object.values(o).join(", ")}]))`:s+=`z.record(${Object.values(o)})`,s+=`.superRefine((value, ctx) => {
|
|
36
36
|
`,s+=`for (const key in value) {
|
|
37
37
|
`,n&&(t.properties?s+=`let evaluated = [${Object.keys(t.properties).map(l=>JSON.stringify(l)).join(", ")}].includes(key)
|
|
38
38
|
`:s+=`let evaluated = false
|
|
@@ -64,7 +64,7 @@ ${Q}`.trim();case u.ZodFirstPartyTypeKind.ZodEnum:return l.values.map(T).join("
|
|
|
64
64
|
`,s+=`}
|
|
65
65
|
`,s+=`}
|
|
66
66
|
`),s+=`}
|
|
67
|
-
`,s+="})"}let i=r?s?r+s:n?n==="z.never()"?r+".strict()":r+`.catchall(${n})`:r:s||(n?`z.record(${n})`:"z.record(z.any())");return $.an.anyOf(t)&&(i+=`.and(${sd(p(c({},t),{anyOf:t.anyOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?p(c({},o),{type:"object"}):o)}),e)})`),$.a.oneOf(t)&&(i+=`.and(${Bs(p(c({},t),{oneOf:t.oneOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?p(c({},o),{type:"object"}):o)}),e)})`),$.an.allOf(t)&&(i+=`.and(${$t(p(c({},t),{allOf:t.allOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?p(c({},o),{type:"object"}):o)}),e)})`),i}a(id,"parseObject");var _m=a(t=>{var e;let r="z.string()";if((e=t[b])!=null&&e.coerce){if(t.format==="date-time")return"z.coerce.date()";r="z.coerce.string()"}return r+=G(t,"format",({value:n})=>{switch(n){case"email":return[".email(",")"];case"ip":return[".ip(",")"];case"ipv4":return['.ip({ version: "v4"',", message: "," })"];case"ipv6":return['.ip({ version: "v6"',", message: "," })"];case"uri":return[".url(",")"];case"uuid":return[".uuid(",")"];case"date-time":return[".datetime(",")"]}}),r+=G(t,"pattern",({json:n})=>[`.regex(new RegExp(${n})`,", ",")"]),r+=G(t,"minLength",({json:n})=>[`.min(${n}`,", ",")"]),r+=G(t,"maxLength",({json:n})=>[`.max(${n}`,", ",")"]),r},"parseString"),Tm=a((t,e)=>`${W(pm(t,"nullable"),e,!0)}.nullable()`,"parseNullable"),bm=a(t=>`z.ref('${t.$ref}')`,"parseRef"),wm=a((t,e)=>{var r,n;if(t.oneOf.length<=1||!((r=t.discriminator)!=null&&r.propertyName))return Bs(t,e);let s=t.oneOf.map((i,o)=>W(i,p(c({},e),{path:[...e.path,"oneOf",o]})));return`z.discriminatedUnion("${(n=t.discriminator)==null?void 0:n.propertyName}", [${s.join(", ")}])`},"parseDiscriminator"),W=a((t,e={seen:new Map,path:[]},r)=>{if(typeof t!="object")return t?"z.any()":"z.never()";if(e.parserOverride){let i=e.parserOverride(t,e);if(typeof i=="string")return i}let n=e.seen.get(t);if(n){if(n.r!==void 0)return n.r;if(e.depth===void 0||n.n>=e.depth)return"z.any()";n.n+=1}else n={r:void 0,n:0},e.seen.set(t,n);let s=km(t,e);return r||(s=Pm(t,s),e.withoutDefaults||(s=xm(t,s))),n.r=s,s},"parseSchema"),Pm=a((t,e)=>(t.description&&(e+=`.describe(${JSON.stringify(t.description)})`),e),"addMeta"),xm=a((t,e)=>(t.default!==void 0&&(e+=`.default(${JSON.stringify(t.default)})`),e),"addDefaults"),km=a((t,e)=>$.a.nullable(t)?Tm(t,e):$.an.object(t)?id(t,e):$.an.array(t)?gm(t,e):$.an.anyOf(t)?sd(t,e):$.an.allOf(t)?$t(t,e):$.a.discriminator(t)?wm(t,e):$.a.oneOf(t)?Bs(t,e):$.a.not(t)?cm(t,e):$.an.enum(t)?mm(t):$.a.const(t)?hm(t):$.a.multipleType(t)?lm(t,e):$.a.primitive(t,"string")?_m(t):$.a.primitive(t,"number")||$.a.primitive(t,"integer")?vm(t):$.a.primitive(t,"boolean")?am(t):$.a.primitive(t,"null")?dm(t):$.a.conditional(t)?ym(t,e):$.a.ref(t)?bm(t):om(t),"selectParser"),$={an:{object:a(t=>t.type==="object","object"),array:a(t=>t.type==="array","array"),anyOf:a(t=>t.anyOf!==void 0,"anyOf"),allOf:a(t=>t.allOf!==void 0,"allOf"),enum:a(t=>t.enum!==void 0,"enum")},a:{nullable:a(t=>t.nullable===!0,"nullable"),multipleType:a(t=>Array.isArray(t.type),"multipleType"),not:a(t=>t.not!==void 0,"not"),const:a(t=>t.const!==void 0,"const"),primitive:a((t,e)=>t.type===e,"primitive"),conditional:a(t=>!!("if"in t&&t.if&&"then"in t&&"else"in t&&t.then&&t.else),"conditional"),discriminator:a(t=>{var e;return t.oneOf!==void 0&&((e=t.discriminator)==null?void 0:e.propertyName)!==void 0},"discriminator"),oneOf:a(t=>t.oneOf!==void 0,"oneOf"),ref:a(t=>t.$ref!==void 0,"ref")}},Sm=a(t=>{let e;try{e=new Function("z",`return ${t}`)(u)}catch(r){return{sucess:!1,error:`Failed to evaluate schema: ${(r instanceof Error?r:new Error(String(r))).message}`}}return e instanceof u.ZodType?{sucess:!0,value:e}:{sucess:!1,error:`String "${t}" does not evaluate to a Zod schema`}},"evalZuiString"),Om=a(t=>W(t,{seen:new Map,path:[]}),"jsonSchemaToZodStr"),Em=a(t=>{let e=Om(t);e=e.replaceAll("errors: z.ZodError[]","errors");let r=Sm(e);if(!r.sucess)throw new Wr(r.error);return r.value},"jsonSchemaToZod"),Bt=a((t,e)=>{var r,n;if(e[b]&&t._def&&(t._def[b]=e[b]),((r=t._def)==null?void 0:r.typeName)==="ZodObject"&&e.type==="object"&&e.properties&&Object.entries(e.properties).forEach(([s,i])=>{let o=typeof t._def.shape=="function"?t._def.shape():t._def.shape;o[s]&&Bt(o[s],i)}),((n=t._def)==null?void 0:n.typeName)==="ZodRecord"&&e.type==="object"&&e.additionalProperties&&Bt(t._def.valueType,e.additionalProperties),e.type==="array"&&e.items){let s=e.items;if(typeof s=="object"&&!Array.isArray(s)){let i=t._def.type;i&&Bt(i,s)}else Array.isArray(s)&&s.forEach((i,o)=>{let l=t._def;l.typeName===y.ZodFirstPartyTypeKind.ZodTuple&&Bt(l.items[o],i)})}},"applyZuiPropsRecursively"),Zm=a(t=>{let e=Em(t);return Bt(e,t),e},"fromJSONSchemaLegacy"),Im=a(t=>{var e,r;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(n=>typeof n!="boolean"&&ad(n))&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===u.ZodFirstPartyTypeKind.ZodOptional},"isOptionalSchema"),Bm=a(t=>{var e,r;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(n=>typeof n!="boolean"&&n.type==="null")&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===u.ZodFirstPartyTypeKind.ZodNullable},"isNullableSchema"),ad=a(t=>{var e,r;return t.not===!0&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===u.ZodFirstPartyTypeKind.ZodUndefined},"isUndefinedSchema"),Cm=a(t=>{var e,r;return!t.not&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===u.ZodFirstPartyTypeKind.ZodUnknown},"isUnknownSchema"),Am=a(({type:t,minimum:e,exclusiveMinimum:r,maximum:n,exclusiveMaximum:s,multipleOf:i,format:o})=>{let l=u.number();return t==="integer"&&(l=l.int()),o==="finite"&&(l=l.finite()),r!==void 0?l=l.gt(r):e!==void 0&&(l=l.gte(e)),s!==void 0?l=l.lt(s):n!==void 0&&(l=l.lte(n)),i!==void 0&&(l=l.multipleOf(i)),l},"numberJSONSchemaToZuiNumber"),Rm=a(({format:t,pattern:e,minLength:r,maxLength:n})=>{let s=u.string();if(r&&n&&r===n?s=s.length(r):(r&&(s=s.min(r)),n&&(s=s.max(n))),t==="cuid"||e===j.cuid)s=s.cuid();else if(t==="cuid2"||e===j.cuid2)s=s.cuid2();else if(t==="emoji"||e===j.emoji)s=s.emoji();else if(t==="ulid"||e===j.ulid)s=s.ulid();else if(t==="date-time"){let{precision:i,offset:o}=e?Vh(e):{};s=s.datetime({precision:i,offset:o})}else t==="email"||e===j.email?s=s.email():t==="ipv4"||e===j.ipv4?s=s.ip():t==="ipv6"||e===j.ipv6?s=s.ip("v6"):t==="uri"?s=s.url():t==="uuid"||e===j.uuid?s=s.uuid():e&&(s=s.regex(new RegExp(e)));return s},"stringJSONSchemaToZuiString"),_t=a((t,e)=>{let r=[];e.enum!==void 0&&r.push(...e.enum),e.const!==void 0&&r.push(e.const);let n=r.filter(o=>typeof o===t),[s]=n;if(!s){if(t==="string"&&e.type==="string")return Rm(e);if(t==="number"&&(e.type==="number"||e.type==="integer"))return Am(e);if(t==="boolean")return u.boolean();if(t==="null")return u.null();throw new Wr(`Unknown primitive type: "${t}"`)}if(n.length===1)return u.literal(s);let i=n.map(o=>u.literal(o));return u.union(i)},"toZuiPrimitive"),Hm=a((t,e)=>Dm(t)?Nm(t,e):Mm(t)?$m(t,e):jm(t,e),"arrayJSONSchemaToZuiArray"),Dm=a(t=>Array.isArray(t.items),"_isTuple"),Mm=a(t=>t.items!==void 0&&t.uniqueItems,"_isSet"),Nm=a(({items:t,additionalItems:e},r)=>{let n=t.map(r),s=u.tuple(n);return e!==void 0&&(s=s.rest(r(e))),s},"_handleTuple"),$m=a(({items:t,minItems:e,maxItems:r},n)=>{let s=u.set(n(t));return e&&(s=s.min(e)),r&&(s=s.max(r)),s},"_handleSet"),jm=a(({minItems:t,maxItems:e,items:r},n)=>{let s=u.array(n(r));return t&&t===e?s.length(t):(t&&(s=s.min(t)),e&&(s=s.max(e)),s)},"_handleArray"),Je=u.any();function od(t){return F(t)}a(od,"fromJSONSchema");function F(t){var e;if(t===void 0)return Je;if(t===!0)return u.any();if(t===!1)return u.never();if(t.default!==void 0)return F(p(c({},t),{default:void 0})).default(t.default);if(t.readOnly)return F(p(c({},t),{readOnly:void 0})).readonly();if(t.oneOf!==void 0)throw new Te({oneOf:t.oneOf});if(t.patternProperties!==void 0)throw new Te({patternProperties:t.patternProperties});if(t.propertyNames!==void 0)throw new Te({propertyNames:t.propertyNames});if(t.if!==void 0)throw new Te({if:t.if});if(t.then!==void 0)throw new Te({then:t.then});if(t.else!==void 0)throw new Te({else:t.else});if(t.$ref!==void 0)return u.ref(t.$ref);if(t.not!==void 0){if(ad(t))return u.undefined();if(t.not===!0)return u.never();throw new Te({not:t.not})}if(Array.isArray(t.type)){if(t.type.length===0)return Je;if(t.type.length===1)return F(p(c({},t),{type:t.type[0]}));let r=t,{type:n}=r,s=Bi(r,["type"]),i=t.type.map(o=>F(p(c({},s),{type:o})));return u.union(i)}if(t.type==="string")return t.enum&&t.enum.length>0?u.enum(t.enum):_t("string",t);if(t.type==="integer"){let r=_t("number",t);return r instanceof u.ZodNumber?r.int():r}if(t.type==="number")return _t("number",t);if(t.type==="boolean")return _t("boolean",t);if(t.type==="null")return _t("null",t);if(t.type==="array")return Hm(t,F);if(t.type==="object"){if(t.additionalProperties!==void 0&&t.properties!==void 0){let r=F(t.additionalProperties);return F(p(c({},t),{additionalProperties:void 0})).catchall(r)}if(t.properties!==void 0){let r={};for(let[n,s]of Object.entries(t.properties)){let i=F(s),o=(e=t.required)!=null?e:[];r[n]=o.includes(n)?i:i.optional()}return u.object(r)}if(t.additionalProperties!==void 0){let r=F(t.additionalProperties);return u.record(r)}return u.record(Je)}if(t.anyOf!==void 0){if(t.anyOf.length===0)return Je;if(t.anyOf.length===1)return F(t.anyOf[0]);if(Im(t))return F(t.anyOf[0]).optional();if(Bm(t))return F(t.anyOf[0]).nullable();let r=t.anyOf.map(F);return u.union(r)}if(t.allOf!==void 0){if(t.allOf.length===0)return Je;if(t.allOf.length===1)return F(t.allOf[0]);let[r,...n]=t.allOf,s=F(r),i=F({allOf:n});return u.intersection(s,i)}return Cm(t)?u.unknown():Je}a(F,"_fromJSONSchema");var Km=/^\d{4}-\d{2}-\d{2}(T|\s)?((\d{2}:\d{2}:\d{2}(\.\d{1,3})?)|(\d{2}:\d{2}))?(\s?([+-]\d{2}:\d{2}|Z))?$/,Fn=a((t,e,r=!0)=>{if(typeof t!="object")throw new Rn("Input must be an object");let n=a(o=>{let l=o;return e?.nullable&&(l=l.nullable()),e?.optional&&(l=l.optional()),e?.passtrough&&typeof l.passthrough=="function"&&(l=l.passthrough()),l},"applyOptions"),s=Object.entries(t).reduce((o,[l,d])=>{if(d===null)o[l]=n(y.null());else switch(typeof d){case"string":o[l]=Km.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(Fn(d[0],e,!1))):["string","number","boolean"].includes(typeof d[0])&&(o[l]=n(y.array(y[typeof d[0]]()))):o[l]=n(Fn(d,e,!1));break;default:throw new Rn(`Unsupported type for key ${l}`)}return o},{}),i=Object.keys(s).length>0;return e?.passtrough||!r&&!i?y.object(s).passthrough():y.object(s)},"fromObject");function ld(){return{}}a(ld,"parseAnyDef");function cd(t,e){var r,n;let s={type:"array"};return((n=(r=t.type)==null?void 0:r._def)==null?void 0:n.typeName)!=="ZodAny"&&(s.items=C(t.type._def,p(c({},e),{currentPath:[...e.currentPath,"items"]}))),t.minLength&&H(s,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&H(s,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(H(s,"minItems",t.exactLength.value,t.exactLength.message,e),H(s,"maxItems",t.exactLength.value,t.exactLength.message,e)),s}a(cd,"parseArrayDef");function dd(t,e){let r=c({type:"integer",format:"int64"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?H(r,"minimum",n.value,n.message,e):H(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),H(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?H(r,"maximum",n.value,n.message,e):H(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),H(r,"maximum",n.value,n.message,e));break;case"multipleOf":H(r,"multipleOf",n.value,n.message,e);break}return r}a(dd,"parseBigintDef");function ud(t){return c({type:"boolean"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{})}a(ud,"parseBooleanDef");function pd(t,e){return C(t.type._def,e)}a(pd,"parseBrandedDef");var Um=a((t,e)=>C(t.innerType._def,e),"parseCatchDef");function fd(t,e){return e.dateStrategy=="integer"?zm(t,e):c({type:"string",format:"date-time"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{})}a(fd,"parseDateDef");var zm=a((t,e)=>{let r=c({type:"integer",format:"unix-time"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"&&H(r,"minimum",n.value,n.message,e);break;case"max":e.target==="jsonSchema7"&&H(r,"maximum",n.value,n.message,e);break}return r},"integerDateParser");function gd(t,e){return p(c({},C(t.innerType._def,e)),{default:t.defaultValue()})}a(gd,"parseDefaultDef");function hd(t,e){return e.effectStrategy==="input"?C(t.schema._def,e):{}}a(hd,"parseEffectsDef");function md(t){return{type:"string",enum:t.values}}a(md,"parseEnumDef");var Fm=a(t=>"type"in t&&t.type==="string"?!1:"allOf"in t,"isJsonSchema7AllOfType");function yd(t,e){let r=[C(t.left._def,p(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),C(t.right._def,p(c({},e),{currentPath:[...e.currentPath,"allOf","1"]}))].filter(i=>!!i),n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,s=[];return r.forEach(i=>{if(Fm(i))s.push(...i.allOf),i.unevaluatedProperties===void 0&&(n=void 0);else{let o=i;if("additionalProperties"in i&&i.additionalProperties===!1){let l=i,{additionalProperties:d}=l;o=Bi(l,["additionalProperties"])}else n=void 0;s.push(o)}}),s.length?c({allOf:s},n):void 0}a(yd,"parseIntersectionDef");function vd(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(vd,"parseLiteralDef");function Cs(t,e){var r,n,s,i,o;if(e.target==="openApi3"&&((r=t.keyType)==null?void 0:r._def.typeName)==="ZodEnum")return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((d,f)=>{var g;return p(c({},d),{[f]:(g=C(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"properties",f]})))!=null?g:{}})},{}),additionalProperties:!1};let l={type:"object",additionalProperties:(n=C(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?n:{}};if(e.target==="openApi3")return l;if(((s=t.keyType)==null?void 0:s._def.typeName)==="ZodString"&&((i=t.keyType._def.checks)!=null&&i.length)){let d=Object.entries(as(t.keyType._def,e)).reduce((f,[g,m])=>g==="type"?f:p(c({},f),{[g]:m}),{});return p(c({},l),{propertyNames:d})}else if(((o=t.keyType)==null?void 0:o._def.typeName)==="ZodEnum")return p(c({},l),{propertyNames:{enum:t.keyType._def.values}});return l}a(Cs,"parseRecordDef");function _d(t,e){if(e.mapStrategy==="record")return Cs(t,e);let r=C(t.keyType._def,p(c({},e),{currentPath:[...e.currentPath,"items","items","0"]}))||{},n=C(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"items","items","1"]}))||{};return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}a(_d,"parseMapDef");function Td(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(Td,"parseNativeEnumDef");function bd(){return{not:{}}}a(bd,"parseNeverDef");function wd(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}a(wd,"parseNullDef");var zr={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function Pd(t,e){if(e.target==="openApi3")return Oi(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in zr&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((s,i)=>{let o=zr[i._def.typeName];return o&&!s.includes(o)?[...s,o]:s},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((s,i)=>{let o=typeof i._def.value;switch(o){case"string":case"number":case"boolean":return[...s,o];case"bigint":return[...s,"integer"];case"object":if(i._def.value===null)return[...s,"null"];case"symbol":case"undefined":case"function":default:return s}},[]);if(n.length===r.length){let s=n.filter((i,o,l)=>l.indexOf(i)===o);return{type:s.length>1?s:s[0],enum:r.reduce((i,o)=>i.includes(o._def.value)?i:[...i,o._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,s)=>[...n,...s._def.values.filter(i=>!n.includes(i))],[])};return Oi(t,e)}a(Pd,"parseUnionDef");var Oi=a((t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((s,i)=>C(s._def,p(c({},e),{currentPath:[...e.currentPath,e.unionStrategy,`${i}`]}))).filter(s=>!!s&&(!e.strictUnions||typeof s=="object"&&Object.keys(s).length>0)),n=e.discriminator&&t.typeName==="ZodDiscriminatedUnion"&&typeof t.discriminator=="string"?{discriminator:{propertyName:t.discriminator}}:{};if(r.length)return e.unionStrategy==="anyOf"?c({anyOf:r},n):c({oneOf:r},n)},"asUnionOf");function xd(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length)){let n=t.innerType;if(e.target==="openApi3"){let i={type:zr[n._def.typeName],nullable:!0};return Wn(n._def,e,i)}let s={type:[zr[n._def.typeName],"null"]};return Wn(n._def,e,s)}if(e.target==="openApi3"){let n=C(t.innerType._def,p(c({},e),{currentPath:[...e.currentPath]}));return n&&p(c({},n),{nullable:!0})}let r=C(t.innerType._def,p(c({},e),{currentPath:[...e.currentPath,"anyOf","0"]}));return r&&{anyOf:[r,{type:"null"}]}}a(xd,"parseNullableDef");function kd(t,e){let r=c({type:"number"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"int":r.type="integer",is(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?H(r,"minimum",n.value,n.message,e):H(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),H(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?H(r,"maximum",n.value,n.message,e):H(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),H(r,"maximum",n.value,n.message,e));break;case"multipleOf":H(r,"multipleOf",n.value,n.message,e);break}return r}a(kd,"parseNumberDef");var Wm=a((t,e)=>{var r;return t.unknownKeys instanceof O?(r=C(t.unknownKeys._def,p(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?r:!0:t.unknownKeys==="passthrough"},"getAdditionalProperties");function Sd(t,e){let r=p(c({type:"object"},Object.entries(t.shape()).reduce((n,[s,i])=>{if(i===void 0||i._def===void 0)return n;let o=C(i._def,p(c({},e),{currentPath:[...e.currentPath,"properties",s],propertyPath:[...e.currentPath,"properties",s]}));return o===void 0?n:{properties:p(c({},n.properties),{[s]:o}),required:i.isOptional()?n.required:[...n.required,s]}},{properties:{},required:[]})),{additionalProperties:Wm(t,e)});return r.required.length||delete r.required,r}a(Sd,"parseObjectDef");var Lm=a((t,e)=>{var r;if(e.currentPath.toString()===((r=e.propertyPath)==null?void 0:r.toString()))return C(t.innerType._def,e);let n=C(t.innerType._def,p(c({},e),{currentPath:[...e.currentPath,"anyOf","1"]}));return n?{anyOf:[{not:{}},n]}:{}},"parseOptionalDef"),qm=a((t,e)=>{if(e.pipeStrategy==="input")return C(t.in._def,e);if(e.pipeStrategy==="output")return C(t.out._def,e);let r=C(t.in._def,p(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),n=C(t.out._def,p(c({},e),{currentPath:[...e.currentPath,"allOf",r?"1":"0"]}));return{allOf:[r,n].filter(s=>s!==void 0)}},"parsePipelineDef");function Od(t,e){return C(t.type._def,e)}a(Od,"parsePromiseDef");function Ed(t,e){let n={type:"array",uniqueItems:!0,items:C(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"items"]}))};return t.minSize&&H(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&H(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}a(Ed,"parseSetDef");function Zd(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>C(r._def,p(c({},e),{currentPath:[...e.currentPath,"items",`${n}`]}))).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:C(t.rest._def,p(c({},e),{currentPath:[...e.currentPath,"additionalItems"]}))}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>C(r._def,p(c({},e),{currentPath:[...e.currentPath,"items",`${n}`]}))).reduce((r,n)=>n===void 0?r:[...r,n],[])}}a(Zd,"parseTupleDef");function Id(){return{not:{}}}a(Id,"parseUndefinedDef");function Bd(){return{}}a(Bd,"parseUnknownDef");var Vm=a((t,e)=>C(t.innerType._def,e),"parseReadonlyDef");function Cd(t){return{$ref:t.uri}}a(Cd,"parseRefDef");function C(t,e,r=!1){let n=e.seen.get(t);if(n&&!r){let o=Gm(n,e);if(o!==void 0)return o}let s={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,s);let i=Xm(t,t.typeName,e);return i&&Wn(t,e,i),s.jsonSchema=i,i}a(C,"parseDef");var Gm=a((t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Jm(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((r,n)=>e.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),{}):e.$refStrategy==="seen"?{}:void 0}},"get$ref"),Jm=a((t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")},"getRelativePath"),Xm=a((t,e,r)=>{switch(e){case"ZodString":return as(t,r);case"ZodNumber":return kd(t,r);case"ZodObject":return Sd(t,r);case"ZodBigInt":return dd(t,r);case"ZodBoolean":return ud(t);case"ZodDate":return fd(t,r);case"ZodUndefined":return Id();case"ZodNull":return wd(r);case"ZodArray":return cd(t,r);case"ZodUnion":case"ZodDiscriminatedUnion":return Pd(t,r);case"ZodIntersection":return yd(t,r);case"ZodTuple":return Zd(t,r);case"ZodRecord":return Cs(t,r);case"ZodRef":return Cd(t);case"ZodLiteral":return vd(t,r);case"ZodEnum":return md(t);case"ZodNativeEnum":return Td(t);case"ZodNullable":return xd(t,r);case"ZodOptional":return Lm(t,r);case"ZodMap":return _d(t,r);case"ZodSet":return Ed(t,r);case"ZodLazy":return C(t.getter()._def,r);case"ZodPromise":return Od(t,r);case"ZodNaN":case"ZodNever":return bd();case"ZodEffects":return hd(t,r);case"ZodAny":return ld();case"ZodUnknown":return Bd();case"ZodDefault":return gd(t,r);case"ZodBranded":return pd(t,r);case"ZodReadonly":return Vm(t,r);case"ZodCatch":return Um(t,r);case"ZodPipeline":return qm(t,r);case"ZodFunction":case"ZodVoid":case"ZodSymbol":return;default:return(n=>{})(e)}},"selectParser"),Wn=a((t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),Object.assign(r,{[b]:c(c({},t[b]),r[b])}),r),"addMeta"),Ei={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"string",mapStrategy:"entries",definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",emailStrategy:"format:email",discriminator:!1,unionStrategy:"anyOf"},Ym=a(t=>typeof t=="string"?p(c({},Ei),{name:t}):c(c({},Ei),t),"getDefaultOptions"),Qm=a(t=>{let e=Ym(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return p(c({},e),{currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([n,s])=>[s._def,{def:s._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))})},"getRefs"),ey=a((t,e)=>{var r;let n=Qm(e),s=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((d,[f,g])=>{var m;return p(c({},d),{[f]:(m=C(g._def,p(c({},n),{currentPath:[...n.basePath,n.definitionPath,f]}),!0))!=null?m:{}})},{}):void 0,i=typeof e=="string"?e:e?.name,o=(r=C(t._def,i===void 0?n:p(c({},n),{currentPath:[...n.basePath,n.definitionPath,i]}),!1))!=null?r:{},l=i===void 0?s?p(c({},o),{[n.definitionPath]:s}):o:{$ref:[...n.$refStrategy==="relative"?[]:n.basePath,n.definitionPath,i].join("/"),[n.definitionPath]:p(c({},s),{[i]:o})};return n.target==="jsonSchema7"?l.$schema="http://json-schema.org/draft-07/schema#":n.target==="jsonSchema2019-09"&&(l.$schema="https://json-schema.org/draft/2019-09/schema#"),l},"zodToJsonSchema"),ty=a((t,e={target:"openApi3"})=>{let r=ey(t,e);return e.$schemaUrl===!1?delete r.$schema:typeof e.$schemaUrl=="string"&&(r.$schema=e.$schemaUrl),r},"toJSONSchemaLegacy");var ut=(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")},Ad=y;var re=y.string().min(1),Hd=y.object({text:re}),Dd=y.object({markdown:re}),Md=y.object({imageUrl:re}),Nd=y.object({audioUrl:re}),$d=y.object({videoUrl:re}),jd=y.object({fileUrl:re,title:re.optional()}),Kd=y.object({latitude:y.number(),longitude:y.number(),address:y.string().optional(),title:y.string().optional()}),Ud=y.object({title:re,subtitle:re.optional(),imageUrl:re.optional(),actions:y.array(y.object({action:y.enum(["postback","url","say"]),label:re,value:re}))}),Rd=y.object({text:re,options:y.array(y.object({label:re,value:re}))}),ry=y.object({items:y.array(Ud)}),ny=y.union([y.object({type:y.literal("text"),payload:Hd}),y.object({type:y.literal("markdown"),payload:Dd}),y.object({type:y.literal("image"),payload:Md}),y.object({type:y.literal("audio"),payload:Nd}),y.object({type:y.literal("video"),payload:$d}),y.object({type:y.literal("file"),payload:jd}),y.object({type:y.literal("location"),payload:Kd})]),sy=y.object({items:y.array(ny)}),iy={schema:Dd},ay={text:{schema:Hd},image:{schema:Md},audio:{schema:Nd},video:{schema:$d},file:{schema:jd},location:{schema:Kd},carousel:{schema:ry},card:{schema:Ud},dropdown:{schema:Rd},choice:{schema:Rd},bloc:{schema:sy}};var Lt="x-bot-id",Rs="x-bot-user-id",Hs="x-integration-id",Ds="x-webhook-id",Ms="x-bp-configuration-type",qt="x-bp-configuration",Vt="x-bp-operation",Ns="x-bp-type",oy={HIDDEN_IN_STUDIO:{bpActionHiddenInStudio:"true"},AWAIT_RETURN:{bpActionAwaitReturn:"true"}};var zd=require("browser-or-node");var $s=console;function oe(t){if(!t.body)throw new Error("Missing body");return JSON.parse(t.body)}async function Gt(t,e=8072,r=uy){if(!zd.isNode)throw new Error("This function can only be called in Node.js");let s=require("http").createServer(async(i,o)=>{try{let l=await ly(i);if(l.path==="/health"){o.writeHead(200).end("ok");return}let d=await t(l);o.writeHead(d?.status??200,d?.headers??{}).end(d?.body??"{}")}catch(l){$s.error("Error while handling request",{error:l?.message??"Internal error occured"}),o.writeHead(500).end(JSON.stringify({error:l?.message??"Internal error occured"}))}});return s.listen(e,()=>r(e)),s}async function ly(t){let e=await dy(t),r={};for(let s=0;s<t.rawHeaders.length;s+=2){let i=t.rawHeaders[s].toLowerCase(),o=t.rawHeaders[s+1];r[i]=o}let n=new URL(t.url??"",t.headers.host?`http://${t.headers.host}`:"http://botpress.cloud");return{body:e,path:n.pathname,query:cy(n.search,"?"),headers:r,method:t.method?.toUpperCase()??"GET"}}function cy(t,e){return t.indexOf(e)===0?t.slice(e.length):t}async function dy(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 uy(t){$s.info(`Listening on port ${t}`)}var Sn=require("@botpress/client");var M={};yt(M,{mapKeys:()=>gy,mapValues:()=>fy,mergeRecords:()=>my,pairs:()=>hn,stripUndefinedProps:()=>hy,values:()=>py});var hn=t=>Object.entries(t),py=t=>Object.values(t),fy=(t,e)=>Object.fromEntries(hn(t).map(([r,n])=>[r,e(n,r)])),gy=(t,e)=>Object.fromEntries(hn(t).map(([r,n])=>[e(r),n])),hy=t=>Object.fromEntries(hn(t).filter(([,e])=>e!==void 0)),my=(t,e,r)=>{let n=[...Object.keys(t),...Object.keys(e)],s=[...new Set(n)],i={};for(let o of s){let l=t[o],d=e[o];l&&d?i[o]=r(l,d):l?i[o]=l:d&&(i[o]=d)}return i};var S={};yt(S,{safePush:()=>yy,unique:()=>vy});var yy=(t,...e)=>t?[...t,...e]:[...e],vy=t=>Array.from(new Set(t));var ve={};yt(ve,{setName:()=>_y});var _y=(t,e)=>(Object.defineProperty(t,"name",{value:e}),t);var Fd=t=>{let{name:e,version:r}=t,n={actions:{},events:{},channels:{}},s={name:e,version:r,entities:M.mapValues(t.entities,o=>({name:o.name})),actions:{},events:{},channels:{}},i=M.mapValues(t.entities,o=>o.schema);for(let[o,l]of Object.entries(t.definition.actions??{})){let d=l.input.schema.dereference(i),f=l.output.schema.dereference(i),g=t.actions?.[o]?.name??o;n.actions[g]={...l,...t.actions?.[o]??{},input:{schema:d},output:{schema:f}},s.actions[o]={name:g}}for(let[o,l]of Object.entries(t.definition.events??{})){let d=l.schema.dereference(i),f=t.events?.[o]?.name??o;n.events[f]={...l,...t.events?.[o]??{},schema:d},s.events[o]={name:f}}for(let[o,l]of Object.entries(t.definition.channels??{})){let d={};for(let[g,m]of Object.entries(l.messages)){let P=m.schema.dereference(i);d[g]={...m,schema:P}}let f=t.channels?.[o]?.name??o;n.channels[f]={...l,...t.channels?.[o]??{},message:{...l.message??{},tags:{...l.message?.tags??{},...t.channels?.[o]?.message?.tags??{}}},conversation:{...l.conversation??{},tags:{...l.conversation?.tags??{},...t.channels?.[o]?.conversation?.tags??{}}},messages:d},s.channels[o]={name:f}}return{resolved:n,statement:s}};var mn=Symbol("schemaName"),Wd=t=>t?M.mapValues(t,(r,n)=>({...r,[mn]:n})):{},Ld=t=>mn in t&&t[mn]!==void 0,qd=t=>t[mn];var yn=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.readme=e.readme,this.title=e.title,this.identifier=e.identifier,this.description=e.description,this.configuration=e.configuration,this.configurations=e.configurations,this.events=e.events,this.actions=e.actions,this.channels=e.channels,this.states=e.states,this.user=e.user,this.secrets=e.secrets,this.entities=e.entities,this.interfaces=e.interfaces,this.__advanced=e.__advanced,this.attributes=e.attributes}name;version;title;description;icon;readme;configuration;configurations;events;actions;channels;states;user;secrets;identifier;entities;interfaces;__advanced;attributes;extend(e,r){let{entities:n,actions:s,events:i,channels:o}=this._callBuilder(e,r),l=this;l.interfaces??={};let d=Object.values(n).map(P=>P.name),f=d.length===0?e.name:`${e.name}<${d.join(",")}>`,{resolved:g,statement:m}=Fd({...e,entities:n,actions:M.stripUndefinedProps(s),events:M.stripUndefinedProps(i),channels:M.stripUndefinedProps(o)});return l.actions=M.mergeRecords(l.actions??{},g.actions,this._mergeActions),l.channels=M.mergeRecords(l.channels??{},g.channels,this._mergeChannels),l.events=M.mergeRecords(l.events??{},g.events,this._mergeEvents),l.interfaces[f]={id:e.id,...m},this}_callBuilder(e,r){let s={entities:Wd(this.entities)},i=r(s),o=M.pairs(i.entities).find(([d,f])=>!Ld(f));if(o)throw new Error(`Cannot extend interface "${e.name}" with entity "${o[0]}"; the provided schema is not part of the integration's entities.`);return{entities:M.mapValues(i.entities,d=>({name:qd(d),schema:d.schema})),actions:i.actions??{},events:i.events??{},channels:i.channels??{}}}_mergeActions=(e,r)=>({...e,...r,input:{schema:ut(e.input.schema,r.input.schema)},output:{schema:ut(e.output.schema,r.output.schema)}});_mergeEvents=(e,r)=>({...e,...r,schema:ut(e.schema,r.schema)});_mergeChannels=(e,r)=>{let n=M.mergeRecords(e.messages,r.messages,this._mergeMessage),s;(e.conversation||r.conversation)&&(s={tags:{...e.conversation?.tags,...r.conversation?.tags}});let i;return(e.message||r.message)&&(i={tags:{...e.message?.tags,...r.message?.tags}}),{...e,...r,messages:n,conversation:s,message:i}};_mergeMessage=(e,r)=>({schema:ut(e.schema,r.schema)})};var _e=require("@botpress/client");var Vd=Ls(require("@botpress/client")),vn={retries:3,retryCondition:t=>Vd.axiosRetry.isNetworkOrIdempotentRequestError(t)||[429,502].includes(t.response?.status??0),retryDelay:(t,e)=>(Ty(e.response?.headers??{})??t)*1e3},Ty=t=>{let e=["RateLimit-Reset","X-RateLimit-Reset","Retry-After","ratelimit-reset","x-ratelimit-reset","retry-after"];for(let r of e){let n=t[r];if(n!==void 0)return by(String(n))}},by=t=>{let e=wy(t)?Py(t):t.length>0?parseInt(t,10):void 0;return e===void 0||isNaN(e)?void 0:e},wy=t=>t.includes(" "),Py=t=>{let e=xy(t);if(!e)return;let r=new Date;return Math.max(0,Math.floor((e.getTime()-r.getTime())/1e3))},xy=t=>{let e=new Date(t);return isNaN(e.getTime())?void 0:e};var pt=class{constructor(e){this._client=e}get _inner(){return this._client}createConversation=(e=>this._client.createConversation(e));getConversation=(e=>this._client.getConversation(e));listConversations=(e=>this._client.listConversations(e));getOrCreateConversation=(e=>this._client.getOrCreateConversation(e));updateConversation=(e=>this._client.updateConversation(e));deleteConversation=(e=>this._client.deleteConversation(e));listParticipants=(e=>this._client.listParticipants(e));addParticipant=(e=>this._client.addParticipant(e));getParticipant=(e=>this._client.getParticipant(e));removeParticipant=(e=>this._client.removeParticipant(e));createEvent=(e=>this._client.createEvent(e));getEvent=(e=>this._client.getEvent(e));listEvents=(e=>this._client.listEvents(e));createMessage=(e=>this._client.createMessage(e));getOrCreateMessage=(e=>this._client.getOrCreateMessage(e));getMessage=(e=>this._client.getMessage(e).then(r=>r));updateMessage=(e=>this._client.updateMessage(e).then(r=>r));listMessages=(e=>this._client.listMessages(e));deleteMessage=(e=>this._client.deleteMessage(e));createUser=(e=>this._client.createUser(e));getUser=(e=>this._client.getUser(e));listUsers=e=>this._client.listUsers(e);getOrCreateUser=(e=>this._client.getOrCreateUser(e));updateUser=(e=>this._client.updateUser(e));deleteUser=e=>this._client.deleteUser(e);getState=(e=>this._client.getState(e));setState=(e=>this._client.setState(e));getOrSetState=(e=>this._client.getOrSetState(e));patchState=(e=>this._client.patchState(e));configureIntegration=e=>this._client.configureIntegration(e);uploadFile=e=>this._client.uploadFile(e);upsertFile=e=>this._client.upsertFile(e);deleteFile=e=>this._client.deleteFile(e);listFiles=e=>this._client.listFiles(e);getFile=e=>this._client.getFile(e);updateFileMetadata=e=>this._client.updateFileMetadata(e);trackAnalytics=e=>this._client.trackAnalytics(e)};var _n=class{_cost=0;get cost(){return this._cost}setCost(e){this._cost=e}toJSON(){return{cost:this.cost}}};var xe="#";var Wv=y.enum(["webhook_received","message_created","action_triggered","register","unregister","ping","create_user","create_conversation"]),Gd=t=>{let e=t[Lt],r=t[Rs],n=t[Hs],s=t[Ds],i=t[Ms],o=t[qt],l=t[Vt];if(!e)throw new Error("Missing bot headers");if(!r)throw new Error("Missing bot user headers");if(!n)throw new Error("Missing integration headers");if(!s)throw new Error("Missing webhook headers");if(!o)throw new Error("Missing configuration headers");if(!l)throw new Error("Missing operation headers");return{botId:e,botUserId:r,integrationId:n,webhookId:s,operation:l,configurationType:i??null,configuration:o?JSON.parse(Buffer.from(o,"base64").toString("utf-8")):{}}};var Jd=Ls(require("util")),ft=class{defaultOptions;constructor(e){this.defaultOptions=e}info(...e){this._log("info",e)}debug(...e){this._log("debug",e)}warn(...e){this._log("warn",e)}error(...e){this._log("error",e)}_log(e,r){this._getConsoleMethod(e)(this._serializeMessage(r))}_serializeMessage(e){let r=Jd.default.format(...e);return process.env.BP_LOG_FORMAT==="json"?this.getJsonMessage(r):r}getJsonMessage(e){return JSON.stringify({msg:e,options:this.defaultOptions})}_getConsoleMethod(e){switch(e){case"debug":return console.debug;case"warn":return console.warn;case"error":return console.error;default:return console.info}}};var gt=class t extends ft{constructor(e){super({visibleToBotOwners:!0,...e})}with(e){return new t({...this.defaultOptions,...e})}withUserId(e){return this.with({userId:e})}withConversationId(e){return this.with({conversationId:e})}withVisibleToBotOwners(e){return this.with({visibleToBotOwners:e})}forBot(){return this.withVisibleToBotOwners(!0)}getJsonMessage(e){return JSON.stringify({msg:e,visible_to_bot_owner:this.defaultOptions.visibleToBotOwners,options:this.defaultOptions})}};var ky=t=>["traceparent","tracestate","sentry-trace"].reduce((e,r)=>(t[r]&&(e[r]=t[r]),e),{}),Sy=(t,e,r)=>{let[,n]=(e.headers.traceparent||"").split("-"),s=new _e.Client({botId:t.botId,integrationId:t.integrationId,retry:vn,headers:ky(e.headers)}),i=new pt(s),o=new gt({traceId:n});return{ctx:t,req:e,client:i,logger:o,instance:r}},Oy=async t=>{let{ctx:e}=t;switch(e.operation){case"webhook_received":return await Zy(t);case"register":return await Iy(t);case"unregister":return await By(t);case"message_created":return await Ry(t);case"action_triggered":return await Hy(t);case"ping":return await Ey(t);case"create_user":return await Cy(t);case"create_conversation":return await Ay(t);default:throw new _e.InvalidPayloadError(`Unknown operation ${e.operation}`)}},Xd=t=>async e=>{let r=Gd(e.headers),n=Sy(r,e,t),{logger:s}=n;try{let i;return i=await Dy(n),i?{...i,status:i.status??200}:(i=await Oy(n),i?{...i,status:i.status??200}:{status:200})}catch(i){if((0,_e.isApiError)(i)){let l=i.type==="Runtime"?i:new _e.RuntimeError(i.message,i);return s.forBot().error(l.message),{status:l.code,body:JSON.stringify(l.toJSON())}}console.error(i);let o=new _e.RuntimeError("An unexpected error occurred in the integration. Bot owners: Check logs for more informations. Integration owners: throw a RuntimeError to return a custom error message instead.");return s.forBot().error(o.message),{status:o.code,body:JSON.stringify(o.toJSON())}}},Ey=async t=>{},Zy=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{let{req:i}=oe(r);return s.webhook({client:t,ctx:e,req:i,logger:n})},Iy=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.register)return;let{webhookUrl:i}=oe(r);await s.register({client:t,ctx:e,webhookUrl:i,logger:n})},By=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.unregister)return;let{webhookUrl:i}=oe(r);await s.unregister({ctx:e,webhookUrl:i,client:t,logger:n})},Cy=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.createUser)return;let{tags:i}=oe(r);return await s.createUser({ctx:e,client:t,tags:i,logger:n})},Ay=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.createConversation)return;let{channel:i,tags:o}=oe(r);return await s.createConversation({ctx:e,client:t,channel:i,tags:o,logger:n})},Ry=async({ctx:t,req:e,client:r,logger:n,instance:s})=>{let{conversation:i,user:o,type:l,payload:d,message:f}=oe(e),g=s.channels[i.channel];if(!g)throw new Error(`Channel ${i.channel} not found`);let m=g.messages[l];if(!m)throw new Error(`Message of type ${l} not found in channel ${i.channel}`);await m({ctx:t,conversation:i,message:f,user:o,type:l,client:r,payload:d,ack:async({tags:E})=>{await r.updateMessage({id:f.id,tags:E})},logger:n})},Hy=async({req:t,ctx:e,client:r,logger:n,instance:s})=>{let{input:i,type:o}=oe(t);if(!o)throw new Error("Missing action type");let l=s.actions[o];if(!l)throw new Error(`Action ${o} not found`);let d=new _n,g={output:await l({ctx:e,input:i,client:r,type:o,logger:n,metadata:d}),meta:d.toJSON()};return{body:JSON.stringify(g)}},Dy=async({instance:t,client:e,ctx:r,logger:n,req:s})=>{let i=t.unknownOperationHandler;if(i)return await i({client:e,ctx:r,logger:n,req:s})};var Tn=class{constructor(e){this.props=e;this.actions=e.actions,this.channels=e.channels,this.register=e.register,this.unregister=e.unregister,this.createUser=e.createUser,this.createConversation=e.createConversation,this.webhook=e.handler,this.unknownOperationHandler=e.__advanced?.unknownOperationHandler}actions;channels;register;unregister;createUser;createConversation;webhook;unknownOperationHandler;handler=Xd(this);start=e=>Gt(this.handler,e)};var bn=class{constructor(e){this.props=e;this.integrations=e.integrations,this.plugins=e.plugins,this.user=e.user,this.conversation=e.conversation,this.message=e.message,this.states=e.states,this.configuration=e.configuration,this.events=e.events,this.recurringEvents=e.recurringEvents,this.actions=e.actions,this.tables=e.tables,this.workflows=e.workflows,this.attributes=e.attributes,this.__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;addIntegration(e,r){let n=this;return n.integrations||(n.integrations={}),n.integrations[e.name]={...e,enabled:r?.enabled,configurationType:r?.configurationType,configuration:r?.configuration,disabledChannels:r?.disabledChannels},this}addPlugin(e,r){let n=this;n.plugins||(n.plugins={});let s=r.alias??e.name.replace("/","-");return n.plugins[s]={...e,alias:s,configuration:r.configuration,interfaces:r.interfaces},n.withPlugins.user=this._mergeUser(n.withPlugins.user,e.definition.user),n.withPlugins.conversation=this._mergeConversation(n.withPlugins.conversation,e.definition.conversation),n.withPlugins.message=this._mergeMessage(n.withPlugins.message,e.definition.message),n.withPlugins.recurringEvents=this._mergeRecurringEvents(n.withPlugins.recurringEvents,e.definition.recurringEvents),n.withPlugins.tables=this._mergeTables(n.withPlugins.tables,e.definition.tables),n.withPlugins.workflows=this._mergeWorkflows(n.withPlugins.workflows,e.definition.workflows),n.withPlugins.states=this._mergeStates(n.withPlugins.states,this._prefixKeysWithPluginAlias(e.definition.states,s)),n.withPlugins.events=this._mergeEvents(n.withPlugins.events,this._prefixKeysWithPluginAlias(e.definition.events,s)),n.withPlugins.actions=this._mergeActions(n.withPlugins.actions,this._prefixKeysWithPluginAlias(e.definition.actions,s)),this}_mergeUser=(e,r)=>({tags:{...e?.tags,...r?.tags}});_mergeConversation=(e,r)=>({tags:{...e?.tags,...r?.tags}});_mergeMessage=(e,r)=>({tags:{...e?.tags,...r?.tags}});_mergeStates=(e,r)=>({...e,...r});_mergeEvents=(e,r)=>({...e,...r});_mergeRecurringEvents=(e,r)=>({...e,...r});_mergeActions=(e,r)=>({...e,...r});_mergeTables=(e,r)=>({...e,...r});_mergeWorkflows=(e,r)=>({...e,...r});_prefixKeysWithPluginAlias=(e,r)=>M.mapKeys(e??{},n=>`${r}${xe}${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 f=Object.entries(l.entities??{});for(let[g,{name:m}]of f){let P=d.definition.entities?.[m]?.schema;if(!P)throw new Error(`Interface entity "${m}" does not exist in integration "${d.name}"`);e[`interface:${o}/entities/${g}`]=P}}}return e}_dereferenceZuiSchema(e,r){return e.dereference(r)}_dereferenceDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,this._dereferenceDefinitionSchema(s,r)]))}_dereferenceDefinitionSchema(e,r){return e&&{...e,schema:this._dereferenceZuiSchema(e.schema,r)}}_dereferenceActionDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,{...s,input:{schema:this._dereferenceZuiSchema(s.input.schema,r)},output:{schema:this._dereferenceZuiSchema(s.output.schema,r)}}]))}};var Ve=require("@botpress/client");var ht=class t extends ft{constructor(e){super({...e})}with(e){return new t({...this.defaultOptions,...e})}withUserId(e){return this.with({userId:e})}withConversationId(e){return this.with({conversationId:e})}withWorkflowId(e){return this.with({workflowId:e})}withEventId(e){return this.with({eventId:e})}withMessageId(e){return this.with({messageId:e})}};var ce=class{constructor(e,r={before:{},after:{}}){this._client=e;this._hooks=r}get _inner(){return this._client}getConversation=(e=>this._run("getConversation",e));listConversations=(e=>this._run("listConversations",e));updateConversation=(e=>this._run("updateConversation",e));deleteConversation=(e=>this._run("deleteConversation",e));listParticipants=(e=>this._run("listParticipants",e));addParticipant=(e=>this._run("addParticipant",e));getParticipant=(e=>this._run("getParticipant",e));removeParticipant=(e=>this._run("removeParticipant",e));createEvent=(e=>this._run("createEvent",e));getEvent=(e=>this._run("getEvent",e));listEvents=(e=>this._run("listEvents",e));createMessage=(e=>this._run("createMessage",e));getOrCreateMessage=(e=>this._run("getOrCreateMessage",e));getMessage=(e=>this._run("getMessage",e));updateMessage=(e=>this._run("updateMessage",e));listMessages=(e=>this._run("listMessages",e));deleteMessage=(e=>this._run("deleteMessage",e));getUser=(e=>this._run("getUser",e));listUsers=(e=>this._run("listUsers",e));updateUser=(e=>this._run("updateUser",e));deleteUser=(e=>this._run("deleteUser",e));getState=(e=>this._run("getState",e));setState=(e=>this._run("setState",e));getOrSetState=(e=>this._run("getOrSetState",e));patchState=(e=>this._run("patchState",e));callAction=(e=>this._run("callAction",e));uploadFile=(e=>this._run("uploadFile",e));upsertFile=(e=>this._run("upsertFile",e));deleteFile=(e=>this._run("deleteFile",e));listFiles=(e=>this._run("listFiles",e));getFile=(e=>this._run("getFile",e));updateFileMetadata=(e=>this._run("updateFileMetadata",e));searchFiles=(e=>this._run("searchFiles",e));trackAnalytics=(e=>this._run("trackAnalytics",e));getTableRow=(e=>this._run("getTableRow",e));createTableRows=(e=>this._run("createTableRows",e));findTableRows=(e=>this._run("findTableRows",e));deleteTableRows=(e=>this._run("deleteTableRows",e));updateTableRows=(e=>this._run("updateTableRows",e));upsertTableRows=(e=>this._run("upsertTableRows",e));createWorkflow=(e=>this._run("createWorkflow",e));getWorkflow=(e=>this._run("getWorkflow",e));updateWorkflow=(e=>this._run("updateWorkflow",e));deleteWorkflow=(e=>this._run("deleteWorkflow",e));listWorkflows=(e=>this._run("listWorkflows",e));createConversation=e=>this._client.createConversation(e);getOrCreateConversation=e=>this._client.getOrCreateConversation(e);createUser=e=>this._client.createUser(e);getOrCreateUser=e=>this._client.getOrCreateUser(e);_run=async(e,r)=>{let n=this._hooks.before[e];n&&(r=await n(r));let s=await this._client[e](r),i=this._hooks.after[e];return i&&(s=await i(s,r)),s}};var mt=t=>new Proxy({},{get:(e,r)=>({listInstances:{all:n=>ke({workflowName:r,client:t,input:n}),running:n=>ke({workflowName:r,client:t,input:n,statuses:["in_progress"]}),scheduled:n=>ke({workflowName:r,client:t,input:n,statuses:["pending","listening"]}),allFinished:n=>ke({workflowName:r,client:t,input:n,statuses:["completed","cancelled","failed","timedout"]}),cancelled:n=>ke({workflowName:r,client:t,input:n,statuses:["cancelled"]}),failed:n=>ke({workflowName:r,client:t,input:n,statuses:["failed"]}),succeeded:n=>ke({workflowName:r,client:t,input:n,statuses:["completed"]}),timedOut:n=>ke({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})}}})}),ke=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 My=y.enum(["event_received","register","unregister","ping","action_triggered"]),Yd=t=>{let e=t[Lt],r=t[qt],n=t[Ns],s=My.parse(t[Vt]);if(!e)throw new Error("Missing bot headers");if(!n)throw new Error("Missing type headers");if(!r)throw new Error("Missing configuration headers");if(!s)throw new Error("Missing operation headers");return{botId:e,operation:s,type:n,configuration:r?JSON.parse(Buffer.from(r,"base64").toString("utf-8")):{}}};var Y={status:200};var Ks=t=>{switch(t){case"workflow_continued":return"continued";case"workflow_started":return"started";case"workflow_timedout":return"timed_out";default:throw new Error(`Unsupported workflow update type: ${t}`)}};var Ny=["child_workflow_deleted","child_workflow_finished","workflow_timedout","workflow_started","workflow_continued"],Qd=async(t,e)=>{if(t.ctx.type!=="workflow_update"||!Ny.includes(e.payload.type))throw new Error("Unexpected event type");let r={...t,logger:$y(t,e)};if(!e.payload.workflow.name)return r.logger.warn("Received workflow update event without a workflow name. Assuming this workflow was not defined by the bot.",e.payload.workflow),Y;switch(e.payload.type){case"child_workflow_deleted":case"child_workflow_finished":r.logger.info(`Received child workflow event "${e.payload.type}", but child workflows are not yet supported`);break;case"workflow_timedout":case"workflow_started":case"workflow_continued":return await jy(r,e);default:e.payload.type}return Y},$y=(t,e)=>t.logger.with({eventId:e.id,workflowId:e.payload.workflow.id,conversationId:e.payload.conversation?.id,userId:e.payload.user?.id}),jy=async(t,e)=>{let r=Ks(e.payload.type),n=t.self.workflowHandlers[r]?.[e.payload.workflow.name];if(!n||n.length===0)return t.logger.warn(`No ${r} handler found for workflow "${e.payload.workflow.name}"`),Y;let{updatedWorkflow:s}=await Ky(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. `),Y},Ky=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)await i({...t,event:e,conversation:e.payload.conversation,user:e.payload.user,workflow:de({...t,workflow:s,event:e,onWorkflowUpdate(o){s=o}}),workflows:mt(t.client)});return{updatedWorkflow:s}};var eu=t=>async e=>{let r=Yd(e.headers),n=new ht,s=new Ve.Client({botId:r.botId,retry:vn}),i=new ce(s,{before:{createMessage:async l=>{let d=t.hookHandlers.before_outgoing_message[l.type]??[];for(let f of d){let g=new ce(s);l=(await f({client:g,ctx:r,logger:n.with({conversationId:l.conversationId,userId:l.userId}),data:l,...Se({client:g})}))?.data??l}return l},callAction:async l=>{let d=t.hookHandlers.before_outgoing_call_action[l.type]??[];for(let f of d){let g=new ce(s);l=(await f({client:g,ctx:r,logger:n,data:l,...Se({client:g})}))?.data??l}return l}},after:{createMessage:async l=>{let d=t.hookHandlers.after_outgoing_message[l.message.type]??[];for(let f of d){let g=new ce(s);l=(await f({client:g,ctx:r,logger:n.with({messageId:l.message.id,conversationId:l.message.conversationId,userId:l.message.userId}),data:l,...Se({client:g})}))?.data??l}return l},callAction:async(l,d)=>{let{type:f}=d,g=t.hookHandlers.after_outgoing_call_action[f]??[];for(let m of g){let P=new ce(s);l=(await m({client:P,ctx:r,logger:n,data:{type:f,...l},...Se({client:P})}))?.data??l}return l}}}),o={req:e,ctx:r,logger:n,client:i,self:t};try{switch(r.operation){case"action_triggered":return await Ly(o);case"event_received":return await Wy(o);case"register":return await zy(o);case"unregister":return await Fy(o);case"ping":return await Uy(o);default:throw new Error(`Unknown operation ${r.operation}`)}}catch(l){let d=l instanceof Error?l:new Error(String(l));if((0,Ve.isApiError)(d)){let g=d.type==="Runtime"?d:new Ve.RuntimeError(d.message,d);return n.error(g.message),{status:g.code,body:JSON.stringify(g.toJSON())}}let f=new Ve.RuntimeError("An unexpected error occurred in the bot.",d);return n.error(f.message,d),{status:f.code,body:JSON.stringify(f.toJSON())}}},Uy=async t=>Y,zy=async t=>Y,Fy=async t=>Y,Wy=async t=>{let{ctx:e,logger:r,req:n,client:s,self:i}=t,o={client:s,ctx:e,logger:r,...Se({client:s})},l=oe(n);if(o.logger=o.logger.with({eventId:l.event.id,messageId:l.event.messageId,conversationId:l.event.conversationId,userId:l.event.userId}),e.type==="workflow_update")return await Qd(t,l.event);if(e.type==="message_created"){let E=l.event,I=E.payload.message;o.logger=o.logger.with({messageId:I.id,conversationId:I.conversationId,userId:I.userId});let U=i.hookHandlers.before_incoming_message[I.type]??[];for(let q of U){let se=await q({...o,data:I});if(I=se?.data??I,se?.stop)return Y}let L={...o,user:E.payload.user,conversation:E.payload.conversation,message:I,event:E},Q=i.messageHandlers[I.type]??[];for(let q of Q)await q(L);let ie=i.hookHandlers.after_incoming_message[I.type]??[];for(let q of ie){let se=await q({...o,data:I});if(I=se?.data??I,se?.stop)return Y}return Y}if(e.type==="state_expired"){let I=l.event.payload.state,U={...o,state:I},L=i.stateExpiredHandlers[I.name]??[];for(let Q of L)await Q(U);return Y}let d=l.event,f=i.hookHandlers.before_incoming_event[d.type]??[];for(let E of f){let I=await E({...o,data:d});if(d=I?.data??d,I?.stop)return Y}let g={...o,event:d},m=i.eventHandlers[d.type]??[];for(let E of m)await E(g);let P=i.hookHandlers.after_incoming_event[d.type]??[];for(let E of P){let I=await E({...o,data:d});if(d=I?.data??d,I?.stop)return Y}return Y},Ly=async({ctx:t,logger:e,req:r,client:n,self:s})=>{let{input:i,type:o}=oe(r);if(!o)throw new Error("Missing action type");let l=s.hookHandlers.before_incoming_call_action[o]??[];for(let P of l){let E=await P({ctx:t,logger:e,client:n,data:{type:o,input:i},...Se({client:n})});i=E?.data?.input??i,o=E?.data?.type??o}let d=s.actionHandlers[o];if(!d)throw new Error(`Action ${o} not found`);let f=await d({ctx:t,logger:e,input:i,client:n,type:o,...Se({client:n})}),g=s.hookHandlers.after_incoming_call_action[o]??[];for(let P of g){let E=await P({ctx:t,logger:e,client:n,data:{type:o,output:f},...Se({client:n})});o=E?.data?.type??o,f=E?.data?.output??f}return{status:200,body:JSON.stringify({output:f})}},Se=t=>({workflows:mt(t.client)});var wn=class{constructor(e){this.props=e;this._actionHandlers=e.actions,this._plugins=e.plugins}_actionHandlers;_messageHandlers={};_eventHandlers={};_stateExpiredHandlers={};_hookHandlers={before_incoming_event:{},before_incoming_message:{},before_outgoing_message:{},before_outgoing_call_action:{},before_incoming_call_action:{},after_incoming_event:{},after_incoming_message:{},after_outgoing_message:{},after_outgoing_call_action:{},after_incoming_call_action:{}};_workflowHandlers={started:{},continued:{},timed_out:{}};_plugins={};_registerOrder=0;get actionHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._actionHandlers[r];if(n)return n;for(let[s,i]of Object.entries(this._plugins)){let[o,l]=r.split(xe);if(!(o!==s||!l)&&(n=i.actionHandlers[l],n))return n}}})}get messageHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.messageHandlers[r]??[]),s=this._messageHandlers[r]??[],i=this._messageHandlers["*"]??[],o=[...s,...i].sort((l,d)=>l.order-d.order).map(({handler:l})=>l);return S.unique([...n,...o])}})}get eventHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.eventHandlers[r]??[]),s=this._eventHandlers[r]??[],i=this._eventHandlers["*"]??[],o=[...s,...i].sort((l,d)=>l.order-d.order).map(({handler:l})=>l);return S.unique([...n,...o])}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.stateExpiredHandlers[r]??[]),s=this._stateExpiredHandlers[r]??[],i=this._stateExpiredHandlers["*"]??[],o=[...s,...i].sort((l,d)=>l.order-d.order).map(({handler:l})=>l);return S.unique([...n,...o])}})}get hookHandlers(){return new Proxy({},{get:(e,r)=>{if(this._hookHandlers[r])return new Proxy({},{get:(s,i)=>{let o=Object.values(this._plugins).flatMap(m=>m.hookHandlers[r]?.[i]??[]),l=this._hookHandlers[r]??{},d=l[i]??[],f=l["*"]??[],g=[...d,...f].sort((m,P)=>m.order-P.order).map(({handler:m})=>m);return S.unique([...o,...g])}})}})}get workflowHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._workflowHandlers[r];if(n)return new Proxy({},{get:(s,i)=>{let o=n[i]?.sort((d,f)=>d.order-f.order).map(({handler:d})=>d)??[],l=Object.values(this._plugins).flatMap(d=>d.workflowHandlers[r]?.[i]??[]);return S.unique([...o,...l])}})}})}on={message:(e,r)=>{this._messageHandlers[e]=S.safePush(this._messageHandlers[e],{handler:r,order:this._registerOrder++})},event:(e,r)=>{this._eventHandlers[e]=S.safePush(this._eventHandlers[e],{handler:r,order:this._registerOrder++})},stateExpired:(e,r)=>{this._stateExpiredHandlers[e]=S.safePush(this._stateExpiredHandlers[e],{handler:r,order:this._registerOrder++})},beforeIncomingEvent:(e,r)=>{this._hookHandlers.before_incoming_event[e]=S.safePush(this._hookHandlers.before_incoming_event[e],{handler:r,order:this._registerOrder++})},beforeIncomingMessage:(e,r)=>{this._hookHandlers.before_incoming_message[e]=S.safePush(this._hookHandlers.before_incoming_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingMessage:(e,r)=>{this._hookHandlers.before_outgoing_message[e]=S.safePush(this._hookHandlers.before_outgoing_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingCallAction:(e,r)=>{this._hookHandlers.before_outgoing_call_action[e]=S.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},beforeIncomingCallAction:(e,r)=>{this._hookHandlers.before_incoming_call_action[e]=S.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingEvent:(e,r)=>{this._hookHandlers.after_incoming_event[e]=S.safePush(this._hookHandlers.after_incoming_event[e],{handler:r,order:this._registerOrder++})},afterIncomingMessage:(e,r)=>{this._hookHandlers.after_incoming_message[e]=S.safePush(this._hookHandlers.after_incoming_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingMessage:(e,r)=>{this._hookHandlers.after_outgoing_message[e]=S.safePush(this._hookHandlers.after_outgoing_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingCallAction:(e,r)=>{this._hookHandlers.after_outgoing_call_action[e]=S.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingCallAction:(e,r)=>{this._hookHandlers.after_incoming_call_action[e]=S.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:r,order:this._registerOrder++})},workflowStart:(e,r)=>{this._workflowHandlers.started[e]=S.safePush(this._workflowHandlers.started[e],{handler:r,order:this._registerOrder++})},workflowContinue:(e,r)=>{this._workflowHandlers.continued[e]=S.safePush(this._workflowHandlers.continued[e],{handler:r,order:this._registerOrder++})},workflowTimeout:(e,r)=>{this._workflowHandlers.timed_out[e]=S.safePush(this._workflowHandlers.timed_out[e],{handler:r,order:this._registerOrder++})}};handler=eu(this);start=e=>Gt(this.handler,e)};var Pn=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.title=e.title,this.description=e.description,this.readme=e.readme,this.entities=e.entities??{},this.attributes=e.attributes,this.__advanced=e.__advanced;let r=this._getEntityReference(this.entities),n=e.events===void 0?{}:M.mapValues(e.events,o=>({...o,schema:o.schema(r)})),s=e.actions===void 0?{}:M.mapValues(e.actions,o=>({...o,input:{...o.input,schema:o.input.schema(r)},output:{...o.output,schema:o.output.schema(r)}})),i=e.channels===void 0?{}:M.mapValues(e.channels,o=>({...o,messages:M.mapValues(o.messages,l=>({...l,schema:l.schema(r)}))}));this.events=n,this.actions=s,this.channels=i}name;version;title;description;icon;readme;attributes;entities;events;actions;channels;__advanced;_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=Ad.ref(n);i&&l.title(i),o&&l.describe(o),r[n]=l}return r}};var xn=class{constructor(e){this.props=e;let r=Object.fromEntries(Object.entries(e.interfaces??{}).map(([n,s])=>[n,Object.fromEntries(Object.entries(s.definition.entities??{}).map(([i])=>[i,y.ref(`interface:${n}/entities/${i}`)]))]));this.name=e.name,this.version=e.version,this.icon=e.icon,this.readme=e.readme,this.title=e.title,this.description=e.description,this.integrations=e.integrations,this.interfaces=e.interfaces,this.user=e.user,this.conversation=e.conversation,this.message=e.message,this.recurringEvents=e.recurringEvents,this.workflows=e.workflows,this.attributes=e.attributes,this.__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;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 tu=t=>{let[e,r]=t.split(Us);return!e||!r?null:{namespace:e,eventName:r}},ru=t=>`${t.namespace}${Us}${t.actionName}`,nu=t=>`${t.namespace}${Us}${t.eventName}`,su=(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}},iu=(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 au=(t,e)=>new Proxy({},{get:(r,n)=>new Proxy({},{get:(s,i)=>o=>qy({client:t,interfaces:e.interfaces,integrationOrInterfaceName:n,methodName:i,input:o})})}),qy=async({client:t,interfaces:e,integrationOrInterfaceName:r,methodName:n,input:s})=>{let i=su({namespace:r,actionName:n},e),o=ru(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})}},ou=(t,e)=>new Proxy({},{get:(r,n)=>{let s=e.alias!==void 0?`${e.alias}${xe}${n}`:n;return new zs({client:t,eventName:s})}});var Fs=class{constructor(e,r,n){this._client=e;this._stateType=r;this._stateName=n}async get(e){return await this._client.getState({type:this._stateType,name:this._stateName,id:e}).then(r=>r.state.payload)}async set(e,r){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:r})}async getOrSet(e,r){return await this._client.getOrSetState({type:this._stateType,name:this._stateName,id:e,payload:r}).then(n=>n.state.payload)}async delete(e){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:null})}async patch(e,r){await this._client.patchState({type:this._stateType,name:this._stateName,id:e,payload:r})}},lu=(t,e)=>new Proxy({},{get:(r,n)=>new Proxy({},{get:(s,i)=>{let o=e.alias!==void 0?`${e.alias}${xe}${i}`:i;return new Fs(t,n,o)}})});var kn=class{constructor(e){this.props=e;this._actionHandlers=e.actions}_runtimeProps;_actionHandlers;_messageHandlers={};_eventHandlers={};_stateExpiredHandlers={};_hookHandlers={before_incoming_event:{},before_incoming_message:{},before_outgoing_message:{},before_outgoing_call_action:{},before_incoming_call_action:{},after_incoming_event:{},after_incoming_message:{},after_outgoing_message:{},after_outgoing_call_action:{},after_incoming_call_action:{}};_workflowHandlers={started:{},continued:{},timed_out:{}};_registerOrder=0;initialize(e){return this._runtimeProps=e,this}get _runtime(){if(!this._runtimeProps)throw new Error("Plugin not correctly initialized. This is likely because you access your plugin config outside of an handler.");return this._runtimeProps}_getTools(e){let{configuration:r,interfaces:n,alias:s}=this._runtime,i=au(e,this._runtime),o=lu(e,this._runtime),l=mt(e),d=ou(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 ve.setName(s=>n({...s,...this._getTools(s.client)}),n.name)}})}get messageHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._messageHandlers[r]??[],s=this._messageHandlers["*"]??[];return S.unique([...n,...s]).sort((o,l)=>o.order-l.order).map(({handler:o})=>ve.setName(l=>o({...l,...this._getTools(l.client)}),o.name))}})}get eventHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._eventHandlers[r]??[],s=Object.entries(this._eventHandlers).filter(([l])=>this._eventResolvesTo(l,r)).flatMap(([,l])=>l??[]),i=this._eventHandlers["*"]??[];return S.unique([...n,...s,...i]).sort((l,d)=>l.order-d.order).map(({handler:l})=>ve.setName(d=>l({...d,...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 S.unique([...n,...s]).sort((o,l)=>o.order-l.order).map(({handler:o})=>ve.setName(l=>o({...l,...this._getTools(l.client)}),o.name))}})}get hookHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._hookHandlers[r];if(n)return new Proxy({},{get:(s,i)=>{i=this._stripAliasPrefix(i);let o=n[i]??[],l=Object.entries(n).filter(([g])=>this._eventResolvesTo(g,i)).flatMap(([,g])=>g??[]),d=n["*"]??[];return S.unique([...o,...l,...d]).sort((g,m)=>g.order-m.order).map(({handler:g})=>ve.setName(m=>g({...m,...this._getTools(m.client)}),g.name))}})}})}get workflowHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._workflowHandlers[r];if(n)return new Proxy({},{get:(s,i)=>(n[i]?.sort((l,d)=>l.order-d.order)??[]).map(({handler:l})=>ve.setName(d=>l({...d,...this._getTools(d.client)}),l.name))})}})}on={message:(e,r)=>{this._messageHandlers[e]=S.safePush(this._messageHandlers[e],{handler:r,order:this._registerOrder++})},event:(e,r)=>{this._eventHandlers[e]=S.safePush(this._eventHandlers[e],{handler:r,order:this._registerOrder++})},stateExpired:(e,r)=>{this._stateExpiredHandlers[e]=S.safePush(this._stateExpiredHandlers[e],{handler:r,order:this._registerOrder++})},beforeIncomingEvent:(e,r)=>{this._hookHandlers.before_incoming_event[e]=S.safePush(this._hookHandlers.before_incoming_event[e],{handler:r,order:this._registerOrder++})},beforeIncomingMessage:(e,r)=>{this._hookHandlers.before_incoming_message[e]=S.safePush(this._hookHandlers.before_incoming_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingMessage:(e,r)=>{this._hookHandlers.before_outgoing_message[e]=S.safePush(this._hookHandlers.before_outgoing_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingCallAction:(e,r)=>{this._hookHandlers.before_outgoing_call_action[e]=S.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},beforeIncomingCallAction:(e,r)=>{this._hookHandlers.before_incoming_call_action[e]=S.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingEvent:(e,r)=>{this._hookHandlers.after_incoming_event[e]=S.safePush(this._hookHandlers.after_incoming_event[e],{handler:r,order:this._registerOrder++})},afterIncomingMessage:(e,r)=>{this._hookHandlers.after_incoming_message[e]=S.safePush(this._hookHandlers.after_incoming_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingMessage:(e,r)=>{this._hookHandlers.after_outgoing_message[e]=S.safePush(this._hookHandlers.after_outgoing_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingCallAction:(e,r)=>{this._hookHandlers.after_outgoing_call_action[e]=S.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingCallAction:(e,r)=>{this._hookHandlers.after_incoming_call_action[e]=S.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:r,order:this._registerOrder++})},workflowStart:(e,r)=>{this._workflowHandlers.started[e]=S.safePush(this._workflowHandlers.started[e],{handler:r,order:this._registerOrder++})},workflowContinue:(e,r)=>{this._workflowHandlers.continued[e]=S.safePush(this._workflowHandlers.continued[e],{handler:r,order:this._registerOrder++})},workflowTimeout:(e,r)=>{this._workflowHandlers.timed_out[e]=S.safePush(this._workflowHandlers.timed_out[e],{handler:r,order:this._registerOrder++})}};_eventResolvesTo=(e,r)=>{let n=tu(e);if(!n)return!1;let s=iu(n,this._runtime.interfaces);return nu(s)===r};_stripAliasPrefix=e=>{let{alias:r}=this._runtime;if(!r)return e;let n=`${r}#`;return e.startsWith(n)?e.slice(n.length):e}};0&&(module.exports={BRAND,Bot,BotDefinition,BotLogger,BotSpecificClient,DIRTY,EMPTY_PATH,INVALID,Integration,IntegrationDefinition,IntegrationLogger,IntegrationSpecificClient,InterfaceDefinition,NEVER,OK,ParseInputLazyPath,ParseStatus,Plugin,PluginDefinition,RuntimeError,Schema,WELL_KNOWN_ATTRIBUTES,ZodAny,ZodArray,ZodBigInt,ZodBoolean,ZodBranded,ZodCatch,ZodDate,ZodDefault,ZodDiscriminatedUnion,ZodEffects,ZodEnum,ZodError,ZodFirstPartyTypeKind,ZodFunction,ZodIntersection,ZodIssueCode,ZodLazy,ZodLiteral,ZodMap,ZodNaN,ZodNativeEnum,ZodNever,ZodNull,ZodNullable,ZodNumber,ZodObject,ZodOptional,ZodParsedType,ZodPipeline,ZodPromise,ZodReadonly,ZodRecord,ZodRef,ZodSchema,ZodSet,ZodString,ZodSymbol,ZodTransformer,ZodTuple,ZodType,ZodUndefined,ZodUnion,ZodUnknown,ZodVoid,addIssueToContext,agent,aimodel,any,array,bigint,boolean,botIdHeader,botUserIdHeader,coerce,configurationHeader,configurationTypeHeader,conversation,createZodEnum,cuid2Regex,cuidRegex,custom,datasource,date,discriminatedUnion,effect,emailRegex,enum:null,errorUtil,event,function:null,getErrorMap,getParsedType,instanceof:null,integrationIdHeader,intent,intersection,ipv4Regex,ipv6Regex,isAborted,isApiError,isAsync,isDirty,isEmojiRegex,isValid,knowledgebase,late,lazy,literal,makeIssue,map,mergeObjectSchemas,message,messages,nan,nativeEnum,never,null:null,nullable,number,object,objectUtil,oboolean,onumber,operationHeader,optional,ostring,parseBody,pipeline,preprocess,processCreateParams,promise,quotelessJson,readonly,record,ref,serve,set,setErrorMap,strictObject,string,symbol,table,tablerow,transformer,transforms,tuple,typeHeader,ulidRegex,undefined,union,unknown,user,util,uuidRegex,variable,void:null,webhookIdHeader,z});
|
|
67
|
+
`,s+="})"}let i=r?s?r+s:n?n==="z.never()"?r+".strict()":r+`.catchall(${n})`:r:s||(n?`z.record(${n})`:"z.record(z.any())");return j.an.anyOf(t)&&(i+=`.and(${Qc(p(c({},t),{anyOf:t.anyOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?p(c({},o),{type:"object"}):o)}),e)})`),j.a.oneOf(t)&&(i+=`.and(${Bs(p(c({},t),{oneOf:t.oneOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?p(c({},o),{type:"object"}):o)}),e)})`),j.an.allOf(t)&&(i+=`.and(${jt(p(c({},t),{allOf:t.allOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?p(c({},o),{type:"object"}):o)}),e)})`),i}a(ed,"parseObject");var Tm=a(t=>{var e;let r="z.string()";if((e=t[b])!=null&&e.coerce){if(t.format==="date-time")return"z.coerce.date()";r="z.coerce.string()"}return r+=G(t,"format",({value:n})=>{switch(n){case"email":return[".email(",")"];case"ip":return[".ip(",")"];case"ipv4":return['.ip({ version: "v4"',", message: "," })"];case"ipv6":return['.ip({ version: "v6"',", message: "," })"];case"uri":return[".url(",")"];case"uuid":return[".uuid(",")"];case"date-time":return[".datetime(",")"]}}),r+=G(t,"pattern",({json:n})=>[`.regex(new RegExp(${n})`,", ",")"]),r+=G(t,"minLength",({json:n})=>[`.min(${n}`,", ",")"]),r+=G(t,"maxLength",({json:n})=>[`.max(${n}`,", ",")"]),r},"parseString"),bm=a((t,e)=>`${W(fm(t,"nullable"),e,!0)}.nullable()`,"parseNullable"),wm=a(t=>`z.ref('${t.$ref}')`,"parseRef"),Pm=a((t,e)=>{var r,n;if(t.oneOf.length<=1||!((r=t.discriminator)!=null&&r.propertyName))return Bs(t,e);let s=t.oneOf.map((i,o)=>W(i,p(c({},e),{path:[...e.path,"oneOf",o]})));return`z.discriminatedUnion("${(n=t.discriminator)==null?void 0:n.propertyName}", [${s.join(", ")}])`},"parseDiscriminator"),W=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=Sm(t,e);return r||(s=xm(t,s),e.withoutDefaults||(s=km(t,s))),n.r=s,s},"parseSchema"),xm=a((t,e)=>(t.description&&(e+=`.describe(${JSON.stringify(t.description)})`),e),"addMeta"),km=a((t,e)=>(t.default!==void 0&&(e+=`.default(${JSON.stringify(t.default)})`),e),"addDefaults"),Sm=a((t,e)=>j.a.nullable(t)?bm(t,e):j.an.object(t)?ed(t,e):j.an.array(t)?hm(t,e):j.an.anyOf(t)?Qc(t,e):j.an.allOf(t)?jt(t,e):j.a.discriminator(t)?Pm(t,e):j.a.oneOf(t)?Bs(t,e):j.a.not(t)?dm(t,e):j.an.enum(t)?ym(t):j.a.const(t)?mm(t):j.a.multipleType(t)?cm(t,e):j.a.primitive(t,"string")?Tm(t):j.a.primitive(t,"number")||j.a.primitive(t,"integer")?_m(t):j.a.primitive(t,"boolean")?om(t):j.a.primitive(t,"null")?um(t):j.a.conditional(t)?vm(t,e):j.a.ref(t)?wm(t):lm(t),"selectParser"),j={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")}},Em=a(t=>{let e;try{e=new Function("z",`return ${t}`)(u)}catch(r){return{sucess:!1,error:`Failed to evaluate schema: ${(r instanceof Error?r:new Error(String(r))).message}`}}return e instanceof u.ZodType?{sucess:!0,value:e}:{sucess:!1,error:`String "${t}" does not evaluate to a Zod schema`}},"evalZuiString"),Om=a(t=>W(t,{seen:new Map,path:[]}),"jsonSchemaToZodStr"),Zm=a(t=>{let e=Om(t);e=e.replaceAll("errors: z.ZodError[]","errors");let r=Em(e);if(!r.sucess)throw new Ur(r.error);return r.value},"jsonSchemaToZod"),Bt=a((t,e)=>{var r,n;if(e[b]&&t._def&&(t._def[b]=e[b]),((r=t._def)==null?void 0:r.typeName)==="ZodObject"&&e.type==="object"&&e.properties&&Object.entries(e.properties).forEach(([s,i])=>{let o=typeof t._def.shape=="function"?t._def.shape():t._def.shape;o[s]&&Bt(o[s],i)}),((n=t._def)==null?void 0:n.typeName)==="ZodRecord"&&e.type==="object"&&e.additionalProperties&&Bt(t._def.valueType,e.additionalProperties),e.type==="array"&&e.items){let s=e.items;if(typeof s=="object"&&!Array.isArray(s)){let i=t._def.type;i&&Bt(i,s)}else Array.isArray(s)&&s.forEach((i,o)=>{let l=t._def;l.typeName===y.ZodFirstPartyTypeKind.ZodTuple&&Bt(l.items[o],i)})}},"applyZuiPropsRecursively"),Im=a(t=>{let e=Zm(t);return Bt(e,t),e},"fromJSONSchemaLegacy"),Bm=a(t=>{var e,r;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(n=>typeof n!="boolean"&&td(n))&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===u.ZodFirstPartyTypeKind.ZodOptional},"isOptionalSchema"),Am=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)===u.ZodFirstPartyTypeKind.ZodNullable},"isNullableSchema"),td=a(t=>{var e,r;return t.not===!0&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===u.ZodFirstPartyTypeKind.ZodUndefined},"isUndefinedSchema"),Rm=a(t=>{var e,r;return!t.not&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===u.ZodFirstPartyTypeKind.ZodUnknown},"isUnknownSchema"),Cm=a(({type:t,minimum:e,exclusiveMinimum:r,maximum:n,exclusiveMaximum:s,multipleOf:i,format:o})=>{let l=u.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"),Hm=a(({format:t,pattern:e,minLength:r,maxLength:n})=>{let s=u.string();if(r&&n&&r===n?s=s.length(r):(r&&(s=s.min(r)),n&&(s=s.max(n))),t==="cuid"||e===$.cuid)s=s.cuid();else if(t==="cuid2"||e===$.cuid2)s=s.cuid2();else if(t==="emoji"||e===$.emoji)s=s.emoji();else if(t==="ulid"||e===$.ulid)s=s.ulid();else if(t==="date-time"){let{precision:i,offset:o}=e?Gh(e):{};s=s.datetime({precision:i,offset:o})}else t==="email"||e===$.email?s=s.email():t==="ipv4"||e===$.ipv4?s=s.ip():t==="ipv6"||e===$.ipv6?s=s.ip("v6"):t==="uri"?s=s.url():t==="uuid"||e===$.uuid?s=s.uuid():e&&(s=s.regex(new RegExp(e)));return s},"stringJSONSchemaToZuiString"),_t=a((t,e)=>{let r=[];e.enum!==void 0&&r.push(...e.enum),e.const!==void 0&&r.push(e.const);let n=r.filter(o=>typeof o===t),[s]=n;if(!s){if(t==="string"&&e.type==="string")return Hm(e);if(t==="number"&&(e.type==="number"||e.type==="integer"))return Cm(e);if(t==="boolean")return u.boolean();if(t==="null")return u.null();throw new Ur(`Unknown primitive type: "${t}"`)}if(n.length===1)return u.literal(s);let i=n.map(o=>u.literal(o));return u.union(i)},"toZuiPrimitive"),Dm=a((t,e)=>Nm(t)?jm(t,e):Mm(t)?$m(t,e):Km(t,e),"arrayJSONSchemaToZuiArray"),Nm=a(t=>Array.isArray(t.items),"_isTuple"),Mm=a(t=>t.items!==void 0&&t.uniqueItems,"_isSet"),jm=a(({items:t,additionalItems:e},r)=>{let n=t.map(r),s=u.tuple(n);return e!==void 0&&(s=s.rest(r(e))),s},"_handleTuple"),$m=a(({items:t,minItems:e,maxItems:r},n)=>{let s=u.set(n(t));return e&&(s=s.min(e)),r&&(s=s.max(r)),s},"_handleSet"),Km=a(({minItems:t,maxItems:e,items:r},n)=>{let s=u.array(n(r));return t&&t===e?s.length(t):(t&&(s=s.min(t)),e&&(s=s.max(e)),s)},"_handleArray"),Ye=u.any();function rd(t){return F(t)}a(rd,"fromJSONSchema");function F(t){var e;if(t===void 0)return Ye;if(t===!0)return u.any();if(t===!1)return u.never();if(t.default!==void 0)return F(p(c({},t),{default:void 0})).default(t.default);if(t.readOnly)return F(p(c({},t),{readOnly:void 0})).readonly();if(t.oneOf!==void 0)throw new we({oneOf:t.oneOf});if(t.patternProperties!==void 0)throw new we({patternProperties:t.patternProperties});if(t.propertyNames!==void 0)throw new we({propertyNames:t.propertyNames});if(t.if!==void 0)throw new we({if:t.if});if(t.then!==void 0)throw new we({then:t.then});if(t.else!==void 0)throw new we({else:t.else});if(t.$ref!==void 0)return u.ref(t.$ref);if(t.not!==void 0){if(td(t))return u.undefined();if(t.not===!0)return u.never();throw new we({not:t.not})}if(Array.isArray(t.type)){if(t.type.length===0)return Ye;if(t.type.length===1)return F(p(c({},t),{type:t.type[0]}));let r=t,{type:n}=r,s=Si(r,["type"]),i=t.type.map(o=>F(p(c({},s),{type:o})));return u.union(i)}if(t.type==="string")return t.enum&&t.enum.length>0?u.enum(t.enum):_t("string",t);if(t.type==="integer"){let r=_t("number",t);return r instanceof u.ZodNumber?r.int():r}if(t.type==="number")return _t("number",t);if(t.type==="boolean")return _t("boolean",t);if(t.type==="null")return _t("null",t);if(t.type==="array")return Dm(t,F);if(t.type==="object"){if(t.additionalProperties!==void 0&&t.properties!==void 0){let r=F(t.additionalProperties);return F(p(c({},t),{additionalProperties:void 0})).catchall(r)}if(t.properties!==void 0){let r={};for(let[n,s]of Object.entries(t.properties)){let i=F(s),o=(e=t.required)!=null?e:[];r[n]=o.includes(n)?i:i.optional()}return u.object(r)}if(t.additionalProperties!==void 0){let r=F(t.additionalProperties);return u.record(r)}return u.record(Ye)}if(t.anyOf!==void 0){if(t.anyOf.length===0)return Ye;if(t.anyOf.length===1)return F(t.anyOf[0]);if(Bm(t))return F(t.anyOf[0]).optional();if(Am(t))return F(t.anyOf[0]).nullable();let r=t.anyOf.map(F);return u.union(r)}if(t.allOf!==void 0){if(t.allOf.length===0)return Ye;if(t.allOf.length===1)return F(t.allOf[0]);let[r,...n]=t.allOf,s=F(r),i=F({allOf:n});return u.intersection(s,i)}return Rm(t)?u.unknown():Ye}a(F,"_fromJSONSchema");var Um=/^\d{4}-\d{2}-\d{2}(T|\s)?((\d{2}:\d{2}:\d{2}(\.\d{1,3})?)|(\d{2}:\d{2}))?(\s?([+-]\d{2}:\d{2}|Z))?$/,Fn=a((t,e,r=!0)=>{if(typeof t!="object")throw new Cn("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]=Um.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(Fn(d[0],e,!1))):["string","number","boolean"].includes(typeof d[0])&&(o[l]=n(y.array(y[typeof d[0]]()))):o[l]=n(Fn(d,e,!1));break;default:throw new Cn(`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 nd(){return{}}a(nd,"parseAnyDef");function sd(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,p(c({},e),{currentPath:[...e.currentPath,"items"]}))),t.minLength&&H(s,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&H(s,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(H(s,"minItems",t.exactLength.value,t.exactLength.message,e),H(s,"maxItems",t.exactLength.value,t.exactLength.message,e)),s}a(sd,"parseArrayDef");function id(t,e){let r=c({type:"integer",format:"int64"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?H(r,"minimum",n.value,n.message,e):H(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),H(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?H(r,"maximum",n.value,n.message,e):H(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),H(r,"maximum",n.value,n.message,e));break;case"multipleOf":H(r,"multipleOf",n.value,n.message,e);break}return r}a(id,"parseBigintDef");function ad(t){return c({type:"boolean"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{})}a(ad,"parseBooleanDef");function od(t,e){return A(t.type._def,e)}a(od,"parseBrandedDef");var zm=a((t,e)=>A(t.innerType._def,e),"parseCatchDef");function ld(t,e){return e.dateStrategy=="integer"?Fm(t,e):c({type:"string",format:"date-time"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{})}a(ld,"parseDateDef");var Fm=a((t,e)=>{let r=c({type:"integer",format:"unix-time"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"&&H(r,"minimum",n.value,n.message,e);break;case"max":e.target==="jsonSchema7"&&H(r,"maximum",n.value,n.message,e);break}return r},"integerDateParser");function cd(t,e){return p(c({},A(t.innerType._def,e)),{default:t.defaultValue()})}a(cd,"parseDefaultDef");function dd(t,e){return e.effectStrategy==="input"?A(t.schema._def,e):{}}a(dd,"parseEffectsDef");function ud(t){return{type:"string",enum:t.values}}a(ud,"parseEnumDef");var Wm=a(t=>"type"in t&&t.type==="string"?!1:"allOf"in t,"isJsonSchema7AllOfType");function pd(t,e){let r=[A(t.left._def,p(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),A(t.right._def,p(c({},e),{currentPath:[...e.currentPath,"allOf","1"]}))].filter(i=>!!i),n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,s=[];return r.forEach(i=>{if(Wm(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=Si(l,["additionalProperties"])}else n=void 0;s.push(o)}}),s.length?c({allOf:s},n):void 0}a(pd,"parseIntersectionDef");function fd(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(fd,"parseLiteralDef");function As(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,f)=>{var g;return p(c({},d),{[f]:(g=A(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"properties",f]})))!=null?g:{}})},{}),additionalProperties:!1};let l={type:"object",additionalProperties:(n=A(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?n:{}};if(e.target==="openApi3")return l;if(((s=t.keyType)==null?void 0:s._def.typeName)==="ZodString"&&((i=t.keyType._def.checks)!=null&&i.length)){let d=Object.entries(as(t.keyType._def,e)).reduce((f,[g,m])=>g==="type"?f:p(c({},f),{[g]:m}),{});return p(c({},l),{propertyNames:d})}else if(((o=t.keyType)==null?void 0:o._def.typeName)==="ZodEnum")return p(c({},l),{propertyNames:{enum:t.keyType._def.values}});return l}a(As,"parseRecordDef");function gd(t,e){if(e.mapStrategy==="record")return As(t,e);let r=A(t.keyType._def,p(c({},e),{currentPath:[...e.currentPath,"items","items","0"]}))||{},n=A(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"items","items","1"]}))||{};return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}a(gd,"parseMapDef");function hd(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(hd,"parseNativeEnumDef");function md(){return{not:{}}}a(md,"parseNeverDef");function yd(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}a(yd,"parseNullDef");var $r={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function vd(t,e){if(e.target==="openApi3")return wi(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in $r&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((s,i)=>{let o=$r[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 wi(t,e)}a(vd,"parseUnionDef");var wi=a((t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((s,i)=>A(s._def,p(c({},e),{currentPath:[...e.currentPath,e.unionStrategy,`${i}`]}))).filter(s=>!!s&&(!e.strictUnions||typeof s=="object"&&Object.keys(s).length>0)),n=e.discriminator&&t.typeName==="ZodDiscriminatedUnion"&&typeof t.discriminator=="string"?{discriminator:{propertyName:t.discriminator}}:{};if(r.length)return e.unionStrategy==="anyOf"?c({anyOf:r},n):c({oneOf:r},n)},"asUnionOf");function _d(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:$r[n._def.typeName],nullable:!0};return Wn(n._def,e,i)}let s={type:[$r[n._def.typeName],"null"]};return Wn(n._def,e,s)}if(e.target==="openApi3"){let n=A(t.innerType._def,p(c({},e),{currentPath:[...e.currentPath]}));return n&&p(c({},n),{nullable:!0})}let r=A(t.innerType._def,p(c({},e),{currentPath:[...e.currentPath,"anyOf","0"]}));return r&&{anyOf:[r,{type:"null"}]}}a(_d,"parseNullableDef");function Td(t,e){let r=c({type:"number"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"int":r.type="integer",is(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?H(r,"minimum",n.value,n.message,e):H(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),H(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?H(r,"maximum",n.value,n.message,e):H(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),H(r,"maximum",n.value,n.message,e));break;case"multipleOf":H(r,"multipleOf",n.value,n.message,e);break}return r}a(Td,"parseNumberDef");var Lm=a((t,e)=>{var r;return t.unknownKeys instanceof E?(r=A(t.unknownKeys._def,p(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?r:!0:t.unknownKeys==="passthrough"},"getAdditionalProperties");function bd(t,e){let r=p(c({type:"object"},Object.entries(t.shape()).reduce((n,[s,i])=>{if(i===void 0||i._def===void 0)return n;let o=A(i._def,p(c({},e),{currentPath:[...e.currentPath,"properties",s],propertyPath:[...e.currentPath,"properties",s]}));return o===void 0?n:{properties:p(c({},n.properties),{[s]:o}),required:i.isOptional()?n.required:[...n.required,s]}},{properties:{},required:[]})),{additionalProperties:Lm(t,e)});return r.required.length||delete r.required,r}a(bd,"parseObjectDef");var qm=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,p(c({},e),{currentPath:[...e.currentPath,"anyOf","1"]}));return n?{anyOf:[{not:{}},n]}:{}},"parseOptionalDef"),Vm=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,p(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),n=A(t.out._def,p(c({},e),{currentPath:[...e.currentPath,"allOf",r?"1":"0"]}));return{allOf:[r,n].filter(s=>s!==void 0)}},"parsePipelineDef");function wd(t,e){return A(t.type._def,e)}a(wd,"parsePromiseDef");function Pd(t,e){let n={type:"array",uniqueItems:!0,items:A(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"items"]}))};return t.minSize&&H(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&H(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}a(Pd,"parseSetDef");function xd(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>A(r._def,p(c({},e),{currentPath:[...e.currentPath,"items",`${n}`]}))).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:A(t.rest._def,p(c({},e),{currentPath:[...e.currentPath,"additionalItems"]}))}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>A(r._def,p(c({},e),{currentPath:[...e.currentPath,"items",`${n}`]}))).reduce((r,n)=>n===void 0?r:[...r,n],[])}}a(xd,"parseTupleDef");function kd(){return{not:{}}}a(kd,"parseUndefinedDef");function Sd(){return{}}a(Sd,"parseUnknownDef");var Gm=a((t,e)=>A(t.innerType._def,e),"parseReadonlyDef");function Ed(t){return{$ref:t.uri}}a(Ed,"parseRefDef");function A(t,e,r=!1){let n=e.seen.get(t);if(n&&!r){let o=Jm(n,e);if(o!==void 0)return o}let s={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,s);let i=Xm(t,t.typeName,e);return i&&Wn(t,e,i),s.jsonSchema=i,i}a(A,"parseDef");var Jm=a((t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Ym(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"),Ym=a((t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")},"getRelativePath"),Xm=a((t,e,r)=>{switch(e){case"ZodString":return as(t,r);case"ZodNumber":return Td(t,r);case"ZodObject":return bd(t,r);case"ZodBigInt":return id(t,r);case"ZodBoolean":return ad(t);case"ZodDate":return ld(t,r);case"ZodUndefined":return kd();case"ZodNull":return yd(r);case"ZodArray":return sd(t,r);case"ZodUnion":case"ZodDiscriminatedUnion":return vd(t,r);case"ZodIntersection":return pd(t,r);case"ZodTuple":return xd(t,r);case"ZodRecord":return As(t,r);case"ZodRef":return Ed(t);case"ZodLiteral":return fd(t,r);case"ZodEnum":return ud(t);case"ZodNativeEnum":return hd(t);case"ZodNullable":return _d(t,r);case"ZodOptional":return qm(t,r);case"ZodMap":return gd(t,r);case"ZodSet":return Pd(t,r);case"ZodLazy":return A(t.getter()._def,r);case"ZodPromise":return wd(t,r);case"ZodNaN":case"ZodNever":return md();case"ZodEffects":return dd(t,r);case"ZodAny":return nd();case"ZodUnknown":return Sd();case"ZodDefault":return cd(t,r);case"ZodBranded":return od(t,r);case"ZodReadonly":return Gm(t,r);case"ZodCatch":return zm(t,r);case"ZodPipeline":return Vm(t,r);case"ZodFunction":case"ZodVoid":case"ZodSymbol":return;default:return(n=>{})(e)}},"selectParser"),Wn=a((t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),Object.assign(r,{[b]:c(c({},t[b]),r[b])}),r),"addMeta"),Pi={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"},Qm=a(t=>typeof t=="string"?p(c({},Pi),{name:t}):c(c({},Pi),t),"getDefaultOptions"),ey=a(t=>{let e=Qm(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return p(c({},e),{currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([n,s])=>[s._def,{def:s._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))})},"getRefs"),ty=a((t,e)=>{var r;let n=ey(e),s=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((d,[f,g])=>{var m;return p(c({},d),{[f]:(m=A(g._def,p(c({},n),{currentPath:[...n.basePath,n.definitionPath,f]}),!0))!=null?m:{}})},{}):void 0,i=typeof e=="string"?e:e?.name,o=(r=A(t._def,i===void 0?n:p(c({},n),{currentPath:[...n.basePath,n.definitionPath,i]}),!1))!=null?r:{},l=i===void 0?s?p(c({},o),{[n.definitionPath]:s}):o:{$ref:[...n.$refStrategy==="relative"?[]:n.basePath,n.definitionPath,i].join("/"),[n.definitionPath]:p(c({},s),{[i]:o})};return n.target==="jsonSchema7"?l.$schema="http://json-schema.org/draft-07/schema#":n.target==="jsonSchema2019-09"&&(l.$schema="https://json-schema.org/draft/2019-09/schema#"),l},"zodToJsonSchema"),ry=a((t,e={target:"openApi3"})=>{let r=ty(t,e);return e.$schemaUrl===!1?delete r.$schema:typeof e.$schemaUrl=="string"&&(r.$schema=e.$schemaUrl),r},"toJSONSchemaLegacy");var pt=(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")},Od=y;var ne=y.string().min(1),Id=y.object({text:ne}),Bd=y.object({markdown:ne}),Ad=y.object({imageUrl:ne}),Rd=y.object({audioUrl:ne}),Cd=y.object({videoUrl:ne}),Hd=y.object({fileUrl:ne,title:ne.optional()}),Dd=y.object({latitude:y.number(),longitude:y.number(),address:y.string().optional(),title:y.string().optional()}),Nd=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}))}),Zd=y.object({text:ne,options:y.array(y.object({label:ne,value:ne}))}),ny=y.object({items:y.array(Nd)}),sy=y.union([y.object({type:y.literal("text"),payload:Id}),y.object({type:y.literal("markdown"),payload:Bd}),y.object({type:y.literal("image"),payload:Ad}),y.object({type:y.literal("audio"),payload:Rd}),y.object({type:y.literal("video"),payload:Cd}),y.object({type:y.literal("file"),payload:Hd}),y.object({type:y.literal("location"),payload:Dd})]),iy=y.object({items:y.array(sy)}),ay={schema:Bd},oy={text:{schema:Id},image:{schema:Ad},audio:{schema:Rd},video:{schema:Cd},file:{schema:Hd},location:{schema:Dd},carousel:{schema:ny},card:{schema:Nd},dropdown:{schema:Zd},choice:{schema:Zd},bloc:{schema:iy}};var ly={HIDDEN_IN_STUDIO:{bpActionHiddenInStudio:"true"},AWAIT_RETURN:{bpActionAwaitReturn:"true"}};var Md=require("browser-or-node");var Cs=console;function le(t){if(!t.body)throw new Error("Missing body");return JSON.parse(t.body)}async function Lt(t,e=8072,r=py){if(!Md.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 cy(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){Cs.error("Error while handling request",{error:l?.message??"Internal error occured"}),o.writeHead(500).end(JSON.stringify({error:l?.message??"Internal error occured"}))}});return s.listen(e,()=>r(e)),s}async function cy(t){let e=await uy(t),r={};for(let s=0;s<t.rawHeaders.length;s+=2){let i=t.rawHeaders[s].toLowerCase(),o=t.rawHeaders[s+1];r[i]=o}let n=new URL(t.url??"",t.headers.host?`http://${t.headers.host}`:"http://botpress.cloud");return{body:e,path:n.pathname,query:dy(n.search,"?"),headers:r,method:t.method?.toUpperCase()??"GET"}}function dy(t,e){return t.indexOf(e)===0?t.slice(e.length):t}async function uy(t){return new Promise((e,r)=>{if(t.method!=="POST"&&t.method!=="PUT"&&t.method!=="PATCH")return e(void 0);let n="";t.on("data",s=>n+=s.toString()),t.on("error",s=>r(s)),t.on("end",()=>e(n))})}function py(t){Cs.info(`Listening on port ${t}`)}var Sn=require("@botpress/client");var N={};yt(N,{mapKeys:()=>hy,mapValues:()=>gy,mergeRecords:()=>yy,pairs:()=>pn,stripUndefinedProps:()=>my,values:()=>fy});var pn=t=>Object.entries(t),fy=t=>Object.values(t),gy=(t,e)=>Object.fromEntries(pn(t).map(([r,n])=>[r,e(n,r)])),hy=(t,e)=>Object.fromEntries(pn(t).map(([r,n])=>[e(r),n])),my=t=>Object.fromEntries(pn(t).filter(([,e])=>e!==void 0)),yy=(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 S={};yt(S,{safePush:()=>vy,unique:()=>_y});var vy=(t,...e)=>t?[...t,...e]:[...e],_y=t=>Array.from(new Set(t));var X={};yt(X,{setName:()=>Ty});var Ty=(t,e)=>(Object.defineProperty(t,"name",{value:e}),t);var jd=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),f=l.output.schema.dereference(i),g=t.actions?.[o]?.name??o;n.actions[g]={...l,...t.actions?.[o]??{},input:{schema:d},output:{schema:f}},s.actions[o]={name:g}}for(let[o,l]of Object.entries(t.definition.events??{})){let d=l.schema.dereference(i),f=t.events?.[o]?.name??o;n.events[f]={...l,...t.events?.[o]??{},schema:d},s.events[o]={name:f}}for(let[o,l]of Object.entries(t.definition.channels??{})){let d={};for(let[g,m]of Object.entries(l.messages)){let P=m.schema.dereference(i);d[g]={...m,schema:P}}let f=t.channels?.[o]?.name??o;n.channels[f]={...l,...t.channels?.[o]??{},message:{...l.message??{},tags:{...l.message?.tags??{},...t.channels?.[o]?.message?.tags??{}}},conversation:{...l.conversation??{},tags:{...l.conversation?.tags??{},...t.channels?.[o]?.conversation?.tags??{}}},messages:d},s.channels[o]={name:f}}return{resolved:n,statement:s}};var fn=Symbol("schemaName"),$d=t=>t?N.mapValues(t,(r,n)=>({...r,[fn]:n})):{},Kd=t=>fn in t&&t[fn]!==void 0,Ud=t=>t[fn];var gn=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.readme=e.readme,this.title=e.title,this.identifier=e.identifier,this.description=e.description,this.configuration=e.configuration,this.configurations=e.configurations,this.events=e.events,this.actions=e.actions,this.channels=e.channels,this.states=e.states,this.user=e.user,this.secrets=e.secrets,this.entities=e.entities,this.interfaces=e.interfaces,this.__advanced=e.__advanced,this.attributes=e.attributes}name;version;title;description;icon;readme;configuration;configurations;events;actions;channels;states;user;secrets;identifier;entities;interfaces;__advanced;attributes;extend(e,r){let{entities:n,actions:s,events:i,channels:o}=this._callBuilder(e,r),l=this;l.interfaces??={};let d=Object.values(n).map(P=>P.name),f=d.length===0?e.name:`${e.name}<${d.join(",")}>`,{resolved:g,statement:m}=jd({...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[f]={id:e.id,...m},this}_callBuilder(e,r){let s={entities:$d(this.entities)},i=r(s),o=N.pairs(i.entities).find(([d,f])=>!Kd(f));if(o)throw new Error(`Cannot extend interface "${e.name}" with entity "${o[0]}"; the provided schema is not part of the integration's entities.`);return{entities:N.mapValues(i.entities,d=>({name:Ud(d),schema:d.schema})),actions:i.actions??{},events:i.events??{},channels:i.channels??{}}}_mergeActions=(e,r)=>({...e,...r,input:{schema:pt(e.input.schema,r.input.schema)},output:{schema:pt(e.output.schema,r.output.schema)}});_mergeEvents=(e,r)=>({...e,...r,schema:pt(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:pt(e.schema,r.schema)})};var Te=require("@botpress/client");var zd=Ks(require("@botpress/client")),hn={retries:3,retryCondition:t=>zd.axiosRetry.isNetworkOrIdempotentRequestError(t)||[429,502].includes(t.response?.status??0),retryDelay:(t,e)=>(by(e.response?.headers??{})??t)*1e3},by=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 wy(String(n))}},wy=t=>{let e=Py(t)?xy(t):t.length>0?parseInt(t,10):void 0;return e===void 0||isNaN(e)?void 0:e},Py=t=>t.includes(" "),xy=t=>{let e=ky(t);if(!e)return;let r=new Date;return Math.max(0,Math.floor((e.getTime()-r.getTime())/1e3))},ky=t=>{let e=new Date(t);return isNaN(e.getTime())?void 0:e};var ft=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 mn=class{_cost=0;get cost(){return this._cost}setCost(e){this._cost=e}toJSON(){return{cost:this.cost}}};var Se="#",yn="x-bot-id",Fd="x-bot-user-id",Wd="x-integration-id",Ld="x-integration-alias",qd="x-webhook-id",Vd="x-bp-configuration-type",vn="x-bp-configuration",_n="x-bp-operation",Gd="x-bp-type";var de=t=>{throw t instanceof Error?t:new Error(t)};var Vv=y.enum(["webhook_received","message_created","action_triggered","register","unregister","ping","create_user","create_conversation"]),Jd=t=>({botId:t[yn]||de("Missing bot header"),botUserId:t[Fd]||de("Missing bot user header"),integrationId:t[Wd]||de("Missing integration header"),integrationAlias:t[Ld],webhookId:t[qd]||de("Missing webhook header"),operation:t[_n]||de("Missing operation header"),configurationType:t[Vd]??null,configuration:JSON.parse(Buffer.from(t[vn]||de("Missing configuration header"),"base64").toString("utf-8"))});var Yd=Ks(require("util")),gt=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=Yd.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 ht=class t extends gt{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 Sy=t=>["traceparent","tracestate","sentry-trace"].reduce((e,r)=>(t[r]&&(e[r]=t[r]),e),{}),Ey=(t,e,r)=>{let[,n]=(e.headers.traceparent||"").split("-"),s=new Te.Client({botId:t.botId,integrationId:t.integrationId,integrationAlias:t.integrationAlias,retry:hn,headers:Sy(e.headers)}),i=new ft(s),o=new ht({traceId:n});return{ctx:t,req:e,client:i,logger:o,instance:r}},Oy=async t=>{let{ctx:e}=t;switch(e.operation){case"webhook_received":return await Iy(t);case"register":return await By(t);case"unregister":return await Ay(t);case"message_created":return await Hy(t);case"action_triggered":return await Dy(t);case"ping":return await Zy(t);case"create_user":return await Ry(t);case"create_conversation":return await Cy(t);default:throw new Te.InvalidPayloadError(`Unknown operation ${e.operation}`)}},Xd=t=>async e=>{let r=Jd(e.headers),n=Ey(r,e,t),{logger:s}=n;try{let i;return i=await Ny(n),i?{...i,status:i.status??200}:(i=await Oy(n),i?{...i,status:i.status??200}:{status:200})}catch(i){if((0,Te.isApiError)(i)){let l=i.type==="Runtime"?i:new Te.RuntimeError(i.message,i);return s.forBot().error(l.message),{status:l.code,body:JSON.stringify(l.toJSON())}}console.error(i);let o=new Te.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())}}},Zy=async t=>{},Iy=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})},By=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})},Ay=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})},Ry=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})},Cy=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})},Hy=async({ctx:t,req:e,client:r,logger:n,instance:s})=>{let{conversation:i,user:o,type:l,payload:d,message:f}=le(e),g=s.channels[i.channel];if(!g)throw new Error(`Channel ${i.channel} not found`);let m=g.messages[l];if(!m)throw new Error(`Message of type ${l} not found in channel ${i.channel}`);await m({ctx:t,conversation:i,message:f,user:o,type:l,client:r,payload:d,ack:async({tags:O})=>{await r.updateMessage({id:f.id,tags:O})},logger:n})},Dy=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 mn,g={output:await l({ctx:e,input:i,client:r,type:o,logger:n,metadata:d}),meta:d.toJSON()};return{body:JSON.stringify(g)}},Ny=async({instance:t,client:e,ctx:r,logger:n,req:s})=>{let i=t.unknownOperationHandler;if(i)return await i({client:e,ctx:r,logger:n,req:s})};var Tn=class{constructor(e){this.props=e;this.actions=e.actions,this.channels=e.channels,this.register=e.register,this.unregister=e.unregister,this.createUser=e.createUser,this.createConversation=e.createConversation,this.webhook=e.handler,this.unknownOperationHandler=e.__advanced?.unknownOperationHandler}actions;channels;register;unregister;createUser;createConversation;webhook;unknownOperationHandler;handler=Xd(this);start=e=>Lt(this.handler,e)};var bn=class{constructor(e){this.props=e;this.integrations=e.integrations,this.plugins=e.plugins,this.user=e.user,this.conversation=e.conversation,this.message=e.message,this.states=e.states,this.configuration=e.configuration,this.events=e.events,this.recurringEvents=e.recurringEvents,this.actions=e.actions,this.tables=e.tables,this.workflows=e.workflows,this.attributes=e.attributes,this.__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;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}${Se}${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 f=Object.entries(l.entities??{});for(let[g,{name:m}]of f){let P=d.definition.entities?.[m]?.schema;if(!P)throw new Error(`Interface entity "${m}" does not exist in integration "${d.name}"`);e[`interface:${o}/entities/${g}`]=P}}}return e}_dereferenceZuiSchema(e,r){return e.dereference(r)}_dereferenceDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,this._dereferenceDefinitionSchema(s,r)]))}_dereferenceDefinitionSchema(e,r){return e&&{...e,schema:this._dereferenceZuiSchema(e.schema,r)}}_dereferenceActionDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,{...s,input:{schema:this._dereferenceZuiSchema(s.input.schema,r)},output:{schema:this._dereferenceZuiSchema(s.output.schema,r)}}]))}};var Ge=require("@botpress/client");var mt=class t extends gt{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 pe=class{constructor(e,r={before:{},after:{}}){this._client=e;this._hooks=r}get _inner(){return this._client}getConversation=(e=>this._run("getConversation",e));listConversations=(e=>this._run("listConversations",e));updateConversation=(e=>this._run("updateConversation",e));deleteConversation=(e=>this._run("deleteConversation",e));listParticipants=(e=>this._run("listParticipants",e));addParticipant=(e=>this._run("addParticipant",e));getParticipant=(e=>this._run("getParticipant",e));removeParticipant=(e=>this._run("removeParticipant",e));createEvent=(e=>this._run("createEvent",e));getEvent=(e=>this._run("getEvent",e));listEvents=(e=>this._run("listEvents",e));createMessage=(e=>this._run("createMessage",e));getOrCreateMessage=(e=>this._run("getOrCreateMessage",e));getMessage=(e=>this._run("getMessage",e));updateMessage=(e=>this._run("updateMessage",e));listMessages=(e=>this._run("listMessages",e));deleteMessage=(e=>this._run("deleteMessage",e));getUser=(e=>this._run("getUser",e));listUsers=(e=>this._run("listUsers",e));updateUser=(e=>this._run("updateUser",e));deleteUser=(e=>this._run("deleteUser",e));getState=(e=>this._run("getState",e));setState=(e=>this._run("setState",e));getOrSetState=(e=>this._run("getOrSetState",e));patchState=(e=>this._run("patchState",e));callAction=(e=>this._run("callAction",e));uploadFile=(e=>this._run("uploadFile",e));upsertFile=(e=>this._run("upsertFile",e));deleteFile=(e=>this._run("deleteFile",e));listFiles=(e=>this._run("listFiles",e));getFile=(e=>this._run("getFile",e));updateFileMetadata=(e=>this._run("updateFileMetadata",e));searchFiles=(e=>this._run("searchFiles",e));trackAnalytics=(e=>this._run("trackAnalytics",e));getTableRow=(e=>this._run("getTableRow",e));createTableRows=(e=>this._run("createTableRows",e));findTableRows=(e=>this._run("findTableRows",e));deleteTableRows=(e=>this._run("deleteTableRows",e));updateTableRows=(e=>this._run("updateTableRows",e));upsertTableRows=(e=>this._run("upsertTableRows",e));createWorkflow=(e=>this._run("createWorkflow",e));getWorkflow=(e=>this._run("getWorkflow",e));updateWorkflow=(e=>this._run("updateWorkflow",e));deleteWorkflow=(e=>this._run("deleteWorkflow",e));listWorkflows=(e=>this._run("listWorkflows",e));createConversation=e=>this._client.createConversation(e);getOrCreateConversation=e=>this._client.getOrCreateConversation(e);createUser=e=>this._client.createUser(e);getOrCreateUser=e=>this._client.getOrCreateUser(e);_run=async(e,r)=>{let n=this._hooks.before[e];n&&(r=await n(r));let s=await this._client[e](r),i=this._hooks.after[e];return i&&(s=await i(s,r)),s}};var My=y.enum(["event_received","register","unregister","ping","action_triggered"]),Qd=t=>({botId:t[yn]||de("Missing bot id header"),operation:My.parse(t[_n]),type:t[Gd]||de("Missing type header"),configuration:JSON.parse(Buffer.from(t[vn]||de("Missing configuration header"),"base64").toString("utf-8"))});var Q={status:200};var Ds=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"],eu=async(t,e)=>{if(t.ctx.type!=="workflow_update"||!jy.includes(e.payload.type))throw new Error("Unexpected event type");let r={...t,logger:$y(t,e)};if(!e.payload.workflow.name)return r.logger.warn("Received workflow update event without a workflow name. Assuming this workflow was not defined by the bot.",e.payload.workflow),Q;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 Ky(r,e);default:e.payload.type}return Q},$y=(t,e)=>t.logger.with({eventId:e.id,workflowId:e.payload.workflow.id,conversationId:e.payload.conversation?.id,userId:e.payload.user?.id}),Ky=async(t,e)=>{let r=Ds(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}"`),Q;let{updatedWorkflow:s}=await Uy(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. `),Q},Uy=async(t,e)=>{let r=Ds(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 tu=t=>async e=>{let r=Qd(e.headers),n=new mt,s=new Ge.Client({botId:r.botId,retry:hn}),i=new pe(s,{before:{createMessage:async l=>{let d=t.hookHandlers.before_outgoing_message[l.type]??[];for(let f of d){let g=new pe(s);l=(await f({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 f of d){let g=new pe(s);l=(await f({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 f of d){let g=new pe(s);l=(await f({client:g,ctx:r,logger:n.with({messageId:l.message.id,conversationId:l.message.conversationId,userId:l.message.userId}),data:l}))?.data??l}return l},callAction:async(l,d)=>{let{type:f}=d,g=t.hookHandlers.after_outgoing_call_action[f]??[];for(let m of g){let P=new pe(s);l=(await m({client:P,ctx:r,logger:n,data:{type:f,...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 qy(o);case"event_received":return await Ly(o);case"register":return await Fy(o);case"unregister":return await Wy(o);case"ping":return await zy(o);default:throw new Error(`Unknown operation ${r.operation}`)}}catch(l){let d=l instanceof Error?l:new Error(String(l));if((0,Ge.isApiError)(d)){let g=d.type==="Runtime"?d:new Ge.RuntimeError(d.message,d);return n.error(g.message),{status:g.code,body:JSON.stringify(g.toJSON())}}let f=new Ge.RuntimeError("An unexpected error occurred in the bot.",d);return n.error(f.message,d),{status:f.code,body:JSON.stringify(f.toJSON())}}},zy=async t=>Q,Fy=async t=>Q,Wy=async t=>Q,Ly=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 eu(t,l.event);if(e.type==="message_created"){let O=l.event,I=O.payload.message;o.logger=o.logger.with({messageId:I.id,conversationId:I.conversationId,userId:I.userId});let U=i.hookHandlers.before_incoming_message[I.type]??[];for(let q of U){let ie=await q({...o,data:I});if(I=ie?.data??I,ie?.stop)return Q}let L={...o,user:O.payload.user,conversation:O.payload.conversation,message:I,event:O},ee=i.messageHandlers[I.type]??[];for(let q of ee)await q(L);let ae=i.hookHandlers.after_incoming_message[I.type]??[];for(let q of ae){let ie=await q({...o,data:I});if(I=ie?.data??I,ie?.stop)return Q}return Q}if(e.type==="state_expired"){let I=l.event.payload.state,U={...o,state:I},L=i.stateExpiredHandlers[I.name]??[];for(let ee of L)await ee(U);return Q}let d=l.event,f=i.hookHandlers.before_incoming_event[d.type]??[];for(let O of f){let I=await O({...o,data:d});if(d=I?.data??d,I?.stop)return Q}let g={...o,event:d},m=i.eventHandlers[d.type]??[];for(let O of m)await O(g);let P=i.hookHandlers.after_incoming_event[d.type]??[];for(let O of P){let I=await O({...o,data:d});if(d=I?.data??d,I?.stop)return Q}return Q},qy=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 P of l){let O=await P({ctx:t,logger:e,client:n,data:{type:o,input:i}});i=O?.data?.input??i,o=O?.data?.type??o}let d=s.actionHandlers[o];if(!d)throw new Error(`Action ${o} not found`);let f=await d({ctx:t,logger:e,input:i,client:n,type:o}),g=s.hookHandlers.after_incoming_call_action[o]??[];for(let P of g){let O=await P({ctx:t,logger:e,client:n,data:{type:o,output:f}});o=O?.data?.type??o,f=O?.data?.output??f}return{status:200,body:JSON.stringify({output:f})}};var be=t=>new Proxy({},{get:(e,r)=>({listInstances:{all:n=>Ee({workflowName:r,client:t,input:n}),running:n=>Ee({workflowName:r,client:t,input:n,statuses:["in_progress"]}),scheduled:n=>Ee({workflowName:r,client:t,input:n,statuses:["pending","listening"]}),allFinished:n=>Ee({workflowName:r,client:t,input:n,statuses:["completed","cancelled","failed","timedout"]}),cancelled:n=>Ee({workflowName:r,client:t,input:n,statuses:["cancelled"]}),failed:n=>Ee({workflowName:r,client:t,input:n,statuses:["failed"]}),succeeded:n=>Ee({workflowName:r,client:t,input:n,statuses:["completed"]}),timedOut:n=>Ee({workflowName:r,client:t,input:n,statuses:["timedout"]})},startNewInstance:async n=>{let{workflow:s}=await t.createWorkflow({name:r,status:"pending",...n});return{workflow:ce({client:t,workflow:s})}}})}),Ee=async t=>{let e=await t.client.listWorkflows({name:t.workflowName,statuses:t.statuses,...t.input});return{...e,workflows:e.workflows.map(r=>ce({client:t.client,workflow:r}))}},ce=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:ce({...t,workflow:n})}},async acknowledgeStartOfProcessing(){if(!t.event||t.workflow.status!=="pending"||e)return{workflow:ce(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:ce({...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:ce({...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:ce({...t,workflow:n})}},async cancel(){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,status:"cancelled"});return await t.onWorkflowUpdate?.(r),{workflow:ce({...t,workflow:r})}}}};var wn=class{constructor(e){this.props=e;this._actionHandlers=e.actions,this._plugins=e.plugins}_actionHandlers;_messageHandlers={};_eventHandlers={};_stateExpiredHandlers={};_hookHandlers={before_incoming_event:{},before_incoming_message:{},before_outgoing_message:{},before_outgoing_call_action:{},before_incoming_call_action:{},after_incoming_event:{},after_incoming_message:{},after_outgoing_message:{},after_outgoing_call_action:{},after_incoming_call_action:{}};_workflowHandlers={started:{},continued:{},timed_out:{}};_plugins={};_registerOrder=0;get actionHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._actionHandlers[r];if(n)return n;for(let[s,i]of Object.entries(this._plugins)){let[o,l]=r.split(Se);if(!(o!==s||!l)&&(n=i.actionHandlers[l],n))return X.setName(d=>n({...d,workflows:be(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 S.unique([...n,...o]).map(l=>X.setName(d=>l({...d,workflows:be(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 S.unique([...n,...o]).map(l=>X.setName(d=>l({...d,workflows:be(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 S.unique([...n,...o]).map(l=>X.setName(d=>l({...d,workflows:be(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(m=>m.hookHandlers[r]?.[i]??[]),l=this._hookHandlers[r]??{},d=l[i]??[],f=l["*"]??[],g=[...d,...f].sort((m,P)=>m.order-P.order).map(({handler:m})=>m);return S.unique([...o,...g]).map(m=>X.setName(P=>m({...P,workflows:be(P.client)}),m.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,f)=>d.order-f.order).map(({handler:d})=>d)??[],l=Object.values(this._plugins).flatMap(d=>d.workflowHandlers[r]?.[i]??[]);return S.unique([...o,...l]).map(d=>X.setName(async f=>{let g=f.workflow;return await d({...f,workflow:ce({...f,onWorkflowUpdate(m){g=m}}),workflows:be(f.client)}),g},d.name))}})}})}on={message:(e,r)=>{this._messageHandlers[e]=S.safePush(this._messageHandlers[e],{handler:r,order:this._registerOrder++})},event:(e,r)=>{this._eventHandlers[e]=S.safePush(this._eventHandlers[e],{handler:r,order:this._registerOrder++})},stateExpired:(e,r)=>{this._stateExpiredHandlers[e]=S.safePush(this._stateExpiredHandlers[e],{handler:r,order:this._registerOrder++})},beforeIncomingEvent:(e,r)=>{this._hookHandlers.before_incoming_event[e]=S.safePush(this._hookHandlers.before_incoming_event[e],{handler:r,order:this._registerOrder++})},beforeIncomingMessage:(e,r)=>{this._hookHandlers.before_incoming_message[e]=S.safePush(this._hookHandlers.before_incoming_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingMessage:(e,r)=>{this._hookHandlers.before_outgoing_message[e]=S.safePush(this._hookHandlers.before_outgoing_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingCallAction:(e,r)=>{this._hookHandlers.before_outgoing_call_action[e]=S.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},beforeIncomingCallAction:(e,r)=>{this._hookHandlers.before_incoming_call_action[e]=S.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingEvent:(e,r)=>{this._hookHandlers.after_incoming_event[e]=S.safePush(this._hookHandlers.after_incoming_event[e],{handler:r,order:this._registerOrder++})},afterIncomingMessage:(e,r)=>{this._hookHandlers.after_incoming_message[e]=S.safePush(this._hookHandlers.after_incoming_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingMessage:(e,r)=>{this._hookHandlers.after_outgoing_message[e]=S.safePush(this._hookHandlers.after_outgoing_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingCallAction:(e,r)=>{this._hookHandlers.after_outgoing_call_action[e]=S.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingCallAction:(e,r)=>{this._hookHandlers.after_incoming_call_action[e]=S.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:r,order:this._registerOrder++})},workflowStart:(e,r)=>{this._workflowHandlers.started[e]=S.safePush(this._workflowHandlers.started[e],{handler:r,order:this._registerOrder++})},workflowContinue:(e,r)=>{this._workflowHandlers.continued[e]=S.safePush(this._workflowHandlers.continued[e],{handler:r,order:this._registerOrder++})},workflowTimeout:(e,r)=>{this._workflowHandlers.timed_out[e]=S.safePush(this._workflowHandlers.timed_out[e],{handler:r,order:this._registerOrder++})}};handler=tu(this);start=e=>Lt(this.handler,e)};var Pn=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.title=e.title,this.description=e.description,this.readme=e.readme,this.entities=e.entities??{},this.attributes=e.attributes,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;_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=Od.ref(n);i&&l.title(i),o&&l.describe(o),r[n]=l}return r}};var xn=class{constructor(e){this.props=e;let r=Object.fromEntries(Object.entries(e.interfaces??{}).map(([n,s])=>[n,Object.fromEntries(Object.entries(s.definition.entities??{}).map(([i])=>[i,y.ref(`interface:${n}/entities/${i}`)]))]));this.name=e.name,this.version=e.version,this.icon=e.icon,this.readme=e.readme,this.title=e.title,this.description=e.description,this.integrations=e.integrations,this.interfaces=e.interfaces,this.user=e.user,this.conversation=e.conversation,this.message=e.message,this.recurringEvents=e.recurringEvents,this.workflows=e.workflows,this.attributes=e.attributes,this.__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;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 Ns=":";var ru=t=>{let[e,r]=t.split(Ns);return!e||!r?null:{namespace:e,eventName:r}},nu=t=>`${t.namespace}${Ns}${t.actionName}`,su=t=>`${t.namespace}${Ns}${t.eventName}`,iu=(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}},au=(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 ou=(t,e)=>new Proxy({},{get:(r,n)=>new Proxy({},{get:(s,i)=>o=>Vy({client:t,interfaces:e.interfaces,integrationOrInterfaceName:n,methodName:i,input:o})})}),Vy=async({client:t,interfaces:e,integrationOrInterfaceName:r,methodName:n,input:s})=>{let i=iu({namespace:r,actionName:n},e),o=nu(i);return(await t.callAction({type:o,input:s})).output};var Ms=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})}},lu=(t,e)=>new Proxy({},{get:(r,n)=>{let s=e.alias!==void 0?`${e.alias}${Se}${n}`:n;return new Ms({client:t,eventName:s})}});var js=class{constructor(e,r,n){this._client=e;this._stateType=r;this._stateName=n}async get(e){return await this._client.getState({type:this._stateType,name:this._stateName,id:e}).then(r=>r.state.payload)}async set(e,r){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:r})}async getOrSet(e,r){return await this._client.getOrSetState({type:this._stateType,name:this._stateName,id:e,payload:r}).then(n=>n.state.payload)}async delete(e){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:null})}async patch(e,r){await this._client.patchState({type:this._stateType,name:this._stateName,id:e,payload:r})}},cu=(t,e)=>new Proxy({},{get:(r,n)=>new Proxy({},{get:(s,i)=>{let o=e.alias!==void 0?`${e.alias}${Se}${i}`:i;return new js(t,n,o)}})});var kn=class{constructor(e){this.props=e;this._actionHandlers=e.actions}_runtimeProps;_actionHandlers;_messageHandlers={};_eventHandlers={};_stateExpiredHandlers={};_hookHandlers={before_incoming_event:{},before_incoming_message:{},before_outgoing_message:{},before_outgoing_call_action:{},before_incoming_call_action:{},after_incoming_event:{},after_incoming_message:{},after_outgoing_message:{},after_outgoing_call_action:{},after_incoming_call_action:{}};_workflowHandlers={started:{},continued:{},timed_out:{}};_registerOrder=0;initialize(e){return this._runtimeProps=e,this}get _runtime(){if(!this._runtimeProps)throw new Error("Plugin not correctly initialized. This is likely because you access your plugin config outside of an handler.");return this._runtimeProps}_getTools(e){let{configuration:r,interfaces:n,alias:s}=this._runtime,i=ou(e,this._runtime),o=cu(e,this._runtime),l=be(e),d=lu(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 X.setName(s=>n({...s,...this._getTools(s.client)}),n.name)}})}get messageHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._messageHandlers[r]??[],s=this._messageHandlers["*"]??[];return S.unique([...n,...s]).sort((o,l)=>o.order-l.order).map(({handler:o})=>X.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 S.unique([...n,...s,...i]).sort((l,d)=>l.order-d.order).map(({handler:l})=>X.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 S.unique([...n,...s]).sort((o,l)=>o.order-l.order).map(({handler:o})=>X.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 S.unique([...o,...l,...d]).sort((g,m)=>g.order-m.order).map(({handler:g})=>X.setName(m=>g({...m,data:m.data,...this._getTools(m.client)}),g.name))}})}})}get workflowHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._workflowHandlers[r];if(n)return new Proxy({},{get:(s,i)=>(n[i]?.sort((l,d)=>l.order-d.order)??[]).map(({handler:l})=>X.setName(async d=>{let f=d.workflow;return await l({...d,workflow:ce({...d,onWorkflowUpdate(g){f=g}}),...this._getTools(d.client)}),f},l.name))})}})}on={message:(e,r)=>{this._messageHandlers[e]=S.safePush(this._messageHandlers[e],{handler:r,order:this._registerOrder++})},event:(e,r)=>{this._eventHandlers[e]=S.safePush(this._eventHandlers[e],{handler:r,order:this._registerOrder++})},stateExpired:(e,r)=>{this._stateExpiredHandlers[e]=S.safePush(this._stateExpiredHandlers[e],{handler:r,order:this._registerOrder++})},beforeIncomingEvent:(e,r)=>{this._hookHandlers.before_incoming_event[e]=S.safePush(this._hookHandlers.before_incoming_event[e],{handler:r,order:this._registerOrder++})},beforeIncomingMessage:(e,r)=>{this._hookHandlers.before_incoming_message[e]=S.safePush(this._hookHandlers.before_incoming_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingMessage:(e,r)=>{this._hookHandlers.before_outgoing_message[e]=S.safePush(this._hookHandlers.before_outgoing_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingCallAction:(e,r)=>{this._hookHandlers.before_outgoing_call_action[e]=S.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},beforeIncomingCallAction:(e,r)=>{this._hookHandlers.before_incoming_call_action[e]=S.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingEvent:(e,r)=>{this._hookHandlers.after_incoming_event[e]=S.safePush(this._hookHandlers.after_incoming_event[e],{handler:r,order:this._registerOrder++})},afterIncomingMessage:(e,r)=>{this._hookHandlers.after_incoming_message[e]=S.safePush(this._hookHandlers.after_incoming_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingMessage:(e,r)=>{this._hookHandlers.after_outgoing_message[e]=S.safePush(this._hookHandlers.after_outgoing_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingCallAction:(e,r)=>{this._hookHandlers.after_outgoing_call_action[e]=S.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingCallAction:(e,r)=>{this._hookHandlers.after_incoming_call_action[e]=S.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:r,order:this._registerOrder++})},workflowStart:(e,r)=>{this._workflowHandlers.started[e]=S.safePush(this._workflowHandlers.started[e],{handler:r,order:this._registerOrder++})},workflowContinue:(e,r)=>{this._workflowHandlers.continued[e]=S.safePush(this._workflowHandlers.continued[e],{handler:r,order:this._registerOrder++})},workflowTimeout:(e,r)=>{this._workflowHandlers.timed_out[e]=S.safePush(this._workflowHandlers.timed_out[e],{handler:r,order:this._registerOrder++})}};_eventResolvesTo=(e,r)=>{let n=ru(e);if(!n)return!1;let s=au(n,this._runtime.interfaces);return su(s)===r};_stripAliasPrefix=e=>{let{alias:r}=this._runtime;if(!r)return e;let n=`${r}#`;return e.startsWith(n)?e.slice(n.length):e}};0&&(module.exports={BRAND,Bot,BotDefinition,BotLogger,BotSpecificClient,DIRTY,EMPTY_PATH,INVALID,Integration,IntegrationDefinition,IntegrationLogger,IntegrationSpecificClient,InterfaceDefinition,NEVER,OK,ParseInputLazyPath,ParseStatus,Plugin,PluginDefinition,RuntimeError,Schema,WELL_KNOWN_ATTRIBUTES,ZodAny,ZodArray,ZodBigInt,ZodBoolean,ZodBranded,ZodCatch,ZodDate,ZodDefault,ZodDiscriminatedUnion,ZodEffects,ZodEnum,ZodError,ZodFirstPartyTypeKind,ZodFunction,ZodIntersection,ZodIssueCode,ZodLazy,ZodLiteral,ZodMap,ZodNaN,ZodNativeEnum,ZodNever,ZodNull,ZodNullable,ZodNumber,ZodObject,ZodOptional,ZodParsedType,ZodPipeline,ZodPromise,ZodReadonly,ZodRecord,ZodRef,ZodSchema,ZodSet,ZodString,ZodSymbol,ZodTransformer,ZodTuple,ZodType,ZodUndefined,ZodUnion,ZodUnknown,ZodVoid,addIssueToContext,agent,aimodel,any,array,bigint,boolean,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,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,void:null,z});
|
|
68
68
|
/*! Bundled license information:
|
|
69
69
|
|
|
70
70
|
@bpinternal/zui/dist/index.js:
|