@botpress/sdk 4.16.0 → 4.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +5 -5
- package/dist/index.cjs +20 -15
- package/dist/index.cjs.map +4 -4
- package/dist/index.mjs +32 -27
- package/dist/index.mjs.map +4 -4
- package/dist/integration/server/types.d.ts +1 -1
- package/package.json +5 -2
package/dist/index.cjs
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
|
|
3
|
-
* ${
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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) => {
|
|
1
|
+
"use strict";var mu=Object.create;var Vt=Object.defineProperty;var yu=Object.getOwnPropertyDescriptor;var vu=Object.getOwnPropertyNames;var _u=Object.getPrototypeOf,Tu=Object.prototype.hasOwnProperty;var yt=(t,e)=>{for(var r in e)Vt(t,r,{get:e[r],enumerable:!0})},Us=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of vu(e))!Tu.call(t,s)&&s!==r&&Vt(t,s,{get:()=>e[s],enumerable:!(n=yu(e,s))||n.enumerable});return t};var zs=(t,e,r)=>(r=t!=null?mu(_u(t)):{},Us(e||!t||!t.__esModule?Vt(r,"default",{value:t,enumerable:!0}):r,t)),bu=t=>Us(Vt({},"__esModule",{value:!0}),t);var tv={};yt(tv,{BRAND:()=>jl,Bot:()=>wn,BotDefinition:()=>bn,BotLogger:()=>mt,BotSpecificClient:()=>fe,DIRTY:()=>De,EMPTY_PATH:()=>Rl,INVALID:()=>x,Integration:()=>Tn,IntegrationDefinition:()=>gn,IntegrationLogger:()=>ht,IntegrationSpecificClient:()=>ft,InterfaceDefinition:()=>Pn,NEVER:()=>rd,OK:()=>G,ParseInputLazyPath:()=>oe,ParseStatus:()=>re,Plugin:()=>kn,PluginDefinition:()=>xn,RuntimeError:()=>Sn.RuntimeError,Schema:()=>O,WELL_KNOWN_ATTRIBUTES:()=>gy,ZodAny:()=>ot,ZodArray:()=>lt,ZodBigInt:()=>Xr,ZodBoolean:()=>Qr,ZodBranded:()=>en,ZodCatch:()=>tn,ZodDate:()=>rn,ZodDefault:()=>Ut,ZodDiscriminatedUnion:()=>fs,ZodEffects:()=>Se,ZodEnum:()=>Ve,ZodError:()=>pe,ZodFirstPartyTypeKind:()=>cs,ZodFunction:()=>hs,ZodIntersection:()=>nn,ZodIssueCode:()=>h,ZodLazy:()=>sn,ZodLiteral:()=>an,ZodMap:()=>ms,ZodNaN:()=>ys,ZodNativeEnum:()=>on,ZodNever:()=>ut,ZodNull:()=>ln,ZodNullable:()=>Me,ZodNumber:()=>cn,ZodObject:()=>$e,ZodOptional:()=>ye,ZodParsedType:()=>_,ZodPipeline:()=>dn,ZodPromise:()=>Ft,ZodReadonly:()=>Lt,ZodRecord:()=>vs,ZodRef:()=>_s,ZodSchema:()=>O,ZodSet:()=>Ts,ZodString:()=>J,ZodSymbol:()=>Os,ZodTransformer:()=>Se,ZodTuple:()=>je,ZodType:()=>O,ZodUndefined:()=>Wt,ZodUnion:()=>un,ZodUnknown:()=>nt,ZodVoid:()=>Zs,addIssueToContext:()=>v,agent:()=>dc,aimodel:()=>hc,any:()=>Sc,array:()=>Ic,bigint:()=>bc,boolean:()=>As,coerce:()=>td,conversation:()=>oc,createZodEnum:()=>zt,cuid2Regex:()=>ws,cuidRegex:()=>bs,custom:()=>ps,datasource:()=>mc,date:()=>wc,discriminatedUnion:()=>Cc,effect:()=>Ln,emailRegex:()=>ks,enum:()=>Lc,errorUtil:()=>P,event:()=>uc,function:()=>Uc,getErrorMap:()=>it,getParsedType:()=>me,instanceof:()=>_c,intent:()=>gc,intersection:()=>Hc,ipv4Regex:()=>Ss,ipv6Regex:()=>Es,isAborted:()=>lr,isApiError:()=>Sn.isApiError,isAsync:()=>$t,isDirty:()=>cr,isEmojiRegex:()=>ec,isValid:()=>at,json:()=>xu,knowledgebase:()=>yc,late:()=>vc,lazy:()=>zc,literal:()=>Fc,makeIssue:()=>Mt,map:()=>jc,mergeObjectSchemas:()=>pt,message:()=>cc,messages:()=>Hs,nan:()=>Tc,nativeEnum:()=>Wc,never:()=>Oc,null:()=>kc,nullable:()=>Gc,number:()=>Bs,object:()=>Bc,objectUtil:()=>ar,oboolean:()=>ed,onumber:()=>Qc,optional:()=>Vc,ostring:()=>Xc,parseBody:()=>le,pipeline:()=>Yc,preprocess:()=>Jc,processCreateParams:()=>S,promise:()=>qc,quotelessJson:()=>Il,readonly:()=>$c,record:()=>Nc,ref:()=>Mc,serve:()=>qt,set:()=>Kc,setErrorMap:()=>us,strictObject:()=>Ac,string:()=>Is,symbol:()=>Pc,table:()=>pc,tablerow:()=>fc,transformer:()=>Ln,transforms:()=>Ii,tuple:()=>Dc,ulidRegex:()=>Ps,undefined:()=>xc,union:()=>Rc,unknown:()=>Ec,user:()=>lc,util:()=>I,uuidRegex:()=>xs,variable:()=>ac,void:()=>Zc,z:()=>y});module.exports=bu(tv);var Hs={};yt(Hs,{defaults:()=>fy,markdown:()=>py});var Vn=Object.defineProperty,wu=Object.defineProperties,Pu=Object.getOwnPropertyDescriptors,ir=Object.getOwnPropertySymbols,Ei=Object.prototype.hasOwnProperty,Oi=Object.prototype.propertyIsEnumerable,Fs=(t,e,r)=>e in t?Vn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,c=(t,e)=>{for(var r in e||(e={}))Ei.call(e,r)&&Fs(t,r,e[r]);if(ir)for(var r of ir(e))Oi.call(e,r)&&Fs(t,r,e[r]);return t},f=(t,e)=>wu(t,Pu(e)),a=(t,e)=>Vn(t,"name",{value:e,configurable:!0}),Zi=(t,e)=>{var r={};for(var n in t)Ei.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&&Oi.call(t,n)&&(r[n]=t[n]);return r},Kr=(t,e)=>{for(var r in e)Vn(t,r,{get:e[r],enumerable:!0})},xu={},Ii={};Kr(Ii,{errors:()=>Hi,fromJSONSchema:()=>ad,fromJSONSchemaLegacy:()=>Dm,fromObject:()=>Wn,toJSONSchema:()=>q,toJSONSchemaLegacy:()=>ly,toTypescriptSchema:()=>as,toTypescriptType:()=>Gn});var y={};Kr(y,{BRAND:()=>jl,DIRTY:()=>De,EMPTY_PATH:()=>Rl,INVALID:()=>x,NEVER:()=>rd,OK:()=>G,ParseInputLazyPath:()=>oe,ParseStatus:()=>re,Schema:()=>O,ZodAny:()=>ot,ZodArray:()=>lt,ZodBigInt:()=>Xr,ZodBoolean:()=>Qr,ZodBranded:()=>en,ZodCatch:()=>tn,ZodDate:()=>rn,ZodDefault:()=>Ut,ZodDiscriminatedUnion:()=>fs,ZodEffects:()=>Se,ZodEnum:()=>Ve,ZodError:()=>pe,ZodFirstPartyTypeKind:()=>cs,ZodFunction:()=>hs,ZodIntersection:()=>nn,ZodIssueCode:()=>h,ZodLazy:()=>sn,ZodLiteral:()=>an,ZodMap:()=>ms,ZodNaN:()=>ys,ZodNativeEnum:()=>on,ZodNever:()=>ut,ZodNull:()=>ln,ZodNullable:()=>Me,ZodNumber:()=>cn,ZodObject:()=>$e,ZodOptional:()=>ye,ZodParsedType:()=>_,ZodPipeline:()=>dn,ZodPromise:()=>Ft,ZodReadonly:()=>Lt,ZodRecord:()=>vs,ZodRef:()=>_s,ZodSchema:()=>O,ZodSet:()=>Ts,ZodString:()=>J,ZodSymbol:()=>Os,ZodTransformer:()=>Se,ZodTuple:()=>je,ZodType:()=>O,ZodUndefined:()=>Wt,ZodUnion:()=>un,ZodUnknown:()=>nt,ZodVoid:()=>Zs,addIssueToContext:()=>v,agent:()=>dc,aimodel:()=>hc,any:()=>Sc,array:()=>Ic,bigint:()=>bc,boolean:()=>As,coerce:()=>td,conversation:()=>oc,createZodEnum:()=>zt,cuid2Regex:()=>ws,cuidRegex:()=>bs,custom:()=>ps,datasource:()=>mc,date:()=>wc,default:()=>pm,discriminatedUnion:()=>Cc,effect:()=>Ln,emailRegex:()=>ks,enum:()=>Lc,errorUtil:()=>P,event:()=>uc,function:()=>Uc,getErrorMap:()=>it,getParsedType:()=>me,instanceof:()=>_c,intent:()=>gc,intersection:()=>Hc,ipv4Regex:()=>Ss,ipv6Regex:()=>Es,isAborted:()=>lr,isAsync:()=>$t,isDirty:()=>cr,isEmojiRegex:()=>ec,isValid:()=>at,knowledgebase:()=>yc,late:()=>vc,lazy:()=>zc,literal:()=>Fc,makeIssue:()=>Mt,map:()=>jc,message:()=>cc,nan:()=>Tc,nativeEnum:()=>Wc,never:()=>Oc,null:()=>kc,nullable:()=>Gc,number:()=>Bs,object:()=>Bc,objectUtil:()=>ar,oboolean:()=>ed,onumber:()=>Qc,optional:()=>Vc,ostring:()=>Xc,pipeline:()=>Yc,preprocess:()=>Jc,processCreateParams:()=>S,promise:()=>qc,quotelessJson:()=>Il,readonly:()=>$c,record:()=>Nc,ref:()=>Mc,set:()=>Kc,setErrorMap:()=>us,strictObject:()=>Ac,string:()=>Is,symbol:()=>Pc,table:()=>pc,tablerow:()=>fc,transformer:()=>Ln,tuple:()=>Dc,ulidRegex:()=>Ps,undefined:()=>xc,union:()=>Rc,unknown:()=>Ec,user:()=>lc,util:()=>I,uuidRegex:()=>xs,variable:()=>ac,void:()=>Zc});var w="x-zui";function Bi(t){return typeof t=="symbol"?"symbol":typeof t=="bigint"?`${t.toString()}n`:b(t)}a(Bi,"primitiveToTypscriptLiteralType");function b(t){return typeof t>"u"?"undefined":typeof t=="symbol"?t.description?`Symbol(${b(t.description)})`:"Symbol()":typeof t=="bigint"?`BigInt(${t.toString()})`:typeof t=="string"?Ci(t):JSON.stringify(t)}a(b,"primitiveToTypescriptValue");function tt(t){return typeof t>"u"?"undefined":JSON.stringify(t)}a(tt,"unknownToTypescriptValue");var Ai=a((t,e)=>{let r=Object.entries(t),n=e?" as const":"";return`{ ${r.map(([s,i])=>`${Hn(s)}: ${tt(i)}`).join(", ")} }${n}`},"recordOfUnknownToTypescriptRecord"),Hn=a(t=>/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t)?t:b(t),"toPropertyKey"),ku=a(t=>t.charAt(0).toUpperCase()+t.slice(1),"capitalize"),Ri=a(t=>{let e=/[^a-zA-Z0-9_]/g;return t.split(e).map(ku).filter(n=>!!n).join("")},"toTypeArgumentName"),Ls=a(t=>{for(var e;t.length&&!((e=t[0])!=null&&e.trim());)t.shift();for(;t.length&&!t[t.length-1].trim();)t.pop()},"trimEmptyLinesInPlace"),z=a(t=>{t=t?.replace(/(\n(\s*)?){3,}/g,`
|
|
2
|
+
|
|
3
|
+
`);let e=a(s=>s.startsWith("* ")?` ${s}`:` * ${s}`,"ensureLineStartsWithAsterisk"),r=a(s=>s.replace(/\*\//g,"*\\/"),"escapeCommentEnd"),n=(t??"").split(`
|
|
4
|
+
`).map(s=>s.trim());return Ls(n),n.length&&(n[0]=n[0].replace(/^\/\*\*?/,""),n[n.length-1]=n[n.length-1].replace(/\*\/$/,"")),Ls(n),n.length===0?"":n.length===1?`/** ${r(n[0])} */`:`/**
|
|
5
|
+
${n.map(e).map(r).join(`
|
|
6
|
+
`)}
|
|
7
|
+
*/`},"getMultilineComment");function Ci(t){if(typeof t!="string")return"";let r=String.raw`${t}`.replace(/\\/g,"\\\\").replace(/\n/g,"\\n").replace(/"/g,'\\"').replace(/'/g,"\\'");return r.includes("`")?`"${r}"`:r.includes("'")?`"${r}"`:`'${r}'`}a(Ci,"escapeString");var Hi={};Kr(Hi,{JSONSchemaToZuiError:()=>Ur,ObjectToZuiError:()=>Dn,UnrepresentableGenericError:()=>Nn,UnsupportedJSONSchemaToZuiError:()=>Pe,UnsupportedZuiCheckToJSONSchemaError:()=>Ui,UnsupportedZuiToJSONSchemaError:()=>te,UnsupportedZuiToTypescriptSchemaError:()=>Ie,UnsupportedZuiToTypescriptTypeError:()=>Gi,UntitledDeclarationError:()=>Yi,ZuiToJSONSchemaError:()=>zr,ZuiToTypescriptSchemaError:()=>Li,ZuiToTypescriptTypeError:()=>Fr,ZuiTransformError:()=>dt});var Di=class extends Error{constructor(e,r){super(r),this.transform=e}};a(Di,"ZuiTransformError");var dt=Di,Ni=class extends dt{constructor(e){super("json-schema-to-zui",e)}};a(Ni,"JSONSchemaToZuiError");var Ur=Ni,Mi=class extends dt{constructor(e){super("object-to-zui",e)}};a(Mi,"ObjectToZuiError");var Dn=Mi,$i=class extends dt{constructor(e){super("zui-to-json-schema",e)}};a($i,"ZuiToJSONSchemaError");var zr=$i,ji=class extends zr{constructor(e,{suggestedAlternative:r}={}){super(`Zod type ${e} cannot be transformed to JSON Schema.`+(r?` Suggested alternative: ${r}`:""))}};a(ji,"UnsupportedZuiToJSONSchemaError");var te=ji,Ki=class extends zr{constructor({zodType:e,checkKind:r}){super(`Zod check .${r}() of type ${e} cannot be transformed to JSON Schema.`)}};a(Ki,"UnsupportedZuiCheckToJSONSchemaError");var Ui=Ki,zi=class extends Ur{constructor(e){super(`JSON Schema ${JSON.stringify(e)} cannot be transformed to ZUI type.`)}};a(zi,"UnsupportedJSONSchemaToZuiError");var Pe=zi,Fi=class extends dt{constructor(e){super("zui-to-typescript-schema",e)}};a(Fi,"ZuiToTypescriptSchemaError");var Li=Fi,Wi=class extends Li{constructor(e){super(`Zod type ${e} cannot be transformed to TypeScript schema.`)}};a(Wi,"UnsupportedZuiToTypescriptSchemaError");var Ie=Wi,qi=class extends dt{constructor(e){super("zui-to-typescript-type",e)}};a(qi,"ZuiToTypescriptTypeError");var Fr=qi,Vi=class extends Fr{constructor(e){super(`Zod type ${e} cannot be transformed to TypeScript type.`)}};a(Vi,"UnsupportedZuiToTypescriptTypeError");var Gi=Vi,Ji=class extends Fr{constructor(){super("Schema must have a title to be transformed to a TypeScript type with a declaration.")}};a(Ji,"UntitledDeclarationError");var Yi=Ji,Xi=class extends Fr{constructor(){super('ZodRef can only be transformed to a TypeScript type with a "type" declaration.')}};a(Xi,"UnrepresentableGenericError");var Nn=Xi,Qi=["string","number","boolean","unknown","void","any","null","undefined","never","bigint","symbol","object"],Su=5,Eu=a(t=>Qi.includes(t),"isPrimitive"),Ou=a(t=>Qi.map(e=>`${e}[]`).includes(t),"isArrayOfPrimitives"),On=a(t=>t.replace(/ +/g," ").trim(),"stripSpaces"),ea=class{constructor(e,r){this.key=e,this.value=r}};a(ea,"KeyValue");var Gt=ea,ta=class{constructor(e){this.schema=e}};a(ta,"FnParameters");var Ws=ta,ra=class{constructor(e){this.schema=e}};a(ra,"FnReturn");var qs=ra,na=class{constructor(e){this.props=e}};a(na,"Declaration");var At=na;function Gn(t,e={}){let r=Bu(t,e),n=B(r,e);return e.formatter&&(n=e.formatter(n)),n}a(Gn,"toTypescriptType");var Vs=a(t=>t.endsWith("?")?t:`${t}?`,"_optionalKey");function B(t,e){var r,n,s;let i=f(c({},e),{declaration:!1,parent:t});if(t===null)return"";if(t instanceof At)return Zu(t,i);if(t instanceof Gt){let d;if(t.value instanceof p.ZodOptional?d=t.value:t.value instanceof p.ZodDefault&&e.treatDefaultAsOptional&&(d=t.value._def.innerType.optional()),d){let k=d._def.innerType;return k instanceof p.Schema&&!k.description&&d.description&&(k=k?.describe(d.description)),B(new Gt(Vs(t.key),k),i)}let u=z(t.value._def.description||t.value.description),g=u?.trim().length>0?`
|
|
8
|
+
`:"",m=t.value.describe(""),Z=t.value instanceof p.ZodAny?Vs(t.key):t.key;return`${g}${u}${g}${Z}: ${B(m,i)}${g}`}if(t instanceof Ws){if(t.schema instanceof p.ZodTuple){let m="";for(let T=0;T<t.schema.items.length;T++){let Z=(s=(n=(r=t.schema.items[T])==null?void 0:r.ui)==null?void 0:n.title)!=null?s:`arg${T}`,k=t.schema.items[T];m+=`${B(new Gt(Hn(Z),k),i)}${T<t.schema.items.length-1?", ":""} `}return m}let d=t.schema.naked()instanceof p.ZodLiteral,u=B(t.schema,i).trim();return u.startsWith("{")&&u.endsWith("}")||u.startsWith("[")&&u.endsWith("]")||u.startsWith("(")&&u.endsWith(")")||u.startsWith("Array<")&&u.endsWith(">")||u.startsWith("Record<")&&u.endsWith(">")||Ou(u)||d?`args: ${u}`:u}if(t instanceof qs)return t.schema instanceof p.ZodOptional?`${B(t.schema.unwrap(),i)} | undefined`:B(t.schema,i);let o=t,l=o._def;switch(l.typeName){case p.ZodFirstPartyTypeKind.ZodString:return`${z(o.description)} string`.trim();case p.ZodFirstPartyTypeKind.ZodNumber:case p.ZodFirstPartyTypeKind.ZodNaN:case p.ZodFirstPartyTypeKind.ZodBigInt:return`${z(o.description)} number`.trim();case p.ZodFirstPartyTypeKind.ZodBoolean:return`${z(o.description)} boolean`.trim();case p.ZodFirstPartyTypeKind.ZodDate:return`${z(o.description)} Date`.trim();case p.ZodFirstPartyTypeKind.ZodUndefined:return`${z(o.description)} undefined`.trim();case p.ZodFirstPartyTypeKind.ZodNull:return`${z(o.description)} null`.trim();case p.ZodFirstPartyTypeKind.ZodAny:return`${z(o.description)} any`.trim();case p.ZodFirstPartyTypeKind.ZodUnknown:return`${z(o.description)} unknown`.trim();case p.ZodFirstPartyTypeKind.ZodNever:return`${z(o.description)} never`.trim();case p.ZodFirstPartyTypeKind.ZodVoid:return`${z(o.description)} void`.trim();case p.ZodFirstPartyTypeKind.ZodArray:let d=B(l.type,i);return Eu(d)?`${d}[]`:`Array<${d}>`;case p.ZodFirstPartyTypeKind.ZodObject:return`{ ${Object.entries(l.shape()).map(([ee,En])=>En instanceof p.Schema?B(new Gt(Hn(ee),En),i):`${ee}: unknown`).join("; ")} }`;case p.ZodFirstPartyTypeKind.ZodUnion:let g=l.options.map(ee=>B(ee,i));return`${z(o.description)}
|
|
9
|
+
${g.join(" | ")}`;case p.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:let m=l.options.map(ee=>B(ee,i));return`${z(o.description)}
|
|
10
|
+
${m.join(" | ")}`;case p.ZodFirstPartyTypeKind.ZodIntersection:return`${B(l.left,i)} & ${B(l.right,i)}`;case p.ZodFirstPartyTypeKind.ZodTuple:return l.items.length===0?"[]":`[${l.items.map(ee=>B(ee,i)).join(", ")}]`;case p.ZodFirstPartyTypeKind.ZodRecord:let Z=B(l.keyType,i),k=B(l.valueType,i);return`${z(o.description)} { [key: ${Z}]: ${k} }`;case p.ZodFirstPartyTypeKind.ZodMap:return`Map<${B(l.keyType,i)}, ${B(l.valueType,i)}>`;case p.ZodFirstPartyTypeKind.ZodSet:return`Set<${B(l.valueType,i)}>`;case p.ZodFirstPartyTypeKind.ZodFunction:let K=B(new Ws(l.args),i),F=B(new qs(l.returns),i),Q=e?.parent instanceof At&&e?.parent.props.type==="type";return e?.declaration&&!Q?`${z(o.description)}
|
|
11
|
+
(${K}): ${F}`:`${z(o.description)}
|
|
12
|
+
(${K}) => ${F}`;case p.ZodFirstPartyTypeKind.ZodLazy:return B(l.getter(),i);case p.ZodFirstPartyTypeKind.ZodLiteral:let ie=Bi(l.value);return`${z(o.description)}
|
|
13
|
+
${ie}`.trim();case p.ZodFirstPartyTypeKind.ZodEnum:return l.values.map(b).join(" | ");case p.ZodFirstPartyTypeKind.ZodEffects:return B(l.schema,i);case p.ZodFirstPartyTypeKind.ZodNativeEnum:throw new Gi(p.ZodFirstPartyTypeKind.ZodNativeEnum);case p.ZodFirstPartyTypeKind.ZodOptional:return`${B(l.innerType,i)} | undefined`;case p.ZodFirstPartyTypeKind.ZodNullable:return`${B(l.innerType,i)} | null`;case p.ZodFirstPartyTypeKind.ZodDefault:let ae=e.treatDefaultAsOptional?l.innerType.optional():l.innerType;return B(ae,i);case p.ZodFirstPartyTypeKind.ZodCatch:return B(l.innerType,i);case p.ZodFirstPartyTypeKind.ZodPromise:return`Promise<${B(l.type,i)}>`;case p.ZodFirstPartyTypeKind.ZodBranded:return B(l.type,i);case p.ZodFirstPartyTypeKind.ZodPipeline:return B(l.in,i);case p.ZodFirstPartyTypeKind.ZodSymbol:return`${z(o.description)} symbol`.trim();case p.ZodFirstPartyTypeKind.ZodReadonly:return`Readonly<${B(l.innerType,i)}>`;case p.ZodFirstPartyTypeKind.ZodRef:return Ri(l.uri);default:I.assertNever(l)}}a(B,"sUnwrapZod");var Zu=a((t,e)=>{if(t.props.type==="none")return B(t.props.schema,e);let{schema:r,identifier:n}=t.props,s=z(r.description),i=r.describe(""),o=B(i,f(c({},e),{declaration:!0})),d=o.split(`
|
|
14
|
+
`).length>=Su&&e.includeClosingTags?`// end of ${n}`:"";if(t.props.type!=="type"&&r instanceof p.ZodFunction)return On(`${s}
|
|
15
|
+
declare function ${n}${o};${d}`);if(t.props.type==="variable")return On(`${s}declare const ${n}: ${o};${d}`);let u=t.props.args.length>0?`<${t.props.args.map(Ri).join(", ")}>`:"";return On(`${s}type ${t.props.identifier}${u} = ${o};${d}`)},"unwrapDeclaration"),Iu=a(t=>t.declaration?t.declaration===!0?"variable":t.declaration:"none","getDeclarationType"),Bu=a((t,e)=>{let r=Iu(e),n=t.getReferences();if(r==="none"){if(n.length>0)throw new Nn;return new At({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 Nn;return new At({type:"variable",identifier:s,schema:t})}return new At({type:"type",identifier:s,schema:t,args:n})},"getDeclarationProps"),Au=typeof global=="object"&&global&&global.Object===Object&&global,sa=Au,Ru=typeof self=="object"&&self&&self.Object===Object&&self,Cu=sa||Ru||Function("return this")(),_e=Cu,Hu=_e.Symbol,xe=Hu,ia=Object.prototype,Du=ia.hasOwnProperty,Nu=ia.toString,vt=xe?xe.toStringTag:void 0;function aa(t){var e=Du.call(t,vt),r=t[vt];try{t[vt]=void 0;var n=!0}catch{}var s=Nu.call(t);return n&&(e?t[vt]=r:delete t[vt]),s}a(aa,"getRawTag");var Mu=aa,$u=Object.prototype,ju=$u.toString;function oa(t){return ju.call(t)}a(oa,"objectToString");var Ku=oa,Uu="[object Null]",zu="[object Undefined]",Gs=xe?xe.toStringTag:void 0;function la(t){return t==null?t===void 0?zu:Uu:Gs&&Gs in Object(t)?Mu(t):Ku(t)}a(la,"baseGetTag");var Ke=la;function ca(t){return t!=null&&typeof t=="object"}a(ca,"isObjectLike");var Ne=ca,Fu="[object Symbol]";function da(t){return typeof t=="symbol"||Ne(t)&&Ke(t)==Fu}a(da,"isSymbol");var Jn=da;function ua(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(ua,"arrayMap");var pa=ua,Lu=Array.isArray,ve=Lu,Wu=1/0,Js=xe?xe.prototype:void 0,Ys=Js?Js.toString:void 0;function Yn(t){if(typeof t=="string")return t;if(ve(t))return pa(t,Yn)+"";if(Jn(t))return Ys?Ys.call(t):"";var e=t+"";return e=="0"&&1/t==-Wu?"-0":e}a(Yn,"baseToString");var qu=Yn;function fa(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}a(fa,"isObject");var st=fa;function ga(t){return t}a(ga,"identity");var Vu=ga,Gu="[object AsyncFunction]",Ju="[object Function]",Yu="[object GeneratorFunction]",Xu="[object Proxy]";function ha(t){if(!st(t))return!1;var e=Ke(t);return e==Ju||e==Yu||e==Gu||e==Xu}a(ha,"isFunction");var ma=ha,Qu=_e["__core-js_shared__"],Zn=Qu,Xs=(function(){var t=/[^.]+$/.exec(Zn&&Zn.keys&&Zn.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function ya(t){return!!Xs&&Xs in t}a(ya,"isMasked");var ep=ya,tp=Function.prototype,rp=tp.toString;function va(t){if(t!=null){try{return rp.call(t)}catch{}try{return t+""}catch{}}return""}a(va,"toSource");var Ue=va,np=/[\\^$.*+?()[\]{}|]/g,sp=/^\[object .+?Constructor\]$/,ip=Function.prototype,ap=Object.prototype,op=ip.toString,lp=ap.hasOwnProperty,cp=RegExp("^"+op.call(lp).replace(np,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function _a(t){if(!st(t)||ep(t))return!1;var e=ma(t)?cp:sp;return e.test(Ue(t))}a(_a,"baseIsNative");var dp=_a;function Ta(t,e){return t?.[e]}a(Ta,"getValue");var up=Ta;function ba(t,e){var r=up(t,e);return dp(r)?r:void 0}a(ba,"getNative");var ze=ba,pp=ze(_e,"WeakMap"),Mn=pp,fp=(function(){try{var t=ze(Object,"defineProperty");return t({},"",{}),t}catch{}})(),Qs=fp,gp=9007199254740991,hp=/^(?:0|[1-9]\d*)$/;function wa(t,e){var r=typeof t;return e=e??gp,!!e&&(r=="number"||r!="symbol"&&hp.test(t))&&t>-1&&t%1==0&&t<e}a(wa,"isIndex");var Xn=wa;function Pa(t,e,r){e=="__proto__"&&Qs?Qs(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}a(Pa,"baseAssignValue");var xa=Pa;function ka(t,e){return t===e||t!==t&&e!==e}a(ka,"eq");var Qn=ka,mp=Object.prototype,yp=mp.hasOwnProperty;function Sa(t,e,r){var n=t[e];(!(yp.call(t,e)&&Qn(n,r))||r===void 0&&!(e in t))&&xa(t,e,r)}a(Sa,"assignValue");var vp=Sa,_p=9007199254740991;function Ea(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=_p}a(Ea,"isLength");var es=Ea;function Oa(t){return t!=null&&es(t.length)&&!ma(t)}a(Oa,"isArrayLike");var Za=Oa,Tp=Object.prototype;function Ia(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Tp;return t===r}a(Ia,"isPrototype");var Ba=Ia;function Aa(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}a(Aa,"baseTimes");var bp=Aa,wp="[object Arguments]";function Ra(t){return Ne(t)&&Ke(t)==wp}a(Ra,"baseIsArguments");var ei=Ra,Ca=Object.prototype,Pp=Ca.hasOwnProperty,xp=Ca.propertyIsEnumerable,kp=ei((function(){return arguments})())?ei:function(t){return Ne(t)&&Pp.call(t,"callee")&&!xp.call(t,"callee")},Ha=kp;function Da(){return!1}a(Da,"stubFalse");var Sp=Da,Na=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ti=Na&&typeof module=="object"&&module&&!module.nodeType&&module,Ep=ti&&ti.exports===Na,ri=Ep?_e.Buffer:void 0,Op=ri?ri.isBuffer:void 0,Zp=Op||Sp,$n=Zp,Ip="[object Arguments]",Bp="[object Array]",Ap="[object Boolean]",Rp="[object Date]",Cp="[object Error]",Hp="[object Function]",Dp="[object Map]",Np="[object Number]",Mp="[object Object]",$p="[object RegExp]",jp="[object Set]",Kp="[object String]",Up="[object WeakMap]",zp="[object ArrayBuffer]",Fp="[object DataView]",Lp="[object Float32Array]",Wp="[object Float64Array]",qp="[object Int8Array]",Vp="[object Int16Array]",Gp="[object Int32Array]",Jp="[object Uint8Array]",Yp="[object Uint8ClampedArray]",Xp="[object Uint16Array]",Qp="[object Uint32Array]",D={};D[Lp]=D[Wp]=D[qp]=D[Vp]=D[Gp]=D[Jp]=D[Yp]=D[Xp]=D[Qp]=!0;D[Ip]=D[Bp]=D[zp]=D[Ap]=D[Fp]=D[Rp]=D[Cp]=D[Hp]=D[Dp]=D[Np]=D[Mp]=D[$p]=D[jp]=D[Kp]=D[Up]=!1;function Ma(t){return Ne(t)&&es(t.length)&&!!D[Ke(t)]}a(Ma,"baseIsTypedArray");var ef=Ma;function $a(t){return function(e){return t(e)}}a($a,"baseUnary");var tf=$a,ja=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Rt=ja&&typeof module=="object"&&module&&!module.nodeType&&module,rf=Rt&&Rt.exports===ja,In=rf&&sa.process,nf=(function(){try{var t=Rt&&Rt.require&&Rt.require("util").types;return t||In&&In.binding&&In.binding("util")}catch{}})(),ni=nf,si=ni&&ni.isTypedArray,sf=si?tf(si):ef,Ka=sf,af=Object.prototype,of=af.hasOwnProperty;function Ua(t,e){var r=ve(t),n=!r&&Ha(t),s=!r&&!n&&$n(t),i=!r&&!n&&!s&&Ka(t),o=r||n||s||i,l=o?bp(t.length,String):[],d=l.length;for(var u in t)(e||of.call(t,u))&&!(o&&(u=="length"||s&&(u=="offset"||u=="parent")||i&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||Xn(u,d)))&&l.push(u);return l}a(Ua,"arrayLikeKeys");var za=Ua;function Fa(t,e){return function(r){return t(e(r))}}a(Fa,"overArg");var La=Fa,lf=La(Object.keys,Object),cf=lf,df=Object.prototype,uf=df.hasOwnProperty;function Wa(t){if(!Ba(t))return cf(t);var e=[];for(var r in Object(t))uf.call(t,r)&&r!="constructor"&&e.push(r);return e}a(Wa,"baseKeys");var pf=Wa;function qa(t){return Za(t)?za(t):pf(t)}a(qa,"keys");var ts=qa;function Va(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}a(Va,"nativeKeysIn");var ff=Va,gf=Object.prototype,hf=gf.hasOwnProperty;function Ga(t){if(!st(t))return ff(t);var e=Ba(t),r=[];for(var n in t)n=="constructor"&&(e||!hf.call(t,n))||r.push(n);return r}a(Ga,"baseKeysIn");var mf=Ga;function Ja(t){return Za(t)?za(t,!0):mf(t)}a(Ja,"keysIn");var yf=Ja,vf=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,_f=/^\w*$/;function Ya(t,e){if(ve(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||Jn(t)?!0:_f.test(t)||!vf.test(t)||e!=null&&t in Object(e)}a(Ya,"isKey");var rs=Ya,Tf=ze(Object,"create"),Ht=Tf;function Xa(){this.__data__=Ht?Ht(null):{},this.size=0}a(Xa,"hashClear");var bf=Xa;function Qa(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}a(Qa,"hashDelete");var wf=Qa,Pf="__lodash_hash_undefined__",xf=Object.prototype,kf=xf.hasOwnProperty;function eo(t){var e=this.__data__;if(Ht){var r=e[t];return r===Pf?void 0:r}return kf.call(e,t)?e[t]:void 0}a(eo,"hashGet");var Sf=eo,Ef=Object.prototype,Of=Ef.hasOwnProperty;function to(t){var e=this.__data__;return Ht?e[t]!==void 0:Of.call(e,t)}a(to,"hashHas");var Zf=to,If="__lodash_hash_undefined__";function ro(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Ht&&e===void 0?If:e,this}a(ro,"hashSet");var Bf=ro;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,"Hash");Fe.prototype.clear=bf;Fe.prototype.delete=wf;Fe.prototype.get=Sf;Fe.prototype.has=Zf;Fe.prototype.set=Bf;var ii=Fe;function no(){this.__data__=[],this.size=0}a(no,"listCacheClear");var Af=no;function so(t,e){for(var r=t.length;r--;)if(Qn(t[r][0],e))return r;return-1}a(so,"assocIndexOf");var Lr=so,Rf=Array.prototype,Cf=Rf.splice;function io(t){var e=this.__data__,r=Lr(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():Cf.call(e,r,1),--this.size,!0}a(io,"listCacheDelete");var Hf=io;function ao(t){var e=this.__data__,r=Lr(e,t);return r<0?void 0:e[r][1]}a(ao,"listCacheGet");var Df=ao;function oo(t){return Lr(this.__data__,t)>-1}a(oo,"listCacheHas");var Nf=oo;function lo(t,e){var r=this.__data__,n=Lr(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this}a(lo,"listCacheSet");var Mf=lo;function Le(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}a(Le,"ListCache");Le.prototype.clear=Af;Le.prototype.delete=Hf;Le.prototype.get=Df;Le.prototype.has=Nf;Le.prototype.set=Mf;var Wr=Le,$f=ze(_e,"Map"),Dt=$f;function co(){this.size=0,this.__data__={hash:new ii,map:new(Dt||Wr),string:new ii}}a(co,"mapCacheClear");var jf=co;function uo(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}a(uo,"isKeyable");var Kf=uo;function po(t,e){var r=t.__data__;return Kf(e)?r[typeof e=="string"?"string":"hash"]:r.map}a(po,"getMapData");var qr=po;function fo(t){var e=qr(this,t).delete(t);return this.size-=e?1:0,e}a(fo,"mapCacheDelete");var Uf=fo;function go(t){return qr(this,t).get(t)}a(go,"mapCacheGet");var zf=go;function ho(t){return qr(this,t).has(t)}a(ho,"mapCacheHas");var Ff=ho;function mo(t,e){var r=qr(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this}a(mo,"mapCacheSet");var Lf=mo;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=jf;We.prototype.delete=Uf;We.prototype.get=zf;We.prototype.has=Ff;We.prototype.set=Lf;var Vr=We,Wf="Expected a function";function Gr(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(Wf);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 qf=Gr,Vf=500;function yo(t){var e=qf(t,function(n){return r.size===Vf&&r.clear(),n}),r=e.cache;return e}a(yo,"memoizeCapped");var Gf=yo,Jf=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Yf=/\\(\\)?/g,Xf=Gf(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(Jf,function(r,n,s,i){e.push(s?i.replace(Yf,"$1"):n||r)}),e}),Qf=Xf;function vo(t){return t==null?"":qu(t)}a(vo,"toString");var eg=vo;function _o(t,e){return ve(t)?t:rs(t,e)?[t]:Qf(eg(t))}a(_o,"castPath");var Jr=_o,tg=1/0;function To(t){if(typeof t=="string"||Jn(t))return t;var e=t+"";return e=="0"&&1/t==-tg?"-0":e}a(To,"toKey");var Kt=To;function bo(t,e){e=Jr(e,t);for(var r=0,n=e.length;t!=null&&r<n;)t=t[Kt(e[r++])];return r&&r==n?t:void 0}a(bo,"baseGet");var ns=bo;function wo(t,e,r){var n=t==null?void 0:ns(t,e);return n===void 0?r:n}a(wo,"get");var rg=wo;function Po(t,e){for(var r=-1,n=e.length,s=t.length;++r<n;)t[s+r]=e[r];return t}a(Po,"arrayPush");var xo=Po,ng=La(Object.getPrototypeOf,Object),ko=ng,sg="[object Object]",ig=Function.prototype,ag=Object.prototype,So=ig.toString,og=ag.hasOwnProperty,lg=So.call(Object);function Eo(t){if(!Ne(t)||Ke(t)!=sg)return!1;var e=ko(t);if(e===null)return!0;var r=og.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&So.call(r)==lg}a(Eo,"isPlainObject");var ai=Eo;function Oo(){this.__data__=new Wr,this.size=0}a(Oo,"stackClear");var cg=Oo;function Zo(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}a(Zo,"stackDelete");var dg=Zo;function Io(t){return this.__data__.get(t)}a(Io,"stackGet");var ug=Io;function Bo(t){return this.__data__.has(t)}a(Bo,"stackHas");var pg=Bo,fg=200;function Ao(t,e){var r=this.__data__;if(r instanceof Wr){var n=r.__data__;if(!Dt||n.length<fg-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(Ao,"stackSet");var gg=Ao;function qe(t){var e=this.__data__=new Wr(t);this.size=e.size}a(qe,"Stack");qe.prototype.clear=cg;qe.prototype.delete=dg;qe.prototype.get=ug;qe.prototype.has=pg;qe.prototype.set=gg;var Yt=qe;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 hg=Ro;function Co(){return[]}a(Co,"stubArray");var Ho=Co,mg=Object.prototype,yg=mg.propertyIsEnumerable,oi=Object.getOwnPropertySymbols,vg=oi?function(t){return t==null?[]:(t=Object(t),hg(oi(t),function(e){return yg.call(t,e)}))}:Ho,Do=vg,_g=Object.getOwnPropertySymbols,Tg=_g?function(t){for(var e=[];t;)xo(e,Do(t)),t=ko(t);return e}:Ho,bg=Tg;function No(t,e,r){var n=e(t);return ve(t)?n:xo(n,r(t))}a(No,"baseGetAllKeys");var Mo=No;function $o(t){return Mo(t,ts,Do)}a($o,"getAllKeys");var li=$o;function jo(t){return Mo(t,yf,bg)}a(jo,"getAllKeysIn");var wg=jo,Pg=ze(_e,"DataView"),jn=Pg,xg=ze(_e,"Promise"),Kn=xg,kg=ze(_e,"Set"),Un=kg,ci="[object Map]",Sg="[object Object]",di="[object Promise]",ui="[object Set]",pi="[object WeakMap]",fi="[object DataView]",Eg=Ue(jn),Og=Ue(Dt),Zg=Ue(Kn),Ig=Ue(Un),Bg=Ue(Mn),Be=Ke;(jn&&Be(new jn(new ArrayBuffer(1)))!=fi||Dt&&Be(new Dt)!=ci||Kn&&Be(Kn.resolve())!=di||Un&&Be(new Un)!=ui||Mn&&Be(new Mn)!=pi)&&(Be=a(function(t){var e=Ke(t),r=e==Sg?t.constructor:void 0,n=r?Ue(r):"";if(n)switch(n){case Eg:return fi;case Og:return ci;case Zg:return di;case Ig:return ui;case Bg:return pi}return e},"getTag"));var gi=Be,Ag=_e.Uint8Array,hi=Ag,Rg="__lodash_hash_undefined__";function Ko(t){return this.__data__.set(t,Rg),this}a(Ko,"setCacheAdd");var Cg=Ko;function Uo(t){return this.__data__.has(t)}a(Uo,"setCacheHas");var Hg=Uo;function Nt(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new Vr;++e<r;)this.add(t[e])}a(Nt,"SetCache");Nt.prototype.add=Nt.prototype.push=Cg;Nt.prototype.has=Hg;var Dg=Nt;function zo(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(zo,"arraySome");var Ng=zo;function Fo(t,e){return t.has(e)}a(Fo,"cacheHas");var Mg=Fo,$g=1,jg=2;function Lo(t,e,r,n,s,i){var o=r&$g,l=t.length,d=e.length;if(l!=d&&!(o&&d>l))return!1;var u=i.get(t),g=i.get(e);if(u&&g)return u==e&&g==t;var m=-1,T=!0,Z=r&jg?new Dg:void 0;for(i.set(t,e),i.set(e,t);++m<l;){var k=t[m],K=e[m];if(n)var F=o?n(K,k,m,e,t,i):n(k,K,m,t,e,i);if(F!==void 0){if(F)continue;T=!1;break}if(Z){if(!Ng(e,function(Q,ie){if(!Mg(Z,ie)&&(k===Q||s(k,Q,r,n,i)))return Z.push(ie)})){T=!1;break}}else if(!(k===K||s(k,K,r,n,i))){T=!1;break}}return i.delete(t),i.delete(e),T}a(Lo,"equalArrays");var Wo=Lo;function qo(t){var e=-1,r=Array(t.size);return t.forEach(function(n,s){r[++e]=[s,n]}),r}a(qo,"mapToArray");var Kg=qo;function Vo(t){var e=-1,r=Array(t.size);return t.forEach(function(n){r[++e]=n}),r}a(Vo,"setToArray");var Ug=Vo,zg=1,Fg=2,Lg="[object Boolean]",Wg="[object Date]",qg="[object Error]",Vg="[object Map]",Gg="[object Number]",Jg="[object RegExp]",Yg="[object Set]",Xg="[object String]",Qg="[object Symbol]",eh="[object ArrayBuffer]",th="[object DataView]",mi=xe?xe.prototype:void 0,Bn=mi?mi.valueOf:void 0;function Go(t,e,r,n,s,i,o){switch(r){case th:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case eh:return!(t.byteLength!=e.byteLength||!i(new hi(t),new hi(e)));case Lg:case Wg:case Gg:return Qn(+t,+e);case qg:return t.name==e.name&&t.message==e.message;case Jg:case Xg:return t==e+"";case Vg:var l=Kg;case Yg:var d=n&zg;if(l||(l=Ug),t.size!=e.size&&!d)return!1;var u=o.get(t);if(u)return u==e;n|=Fg,o.set(t,e);var g=Wo(l(t),l(e),n,s,i,o);return o.delete(t),g;case Qg:if(Bn)return Bn.call(t)==Bn.call(e)}return!1}a(Go,"equalByTag");var rh=Go,nh=1,sh=Object.prototype,ih=sh.hasOwnProperty;function Jo(t,e,r,n,s,i){var o=r&nh,l=li(t),d=l.length,u=li(e),g=u.length;if(d!=g&&!o)return!1;for(var m=d;m--;){var T=l[m];if(!(o?T in e:ih.call(e,T)))return!1}var Z=i.get(t),k=i.get(e);if(Z&&k)return Z==e&&k==t;var K=!0;i.set(t,e),i.set(e,t);for(var F=o;++m<d;){T=l[m];var Q=t[T],ie=e[T];if(n)var ue=o?n(ie,Q,T,e,t,i):n(Q,ie,T,t,e,i);if(!(ue===void 0?Q===ie||s(Q,ie,r,n,i):ue)){K=!1;break}F||(F=T=="constructor")}if(K&&!F){var ae=t.constructor,ee=e.constructor;ae!=ee&&"constructor"in t&&"constructor"in e&&!(typeof ae=="function"&&ae instanceof ae&&typeof ee=="function"&&ee instanceof ee)&&(K=!1)}return i.delete(t),i.delete(e),K}a(Jo,"equalObjects");var ah=Jo,oh=1,yi="[object Arguments]",vi="[object Array]",Jt="[object Object]",lh=Object.prototype,_i=lh.hasOwnProperty;function Yo(t,e,r,n,s,i){var o=ve(t),l=ve(e),d=o?vi:gi(t),u=l?vi:gi(e);d=d==yi?Jt:d,u=u==yi?Jt:u;var g=d==Jt,m=u==Jt,T=d==u;if(T&&$n(t)){if(!$n(e))return!1;o=!0,g=!1}if(T&&!g)return i||(i=new Yt),o||Ka(t)?Wo(t,e,r,n,s,i):rh(t,e,d,r,n,s,i);if(!(r&oh)){var Z=g&&_i.call(t,"__wrapped__"),k=m&&_i.call(e,"__wrapped__");if(Z||k){var K=Z?t.value():t,F=k?e.value():e;return i||(i=new Yt),s(K,F,r,n,i)}}return T?(i||(i=new Yt),ah(t,e,r,n,s,i)):!1}a(Yo,"baseIsEqualDeep");var ch=Yo;function ss(t,e,r,n,s){return t===e?!0:t==null||e==null||!Ne(t)&&!Ne(e)?t!==t&&e!==e:ch(t,e,r,n,ss,s)}a(ss,"baseIsEqual");var Yr=ss,dh=1,uh=2;function Xo(t,e,r,n){var s=r.length,i=s,o=!n;if(t==null)return!i;for(t=Object(t);s--;){var l=r[s];if(o&&l[2]?l[1]!==t[l[0]]:!(l[0]in t))return!1}for(;++s<i;){l=r[s];var d=l[0],u=t[d],g=l[1];if(o&&l[2]){if(u===void 0&&!(d in t))return!1}else{var m=new Yt;if(n)var T=n(u,g,d,t,e,m);if(!(T===void 0?Yr(g,u,dh|uh,n,m):T))return!1}}return!0}a(Xo,"baseIsMatch");var ph=Xo;function Qo(t){return t===t&&!st(t)}a(Qo,"isStrictComparable");var el=Qo;function tl(t){for(var e=ts(t),r=e.length;r--;){var n=e[r],s=t[n];e[r]=[n,s,el(s)]}return e}a(tl,"getMatchData");var fh=tl;function rl(t,e){return function(r){return r==null?!1:r[t]===e&&(e!==void 0||t in Object(r))}}a(rl,"matchesStrictComparable");var nl=rl;function sl(t){var e=fh(t);return e.length==1&&e[0][2]?nl(e[0][0],e[0][1]):function(r){return r===t||ph(r,t,e)}}a(sl,"baseMatches");var gh=sl;function il(t,e){return t!=null&&e in Object(t)}a(il,"baseHasIn");var hh=il;function al(t,e,r){e=Jr(e,t);for(var n=-1,s=e.length,i=!1;++n<s;){var o=Kt(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&&es(s)&&Xn(o,s)&&(ve(t)||Ha(t)))}a(al,"hasPath");var mh=al;function ol(t,e){return t!=null&&mh(t,e,hh)}a(ol,"hasIn");var yh=ol,vh=1,_h=2;function ll(t,e){return rs(t)&&el(e)?nl(Kt(t),e):function(r){var n=rg(r,t);return n===void 0&&n===e?yh(r,t):Yr(e,n,vh|_h)}}a(ll,"baseMatchesProperty");var Th=ll;function cl(t){return function(e){return e?.[t]}}a(cl,"baseProperty");var bh=cl;function dl(t){return function(e){return ns(e,t)}}a(dl,"basePropertyDeep");var wh=dl;function ul(t){return rs(t)?bh(Kt(t)):wh(t)}a(ul,"property");var Ph=ul;function pl(t){return typeof t=="function"?t:t==null?Vu:typeof t=="object"?ve(t)?Th(t[0],t[1]):gh(t):Ph(t)}a(pl,"baseIteratee");var is=pl;function fl(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(fl,"createBaseFor");var xh=fl,kh=xh(),Sh=kh;function gl(t,e){return t&&Sh(t,e,ts)}a(gl,"baseForOwn");var Eh=gl;function hl(t,e){return Yr(t,e)}a(hl,"isEqual");var rt=hl;function ml(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(ml,"isEqualWith");var Oh=ml;function yl(t){return t===void 0}a(yl,"isUndefined");var Ti=yl;function vl(t,e){var r={};return e=is(e,3),Eh(t,function(n,s,i){xa(r,s,e(n,s,i))}),r}a(vl,"mapValues");var Zh=vl,Ih="Expected a function";function _l(t){if(typeof t!="function")throw new TypeError(Ih);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(_l,"negate");var Bh=_l;function Tl(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=Kt(e[s]),u=r;if(d==="__proto__"||d==="constructor"||d==="prototype")return t;if(s!=o){var g=l[d];u=n?n(g,d,l):void 0,u===void 0&&(u=st(g)?g:Xn(e[s+1])?[]:{})}vp(l,d,u),l=l[d]}return t}a(Tl,"baseSet");var Ah=Tl;function bl(t,e,r){for(var n=-1,s=e.length,i={};++n<s;){var o=e[n],l=ns(t,o);r(l,o)&&Ah(i,Jr(o,t),l)}return i}a(bl,"basePickBy");var Rh=bl;function wl(t,e){if(t==null)return{};var r=pa(wg(t),function(n){return[n]});return e=is(e),Rh(t,r,function(n,s){return e(n,s[0])})}a(wl,"pickBy");var Ch=wl;function Pl(t,e){return Ch(t,Bh(is(e)))}a(Pl,"omitBy");var bi=Pl,Hh=a(t=>{let e=t.checks;return e.length===0?"":e.map(Dh).join("")},"generateStringChecks"),Dh=a(t=>{switch(t.kind){case"min":return`.min(${b(t.value)}, ${b(t.message)})`;case"max":return`.max(${b(t.value)}, ${b(t.message)})`;case"length":return`.length(${b(t.value)}, ${b(t.message)})`;case"email":return`.email(${b(t.message)})`;case"url":return`.url(${b(t.message)})`;case"emoji":return`.emoji(${b(t.message)})`;case"uuid":return`.uuid(${b(t.message)})`;case"cuid":return`.cuid(${b(t.message)})`;case"cuid2":return`.cuid2(${b(t.message)})`;case"ulid":return`.ulid(${b(t.message)})`;case"includes":let e=tt({message:t.message,position:t.position});return`.includes(${b(t.value)}, ${e})`;case"startsWith":return`.startsWith(${b(t.value)}, ${b(t.message)})`;case"endsWith":return`.endsWith(${b(t.value)}, ${b(t.message)})`;case"regex":return`.regex(${String(t.regex)}, ${b(t.message)})`;case"trim":return".trim()";case"toLowerCase":return".toLowerCase()";case"toUpperCase":return".toUpperCase()";case"datetime":let n=t.precision===null?void 0:t.precision;return`.datetime(${tt({message:t.message,precision:n,offset:t.offset})})`;case"ip":return`.ip(${tt({message:t.message,version:t.version})})`;default:return""}},"_generateStringCheck"),Nh=a(t=>{let e=t.checks;return e.length===0?"":e.map(Mh).join("")},"generateNumberChecks"),Mh=a(t=>{switch(t.kind){case"min":return`.min(${b(t.value)}, ${b(t.message)})`;case"max":return`.max(${b(t.value)}, ${b(t.message)})`;case"int":return`.int(${b(t.message)})`;case"multipleOf":return`.multipleOf(${b(t.value)}, ${b(t.message)})`;case"finite":return`.finite(${b(t.message)})`;default:return""}},"_generateNumberCheck"),$h=a(t=>{let e=t.checks;return e.length===0?"":e.map(jh).join("")},"generateBigIntChecks"),jh=a(t=>{switch(t.kind){case"min":return`.min(${b(t.value)}, ${b(t.message)})`;case"max":return`.max(${b(t.value)}, ${b(t.message)})`;case"multipleOf":return`.multipleOf(${b(t.value)}, ${b(t.message)})`;default:return""}},"_generateBigIntCheck"),Kh=a(t=>{let e=t.checks;return e.length===0?"":e.map(Uh).join("")},"generateDateChecks"),Uh=a(t=>{switch(t.kind){case"min":return`.min(${wi(t.value)}, ${b(t.message)})`;case"max":return`.max(${wi(t.value)}, ${b(t.message)})`;default:return""}},"_generateDateCheck"),wi=a(t=>`new Date(${t})`,"dateTs"),zh=a(t=>{let e=[];if(t.exactLength){let{value:r,message:n}=t.exactLength;e.push(`.length(${b(r)}, ${b(n)})`)}if(t.minLength){let{value:r,message:n}=t.minLength;e.push(`.min(${b(r)}, ${b(n)})`)}if(t.maxLength){let{value:r,message:n}=t.maxLength;e.push(`.max(${b(r)}, ${b(n)})`)}return e.join("")},"generateArrayChecks"),Fh=a(t=>{let e=[];if(t.minSize){let{value:r,message:n}=t.minSize;e.push(`.min(${b(r)}, ${b(n)})`)}if(t.maxSize){let{value:r,message:n}=t.maxSize;e.push(`.max(${b(r)}, ${b(n)})`)}return e.join("")},"generateSetChecks");function as(t){return M(t)}a(as,"toTypescriptSchema");function M(t){let r=t._def;switch(r.typeName){case p.ZodFirstPartyTypeKind.ZodString:return`z.string()${Hh(r)}${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodNumber:return`z.number()${Nh(r)}${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodNaN:return`z.nan()${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodBigInt:return`z.bigint()${$h(r)}${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodBoolean:return`z.boolean()${C(r)}${R(t._def)}`.trim();case p.ZodFirstPartyTypeKind.ZodDate:return`z.date()${Kh(r)}${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodUndefined:return`z.undefined()${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodNull:return`z.null()${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodAny:return`z.any()${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodUnknown:return`z.unknown()${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodNever:return`z.never()${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodVoid:return`z.void()${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodArray:return`z.array(${M(r.type)})${zh(r)}${C(r)}${R(r)}`;case p.ZodFirstPartyTypeKind.ZodObject:let n=Zh(r.shape(),M),s=t.additionalProperties(),i=s?`.catchall(${M(s)})`:"";return["z.object({",...Object.entries(n).map(([gu,hu])=>` ${gu}: ${hu},`),`})${i}${C(r)}${R(r)}`].join(`
|
|
16
|
+
`).trim();case p.ZodFirstPartyTypeKind.ZodUnion:return`z.union([${r.options.map(M).join(", ")}])${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:let l=r.options.map(M);return`z.discriminatedUnion(${b(r.discriminator)}, [${l.join(", ")}])${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodIntersection:let u=M(r.left),g=M(r.right);return`z.intersection(${u}, ${g})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodTuple:return`z.tuple([${r.items.map(M).join(", ")}])${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodRecord:let T=M(r.keyType),Z=M(r.valueType);return`z.record(${T}, ${Z})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodMap:let k=M(r.keyType),K=M(r.valueType);return`z.map(${k}, ${K})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodSet:return`z.set(${M(r.valueType)})${Fh(r)}${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodFunction:let F=r.args.items.map(M),Q=F.length?`.args(${F.join(", ")})`:"",ie=M(r.returns);return`z.function()${Q}.returns(${ie})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodLazy:return`z.lazy(() => ${M(r.getter())})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodLiteral:return`z.literal(${b(r.value)})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodEnum:return`z.enum([${r.values.map(b).join(", ")}])${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodEffects:throw new Ie(p.ZodFirstPartyTypeKind.ZodEffects);case p.ZodFirstPartyTypeKind.ZodNativeEnum:throw new Ie(p.ZodFirstPartyTypeKind.ZodNativeEnum);case p.ZodFirstPartyTypeKind.ZodOptional:return`z.optional(${M(r.innerType)})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodNullable:return`z.nullable(${M(r.innerType)})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodDefault:let ee=tt(r.defaultValue());return`z.default(${M(r.innerType)}, ${ee})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodCatch:throw new Ie(p.ZodFirstPartyTypeKind.ZodCatch);case p.ZodFirstPartyTypeKind.ZodPromise:return`z.promise(${M(r.type)})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodBranded:throw new Ie(p.ZodFirstPartyTypeKind.ZodBranded);case p.ZodFirstPartyTypeKind.ZodPipeline:throw new Ie(p.ZodFirstPartyTypeKind.ZodPipeline);case p.ZodFirstPartyTypeKind.ZodSymbol:throw new Ie(p.ZodFirstPartyTypeKind.ZodSymbol);case p.ZodFirstPartyTypeKind.ZodReadonly:return`z.readonly(${M(r.innerType)})${C(r)}${R(r)}`.trim();case p.ZodFirstPartyTypeKind.ZodRef:return`z.ref(${b(r.uri)})${C(r)}${R(r)}`.trim();default:I.assertNever(r)}}a(M,"sUnwrapZod");var R=a(t=>t.description?`.describe(${b(t.description)})`:"","_maybeDescribe"),C=a(t=>`${Lh(t)}${Wh(t)}${qh(t)}${Vh(t)}${Gh(t)}${Jh(t)}${Yh(t)}`,"_addZuiExtensions"),Lh=a(t=>{var e;return(e=t[w])!=null&&e.title?`.title(${b(t[w].title)})`:""},"_maybeTitle"),Wh=a(t=>{var e;return(e=t[w])!=null&&e.displayAs?`.displayAs(${Ai({id:t[w].displayAs[0],params:t[w].displayAs[1]})})`:""},"_maybeDisplayAs"),qh=a(t=>{var e;return(e=t[w])!=null&&e.disabled?`.disabled(${t[w].disabled})`:""},"_maybeDisabled"),Vh=a(t=>{var e;return(e=t[w])!=null&&e.hidden?`.hidden(${t[w].hidden})`:""},"_maybeHidden"),Gh=a(t=>{var e;return(e=t[w])!=null&&e.placeholder?`.placeholder(${b(t[w].placeholder)})`:""},"_maybePlaceholder"),Jh=a(t=>{var e;return(e=t[w])!=null&&e.secret?".secret()":""},"_maybeSecret"),Yh=a(t=>{var e;let r=["title","tooltip","displayAs","disabled","hidden","placeholder","secret","coerce"],n=Object.entries((e=t[w])!=null?e:{}).filter(([s])=>!r.includes(s));return n.length>0?`.metadata(${Ai(Object.fromEntries(n))})`:""},"_maybeSetMetadata"),Xh=a(t=>{let e={type:"number",description:t.description,"x-zui":t._def["x-zui"]};t._def[w]&&(e[w]=t._def[w]);for(let r of t._def.checks)switch(r.kind){case"min":{let n=r.inclusive?"minimum":"exclusiveMinimum",s=r.inclusive?"exclusiveMinimum":"minimum";e[n]=r.value,delete e[s];break}case"max":{let n=r.inclusive?"maximum":"exclusiveMaximum",s=r.inclusive?"exclusiveMaximum":"maximum";e[n]=r.value,delete e[s];break}case"int":e.type="integer";break;case"finite":{e.format="finite";break}case"multipleOf":e.multipleOf=r.value;break;default:}return e},"zodNumberToJsonNumber"),xl="\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}",kl="(([+-]\\d{2}(:?\\d{2})?)|Z)",Qh="Z",Sl="(\\.\\d+)?",zn="\\.\\d{",em="}",El=a(t=>{let e=t.precision?zn+t.precision+em:t.precision===0?"":Sl,r=t.offset?kl:Qh;return new RegExp(`^${xl}${e}${r}$`)},"generateDatetimeRegex"),tm=a(t=>({precision:rm(t),offset:t.endsWith(`${kl}$`)}),"extractPrecisionAndOffset"),rm=a(t=>{let e=t.slice(1+xl.length);return e.startsWith(Sl)?null:e.startsWith(zn)?parseInt(e.slice(zn.length)):0},"_extractPrecision"),Ct={};Kr(Ct,{escapeSpecialChars:()=>nm});var nm=a(t=>t.replaceAll(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeSpecialChars");function os(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage=f(c({},t.errorMessage),{[e]:r}))}a(os,"addErrorMessage");function H(t,e,r,n,s){t[e]=r,os(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 ls(t,e){let r=c({type:"string"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{});function n(s){return e.patternStrategy==="escape"?Ct.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":Ze(r,"email",s.message,e);break;case"format:idn-email":Ze(r,"idn-email",s.message,e);break;case"pattern:zod":ge(r,j.email,s.message,e);break}break;case"url":Ze(r,"uri",s.message,e);break;case"uuid":Ze(r,"uuid",s.message,e);break;case"regex":ge(r,s.regex.source,s.message,e);break;case"cuid":ge(r,j.cuid,s.message,e);break;case"cuid2":ge(r,j.cuid2,s.message,e);break;case"startsWith":ge(r,"^"+n(s.value),s.message,e);break;case"endsWith":ge(r,n(s.value)+"$",s.message,e);break;case"datetime":Ze(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":{ge(r,n(s.value),s.message,e);break}case"ip":{s.version!=="v6"&&Ze(r,"ipv4",s.message,e),s.version!=="v4"&&Ze(r,"ipv6",s.message,e);break}case"emoji":ge(r,j.emoji,s.message,e);break;case"ulid":{ge(r,j.ulid,s.message,e);break}case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}a(ls,"parseStringDef");var Ze=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"),ge=a((t,e,r,n)=>{var s;t.pattern||(s=t.allOf)!=null&&s.some(i=>i.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push(c({pattern:t.pattern},t.errorMessage&&n.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}})),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push(c({pattern:e},r&&n.errorMessages&&{errorMessage:{pattern:r}}))):H(t,"pattern",e,r,n)},"addPattern"),sm=a(t=>{let e={type:"string",description:t.description,"x-zui":t._def["x-zui"]};t._def[w]&&(e[w]=t._def[w]);for(let r of t._def.checks)switch(r.kind){case"cuid":e.format="cuid",e.pattern=j.cuid;break;case"cuid2":e.format="cuid2",e.pattern=j.cuid2;break;case"ulid":e.format="ulid",e.pattern=j.ulid;break;case"uuid":e.format="uuid",e.pattern=j.uuid;break;case"emoji":e.format="emoji",e.pattern=j.emoji;break;case"email":e.format="email",e.pattern=j.email;break;case"ip":e.format=r.version==="v6"?"ipv6":"ipv4",e.pattern=r.version==="v6"?j.ipv6:j.ipv4;break;case"datetime":e.format="date-time",e.pattern=El(r).source,e[w]=f(c({},e[w]),{precision:r.precision,offset:r.offset});break;case"url":e.format="uri";break;case"endsWith":e.pattern=`${Ct.escapeSpecialChars(r.value)}$`;break;case"startsWith":e.pattern=`^${Ct.escapeSpecialChars(r.value)}`;break;case"includes":let n=r.position&&r.position>=1?`^(?:.{${r.position}}).*`:"";e.pattern=`${n}${Ct.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 Ui({zodType:p.ZodFirstPartyTypeKind.ZodString,checkKind:r.kind})}return e},"zodStringToJsonString"),im=a((t,e)=>{let r={type:"array",description:t.description,items:e(t._def.type),"x-zui":t._def["x-zui"]};return t._def[w]&&(r[w]=t._def[w]),t._def.minLength&&(r.minItems=t._def.minLength.value),t._def.maxLength&&(r.maxItems=t._def.maxLength.value),t._def.exactLength&&(r.minItems=t._def.exactLength.value,r.maxItems=t._def.exactLength.value),r},"zodArrayToJsonArray"),am=a((t,e)=>{let r={type:"array",description:t.description,uniqueItems:!0,items:e(t._def.valueType),"x-zui":t._def["x-zui"]};return t._def[w]&&(r[w]=t._def[w]),t._def.minSize&&(r.minItems=t._def.minSize.value),t._def.maxSize&&(r.maxItems=t._def.maxSize.value),r},"zodSetToJsonSet"),om=a((t,e)=>{let r={type:"array",description:t.description,items:t._def.items.map(n=>e(n))};return t._def[w]&&(r[w]=t._def[w]),t._def.rest&&(r.additionalItems=e(t._def.rest)),r},"zodTupleToJsonTuple");function q(t){let e=t,r=e._def;switch(r.typeName){case p.ZodFirstPartyTypeKind.ZodString:return sm(e);case p.ZodFirstPartyTypeKind.ZodNumber:return Xh(e);case p.ZodFirstPartyTypeKind.ZodNaN:throw new te(p.ZodFirstPartyTypeKind.ZodNaN);case p.ZodFirstPartyTypeKind.ZodBigInt:throw new te(p.ZodFirstPartyTypeKind.ZodBigInt,{suggestedAlternative:"serialize bigint to string"});case p.ZodFirstPartyTypeKind.ZodBoolean:return{type:"boolean",description:r.description,"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodDate:throw new te(p.ZodFirstPartyTypeKind.ZodDate,{suggestedAlternative:"use z.string().datetime() instead"});case p.ZodFirstPartyTypeKind.ZodUndefined:return An(r);case p.ZodFirstPartyTypeKind.ZodNull:return Rn(r);case p.ZodFirstPartyTypeKind.ZodAny:return{description:r.description,"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodUnknown:return{description:r.description,"x-zui":f(c({},r["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodUnknown}})};case p.ZodFirstPartyTypeKind.ZodNever:return{not:!0,description:r.description,"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodVoid:throw new te(p.ZodFirstPartyTypeKind.ZodVoid);case p.ZodFirstPartyTypeKind.ZodArray:return im(e,q);case p.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,q(m)]),l=!1;return r.unknownKeys instanceof p.ZodType?l=q(r.unknownKeys):r.unknownKeys==="passthrough"&&(l=!0),{type:"object",description:r.description,properties:Object.fromEntries(o),required:i,additionalProperties:l,"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodUnion:return{description:r.description,anyOf:r.options.map(g=>q(g)),"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:return{description:r.description,anyOf:r.options.map(g=>q(g)),"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodIntersection:let d=q(r.left),u=q(r.right);return"additionalProperties"in d&&delete d.additionalProperties,"additionalProperties"in u&&delete u.additionalProperties,{description:r.description,allOf:[d,u],"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodTuple:return om(e,q);case p.ZodFirstPartyTypeKind.ZodRecord:return{type:"object",description:r.description,additionalProperties:q(r.valueType),"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodMap:throw new te(p.ZodFirstPartyTypeKind.ZodMap);case p.ZodFirstPartyTypeKind.ZodSet:return am(e,q);case p.ZodFirstPartyTypeKind.ZodFunction:throw new te(p.ZodFirstPartyTypeKind.ZodFunction);case p.ZodFirstPartyTypeKind.ZodLazy:throw new te(p.ZodFirstPartyTypeKind.ZodLazy);case p.ZodFirstPartyTypeKind.ZodLiteral:if(typeof r.value=="string")return{type:"string",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(typeof r.value=="number")return{type:"number",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(typeof r.value=="boolean")return{type:"boolean",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(r.value===null)return Rn(r);if(r.value===void 0)return An(r);{p.util.assertEqual(!0);let g=typeof r.value;throw new zr(`Unsupported literal type: "${g}"`)}case p.ZodFirstPartyTypeKind.ZodEnum:return{type:"string",description:r.description,enum:r.values,"x-zui":r["x-zui"]};case p.ZodFirstPartyTypeKind.ZodEffects:throw new te(p.ZodFirstPartyTypeKind.ZodEffects);case p.ZodFirstPartyTypeKind.ZodNativeEnum:throw new te(p.ZodFirstPartyTypeKind.ZodNativeEnum);case p.ZodFirstPartyTypeKind.ZodOptional:return{description:r.description,anyOf:[q(r.innerType),An()],"x-zui":f(c({},r["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodOptional}})};case p.ZodFirstPartyTypeKind.ZodNullable:return{anyOf:[q(r.innerType),Rn()],"x-zui":f(c({},r["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodNullable}})};case p.ZodFirstPartyTypeKind.ZodDefault:return f(c({},q(r.innerType)),{default:r.defaultValue()});case p.ZodFirstPartyTypeKind.ZodCatch:throw new te(p.ZodFirstPartyTypeKind.ZodCatch);case p.ZodFirstPartyTypeKind.ZodPromise:throw new te(p.ZodFirstPartyTypeKind.ZodPromise);case p.ZodFirstPartyTypeKind.ZodBranded:throw new te(p.ZodFirstPartyTypeKind.ZodBranded);case p.ZodFirstPartyTypeKind.ZodPipeline:throw new te(p.ZodFirstPartyTypeKind.ZodPipeline);case p.ZodFirstPartyTypeKind.ZodSymbol:throw new te(p.ZodFirstPartyTypeKind.ZodPipeline);case p.ZodFirstPartyTypeKind.ZodReadonly:return f(c({},q(r.innerType)),{readOnly:!0});case p.ZodFirstPartyTypeKind.ZodRef:return{$ref:r.uri,description:r.description,"x-zui":r["x-zui"]};default:p.util.assertNever(r)}}a(q,"toJSONSchema");var An=a(t=>({not:!0,description:t?.description,"x-zui":f(c({},t?.["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodUndefined}})}),"undefinedSchema"),Rn=a(t=>({type:"null",description:t?.description,"x-zui":t?.["x-zui"]}),"nullSchema"),Ol=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(Ol,"ParseInputLazyPath");var oe=Ol,Pi=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 pe(t.common.issues);return this._error=r,this._error}}},"handleResult"),Zl=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 me(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:me(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:me(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if($t(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:me(e)},i=this._parseSync({data:e,path:s.path,parent:s});return Pi(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:me(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await($t(s)?s:Promise.resolve(s));return Pi(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 Se({schema:this,typeName:"ZodEffects",effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ye.create(this,this._def)}nullable(){return Me.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return lt.create(this,this._def)}promise(){return Ft.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 Se(f(c({},S(this._def)),{schema:this,typeName:"ZodEffects",effect:{type:"transform",transform:e}}))}default(e){let r=typeof e=="function"?e:()=>e;return new Ut(f(c({},S(this._def)),{innerType:this,defaultValue:r,typeName:"ZodDefault"}))}brand(){return new en(c({typeName:"ZodBranded",type:this},S(this._def)))}catch(e){let r=typeof e=="function"?e:()=>e;return new tn(f(c({},S(this._def)),{innerType:this,catchValue:r,typeName:"ZodCatch"}))}describe(e){let r=this.clone();return r._metadataRoot._def.description=e,r}pipe(e){return dn.create(this,e)}readonly(){return Lt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}metadata(e){var r,n,s;let i=this.clone(),o=i._metadataRoot;(s=(r=o._def)[n=w])!=null||(r[n]={});for(let[l,d]of Object.entries(e))o._def[w]=f(c({},o._def[w]),{[l]:d});return i}getMetadata(){return c({},this._metadataRoot._def[w])}setMetadata(e){this._metadataRoot._def[w]=c({},e)}get ui(){return c({},this._metadataRoot._def[w])}get _metadataRoot(){return this.naked()}displayAs(e){return this.metadata({displayAs:[e.id,e.params]})}title(e){return this.metadata({title:e})}hidden(e){let r;return e===void 0?r=!0:typeof e=="function"?r=e.toString():r=e,this.metadata({hidden:r})}disabled(e){let r;return e===void 0?r=!0:typeof e=="function"?r=e.toString():r=e,this.metadata({disabled:r})}placeholder(e){return this.metadata({placeholder:e})}toJSONSchema(){return q(this)}toTypescriptType(e){return Gn(this,e)}toTypescriptSchema(){return as(this)}naked(){return this}};a(Zl,"ZodType");var O=Zl,cs=(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))(cs||{}),I;(t=>{t.assertEqual=a(s=>s,"assertEqual");function e(s){}t.assertIs=e,a(e,"assertIs");function r(s){throw new Error("assertNever called")}t.assertNever=r,a(r,"assertNever"),t.arrayToEnum=a(s=>{let i={};for(let o of s)i[o]=o;return i},"arrayToEnum"),t.getValidEnumValues=a(s=>{let i=(0,t.objectKeys)(s).filter(l=>typeof s[s[l]]!="number"),o={};for(let l of i)o[l]=s[l];return(0,t.objectValues)(o)},"getValidEnumValues"),t.objectValues=a(s=>(0,t.objectKeys)(s).map(function(i){return s[i]}),"objectValues"),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=a((s,i)=>{for(let o of s)if(i(o))return o},"find"),t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=n,a(n,"joinValues"),t.jsonStringifyReplacer=a((s,i)=>typeof i=="bigint"?i.toString():i,"jsonStringifyReplacer"),t.compareFunctions=a((s,i)=>s.toString()===i.toString(),"compareFunctions"),t.mock=a(()=>({}),"mock")})(I||(I={}));var ar;(t=>{t.mergeShapes=a((e,r)=>c(c({},e),r),"mergeShapes")})(ar||(ar={}));var _=I.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),me=a(t=>{switch(typeof t){case"undefined":return _.undefined;case"string":return _.string;case"number":return isNaN(t)?_.nan:_.number;case"boolean":return _.boolean;case"function":return _.function;case"bigint":return _.bigint;case"symbol":return _.symbol;case"object":return Array.isArray(t)?_.array:t===null?_.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?_.promise:typeof Map<"u"&&t instanceof Map?_.map:typeof Set<"u"&&t instanceof Set?_.set:typeof Date<"u"&&t instanceof Date?_.date:_.object;default:return _.unknown}},"getParsedType");function S(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s,supportsExtensions:i,[w]:o}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);let l=o?Object.fromEntries(Object.entries(o).filter(([u])=>u!=="secret"||i?.includes("secret"))):void 0;return e?{errorMap:e,description:s,[w]:l}:{errorMap:a((u,g)=>u.code!=="invalid_type"?{message:g.defaultError}:typeof g.data>"u"?{message:n??g.defaultError}:{message:r??g.defaultError},"customMap"),description:s,[w]:l}}a(S,"processCreateParams");var ds=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,I.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:r=`Unrecognized key(s) in object: ${I.joinValues(t.keys,", ")}`;break;case h.invalid_union:r="Invalid input";break;case h.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${I.joinValues(t.options)}`;break;case h.invalid_enum_value:r=`Invalid enum value. Expected ${I.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}"`:I.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,I.assertNever(t)}return{message:r}},"errorMap"),xi=ds,h=I.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite","unresolved_reference"]),Il=a(t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),or=class Bl extends Error{constructor(e){super(),this.issues=[],this.addIssue=a(n=>{this.issues=[...this.issues,n]},"addIssue"),this.addIssues=a((n=[])=>{this.issues=[...this.issues,...n]},"addIssues");let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let r=e||function(i){return i.message},n={_errors:[]},s=a(i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)n._errors.push(r(o));else{let l=n,d=0;for(;d<o.path.length;){let u=o.path[d];d===o.path.length-1?(l[u]=l[u]||{_errors:[]},l[u]._errors.push(r(o))):l[u]=l[u]||{_errors:[]},l=l[u],d++}}},"processError");return s(this),n}static assert(e){if(!(e instanceof Bl))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,I.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};a(or,"ZodError");or.create=a(t=>new or(t),"create");var pe=or,Al=ds;function us(t){Al=t}a(us,"setErrorMap");function it(){return Al}a(it,"getErrorMap");var Mt=a(t=>{var e;let{data:r,path:n,errorMaps:s,issueData:i}=t,o=[...n,...i.path||[]],l=f(c({},i),{path:o}),d="",u=s.filter(g=>!!g).slice().reverse();for(let g of u)d=g(l,{data:r,defaultError:d}).message;return f(c({},i),{path:o,message:(e=i.message)!=null?e:d})},"makeIssue"),Rl=[];function v(t,e){let r=Mt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,it(),ds].filter(n=>!!n)});t.common.issues.push(r)}a(v,"addIssueToContext");var Cl=class Hl{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 Hl.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(Cl,"ParseStatus");var re=Cl,x=Object.freeze({status:"aborted"}),De=a(t=>({status:"dirty",value:t}),"DIRTY"),G=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"),$t=a(t=>typeof Promise<"u"&&t instanceof Promise,"isAsync"),P;(t=>{t.errToObj=a(e=>typeof e=="string"?{message:e}:e||{},"errToObj"),t.toString=a(e=>typeof e=="string"?e:e?.message,"toString")})(P||(P={}));var dr=class Dl extends O{constructor(){super(...arguments),this._any=!0}_parse(e){return G(e.data)}isEqual(e){return e instanceof Dl}};a(dr,"ZodAny");dr.create=a(t=>new dr(c({typeName:"ZodAny"},S(t))),"create");var ot=dr,ur=class Ae extends O{dereference(e){return new Ae(f(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new Ae(f(c({},this._def),{type:this._def.type.clone()}))}isEqual(e){var r,n,s,i,o,l;return e instanceof Ae?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 Ae(f(c({},this._def),{minLength:{value:e,message:P.toString(r)}}))}max(e,r){return new Ae(f(c({},this._def),{maxLength:{value:e,message:P.toString(r)}}))}length(e,r){return new Ae(f(c({},this._def),{exactLength:{value:e,message:P.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"},S(e))),"create");var lt=ur,lm=a((t,e)=>Nl(t,e,new WeakSet),"isEqual"),Nl=a((t,e,r)=>Oh(t,e,cm(r)),"_isEqualWithVisitedTracking"),cm=a(t=>(e,r)=>{if(ai(e)&&!t.has(e)&&ai(r)&&!t.has(r)){let n=bi(e,Ti),s=bi(r,Ti);return t.add(n).add(s).add(e).add(r),Nl(n,s,t)}},"_customizerWithVisitedTracking"),dm={compare:lm},Ml=class{constructor(e=[],r={}){this._options=c(c({},dm),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(Ml,"CustomSet");var U=Ml,pr=class Xt 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 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()):I.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 U(this._def.checks),n=new U(e._def.checks);return r.isEqual(n)}gte(e,r){return this.setLimit("min",e,!0,P.toString(r))}gt(e,r){return this.setLimit("min",e,!1,P.toString(r))}lte(e,r){return this.setLimit("max",e,!0,P.toString(r))}lt(e,r){return this.setLimit("max",e,!1,P.toString(r))}setLimit(e,r,n,s){return new Xt(f(c({},this._def),{checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:P.toString(s)}]}))}_addCheck(e){return new Xt(f(c({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:P.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:P.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:P.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:P.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:P.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};a(pr,"ZodBigInt");pr.create=a(t=>{var e;return new pr(c({checks:[],typeName:"ZodBigInt",coerce:(e=t?.coerce)!=null?e:!1},S(t)))},"create");var Xr=pr,fr=class $l 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 G(e.data)}isEqual(e){return e instanceof $l?this._def.coerce===e._def.coerce:!1}};a(fr,"ZodBoolean");fr.create=a(t=>new fr(c({typeName:"ZodBoolean",coerce:t?.coerce||!1},S(t))),"create");var Qr=fr,jl=Symbol("zod_brand"),Kl=class Tt extends O{dereference(e){return new Tt(f(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new Tt(f(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}isEqual(e){return e instanceof Tt?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}mandatory(){return new Tt(f(c({},this._def),{type:this._def.type.mandatory()}))}};a(Kl,"ZodBranded");var en=Kl,gr=class bt extends O{_parse(e){let{ctx:r}=this._processInputParams(e),n=f(c({},r),{common:f(c({},r.common),{issues:[]})}),s=this._def.innerType._parse({data:n.data,path:n.path,parent:c({},n)});return $t(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new pe(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new pe(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}isEqual(e){return e instanceof bt?this._def.innerType.isEqual(e._def.innerType)&&I.compareFunctions(this._def.catchValue,e._def.catchValue):!1}dereference(e){return new bt(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new bt(f(c({},this._def),{innerType:this._def.innerType.clone()}))}naked(){return this._def.innerType.naked()}mandatory(){return new bt(f(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},S(e))),"create");var tn=gr,ps=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,u=typeof l=="string"?{message:l}:l;s.addIssue(f(c({code:"custom"},u),{fatal:d}))}}):ot.create(),"custom"),hr=class Fn 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 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()):I.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Fn(f(c({},this._def),{checks:[...this._def.checks,e]}))}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:P.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:P.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}isEqual(e){if(!(e instanceof Fn))return!1;let r=new U(this._def.checks),n=new U(e._def.checks);return r.isEqual(n)&&this._def.coerce===e._def.coerce}};a(hr,"ZodDate");hr.create=a(t=>new hr(c({checks:[],coerce:t?.coerce||!1,typeName:"ZodDate"},S(t))),"create");var rn=hr,mr=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(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new wt(f(c({},this._def),{innerType:this._def.innerType.clone()}))}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(f(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},S(r))),"create");var Ut=mr,Te=a(t=>Array.from(new Set(t)),"unique"),he=a(t=>t instanceof sn?he(t.schema):t instanceof Se?he(t.innerType()):t instanceof an?[t.value]:t instanceof Ve?t.options:t instanceof on?I.objectValues(t.enum):t instanceof Ut?he(t._def.innerType):t instanceof Wt?[void 0]:t instanceof ln?[null]:t instanceof ye?[void 0,...he(t.unwrap())]:t instanceof Me?[null,...he(t.unwrap())]:t instanceof en||t instanceof Lt?he(t.unwrap()):t instanceof tn?he(t._def.innerType):[],"getDiscriminator"),Ul=class Re extends O{dereference(e){let r=this.options.map(s=>s.dereference(e)),n=Re._getOptionsMap(this.discriminator,r);return new Re(f(c({},this._def),{options:r,optionsMap:n}))}getReferences(){return Te(this.options.flatMap(e=>e.getReferences()))}clone(){let e=this.options.map(r=>r.clone());return new Re(f(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=Re._getOptionsMap(e,r);return new Re(c({typeName:"ZodDiscriminatedUnion",discriminator:e,options:r,optionsMap:s},S(n)))}static _getOptionsMap(e,r){let n=new Map;for(let s of r){let i=he(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 Re)||this._def.discriminator!==e._def.discriminator)return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new U(this._def.options,{compare:r}),s=new U(e._def.options,{compare:r});return n.isEqual(s)}};a(Ul,"ZodDiscriminatedUnion");var fs=Ul;function zt(t,e){return new Ve(c({values:t,typeName:"ZodEnum"},S(e)))}a(zt,"createZodEnum");var gs=class Qt extends O{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return v(r,{expected:I.joinValues(n),received:r.parsedType,code: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 G(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return 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 U(this._def.values),n=new U(e._def.values);return r.isEqual(n)}};a(gs,"ZodEnum");gs.create=zt;var Ve=gs,zl=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(f(c({},this._def),{args:r,returns:n}))}getReferences(){return Te([...this._def.args.getReferences(),...this._def.returns.getReferences()])}clone(){return new Ce(f(c({},this._def),{args:this._def.args.clone(),returns:this._def.returns.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==_.function)return v(r,{code: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,it(),xi].filter(u=>!!u),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,it(),xi].filter(u=>!!u),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 Ft){let l=this;return G(async function(...d){let u=new pe([]),g=await l._def.args.parseAsync(d,i).catch(Z=>{throw u.addIssue(n(d,Z)),u}),m=await Reflect.apply(o,this,g);return await l._def.returns._def.type.parseAsync(m,i).catch(Z=>{throw u.addIssue(s(m,Z)),u})})}else{let l=this;return G(function(...d){let u=l._def.args.safeParse(d,i);if(!u.success)throw new pe([n(d,u.error)]);let g=Reflect.apply(o,this,u.data),m=l._def.returns.safeParse(g,i);if(!m.success)throw new pe([s(g,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ce(f(c({},this._def),{args:je.create(e).rest(nt.create())}))}returns(e){return new Ce(f(c({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new Ce(c({args:e||je.create([]).rest(nt.create()),returns:r||nt.create(),typeName:"ZodFunction"},S(n)))}isEqual(e){return e instanceof Ce&&this._def.args.isEqual(e._def.args)&&this._def.returns.isEqual(e._def.returns)}};a(zl,"ZodFunction");var hs=zl;function yr(t,e){let r=me(t),n=me(e);if(t===e)return{valid:!0,data:t};if(r===_.object&&n===_.object){let s=I.objectKeys(e),i=I.objectKeys(t).filter(l=>s.indexOf(l)!==-1),o=c(c({},t),e);for(let l of i){let d=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 O{dereference(e){return new er(f(c({},this._def),{left:this._def.left.dereference(e),right:this._def.right.dereference(e)}))}getReferences(){return Te([...this._def.left.getReferences(),...this._def.right.getReferences()])}clone(){return new er(f(c({},this._def),{left:this._def.left.clone(),right:this._def.right.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=a((i,o)=>{if(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 U([this._def.left,this._def.right],{compare:r}),s=new U([e._def.left,e._def.right],{compare:r});return n.isEqual(s)}};a(vr,"ZodIntersection");vr.create=a((t,e,r)=>new vr(c({left:t,right:e,typeName:"ZodIntersection"},S(r))),"create");var nn=vr,_r=class Pt extends O{get schema(){return this._def.getter()}dereference(e){return new Pt(f(c({},this._def),{getter:a(()=>this._def.getter().dereference(e),"getter")}))}getReferences(){return this._def.getter().getReferences()}clone(){return new Pt(f(c({},this._def),{getter:a(()=>this._def.getter().clone(),"getter")}))}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}isEqual(e){return e instanceof Pt?this._def.getter().isEqual(e._def.getter()):!1}naked(){return this._def.getter().naked()}mandatory(){return new Pt(f(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"},S(e))),"create");var sn=_r,Tr=class Fl 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 Fl?rt(this._def.value,e._def.value):!1}};a(Tr,"ZodLiteral");Tr.create=a((t,e)=>new Tr(c({value:t,typeName:"ZodLiteral"},S(e))),"create");var an=Tr,br=class tr 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 tr(f(c({},this._def),{keyType:r,valueType:n}))}getReferences(){return Te([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new tr(f(c({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.map)return v(n,{code: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],u)=>({key:s._parse(new oe(n,l,n.path,[u,"key"])),value:i._parse(new oe(n,d,n.path,[u,"value"]))}));if(n.common.async){let l=new Map;return Promise.resolve().then(async()=>{for(let d of o){let u=await d.key,g=await d.value;if(u.status==="aborted"||g.status==="aborted")return x;(u.status==="dirty"||g.status==="dirty")&&r.dirty(),l.set(u.value,g.value)}return{status:r.value,value:l}})}else{let l=new Map;for(let d of o){let u=d.key,g=d.value;if(u.status==="aborted"||g.status==="aborted")return x;(u.status==="dirty"||g.status==="dirty")&&r.dirty(),l.set(u.value,g.value)}return{status:r.value,value:l}}}isEqual(e){return!(!(e instanceof 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"},S(r))),"create");var ms=br,wr=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(wr,"ZodNaN");wr.create=a(t=>new wr(c({typeName:"ZodNaN"},S(t))),"create");var ys=wr,Pr=class Wl extends O{_parse(e){let r=I.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==_.string&&n.parsedType!==_.number){let s=I.objectValues(r);return v(n,{expected:I.joinValues(s),received:n.parsedType,code:h.invalid_type}),x}if(r.indexOf(e.data)===-1){let s=I.objectValues(r);return v(n,{received:n.data,code:h.invalid_enum_value,options:s}),x}return G(e.data)}get enum(){return this._def.values}isEqual(e){return e instanceof Wl?rt(this._def.values,e._def.values):!1}};a(Pr,"ZodNativeEnum");Pr.create=a((t,e)=>new Pr(c({values:t,typeName:"ZodNativeEnum"},S(e))),"create");var on=Pr,xr=class ql 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 ql}};a(xr,"ZodNever");xr.create=a(t=>new xr(c({typeName:"ZodNever"},S(t))),"create");var ut=xr,kr=class Vl 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 G(e.data)}isEqual(e){return e instanceof Vl}};a(kr,"ZodNull");kr.create=a(t=>new kr(c({typeName:"ZodNull"},S(t))),"create");var ln=kr,Sr=class xt extends O{dereference(e){return new xt(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new xt(f(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)===_.null?G(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof xt?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new xt(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(Sr,"ZodNullable");Sr.create=a((t,e)=>new Sr(c({innerType:t,typeName:"ZodNullable"},S(e))),"create");var Me=Sr;function Gl(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(Gl,"floatSafeRemainder");var Er=class rr 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 re;for(let i of this._def.checks)i.kind==="int"?I.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"?Gl(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()):I.assertNever(i);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,P.toString(r))}gt(e,r){return this.setLimit("min",e,!1,P.toString(r))}lte(e,r){return this.setLimit("max",e,!0,P.toString(r))}lt(e,r){return this.setLimit("max",e,!1,P.toString(r))}setLimit(e,r,n,s){return new rr(f(c({},this._def),{checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:P.toString(s)}]}))}_addCheck(e){return new rr(f(c({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:P.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:P.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:P.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:P.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:P.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:P.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:P.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:P.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:P.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&I.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}isEqual(e){if(!(e instanceof rr))return!1;let r=new U(this._def.checks),n=new U(e._def.checks);return r.isEqual(n)}};a(Er,"ZodNumber");Er.create=a(t=>new Er(c({checks:[],typeName:"ZodNumber",coerce:t?.coerce||!1},S(t))),"create");var cn=Er;function He(t){if(t instanceof $e){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=ye.create(He(n))}return new $e(f(c({},t._def),{shape:a(()=>e,"shape")}))}else return t instanceof lt?new lt(f(c({},t._def),{type:He(t.element)})):t instanceof ye?ye.create(He(t.unwrap())):t instanceof Me?Me.create(He(t.unwrap())):t instanceof je?je.create(t.items.map(e=>He(e))):t}a(He,"deepPartialify");var ke=class se extends O{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=I.objectKeys(e);return this._cached={shape:e,keys:r}}dereference(e){let r=this._def.shape(),n={};for(let s in r)n[s]=r[s].dereference(e);return new se(f(c({},this._def),{shape:a(()=>n,"shape")}))}getReferences(){let e=this._def.shape(),r=[];for(let n in e)r.push(...e[n].getReferences());return Te(r)}clone(){let e={},r=this._def.shape();for(let[n,s]of Object.entries(r))e[n]=s.clone();return new se(f(c({},this._def),{shape:a(()=>e,"shape")}))}_parse(e){if(this._getType(e)!==_.object){let g=this._getOrReturnCtx(e);return v(g,{code: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],T=s.data[g];d.push({key:{status:"valid",value:g},value:m._parse(new oe(s,T,s.path,g)),alwaysSet:g in s.data})}let u=this._def.unknownKeys;if(u==="passthrough")for(let g of l)d.push({key:{status:"valid",value:g},value:{status:"valid",value:s.data[g]}});else if(u==="strict")l.length>0&&(v(s,{code:h.unrecognized_keys,keys:l}),n.dirty());else if(u!=="strip")for(let g of l){let m=s.data[g];d.push({key:{status:"valid",value:g},value:u._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 T=await m.key;g.push({key:T,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 P.errToObj,new se(c(f(c({},this._def),{unknownKeys:"strict"}),e!==void 0?{errorMap:a((r,n)=>{var s,i,o,l;let d=(o=(i=(s=this._def).errorMap)==null?void 0:i.call(s,r,n).message)!=null?o:n.defaultError;return r.code==="unrecognized_keys"?{message:(l=P.errToObj(e).message)!=null?l:d}:{message:d}},"errorMap")}:{}))}strip(){return new se(f(c({},this._def),{unknownKeys:"strip"}))}passthrough(){return new se(f(c({},this._def),{unknownKeys:"passthrough"}))}additionalProperties(){if(this._def.unknownKeys instanceof O)return this._def.unknownKeys;if(this._def.unknownKeys==="passthrough")return ot.create();if(this._def.unknownKeys==="strict")return ut.create()}extend(e){return new se(f(c({},this._def),{shape:a(()=>c(c({},this._def.shape()),e),"shape")}))}merge(e){return new se({unknownKeys:e._def.unknownKeys,shape:a(()=>c(c({},this._def.shape()),e._def.shape()),"shape"),typeName:"ZodObject"})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new se(f(c({},this._def),{unknownKeys:e}))}pick(e){let r={};return I.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new se(f(c({},this._def),{shape:a(()=>r,"shape")}))}omit(e){let r={};return I.objectKeys(this.shape).forEach(n=>{e[n]||(r[n]=this.shape[n])}),new se(f(c({},this._def),{shape:a(()=>r,"shape")}))}deepPartial(){return He(this)}partial(e){let r={};return I.objectKeys(this.shape).forEach(n=>{let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s?.optional()}),new se(f(c({},this._def),{shape:a(()=>r,"shape")}))}required(e){let r={};return I.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof ye;)i=i._def.innerType;r[n]=i}}),new se(f(c({},this._def),{shape:a(()=>r,"shape")}))}keyof(){return zt(I.objectKeys(this.shape))}isEqual(e){if(!(e instanceof se)||!this._unknownKeysEqual(e))return!1;let r=this._def.shape(),n=e._def.shape(),s=a((l,d)=>l[0]===d[0]&&l[1].isEqual(d[1]),"compare"),i=new U(Object.entries(r),{compare:s}),o=new U(Object.entries(n),{compare:s});return i.isEqual(o)}_unknownKeysEqual(e){let r=this.additionalProperties(),n=e.additionalProperties();return r===void 0||n===void 0?r===n:r.isEqual(n)}};a(ke,"ZodObject");ke.create=a((t,e)=>new ke(c({shape:a(()=>t,"shape"),unknownKeys:"strip",typeName:"ZodObject"},S(e))),"create");ke.strictCreate=a((t,e)=>new ke(c({shape:a(()=>t,"shape"),unknownKeys:"strict",typeName:"ZodObject"},S(e))),"strictCreate");ke.lazycreate=a((t,e)=>new ke(c({shape:t,unknownKeys:"strip",typeName:"ZodObject"},S(e))),"lazycreate");var $e=ke,Or=class nr extends O{dereference(e){return new nr(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new nr(f(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)===_.undefined?G(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof 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"},S(e))),"create");var ye=Or,Jl=class kt extends O{dereference(e){return new kt(f(c({},this._def),{in:this._def.in.dereference(e),out:this._def.out.dereference(e)}))}getReferences(){return Te([...this._def.in.getReferences(),...this._def.out.getReferences()])}clone(){return new kt(f(c({},this._def),{in:this._def.in.clone(),out:this._def.out.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return a(async()=>{let i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?x:i.status==="dirty"?(r.dirty(),De(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(Jl,"ZodPipeline");var dn=Jl,Zr=class sr extends O{unwrap(){return this._def.type}dereference(e){return new sr(f(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new sr(f(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==_.promise&&r.common.async===!1)return v(r,{code:h.invalid_type,expected:_.promise,received:r.parsedType}),x;let n=r.parsedType===_.promise?r.data:Promise.resolve(r.data);return G(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}isEqual(e){return e instanceof 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"},S(e))),"create");var Ft=Zr,Ir=class St extends O{dereference(e){return new St(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new St(f(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(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(Ir,"ZodReadonly");Ir.create=a((t,e)=>new Ir(c({innerType:t,typeName:"ZodReadonly"},S(e))),"create");var Lt=Ir,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(f(c({},this._def),{keyType:r,valueType:n}))}getReferences(){return Te([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new Xe(f(c({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.object)return v(n,{code: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 O?new Xe(c({keyType:e,valueType:r,typeName:"ZodRecord"},S(n))):new Xe(c({keyType:J.create(),valueType:e,typeName:"ZodRecord"},S(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 vs=Yl,Br=class Xl 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 Xl?this._def.uri===e._def.uri:!1}};a(Br,"ZodRef");Br.create=a(t=>new Br({typeName:"ZodRef",uri:t}),"create");var _s=Br,Ar=class Qe extends O{dereference(e){return new Qe(f(c({},this._def),{valueType:this._def.valueType.dereference(e)}))}getReferences(){return this._def.valueType.getReferences()}clone(){return new Qe(f(c({},this._def),{valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.set)return v(n,{code: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 u=new Set;for(let g of d){if(g.status==="aborted")return x;g.status==="dirty"&&r.dirty(),u.add(g.value)}return{status:r.value,value:u}}a(o,"finalizeSet");let l=[...n.data.values()].map((d,u)=>i._parse(new oe(n,d,n.path,u)));return n.common.async?Promise.all(l).then(d=>o(d)):o(l)}min(e,r){return new Qe(f(c({},this._def),{minSize:{value:e,message:P.toString(r)}}))}max(e,r){return new Qe(f(c({},this._def),{maxSize:{value:e,message:P.toString(r)}}))}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}isEqual(e){var r,n,s,i;if(!(e instanceof 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,u=(i=e._def.maxSize)==null?void 0:i.value;return d!==u?!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"},S(e))),"create");var Ts=Ar,bs=/^c[^\s-]{8,}$/i,ws=/^[a-z][a-z0-9]*$/,Ps=/^[0-9A-HJKMNP-TV-Z]{26}$/,xs=/^[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,ks=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ql="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",ec=a(t=>t===Ql,"isEmojiRegex"),Cn,Ss=/^(((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}))$/,Es=/^(([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 tc(t,e){return!!((e==="v4"||!e)&&Ss.test(t)||(e==="v6"||!e)&&Es.test(t))}a(tc,"isValidIP");var Rr=class et 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 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")ks.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(Ql,"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")xs.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")bs.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")ws.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")Ps.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"?tc(e.data,i.version)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"ip",code:h.invalid_string,message:i.message}),n.dirty()):I.assertNever(i);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),c({validation:r,code:h.invalid_string},P.errToObj(n)))}_addCheck(e){return new et(f(c({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(c({kind:"email"},P.errToObj(e)))}url(e){return this._addCheck(c({kind:"url"},P.errToObj(e)))}emoji(e){return this._addCheck(c({kind:"emoji"},P.errToObj(e)))}uuid(e){return this._addCheck(c({kind:"uuid"},P.errToObj(e)))}cuid(e){return this._addCheck(c({kind:"cuid"},P.errToObj(e)))}cuid2(e){return this._addCheck(c({kind:"cuid2"},P.errToObj(e)))}ulid(e){return this._addCheck(c({kind:"ulid"},P.errToObj(e)))}ip(e){return this._addCheck(c({kind:"ip"},P.errToObj(e)))}datetime(e){var r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck(c({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(r=e?.offset)!=null?r:!1},P.errToObj(e?.message)))}regex(e,r){return this._addCheck(c({kind:"regex",regex:e},P.errToObj(r)))}includes(e,r){return this._addCheck(c({kind:"includes",value:e,position:r?.position},P.errToObj(r?.message)))}startsWith(e,r){return this._addCheck(c({kind:"startsWith",value:e},P.errToObj(r)))}endsWith(e,r){return this._addCheck(c({kind:"endsWith",value:e},P.errToObj(r)))}min(e,r){return this._addCheck(c({kind:"min",value:e},P.errToObj(r)))}max(e,r){return this._addCheck(c({kind:"max",value:e},P.errToObj(r)))}length(e,r){return this._addCheck(c({kind:"length",value:e},P.errToObj(r)))}nonempty(e){return this.min(1,P.errToObj(e))}trim(){return new et(f(c({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}secret(){return this._def[w]=f(c({},this._def[w]),{secret:!0}),this}toLowerCase(){return new et(f(c({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new et(f(c({},this._def),{checks:[...this._def.checks,{kind:"toUpperCase"}]}))}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}isEqual(e){if(!(e instanceof et))return!1;let r=new U(this._def.checks),n=new U(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},S(f(c({},t),{supportsExtensions:["secret"]}))))},"create");var J=Rr,Cr=class rc 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 G(e.data)}isEqual(e){return e instanceof rc}};a(Cr,"ZodSymbol");Cr.create=a(t=>new Cr(c({typeName:"ZodSymbol"},S(t))),"create");var Os=Cr,ct=class Et 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 Et(f(c({},this._def),{schema:this._def.schema.dereference(e)}))}getReferences(){return this._def.schema.getReferences()}clone(){return new Et(f(c({},this._def),{schema:this._def.schema.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a(o=>{v(n,o),o.fatal?r.abort():r.dirty()},"addIssue"),get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let o=s.transform(n.data,i);if(n.common.async)return Promise.resolve(o).then(async l=>{if(r.value==="aborted")return x;let d=await this._def.schema._parseAsync({data:l,path:n.path,parent:n});return d.status==="aborted"?x:d.status==="dirty"||r.value==="dirty"?De(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"?De(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);I.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:I.compareFunctions(this._def.effect.refinement,e._def.effect.refinement):this._def.effect.type==="transform"?e._def.effect.type!=="transform"?!1:I.compareFunctions(this._def.effect.transform,e._def.effect.transform):this._def.effect.type==="preprocess"?e._def.effect.type!=="preprocess"?!1:I.compareFunctions(this._def.effect.transform,e._def.effect.transform):!1}naked(){return this._def.schema.naked()}mandatory(){return new Et(f(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},S(r))),"create");ct.createWithPreprocess=a((t,e,r)=>new ct(c({schema:e,effect:{type:"preprocess",transform:t},typeName:"ZodEffects"},S(r))),"createWithPreprocess");var Se=ct,Hr=class Ot 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 Ot(f(c({},this._def),{items:r,rest:n}))}getReferences(){return Te([...this._def.items.flatMap(e=>e.getReferences()),...this._def.rest?this._def.rest.getReferences():[]])}clone(){let e=this._def.items.map(n=>n.clone()),r=this._def.rest?this._def.rest.clone():null;return new Ot(f(c({},this._def),{items:e,rest:r}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.array)return v(n,{code: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(f(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 U(this._def.items,{compare:r}),s=new U(e._def.items,{compare:r});return n.isEqual(s)}_restEquals(e){return this._def.rest===null?e._def.rest===null:e._def.rest!==null&&this._def.rest.isEqual(e._def.rest)}};a(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},S(e)))},"create");var je=Hr,Dr=class nc 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 G(e.data)}isEqual(e){return e instanceof nc}mandatory(){return ut.create(c({},this._def))}};a(Dr,"ZodUndefined");Dr.create=a(t=>new Dr(c({typeName:"ZodUndefined"},S(t))),"create");var Wt=Dr,Nr=class Zt extends O{dereference(e){let r=this._def.options.map(n=>n.dereference(e));return new Zt(f(c({},this._def),{options:r}))}getReferences(){return Te(this._def.options.reduce((e,r)=>[...e,...r.getReferences()],[]))}clone(){let e=this._def.options.map(r=>r.clone());return new Zt(f(c({},this._def),{options:e}))}_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function s(i){for(let l of i)if(l.result.status==="valid")return l.result;for(let l of i)if(l.result.status==="dirty")return r.common.issues.push(...l.ctx.common.issues),l.result;let o=i.map(l=>new pe(l.ctx.common.issues));return v(r,{code:h.invalid_union,unionErrors:o}),x}if(a(s,"handleResults"),r.common.async)return Promise.all(n.map(async i=>{let o=f(c({},r),{common:f(c({},r.common),{issues:[]}),parent:null});return{result:await i._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(s);{let i,o=[];for(let d of n){let u=f(c({},r),{common:f(c({},r.common),{issues:[]}),parent:null}),g=d._parseSync({data:r.data,path:r.path,parent:u});if(g.status==="valid")return g;g.status==="dirty"&&!i&&(i={result:g,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let l=o.map(d=>new pe(d));return v(r,{code: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 U([...this._def.options],{compare:r}),s=new U([...e._def.options],{compare:r});return n.isEqual(s)}mandatory(){let e=this._def.options.filter(i=>!(i instanceof Wt)).map(i=>i.mandatory()),[r,n,...s]=e;return r?n?new Zt(f(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"},S(e))),"create");var un=Nr,Mr=class sc extends O{constructor(){super(...arguments),this._unknown=!0}_parse(e){return G(e.data)}isEqual(e){return e instanceof sc}};a(Mr,"ZodUnknown");Mr.create=a(t=>new Mr(c({typeName:"ZodUnknown"},S(t))),"create");var nt=Mr,$r=class ic 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 G(e.data)}isEqual(e){return e instanceof ic}};a($r,"ZodVoid");$r.create=a(t=>new $r(c({typeName:"ZodVoid"},S(t))),"create");var Zs=$r,um=["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"],Pv=Ve.create(["any","string","number","boolean","object","pattern","date","array","target","time","enum"]),ac=a(t=>J.create().displayAs({id:"variable",params:c({type:t?.type||"any"},t?.params)}),"variable"),oc=a(t=>J.create().displayAs({id:"conversation",params:c({},t?.params)}),"conversation"),lc=a(t=>J.create().displayAs({id:"user",params:c({},t?.params)}),"user"),cc=a(t=>J.create().displayAs({id:"message",params:c({},t?.params)}),"message"),dc=a(t=>J.create().displayAs({id:"agent",params:c({},t?.params)}),"agent"),uc=a(t=>J.create().displayAs({id:"event",params:c({},t?.params)}),"event"),pc=a(t=>J.create().displayAs({id:"table",params:c({},t?.params)}),"table"),fc=a(t=>J.create().displayAs({id:"tablerow",params:c({},t?.params)}),"tablerow"),gc=a(t=>J.create().displayAs({id:"intent",params:c({},t?.params)}),"intent"),hc=a(()=>Ve.create(um).displayAs({id:"dropdown",params:{}}),"aimodel"),mc=a(t=>J.create().displayAs({id:"datasource",params:c({},t)}),"datasource"),yc=a(t=>J.create().displayAs({id:"knowledgebase",params:c({},t)}),"knowledgebase"),vc={object:$e.lazycreate},_c=a((t,e={message:`Input not instance of ${t.name}`})=>ps(r=>r instanceof t,e),"instanceOfType"),Is=J.create,Bs=cn.create,Tc=ys.create,bc=Xr.create,As=Qr.create,wc=rn.create,Pc=Os.create,xc=Wt.create,kc=ln.create,Sc=ot.create,Ec=nt.create,Oc=ut.create,Zc=Zs.create,Ic=lt.create,Bc=$e.create,Ac=$e.strictCreate,Rc=un.create,Cc=fs.create,Hc=nn.create,Dc=je.create,Nc=vs.create,Mc=_s.create,$c=Lt.create,jc=ms.create,Kc=Ts.create,Uc=hs.create,zc=sn.create,Fc=an.create,Lc=Ve.create,Wc=on.create,qc=Ft.create,Ln=Se.create,Vc=ye.create,Gc=Me.create,pm=Ut.create,Jc=Se.createWithPreprocess,Yc=dn.create,Xc=a(()=>Is().optional(),"ostring"),Qc=a(()=>Bs().optional(),"onumber"),ed=a(()=>As().optional(),"oboolean"),td={string:a(t=>J.create(f(c({},t),{coerce:!0})),"string"),number:a(t=>cn.create(f(c({},t),{coerce:!0})),"number"),boolean:a(t=>Qr.create(f(c({},t),{coerce:!0})),"boolean"),bigint:a(t=>Xr.create(f(c({},t),{coerce:!0})),"bigint"),date:a(t=>rn.create(f(c({},t),{coerce:!0})),"date")},rd=x,p=y,nd=a((t,e)=>t.anyOf.length?t.anyOf.length===1?W(t.anyOf[0],f(c({},e),{path:[...e.path,"anyOf",0]})):`z.union([${t.anyOf.map((r,n)=>W(r,f(c({},e),{path:[...e.path,"anyOf",n]}))).join(", ")}])`:"z.any()","parseAnyOf"),fm=a(t=>{var e;return(e=t[w])!=null&&e.coerce?"z.coerce.boolean()":"z.boolean()"},"parseBoolean"),gm=a(t=>"z.any()","parseDefault"),hm=a((t,e)=>`z.union([${t.type.map(r=>W(f(c({},t),{type:r}),e)).join(", ")}])`,"parseMultipleType"),mm=a((t,e)=>`z.any().refine((value) => !${W(t.not,f(c({},e),{path:[...e.path,"not"]}))}.safeParse(value).success, "Invalid input: Should NOT be valid against schema")`,"parseNot"),ym=a(t=>"z.null()","parseNull"),vm=a(t=>[t.slice(0,t.length/2),t.slice(t.length/2)],"half"),_m=a((t,...e)=>Object.keys(t).reduce((r,n)=>(e.includes(n)||(r[n]=t[n]),r),{}),"omit");function V(t,e,r){var n;let s=t[e],i="";if(s!==void 0){let o=r({value:s,json:JSON.stringify(s)});if(o){let l=o[0],d=o.length===3?o[1]:"",u=o.length===3?o[2]:o[1];i+=l,((n=t.errorMessage)==null?void 0:n[e])!==void 0&&(i+=d+JSON.stringify(t.errorMessage[e])),i+=u}}return i}a(V,"withMessage");var It=Symbol("Original index"),Tm=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(f(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,f(c({},e),{path:[...e.path,"allOf",r[It]]}))}else{let[r,n]=vm(Tm(t.allOf));return`z.intersection(${jt({allOf:r},e)}, ${jt({allOf:n},e)})`}}a(jt,"parseAllOf");var bm=a((t,e)=>{if(Array.isArray(t.items))return`z.tuple([${t.items.map((n,s)=>W(n,f(c({},e),{path:[...e.path,"items",s]})))}])`;let r=t.items?`z.array(${W(t.items,f(c({},e),{path:[...e.path,"items"]}))})`:"z.array(z.any())";return r+=V(t,"minItems",({json:n})=>[`.min(${n}`,", ",")"]),r+=V(t,"maxItems",({json:n})=>[`.max(${n}`,", ",")"]),r},"parseArray"),wm=a(t=>`z.literal(${JSON.stringify(t.const)})`,"parseConst"),Pm=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"),xm=a((t,e)=>{let r=W(t.if,f(c({},e),{path:[...e.path,"if"]})),n=W(t.then,f(c({},e),{path:[...e.path,"then"]})),s=W(t.else,f(c({},e),{path:[...e.path,"else"]}));return`z.union([${n}, ${s}]).superRefine((value,ctx) => {
|
|
12
17
|
const result = ${r}.safeParse(value).success
|
|
13
18
|
? ${n}.safeParse(value)
|
|
14
19
|
: ${s}.safeParse(value);
|
|
15
20
|
if (!result.success) {
|
|
16
21
|
result.error.errors.forEach((error) => ctx.addIssue(error))
|
|
17
22
|
}
|
|
18
|
-
})`},"parseIfThenElse"),
|
|
19
|
-
const schemas = [${t.oneOf.map((r,n)=>W(r,
|
|
23
|
+
})`},"parseIfThenElse"),km=a(t=>{var e;let r="z.number()";return(e=t[w])!=null&&e.coerce&&(r="z.coerce.number()"),t.type==="integer"?r+=V(t,"type",()=>[".int(",")"]):r+=V(t,"format",({value:n})=>{if(n==="int64")return[".int(",")"]}),r+=V(t,"multipleOf",({value:n,json:s})=>n===1?r.startsWith("z.number().int(")?void 0:[".int(",")"]:[`.multipleOf(${s}`,", ",")"]),typeof t.minimum=="number"?t.exclusiveMinimum===!0?r+=V(t,"minimum",({json:n})=>[`.gt(${n}`,", ",")"]):r+=V(t,"minimum",({json:n})=>[`.gte(${n}`,", ",")"]):typeof t.exclusiveMinimum=="number"&&(r+=V(t,"exclusiveMinimum",({json:n})=>[`.gt(${n}`,", ",")"])),typeof t.maximum=="number"?t.exclusiveMaximum===!0?r+=V(t,"maximum",({json:n})=>[`.lt(${n}`,", ",")"]):r+=V(t,"maximum",({json:n})=>[`.lte(${n}`,", ",")"]):typeof t.exclusiveMaximum=="number"&&(r+=V(t,"exclusiveMaximum",({json:n})=>[`.lt(${n}`,", ",")"])),r},"parseNumber"),Rs=a((t,e)=>t.oneOf.length?t.oneOf.length===1?W(t.oneOf[0],f(c({},e),{path:[...e.path,"oneOf",0]})):`z.any().superRefine((x, ctx) => {
|
|
24
|
+
const schemas = [${t.oneOf.map((r,n)=>W(r,f(c({},e),{path:[...e.path,"oneOf",n]}))).join(", ")}];
|
|
20
25
|
const errors = schemas.reduce(
|
|
21
26
|
(errors: z.ZodError[], schema) =>
|
|
22
27
|
((result) => ("error" in result ? [...errors, result.error] : errors))(
|
|
@@ -32,7 +37,7 @@ ${ee}`.trim();case u.ZodFirstPartyTypeKind.ZodEnum:return l.values.map(T).join("
|
|
|
32
37
|
message: "Invalid input: Should pass single schema",
|
|
33
38
|
});
|
|
34
39
|
}
|
|
35
|
-
})`:"z.any()","parseOneOf");function
|
|
40
|
+
})`:"z.any()","parseOneOf");function sd(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,f(c({},e),{path:[...e.path,"properties",o]}))}`,u=typeof l=="object"&&l.default!==void 0||typeof t.default=="object"&&t.default!==null&&o in t.default,g=Array.isArray(t.required)?t.required.includes(o):typeof l=="object"&&l.required===!0;return!u&&!g?`${d}.optional()`:d}).join(", "),r+=" })"):r="z.object({})");let n=t.additionalProperties!==void 0?W(t.additionalProperties,f(c({},e),{path:[...e.path,"additionalProperties"]})):void 0,s;if(t.patternProperties){let o=Object.fromEntries(Object.entries(t.patternProperties).map(([l,d])=>[l,W(d,f(c({},e),{path:[...e.path,"patternProperties",l]}))],{}));s="",r?n?s+=`.catchall(z.union([${[...Object.values(o),n].join(", ")}]))`:Object.keys(o).length>1?s+=`.catchall(z.union([${Object.values(o).join(", ")}]))`:s+=`.catchall(${Object.values(o)})`:n?s+=`z.record(z.union([${[...Object.values(o),n].join(", ")}]))`:Object.keys(o).length>1?s+=`z.record(z.union([${Object.values(o).join(", ")}]))`:s+=`z.record(${Object.values(o)})`,s+=`.superRefine((value, ctx) => {
|
|
36
41
|
`,s+=`for (const key in value) {
|
|
37
42
|
`,n&&(t.properties?s+=`let evaluated = [${Object.keys(t.properties).map(l=>JSON.stringify(l)).join(", ")}].includes(key)
|
|
38
43
|
`:s+=`let evaluated = false
|
|
@@ -64,7 +69,7 @@ ${ee}`.trim();case u.ZodFirstPartyTypeKind.ZodEnum:return l.values.map(T).join("
|
|
|
64
69
|
`,s+=`}
|
|
65
70
|
`,s+=`}
|
|
66
71
|
`),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 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});
|
|
72
|
+
`,s+="})"}let i=r?s?r+s:n?n==="z.never()"?r+".strict()":r+`.catchall(${n})`:r:s||(n?`z.record(${n})`:"z.record(z.any())");return $.an.anyOf(t)&&(i+=`.and(${nd(f(c({},t),{anyOf:t.anyOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?f(c({},o),{type:"object"}):o)}),e)})`),$.a.oneOf(t)&&(i+=`.and(${Rs(f(c({},t),{oneOf:t.oneOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?f(c({},o),{type:"object"}):o)}),e)})`),$.an.allOf(t)&&(i+=`.and(${jt(f(c({},t),{allOf:t.allOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?f(c({},o),{type:"object"}):o)}),e)})`),i}a(sd,"parseObject");var Sm=a(t=>{var e;let r="z.string()";if((e=t[w])!=null&&e.coerce){if(t.format==="date-time")return"z.coerce.date()";r="z.coerce.string()"}return r+=V(t,"format",({value:n})=>{switch(n){case"email":return[".email(",")"];case"ip":return[".ip(",")"];case"ipv4":return['.ip({ version: "v4"',", message: "," })"];case"ipv6":return['.ip({ version: "v6"',", message: "," })"];case"uri":return[".url(",")"];case"uuid":return[".uuid(",")"];case"date-time":return[".datetime(",")"]}}),r+=V(t,"pattern",({json:n})=>[`.regex(new RegExp(${n})`,", ",")"]),r+=V(t,"minLength",({json:n})=>[`.min(${n}`,", ",")"]),r+=V(t,"maxLength",({json:n})=>[`.max(${n}`,", ",")"]),r},"parseString"),Em=a((t,e)=>`${W(_m(t,"nullable"),e,!0)}.nullable()`,"parseNullable"),Om=a(t=>`z.ref('${t.$ref}')`,"parseRef"),Zm=a((t,e)=>{var r,n;if(t.oneOf.length<=1||!((r=t.discriminator)!=null&&r.propertyName))return Rs(t,e);let s=t.oneOf.map((i,o)=>W(i,f(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=Am(t,e);return r||(s=Im(t,s),e.withoutDefaults||(s=Bm(t,s))),n.r=s,s},"parseSchema"),Im=a((t,e)=>(t.description&&(e+=`.describe(${JSON.stringify(t.description)})`),e),"addMeta"),Bm=a((t,e)=>(t.default!==void 0&&(e+=`.default(${JSON.stringify(t.default)})`),e),"addDefaults"),Am=a((t,e)=>$.a.nullable(t)?Em(t,e):$.an.object(t)?sd(t,e):$.an.array(t)?bm(t,e):$.an.anyOf(t)?nd(t,e):$.an.allOf(t)?jt(t,e):$.a.discriminator(t)?Zm(t,e):$.a.oneOf(t)?Rs(t,e):$.a.not(t)?mm(t,e):$.an.enum(t)?Pm(t):$.a.const(t)?wm(t):$.a.multipleType(t)?hm(t,e):$.a.primitive(t,"string")?Sm(t):$.a.primitive(t,"number")||$.a.primitive(t,"integer")?km(t):$.a.primitive(t,"boolean")?fm(t):$.a.primitive(t,"null")?ym(t):$.a.conditional(t)?xm(t,e):$.a.ref(t)?Om(t):gm(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")}},Rm=a(t=>{let e;try{e=new Function("z",`return ${t}`)(p)}catch(r){return{sucess:!1,error:`Failed to evaluate schema: ${(r instanceof Error?r:new Error(String(r))).message}`}}return e instanceof p.ZodType?{sucess:!0,value:e}:{sucess:!1,error:`String "${t}" does not evaluate to a Zod schema`}},"evalZuiString"),Cm=a(t=>W(t,{seen:new Map,path:[]}),"jsonSchemaToZodStr"),Hm=a(t=>{let e=Cm(t);e=e.replaceAll("errors: z.ZodError[]","errors");let r=Rm(e);if(!r.sucess)throw new Ur(r.error);return r.value},"jsonSchemaToZod"),Bt=a((t,e)=>{var r,n;if(e[w]&&t._def&&(t.naked()._def[w]=e[w]),((r=t._def)==null?void 0:r.typeName)==="ZodObject"&&e.type==="object"&&e.properties&&Object.entries(e.properties).forEach(([s,i])=>{let o=typeof t._def.shape=="function"?t._def.shape():t._def.shape;o[s]&&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"),Dm=a(t=>{let e=Hm(t);return Bt(e,t),e},"fromJSONSchemaLegacy"),Nm=a(t=>{var e,r;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(n=>typeof n!="boolean"&&id(n))&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===p.ZodFirstPartyTypeKind.ZodOptional},"isOptionalSchema"),Mm=a(t=>{var e,r;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(n=>typeof n!="boolean"&&n.type==="null")&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===p.ZodFirstPartyTypeKind.ZodNullable},"isNullableSchema"),id=a(t=>{var e,r;return t.not===!0&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===p.ZodFirstPartyTypeKind.ZodUndefined},"isUndefinedSchema"),$m=a(t=>{var e,r;return!t.not&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===p.ZodFirstPartyTypeKind.ZodUnknown},"isUnknownSchema"),jm=a(({type:t,minimum:e,exclusiveMinimum:r,maximum:n,exclusiveMaximum:s,multipleOf:i,format:o})=>{let l=p.number();return t==="integer"&&(l=l.int()),o==="finite"&&(l=l.finite()),r!==void 0?l=l.gt(r):e!==void 0&&(l=l.gte(e)),s!==void 0?l=l.lt(s):n!==void 0&&(l=l.lte(n)),i!==void 0&&(l=l.multipleOf(i)),l},"numberJSONSchemaToZuiNumber"),Km=a(({format:t,pattern:e,minLength:r,maxLength:n})=>{let s=p.string();if(r&&n&&r===n?s=s.length(r):(r&&(s=s.min(r)),n&&(s=s.max(n))),t==="cuid"||e===j.cuid)s=s.cuid();else if(t==="cuid2"||e===j.cuid2)s=s.cuid2();else if(t==="emoji"||e===j.emoji)s=s.emoji();else if(t==="ulid"||e===j.ulid)s=s.ulid();else if(t==="date-time"){let{precision:i,offset:o}=e?tm(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 Km(e);if(t==="number"&&(e.type==="number"||e.type==="integer"))return jm(e);if(t==="boolean")return p.boolean();if(t==="null")return p.null();throw new Ur(`Unknown primitive type: "${t}"`)}if(n.length===1)return p.literal(s);let i=n.map(o=>p.literal(o));return p.union(i)},"toZuiPrimitive"),Um=a((t,e)=>zm(t)?Lm(t,e):Fm(t)?Wm(t,e):qm(t,e),"arrayJSONSchemaToZuiArray"),zm=a(t=>Array.isArray(t.items),"_isTuple"),Fm=a(t=>t.items!==void 0&&t.uniqueItems,"_isSet"),Lm=a(({items:t,additionalItems:e},r)=>{let n=t.map(r),s=p.tuple(n);return e!==void 0&&(s=s.rest(r(e))),s},"_handleTuple"),Wm=a(({items:t,minItems:e,maxItems:r},n)=>{let s=p.set(n(t));return e&&(s=s.min(e)),r&&(s=s.max(r)),s},"_handleSet"),qm=a(({minItems:t,maxItems:e,items:r},n)=>{let s=p.array(n(r));return t&&t===e?s.length(t):(t&&(s=s.min(t)),e&&(s=s.max(e)),s)},"_handleArray"),Ye=p.any();function ad(t){return L(t)}a(ad,"fromJSONSchema");function L(t){var e;if(t===void 0)return Ye;if(t===!0)return p.any();if(t===!1)return p.never();if(t.default!==void 0)return L(f(c({},t),{default:void 0})).default(t.default);if(t.readOnly)return L(f(c({},t),{readOnly:void 0})).readonly();if(t.oneOf!==void 0)throw new Pe({oneOf:t.oneOf});if(t.patternProperties!==void 0)throw new Pe({patternProperties:t.patternProperties});if(t.propertyNames!==void 0)throw new Pe({propertyNames:t.propertyNames});if(t.if!==void 0)throw new Pe({if:t.if});if(t.then!==void 0)throw new Pe({then:t.then});if(t.else!==void 0)throw new Pe({else:t.else});if(t.$ref!==void 0)return p.ref(t.$ref);if(t.not!==void 0){if(id(t))return p.undefined();if(t.not===!0)return p.never();throw new Pe({not:t.not})}if(Array.isArray(t.type)){if(t.type.length===0)return Ye;if(t.type.length===1)return L(f(c({},t),{type:t.type[0]}));let r=t,{type:n}=r,s=Zi(r,["type"]),i=t.type.map(o=>L(f(c({},s),{type:o})));return p.union(i)}if(t.type==="string")return t.enum&&t.enum.length>0?p.enum(t.enum):_t("string",t);if(t.type==="integer"){let r=_t("number",t);return r instanceof p.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 Um(t,L);if(t.type==="object"){if(t.additionalProperties!==void 0&&t.properties!==void 0){let r=L(t.additionalProperties);return L(f(c({},t),{additionalProperties:void 0})).catchall(r)}if(t.properties!==void 0){let r={};for(let[n,s]of Object.entries(t.properties)){let i=L(s),o=(e=t.required)!=null?e:[];r[n]=o.includes(n)?i:i.optional()}return p.object(r)}if(t.additionalProperties!==void 0){let r=L(t.additionalProperties);return p.record(r)}return p.record(Ye)}if(t.anyOf!==void 0){if(t.anyOf.length===0)return Ye;if(t.anyOf.length===1)return L(t.anyOf[0]);if(Nm(t))return L(t.anyOf[0]).optional();if(Mm(t))return L(t.anyOf[0]).nullable();let r=t.anyOf.map(L);return p.union(r)}if(t.allOf!==void 0){if(t.allOf.length===0)return Ye;if(t.allOf.length===1)return L(t.allOf[0]);let[r,...n]=t.allOf,s=L(r),i=L({allOf:n});return p.intersection(s,i)}return $m(t)?p.unknown():Ye}a(L,"_fromJSONSchema");var Vm=/^\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))?$/,Wn=a((t,e,r=!0)=>{if(typeof t!="object")throw new Dn("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]=Vm.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(Wn(d[0],e,!1))):["string","number","boolean"].includes(typeof d[0])&&(o[l]=n(y.array(y[typeof d[0]]()))):o[l]=n(Wn(d,e,!1));break;default:throw new Dn(`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 od(){return{}}a(od,"parseAnyDef");function ld(t,e){var r,n;let s={type:"array"};return((n=(r=t.type)==null?void 0:r._def)==null?void 0:n.typeName)!=="ZodAny"&&(s.items=A(t.type._def,f(c({},e),{currentPath:[...e.currentPath,"items"]}))),t.minLength&&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(ld,"parseArrayDef");function cd(t,e){let r=c({type:"integer",format:"int64"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?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(cd,"parseBigintDef");function dd(t){return c({type:"boolean"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{})}a(dd,"parseBooleanDef");function ud(t,e){return A(t.type._def,e)}a(ud,"parseBrandedDef");var Gm=a((t,e)=>A(t.innerType._def,e),"parseCatchDef");function pd(t,e){return e.dateStrategy=="integer"?Jm(t,e):c({type:"string",format:"date-time"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{})}a(pd,"parseDateDef");var Jm=a((t,e)=>{let r=c({type:"integer",format:"unix-time"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{});for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"&&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 fd(t,e){return f(c({},A(t.innerType._def,e)),{default:t.defaultValue()})}a(fd,"parseDefaultDef");function gd(t,e){return e.effectStrategy==="input"?A(t.schema._def,e):{}}a(gd,"parseEffectsDef");function hd(t){return{type:"string",enum:t.values}}a(hd,"parseEnumDef");var Ym=a(t=>"type"in t&&t.type==="string"?!1:"allOf"in t,"isJsonSchema7AllOfType");function md(t,e){let r=[A(t.left._def,f(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),A(t.right._def,f(c({},e),{currentPath:[...e.currentPath,"allOf","1"]}))].filter(i=>!!i),n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,s=[];return r.forEach(i=>{if(Ym(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=Zi(l,["additionalProperties"])}else n=void 0;s.push(o)}}),s.length?c({allOf:s},n):void 0}a(md,"parseIntersectionDef");function yd(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(yd,"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,u)=>{var g;return f(c({},d),{[u]:(g=A(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"properties",u]})))!=null?g:{}})},{}),additionalProperties:!1};let l={type:"object",additionalProperties:(n=A(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?n:{}};if(e.target==="openApi3")return l;if(((s=t.keyType)==null?void 0:s._def.typeName)==="ZodString"&&((i=t.keyType._def.checks)!=null&&i.length)){let d=Object.entries(ls(t.keyType._def,e)).reduce((u,[g,m])=>g==="type"?u:f(c({},u),{[g]:m}),{});return f(c({},l),{propertyNames:d})}else if(((o=t.keyType)==null?void 0:o._def.typeName)==="ZodEnum")return f(c({},l),{propertyNames:{enum:t.keyType._def.values}});return l}a(Cs,"parseRecordDef");function vd(t,e){if(e.mapStrategy==="record")return Cs(t,e);let r=A(t.keyType._def,f(c({},e),{currentPath:[...e.currentPath,"items","items","0"]}))||{},n=A(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"items","items","1"]}))||{};return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}a(vd,"parseMapDef");function _d(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(_d,"parseNativeEnumDef");function Td(){return{not:{}}}a(Td,"parseNeverDef");function bd(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}a(bd,"parseNullDef");var jr={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function wd(t,e){if(e.target==="openApi3")return ki(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in jr&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((s,i)=>{let o=jr[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 ki(t,e)}a(wd,"parseUnionDef");var ki=a((t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((s,i)=>A(s._def,f(c({},e),{currentPath:[...e.currentPath,e.unionStrategy,`${i}`]}))).filter(s=>!!s&&(!e.strictUnions||typeof s=="object"&&Object.keys(s).length>0)),n=e.discriminator&&t.typeName==="ZodDiscriminatedUnion"&&typeof t.discriminator=="string"?{discriminator:{propertyName:t.discriminator}}:{};if(r.length)return e.unionStrategy==="anyOf"?c({anyOf:r},n):c({oneOf:r},n)},"asUnionOf");function Pd(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:jr[n._def.typeName],nullable:!0};return qn(n._def,e,i)}let s={type:[jr[n._def.typeName],"null"]};return qn(n._def,e,s)}if(e.target==="openApi3"){let n=A(t.innerType._def,f(c({},e),{currentPath:[...e.currentPath]}));return n&&f(c({},n),{nullable:!0})}let r=A(t.innerType._def,f(c({},e),{currentPath:[...e.currentPath,"anyOf","0"]}));return r&&{anyOf:[r,{type:"null"}]}}a(Pd,"parseNullableDef");function xd(t,e){let r=c({type:"number"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"int":r.type="integer",os(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(xd,"parseNumberDef");var Xm=a((t,e)=>{var r;return t.unknownKeys instanceof O?(r=A(t.unknownKeys._def,f(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?r:!0:t.unknownKeys==="passthrough"},"getAdditionalProperties");function kd(t,e){let r=f(c({type:"object"},Object.entries(t.shape()).reduce((n,[s,i])=>{if(i===void 0||i._def===void 0)return n;let o=A(i._def,f(c({},e),{currentPath:[...e.currentPath,"properties",s],propertyPath:[...e.currentPath,"properties",s]}));return o===void 0?n:{properties:f(c({},n.properties),{[s]:o}),required:i.isOptional()?n.required:[...n.required,s]}},{properties:{},required:[]})),{additionalProperties:Xm(t,e)});return r.required.length||delete r.required,r}a(kd,"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,f(c({},e),{currentPath:[...e.currentPath,"anyOf","1"]}));return n?{anyOf:[{not:{}},n]}:{}},"parseOptionalDef"),ey=a((t,e)=>{if(e.pipeStrategy==="input")return A(t.in._def,e);if(e.pipeStrategy==="output")return A(t.out._def,e);let r=A(t.in._def,f(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),n=A(t.out._def,f(c({},e),{currentPath:[...e.currentPath,"allOf",r?"1":"0"]}));return{allOf:[r,n].filter(s=>s!==void 0)}},"parsePipelineDef");function Sd(t,e){return A(t.type._def,e)}a(Sd,"parsePromiseDef");function Ed(t,e){let n={type:"array",uniqueItems:!0,items:A(t.valueType._def,f(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 Od(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>A(r._def,f(c({},e),{currentPath:[...e.currentPath,"items",`${n}`]}))).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:A(t.rest._def,f(c({},e),{currentPath:[...e.currentPath,"additionalItems"]}))}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>A(r._def,f(c({},e),{currentPath:[...e.currentPath,"items",`${n}`]}))).reduce((r,n)=>n===void 0?r:[...r,n],[])}}a(Od,"parseTupleDef");function Zd(){return{not:{}}}a(Zd,"parseUndefinedDef");function Id(){return{}}a(Id,"parseUnknownDef");var ty=a((t,e)=>A(t.innerType._def,e),"parseReadonlyDef");function Bd(t){return{$ref:t.uri}}a(Bd,"parseRefDef");function A(t,e,r=!1){let n=e.seen.get(t);if(n&&!r){let o=ry(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=sy(t,t.typeName,e);return i&&qn(t,e,i),s.jsonSchema=i,i}a(A,"parseDef");var ry=a((t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:ny(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"),ny=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"),sy=a((t,e,r)=>{switch(e){case"ZodString":return ls(t,r);case"ZodNumber":return xd(t,r);case"ZodObject":return kd(t,r);case"ZodBigInt":return cd(t,r);case"ZodBoolean":return dd(t);case"ZodDate":return pd(t,r);case"ZodUndefined":return Zd();case"ZodNull":return bd(r);case"ZodArray":return ld(t,r);case"ZodUnion":case"ZodDiscriminatedUnion":return wd(t,r);case"ZodIntersection":return md(t,r);case"ZodTuple":return Od(t,r);case"ZodRecord":return Cs(t,r);case"ZodRef":return Bd(t);case"ZodLiteral":return yd(t,r);case"ZodEnum":return hd(t);case"ZodNativeEnum":return _d(t);case"ZodNullable":return Pd(t,r);case"ZodOptional":return Qm(t,r);case"ZodMap":return vd(t,r);case"ZodSet":return Ed(t,r);case"ZodLazy":return A(t.getter()._def,r);case"ZodPromise":return Sd(t,r);case"ZodNaN":case"ZodNever":return Td();case"ZodEffects":return gd(t,r);case"ZodAny":return od();case"ZodUnknown":return Id();case"ZodDefault":return fd(t,r);case"ZodBranded":return ud(t,r);case"ZodReadonly":return ty(t,r);case"ZodCatch":return Gm(t,r);case"ZodPipeline":return ey(t,r);case"ZodFunction":case"ZodVoid":case"ZodSymbol":return;default:return(n=>{})(e)}},"selectParser"),qn=a((t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),Object.assign(r,{[w]:c(c({},t[w]),r[w])}),r),"addMeta"),Si={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"},iy=a(t=>typeof t=="string"?f(c({},Si),{name:t}):c(c({},Si),t),"getDefaultOptions"),ay=a(t=>{let e=iy(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return f(c({},e),{currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([n,s])=>[s._def,{def:s._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))})},"getRefs"),oy=a((t,e)=>{var r;let n=ay(e),s=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((d,[u,g])=>{var m;return f(c({},d),{[u]:(m=A(g._def,f(c({},n),{currentPath:[...n.basePath,n.definitionPath,u]}),!0))!=null?m:{}})},{}):void 0,i=typeof e=="string"?e:e?.name,o=(r=A(t._def,i===void 0?n:f(c({},n),{currentPath:[...n.basePath,n.definitionPath,i]}),!1))!=null?r:{},l=i===void 0?s?f(c({},o),{[n.definitionPath]:s}):o:{$ref:[...n.$refStrategy==="relative"?[]:n.basePath,n.definitionPath,i].join("/"),[n.definitionPath]:f(c({},s),{[i]:o})};return n.target==="jsonSchema7"?l.$schema="http://json-schema.org/draft-07/schema#":n.target==="jsonSchema2019-09"&&(l.$schema="https://json-schema.org/draft/2019-09/schema#"),l},"zodToJsonSchema"),ly=a((t,e={target:"openApi3"})=>{let r=oy(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")},Ad=y;var ne=y.string().min(1),Cd=y.object({text:ne}),Hd=y.object({markdown:ne}),Dd=y.object({imageUrl:ne}),Nd=y.object({audioUrl:ne}),Md=y.object({videoUrl:ne}),$d=y.object({fileUrl:ne,title:ne.optional()}),jd=y.object({latitude:y.number(),longitude:y.number(),address:y.string().optional(),title:y.string().optional()}),Kd=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}))}),Rd=y.object({text:ne,options:y.array(y.object({label:ne,value:ne}))}),cy=y.object({items:y.array(Kd)}),dy=y.union([y.object({type:y.literal("text"),payload:Cd}),y.object({type:y.literal("markdown"),payload:Hd}),y.object({type:y.literal("image"),payload:Dd}),y.object({type:y.literal("audio"),payload:Nd}),y.object({type:y.literal("video"),payload:Md}),y.object({type:y.literal("file"),payload:$d}),y.object({type:y.literal("location"),payload:jd})]),uy=y.object({items:y.array(dy)}),py={schema:Hd},fy={text:{schema:Cd},image:{schema:Dd},audio:{schema:Nd},video:{schema:Md},file:{schema:$d},location:{schema:jd},carousel:{schema:cy},card:{schema:Kd},dropdown:{schema:Rd},choice:{schema:Rd},bloc:{schema:uy}};var gy={HIDDEN_IN_STUDIO:{bpActionHiddenInStudio:"true"},AWAIT_RETURN:{bpActionAwaitReturn:"true"}};var Ud=require("browser-or-node");var Ds=console;function le(t){if(!t.body)throw new Error("Missing body");return JSON.parse(t.body)}async function qt(t,e=8072,r=vy){if(!Ud.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 hy(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){Ds.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 hy(t){let e=await yy(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:my(n.search,"?"),headers:r,method:t.method?.toUpperCase()??"GET"}}function my(t,e){return t.indexOf(e)===0?t.slice(e.length):t}async function yy(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 vy(t){Ds.info(`Listening on port ${t}`)}var Sn=require("@botpress/client");var N={};yt(N,{mapKeys:()=>by,mapValues:()=>Ty,mergeRecords:()=>Py,pairs:()=>pn,stripUndefinedProps:()=>wy,values:()=>_y});var pn=t=>Object.entries(t),_y=t=>Object.values(t),Ty=(t,e)=>Object.fromEntries(pn(t).map(([r,n])=>[r,e(n,r)])),by=(t,e)=>Object.fromEntries(pn(t).map(([r,n])=>[e(r),n])),wy=t=>Object.fromEntries(pn(t).filter(([,e])=>e!==void 0)),Py=(t,e,r)=>{let n=[...Object.keys(t),...Object.keys(e)],s=[...new Set(n)],i={};for(let o of s){let l=t[o],d=e[o];l&&d?i[o]=r(l,d):l?i[o]=l:d&&(i[o]=d)}return i};var E={};yt(E,{safePush:()=>xy,unique:()=>ky});var xy=(t,...e)=>t?[...t,...e]:[...e],ky=t=>Array.from(new Set(t));var Y={};yt(Y,{setName:()=>Sy});var Sy=(t,e)=>(Object.defineProperty(t,"name",{value:e}),t);var zd=t=>{let{name:e,version:r}=t,n={actions:{},events:{},channels:{}},s={name:e,version:r,entities:N.mapValues(t.entities,o=>({name:o.name})),actions:{},events:{},channels:{}},i=N.mapValues(t.entities,o=>o.schema);for(let[o,l]of Object.entries(t.definition.actions??{})){let d=l.input.schema.dereference(i),u=l.output.schema.dereference(i),g=t.actions?.[o]?.name??o;n.actions[g]={...l,...t.actions?.[o]??{},input:{schema:d},output:{schema:u}},s.actions[o]={name:g}}for(let[o,l]of Object.entries(t.definition.events??{})){let d=l.schema.dereference(i),u=t.events?.[o]?.name??o;n.events[u]={...l,...t.events?.[o]??{},schema:d},s.events[o]={name:u}}for(let[o,l]of Object.entries(t.definition.channels??{})){let d={};for(let[g,m]of Object.entries(l.messages)){let T=m.schema.dereference(i);d[g]={...m,schema:T}}let u=t.channels?.[o]?.name??o;n.channels[u]={...l,...t.channels?.[o]??{},message:{...l.message??{},tags:{...l.message?.tags??{},...t.channels?.[o]?.message?.tags??{}}},conversation:{...l.conversation??{},tags:{...l.conversation?.tags??{},...t.channels?.[o]?.conversation?.tags??{}}},messages:d},s.channels[o]={name:u}}return{resolved:n,statement:s}};var fn=Symbol("schemaName"),Fd=t=>t?N.mapValues(t,(r,n)=>({...r,[fn]:n})):{},Ld=t=>fn in t&&t[fn]!==void 0,Wd=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(T=>T.name),u=d.length===0?e.name:`${e.name}<${d.join(",")}>`,{resolved:g,statement:m}=zd({...e,entities:n,actions:N.stripUndefinedProps(s),events:N.stripUndefinedProps(i),channels:N.stripUndefinedProps(o)});return l.actions=N.mergeRecords(l.actions??{},g.actions,this._mergeActions),l.channels=N.mergeRecords(l.channels??{},g.channels,this._mergeChannels),l.events=N.mergeRecords(l.events??{},g.events,this._mergeEvents),l.interfaces[u]={id:e.id,...m},this}_callBuilder(e,r){let s={entities:Fd(this.entities)},i=r(s),o=N.pairs(i.entities).find(([d,u])=>!Ld(u));if(o)throw new Error(`Cannot extend interface "${e.name}" with entity "${o[0]}"; the provided schema is not part of the integration's entities.`);return{entities:N.mapValues(i.entities,d=>({name:Wd(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 be=require("@botpress/client");var qd=zs(require("@botpress/client")),hn={retries:3,retryCondition:t=>qd.axiosRetry.isNetworkOrIdempotentRequestError(t)||[429,502].includes(t.response?.status??0),retryDelay:(t,e)=>(Ey(e.response?.headers??{})??t)*1e3},Ey=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 Oy(String(n))}},Oy=t=>{let e=Zy(t)?Iy(t):t.length>0?parseInt(t,10):void 0;return e===void 0||isNaN(e)?void 0:e},Zy=t=>t.includes(" "),Iy=t=>{let e=By(t);if(!e)return;let r=new Date;return Math.max(0,Math.floor((e.getTime()-r.getTime())/1e3))},By=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 Ee="#",yn="x-bot-id",Vd="x-bot-user-id",Gd="x-integration-id",Jd="x-integration-alias",Yd="x-webhook-id",Xd="x-bp-configuration-type",vn="x-bp-configuration",_n="x-bp-operation",Qd="x-bp-type";var ce=t=>{throw t instanceof Error?t:new Error(t)};var Qv=y.enum(["webhook_received","message_created","action_triggered","register","unregister","ping","create_user","create_conversation"]),eu=t=>({botId:t[yn]||ce("Missing bot header"),botUserId:t[Vd]||ce("Missing bot user header"),integrationId:t[Gd]||ce("Missing integration header"),integrationAlias:t[Jd]||ce("Missing integration alias header"),webhookId:t[Yd]||ce("Missing webhook header"),operation:t[_n]||ce("Missing operation header"),configurationType:t[Xd]??null,configuration:JSON.parse(Buffer.from(t[vn]||ce("Missing configuration header"),"base64").toString("utf-8"))});var tu=zs(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=tu.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 Ay=t=>["traceparent","tracestate","sentry-trace"].reduce((e,r)=>(t[r]&&(e[r]=t[r]),e),{}),Ry=(t,e,r)=>{let[,n]=(e.headers.traceparent||"").split("-"),s=new be.Client({botId:t.botId,integrationId:t.integrationId,integrationAlias:t.integrationAlias,retry:hn,headers:Ay(e.headers)}),i=new ft(s),o=new ht({traceId:n});return{ctx:t,req:e,client:i,logger:o,instance:r}},Cy=async t=>{let{ctx:e}=t;switch(e.operation){case"webhook_received":return await Dy(t);case"register":return await Ny(t);case"unregister":return await My(t);case"message_created":return await Ky(t);case"action_triggered":return await Uy(t);case"ping":return await Hy(t);case"create_user":return await $y(t);case"create_conversation":return await jy(t);default:throw new be.InvalidPayloadError(`Unknown operation ${e.operation}`)}},ru=t=>async e=>{let r=eu(e.headers),n=Ry(r,e,t),{logger:s}=n;try{let i;return i=await zy(n),i?{...i,status:i.status??200}:(i=await Cy(n),i?{...i,status:i.status??200}:{status:200})}catch(i){if((0,be.isApiError)(i)){let l=i.type==="Runtime"?i:new be.RuntimeError(i.message,i);return s.forBot().error(l.message),{status:l.code,body:JSON.stringify(l.toJSON())}}console.error(i);let o=new be.RuntimeError("An unexpected error occurred in the integration. Bot owners: Check logs for more informations. Integration owners: throw a RuntimeError to return a custom error message instead.");return s.forBot().error(o.message),{status:o.code,body:JSON.stringify(o.toJSON())}}},Hy=async t=>{},Dy=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})},Ny=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})},My=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})},$y=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})},jy=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})},Ky=async({ctx:t,req:e,client:r,logger:n,instance:s})=>{let{conversation:i,user:o,type:l,payload:d,message:u}=le(e),g=s.channels[i.channel];if(!g)throw new Error(`Channel ${i.channel} not found`);let 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:u,user:o,type:l,client:r,payload:d,ack:async({tags:Z})=>{await r.updateMessage({id:u.id,tags:Z})},logger:n})},Uy=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)}},zy=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=ru(this);start=e=>qt(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}${Ee}${n}`);dereferencePluginEntities(){let e=this._buildZuiReferenceMap();return{...this,withPlugins:{...this.withPlugins,events:this._dereferenceDefinitionSchemas(this.withPlugins.events,e),states:this._dereferenceDefinitionSchemas(this.withPlugins.states,e),tables:this._dereferenceDefinitionSchemas(this.withPlugins.tables,e),actions:this._dereferenceActionDefinitionSchemas(this.withPlugins.actions,e)},plugins:Object.fromEntries(Object.entries(this.plugins??{}).map(([r,n])=>[r,{...n,definition:{...n.definition,configuration:this._dereferenceDefinitionSchema(n.definition.configuration,e),events:this._dereferenceDefinitionSchemas(n.definition.events,e),states:this._dereferenceDefinitionSchemas(n.definition.states,e),tables:this._dereferenceDefinitionSchemas(n.definition.tables,e),actions:this._dereferenceActionDefinitionSchemas(n.definition.actions,e)}}]))}}_buildZuiReferenceMap(){let e={},r=Object.entries(this.plugins??{});for(let[n,s]of r){let i=Object.entries(s.interfaces??{});for(let[o,l]of i){let d=this.integrations?.[l.name];if(!d)throw new Error(`Interface with alias "${o}" of plugin with alias "${n}" references integration "${l.name}" which is not installed`);let u=Object.entries(l.entities??{});for(let[g,{name:m}]of u){let T=d.definition.entities?.[m]?.schema;if(!T)throw new Error(`Interface entity "${m}" does not exist in integration "${d.name}"`);e[`interface:${o}/entities/${g}`]=T}}}return e}_dereferenceZuiSchema(e,r){return e.dereference(r)}_dereferenceDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,this._dereferenceDefinitionSchema(s,r)]))}_dereferenceDefinitionSchema(e,r){return e&&{...e,schema:this._dereferenceZuiSchema(e.schema,r)}}_dereferenceActionDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,{...s,input:{schema:this._dereferenceZuiSchema(s.input.schema,r)},output:{schema:this._dereferenceZuiSchema(s.output.schema,r)}}]))}};var Je=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 fe=class{constructor(e,r={before:{},after:{}}){this._client=e;this._hooks=r}get _inner(){return this._client}getConversation=(e=>this._run("getConversation",e));listConversations=(e=>this._run("listConversations",e));updateConversation=(e=>this._run("updateConversation",e));deleteConversation=(e=>this._run("deleteConversation",e));listParticipants=(e=>this._run("listParticipants",e));addParticipant=(e=>this._run("addParticipant",e));getParticipant=(e=>this._run("getParticipant",e));removeParticipant=(e=>this._run("removeParticipant",e));createEvent=(e=>this._run("createEvent",e));getEvent=(e=>this._run("getEvent",e));listEvents=(e=>this._run("listEvents",e));createMessage=(e=>this._run("createMessage",e));getOrCreateMessage=(e=>this._run("getOrCreateMessage",e));getMessage=(e=>this._run("getMessage",e));updateMessage=(e=>this._run("updateMessage",e));listMessages=(e=>this._run("listMessages",e));deleteMessage=(e=>this._run("deleteMessage",e));getUser=(e=>this._run("getUser",e));listUsers=(e=>this._run("listUsers",e));updateUser=(e=>this._run("updateUser",e));deleteUser=(e=>this._run("deleteUser",e));getState=(e=>this._run("getState",e));setState=(e=>this._run("setState",e));getOrSetState=(e=>this._run("getOrSetState",e));patchState=(e=>this._run("patchState",e));callAction=(e=>this._run("callAction",e));uploadFile=(e=>this._run("uploadFile",e));upsertFile=(e=>this._run("upsertFile",e));deleteFile=(e=>this._run("deleteFile",e));listFiles=(e=>this._run("listFiles",e));getFile=(e=>this._run("getFile",e));updateFileMetadata=(e=>this._run("updateFileMetadata",e));searchFiles=(e=>this._run("searchFiles",e));trackAnalytics=(e=>this._run("trackAnalytics",e));getTableRow=(e=>this._run("getTableRow",e));createTableRows=(e=>this._run("createTableRows",e));findTableRows=(e=>this._run("findTableRows",e));deleteTableRows=(e=>this._run("deleteTableRows",e));updateTableRows=(e=>this._run("updateTableRows",e));upsertTableRows=(e=>this._run("upsertTableRows",e));createWorkflow=(e=>this._run("createWorkflow",e));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 Fy=y.enum(["event_received","register","unregister","ping","action_triggered"]),nu=t=>({botId:t[yn]||ce("Missing bot id header"),operation:Fy.parse(t[_n]),type:t[Qd]||ce("Missing type header"),configuration:JSON.parse(Buffer.from(t[vn]||ce("Missing configuration header"),"base64").toString("utf-8"))});var X={status:200};var Ms=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 Ly=["child_workflow_deleted","child_workflow_finished","workflow_timedout","workflow_started","workflow_continued"],su=async(t,e)=>{if(t.ctx.type!=="workflow_update"||!Ly.includes(e.payload.type))throw new Error("Unexpected event type");let r={...t,logger:Wy(t,e)};if(!e.payload.workflow.name)return r.logger.warn("Received workflow update event without a workflow name. Assuming this workflow was not defined by the bot.",e.payload.workflow),X;switch(e.payload.type){case"child_workflow_deleted":case"child_workflow_finished":r.logger.info(`Received child workflow event "${e.payload.type}", but child workflows are not yet supported`);break;case"workflow_timedout":case"workflow_started":case"workflow_continued":return await qy(r,e);default:e.payload.type}return X},Wy=(t,e)=>t.logger.with({eventId:e.id,workflowId:e.payload.workflow.id,conversationId:e.payload.conversation?.id,userId:e.payload.user?.id}),qy=async(t,e)=>{let r=Ms(e.payload.type),n=t.self.workflowHandlers[r]?.[e.payload.workflow.name];if(!n||n.length===0)return t.logger.warn(`No ${r} handler found for workflow "${e.payload.workflow.name}"`),X;let{updatedWorkflow:s}=await Vy(t,e);return s.status==="pending"&&t.logger.warn(`Workflow "${e.payload.workflow.name}" is still in pending status after processing "${r}" event. This may indicate that the workflow was not properly acknowledged or terminated by the handler. `),X},Vy=async(t,e)=>{let r=Ms(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 iu=t=>async e=>{let r=nu(e.headers),n=new mt,s=new Je.Client({botId:r.botId,retry:hn}),i=new fe(s,{before:{createMessage:async l=>{let d=t.hookHandlers.before_outgoing_message[l.type]??[];for(let u of d){let g=new fe(s);l=(await u({client:g,ctx:r,logger:n.with({conversationId:l.conversationId,userId:l.userId}),data:l}))?.data??l}return l},callAction:async l=>{let d=t.hookHandlers.before_outgoing_call_action[l.type]??[];for(let u of d){let g=new fe(s);l=(await u({client:g,ctx:r,logger:n,data:l}))?.data??l}return l}},after:{createMessage:async l=>{let d=t.hookHandlers.after_outgoing_message[l.message.type]??[];for(let u of d){let g=new fe(s);l=(await u({client:g,ctx:r,logger:n.with({messageId:l.message.id,conversationId:l.message.conversationId,userId:l.message.userId}),data:l}))?.data??l}return l},callAction:async(l,d)=>{let{type:u}=d,g=t.hookHandlers.after_outgoing_call_action[u]??[];for(let m of g){let T=new fe(s);l=(await m({client:T,ctx:r,logger:n,data:{type:u,...l}}))?.data??l}return l}}}),o={req:e,ctx:r,logger:n,client:i,self:t};try{switch(r.operation){case"action_triggered":return await Qy(o);case"event_received":return await Xy(o);case"register":return await Jy(o);case"unregister":return await Yy(o);case"ping":return await Gy(o);default:throw new Error(`Unknown operation ${r.operation}`)}}catch(l){let d=l instanceof Error?l:new Error(String(l));if((0,Je.isApiError)(d)){let g=d.type==="Runtime"?d:new Je.RuntimeError(d.message,d);return n.error(g.message),{status:g.code,body:JSON.stringify(g.toJSON())}}let u=new Je.RuntimeError("An unexpected error occurred in the bot.",d);return n.error(u.message,d),{status:u.code,body:JSON.stringify(u.toJSON())}}},Gy=async t=>X,Jy=async t=>X,Yy=async t=>X,Xy=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 su(t,l.event);if(e.type==="message_created"){let Z=l.event,k=Z.payload.message;o.logger=o.logger.with({messageId:k.id,conversationId:k.conversationId,userId:k.userId});let K=i.hookHandlers.before_incoming_message[k.type]??[];for(let ue of K){let ae=await ue({...o,data:k});if(k=ae?.data??k,ae?.stop)return X}let F={...o,user:Z.payload.user,conversation:Z.payload.conversation,message:k,event:Z},Q=i.messageHandlers[k.type]??[];for(let ue of Q)await ue(F);let ie=i.hookHandlers.after_incoming_message[k.type]??[];for(let ue of ie){let ae=await ue({...o,data:k});if(k=ae?.data??k,ae?.stop)return X}return X}if(e.type==="state_expired"){let k=l.event.payload.state,K={...o,state:k},F=i.stateExpiredHandlers[k.name]??[];for(let Q of F)await Q(K);return X}let d=l.event,u=i.hookHandlers.before_incoming_event[d.type]??[];for(let Z of u){let k=await Z({...o,data:d});if(d=k?.data??d,k?.stop)return X}let g={...o,event:d},m=i.eventHandlers[d.type]??[];for(let Z of m)await Z(g);let T=i.hookHandlers.after_incoming_event[d.type]??[];for(let Z of T){let k=await Z({...o,data:d});if(d=k?.data??d,k?.stop)return X}return X},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 T of l){let Z=await T({ctx:t,logger:e,client:n,data:{type:o,input:i}});i=Z?.data?.input??i,o=Z?.data?.type??o}let d=s.actionHandlers[o];if(!d)throw new Error(`Action ${o} not found`);let u=await d({ctx:t,logger:e,input:i,client:n,type:o}),g=s.hookHandlers.after_incoming_call_action[o]??[];for(let T of g){let Z=await T({ctx:t,logger:e,client:n,data:{type:o,output:u}});o=Z?.data?.type??o,u=Z?.data?.output??u}return{status:200,body:JSON.stringify({output:u})}};var we=t=>new Proxy({},{get:(e,r)=>({listInstances:{all:n=>Oe({workflowName:r,client:t,input:n}),running:n=>Oe({workflowName:r,client:t,input:n,statuses:["in_progress"]}),scheduled:n=>Oe({workflowName:r,client:t,input:n,statuses:["pending","listening"]}),allFinished:n=>Oe({workflowName:r,client:t,input:n,statuses:["completed","cancelled","failed","timedout"]}),cancelled:n=>Oe({workflowName:r,client:t,input:n,statuses:["cancelled"]}),failed:n=>Oe({workflowName:r,client:t,input:n,statuses:["failed"]}),succeeded:n=>Oe({workflowName:r,client:t,input:n,statuses:["completed"]}),timedOut:n=>Oe({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})}}})}),Oe=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 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(Ee);if(!(o!==s||!l)&&(n=i.actionHandlers[l],n))return Y.setName(d=>n({...d,workflows:we(d.client)}),n.name)}}})}get messageHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.messageHandlers[r]??[]),s=this._messageHandlers[r]??[],i=this._messageHandlers["*"]??[],o=[...s,...i].sort((l,d)=>l.order-d.order).map(({handler:l})=>l);return E.unique([...n,...o]).map(l=>Y.setName(d=>l({...d,workflows:we(d.client)}),l.name))}})}get eventHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.eventHandlers[r]??[]),s=this._eventHandlers[r]??[],i=this._eventHandlers["*"]??[],o=[...s,...i].sort((l,d)=>l.order-d.order).map(({handler:l})=>l);return E.unique([...n,...o]).map(l=>Y.setName(d=>l({...d,workflows:we(d.client)}),l.name))}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.stateExpiredHandlers[r]??[]),s=this._stateExpiredHandlers[r]??[],i=this._stateExpiredHandlers["*"]??[],o=[...s,...i].sort((l,d)=>l.order-d.order).map(({handler:l})=>l);return E.unique([...n,...o]).map(l=>Y.setName(d=>l({...d,workflows:we(d.client)}),l.name))}})}get hookHandlers(){return new Proxy({},{get:(e,r)=>{if(this._hookHandlers[r])return new Proxy({},{get:(s,i)=>{let o=Object.values(this._plugins).flatMap(m=>m.hookHandlers[r]?.[i]??[]),l=this._hookHandlers[r]??{},d=l[i]??[],u=l["*"]??[],g=[...d,...u].sort((m,T)=>m.order-T.order).map(({handler:m})=>m);return E.unique([...o,...g]).map(m=>Y.setName(T=>m({...T,workflows:we(T.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,u)=>d.order-u.order).map(({handler:d})=>d)??[],l=Object.values(this._plugins).flatMap(d=>d.workflowHandlers[r]?.[i]??[]);return E.unique([...o,...l]).map(d=>Y.setName(async u=>{let g=u.workflow;return await d({...u,workflow:de({...u,onWorkflowUpdate(m){g=m}}),workflows:we(u.client)}),g},d.name))}})}})}on={message:(e,r)=>{this._messageHandlers[e]=E.safePush(this._messageHandlers[e],{handler:r,order:this._registerOrder++})},event:(e,r)=>{this._eventHandlers[e]=E.safePush(this._eventHandlers[e],{handler:r,order:this._registerOrder++})},stateExpired:(e,r)=>{this._stateExpiredHandlers[e]=E.safePush(this._stateExpiredHandlers[e],{handler:r,order:this._registerOrder++})},beforeIncomingEvent:(e,r)=>{this._hookHandlers.before_incoming_event[e]=E.safePush(this._hookHandlers.before_incoming_event[e],{handler:r,order:this._registerOrder++})},beforeIncomingMessage:(e,r)=>{this._hookHandlers.before_incoming_message[e]=E.safePush(this._hookHandlers.before_incoming_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingMessage:(e,r)=>{this._hookHandlers.before_outgoing_message[e]=E.safePush(this._hookHandlers.before_outgoing_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingCallAction:(e,r)=>{this._hookHandlers.before_outgoing_call_action[e]=E.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},beforeIncomingCallAction:(e,r)=>{this._hookHandlers.before_incoming_call_action[e]=E.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingEvent:(e,r)=>{this._hookHandlers.after_incoming_event[e]=E.safePush(this._hookHandlers.after_incoming_event[e],{handler:r,order:this._registerOrder++})},afterIncomingMessage:(e,r)=>{this._hookHandlers.after_incoming_message[e]=E.safePush(this._hookHandlers.after_incoming_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingMessage:(e,r)=>{this._hookHandlers.after_outgoing_message[e]=E.safePush(this._hookHandlers.after_outgoing_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingCallAction:(e,r)=>{this._hookHandlers.after_outgoing_call_action[e]=E.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingCallAction:(e,r)=>{this._hookHandlers.after_incoming_call_action[e]=E.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:r,order:this._registerOrder++})},workflowStart:(e,r)=>{this._workflowHandlers.started[e]=E.safePush(this._workflowHandlers.started[e],{handler:r,order:this._registerOrder++})},workflowContinue:(e,r)=>{this._workflowHandlers.continued[e]=E.safePush(this._workflowHandlers.continued[e],{handler:r,order:this._registerOrder++})},workflowTimeout:(e,r)=>{this._workflowHandlers.timed_out[e]=E.safePush(this._workflowHandlers.timed_out[e],{handler:r,order:this._registerOrder++})}};handler=iu(this);start=e=>qt(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=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 $s=":";var au=t=>{let[e,r]=t.split($s);return!e||!r?null:{namespace:e,eventName:r}},ou=t=>`${t.namespace}${$s}${t.actionName}`,lu=t=>`${t.namespace}${$s}${t.eventName}`,cu=(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}},du=(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 uu=(t,e)=>new Proxy({},{get:(r,n)=>new Proxy({},{get:(s,i)=>o=>ev({client:t,interfaces:e.interfaces,integrationOrInterfaceName:n,methodName:i,input:o})})}),ev=async({client:t,interfaces:e,integrationOrInterfaceName:r,methodName:n,input:s})=>{let i=cu({namespace:r,actionName:n},e),o=ou(i);return(await t.callAction({type:o,input:s})).output};var js=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})}},pu=(t,e)=>new Proxy({},{get:(r,n)=>{let s=e.alias!==void 0?`${e.alias}${Ee}${n}`:n;return new js({client:t,eventName:s})}});var Ks=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})}},fu=(t,e)=>new Proxy({},{get:(r,n)=>new Proxy({},{get:(s,i)=>{let o=e.alias!==void 0?`${e.alias}${Ee}${i}`:i;return new Ks(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=uu(e,this._runtime),o=fu(e,this._runtime),l=we(e),d=pu(e,this._runtime);return{configuration:r,interfaces:n,actions:i,states:o,alias:s,workflows:l,events:d}}get actionHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._actionHandlers[r];if(n)return Y.setName(s=>n({...s,...this._getTools(s.client)}),n.name)}})}get messageHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._messageHandlers[r]??[],s=this._messageHandlers["*"]??[];return E.unique([...n,...s]).sort((o,l)=>o.order-l.order).map(({handler:o})=>Y.setName(l=>o({...l,message:l.message,...this._getTools(l.client)}),o.name))}})}get eventHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._eventHandlers[r]??[],s=Object.entries(this._eventHandlers).filter(([l])=>this._eventResolvesTo(l,r)).flatMap(([,l])=>l??[]),i=this._eventHandlers["*"]??[];return E.unique([...n,...s,...i]).sort((l,d)=>l.order-d.order).map(({handler:l})=>Y.setName(d=>l({...d,event:d.event,...this._getTools(d.client)}),l.name))}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._stateExpiredHandlers[r]??[],s=this._stateExpiredHandlers["*"]??[];return E.unique([...n,...s]).sort((o,l)=>o.order-l.order).map(({handler:o})=>Y.setName(l=>o({...l,state:l.state,...this._getTools(l.client)}),o.name))}})}get hookHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._hookHandlers[r];if(n)return new Proxy({},{get:(s,i)=>{i=this._stripAliasPrefix(i);let o=n[i]??[],l=Object.entries(n).filter(([g])=>this._eventResolvesTo(g,i)).flatMap(([,g])=>g??[]),d=n["*"]??[];return E.unique([...o,...l,...d]).sort((g,m)=>g.order-m.order).map(({handler:g})=>Y.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})=>Y.setName(async d=>{let u=d.workflow;return await l({...d,workflow:de({...d,onWorkflowUpdate(g){u=g}}),...this._getTools(d.client)}),u},l.name))})}})}on={message:(e,r)=>{this._messageHandlers[e]=E.safePush(this._messageHandlers[e],{handler:r,order:this._registerOrder++})},event:(e,r)=>{this._eventHandlers[e]=E.safePush(this._eventHandlers[e],{handler:r,order:this._registerOrder++})},stateExpired:(e,r)=>{this._stateExpiredHandlers[e]=E.safePush(this._stateExpiredHandlers[e],{handler:r,order:this._registerOrder++})},beforeIncomingEvent:(e,r)=>{this._hookHandlers.before_incoming_event[e]=E.safePush(this._hookHandlers.before_incoming_event[e],{handler:r,order:this._registerOrder++})},beforeIncomingMessage:(e,r)=>{this._hookHandlers.before_incoming_message[e]=E.safePush(this._hookHandlers.before_incoming_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingMessage:(e,r)=>{this._hookHandlers.before_outgoing_message[e]=E.safePush(this._hookHandlers.before_outgoing_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingCallAction:(e,r)=>{this._hookHandlers.before_outgoing_call_action[e]=E.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},beforeIncomingCallAction:(e,r)=>{this._hookHandlers.before_incoming_call_action[e]=E.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingEvent:(e,r)=>{this._hookHandlers.after_incoming_event[e]=E.safePush(this._hookHandlers.after_incoming_event[e],{handler:r,order:this._registerOrder++})},afterIncomingMessage:(e,r)=>{this._hookHandlers.after_incoming_message[e]=E.safePush(this._hookHandlers.after_incoming_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingMessage:(e,r)=>{this._hookHandlers.after_outgoing_message[e]=E.safePush(this._hookHandlers.after_outgoing_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingCallAction:(e,r)=>{this._hookHandlers.after_outgoing_call_action[e]=E.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingCallAction:(e,r)=>{this._hookHandlers.after_incoming_call_action[e]=E.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:r,order:this._registerOrder++})},workflowStart:(e,r)=>{this._workflowHandlers.started[e]=E.safePush(this._workflowHandlers.started[e],{handler:r,order:this._registerOrder++})},workflowContinue:(e,r)=>{this._workflowHandlers.continued[e]=E.safePush(this._workflowHandlers.continued[e],{handler:r,order:this._registerOrder++})},workflowTimeout:(e,r)=>{this._workflowHandlers.timed_out[e]=E.safePush(this._workflowHandlers.timed_out[e],{handler:r,order:this._registerOrder++})}};_eventResolvesTo=(e,r)=>{let n=au(e);if(!n)return!1;let s=du(n,this._runtime.interfaces);return lu(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,json,knowledgebase,late,lazy,literal,makeIssue,map,mergeObjectSchemas,message,messages,nan,nativeEnum,never,null:null,nullable,number,object,objectUtil,oboolean,onumber,optional,ostring,parseBody,pipeline,preprocess,processCreateParams,promise,quotelessJson,readonly,record,ref,serve,set,setErrorMap,strictObject,string,symbol,table,tablerow,transformer,transforms,tuple,ulidRegex,undefined,union,unknown,user,util,uuidRegex,variable,void:null,z});
|
|
68
73
|
/*! Bundled license information:
|
|
69
74
|
|
|
70
75
|
@bpinternal/zui/dist/index.js:
|