@botpress/sdk 6.4.0 → 6.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var vc=Object.create;var Wt=Object.defineProperty;var _c=Object.getOwnPropertyDescriptor;var Tc=Object.getOwnPropertyNames;var bc=Object.getPrototypeOf,wc=Object.prototype.hasOwnProperty;var et=(t,e)=>{for(var n in e)Wt(t,n,{get:e[n],enumerable:!0})},pi=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Tc(e))!wc.call(t,i)&&i!==n&&Wt(t,i,{get:()=>e[i],enumerable:!(r=_c(e,i))||r.enumerable});return t};var Kn=(t,e,n)=>(n=t!=null?vc(bc(t)):{},pi(e||!t||!t.__esModule?Wt(n,"default",{value:t,enumerable:!0}):n,t)),xc=t=>pi(Wt({},"__esModule",{value:!0}),t);var av={};et(av,{Bot:()=>Mn,BotDefinition:()=>Hn,BotLogger:()=>dt,BotSpecificClient:()=>me,Integration:()=>Dn,IntegrationDefinition:()=>Bn,IntegrationLogger:()=>ct,IntegrationSpecificClient:()=>lt,InterfaceDefinition:()=>jn,Plugin:()=>Un,PluginDefinition:()=>$n,RuntimeError:()=>zn.RuntimeError,WELL_KNOWN_ATTRIBUTES:()=>yy,isApiError:()=>zn.isApiError,messages:()=>ti,parseBody:()=>ne,serve:()=>zt,version:()=>di,z:()=>y});module.exports=xc(av);var ti={};et(ti,{defaults:()=>hy,markdown:()=>gy,markdownBloc:()=>my});var mr=Object.defineProperty,Pc=Object.defineProperties,kc=Object.getOwnPropertyDescriptors,nn=Object.getOwnPropertySymbols,Gi=Object.prototype.hasOwnProperty,Ji=Object.prototype.propertyIsEnumerable,fi=(t,e,n)=>e in t?mr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,c=(t,e)=>{for(var n in e||(e={}))Gi.call(e,n)&&fi(t,n,e[n]);if(nn)for(var n of nn(e))Ji.call(e,n)&&fi(t,n,e[n]);return t},f=(t,e)=>Pc(t,kc(e)),l=(t,e)=>mr(t,"name",{value:e,configurable:!0}),Yi=(t,e)=>{var n={};for(var r in t)Gi.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&nn)for(var r of nn(t))e.indexOf(r)<0&&Ji.call(t,r)&&(n[r]=t[r]);return n},ce=(t,e)=>{for(var n in e)mr(t,n,{get:e[n],enumerable:!0})},y={};ce(y,{DIRTY:()=>Vr,ERR:()=>qr,OK:()=>ln,any:()=>ze,array:()=>je,bigint:()=>_n,boolean:()=>Ye,branded:()=>Fr,catch:()=>Wr,coerce:()=>Nl,custom:()=>yn,date:()=>Tn,default:()=>Kr,discriminatedUnion:()=>Dt,downstream:()=>jr,enum:()=>wn,function:()=>Dr,instanceof:()=>Or,intersection:()=>xn,is:()=>K,lazy:()=>Rr,literal:()=>Nt,map:()=>Zr,nan:()=>Br,nativeEnum:()=>Cr,never:()=>Rt,null:()=>$t,nullable:()=>Ur,number:()=>Je,object:()=>at,optional:()=>$r,pipeline:()=>Lr,preprocess:()=>Hr,promise:()=>Nr,readonly:()=>zr,record:()=>Ht,ref:()=>bn,set:()=>Pn,strictObject:()=>Ar,string:()=>we,symbol:()=>Ir,transforms:()=>Xi,tuple:()=>Ut,undefined:()=>vn,union:()=>$e,unknown:()=>Be,upstream:()=>Mr,void:()=>Er,zuiKey:()=>B});var Xi={};ce(Xi,{errors:()=>Dl,fromJSONSchema:()=>ru,fromJSONSchemaLegacy:()=>th,fromObject:()=>pr,json:()=>dy,toJSONSchema:()=>z,toJSONSchemaLegacy:()=>Ch,toTypescriptSchema:()=>ei,toTypescriptType:()=>Qr});var xe={};ce(xe,{DIRTY:()=>Vr,ERR:()=>qr,OK:()=>ln,any:()=>ze,array:()=>je,bigint:()=>_n,boolean:()=>Ye,branded:()=>Fr,catch:()=>Wr,coerce:()=>Nl,custom:()=>yn,date:()=>Tn,default:()=>Kr,discriminatedUnion:()=>Dt,downstream:()=>jr,enum:()=>wn,function:()=>Dr,instanceof:()=>Or,intersection:()=>xn,is:()=>K,lazy:()=>Rr,literal:()=>Nt,map:()=>Zr,nan:()=>Br,nativeEnum:()=>Cr,never:()=>Rt,null:()=>$t,nullable:()=>Ur,number:()=>Je,object:()=>at,optional:()=>$r,pipeline:()=>Lr,preprocess:()=>Hr,promise:()=>Nr,readonly:()=>zr,record:()=>Ht,ref:()=>bn,set:()=>Pn,strictObject:()=>Ar,string:()=>we,symbol:()=>Ir,tuple:()=>Ut,undefined:()=>vn,union:()=>$e,unknown:()=>Be,upstream:()=>Mr,void:()=>Er,zuiKey:()=>B});var B="x-zui",$={};ce($,{CustomSet:()=>Zg});var ge={};ce(ge,{isEqual:()=>_o,unique:()=>Cg});var Sc=typeof global=="object"&&global&&global.Object===Object&&global,Qi=Sc,Oc=typeof self=="object"&&self&&self.Object===Object&&self,Ec=Qi||Oc||Function("return this")(),Pe=Ec,Ic=Pe.Symbol,Ie=Ic,es=Object.prototype,Bc=es.hasOwnProperty,Cc=es.toString,ft=Ie?Ie.toStringTag:void 0;function ts(t){var e=Bc.call(t,ft),n=t[ft];try{t[ft]=void 0;var r=!0}catch{}var i=Cc.call(t);return r&&(e?t[ft]=n:delete t[ft]),i}l(ts,"getRawTag");var Ac=ts,Zc=Object.prototype,Rc=Zc.toString;function ns(t){return Rc.call(t)}l(ns,"objectToString");var Nc=ns,Dc="[object Null]",Hc="[object Undefined]",gi=Ie?Ie.toStringTag:void 0;function rs(t){return t==null?t===void 0?Hc:Dc:gi&&gi in Object(t)?Ac(t):Nc(t)}l(rs,"baseGetTag");var Ke=rs;function is(t){return t!=null&&typeof t=="object"}l(is,"isObjectLike");var Ue=is,Mc="[object Symbol]";function ss(t){return typeof t=="symbol"||Ue(t)&&Ke(t)==Mc}l(ss,"isSymbol");var hr=ss;function as(t,e){for(var n=-1,r=t==null?0:t.length,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i}l(as,"arrayMap");var os=as,jc=Array.isArray,be=jc,$c=1/0,mi=Ie?Ie.prototype:void 0,hi=mi?mi.toString:void 0;function yr(t){if(typeof t=="string")return t;if(be(t))return os(t,yr)+"";if(hr(t))return hi?hi.call(t):"";var e=t+"";return e=="0"&&1/t==-$c?"-0":e}l(yr,"baseToString");var Uc=yr;function ls(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}l(ls,"isObject");var st=ls;function us(t){return t}l(us,"identity");var zc=us,Kc="[object AsyncFunction]",Wc="[object Function]",Lc="[object GeneratorFunction]",Fc="[object Proxy]";function cs(t){if(!st(t))return!1;var e=Ke(t);return e==Wc||e==Lc||e==Kc||e==Fc}l(cs,"isFunction");var ds=cs,qc=Pe["__core-js_shared__"],Wn=qc,yi=(function(){var t=/[^.]+$/.exec(Wn&&Wn.keys&&Wn.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function ps(t){return!!yi&&yi in t}l(ps,"isMasked");var Vc=ps,Gc=Function.prototype,Jc=Gc.toString;function fs(t){if(t!=null){try{return Jc.call(t)}catch{}try{return t+""}catch{}}return""}l(fs,"toSource");var We=fs,Yc=/[\\^$.*+?()[\]{}|]/g,Xc=/^\[object .+?Constructor\]$/,Qc=Function.prototype,ed=Object.prototype,td=Qc.toString,nd=ed.hasOwnProperty,rd=RegExp("^"+td.call(nd).replace(Yc,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function gs(t){if(!st(t)||Vc(t))return!1;var e=ds(t)?rd:Xc;return e.test(We(t))}l(gs,"baseIsNative");var id=gs;function ms(t,e){return t?.[e]}l(ms,"getValue");var sd=ms;function hs(t,e){var n=sd(t,e);return id(n)?n:void 0}l(hs,"getNative");var Le=hs,ad=Le(Pe,"WeakMap"),nr=ad,od=(function(){try{var t=Le(Object,"defineProperty");return t({},"",{}),t}catch{}})(),vi=od,ld=9007199254740991,ud=/^(?:0|[1-9]\d*)$/;function ys(t,e){var n=typeof t;return e=e??ld,!!e&&(n=="number"||n!="symbol"&&ud.test(t))&&t>-1&&t%1==0&&t<e}l(ys,"isIndex");var vr=ys;function vs(t,e,n){e=="__proto__"&&vi?vi(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}l(vs,"baseAssignValue");var _s=vs;function Ts(t,e){return t===e||t!==t&&e!==e}l(Ts,"eq");var _r=Ts,cd=Object.prototype,dd=cd.hasOwnProperty;function bs(t,e,n){var r=t[e];(!(dd.call(t,e)&&_r(r,n))||n===void 0&&!(e in t))&&_s(t,e,n)}l(bs,"assignValue");var pd=bs,fd=9007199254740991;function ws(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=fd}l(ws,"isLength");var Tr=ws;function xs(t){return t!=null&&Tr(t.length)&&!ds(t)}l(xs,"isArrayLike");var Ps=xs,gd=Object.prototype;function ks(t){var e=t&&t.constructor,n=typeof e=="function"&&e.prototype||gd;return t===n}l(ks,"isPrototype");var Ss=ks;function Os(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}l(Os,"baseTimes");var md=Os,hd="[object Arguments]";function Es(t){return Ue(t)&&Ke(t)==hd}l(Es,"baseIsArguments");var _i=Es,Is=Object.prototype,yd=Is.hasOwnProperty,vd=Is.propertyIsEnumerable,_d=_i((function(){return arguments})())?_i:function(t){return Ue(t)&&yd.call(t,"callee")&&!vd.call(t,"callee")},Bs=_d;function Cs(){return!1}l(Cs,"stubFalse");var Td=Cs,As=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ti=As&&typeof module=="object"&&module&&!module.nodeType&&module,bd=Ti&&Ti.exports===As,bi=bd?Pe.Buffer:void 0,wd=bi?bi.isBuffer:void 0,xd=wd||Td,rr=xd,Pd="[object Arguments]",kd="[object Array]",Sd="[object Boolean]",Od="[object Date]",Ed="[object Error]",Id="[object Function]",Bd="[object Map]",Cd="[object Number]",Ad="[object Object]",Zd="[object RegExp]",Rd="[object Set]",Nd="[object String]",Dd="[object WeakMap]",Hd="[object ArrayBuffer]",Md="[object DataView]",jd="[object Float32Array]",$d="[object Float64Array]",Ud="[object Int8Array]",zd="[object Int16Array]",Kd="[object Int32Array]",Wd="[object Uint8Array]",Ld="[object Uint8ClampedArray]",Fd="[object Uint16Array]",qd="[object Uint32Array]",C={};C[jd]=C[$d]=C[Ud]=C[zd]=C[Kd]=C[Wd]=C[Ld]=C[Fd]=C[qd]=!0;C[Pd]=C[kd]=C[Hd]=C[Sd]=C[Md]=C[Od]=C[Ed]=C[Id]=C[Bd]=C[Cd]=C[Ad]=C[Zd]=C[Rd]=C[Nd]=C[Dd]=!1;function Zs(t){return Ue(t)&&Tr(t.length)&&!!C[Ke(t)]}l(Zs,"baseIsTypedArray");var Vd=Zs;function Rs(t){return function(e){return t(e)}}l(Rs,"baseUnary");var Gd=Rs,Ns=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Et=Ns&&typeof module=="object"&&module&&!module.nodeType&&module,Jd=Et&&Et.exports===Ns,Ln=Jd&&Qi.process,Yd=(function(){try{var t=Et&&Et.require&&Et.require("util").types;return t||Ln&&Ln.binding&&Ln.binding("util")}catch{}})(),wi=Yd,xi=wi&&wi.isTypedArray,Xd=xi?Gd(xi):Vd,Ds=Xd,Qd=Object.prototype,ep=Qd.hasOwnProperty;function Hs(t,e){var n=be(t),r=!n&&Bs(t),i=!n&&!r&&rr(t),s=!n&&!r&&!i&&Ds(t),a=n||r||i||s,o=a?md(t.length,String):[],u=o.length;for(var d in t)(e||ep.call(t,d))&&!(a&&(d=="length"||i&&(d=="offset"||d=="parent")||s&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||vr(d,u)))&&o.push(d);return o}l(Hs,"arrayLikeKeys");var Ms=Hs;function js(t,e){return function(n){return t(e(n))}}l(js,"overArg");var $s=js,tp=$s(Object.keys,Object),np=tp,rp=Object.prototype,ip=rp.hasOwnProperty;function Us(t){if(!Ss(t))return np(t);var e=[];for(var n in Object(t))ip.call(t,n)&&n!="constructor"&&e.push(n);return e}l(Us,"baseKeys");var sp=Us;function zs(t){return Ps(t)?Ms(t):sp(t)}l(zs,"keys");var br=zs;function Ks(t){var e=[];if(t!=null)for(var n in Object(t))e.push(n);return e}l(Ks,"nativeKeysIn");var ap=Ks,op=Object.prototype,lp=op.hasOwnProperty;function Ws(t){if(!st(t))return ap(t);var e=Ss(t),n=[];for(var r in t)r=="constructor"&&(e||!lp.call(t,r))||n.push(r);return n}l(Ws,"baseKeysIn");var up=Ws;function Ls(t){return Ps(t)?Ms(t,!0):up(t)}l(Ls,"keysIn");var cp=Ls,dp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,pp=/^\w*$/;function Fs(t,e){if(be(t))return!1;var n=typeof t;return n=="number"||n=="symbol"||n=="boolean"||t==null||hr(t)?!0:pp.test(t)||!dp.test(t)||e!=null&&t in Object(e)}l(Fs,"isKey");var wr=Fs,fp=Le(Object,"create"),Ct=fp;function qs(){this.__data__=Ct?Ct(null):{},this.size=0}l(qs,"hashClear");var gp=qs;function Vs(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}l(Vs,"hashDelete");var mp=Vs,hp="__lodash_hash_undefined__",yp=Object.prototype,vp=yp.hasOwnProperty;function Gs(t){var e=this.__data__;if(Ct){var n=e[t];return n===hp?void 0:n}return vp.call(e,t)?e[t]:void 0}l(Gs,"hashGet");var _p=Gs,Tp=Object.prototype,bp=Tp.hasOwnProperty;function Js(t){var e=this.__data__;return Ct?e[t]!==void 0:bp.call(e,t)}l(Js,"hashHas");var wp=Js,xp="__lodash_hash_undefined__";function Ys(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=Ct&&e===void 0?xp:e,this}l(Ys,"hashSet");var Pp=Ys;function Fe(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}l(Fe,"Hash");Fe.prototype.clear=gp;Fe.prototype.delete=mp;Fe.prototype.get=_p;Fe.prototype.has=wp;Fe.prototype.set=Pp;var Pi=Fe;function Xs(){this.__data__=[],this.size=0}l(Xs,"listCacheClear");var kp=Xs;function Qs(t,e){for(var n=t.length;n--;)if(_r(t[n][0],e))return n;return-1}l(Qs,"assocIndexOf");var cn=Qs,Sp=Array.prototype,Op=Sp.splice;function ea(t){var e=this.__data__,n=cn(e,t);if(n<0)return!1;var r=e.length-1;return n==r?e.pop():Op.call(e,n,1),--this.size,!0}l(ea,"listCacheDelete");var Ep=ea;function ta(t){var e=this.__data__,n=cn(e,t);return n<0?void 0:e[n][1]}l(ta,"listCacheGet");var Ip=ta;function na(t){return cn(this.__data__,t)>-1}l(na,"listCacheHas");var Bp=na;function ra(t,e){var n=this.__data__,r=cn(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}l(ra,"listCacheSet");var Cp=ra;function qe(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}l(qe,"ListCache");qe.prototype.clear=kp;qe.prototype.delete=Ep;qe.prototype.get=Ip;qe.prototype.has=Bp;qe.prototype.set=Cp;var dn=qe,Ap=Le(Pe,"Map"),At=Ap;function ia(){this.size=0,this.__data__={hash:new Pi,map:new(At||dn),string:new Pi}}l(ia,"mapCacheClear");var Zp=ia;function sa(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}l(sa,"isKeyable");var Rp=sa;function aa(t,e){var n=t.__data__;return Rp(e)?n[typeof e=="string"?"string":"hash"]:n.map}l(aa,"getMapData");var pn=aa;function oa(t){var e=pn(this,t).delete(t);return this.size-=e?1:0,e}l(oa,"mapCacheDelete");var Np=oa;function la(t){return pn(this,t).get(t)}l(la,"mapCacheGet");var Dp=la;function ua(t){return pn(this,t).has(t)}l(ua,"mapCacheHas");var Hp=ua;function ca(t,e){var n=pn(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this}l(ca,"mapCacheSet");var Mp=ca;function Ve(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}l(Ve,"MapCache");Ve.prototype.clear=Zp;Ve.prototype.delete=Np;Ve.prototype.get=Dp;Ve.prototype.has=Hp;Ve.prototype.set=Mp;var fn=Ve,jp="Expected a function";function gn(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(jp);var n=l(function(){var r=arguments,i=e?e.apply(this,r):r[0],s=n.cache;if(s.has(i))return s.get(i);var a=t.apply(this,r);return n.cache=s.set(i,a)||s,a},"memoized");return n.cache=new(gn.Cache||fn),n}l(gn,"memoize");gn.Cache=fn;var $p=gn,Up=500;function da(t){var e=$p(t,function(r){return n.size===Up&&n.clear(),r}),n=e.cache;return e}l(da,"memoizeCapped");var zp=da,Kp=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Wp=/\\(\\)?/g,Lp=zp(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(Kp,function(n,r,i,s){e.push(i?s.replace(Wp,"$1"):r||n)}),e}),Fp=Lp;function pa(t){return t==null?"":Uc(t)}l(pa,"toString");var qp=pa;function fa(t,e){return be(t)?t:wr(t,e)?[t]:Fp(qp(t))}l(fa,"castPath");var mn=fa,Vp=1/0;function ga(t){if(typeof t=="string"||hr(t))return t;var e=t+"";return e=="0"&&1/t==-Vp?"-0":e}l(ga,"toKey");var jt=ga;function ma(t,e){e=mn(e,t);for(var n=0,r=e.length;t!=null&&n<r;)t=t[jt(e[n++])];return n&&n==r?t:void 0}l(ma,"baseGet");var xr=ma;function ha(t,e,n){var r=t==null?void 0:xr(t,e);return r===void 0?n:r}l(ha,"get");var Gp=ha;function ya(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t}l(ya,"arrayPush");var va=ya,Jp=$s(Object.getPrototypeOf,Object),_a=Jp,Yp="[object Object]",Xp=Function.prototype,Qp=Object.prototype,Ta=Xp.toString,ef=Qp.hasOwnProperty,tf=Ta.call(Object);function ba(t){if(!Ue(t)||Ke(t)!=Yp)return!1;var e=_a(t);if(e===null)return!0;var n=ef.call(e,"constructor")&&e.constructor;return typeof n=="function"&&n instanceof n&&Ta.call(n)==tf}l(ba,"isPlainObject");var nf=ba;function wa(){this.__data__=new dn,this.size=0}l(wa,"stackClear");var rf=wa;function xa(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}l(xa,"stackDelete");var sf=xa;function Pa(t){return this.__data__.get(t)}l(Pa,"stackGet");var af=Pa;function ka(t){return this.__data__.has(t)}l(ka,"stackHas");var of=ka,lf=200;function Sa(t,e){var n=this.__data__;if(n instanceof dn){var r=n.__data__;if(!At||r.length<lf-1)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new fn(r)}return n.set(t,e),this.size=n.size,this}l(Sa,"stackSet");var uf=Sa;function Ge(t){var e=this.__data__=new dn(t);this.size=e.size}l(Ge,"Stack");Ge.prototype.clear=rf;Ge.prototype.delete=sf;Ge.prototype.get=af;Ge.prototype.has=of;Ge.prototype.set=uf;var qt=Ge;function Oa(t,e){for(var n=-1,r=t==null?0:t.length,i=0,s=[];++n<r;){var a=t[n];e(a,n,t)&&(s[i++]=a)}return s}l(Oa,"arrayFilter");var cf=Oa;function Ea(){return[]}l(Ea,"stubArray");var Ia=Ea,df=Object.prototype,pf=df.propertyIsEnumerable,ki=Object.getOwnPropertySymbols,ff=ki?function(t){return t==null?[]:(t=Object(t),cf(ki(t),function(e){return pf.call(t,e)}))}:Ia,Ba=ff,gf=Object.getOwnPropertySymbols,mf=gf?function(t){for(var e=[];t;)va(e,Ba(t)),t=_a(t);return e}:Ia,hf=mf;function Ca(t,e,n){var r=e(t);return be(t)?r:va(r,n(t))}l(Ca,"baseGetAllKeys");var Aa=Ca;function Za(t){return Aa(t,br,Ba)}l(Za,"getAllKeys");var Si=Za;function Ra(t){return Aa(t,cp,hf)}l(Ra,"getAllKeysIn");var yf=Ra,vf=Le(Pe,"DataView"),ir=vf,_f=Le(Pe,"Promise"),sr=_f,Tf=Le(Pe,"Set"),ar=Tf,Oi="[object Map]",bf="[object Object]",Ei="[object Promise]",Ii="[object Set]",Bi="[object WeakMap]",Ci="[object DataView]",wf=We(ir),xf=We(At),Pf=We(sr),kf=We(ar),Sf=We(nr),Re=Ke;(ir&&Re(new ir(new ArrayBuffer(1)))!=Ci||At&&Re(new At)!=Oi||sr&&Re(sr.resolve())!=Ei||ar&&Re(new ar)!=Ii||nr&&Re(new nr)!=Bi)&&(Re=l(function(t){var e=Ke(t),n=e==bf?t.constructor:void 0,r=n?We(n):"";if(r)switch(r){case wf:return Ci;case xf:return Oi;case Pf:return Ei;case kf:return Ii;case Sf:return Bi}return e},"getTag"));var Ai=Re,Of=Pe.Uint8Array,Zi=Of,Ef="__lodash_hash_undefined__";function Na(t){return this.__data__.set(t,Ef),this}l(Na,"setCacheAdd");var If=Na;function Da(t){return this.__data__.has(t)}l(Da,"setCacheHas");var Bf=Da;function Zt(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new fn;++e<n;)this.add(t[e])}l(Zt,"SetCache");Zt.prototype.add=Zt.prototype.push=If;Zt.prototype.has=Bf;var Cf=Zt;function Ha(t,e){for(var n=-1,r=t==null?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}l(Ha,"arraySome");var Af=Ha;function Ma(t,e){return t.has(e)}l(Ma,"cacheHas");var Zf=Ma,Rf=1,Nf=2;function ja(t,e,n,r,i,s){var a=n&Rf,o=t.length,u=e.length;if(o!=u&&!(a&&u>o))return!1;var d=s.get(t),p=s.get(e);if(d&&p)return d==e&&p==t;var g=-1,h=!0,w=n&Nf?new Cf:void 0;for(s.set(t,e),s.set(e,t);++g<o;){var T=t[g],D=e[g];if(r)var F=a?r(D,T,g,e,t,s):r(T,D,g,t,e,s);if(F!==void 0){if(F)continue;h=!1;break}if(w){if(!Af(e,function(J,ae){if(!Zf(w,ae)&&(T===J||i(T,J,n,r,s)))return w.push(ae)})){h=!1;break}}else if(!(T===D||i(T,D,n,r,s))){h=!1;break}}return s.delete(t),s.delete(e),h}l(ja,"equalArrays");var $a=ja;function Ua(t){var e=-1,n=Array(t.size);return t.forEach(function(r,i){n[++e]=[i,r]}),n}l(Ua,"mapToArray");var Df=Ua;function za(t){var e=-1,n=Array(t.size);return t.forEach(function(r){n[++e]=r}),n}l(za,"setToArray");var Hf=za,Mf=1,jf=2,$f="[object Boolean]",Uf="[object Date]",zf="[object Error]",Kf="[object Map]",Wf="[object Number]",Lf="[object RegExp]",Ff="[object Set]",qf="[object String]",Vf="[object Symbol]",Gf="[object ArrayBuffer]",Jf="[object DataView]",Ri=Ie?Ie.prototype:void 0,Fn=Ri?Ri.valueOf:void 0;function Ka(t,e,n,r,i,s,a){switch(n){case Jf:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case Gf:return!(t.byteLength!=e.byteLength||!s(new Zi(t),new Zi(e)));case $f:case Uf:case Wf:return _r(+t,+e);case zf:return t.name==e.name&&t.message==e.message;case Lf:case qf:return t==e+"";case Kf:var o=Df;case Ff:var u=r&Mf;if(o||(o=Hf),t.size!=e.size&&!u)return!1;var d=a.get(t);if(d)return d==e;r|=jf,a.set(t,e);var p=$a(o(t),o(e),r,i,s,a);return a.delete(t),p;case Vf:if(Fn)return Fn.call(t)==Fn.call(e)}return!1}l(Ka,"equalByTag");var Yf=Ka,Xf=1,Qf=Object.prototype,eg=Qf.hasOwnProperty;function Wa(t,e,n,r,i,s){var a=n&Xf,o=Si(t),u=o.length,d=Si(e),p=d.length;if(u!=p&&!a)return!1;for(var g=u;g--;){var h=o[g];if(!(a?h in e:eg.call(e,h)))return!1}var w=s.get(t),T=s.get(e);if(w&&T)return w==e&&T==t;var D=!0;s.set(t,e),s.set(e,t);for(var F=a;++g<u;){h=o[g];var J=t[h],ae=e[h];if(r)var oe=a?r(ae,J,h,e,t,s):r(J,ae,h,t,e,s);if(!(oe===void 0?J===ae||i(J,ae,n,r,s):oe)){D=!1;break}F||(F=h=="constructor")}if(D&&!F){var H=t.constructor,Oe=e.constructor;H!=Oe&&"constructor"in t&&"constructor"in e&&!(typeof H=="function"&&H instanceof H&&typeof Oe=="function"&&Oe instanceof Oe)&&(D=!1)}return s.delete(t),s.delete(e),D}l(Wa,"equalObjects");var tg=Wa,ng=1,Ni="[object Arguments]",Di="[object Array]",Lt="[object Object]",rg=Object.prototype,Hi=rg.hasOwnProperty;function La(t,e,n,r,i,s){var a=be(t),o=be(e),u=a?Di:Ai(t),d=o?Di:Ai(e);u=u==Ni?Lt:u,d=d==Ni?Lt:d;var p=u==Lt,g=d==Lt,h=u==d;if(h&&rr(t)){if(!rr(e))return!1;a=!0,p=!1}if(h&&!p)return s||(s=new qt),a||Ds(t)?$a(t,e,n,r,i,s):Yf(t,e,u,n,r,i,s);if(!(n&ng)){var w=p&&Hi.call(t,"__wrapped__"),T=g&&Hi.call(e,"__wrapped__");if(w||T){var D=w?t.value():t,F=T?e.value():e;return s||(s=new qt),i(D,F,n,r,s)}}return h?(s||(s=new qt),tg(t,e,n,r,i,s)):!1}l(La,"baseIsEqualDeep");var ig=La;function Pr(t,e,n,r,i){return t===e?!0:t==null||e==null||!Ue(t)&&!Ue(e)?t!==t&&e!==e:ig(t,e,n,r,Pr,i)}l(Pr,"baseIsEqual");var hn=Pr,sg=1,ag=2;function Fa(t,e,n,r){var i=n.length,s=i,a=!r;if(t==null)return!s;for(t=Object(t);i--;){var o=n[i];if(a&&o[2]?o[1]!==t[o[0]]:!(o[0]in t))return!1}for(;++i<s;){o=n[i];var u=o[0],d=t[u],p=o[1];if(a&&o[2]){if(d===void 0&&!(u in t))return!1}else{var g=new qt;if(r)var h=r(d,p,u,t,e,g);if(!(h===void 0?hn(p,d,sg|ag,r,g):h))return!1}}return!0}l(Fa,"baseIsMatch");var og=Fa;function qa(t){return t===t&&!st(t)}l(qa,"isStrictComparable");var Va=qa;function Ga(t){for(var e=br(t),n=e.length;n--;){var r=e[n],i=t[r];e[n]=[r,i,Va(i)]}return e}l(Ga,"getMatchData");var lg=Ga;function Ja(t,e){return function(n){return n==null?!1:n[t]===e&&(e!==void 0||t in Object(n))}}l(Ja,"matchesStrictComparable");var Ya=Ja;function Xa(t){var e=lg(t);return e.length==1&&e[0][2]?Ya(e[0][0],e[0][1]):function(n){return n===t||og(n,t,e)}}l(Xa,"baseMatches");var ug=Xa;function Qa(t,e){return t!=null&&e in Object(t)}l(Qa,"baseHasIn");var cg=Qa;function eo(t,e,n){e=mn(e,t);for(var r=-1,i=e.length,s=!1;++r<i;){var a=jt(e[r]);if(!(s=t!=null&&n(t,a)))break;t=t[a]}return s||++r!=i?s:(i=t==null?0:t.length,!!i&&Tr(i)&&vr(a,i)&&(be(t)||Bs(t)))}l(eo,"hasPath");var dg=eo;function to(t,e){return t!=null&&dg(t,e,cg)}l(to,"hasIn");var pg=to,fg=1,gg=2;function no(t,e){return wr(t)&&Va(e)?Ya(jt(t),e):function(n){var r=Gp(n,t);return r===void 0&&r===e?pg(n,t):hn(e,r,fg|gg)}}l(no,"baseMatchesProperty");var mg=no;function ro(t){return function(e){return e?.[t]}}l(ro,"baseProperty");var hg=ro;function io(t){return function(e){return xr(e,t)}}l(io,"basePropertyDeep");var yg=io;function so(t){return wr(t)?hg(jt(t)):yg(t)}l(so,"property");var vg=so;function ao(t){return typeof t=="function"?t:t==null?zc:typeof t=="object"?be(t)?mg(t[0],t[1]):ug(t):vg(t)}l(ao,"baseIteratee");var kr=ao;function oo(t){return function(e,n,r){for(var i=-1,s=Object(e),a=r(e),o=a.length;o--;){var u=a[t?o:++i];if(n(s[u],u,s)===!1)break}return e}}l(oo,"createBaseFor");var _g=oo,Tg=_g(),bg=Tg;function lo(t,e){return t&&bg(t,e,br)}l(lo,"baseForOwn");var wg=lo;function uo(t,e){return hn(t,e)}l(uo,"isEqual");var Ee=uo;function co(t,e,n){n=typeof n=="function"?n:void 0;var r=n?n(t,e):void 0;return r===void 0?hn(t,e,void 0,n):!!r}l(co,"isEqualWith");var xg=co;function po(t){return t===void 0}l(po,"isUndefined");var Mi=po;function fo(t,e){var n={};return e=kr(e,3),wg(t,function(r,i,s){_s(n,i,e(r,i,s))}),n}l(fo,"mapValues");var Pg=fo,kg="Expected a function";function go(t){if(typeof t!="function")throw new TypeError(kg);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}l(go,"negate");var Sg=go;function mo(t,e,n,r){if(!st(t))return t;e=mn(e,t);for(var i=-1,s=e.length,a=s-1,o=t;o!=null&&++i<s;){var u=jt(e[i]),d=n;if(u==="__proto__"||u==="constructor"||u==="prototype")return t;if(i!=a){var p=o[u];d=r?r(p,u,o):void 0,d===void 0&&(d=st(p)?p:vr(e[i+1])?[]:{})}pd(o,u,d),o=o[u]}return t}l(mo,"baseSet");var Og=mo;function ho(t,e,n){for(var r=-1,i=e.length,s={};++r<i;){var a=e[r],o=xr(t,a);n(o,a)&&Og(s,mn(a,t),o)}return s}l(ho,"basePickBy");var Eg=ho;function yo(t,e){if(t==null)return{};var n=os(yf(t),function(r){return[r]});return e=kr(e),Eg(t,n,function(r,i){return e(r,i[0])})}l(yo,"pickBy");var Ig=yo;function vo(t,e){return Ig(t,Sg(kr(e)))}l(vo,"omitBy");var ji=vo,_o=l((t,e)=>To(t,e,new WeakSet),"isEqual"),$i=l(t=>nf(t),"_isPlainObject"),To=l((t,e,n)=>xg(t,e,Bg(n)),"_isEqualWithVisitedTracking"),Bg=l(t=>(e,n)=>{if($i(e)&&!t.has(e)&&$i(n)&&!t.has(n)){let r=ji(e,Mi),i=ji(n,Mi);return t.add(r).add(i).add(e).add(n),To(r,i,t)}},"_customizerWithVisitedTracking"),Cg=l(t=>Array.from(new Set(t)),"unique"),Ag={compare:_o},bo=class{constructor(e=[],n={}){this._options=c(c({},Ag),n),this._items=[];for(let r of e)this.add(r)}get items(){return[...this._items]}get size(){return this._items.length}has(e){return this._items.some(n=>this._options.compare(n,e))}add(e){this.has(e)||this._items.push(e)}isEqual(e){return this.size!==e.size?!1:this.isSubsetOf(e)&&e.isSubsetOf(this)}isSubsetOf(e){return this.size>e.size?!1:this._items.every(n=>e.has(n))}};l(bo,"CustomSet");var Zg=bo,_={};ce(_,{errToObj:()=>Rg,toString:()=>Ng});var Rg=l(t=>typeof t=="string"?{message:t}:t||{},"errToObj"),Ng=l(t=>typeof t=="string"?t:t?.message,"toString"),ue={};ce(ue,{assertNever:()=>wo});function wo(t){throw new Error("assertNever called")}l(wo,"assertNever");var le={};ce(le,{compareFunctions:()=>Hg,joinValues:()=>xo,jsonStringifyReplacer:()=>Dg});function xo(t,e=" | "){return t.map(n=>typeof n=="string"?`'${n}'`:n).join(e)}l(xo,"joinValues");var Dg=l((t,e)=>typeof e=="bigint"?e.toString():e,"jsonStringifyReplacer"),Hg=l((t,e)=>t.toString()===e.toString(),"compareFunctions"),Po={};ce(Po,{extractPrecisionAndOffset:()=>So,generateDatetimeRegex:()=>ko});var ko=l(t=>{let e=t.precision?or+t.precision+jg:t.precision===0?"":Io,n=t.offset?Eo:Mg;return new RegExp(`^${Oo}${e}${n}$`)},"generateDatetimeRegex"),So=l(t=>({precision:$g(t),offset:t.endsWith(`${Eo}$`)}),"extractPrecisionAndOffset"),Oo="\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}",Eo="(([+-]\\d{2}(:?\\d{2})?)|Z)",Mg="Z",Io="(\\.\\d+)?",or="\\.\\d{",jg="}",$g=l(t=>{let e=t.slice(1+Oo.length);return e.startsWith(Io)?null:e.startsWith(or)?parseInt(e.slice(or.length)):0},"_extractPrecision"),rn=l((t,e)=>{let n;switch(t.code){case"invalid_type":t.received==="undefined"?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case"invalid_literal":n=`Invalid literal value, expected ${JSON.stringify(t.expected,le.jsonStringifyReplacer)}`;break;case"unrecognized_keys":n=`Unrecognized key(s) in object: ${le.joinValues(t.keys,", ")}`;break;case"invalid_union":n="Invalid input";break;case"invalid_union_discriminator":n=`Invalid discriminator value. Expected ${le.joinValues(t.options)}`;break;case"invalid_enum_value":n=`Invalid enum value. Expected ${le.joinValues(t.options)}, received '${t.received}'`;break;case"invalid_arguments":n="Invalid function arguments";break;case"invalid_return_type":n="Invalid function return type";break;case"invalid_date":n="Invalid date";break;case"invalid_string":typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:ue.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case"too_small":t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case"too_big":t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case"custom":n="Invalid input";break;case"invalid_intersection_types":n="Intersection results could not be merged";break;case"not_multiple_of":n=`Number must be a multiple of ${t.multipleOf}`;break;case"not_finite":n="Number must be finite";break;case"unresolved_reference":n="Unresolved reference";break;default:n=e.defaultError,ue.assertNever(t)}return{message:n}},"errorMap"),sn=class Bo extends Error{constructor(e){super(),this.__type__="ZuiError",this.issues=[],this.addIssue=l(r=>{this.issues=[...this.issues,r]},"addIssue"),this.addIssues=l((r=[])=>{this.issues=[...this.issues,...r]},"addIssues");let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let n=e||function(s){return s.message},r={_errors:[]},i=l(s=>{for(let a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let o=r,u=0;for(;u<a.path.length;){let d=a.path[u];u===a.path.length-1?(o[d]=o[d]||{_errors:[]},o[d]._errors.push(n(a))):o[d]=o[d]||{_errors:[]},o=o[d],u++}}},"processError");return i(this),r}static assert(e){if(!(e instanceof Bo))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,le.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}};l(sn,"ZodError");sn.create=l(t=>new sn(t),"create");var Te=sn,Ug=rn;function an(){return Ug}l(an,"getErrorMap");var A={};function Co(t){Object.assign(A,t)}l(Co,"setBuilders");var lr=l(t=>{var e;let{data:n,path:r,errorMaps:i,issueData:s}=t,a=[...r,...s.path||[]],o=f(c({},s),{path:a}),u="",d=i.filter(p=>!!p).slice().reverse();for(let p of d)u=p(o,{data:n,defaultError:u}).message;return f(c({},s),{path:a,message:(e=s.message)!=null?e:u})},"makeIssue");function m(t,e){let n=lr({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,an(),rn].filter(r=>!!r)});t.common.issues.push(n)}l(m,"addIssueToContext");var Ao=class Zo{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let i of n){if(i.status==="aborted")return{status:"aborted"};i.status==="dirty"&&e.dirty(),r.push(i.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let i of n)r.push({key:await i.key,value:await i.value});return Zo.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let i of n){let{key:s,value:a}=i;if(s.status==="aborted")return{status:"aborted"};if(a.status==="aborted")return{status:"aborted"};s.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(r[s.value]=a.value)}return{status:e.value,value:r}}};l(Ao,"ParseStatus");var te=Ao,on=l(t=>typeof Promise<"u"&&t instanceof Promise,"isAsync"),Me=l(t=>{switch(typeof t){case"undefined":return"undefined";case"string":return"string";case"number":return isNaN(t)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(t)?"array":t===null?"null":typeof Promise<"u"&&t instanceof Promise||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"),Ro=class{constructor(e,n,r,i){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};l(Ro,"ParseInputLazyPath");var fe=Ro,No=class extends Error{constructor(e){super(`Cannot access property ${e} before initialization. You're probably importing ZUI incorrectly. If not, reach out to the maintainers.`)}};l(No,"_CircularDependencyError");var qn=No,Do=class{constructor(e){this.__type__="ZuiType",this.spa=this.safeParseAsync,this._handleResult=l((n,r)=>{if(r.status==="valid")return{success:!0,data:r.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let i=new Te(n.common.issues);return this._error=i,this._error}}},"_handleResult"),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.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),this.downstream=this.downstream.bind(this)}get description(){return this._metadataRoot._def.description}get typeName(){return this._def.typeName}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,n){return n||{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 te,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 n=this._parse(e);if(on(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){var r;let i={common:{issues:[],async:(r=n?.async)!=null?r:!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Me(e)},s=this._parseSync({data:e,path:i.path,parent:i});return this._handleResult(i,s)}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Me(e)},i=this._parse({data:e,path:r.path,parent:r}),s=await(on(i)?i:Promise.resolve(i));return this._handleResult(r,s)}refine(e,n){let r=l(i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n,"getIssueProperties");return A.downstream(this,i=>{let s=e(i),a=[],o=l(()=>a.push(c({code:"custom"},r(i))),"setError");return typeof Promise<"u"&&s instanceof Promise?s.then(u=>u?{status:"valid",value:i}:(o(),{status:"dirty",value:i,issues:a})):s?{status:"valid",value:i}:(o(),{status:"dirty",value:i,issues:a})})}superRefine(e){return A.downstream(this,(n,r)=>{let i=[],s=e(n,{addIssue:a=>i.push(a),path:r.path});return typeof Promise<"u"&&s instanceof Promise?s.then(()=>i.some(a=>a.fatal)?{status:"aborted",issues:i}:i.length?{status:"dirty",value:n,issues:i}:{status:"valid",value:n}):i.some(a=>a.fatal)?{status:"aborted",issues:i}:i.length?{status:"dirty",value:n,issues:i}:{status:"valid",value:n}})}downstream(e,n){return A.downstream(this,e,n)}optional(){return A.optional(this,this._def)}nullable(){return A.nullable(this,this._def)}nullish(){return this.nullable().optional()}array(){return A.array(this,this._def)}promise(){return A.promise(this,this._def)}mandatory(){return this}or(e){return A.union([this,e])}and(e){return A.intersection(this,e)}transform(e){return A.downstream(this,(n,r)=>{let i=[],s=e(n,{addIssue:a=>i.push(a),path:r.path});return s instanceof Promise?s.then(a=>i.some(o=>o.fatal)?{status:"aborted",issues:i}:i.length?{status:"dirty",value:a,issues:i}:{status:"valid",value:a}):i.some(a=>a.fatal)?{status:"aborted",issues:i}:i.length?{status:"dirty",value:s,issues:i}:{status:"valid",value:s}},{failFast:!0})}default(e){let n=typeof e=="function"?e:()=>e;return A.default(this,n)}brand(){return A.branded(this)}catch(e){return A.catch(this,e)}describe(e){let n=this.clone();return n._metadataRoot._def.description=e,n}pipe(e){return A.pipeline(this,e)}readonly(){return A.readonly(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}metadata(e){var n,r,i;let s=this.clone(),a=s._metadataRoot;(i=(n=a._def)[r=B])!=null||(n[r]={});for(let[o,u]of Object.entries(e))a._def[B]=f(c({},a._def[B]),{[o]:u});return s}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 n;return e===void 0?n=!0:typeof e=="function"?n=e.toString():n=e,this.metadata({hidden:n})}disabled(e){let n;return e===void 0?n=!0:typeof e=="function"?n=e.toString():n=e,this.metadata({disabled:n})}placeholder(e){return this.metadata({placeholder:e})}toJSONSchema(e){throw new qn("toJSONSchema")}toTypescriptType(e){throw new qn("toTypescriptType")}toTypescriptSchema(){throw new qn("toTypescriptSchema")}naked(){return this}};l(Do,"ZodBaseTypeImpl");var P=Do,Ho=class Mo extends P{constructor(){super(...arguments),this._any=!0}_parse(e){return{status:"valid",value:e.data}}isEqual(e){return e instanceof Mo}};l(Ho,"ZodAnyImpl");var zg=Ho,jo=class Ne extends P{dereference(e){return new Ne(f(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new Ne(f(c({},this._def),{type:this._def.type.clone()}))}isEqual(e){var n,r,i,s,a,o;return e instanceof Ne?Ee((n=this._def.exactLength)==null?void 0:n.value,(r=e._def.exactLength)==null?void 0:r.value)&&Ee((i=this._def.maxLength)==null?void 0:i.value,(s=e._def.maxLength)==null?void 0:s.value)&&Ee((a=this._def.minLength)==null?void 0:a.value,(o=e._def.minLength)==null?void 0:o.value)&&this._def.type.isEqual(e._def.type):!1}_parse(e){let{ctx:n,status:r}=this._processInputParams(e),i=this._def;if(n.parsedType!=="array")return m(n,{code:"invalid_type",expected:"array",received:n.parsedType}),{status:"aborted"};if(i.exactLength!==null){let a=n.data.length>i.exactLength.value,o=n.data.length<i.exactLength.value;(a||o)&&(m(n,{code:a?"too_big":"too_small",minimum:o?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(m(n,{code:"too_small",minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(m(n,{code:"too_big",maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((a,o)=>i.type._parseAsync(new fe(n,a,n.path,o)))).then(a=>te.mergeArray(r,a));let s=[...n.data].map((a,o)=>i.type._parseSync(new fe(n,a,n.path,o)));return te.mergeArray(r,s)}get element(){return this._def.type}min(e,n){return new Ne(f(c({},this._def),{minLength:{value:e,message:_.toString(n)}}))}max(e,n){return new Ne(f(c({},this._def),{maxLength:{value:e,message:_.toString(n)}}))}length(e,n){return new Ne(f(c({},this._def),{exactLength:{value:e,message:_.toString(n)}}))}nonempty(e){return this.min(1,e)}};l(jo,"ZodArrayImpl");var Kg=jo,$o=class Vt extends P{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!=="bigint"){let s=this._getOrReturnCtx(e);return m(s,{code:"invalid_type",expected:"bigint",received:s.parsedType}),{status:"aborted"}}let r,i=new te;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:"too_small",type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:"too_big",type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),m(r,{code:"not_multiple_of",multipleOf:s.value,message:s.message}),i.dirty()):ue.assertNever(s);return{status:i.value,value:e.data}}isEqual(e){if(!(e instanceof Vt)||this._def.coerce!==e._def.coerce)return!1;let n=new $.CustomSet(this._def.checks),r=new $.CustomSet(e._def.checks);return n.isEqual(r)}gte(e,n){return this.setLimit("min",e,!0,_.toString(n))}gt(e,n){return this.setLimit("min",e,!1,_.toString(n))}lte(e,n){return this.setLimit("max",e,!0,_.toString(n))}lt(e,n){return this.setLimit("max",e,!1,_.toString(n))}setLimit(e,n,r,i){return new Vt(f(c({},this._def),{checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:_.toString(i)}]}))}_addCheck(e){return new Vt(f(c({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:_.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};l($o,"ZodBigIntImpl");var Wg=$o,Uo=class zo extends P{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!=="boolean"){let r=this._getOrReturnCtx(e);return m(r,{code:"invalid_type",expected:"boolean",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof zo?this._def.coerce===e._def.coerce:!1}};l(Uo,"ZodBooleanImpl");var Lg=Uo,Ko=class ht extends P{dereference(e){return new ht(f(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new ht(f(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}isEqual(e){return e instanceof ht?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}mandatory(){return new ht(f(c({},this._def),{type:this._def.type.mandatory()}))}};l(Ko,"ZodBrandedImpl");var Fg=Ko,Wo=class yt extends P{_parse(e){let{ctx:n}=this._processInputParams(e),r=f(c({},n),{common:f(c({},n.common),{issues:[]})}),i=this._def.innerType._parse({data:r.data,path:r.path,parent:c({},r)});return on(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Te(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Te(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}isEqual(e){return e instanceof yt?this._def.innerType.isEqual(e._def.innerType)&&le.compareFunctions(this._def.catchValue,e._def.catchValue):!1}dereference(e){return new yt(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new yt(f(c({},this._def),{innerType:this._def.innerType.clone()}))}naked(){return this._def.innerType.naked()}mandatory(){return new yt(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};l(Wo,"ZodCatchImpl");var qg=Wo,Lo=class ur extends P{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!=="date"){let s=this._getOrReturnCtx(e);return m(s,{code:"invalid_type",expected:"date",received:s.parsedType}),{status:"aborted"}}if(isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return m(s,{code:"invalid_date"}),{status:"aborted"}}let r=new te,i;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),m(i,{code:"too_small",message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),m(i,{code:"too_big",message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):ue.assertNever(s);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ur(f(c({},this._def),{checks:[...this._def.checks,e]}))}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:_.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:_.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}isEqual(e){if(!(e instanceof ur))return!1;let n=new $.CustomSet(this._def.checks),r=new $.CustomSet(e._def.checks);return n.isEqual(r)&&this._def.coerce===e._def.coerce}};l(Lo,"ZodDateImpl");var Vg=Lo,Fo=class vt extends P{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType==="undefined"&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}dereference(e){return new vt(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new vt(f(c({},this._def),{innerType:this._def.innerType.clone()}))}isEqual(e){return e instanceof vt?this._def.innerType.isEqual(e._def.innerType)&&Ee(this._def.defaultValue(),e._def.defaultValue()):!1}unwrap(){return this._def.innerType}naked(){return this._def.innerType.naked()}mandatory(){return new vt(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};l(Fo,"ZodDefaultImpl");var Gg=Fo,_e=l(t=>{let e=t;return e?e.typeName==="ZodLazy"?_e(e.schema):e.typeName==="ZodEffects"?_e(e.innerType()):e.typeName==="ZodLiteral"?[e.value]:e.typeName==="ZodEnum"?e.options:e.typeName==="ZodNativeEnum"?Object.values(e.enum):e.typeName==="ZodDefault"?_e(e._def.innerType):e.typeName==="ZodUndefined"?[void 0]:e.typeName==="ZodNull"?[null]:e.typeName==="ZodOptional"?[void 0,..._e(e.unwrap())]:e.typeName==="ZodNullable"?[null,..._e(e.unwrap())]:e.typeName==="ZodBranded"||e.typeName==="ZodReadonly"?_e(e.unwrap()):e.typeName==="ZodCatch"?_e(e._def.innerType):[]:[]},"getDiscriminator"),qo=class _t extends P{constructor(e){let n=_t._getOptionsMap(e.discriminator,e.options);super(f(c({},e),{optionsMap:n}))}dereference(e){let n=this.options.map(r=>r.dereference(e));return new _t(f(c({},this._def),{options:n}))}getReferences(){return ge.unique(this.options.flatMap(e=>e.getReferences()))}clone(){let e=this.options.map(n=>n.clone());return new _t(f(c({},this._def),{options:e}))}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!=="object")return m(n,{code:"invalid_type",expected:"object",received:n.parsedType}),{status:"aborted"};let r=this.discriminator,i=n.data[r],s=this.optionsMap.get(i);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(m(n,{code:"invalid_union_discriminator",options:Array.from(this.optionsMap.keys()),path:[r]}),{status:"aborted"})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static _getOptionsMap(e,n){let r=new Map;for(let i of n){let s=_e(i.shape[e]);if(!s.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of s){if(r.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);r.set(a,i)}}return r}isEqual(e){if(!(e instanceof _t)||this._def.discriminator!==e._def.discriminator)return!1;let n=l((s,a)=>s.isEqual(a),"compare"),r=new $.CustomSet(this._def.options,{compare:n}),i=new $.CustomSet(e._def.options,{compare:n});return r.isEqual(i)}};l(qo,"ZodDiscriminatedUnionImpl");var Jg=qo,Vo=class Go extends P{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return m(n,{expected:le.joinValues(r),received:n.parsedType,code:"invalid_type"}),{status:"aborted"}}if(this._def.values.indexOf(e.data)===-1){let n=this._getOrReturnCtx(e),r=this._def.values;return m(n,{received:n.data,code:"invalid_enum_value",options:r}),{status:"aborted"}}return{status:"valid",value:e.data}}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){return this.enum}get Enum(){return this.enum}extract(e,n=this._def){return A.enum(e,c(c({},this._def),n))}exclude(e,n=this._def){return A.enum(this.options.filter(r=>!e.includes(r)),c(c({},this._def),n))}isEqual(e){if(!(e instanceof Go))return!1;let n=new $.CustomSet(this._def.values),r=new $.CustomSet(e._def.values);return n.isEqual(r)}};l(Vo,"ZodEnumImpl");var Yg=Vo,Jo=class tt extends P{constructor(){super(...arguments),this.validate=this.implement}dereference(e){let n=this._def.args.dereference(e),r=this._def.returns.dereference(e);return new tt(f(c({},this._def),{args:n,returns:r}))}getReferences(){return ge.unique([...this._def.args.getReferences(),...this._def.returns.getReferences()])}clone(){return new tt(f(c({},this._def),{args:this._def.args.clone(),returns:this._def.returns.clone()}))}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!=="function")return m(n,{code:"invalid_type",expected:"function",received:n.parsedType}),{status:"aborted"};function r(d,p){return lr({data:d,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,an(),rn].filter(g=>!!g),issueData:{code:"invalid_arguments",argumentsError:p}})}l(r,"makeArgsIssue");function i(d,p){return lr({data:d,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,an(),rn].filter(g=>!!g),issueData:{code:"invalid_return_type",returnTypeError:p}})}l(i,"makeReturnsIssue");let s={errorMap:n.common.contextualErrorMap},a=n.data,o=this,u=this._def.returns;return K.zuiPromise(u)?{status:"valid",async value(...d){let p=new Te([]),g=await o._def.args.parseAsync(d,s).catch(T=>{throw p.addIssue(r(d,T)),p}),h=await Reflect.apply(a,this,g);return await u._def.type.parseAsync(h,s).catch(T=>{throw K.zuiError(T)?(p.addIssue(i(h,T)),p):T})}}:{status:"valid",value(...d){let p=o._def.args.safeParse(d,s);if(!p.success)throw new Te([r(d,p.error)]);let g=Reflect.apply(a,this,p.data),h=o._def.returns.safeParse(g,s);if(!h.success)throw new Te([i(g,h.error)]);return h.data}}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new tt(f(c({},this._def),{args:A.tuple(e).rest(A.unknown())}))}returns(e){return new tt(f(c({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}isEqual(e){return e instanceof tt&&this._def.args.isEqual(e._def.args)&&this._def.returns.isEqual(e._def.returns)}};l(Jo,"ZodFunctionImpl");var Xg=Jo,Yo=class Gt extends P{dereference(e){return new Gt(f(c({},this._def),{left:this._def.left.dereference(e),right:this._def.right.dereference(e)}))}getReferences(){return ge.unique([...this._def.left.getReferences(),...this._def.right.getReferences()])}clone(){return new Gt(f(c({},this._def),{left:this._def.left.clone(),right:this._def.right.clone()}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),i=l((s,a)=>{if(s.status==="aborted"||a.status==="aborted")return{status:"aborted"};let o=this._mergeValues(s.value,a.value);return o.valid?((s.status==="dirty"||a.status==="dirty")&&n.dirty(),{status:n.value,value:o.data}):(m(r,{code:"invalid_intersection_types"}),{status:"aborted"})},"handleParsed");return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,a])=>i(s,a)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}isEqual(e){if(!(e instanceof Gt))return!1;let n=l((s,a)=>s.isEqual(a),"compare"),r=new $.CustomSet([this._def.left,this._def.right],{compare:n}),i=new $.CustomSet([e._def.left,e._def.right],{compare:n});return r.isEqual(i)}_mergeValues(e,n){let r=Me(e),i=Me(n);if(e===n)return{valid:!0,data:e};if(r==="object"&&i==="object"){let s=Object.keys(n),a=Object.keys(e).filter(u=>s.indexOf(u)!==-1),o=c(c({},e),n);for(let u of a){let d=this._mergeValues(e[u],n[u]);if(!d.valid)return{valid:!1};o[u]=d.data}return{valid:!0,data:o}}else if(r==="array"&&i==="array"){if(e.length!==n.length)return{valid:!1};let s=[];for(let a=0;a<e.length;a++){let o=e[a],u=n[a],d=this._mergeValues(o,u);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return r==="date"&&i==="date"&&+e==+n?{valid:!0,data:e}:{valid:!1}}};l(Yo,"ZodIntersectionImpl");var Qg=Yo,Xo=class Tt extends P{get schema(){return this._def.getter()}dereference(e){return new Tt(f(c({},this._def),{getter:()=>this._def.getter().dereference(e)}))}getReferences(){return this._def.getter().getReferences()}clone(){return new Tt(f(c({},this._def),{getter:()=>this._def.getter().clone()}))}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}isEqual(e){return e instanceof Tt?this._def.getter().isEqual(e._def.getter()):!1}naked(){return this._def.getter().naked()}mandatory(){return new Tt(f(c({},this._def),{getter:()=>this._def.getter().mandatory()}))}};l(Xo,"ZodLazyImpl");var em=Xo,Qo=class el extends P{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return m(n,{received:n.data,code:"invalid_literal",expected:this._def.value}),{status:"aborted"}}return{status:"valid",value:e.data}}get value(){return this._def.value}isEqual(e){return e instanceof el?Ee(this._def.value,e._def.value):!1}};l(Qo,"ZodLiteralImpl");var tm=Qo,tl=class Jt extends P{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}dereference(e){let n=this._def.keyType.dereference(e),r=this._def.valueType.dereference(e);return new Jt(f(c({},this._def),{keyType:n,valueType:r}))}getReferences(){return ge.unique([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new Jt(f(c({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!=="map")return m(r,{code:"invalid_type",expected:"map",received:r.parsedType}),{status:"aborted"};let i=this._def.keyType,s=this._def.valueType,a=[...r.data.entries()].map(([o,u],d)=>({key:i._parse(new fe(r,o,r.path,[d,"key"])),value:s._parse(new fe(r,u,r.path,[d,"value"]))}));if(r.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let u of a){let d=await u.key,p=await u.value;if(d.status==="aborted"||p.status==="aborted")return{status:"aborted"};(d.status==="dirty"||p.status==="dirty")&&n.dirty(),o.set(d.value,p.value)}return{status:n.value,value:o}})}else{let o=new Map;for(let u of a){let d=u.key,p=u.value;if(d.status==="aborted"||p.status==="aborted")return{status:"aborted"};(d.status==="dirty"||p.status==="dirty")&&n.dirty(),o.set(d.value,p.value)}return{status:n.value,value:o}}}isEqual(e){return!(!(e instanceof Jt)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};l(tl,"ZodMapImpl");var nm=tl,nl=class rl extends P{_parse(e){if(this._getType(e)!=="nan"){let r=this._getOrReturnCtx(e);return m(r,{code:"invalid_type",expected:"nan",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof rl}};l(nl,"ZodNaNImpl");var rm=nl,il=class sl extends P{constructor(){super(...arguments),this._getValidEnumValues=l(e=>{let n=Object.keys(e).filter(i=>typeof e[e[i]]!="number"),r={};for(let i of n)r[i]=e[i];return Object.values(r)},"_getValidEnumValues")}_parse(e){let n=this._getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!=="string"&&r.parsedType!=="number"){let i=Object.values(n);return m(r,{expected:le.joinValues(i),received:r.parsedType,code:"invalid_type"}),{status:"aborted"}}if(n.indexOf(e.data)===-1){let i=Object.values(n);return m(r,{received:r.data,code:"invalid_enum_value",options:i}),{status:"aborted"}}return{status:"valid",value:e.data}}get enum(){return this._def.values}isEqual(e){return e instanceof sl?Ee(this._def.values,e._def.values):!1}};l(il,"ZodNativeEnumImpl");var im=il,al=class ol extends P{_parse(e){let n=this._getOrReturnCtx(e);return m(n,{code:"invalid_type",expected:"never",received:n.parsedType}),{status:"aborted"}}isEqual(e){return e instanceof ol}};l(al,"ZodNeverImpl");var sm=al,ll=class ul extends P{_parse(e){if(this._getType(e)!=="null"){let r=this._getOrReturnCtx(e);return m(r,{code:"invalid_type",expected:"null",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof ul}};l(ll,"ZodNullImpl");var am=ll,cl=class bt extends P{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()}))}_parse(e){return this._getType(e)==="null"?{status:"valid",value:null}:this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof bt?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new bt(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};l(cl,"ZodNullableImpl");var om=cl,dl=class Yt extends P{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!=="number"){let s=this._getOrReturnCtx(e);return m(s,{code:"invalid_type",expected:"number",received:s.parsedType}),{status:"aborted"}}let r,i=new te;for(let s of this._def.checks)s.kind==="int"?Number.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:"invalid_type",expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:"too_small",minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:"too_big",maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?this._floatSafeRemainder(e.data,s.value)!==0&&(r=this._getOrReturnCtx(e,r),m(r,{code:"not_multiple_of",multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:"not_finite",message:s.message}),i.dirty()):ue.assertNever(s);return{status:i.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,_.toString(n))}gt(e,n){return this.setLimit("min",e,!1,_.toString(n))}lte(e,n){return this.setLimit("max",e,!0,_.toString(n))}lt(e,n){return this.setLimit("max",e,!1,_.toString(n))}setLimit(e,n,r,i){return new Yt(f(c({},this._def),{checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:_.toString(i)}]}))}_addCheck(e){return new Yt(f(c({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:_.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:_.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:_.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:_.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:_.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Number.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}isEqual(e){if(!(e instanceof Yt))return!1;let n=new $.CustomSet(this._def.checks),r=new $.CustomSet(e._def.checks);return n.isEqual(r)}_floatSafeRemainder(e,n){let r=(e.toString().split(".")[1]||"").length,i=(n.toString().split(".")[1]||"").length,s=r>i?r:i,a=parseInt(e.toFixed(s).replace(".","")),o=parseInt(n.toFixed(s).replace(".",""));return a%o/Math.pow(10,s)}};l(dl,"ZodNumberImpl");var lm=dl,pl=class Q extends P{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),n=Object.keys(e);return this._cached={shape:e,keys:n}}dereference(e){let n=this._def.shape(),r={};for(let i in n)r[i]=n[i].dereference(e);return new Q(f(c({},this._def),{shape:()=>r}))}getReferences(){let e=this._def.shape(),n=[];for(let r in e)n.push(...e[r].getReferences());return ge.unique(n)}clone(){let e={},n=this._def.shape();for(let[i,s]of Object.entries(n))e[i]=s.clone();return new Q(f(c({},this._def),{shape:()=>e}))}_parse(e){if(this._getType(e)!=="object"){let p=this._getOrReturnCtx(e);return m(p,{code:"invalid_type",expected:"object",received:p.parsedType}),{status:"aborted"}}let{status:r,ctx:i}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),o=[];if(this._def.unknownKeys!=="strip")for(let p in i.data)a.includes(p)||o.push(p);let u=[];for(let p of a){let g=s[p],h=i.data[p];u.push({key:{status:"valid",value:p},value:g._parse(new fe(i,h,i.path,p)),alwaysSet:p in i.data})}let d=this._def.unknownKeys;if(d==="passthrough")for(let p of o)u.push({key:{status:"valid",value:p},value:{status:"valid",value:i.data[p]}});else if(d==="strict")o.length>0&&(m(i,{code:"unrecognized_keys",keys:o}),r.dirty());else if(d!=="strip")for(let p of o){let g=i.data[p];u.push({key:{status:"valid",value:p},value:d._parse(new fe(i,g,i.path,p)),alwaysSet:p in i.data})}return i.common.async?Promise.resolve().then(async()=>{let p=[];for(let g of u){let h=await g.key;p.push({key:h,value:await g.value,alwaysSet:g.alwaysSet})}return p}).then(p=>te.mergeObjectSync(r,p)):te.mergeObjectSync(r,u)}get shape(){return this._def.shape()}strict(e){return _.errToObj,new Q(c(f(c({},this._def),{unknownKeys:"strict"}),e!==void 0?{errorMap:(n,r)=>{var i,s,a,o;let u=(a=(s=(i=this._def).errorMap)==null?void 0:s.call(i,n,r).message)!=null?a:r.defaultError;return n.code==="unrecognized_keys"?{message:(o=_.errToObj(e).message)!=null?o:u}:{message:u}}}:{}))}strip(){return new Q(f(c({},this._def),{unknownKeys:"strip"}))}passthrough(){return new Q(f(c({},this._def),{unknownKeys:"passthrough"}))}additionalProperties(){if(typeof this._def.unknownKeys=="object")return this._def.unknownKeys;if(this._def.unknownKeys==="passthrough")return A.any();if(this._def.unknownKeys==="strict")return A.never()}extend(e){return new Q(f(c({},this._def),{shape:()=>c(c({},this._def.shape()),e)}))}merge(e){return new Q({unknownKeys:e._def.unknownKeys,shape:()=>c(c({},this._def.shape()),e._def.shape()),typeName:"ZodObject"})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new Q(f(c({},this._def),{unknownKeys:e}))}pick(e){let n={};return Object.keys(e).forEach(i=>{e[i]&&this.shape[i]&&(n[i]=this.shape[i])}),new Q(f(c({},this._def),{shape:()=>n}))}omit(e){let n={};return Object.entries(this.shape).forEach(([i,s])=>{e[i]||(n[i]=s)}),new Q(f(c({},this._def),{shape:()=>n}))}partial(e){let n={};return Object.keys(this.shape).forEach(i=>{let s=this.shape[i];e&&!e[i]?n[i]=s:n[i]=s?.optional()}),new Q(f(c({},this._def),{shape:()=>n}))}required(e){let n={};return Object.entries(this.shape).forEach(([r,i])=>{if(e&&!e[r])n[r]=i;else{let a=i;for(;K.zuiOptional(a);)a=a._def.innerType;n[r]=a}}),new Q(f(c({},this._def),{shape:()=>n}))}keyof(){let e=Object.keys(this.shape);return A.enum(e)}isEqual(e){if(!(e instanceof Q)||!this._unknownKeysEqual(e))return!1;let n=this._def.shape(),r=e._def.shape(),i=l((o,u)=>o[0]===u[0]&&o[1].isEqual(u[1]),"compare"),s=new $.CustomSet(Object.entries(n),{compare:i}),a=new $.CustomSet(Object.entries(r),{compare:i});return s.isEqual(a)}_unknownKeysEqual(e){let n=this.additionalProperties(),r=e.additionalProperties();return n===void 0||r===void 0?n===r:n.isEqual(r)}};l(pl,"ZodObjectImpl");var fl=pl,gl=class Xt extends P{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)==="undefined"?{status:"valid",value:void 0}: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 this._def.innerType.mandatory()}};l(gl,"ZodOptionalImpl");var um=gl,ml=class Qt extends P{dereference(e){return new Qt(f(c({},this._def),{in:this._def.in.dereference(e),out:this._def.out.dereference(e)}))}getReferences(){return ge.unique([...this._def.in.getReferences(),...this._def.out.getReferences()])}clone(){return new Qt(f(c({},this._def),{in:this._def.in.clone(),out:this._def.out.clone()}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return l(async()=>{let s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?{status:"aborted"}:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})},"handleAsync")();{let i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?{status:"aborted"}:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}isEqual(e){return!(!(e instanceof Qt)||!this._def.in.isEqual(e._def.in)||!this._def.out.isEqual(e._def.out))}};l(ml,"ZodPipelineImpl");var cm=ml,hl=class en extends P{unwrap(){return this._def.type}dereference(e){return new en(f(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new en(f(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:n}=this._processInputParams(e);return n.parsedType!=="promise"&&n.common.async===!1?(m(n,{code:"invalid_type",expected:"promise",received:n.parsedType}),{status:"aborted"}):{status:"valid",value:(n.parsedType==="promise"?n.data:Promise.resolve(n.data)).then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap}))}}isEqual(e){return e instanceof en?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}};l(hl,"ZodPromiseImpl");var dm=hl,yl=class wt extends P{constructor(){super(...arguments),this._freeze=l(e=>e.status!=="valid"?e:f(c({},e),{value:Object.freeze(e.value)}),"_freeze")}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()}))}_parse(e){let n=this._def.innerType._parse(e);return on(n)?n.then(this._freeze):this._freeze(n)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof wt?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new wt(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};l(yl,"ZodReadonlyImpl");var pm=yl,vl=class tn extends P{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}dereference(e){let n=this._def.keyType.dereference(e),r=this._def.valueType.dereference(e);return new tn(f(c({},this._def),{keyType:n,valueType:r}))}getReferences(){return ge.unique([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new tn(f(c({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!=="object")return m(r,{code:"invalid_type",expected:"object",received:r.parsedType}),{status:"aborted"};let i=[],s=this._def.keyType,a=this._def.valueType;for(let o in r.data)i.push({key:s._parse(new fe(r,o,r.path,o)),value:a._parse(new fe(r,r.data[o],r.path,o))});return r.common.async?te.mergeObjectAsync(n,i):te.mergeObjectSync(n,i)}get element(){return this._def.valueType}isEqual(e){return!(!(e instanceof tn)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};l(vl,"ZodRecordImpl");var Ui=vl,_l=class Tl extends P{dereference(e){let n=e[this._def.uri];return n||this}getReferences(){return[this._def.uri]}_parse(e){let n=this._getOrReturnCtx(e);return m(n,{code:"unresolved_reference"}),{status:"aborted"}}isOptional(){return!1}isNullable(){return!1}isEqual(e){return e instanceof Tl?this._def.uri===e._def.uri:!1}};l(_l,"ZodRefImpl");var fm=_l,bl=class nt extends P{dereference(e){return new nt(f(c({},this._def),{valueType:this._def.valueType.dereference(e)}))}getReferences(){return this._def.valueType.getReferences()}clone(){return new nt(f(c({},this._def),{valueType:this._def.valueType.clone()}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!=="set")return m(r,{code:"invalid_type",expected:"set",received:r.parsedType}),{status:"aborted"};let i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(m(r,{code:"too_small",minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(m(r,{code:"too_big",maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());let s=this._def.valueType;function a(u){let d=new Set;for(let p of u){if(p.status==="aborted")return{status:"aborted"};p.status==="dirty"&&n.dirty(),d.add(p.value)}return{status:n.value,value:d}}l(a,"finalizeSet");let o=[...r.data.values()].map((u,d)=>s._parse(new fe(r,u,r.path,d)));return r.common.async?Promise.all(o).then(u=>a(u)):a(o)}min(e,n){return new nt(f(c({},this._def),{minSize:{value:e,message:_.toString(n)}}))}max(e,n){return new nt(f(c({},this._def),{maxSize:{value:e,message:_.toString(n)}}))}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}isEqual(e){var n,r,i,s;if(!(e instanceof nt))return!1;let a=(n=this._def.minSize)==null?void 0:n.value,o=(r=e._def.minSize)==null?void 0:r.value;if(a!==o)return!1;let u=(i=this._def.maxSize)==null?void 0:i.value,d=(s=e._def.maxSize)==null?void 0:s.value;return u!==d?!1:this._def.valueType.isEqual(e._def.valueType)}};l(bl,"ZodSetImpl");var gm=bl,mm=/^c[^\s-]{8,}$/i,hm=/^[a-z][a-z0-9]*$/,ym=/^[0-9A-HJKMNP-TV-Z]{26}$/,vm=/^[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,_m=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Tm="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Vn,bm=/^(((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}))$/,wm=/^(([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 wl(t,e){return!!((e==="v4"||!e)&&bm.test(t)||(e==="v6"||!e)&&wm.test(t))}l(wl,"isValidIP");var xl=class rt extends P{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!=="string"){let s=this._getOrReturnCtx(e);return m(s,{code:"invalid_type",expected:"string",received:s.parsedType}),{status:"aborted"}}let r=new te,i;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),m(i,{code:"too_small",minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),m(i,{code:"too_big",maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){let a=e.data.length>s.value,o=e.data.length<s.value;(a||o)&&(i=this._getOrReturnCtx(e,i),a?m(i,{code:"too_big",maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&m(i,{code:"too_small",minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")_m.test(e.data)||(i=this._getOrReturnCtx(e,i),m(i,{validation:"email",code:"invalid_string",message:s.message}),r.dirty());else if(s.kind==="emoji")Vn||(Vn=new RegExp(Tm,"u")),Vn.test(e.data)||(i=this._getOrReturnCtx(e,i),m(i,{validation:"emoji",code:"invalid_string",message:s.message}),r.dirty());else if(s.kind==="uuid")vm.test(e.data)||(i=this._getOrReturnCtx(e,i),m(i,{validation:"uuid",code:"invalid_string",message:s.message}),r.dirty());else if(s.kind==="cuid")mm.test(e.data)||(i=this._getOrReturnCtx(e,i),m(i,{validation:"cuid",code:"invalid_string",message:s.message}),r.dirty());else if(s.kind==="cuid2")hm.test(e.data)||(i=this._getOrReturnCtx(e,i),m(i,{validation:"cuid2",code:"invalid_string",message:s.message}),r.dirty());else if(s.kind==="ulid")ym.test(e.data)||(i=this._getOrReturnCtx(e,i),m(i,{validation:"ulid",code:"invalid_string",message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),m(i,{validation:"url",code:"invalid_string",message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),m(i,{validation:"regex",code:"invalid_string",message:s.message}),r.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),m(i,{code:"invalid_string",validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),m(i,{code:"invalid_string",validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),m(i,{code:"invalid_string",validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?Po.generateDatetimeRegex(s).test(e.data)||(i=this._getOrReturnCtx(e,i),m(i,{code:"invalid_string",validation:"datetime",message:s.message}),r.dirty()):s.kind==="ip"?wl(e.data,s.version)||(i=this._getOrReturnCtx(e,i),m(i,{validation:"ip",code:"invalid_string",message:s.message}),r.dirty()):ue.assertNever(s);return{status:r.value,value:e.data}}_addCheck(e){return new rt(f(c({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(c({kind:"email"},_.errToObj(e)))}url(e){return this._addCheck(c({kind:"url"},_.errToObj(e)))}emoji(e){return this._addCheck(c({kind:"emoji"},_.errToObj(e)))}uuid(e){return this._addCheck(c({kind:"uuid"},_.errToObj(e)))}cuid(e){return this._addCheck(c({kind:"cuid"},_.errToObj(e)))}cuid2(e){return this._addCheck(c({kind:"cuid2"},_.errToObj(e)))}ulid(e){return this._addCheck(c({kind:"ulid"},_.errToObj(e)))}ip(e){return this._addCheck(c({kind:"ip"},_.errToObj(e)))}datetime(e){var n;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:(n=e?.offset)!=null?n:!1},_.errToObj(e?.message)))}regex(e,n){return this._addCheck(c({kind:"regex",regex:e},_.errToObj(n)))}includes(e,n){return this._addCheck(c({kind:"includes",value:e,position:n?.position},_.errToObj(n?.message)))}startsWith(e,n){return this._addCheck(c({kind:"startsWith",value:e},_.errToObj(n)))}endsWith(e,n){return this._addCheck(c({kind:"endsWith",value:e},_.errToObj(n)))}min(e,n){return this._addCheck(c({kind:"min",value:e},_.errToObj(n)))}max(e,n){return this._addCheck(c({kind:"max",value:e},_.errToObj(n)))}length(e,n){return this._addCheck(c({kind:"length",value:e},_.errToObj(n)))}nonempty(e){return this.min(1,_.errToObj(e))}trim(){return new rt(f(c({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}secret(){return this._def[B]=f(c({},this._def[B]),{secret:!0}),this}toLowerCase(){return new rt(f(c({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new rt(f(c({},this._def),{checks:[...this._def.checks,{kind:"toUpperCase"}]}))}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}isEqual(e){if(!(e instanceof rt))return!1;let n=new $.CustomSet(this._def.checks),r=new $.CustomSet(e._def.checks);return n.isEqual(r)}};l(xl,"ZodStringImpl");var xm=xl,Pl=class kl extends P{_parse(e){if(this._getType(e)!=="symbol"){let r=this._getOrReturnCtx(e);return m(r,{code:"invalid_type",expected:"symbol",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof kl}};l(Pl,"ZodSymbolImpl");var Pm=Pl,Sl=class xt extends P{innerType(){return this._def.schema}sourceType(){return K.zuiEffects(this._def.schema)?this._def.schema.sourceType():this._def.schema}dereference(e){return new xt(f(c({},this._def),{schema:this._def.schema.dereference(e)}))}getReferences(){return this._def.schema.getReferences()}clone(){return new xt(f(c({},this._def),{schema:this._def.schema.clone()}))}_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.effect;if(r.type==="upstream"){let i=r.effect(n.data,{path:n.path});if(n.common.async)return Promise.resolve(i).then(async s=>{if(s??(s={status:"valid",value:n.data}),this._processResult(n,s),s.status==="aborted")return{status:"aborted"};let a=await this._def.schema._parseAsync({data:s.value,path:n.path,parent:n});return a.status==="aborted"?{status:"aborted"}:a.status==="dirty"?{status:"dirty",value:a.value}:s.status==="dirty"?{status:"dirty",value:a.value}:a});{if(i instanceof Promise)throw new Error("Asynchronous upstream transform encountered during synchronous parse operation. Use .parseAsync instead.");if(i??(i={status:"valid",value:n.data}),this._processResult(n,i),i.status==="aborted")return{status:"aborted"};let s=this._def.schema._parseSync({data:i.value,path:n.path,parent:n});return s.status==="aborted"?{status:"aborted"}:s.status==="dirty"?{status:"dirty",value:s.value}:i.status==="dirty"?{status:"dirty",value:s.value}:s}}if(r.type==="downstream")if(n.common.async===!1){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(i.status==="aborted"||i.status==="dirty"&&r.failFast)return i;let s=r.effect(i.value,{path:n.path});if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return s??(s={status:"valid",value:i.value}),this._processResult(n,s),s.status==="aborted"?{status:"aborted"}:s.status==="dirty"?{status:"dirty",value:s.value}:i.status==="dirty"?{status:"dirty",value:s.value}:s}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>i.status==="aborted"||i.status==="dirty"&&r.failFast?i:Promise.resolve(r.effect(i.value,{path:n.path})).then(s=>(s??(s={status:"valid",value:i.value}),this._processResult(n,s),s.status==="aborted"?{status:"aborted"}:s.status==="dirty"?{status:"dirty",value:s.value}:i.status==="dirty"?{status:"dirty",value:s.value}:s)));ue.assertNever(r)}_processResult(e,n){if(n.status!=="valid")for(let r of n.issues)m(e,r)}isEqual(e){return!(e instanceof xt)||!this._def.schema.isEqual(e._def.schema)?!1:this._def.effect.type==="upstream"?e._def.effect.type!=="upstream"?!1:le.compareFunctions(this._def.effect.effect,e._def.effect.effect):this._def.effect.type==="downstream"?e._def.effect.type!=="downstream"||this._def.effect.failFast!==e._def.effect.failFast?!1:le.compareFunctions(this._def.effect.effect,e._def.effect.effect):(this._def.effect,!1)}naked(){return this._def.schema.naked()}mandatory(){return new xt(f(c({},this._def),{schema:this._def.schema.mandatory()}))}};l(Sl,"ZodEffectsImpl");var Sr=Sl,Ol=class Pt extends P{dereference(e){let n=this._def.items.map(i=>i.dereference(e)),r=this._def.rest?this._def.rest.dereference(e):null;return new Pt(f(c({},this._def),{items:n,rest:r}))}getReferences(){return ge.unique([...this._def.items.flatMap(e=>e.getReferences()),...this._def.rest?this._def.rest.getReferences():[]])}clone(){let e=this._def.items.map(r=>r.clone()),n=this._def.rest?this._def.rest.clone():null;return new Pt(f(c({},this._def),{items:e,rest:n}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!=="array")return m(r,{code:"invalid_type",expected:"array",received:r.parsedType}),{status:"aborted"};if(r.data.length<this._def.items.length)return m(r,{code:"too_small",minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),{status:"aborted"};!this._def.rest&&r.data.length>this._def.items.length&&(m(r,{code:"too_big",maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let s=[...r.data].map((a,o)=>{let u=this._def.items[o]||this._def.rest;return u?u._parse(new fe(r,a,r.path,o)):null}).filter(a=>!!a);return r.common.async?Promise.all(s).then(a=>te.mergeArray(n,a)):te.mergeArray(n,s)}get items(){return this._def.items}rest(e){return new Pt(f(c({},this._def),{rest:e}))}isEqual(e){if(!(e instanceof Pt)||!this._restEquals(e))return!1;let n=l((s,a)=>s.isEqual(a),"compare"),r=new $.CustomSet(this._def.items,{compare:n}),i=new $.CustomSet(e._def.items,{compare:n});return r.isEqual(i)}_restEquals(e){return this._def.rest===null?e._def.rest===null:e._def.rest!==null&&this._def.rest.isEqual(e._def.rest)}};l(Ol,"ZodTupleImpl");var km=Ol,El=class Il extends P{_parse(e){if(this._getType(e)!=="undefined"){let r=this._getOrReturnCtx(e);return m(r,{code:"invalid_type",expected:"undefined",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof Il}mandatory(){return A.never(c({},this._def))}};l(El,"ZodUndefinedImpl");var Sm=El,Bl=class kt extends P{dereference(e){let n=this._def.options.map(r=>r.dereference(e));return new kt(f(c({},this._def),{options:n}))}getReferences(){return ge.unique(this._def.options.reduce((e,n)=>[...e,...n.getReferences()],[]))}clone(){let e=this._def.options.map(n=>n.clone());return new kt(f(c({},this._def),{options:e}))}_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function i(s){for(let o of s)if(o.result.status==="valid")return o.result;for(let o of s)if(o.result.status==="dirty")return n.common.issues.push(...o.ctx.common.issues),o.result;let a=s.map(o=>new Te(o.ctx.common.issues));return m(n,{code:"invalid_union",unionErrors:a}),{status:"aborted"}}if(l(i,"handleResults"),n.common.async)return Promise.all(r.map(async s=>{let a=f(c({},n),{common:f(c({},n.common),{issues:[]}),parent:null});return{result:await s._parseAsync({data:n.data,path:n.path,parent:a}),ctx:a}})).then(i);{let s,a=[];for(let u of r){let d=f(c({},n),{common:f(c({},n.common),{issues:[]}),parent:null}),p=u._parseSync({data:n.data,path:n.path,parent:d});if(p.status==="valid")return p;p.status==="dirty"&&!s&&(s={result:p,ctx:d}),d.common.issues.length&&a.push(d.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;let o=a.map(u=>new Te(u));return m(n,{code:"invalid_union",unionErrors:o}),{status:"aborted"}}}get options(){return this._def.options}isEqual(e){if(!(e instanceof kt))return!1;let n=l((s,a)=>s.isEqual(a),"compare"),r=new $.CustomSet([...this._def.options],{compare:n}),i=new $.CustomSet([...e._def.options],{compare:n});return r.isEqual(i)}mandatory(){let e=this._def.options.filter(s=>!K.zuiUndefined(s)).map(s=>s.mandatory()),[n,r,...i]=e;return n?r?new kt(f(c({},this._def),{options:[n,r,...i]})):n:A.never(c({},this._def))}};l(Bl,"ZodUnionImpl");var Om=Bl,Cl=class Al extends P{constructor(){super(...arguments),this._unknown=!0}_parse(e){return{status:"valid",value:e.data}}isEqual(e){return e instanceof Al}};l(Cl,"ZodUnknownImpl");var Em=Cl,Zl=class Rl extends P{_parse(e){if(this._getType(e)!=="undefined"){let r=this._getOrReturnCtx(e);return m(r,{code:"invalid_type",expected:"void",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof Rl}};l(Zl,"ZodVoidImpl");var Im=Zl,Bm=l(t=>t instanceof Error,"_isError"),Cm=l(t=>typeof t=="object"&&t!==null,"_isObject"),K={zuiError:t=>t instanceof Te||Bm(t)&&"__type__"in t&&t.__type__==="ZuiError",zuiType:t=>t instanceof P||Cm(t)&&"__type__"in t&&t.__type__==="ZuiType",zuiAny:t=>t.typeName==="ZodAny",zuiArray:t=>t.typeName==="ZodArray",zuiBigInt:t=>t.typeName==="ZodBigInt",zuiBoolean:t=>t.typeName==="ZodBoolean",zuiBranded:t=>t.typeName==="ZodBranded",zuiCatch:t=>t.typeName==="ZodCatch",zuiDate:t=>t.typeName==="ZodDate",zuiDefault:t=>t.typeName==="ZodDefault",zuiDiscriminatedUnion:t=>t.typeName==="ZodDiscriminatedUnion",zuiEnum:t=>t.typeName==="ZodEnum",zuiFunction:t=>t.typeName==="ZodFunction",zuiIntersection:t=>t.typeName==="ZodIntersection",zuiLazy:t=>t.typeName==="ZodLazy",zuiLiteral:t=>t.typeName==="ZodLiteral",zuiMap:t=>t.typeName==="ZodMap",zuiNaN:t=>t.typeName==="ZodNaN",zuiNativeEnum:t=>t.typeName==="ZodNativeEnum",zuiNever:t=>t.typeName==="ZodNever",zuiNull:t=>t.typeName==="ZodNull",zuiNullable:t=>t.typeName==="ZodNullable",zuiNumber:t=>t.typeName==="ZodNumber",zuiObject:t=>t.typeName==="ZodObject",zuiOptional:t=>t.typeName==="ZodOptional",zuiPipeline:t=>t.typeName==="ZodPipeline",zuiPromise:t=>t.typeName==="ZodPromise",zuiReadonly:t=>t.typeName==="ZodReadonly",zuiRecord:t=>t.typeName==="ZodRecord",zuiRef:t=>t.typeName==="ZodRef",zuiSet:t=>t.typeName==="ZodSet",zuiString:t=>t.typeName==="ZodString",zuiSymbol:t=>t.typeName==="ZodSymbol",zuiEffects:t=>t.typeName==="ZodEffects",zuiTuple:t=>t.typeName==="ZodTuple",zuiUndefined:t=>t.typeName==="ZodUndefined",zuiUnion:t=>t.typeName==="ZodUnion",zuiUnknown:t=>t.typeName==="ZodUnknown",zuiVoid:t=>t.typeName==="ZodVoid"},k=l(t=>{if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:i,supportsExtensions:s,[B]:a}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);let o=a?Object.fromEntries(Object.entries(a).filter(([d])=>d!=="secret"||s?.includes("secret"))):void 0;return e?{errorMap:e,description:i,[B]:o}:{errorMap:l((d,p)=>d.code!=="invalid_type"?{message:p.defaultError}:typeof p.data>"u"?{message:r??p.defaultError}:{message:n??p.defaultError},"customMap"),description:i,[B]:o}},"_processCreateParams"),yn=l((t,e={},n)=>t?ze().downstream(r=>{var i,s;if(!t(r)){let a=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e;return((s=(i=a.fatal)!=null?i:n)!=null?s:!0)?qr(c({code:"custom"},a)):Vr(r,c({code:"custom"},a))}}):ze(),"customType"),Or=l((t,e={message:`Input not instance of ${t.name}`})=>yn(n=>n instanceof t,e),"instanceOfType"),ze=l(t=>new zg(c({typeName:"ZodAny"},k(t))),"anyType"),Be=l(t=>new Em(c({typeName:"ZodUnknown"},k(t))),"unknownType"),Rt=l(t=>new sm(c({typeName:"ZodNever"},k(t))),"neverType"),Er=l(t=>new Im(c({typeName:"ZodVoid"},k(t))),"voidType"),$t=l(t=>new am(c({typeName:"ZodNull"},k(t))),"nullType"),vn=l(t=>new Sm(c({typeName:"ZodUndefined"},k(t))),"undefinedType"),Ir=l(t=>new Pm(c({typeName:"ZodSymbol"},k(t))),"symbolType"),Br=l(t=>new rm(c({typeName:"ZodNaN"},k(t))),"nanType"),we=l(t=>{var e;return new xm(c({checks:[],typeName:"ZodString",coerce:(e=t?.coerce)!=null?e:!1},k(f(c({},t),{supportsExtensions:["secret"]}))))},"stringType"),Je=l(t=>new lm(c({checks:[],typeName:"ZodNumber",coerce:t?.coerce||!1},k(t))),"numberType"),Ye=l(t=>new Lg(c({typeName:"ZodBoolean",coerce:t?.coerce||!1},k(t))),"booleanType"),_n=l(t=>{var e;return new Wg(c({checks:[],typeName:"ZodBigInt",coerce:(e=t?.coerce)!=null?e:!1},k(t)))},"bigIntType"),Tn=l(t=>new Vg(c({checks:[],coerce:t?.coerce||!1,typeName:"ZodDate"},k(t))),"dateType"),bn=l(t=>new fm({typeName:"ZodRef",uri:t}),"refType"),Nt=l((t,e)=>new tm(c({value:t,typeName:"ZodLiteral"},k(e))),"literalType"),wn=l((t,e)=>new Yg(c({values:t,typeName:"ZodEnum"},k(e))),"enumType"),Cr=l((t,e)=>new im(c({values:t,typeName:"ZodNativeEnum"},k(e))),"nativeEnumType"),je=l((t,e)=>new Kg(c({type:t,minLength:null,maxLength:null,exactLength:null,typeName:"ZodArray"},k(e))),"arrayType"),at=l((t,e)=>new fl(c({shape:()=>t,unknownKeys:"strip",typeName:"ZodObject"},k(e))),"objectType"),Ar=l((t,e)=>new fl(c({shape:()=>t,unknownKeys:"strict",typeName:"ZodObject"},k(e))),"strictObjectType"),$e=l((t,e)=>new Om(c({options:t,typeName:"ZodUnion"},k(e))),"unionType"),Dt=l((t,e,n)=>new Jg(c({typeName:"ZodDiscriminatedUnion",discriminator:t,options:e},k(n))),"discriminatedUnionType"),xn=l((t,e,n)=>new Qg(c({left:t,right:e,typeName:"ZodIntersection"},k(n))),"intersectionType"),Ut=l((t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new km(c({items:t,typeName:"ZodTuple",rest:null},k(e)))},"tupleType"),Ht=l((t,e,n)=>e instanceof P?new Ui(c({keyType:t,valueType:e,typeName:"ZodRecord"},k(n))):new Ui(c({keyType:we(),valueType:t,typeName:"ZodRecord"},k(e))),"recordType"),Zr=l((t,e,n)=>new nm(c({valueType:e,keyType:t,typeName:"ZodMap"},k(n))),"mapType"),Pn=l((t,e)=>new gm(c({valueType:t,minSize:null,maxSize:null,typeName:"ZodSet"},k(e))),"setType"),Rr=l((t,e)=>new em(c({getter:t,typeName:"ZodLazy"},k(e))),"lazyType"),Nr=l((t,e)=>new dm(c({type:t,typeName:"ZodPromise"},k(e))),"promiseType"),Dr=l((t,e,n)=>new Xg(c({args:t||Ut([]).rest(Be()),returns:e||Be(),typeName:"ZodFunction"},k(n))),"functionType"),Hr=l((t,e,n)=>new Sr(c({schema:e,effect:{type:"upstream",effect:(r,i)=>{let s=t(r,i);return s instanceof Promise?s.then(a=>ln(a)):ln(s)}},typeName:"ZodEffects"},k(n))),"preprocessType"),Mr=l((t,e,n)=>new Sr(c({schema:e,effect:{type:"upstream",effect:t},typeName:"ZodEffects"},k(n))),"upstreamType"),jr=l((t,e,n)=>new Sr(c({schema:t,effect:{type:"downstream",effect:e,failFast:n?.failFast},typeName:"ZodEffects"},k(n))),"downstreamType"),$r=l((t,e)=>new um(c({innerType:t,typeName:"ZodOptional"},k(e))),"optionalType"),Ur=l((t,e)=>new om(c({innerType:t,typeName:"ZodNullable"},k(e))),"nullableType"),zr=l((t,e)=>new pm(c({innerType:t,typeName:"ZodReadonly"},k(e))),"readonlyType"),Kr=l((t,e,n)=>new Gg(c({innerType:t,typeName:"ZodDefault",defaultValue:typeof e=="function"?e:()=>e},k(n))),"defaultType"),Wr=l((t,e,n)=>new qg(c({innerType:t,typeName:"ZodCatch",catchValue:typeof e=="function"?e:()=>e},k(n))),"catchType"),Lr=l((t,e)=>new cm({in:t,out:e,typeName:"ZodPipeline"}),"pipelineType"),Fr=l(t=>new Fg(c({typeName:"ZodBranded",type:t},k({supportsExtensions:["secret"]}))),"brandedType");Co({any:ze,array:je,bigint:_n,boolean:Ye,branded:Fr,catch:Wr,custom:yn,date:Tn,default:Kr,discriminatedUnion:Dt,enum:wn,function:Dr,instanceof:Or,intersection:xn,lazy:Rr,literal:Nt,map:Zr,nan:Br,nativeEnum:Cr,never:Rt,null:$t,nullable:Ur,number:Je,object:at,optional:$r,pipeline:Lr,preprocess:Hr,upstream:Mr,downstream:jr,promise:Nr,record:Ht,ref:bn,readonly:zr,set:Pn,strictObject:Ar,string:we,symbol:Ir,tuple:Ut,undefined:vn,union:$e,unknown:Be,void:Er});var Nl={string(t){return we(f(c({},t),{coerce:!0}))},number(t){return Je(f(c({},t),{coerce:!0}))},boolean(t){return Ye(f(c({},t),{coerce:!0}))},bigint(t){return _n(f(c({},t),{coerce:!0}))},date(t){return Tn(f(c({},t),{coerce:!0}))}},ln=l(t=>({status:"valid",value:t}),"OK"),qr=l((t,...e)=>({status:"aborted",issues:[t,...e]}),"ERR"),Vr=l((t,e,...n)=>({status:"dirty",value:t,issues:[e,...n]}),"DIRTY"),Dl={};ce(Dl,{JSONSchemaToZuiError:()=>kn,ObjectToZuiError:()=>cr,UnrepresentableGenericError:()=>dr,UnsupportedJSONSchemaToZuiError:()=>De,UnsupportedZuiCheckToJSONSchemaError:()=>Kl,UnsupportedZuiToJSONSchemaError:()=>Y,UnsupportedZuiToTypescriptSchemaError:()=>He,UnsupportedZuiToTypescriptTypeError:()=>Jl,UntitledDeclarationError:()=>Xl,ZuiToJSONSchemaError:()=>Sn,ZuiToTypescriptSchemaError:()=>Fl,ZuiToTypescriptTypeError:()=>On,ZuiTransformError:()=>ot});var Hl=class extends Error{constructor(e,n){super(n),this.transform=e}};l(Hl,"ZuiTransformError");var ot=Hl,Ml=class extends ot{constructor(e){super("json-schema-to-zui",e)}};l(Ml,"JSONSchemaToZuiError");var kn=Ml,jl=class extends ot{constructor(e){super("object-to-zui",e)}};l(jl,"ObjectToZuiError");var cr=jl,$l=class extends ot{constructor(e){super("zui-to-json-schema",e)}};l($l,"ZuiToJSONSchemaError");var Sn=$l,Ul=class extends Sn{constructor(e,{suggestedAlternative:n}={}){super(`Zod type ${e} cannot be transformed to JSON Schema.`+(n?` Suggested alternative: ${n}`:""))}};l(Ul,"UnsupportedZuiToJSONSchemaError");var Y=Ul,zl=class extends Sn{constructor({zodType:e,checkKind:n}){super(`Zod check .${n}() of type ${e} cannot be transformed to JSON Schema.`)}};l(zl,"UnsupportedZuiCheckToJSONSchemaError");var Kl=zl,Wl=class extends kn{constructor(e){super(`JSON Schema ${JSON.stringify(e)} cannot be transformed to ZUI type.`)}};l(Wl,"UnsupportedJSONSchemaToZuiError");var De=Wl,Ll=class extends ot{constructor(e){super("zui-to-typescript-schema",e)}};l(Ll,"ZuiToTypescriptSchemaError");var Fl=Ll,ql=class extends Fl{constructor(e){super(`Zod type ${e} cannot be transformed to TypeScript schema.`)}};l(ql,"UnsupportedZuiToTypescriptSchemaError");var He=ql,Vl=class extends ot{constructor(e){super("zui-to-typescript-type",e)}};l(Vl,"ZuiToTypescriptTypeError");var On=Vl,Gl=class extends On{constructor(e){super(`Zod type ${e} cannot be transformed to TypeScript type.`)}};l(Gl,"UnsupportedZuiToTypescriptTypeError");var Jl=Gl,Yl=class extends On{constructor(){super("Schema must have a title to be transformed to a TypeScript type with a declaration.")}};l(Yl,"UntitledDeclarationError");var Xl=Yl,Ql=class extends On{constructor(){super('ZodRef can only be transformed to a TypeScript type with a "type" declaration.')}};l(Ql,"UnrepresentableGenericError");var dr=Ql,Am=l(t=>{let e;try{e=new Function("z",`return ${t}`)(xe)}catch(n){return{sucess:!1,error:`Failed to evaluate schema: ${(n instanceof Error?n:new Error(String(n))).message}`}}return K.zuiType(e)?{sucess:!0,value:e}:{sucess:!1,error:`String "${t}" does not evaluate to a Zod schema`}},"evalZuiString"),x={ZodString:"ZodString",ZodNumber:"ZodNumber",ZodNaN:"ZodNaN",ZodBigInt:"ZodBigInt",ZodBoolean:"ZodBoolean",ZodDate:"ZodDate",ZodSymbol:"ZodSymbol",ZodUndefined:"ZodUndefined",ZodNull:"ZodNull",ZodAny:"ZodAny",ZodUnknown:"ZodUnknown",ZodNever:"ZodNever",ZodVoid:"ZodVoid",ZodArray:"ZodArray",ZodObject:"ZodObject",ZodUnion:"ZodUnion",ZodDiscriminatedUnion:"ZodDiscriminatedUnion",ZodIntersection:"ZodIntersection",ZodTuple:"ZodTuple",ZodRecord:"ZodRecord",ZodRef:"ZodRef",ZodMap:"ZodMap",ZodSet:"ZodSet",ZodFunction:"ZodFunction",ZodLazy:"ZodLazy",ZodLiteral:"ZodLiteral",ZodEnum:"ZodEnum",ZodEffects:"ZodEffects",ZodNativeEnum:"ZodNativeEnum",ZodOptional:"ZodOptional",ZodNullable:"ZodNullable",ZodDefault:"ZodDefault",ZodCatch:"ZodCatch",ZodPromise:"ZodPromise",ZodBranded:"ZodBranded",ZodPipeline:"ZodPipeline",ZodReadonly:"ZodReadonly"},Zm=l(t=>[t.slice(0,t.length/2),t.slice(t.length/2)],"half"),Rm=l((t,...e)=>Object.keys(t).reduce((n,r)=>(e.includes(r)||(n[r]=t[r]),n),{}),"omit");function q(t,e,n){var r;let i=t[e],s="";if(i!==void 0){let a=n({value:i,json:JSON.stringify(i)});if(a){let o=a[0],u=a.length===3?a[1]:"",d=a.length===3?a[2]:a[1];s+=o,((r=t.errorMessage)==null?void 0:r[e])!==void 0&&(s+=u+JSON.stringify(t.errorMessage[e])),s+=d}}return s}l(q,"withMessage");var St=Symbol("Original index"),Nm=l(t=>{let e=[];for(let n=0;n<t.length;n++){let r=t[n];if(typeof r=="boolean")e.push(r?{[St]:n}:{[St]:n,not:{}});else{if(St in r)return t;e.push(f(c({},r),{[St]:n}))}}return e},"ensureOriginalIndex");function Mt(t,e){if(t.allOf.length===0)return"z.never()";if(t.allOf.length===1){let n=t.allOf[0];return W(n,f(c({},e),{path:[...e.path,"allOf",n[St]]}))}else{let[n,r]=Zm(Nm(t.allOf));return`z.intersection(${Mt({allOf:n},e)}, ${Mt({allOf:r},e)})`}}l(Mt,"parseAllOf");var eu=l((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((n,r)=>W(n,f(c({},e),{path:[...e.path,"anyOf",r]}))).join(", ")}])`:"z.any()","parseAnyOf"),Dm=l((t,e)=>{if(Array.isArray(t.items))return`z.tuple([${t.items.map((r,i)=>W(r,f(c({},e),{path:[...e.path,"items",i]})))}])`;let n=t.items?`z.array(${W(t.items,f(c({},e),{path:[...e.path,"items"]}))})`:"z.array(z.any())";return n+=q(t,"minItems",({json:r})=>[`.min(${r}`,", ",")"]),n+=q(t,"maxItems",({json:r})=>[`.max(${r}`,", ",")"]),n},"parseArray"),Hm=l(t=>{var e;return(e=t[B])!=null&&e.coerce?"z.coerce.boolean()":"z.boolean()"},"parseBoolean"),Mm=l(t=>`z.literal(${JSON.stringify(t.const)})`,"parseConst"),jm=l(t=>"z.any()","parseDefault"),Gr=l((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) => {
1
+ "use strict";var Tc=Object.create;var Lt=Object.defineProperty;var bc=Object.getOwnPropertyDescriptor;var wc=Object.getOwnPropertyNames;var xc=Object.getPrototypeOf,Pc=Object.prototype.hasOwnProperty;var Ze=(t,e)=>{for(var n in e)Lt(t,n,{get:e[n],enumerable:!0})},gi=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of wc(e))!Pc.call(t,i)&&i!==n&&Lt(t,i,{get:()=>e[i],enumerable:!(r=bc(e,i))||r.enumerable});return t};var Wn=(t,e,n)=>(n=t!=null?Tc(xc(t)):{},gi(e||!t||!t.__esModule?Lt(n,"default",{value:t,enumerable:!0}):n,t)),kc=t=>gi(Lt({},"__esModule",{value:!0}),t);var uv={};Ze(uv,{Bot:()=>jn,BotDefinition:()=>Mn,BotLogger:()=>pt,BotSpecificClient:()=>he,Integration:()=>Hn,IntegrationDefinition:()=>Cn,IntegrationLogger:()=>dt,IntegrationSpecificClient:()=>ut,InterfaceDefinition:()=>$n,Plugin:()=>zn,PluginDefinition:()=>Un,RuntimeError:()=>Kn.RuntimeError,WELL_KNOWN_ATTRIBUTES:()=>_y,errors:()=>ii,isApiError:()=>Kn.isApiError,messages:()=>ni,parseBody:()=>re,serve:()=>Kt,version:()=>fi,z:()=>y});module.exports=kc(uv);var ni={};Ze(ni,{defaults:()=>vy,markdown:()=>hy,markdownBloc:()=>yy});var hr=Object.defineProperty,Sc=Object.defineProperties,Oc=Object.getOwnPropertyDescriptors,rn=Object.getOwnPropertySymbols,Yi=Object.prototype.hasOwnProperty,Xi=Object.prototype.propertyIsEnumerable,mi=(t,e,n)=>e in t?hr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,c=(t,e)=>{for(var n in e||(e={}))Yi.call(e,n)&&mi(t,n,e[n]);if(rn)for(var n of rn(e))Xi.call(e,n)&&mi(t,n,e[n]);return t},f=(t,e)=>Sc(t,Oc(e)),l=(t,e)=>hr(t,"name",{value:e,configurable:!0}),Qi=(t,e)=>{var n={};for(var r in t)Yi.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&rn)for(var r of rn(t))e.indexOf(r)<0&&Xi.call(t,r)&&(n[r]=t[r]);return n},de=(t,e)=>{for(var n in e)hr(t,n,{get:e[n],enumerable:!0})},y={};de(y,{DIRTY:()=>Gr,ERR:()=>Vr,OK:()=>un,any:()=>We,array:()=>Ue,bigint:()=>Tn,boolean:()=>Qe,branded:()=>qr,catch:()=>Lr,coerce:()=>Hl,custom:()=>vn,date:()=>bn,default:()=>Wr,discriminatedUnion:()=>Ht,downstream:()=>$r,enum:()=>xn,function:()=>Hr,instanceof:()=>Er,intersection:()=>Pn,is:()=>K,lazy:()=>Nr,literal:()=>Dt,map:()=>Rr,nan:()=>Cr,nativeEnum:()=>Ar,never:()=>Nt,null:()=>Ut,nullable:()=>zr,number:()=>Xe,object:()=>ot,optional:()=>Ur,pipeline:()=>Fr,preprocess:()=>Mr,promise:()=>Dr,readonly:()=>Kr,record:()=>Mt,ref:()=>wn,set:()=>kn,strictObject:()=>Zr,string:()=>xe,symbol:()=>Br,transforms:()=>es,tuple:()=>zt,undefined:()=>_n,union:()=>ze,unknown:()=>Ce,upstream:()=>jr,void:()=>Ir,zuiKey:()=>B});var es={};de(es,{errors:()=>Ml,fromJSONSchema:()=>su,fromJSONSchemaLegacy:()=>rh,fromObject:()=>fr,json:()=>fy,toJSONSchema:()=>z,toJSONSchemaLegacy:()=>Zh,toTypescriptSchema:()=>ti,toTypescriptType:()=>ei});var Pe={};de(Pe,{DIRTY:()=>Gr,ERR:()=>Vr,OK:()=>un,any:()=>We,array:()=>Ue,bigint:()=>Tn,boolean:()=>Qe,branded:()=>qr,catch:()=>Lr,coerce:()=>Hl,custom:()=>vn,date:()=>bn,default:()=>Wr,discriminatedUnion:()=>Ht,downstream:()=>$r,enum:()=>xn,function:()=>Hr,instanceof:()=>Er,intersection:()=>Pn,is:()=>K,lazy:()=>Nr,literal:()=>Dt,map:()=>Rr,nan:()=>Cr,nativeEnum:()=>Ar,never:()=>Nt,null:()=>Ut,nullable:()=>zr,number:()=>Xe,object:()=>ot,optional:()=>Ur,pipeline:()=>Fr,preprocess:()=>Mr,promise:()=>Dr,readonly:()=>Kr,record:()=>Mt,ref:()=>wn,set:()=>kn,strictObject:()=>Zr,string:()=>xe,symbol:()=>Br,tuple:()=>zt,undefined:()=>_n,union:()=>ze,unknown:()=>Ce,upstream:()=>jr,void:()=>Ir,zuiKey:()=>B});var B="x-zui",$={};de($,{CustomSet:()=>Ng});var me={};de(me,{isEqual:()=>bo,unique:()=>Zg});var Ec=typeof global=="object"&&global&&global.Object===Object&&global,ts=Ec,Ic=typeof self=="object"&&self&&self.Object===Object&&self,Bc=ts||Ic||Function("return this")(),ke=Bc,Cc=ke.Symbol,Be=Cc,ns=Object.prototype,Ac=ns.hasOwnProperty,Zc=ns.toString,gt=Be?Be.toStringTag:void 0;function rs(t){var e=Ac.call(t,gt),n=t[gt];try{t[gt]=void 0;var r=!0}catch{}var i=Zc.call(t);return r&&(e?t[gt]=n:delete t[gt]),i}l(rs,"getRawTag");var Rc=rs,Nc=Object.prototype,Dc=Nc.toString;function is(t){return Dc.call(t)}l(is,"objectToString");var Hc=is,Mc="[object Null]",jc="[object Undefined]",hi=Be?Be.toStringTag:void 0;function ss(t){return t==null?t===void 0?jc:Mc:hi&&hi in Object(t)?Rc(t):Hc(t)}l(ss,"baseGetTag");var Le=ss;function as(t){return t!=null&&typeof t=="object"}l(as,"isObjectLike");var Ke=as,$c="[object Symbol]";function os(t){return typeof t=="symbol"||Ke(t)&&Le(t)==$c}l(os,"isSymbol");var yr=os;function ls(t,e){for(var n=-1,r=t==null?0:t.length,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i}l(ls,"arrayMap");var us=ls,Uc=Array.isArray,we=Uc,zc=1/0,yi=Be?Be.prototype:void 0,vi=yi?yi.toString:void 0;function vr(t){if(typeof t=="string")return t;if(we(t))return us(t,vr)+"";if(yr(t))return vi?vi.call(t):"";var e=t+"";return e=="0"&&1/t==-zc?"-0":e}l(vr,"baseToString");var Kc=vr;function cs(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}l(cs,"isObject");var at=cs;function ds(t){return t}l(ds,"identity");var Wc=ds,Lc="[object AsyncFunction]",Fc="[object Function]",qc="[object GeneratorFunction]",Vc="[object Proxy]";function ps(t){if(!at(t))return!1;var e=Le(t);return e==Fc||e==qc||e==Lc||e==Vc}l(ps,"isFunction");var fs=ps,Gc=ke["__core-js_shared__"],Ln=Gc,_i=(function(){var t=/[^.]+$/.exec(Ln&&Ln.keys&&Ln.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function gs(t){return!!_i&&_i in t}l(gs,"isMasked");var Jc=gs,Yc=Function.prototype,Xc=Yc.toString;function ms(t){if(t!=null){try{return Xc.call(t)}catch{}try{return t+""}catch{}}return""}l(ms,"toSource");var Fe=ms,Qc=/[\\^$.*+?()[\]{}|]/g,ed=/^\[object .+?Constructor\]$/,td=Function.prototype,nd=Object.prototype,rd=td.toString,id=nd.hasOwnProperty,sd=RegExp("^"+rd.call(id).replace(Qc,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function hs(t){if(!at(t)||Jc(t))return!1;var e=fs(t)?sd:ed;return e.test(Fe(t))}l(hs,"baseIsNative");var ad=hs;function ys(t,e){return t?.[e]}l(ys,"getValue");var od=ys;function vs(t,e){var n=od(t,e);return ad(n)?n:void 0}l(vs,"getNative");var qe=vs,ld=qe(ke,"WeakMap"),rr=ld,ud=(function(){try{var t=qe(Object,"defineProperty");return t({},"",{}),t}catch{}})(),Ti=ud,cd=9007199254740991,dd=/^(?:0|[1-9]\d*)$/;function _s(t,e){var n=typeof t;return e=e??cd,!!e&&(n=="number"||n!="symbol"&&dd.test(t))&&t>-1&&t%1==0&&t<e}l(_s,"isIndex");var _r=_s;function Ts(t,e,n){e=="__proto__"&&Ti?Ti(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}l(Ts,"baseAssignValue");var bs=Ts;function ws(t,e){return t===e||t!==t&&e!==e}l(ws,"eq");var Tr=ws,pd=Object.prototype,fd=pd.hasOwnProperty;function xs(t,e,n){var r=t[e];(!(fd.call(t,e)&&Tr(r,n))||n===void 0&&!(e in t))&&bs(t,e,n)}l(xs,"assignValue");var gd=xs,md=9007199254740991;function Ps(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=md}l(Ps,"isLength");var br=Ps;function ks(t){return t!=null&&br(t.length)&&!fs(t)}l(ks,"isArrayLike");var Ss=ks,hd=Object.prototype;function Os(t){var e=t&&t.constructor,n=typeof e=="function"&&e.prototype||hd;return t===n}l(Os,"isPrototype");var Es=Os;function Is(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}l(Is,"baseTimes");var yd=Is,vd="[object Arguments]";function Bs(t){return Ke(t)&&Le(t)==vd}l(Bs,"baseIsArguments");var bi=Bs,Cs=Object.prototype,_d=Cs.hasOwnProperty,Td=Cs.propertyIsEnumerable,bd=bi((function(){return arguments})())?bi:function(t){return Ke(t)&&_d.call(t,"callee")&&!Td.call(t,"callee")},As=bd;function Zs(){return!1}l(Zs,"stubFalse");var wd=Zs,Rs=typeof exports=="object"&&exports&&!exports.nodeType&&exports,wi=Rs&&typeof module=="object"&&module&&!module.nodeType&&module,xd=wi&&wi.exports===Rs,xi=xd?ke.Buffer:void 0,Pd=xi?xi.isBuffer:void 0,kd=Pd||wd,ir=kd,Sd="[object Arguments]",Od="[object Array]",Ed="[object Boolean]",Id="[object Date]",Bd="[object Error]",Cd="[object Function]",Ad="[object Map]",Zd="[object Number]",Rd="[object Object]",Nd="[object RegExp]",Dd="[object Set]",Hd="[object String]",Md="[object WeakMap]",jd="[object ArrayBuffer]",$d="[object DataView]",Ud="[object Float32Array]",zd="[object Float64Array]",Kd="[object Int8Array]",Wd="[object Int16Array]",Ld="[object Int32Array]",Fd="[object Uint8Array]",qd="[object Uint8ClampedArray]",Vd="[object Uint16Array]",Gd="[object Uint32Array]",C={};C[Ud]=C[zd]=C[Kd]=C[Wd]=C[Ld]=C[Fd]=C[qd]=C[Vd]=C[Gd]=!0;C[Sd]=C[Od]=C[jd]=C[Ed]=C[$d]=C[Id]=C[Bd]=C[Cd]=C[Ad]=C[Zd]=C[Rd]=C[Nd]=C[Dd]=C[Hd]=C[Md]=!1;function Ns(t){return Ke(t)&&br(t.length)&&!!C[Le(t)]}l(Ns,"baseIsTypedArray");var Jd=Ns;function Ds(t){return function(e){return t(e)}}l(Ds,"baseUnary");var Yd=Ds,Hs=typeof exports=="object"&&exports&&!exports.nodeType&&exports,It=Hs&&typeof module=="object"&&module&&!module.nodeType&&module,Xd=It&&It.exports===Hs,Fn=Xd&&ts.process,Qd=(function(){try{var t=It&&It.require&&It.require("util").types;return t||Fn&&Fn.binding&&Fn.binding("util")}catch{}})(),Pi=Qd,ki=Pi&&Pi.isTypedArray,ep=ki?Yd(ki):Jd,Ms=ep,tp=Object.prototype,np=tp.hasOwnProperty;function js(t,e){var n=we(t),r=!n&&As(t),i=!n&&!r&&ir(t),s=!n&&!r&&!i&&Ms(t),a=n||r||i||s,o=a?yd(t.length,String):[],u=o.length;for(var d in t)(e||np.call(t,d))&&!(a&&(d=="length"||i&&(d=="offset"||d=="parent")||s&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||_r(d,u)))&&o.push(d);return o}l(js,"arrayLikeKeys");var $s=js;function Us(t,e){return function(n){return t(e(n))}}l(Us,"overArg");var zs=Us,rp=zs(Object.keys,Object),ip=rp,sp=Object.prototype,ap=sp.hasOwnProperty;function Ks(t){if(!Es(t))return ip(t);var e=[];for(var n in Object(t))ap.call(t,n)&&n!="constructor"&&e.push(n);return e}l(Ks,"baseKeys");var op=Ks;function Ws(t){return Ss(t)?$s(t):op(t)}l(Ws,"keys");var wr=Ws;function Ls(t){var e=[];if(t!=null)for(var n in Object(t))e.push(n);return e}l(Ls,"nativeKeysIn");var lp=Ls,up=Object.prototype,cp=up.hasOwnProperty;function Fs(t){if(!at(t))return lp(t);var e=Es(t),n=[];for(var r in t)r=="constructor"&&(e||!cp.call(t,r))||n.push(r);return n}l(Fs,"baseKeysIn");var dp=Fs;function qs(t){return Ss(t)?$s(t,!0):dp(t)}l(qs,"keysIn");var pp=qs,fp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,gp=/^\w*$/;function Vs(t,e){if(we(t))return!1;var n=typeof t;return n=="number"||n=="symbol"||n=="boolean"||t==null||yr(t)?!0:gp.test(t)||!fp.test(t)||e!=null&&t in Object(e)}l(Vs,"isKey");var xr=Vs,mp=qe(Object,"create"),At=mp;function Gs(){this.__data__=At?At(null):{},this.size=0}l(Gs,"hashClear");var hp=Gs;function Js(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}l(Js,"hashDelete");var yp=Js,vp="__lodash_hash_undefined__",_p=Object.prototype,Tp=_p.hasOwnProperty;function Ys(t){var e=this.__data__;if(At){var n=e[t];return n===vp?void 0:n}return Tp.call(e,t)?e[t]:void 0}l(Ys,"hashGet");var bp=Ys,wp=Object.prototype,xp=wp.hasOwnProperty;function Xs(t){var e=this.__data__;return At?e[t]!==void 0:xp.call(e,t)}l(Xs,"hashHas");var Pp=Xs,kp="__lodash_hash_undefined__";function Qs(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=At&&e===void 0?kp:e,this}l(Qs,"hashSet");var Sp=Qs;function Ve(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}l(Ve,"Hash");Ve.prototype.clear=hp;Ve.prototype.delete=yp;Ve.prototype.get=bp;Ve.prototype.has=Pp;Ve.prototype.set=Sp;var Si=Ve;function ea(){this.__data__=[],this.size=0}l(ea,"listCacheClear");var Op=ea;function ta(t,e){for(var n=t.length;n--;)if(Tr(t[n][0],e))return n;return-1}l(ta,"assocIndexOf");var dn=ta,Ep=Array.prototype,Ip=Ep.splice;function na(t){var e=this.__data__,n=dn(e,t);if(n<0)return!1;var r=e.length-1;return n==r?e.pop():Ip.call(e,n,1),--this.size,!0}l(na,"listCacheDelete");var Bp=na;function ra(t){var e=this.__data__,n=dn(e,t);return n<0?void 0:e[n][1]}l(ra,"listCacheGet");var Cp=ra;function ia(t){return dn(this.__data__,t)>-1}l(ia,"listCacheHas");var Ap=ia;function sa(t,e){var n=this.__data__,r=dn(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}l(sa,"listCacheSet");var Zp=sa;function Ge(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}l(Ge,"ListCache");Ge.prototype.clear=Op;Ge.prototype.delete=Bp;Ge.prototype.get=Cp;Ge.prototype.has=Ap;Ge.prototype.set=Zp;var pn=Ge,Rp=qe(ke,"Map"),Zt=Rp;function aa(){this.size=0,this.__data__={hash:new Si,map:new(Zt||pn),string:new Si}}l(aa,"mapCacheClear");var Np=aa;function oa(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}l(oa,"isKeyable");var Dp=oa;function la(t,e){var n=t.__data__;return Dp(e)?n[typeof e=="string"?"string":"hash"]:n.map}l(la,"getMapData");var fn=la;function ua(t){var e=fn(this,t).delete(t);return this.size-=e?1:0,e}l(ua,"mapCacheDelete");var Hp=ua;function ca(t){return fn(this,t).get(t)}l(ca,"mapCacheGet");var Mp=ca;function da(t){return fn(this,t).has(t)}l(da,"mapCacheHas");var jp=da;function pa(t,e){var n=fn(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this}l(pa,"mapCacheSet");var $p=pa;function Je(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}l(Je,"MapCache");Je.prototype.clear=Np;Je.prototype.delete=Hp;Je.prototype.get=Mp;Je.prototype.has=jp;Je.prototype.set=$p;var gn=Je,Up="Expected a function";function mn(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(Up);var n=l(function(){var r=arguments,i=e?e.apply(this,r):r[0],s=n.cache;if(s.has(i))return s.get(i);var a=t.apply(this,r);return n.cache=s.set(i,a)||s,a},"memoized");return n.cache=new(mn.Cache||gn),n}l(mn,"memoize");mn.Cache=gn;var zp=mn,Kp=500;function fa(t){var e=zp(t,function(r){return n.size===Kp&&n.clear(),r}),n=e.cache;return e}l(fa,"memoizeCapped");var Wp=fa,Lp=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Fp=/\\(\\)?/g,qp=Wp(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(Lp,function(n,r,i,s){e.push(i?s.replace(Fp,"$1"):r||n)}),e}),Vp=qp;function ga(t){return t==null?"":Kc(t)}l(ga,"toString");var Gp=ga;function ma(t,e){return we(t)?t:xr(t,e)?[t]:Vp(Gp(t))}l(ma,"castPath");var hn=ma,Jp=1/0;function ha(t){if(typeof t=="string"||yr(t))return t;var e=t+"";return e=="0"&&1/t==-Jp?"-0":e}l(ha,"toKey");var $t=ha;function ya(t,e){e=hn(e,t);for(var n=0,r=e.length;t!=null&&n<r;)t=t[$t(e[n++])];return n&&n==r?t:void 0}l(ya,"baseGet");var Pr=ya;function va(t,e,n){var r=t==null?void 0:Pr(t,e);return r===void 0?n:r}l(va,"get");var Yp=va;function _a(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t}l(_a,"arrayPush");var Ta=_a,Xp=zs(Object.getPrototypeOf,Object),ba=Xp,Qp="[object Object]",ef=Function.prototype,tf=Object.prototype,wa=ef.toString,nf=tf.hasOwnProperty,rf=wa.call(Object);function xa(t){if(!Ke(t)||Le(t)!=Qp)return!1;var e=ba(t);if(e===null)return!0;var n=nf.call(e,"constructor")&&e.constructor;return typeof n=="function"&&n instanceof n&&wa.call(n)==rf}l(xa,"isPlainObject");var sf=xa;function Pa(){this.__data__=new pn,this.size=0}l(Pa,"stackClear");var af=Pa;function ka(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}l(ka,"stackDelete");var of=ka;function Sa(t){return this.__data__.get(t)}l(Sa,"stackGet");var lf=Sa;function Oa(t){return this.__data__.has(t)}l(Oa,"stackHas");var uf=Oa,cf=200;function Ea(t,e){var n=this.__data__;if(n instanceof pn){var r=n.__data__;if(!Zt||r.length<cf-1)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new gn(r)}return n.set(t,e),this.size=n.size,this}l(Ea,"stackSet");var df=Ea;function Ye(t){var e=this.__data__=new pn(t);this.size=e.size}l(Ye,"Stack");Ye.prototype.clear=af;Ye.prototype.delete=of;Ye.prototype.get=lf;Ye.prototype.has=uf;Ye.prototype.set=df;var Vt=Ye;function Ia(t,e){for(var n=-1,r=t==null?0:t.length,i=0,s=[];++n<r;){var a=t[n];e(a,n,t)&&(s[i++]=a)}return s}l(Ia,"arrayFilter");var pf=Ia;function Ba(){return[]}l(Ba,"stubArray");var Ca=Ba,ff=Object.prototype,gf=ff.propertyIsEnumerable,Oi=Object.getOwnPropertySymbols,mf=Oi?function(t){return t==null?[]:(t=Object(t),pf(Oi(t),function(e){return gf.call(t,e)}))}:Ca,Aa=mf,hf=Object.getOwnPropertySymbols,yf=hf?function(t){for(var e=[];t;)Ta(e,Aa(t)),t=ba(t);return e}:Ca,vf=yf;function Za(t,e,n){var r=e(t);return we(t)?r:Ta(r,n(t))}l(Za,"baseGetAllKeys");var Ra=Za;function Na(t){return Ra(t,wr,Aa)}l(Na,"getAllKeys");var Ei=Na;function Da(t){return Ra(t,pp,vf)}l(Da,"getAllKeysIn");var _f=Da,Tf=qe(ke,"DataView"),sr=Tf,bf=qe(ke,"Promise"),ar=bf,wf=qe(ke,"Set"),or=wf,Ii="[object Map]",xf="[object Object]",Bi="[object Promise]",Ci="[object Set]",Ai="[object WeakMap]",Zi="[object DataView]",Pf=Fe(sr),kf=Fe(Zt),Sf=Fe(ar),Of=Fe(or),Ef=Fe(rr),De=Le;(sr&&De(new sr(new ArrayBuffer(1)))!=Zi||Zt&&De(new Zt)!=Ii||ar&&De(ar.resolve())!=Bi||or&&De(new or)!=Ci||rr&&De(new rr)!=Ai)&&(De=l(function(t){var e=Le(t),n=e==xf?t.constructor:void 0,r=n?Fe(n):"";if(r)switch(r){case Pf:return Zi;case kf:return Ii;case Sf:return Bi;case Of:return Ci;case Ef:return Ai}return e},"getTag"));var Ri=De,If=ke.Uint8Array,Ni=If,Bf="__lodash_hash_undefined__";function Ha(t){return this.__data__.set(t,Bf),this}l(Ha,"setCacheAdd");var Cf=Ha;function Ma(t){return this.__data__.has(t)}l(Ma,"setCacheHas");var Af=Ma;function Rt(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new gn;++e<n;)this.add(t[e])}l(Rt,"SetCache");Rt.prototype.add=Rt.prototype.push=Cf;Rt.prototype.has=Af;var Zf=Rt;function ja(t,e){for(var n=-1,r=t==null?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}l(ja,"arraySome");var Rf=ja;function $a(t,e){return t.has(e)}l($a,"cacheHas");var Nf=$a,Df=1,Hf=2;function Ua(t,e,n,r,i,s){var a=n&Df,o=t.length,u=e.length;if(o!=u&&!(a&&u>o))return!1;var d=s.get(t),p=s.get(e);if(d&&p)return d==e&&p==t;var g=-1,h=!0,w=n&Hf?new Zf:void 0;for(s.set(t,e),s.set(e,t);++g<o;){var T=t[g],D=e[g];if(r)var F=a?r(D,T,g,e,t,s):r(T,D,g,t,e,s);if(F!==void 0){if(F)continue;h=!1;break}if(w){if(!Rf(e,function(J,oe){if(!Nf(w,oe)&&(T===J||i(T,J,n,r,s)))return w.push(oe)})){h=!1;break}}else if(!(T===D||i(T,D,n,r,s))){h=!1;break}}return s.delete(t),s.delete(e),h}l(Ua,"equalArrays");var za=Ua;function Ka(t){var e=-1,n=Array(t.size);return t.forEach(function(r,i){n[++e]=[i,r]}),n}l(Ka,"mapToArray");var Mf=Ka;function Wa(t){var e=-1,n=Array(t.size);return t.forEach(function(r){n[++e]=r}),n}l(Wa,"setToArray");var jf=Wa,$f=1,Uf=2,zf="[object Boolean]",Kf="[object Date]",Wf="[object Error]",Lf="[object Map]",Ff="[object Number]",qf="[object RegExp]",Vf="[object Set]",Gf="[object String]",Jf="[object Symbol]",Yf="[object ArrayBuffer]",Xf="[object DataView]",Di=Be?Be.prototype:void 0,qn=Di?Di.valueOf:void 0;function La(t,e,n,r,i,s,a){switch(n){case Xf:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case Yf:return!(t.byteLength!=e.byteLength||!s(new Ni(t),new Ni(e)));case zf:case Kf:case Ff:return Tr(+t,+e);case Wf:return t.name==e.name&&t.message==e.message;case qf:case Gf:return t==e+"";case Lf:var o=Mf;case Vf:var u=r&$f;if(o||(o=jf),t.size!=e.size&&!u)return!1;var d=a.get(t);if(d)return d==e;r|=Uf,a.set(t,e);var p=za(o(t),o(e),r,i,s,a);return a.delete(t),p;case Jf:if(qn)return qn.call(t)==qn.call(e)}return!1}l(La,"equalByTag");var Qf=La,eg=1,tg=Object.prototype,ng=tg.hasOwnProperty;function Fa(t,e,n,r,i,s){var a=n&eg,o=Ei(t),u=o.length,d=Ei(e),p=d.length;if(u!=p&&!a)return!1;for(var g=u;g--;){var h=o[g];if(!(a?h in e:ng.call(e,h)))return!1}var w=s.get(t),T=s.get(e);if(w&&T)return w==e&&T==t;var D=!0;s.set(t,e),s.set(e,t);for(var F=a;++g<u;){h=o[g];var J=t[h],oe=e[h];if(r)var le=a?r(oe,J,h,e,t,s):r(J,oe,h,t,e,s);if(!(le===void 0?J===oe||i(J,oe,n,r,s):le)){D=!1;break}F||(F=h=="constructor")}if(D&&!F){var H=t.constructor,Ee=e.constructor;H!=Ee&&"constructor"in t&&"constructor"in e&&!(typeof H=="function"&&H instanceof H&&typeof Ee=="function"&&Ee instanceof Ee)&&(D=!1)}return s.delete(t),s.delete(e),D}l(Fa,"equalObjects");var rg=Fa,ig=1,Hi="[object Arguments]",Mi="[object Array]",Ft="[object Object]",sg=Object.prototype,ji=sg.hasOwnProperty;function qa(t,e,n,r,i,s){var a=we(t),o=we(e),u=a?Mi:Ri(t),d=o?Mi:Ri(e);u=u==Hi?Ft:u,d=d==Hi?Ft:d;var p=u==Ft,g=d==Ft,h=u==d;if(h&&ir(t)){if(!ir(e))return!1;a=!0,p=!1}if(h&&!p)return s||(s=new Vt),a||Ms(t)?za(t,e,n,r,i,s):Qf(t,e,u,n,r,i,s);if(!(n&ig)){var w=p&&ji.call(t,"__wrapped__"),T=g&&ji.call(e,"__wrapped__");if(w||T){var D=w?t.value():t,F=T?e.value():e;return s||(s=new Vt),i(D,F,n,r,s)}}return h?(s||(s=new Vt),rg(t,e,n,r,i,s)):!1}l(qa,"baseIsEqualDeep");var ag=qa;function kr(t,e,n,r,i){return t===e?!0:t==null||e==null||!Ke(t)&&!Ke(e)?t!==t&&e!==e:ag(t,e,n,r,kr,i)}l(kr,"baseIsEqual");var yn=kr,og=1,lg=2;function Va(t,e,n,r){var i=n.length,s=i,a=!r;if(t==null)return!s;for(t=Object(t);i--;){var o=n[i];if(a&&o[2]?o[1]!==t[o[0]]:!(o[0]in t))return!1}for(;++i<s;){o=n[i];var u=o[0],d=t[u],p=o[1];if(a&&o[2]){if(d===void 0&&!(u in t))return!1}else{var g=new Vt;if(r)var h=r(d,p,u,t,e,g);if(!(h===void 0?yn(p,d,og|lg,r,g):h))return!1}}return!0}l(Va,"baseIsMatch");var ug=Va;function Ga(t){return t===t&&!at(t)}l(Ga,"isStrictComparable");var Ja=Ga;function Ya(t){for(var e=wr(t),n=e.length;n--;){var r=e[n],i=t[r];e[n]=[r,i,Ja(i)]}return e}l(Ya,"getMatchData");var cg=Ya;function Xa(t,e){return function(n){return n==null?!1:n[t]===e&&(e!==void 0||t in Object(n))}}l(Xa,"matchesStrictComparable");var Qa=Xa;function eo(t){var e=cg(t);return e.length==1&&e[0][2]?Qa(e[0][0],e[0][1]):function(n){return n===t||ug(n,t,e)}}l(eo,"baseMatches");var dg=eo;function to(t,e){return t!=null&&e in Object(t)}l(to,"baseHasIn");var pg=to;function no(t,e,n){e=hn(e,t);for(var r=-1,i=e.length,s=!1;++r<i;){var a=$t(e[r]);if(!(s=t!=null&&n(t,a)))break;t=t[a]}return s||++r!=i?s:(i=t==null?0:t.length,!!i&&br(i)&&_r(a,i)&&(we(t)||As(t)))}l(no,"hasPath");var fg=no;function ro(t,e){return t!=null&&fg(t,e,pg)}l(ro,"hasIn");var gg=ro,mg=1,hg=2;function io(t,e){return xr(t)&&Ja(e)?Qa($t(t),e):function(n){var r=Yp(n,t);return r===void 0&&r===e?gg(n,t):yn(e,r,mg|hg)}}l(io,"baseMatchesProperty");var yg=io;function so(t){return function(e){return e?.[t]}}l(so,"baseProperty");var vg=so;function ao(t){return function(e){return Pr(e,t)}}l(ao,"basePropertyDeep");var _g=ao;function oo(t){return xr(t)?vg($t(t)):_g(t)}l(oo,"property");var Tg=oo;function lo(t){return typeof t=="function"?t:t==null?Wc:typeof t=="object"?we(t)?yg(t[0],t[1]):dg(t):Tg(t)}l(lo,"baseIteratee");var Sr=lo;function uo(t){return function(e,n,r){for(var i=-1,s=Object(e),a=r(e),o=a.length;o--;){var u=a[t?o:++i];if(n(s[u],u,s)===!1)break}return e}}l(uo,"createBaseFor");var bg=uo,wg=bg(),xg=wg;function co(t,e){return t&&xg(t,e,wr)}l(co,"baseForOwn");var Pg=co;function po(t,e){return yn(t,e)}l(po,"isEqual");var Ie=po;function fo(t,e,n){n=typeof n=="function"?n:void 0;var r=n?n(t,e):void 0;return r===void 0?yn(t,e,void 0,n):!!r}l(fo,"isEqualWith");var kg=fo;function go(t){return t===void 0}l(go,"isUndefined");var $i=go;function mo(t,e){var n={};return e=Sr(e,3),Pg(t,function(r,i,s){bs(n,i,e(r,i,s))}),n}l(mo,"mapValues");var Sg=mo,Og="Expected a function";function ho(t){if(typeof t!="function")throw new TypeError(Og);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}l(ho,"negate");var Eg=ho;function yo(t,e,n,r){if(!at(t))return t;e=hn(e,t);for(var i=-1,s=e.length,a=s-1,o=t;o!=null&&++i<s;){var u=$t(e[i]),d=n;if(u==="__proto__"||u==="constructor"||u==="prototype")return t;if(i!=a){var p=o[u];d=r?r(p,u,o):void 0,d===void 0&&(d=at(p)?p:_r(e[i+1])?[]:{})}gd(o,u,d),o=o[u]}return t}l(yo,"baseSet");var Ig=yo;function vo(t,e,n){for(var r=-1,i=e.length,s={};++r<i;){var a=e[r],o=Pr(t,a);n(o,a)&&Ig(s,hn(a,t),o)}return s}l(vo,"basePickBy");var Bg=vo;function _o(t,e){if(t==null)return{};var n=us(_f(t),function(r){return[r]});return e=Sr(e),Bg(t,n,function(r,i){return e(r,i[0])})}l(_o,"pickBy");var Cg=_o;function To(t,e){return Cg(t,Eg(Sr(e)))}l(To,"omitBy");var Ui=To,bo=l((t,e)=>wo(t,e,new WeakSet),"isEqual"),zi=l(t=>sf(t),"_isPlainObject"),wo=l((t,e,n)=>kg(t,e,Ag(n)),"_isEqualWithVisitedTracking"),Ag=l(t=>(e,n)=>{if(zi(e)&&!t.has(e)&&zi(n)&&!t.has(n)){let r=Ui(e,$i),i=Ui(n,$i);return t.add(r).add(i).add(e).add(n),wo(r,i,t)}},"_customizerWithVisitedTracking"),Zg=l(t=>Array.from(new Set(t)),"unique"),Rg={compare:bo},xo=class{constructor(e=[],n={}){this._options=c(c({},Rg),n),this._items=[];for(let r of e)this.add(r)}get items(){return[...this._items]}get size(){return this._items.length}has(e){return this._items.some(n=>this._options.compare(n,e))}add(e){this.has(e)||this._items.push(e)}isEqual(e){return this.size!==e.size?!1:this.isSubsetOf(e)&&e.isSubsetOf(this)}isSubsetOf(e){return this.size>e.size?!1:this._items.every(n=>e.has(n))}};l(xo,"CustomSet");var Ng=xo,_={};de(_,{errToObj:()=>Dg,toString:()=>Hg});var Dg=l(t=>typeof t=="string"?{message:t}:t||{},"errToObj"),Hg=l(t=>typeof t=="string"?t:t?.message,"toString"),ce={};de(ce,{assertNever:()=>Po});function Po(t){throw new Error("assertNever called")}l(Po,"assertNever");var ue={};de(ue,{compareFunctions:()=>jg,joinValues:()=>ko,jsonStringifyReplacer:()=>Mg});function ko(t,e=" | "){return t.map(n=>typeof n=="string"?`'${n}'`:n).join(e)}l(ko,"joinValues");var Mg=l((t,e)=>typeof e=="bigint"?e.toString():e,"jsonStringifyReplacer"),jg=l((t,e)=>t.toString()===e.toString(),"compareFunctions"),So={};de(So,{extractPrecisionAndOffset:()=>Eo,generateDatetimeRegex:()=>Oo});var Oo=l(t=>{let e=t.precision?lr+t.precision+Ug:t.precision===0?"":Co,n=t.offset?Bo:$g;return new RegExp(`^${Io}${e}${n}$`)},"generateDatetimeRegex"),Eo=l(t=>({precision:zg(t),offset:t.endsWith(`${Bo}$`)}),"extractPrecisionAndOffset"),Io="\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}",Bo="(([+-]\\d{2}(:?\\d{2})?)|Z)",$g="Z",Co="(\\.\\d+)?",lr="\\.\\d{",Ug="}",zg=l(t=>{let e=t.slice(1+Io.length);return e.startsWith(Co)?null:e.startsWith(lr)?parseInt(e.slice(lr.length)):0},"_extractPrecision"),sn=l((t,e)=>{let n;switch(t.code){case"invalid_type":t.received==="undefined"?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case"invalid_literal":n=`Invalid literal value, expected ${JSON.stringify(t.expected,ue.jsonStringifyReplacer)}`;break;case"unrecognized_keys":n=`Unrecognized key(s) in object: ${ue.joinValues(t.keys,", ")}`;break;case"invalid_union":n="Invalid input";break;case"invalid_union_discriminator":n=`Invalid discriminator value. Expected ${ue.joinValues(t.options)}`;break;case"invalid_enum_value":n=`Invalid enum value. Expected ${ue.joinValues(t.options)}, received '${t.received}'`;break;case"invalid_arguments":n="Invalid function arguments";break;case"invalid_return_type":n="Invalid function return type";break;case"invalid_date":n="Invalid date";break;case"invalid_string":typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:ce.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case"too_small":t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case"too_big":t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case"custom":n="Invalid input";break;case"invalid_intersection_types":n="Intersection results could not be merged";break;case"not_multiple_of":n=`Number must be a multiple of ${t.multipleOf}`;break;case"not_finite":n="Number must be finite";break;case"unresolved_reference":n="Unresolved reference";break;default:n=e.defaultError,ce.assertNever(t)}return{message:n}},"errorMap"),an=class Ao extends Error{constructor(e){super(),this.__type__="ZuiError",this.issues=[],this.addIssue=l(r=>{this.issues=[...this.issues,r]},"addIssue"),this.addIssues=l((r=[])=>{this.issues=[...this.issues,...r]},"addIssues");let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let n=e||function(s){return s.message},r={_errors:[]},i=l(s=>{for(let a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let o=r,u=0;for(;u<a.path.length;){let d=a.path[u];u===a.path.length-1?(o[d]=o[d]||{_errors:[]},o[d]._errors.push(n(a))):o[d]=o[d]||{_errors:[]},o=o[d],u++}}},"processError");return i(this),r}static assert(e){if(!(e instanceof Ao))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ue.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}};l(an,"ZodError");an.create=l(t=>new an(t),"create");var be=an,Kg=sn;function on(){return Kg}l(on,"getErrorMap");var A={};function Zo(t){Object.assign(A,t)}l(Zo,"setBuilders");var ur=l(t=>{var e;let{data:n,path:r,errorMaps:i,issueData:s}=t,a=[...r,...s.path||[]],o=f(c({},s),{path:a}),u="",d=i.filter(p=>!!p).slice().reverse();for(let p of d)u=p(o,{data:n,defaultError:u}).message;return f(c({},s),{path:a,message:(e=s.message)!=null?e:u})},"makeIssue");function m(t,e){let n=ur({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,on(),sn].filter(r=>!!r)});t.common.issues.push(n)}l(m,"addIssueToContext");var Ro=class No{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let i of n){if(i.status==="aborted")return{status:"aborted"};i.status==="dirty"&&e.dirty(),r.push(i.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let i of n)r.push({key:await i.key,value:await i.value});return No.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let i of n){let{key:s,value:a}=i;if(s.status==="aborted")return{status:"aborted"};if(a.status==="aborted")return{status:"aborted"};s.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(r[s.value]=a.value)}return{status:e.value,value:r}}};l(Ro,"ParseStatus");var ne=Ro,ln=l(t=>typeof Promise<"u"&&t instanceof Promise,"isAsync"),$e=l(t=>{switch(typeof t){case"undefined":return"undefined";case"string":return"string";case"number":return isNaN(t)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(t)?"array":t===null?"null":typeof Promise<"u"&&t instanceof Promise||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"),Do=class{constructor(e,n,r,i){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};l(Do,"ParseInputLazyPath");var ge=Do,Ho=class extends Error{constructor(e){super(`Cannot access property ${e} before initialization. You're probably importing ZUI incorrectly. If not, reach out to the maintainers.`)}};l(Ho,"_CircularDependencyError");var Vn=Ho,Mo=class{constructor(e){this.__type__="ZuiType",this.spa=this.safeParseAsync,this._handleResult=l((n,r)=>{if(r.status==="valid")return{success:!0,data:r.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let i=new be(n.common.issues);return this._error=i,this._error}}},"_handleResult"),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.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),this.downstream=this.downstream.bind(this)}get description(){return this._metadataRoot._def.description}get typeName(){return this._def.typeName}dereference(e){return this}getReferences(){return[]}clone(){let e=this.constructor;return new e(c({},this._def))}_getType(e){return $e(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:$e(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ne,ctx:{common:e.parent.common,data:e.data,parsedType:$e(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(ln(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){var r;let i={common:{issues:[],async:(r=n?.async)!=null?r:!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$e(e)},s=this._parseSync({data:e,path:i.path,parent:i});return this._handleResult(i,s)}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$e(e)},i=this._parse({data:e,path:r.path,parent:r}),s=await(ln(i)?i:Promise.resolve(i));return this._handleResult(r,s)}refine(e,n){let r=l(i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n,"getIssueProperties");return A.downstream(this,i=>{let s=e(i),a=[],o=l(()=>a.push(c({code:"custom"},r(i))),"setError");return typeof Promise<"u"&&s instanceof Promise?s.then(u=>u?{status:"valid",value:i}:(o(),{status:"dirty",value:i,issues:a})):s?{status:"valid",value:i}:(o(),{status:"dirty",value:i,issues:a})})}superRefine(e){return A.downstream(this,(n,r)=>{let i=[],s=e(n,{addIssue:a=>i.push(a),path:r.path});return typeof Promise<"u"&&s instanceof Promise?s.then(()=>i.some(a=>a.fatal)?{status:"aborted",issues:i}:i.length?{status:"dirty",value:n,issues:i}:{status:"valid",value:n}):i.some(a=>a.fatal)?{status:"aborted",issues:i}:i.length?{status:"dirty",value:n,issues:i}:{status:"valid",value:n}})}downstream(e,n){return A.downstream(this,e,n)}optional(){return A.optional(this,this._def)}nullable(){return A.nullable(this,this._def)}nullish(){return this.nullable().optional()}array(){return A.array(this,this._def)}promise(){return A.promise(this,this._def)}mandatory(){return this}or(e){return A.union([this,e])}and(e){return A.intersection(this,e)}transform(e){return A.downstream(this,(n,r)=>{let i=[],s=e(n,{addIssue:a=>i.push(a),path:r.path});return s instanceof Promise?s.then(a=>i.some(o=>o.fatal)?{status:"aborted",issues:i}:i.length?{status:"dirty",value:a,issues:i}:{status:"valid",value:a}):i.some(a=>a.fatal)?{status:"aborted",issues:i}:i.length?{status:"dirty",value:s,issues:i}:{status:"valid",value:s}},{failFast:!0})}default(e){let n=typeof e=="function"?e:()=>e;return A.default(this,n)}brand(){return A.branded(this)}catch(e){return A.catch(this,e)}describe(e){let n=this.clone();return n._metadataRoot._def.description=e,n}pipe(e){return A.pipeline(this,e)}readonly(){return A.readonly(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}metadata(e){var n,r,i;let s=this.clone(),a=s._metadataRoot;(i=(n=a._def)[r=B])!=null||(n[r]={});for(let[o,u]of Object.entries(e))a._def[B]=f(c({},a._def[B]),{[o]:u});return s}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 n;return e===void 0?n=!0:typeof e=="function"?n=e.toString():n=e,this.metadata({hidden:n})}disabled(e){let n;return e===void 0?n=!0:typeof e=="function"?n=e.toString():n=e,this.metadata({disabled:n})}placeholder(e){return this.metadata({placeholder:e})}toJSONSchema(e){throw new Vn("toJSONSchema")}toTypescriptType(e){throw new Vn("toTypescriptType")}toTypescriptSchema(){throw new Vn("toTypescriptSchema")}naked(){return this}};l(Mo,"ZodBaseTypeImpl");var P=Mo,jo=class $o extends P{constructor(){super(...arguments),this._any=!0}_parse(e){return{status:"valid",value:e.data}}isEqual(e){return e instanceof $o}};l(jo,"ZodAnyImpl");var Wg=jo,Uo=class He extends P{dereference(e){return new He(f(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new He(f(c({},this._def),{type:this._def.type.clone()}))}isEqual(e){var n,r,i,s,a,o;return e instanceof He?Ie((n=this._def.exactLength)==null?void 0:n.value,(r=e._def.exactLength)==null?void 0:r.value)&&Ie((i=this._def.maxLength)==null?void 0:i.value,(s=e._def.maxLength)==null?void 0:s.value)&&Ie((a=this._def.minLength)==null?void 0:a.value,(o=e._def.minLength)==null?void 0:o.value)&&this._def.type.isEqual(e._def.type):!1}_parse(e){let{ctx:n,status:r}=this._processInputParams(e),i=this._def;if(n.parsedType!=="array")return m(n,{code:"invalid_type",expected:"array",received:n.parsedType}),{status:"aborted"};if(i.exactLength!==null){let a=n.data.length>i.exactLength.value,o=n.data.length<i.exactLength.value;(a||o)&&(m(n,{code:a?"too_big":"too_small",minimum:o?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(m(n,{code:"too_small",minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(m(n,{code:"too_big",maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((a,o)=>i.type._parseAsync(new ge(n,a,n.path,o)))).then(a=>ne.mergeArray(r,a));let s=[...n.data].map((a,o)=>i.type._parseSync(new ge(n,a,n.path,o)));return ne.mergeArray(r,s)}get element(){return this._def.type}min(e,n){return new He(f(c({},this._def),{minLength:{value:e,message:_.toString(n)}}))}max(e,n){return new He(f(c({},this._def),{maxLength:{value:e,message:_.toString(n)}}))}length(e,n){return new He(f(c({},this._def),{exactLength:{value:e,message:_.toString(n)}}))}nonempty(e){return this.min(1,e)}};l(Uo,"ZodArrayImpl");var Lg=Uo,zo=class Gt extends P{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!=="bigint"){let s=this._getOrReturnCtx(e);return m(s,{code:"invalid_type",expected:"bigint",received:s.parsedType}),{status:"aborted"}}let r,i=new ne;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:"too_small",type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:"too_big",type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),m(r,{code:"not_multiple_of",multipleOf:s.value,message:s.message}),i.dirty()):ce.assertNever(s);return{status:i.value,value:e.data}}isEqual(e){if(!(e instanceof Gt)||this._def.coerce!==e._def.coerce)return!1;let n=new $.CustomSet(this._def.checks),r=new $.CustomSet(e._def.checks);return n.isEqual(r)}gte(e,n){return this.setLimit("min",e,!0,_.toString(n))}gt(e,n){return this.setLimit("min",e,!1,_.toString(n))}lte(e,n){return this.setLimit("max",e,!0,_.toString(n))}lt(e,n){return this.setLimit("max",e,!1,_.toString(n))}setLimit(e,n,r,i){return new Gt(f(c({},this._def),{checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:_.toString(i)}]}))}_addCheck(e){return new Gt(f(c({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:_.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};l(zo,"ZodBigIntImpl");var Fg=zo,Ko=class Wo extends P{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!=="boolean"){let r=this._getOrReturnCtx(e);return m(r,{code:"invalid_type",expected:"boolean",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof Wo?this._def.coerce===e._def.coerce:!1}};l(Ko,"ZodBooleanImpl");var qg=Ko,Lo=class yt extends P{dereference(e){return new yt(f(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new yt(f(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}isEqual(e){return e instanceof yt?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}mandatory(){return new yt(f(c({},this._def),{type:this._def.type.mandatory()}))}};l(Lo,"ZodBrandedImpl");var Vg=Lo,Fo=class vt extends P{_parse(e){let{ctx:n}=this._processInputParams(e),r=f(c({},n),{common:f(c({},n.common),{issues:[]})}),i=this._def.innerType._parse({data:r.data,path:r.path,parent:c({},r)});return ln(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new be(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new be(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}isEqual(e){return e instanceof vt?this._def.innerType.isEqual(e._def.innerType)&&ue.compareFunctions(this._def.catchValue,e._def.catchValue):!1}dereference(e){return new vt(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new vt(f(c({},this._def),{innerType:this._def.innerType.clone()}))}naked(){return this._def.innerType.naked()}mandatory(){return new vt(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};l(Fo,"ZodCatchImpl");var Gg=Fo,qo=class cr extends P{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!=="date"){let s=this._getOrReturnCtx(e);return m(s,{code:"invalid_type",expected:"date",received:s.parsedType}),{status:"aborted"}}if(isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return m(s,{code:"invalid_date"}),{status:"aborted"}}let r=new ne,i;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),m(i,{code:"too_small",message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),m(i,{code:"too_big",message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):ce.assertNever(s);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new cr(f(c({},this._def),{checks:[...this._def.checks,e]}))}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:_.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:_.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}isEqual(e){if(!(e instanceof cr))return!1;let n=new $.CustomSet(this._def.checks),r=new $.CustomSet(e._def.checks);return n.isEqual(r)&&this._def.coerce===e._def.coerce}};l(qo,"ZodDateImpl");var Jg=qo,Vo=class _t extends P{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType==="undefined"&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}dereference(e){return new _t(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new _t(f(c({},this._def),{innerType:this._def.innerType.clone()}))}isEqual(e){return e instanceof _t?this._def.innerType.isEqual(e._def.innerType)&&Ie(this._def.defaultValue(),e._def.defaultValue()):!1}unwrap(){return this._def.innerType}naked(){return this._def.innerType.naked()}mandatory(){return new _t(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};l(Vo,"ZodDefaultImpl");var Yg=Vo,Te=l(t=>{let e=t;return e?e.typeName==="ZodLazy"?Te(e.schema):e.typeName==="ZodEffects"?Te(e.innerType()):e.typeName==="ZodLiteral"?[e.value]:e.typeName==="ZodEnum"?e.options:e.typeName==="ZodNativeEnum"?Object.values(e.enum):e.typeName==="ZodDefault"?Te(e._def.innerType):e.typeName==="ZodUndefined"?[void 0]:e.typeName==="ZodNull"?[null]:e.typeName==="ZodOptional"?[void 0,...Te(e.unwrap())]:e.typeName==="ZodNullable"?[null,...Te(e.unwrap())]:e.typeName==="ZodBranded"||e.typeName==="ZodReadonly"?Te(e.unwrap()):e.typeName==="ZodCatch"?Te(e._def.innerType):[]:[]},"getDiscriminator"),Go=class Tt extends P{constructor(e){let n=Tt._getOptionsMap(e.discriminator,e.options);super(f(c({},e),{optionsMap:n}))}dereference(e){let n=this.options.map(r=>r.dereference(e));return new Tt(f(c({},this._def),{options:n}))}getReferences(){return me.unique(this.options.flatMap(e=>e.getReferences()))}clone(){let e=this.options.map(n=>n.clone());return new Tt(f(c({},this._def),{options:e}))}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!=="object")return m(n,{code:"invalid_type",expected:"object",received:n.parsedType}),{status:"aborted"};let r=this.discriminator,i=n.data[r],s=this.optionsMap.get(i);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(m(n,{code:"invalid_union_discriminator",options:Array.from(this.optionsMap.keys()),path:[r]}),{status:"aborted"})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static _getOptionsMap(e,n){let r=new Map;for(let i of n){let s=Te(i.shape[e]);if(!s.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of s){if(r.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);r.set(a,i)}}return r}isEqual(e){if(!(e instanceof Tt)||this._def.discriminator!==e._def.discriminator)return!1;let n=l((s,a)=>s.isEqual(a),"compare"),r=new $.CustomSet(this._def.options,{compare:n}),i=new $.CustomSet(e._def.options,{compare:n});return r.isEqual(i)}};l(Go,"ZodDiscriminatedUnionImpl");var Xg=Go,Jo=class Yo extends P{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return m(n,{expected:ue.joinValues(r),received:n.parsedType,code:"invalid_type"}),{status:"aborted"}}if(this._def.values.indexOf(e.data)===-1){let n=this._getOrReturnCtx(e),r=this._def.values;return m(n,{received:n.data,code:"invalid_enum_value",options:r}),{status:"aborted"}}return{status:"valid",value:e.data}}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){return this.enum}get Enum(){return this.enum}extract(e,n=this._def){return A.enum(e,c(c({},this._def),n))}exclude(e,n=this._def){return A.enum(this.options.filter(r=>!e.includes(r)),c(c({},this._def),n))}isEqual(e){if(!(e instanceof Yo))return!1;let n=new $.CustomSet(this._def.values),r=new $.CustomSet(e._def.values);return n.isEqual(r)}};l(Jo,"ZodEnumImpl");var Qg=Jo,Xo=class nt extends P{constructor(){super(...arguments),this.validate=this.implement}dereference(e){let n=this._def.args.dereference(e),r=this._def.returns.dereference(e);return new nt(f(c({},this._def),{args:n,returns:r}))}getReferences(){return me.unique([...this._def.args.getReferences(),...this._def.returns.getReferences()])}clone(){return new nt(f(c({},this._def),{args:this._def.args.clone(),returns:this._def.returns.clone()}))}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!=="function")return m(n,{code:"invalid_type",expected:"function",received:n.parsedType}),{status:"aborted"};function r(d,p){return ur({data:d,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,on(),sn].filter(g=>!!g),issueData:{code:"invalid_arguments",argumentsError:p}})}l(r,"makeArgsIssue");function i(d,p){return ur({data:d,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,on(),sn].filter(g=>!!g),issueData:{code:"invalid_return_type",returnTypeError:p}})}l(i,"makeReturnsIssue");let s={errorMap:n.common.contextualErrorMap},a=n.data,o=this,u=this._def.returns;return K.zuiPromise(u)?{status:"valid",async value(...d){let p=new be([]),g=await o._def.args.parseAsync(d,s).catch(T=>{throw p.addIssue(r(d,T)),p}),h=await Reflect.apply(a,this,g);return await u._def.type.parseAsync(h,s).catch(T=>{throw K.zuiError(T)?(p.addIssue(i(h,T)),p):T})}}:{status:"valid",value(...d){let p=o._def.args.safeParse(d,s);if(!p.success)throw new be([r(d,p.error)]);let g=Reflect.apply(a,this,p.data),h=o._def.returns.safeParse(g,s);if(!h.success)throw new be([i(g,h.error)]);return h.data}}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new nt(f(c({},this._def),{args:A.tuple(e).rest(A.unknown())}))}returns(e){return new nt(f(c({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}isEqual(e){return e instanceof nt&&this._def.args.isEqual(e._def.args)&&this._def.returns.isEqual(e._def.returns)}};l(Xo,"ZodFunctionImpl");var em=Xo,Qo=class Jt extends P{dereference(e){return new Jt(f(c({},this._def),{left:this._def.left.dereference(e),right:this._def.right.dereference(e)}))}getReferences(){return me.unique([...this._def.left.getReferences(),...this._def.right.getReferences()])}clone(){return new Jt(f(c({},this._def),{left:this._def.left.clone(),right:this._def.right.clone()}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),i=l((s,a)=>{if(s.status==="aborted"||a.status==="aborted")return{status:"aborted"};let o=this._mergeValues(s.value,a.value);return o.valid?((s.status==="dirty"||a.status==="dirty")&&n.dirty(),{status:n.value,value:o.data}):(m(r,{code:"invalid_intersection_types"}),{status:"aborted"})},"handleParsed");return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,a])=>i(s,a)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}isEqual(e){if(!(e instanceof Jt))return!1;let n=l((s,a)=>s.isEqual(a),"compare"),r=new $.CustomSet([this._def.left,this._def.right],{compare:n}),i=new $.CustomSet([e._def.left,e._def.right],{compare:n});return r.isEqual(i)}_mergeValues(e,n){let r=$e(e),i=$e(n);if(e===n)return{valid:!0,data:e};if(r==="object"&&i==="object"){let s=Object.keys(n),a=Object.keys(e).filter(u=>s.indexOf(u)!==-1),o=c(c({},e),n);for(let u of a){let d=this._mergeValues(e[u],n[u]);if(!d.valid)return{valid:!1};o[u]=d.data}return{valid:!0,data:o}}else if(r==="array"&&i==="array"){if(e.length!==n.length)return{valid:!1};let s=[];for(let a=0;a<e.length;a++){let o=e[a],u=n[a],d=this._mergeValues(o,u);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return r==="date"&&i==="date"&&+e==+n?{valid:!0,data:e}:{valid:!1}}};l(Qo,"ZodIntersectionImpl");var tm=Qo,el=class bt extends P{get schema(){return this._def.getter()}dereference(e){return new bt(f(c({},this._def),{getter:()=>this._def.getter().dereference(e)}))}getReferences(){return this._def.getter().getReferences()}clone(){return new bt(f(c({},this._def),{getter:()=>this._def.getter().clone()}))}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}isEqual(e){return e instanceof bt?this._def.getter().isEqual(e._def.getter()):!1}naked(){return this._def.getter().naked()}mandatory(){return new bt(f(c({},this._def),{getter:()=>this._def.getter().mandatory()}))}};l(el,"ZodLazyImpl");var nm=el,tl=class nl extends P{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return m(n,{received:n.data,code:"invalid_literal",expected:this._def.value}),{status:"aborted"}}return{status:"valid",value:e.data}}get value(){return this._def.value}isEqual(e){return e instanceof nl?Ie(this._def.value,e._def.value):!1}};l(tl,"ZodLiteralImpl");var rm=tl,rl=class Yt extends P{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}dereference(e){let n=this._def.keyType.dereference(e),r=this._def.valueType.dereference(e);return new Yt(f(c({},this._def),{keyType:n,valueType:r}))}getReferences(){return me.unique([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new Yt(f(c({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!=="map")return m(r,{code:"invalid_type",expected:"map",received:r.parsedType}),{status:"aborted"};let i=this._def.keyType,s=this._def.valueType,a=[...r.data.entries()].map(([o,u],d)=>({key:i._parse(new ge(r,o,r.path,[d,"key"])),value:s._parse(new ge(r,u,r.path,[d,"value"]))}));if(r.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let u of a){let d=await u.key,p=await u.value;if(d.status==="aborted"||p.status==="aborted")return{status:"aborted"};(d.status==="dirty"||p.status==="dirty")&&n.dirty(),o.set(d.value,p.value)}return{status:n.value,value:o}})}else{let o=new Map;for(let u of a){let d=u.key,p=u.value;if(d.status==="aborted"||p.status==="aborted")return{status:"aborted"};(d.status==="dirty"||p.status==="dirty")&&n.dirty(),o.set(d.value,p.value)}return{status:n.value,value:o}}}isEqual(e){return!(!(e instanceof Yt)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};l(rl,"ZodMapImpl");var im=rl,il=class sl extends P{_parse(e){if(this._getType(e)!=="nan"){let r=this._getOrReturnCtx(e);return m(r,{code:"invalid_type",expected:"nan",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof sl}};l(il,"ZodNaNImpl");var sm=il,al=class ol extends P{constructor(){super(...arguments),this._getValidEnumValues=l(e=>{let n=Object.keys(e).filter(i=>typeof e[e[i]]!="number"),r={};for(let i of n)r[i]=e[i];return Object.values(r)},"_getValidEnumValues")}_parse(e){let n=this._getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!=="string"&&r.parsedType!=="number"){let i=Object.values(n);return m(r,{expected:ue.joinValues(i),received:r.parsedType,code:"invalid_type"}),{status:"aborted"}}if(n.indexOf(e.data)===-1){let i=Object.values(n);return m(r,{received:r.data,code:"invalid_enum_value",options:i}),{status:"aborted"}}return{status:"valid",value:e.data}}get enum(){return this._def.values}isEqual(e){return e instanceof ol?Ie(this._def.values,e._def.values):!1}};l(al,"ZodNativeEnumImpl");var am=al,ll=class ul extends P{_parse(e){let n=this._getOrReturnCtx(e);return m(n,{code:"invalid_type",expected:"never",received:n.parsedType}),{status:"aborted"}}isEqual(e){return e instanceof ul}};l(ll,"ZodNeverImpl");var om=ll,cl=class dl extends P{_parse(e){if(this._getType(e)!=="null"){let r=this._getOrReturnCtx(e);return m(r,{code:"invalid_type",expected:"null",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof dl}};l(cl,"ZodNullImpl");var lm=cl,pl=class wt extends P{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()}))}_parse(e){return this._getType(e)==="null"?{status:"valid",value:null}:this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof wt?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new wt(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};l(pl,"ZodNullableImpl");var um=pl,fl=class Xt extends P{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!=="number"){let s=this._getOrReturnCtx(e);return m(s,{code:"invalid_type",expected:"number",received:s.parsedType}),{status:"aborted"}}let r,i=new ne;for(let s of this._def.checks)s.kind==="int"?Number.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:"invalid_type",expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:"too_small",minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:"too_big",maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?this._floatSafeRemainder(e.data,s.value)!==0&&(r=this._getOrReturnCtx(e,r),m(r,{code:"not_multiple_of",multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:"not_finite",message:s.message}),i.dirty()):ce.assertNever(s);return{status:i.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,_.toString(n))}gt(e,n){return this.setLimit("min",e,!1,_.toString(n))}lte(e,n){return this.setLimit("max",e,!0,_.toString(n))}lt(e,n){return this.setLimit("max",e,!1,_.toString(n))}setLimit(e,n,r,i){return new Xt(f(c({},this._def),{checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:_.toString(i)}]}))}_addCheck(e){return new Xt(f(c({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:_.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:_.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:_.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:_.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:_.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Number.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}isEqual(e){if(!(e instanceof Xt))return!1;let n=new $.CustomSet(this._def.checks),r=new $.CustomSet(e._def.checks);return n.isEqual(r)}_floatSafeRemainder(e,n){let r=(e.toString().split(".")[1]||"").length,i=(n.toString().split(".")[1]||"").length,s=r>i?r:i,a=parseInt(e.toFixed(s).replace(".","")),o=parseInt(n.toFixed(s).replace(".",""));return a%o/Math.pow(10,s)}};l(fl,"ZodNumberImpl");var cm=fl,gl=class Q extends P{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),n=Object.keys(e);return this._cached={shape:e,keys:n}}dereference(e){let n=this._def.shape(),r={};for(let i in n)r[i]=n[i].dereference(e);return new Q(f(c({},this._def),{shape:()=>r}))}getReferences(){let e=this._def.shape(),n=[];for(let r in e)n.push(...e[r].getReferences());return me.unique(n)}clone(){let e={},n=this._def.shape();for(let[i,s]of Object.entries(n))e[i]=s.clone();return new Q(f(c({},this._def),{shape:()=>e}))}_parse(e){if(this._getType(e)!=="object"){let p=this._getOrReturnCtx(e);return m(p,{code:"invalid_type",expected:"object",received:p.parsedType}),{status:"aborted"}}let{status:r,ctx:i}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),o=[];if(this._def.unknownKeys!=="strip")for(let p in i.data)a.includes(p)||o.push(p);let u=[];for(let p of a){let g=s[p],h=i.data[p];u.push({key:{status:"valid",value:p},value:g._parse(new ge(i,h,i.path,p)),alwaysSet:p in i.data})}let d=this._def.unknownKeys;if(d==="passthrough")for(let p of o)u.push({key:{status:"valid",value:p},value:{status:"valid",value:i.data[p]}});else if(d==="strict")o.length>0&&(m(i,{code:"unrecognized_keys",keys:o}),r.dirty());else if(d!=="strip")for(let p of o){let g=i.data[p];u.push({key:{status:"valid",value:p},value:d._parse(new ge(i,g,i.path,p)),alwaysSet:p in i.data})}return i.common.async?Promise.resolve().then(async()=>{let p=[];for(let g of u){let h=await g.key;p.push({key:h,value:await g.value,alwaysSet:g.alwaysSet})}return p}).then(p=>ne.mergeObjectSync(r,p)):ne.mergeObjectSync(r,u)}get shape(){return this._def.shape()}strict(e){return _.errToObj,new Q(c(f(c({},this._def),{unknownKeys:"strict"}),e!==void 0?{errorMap:(n,r)=>{var i,s,a,o;let u=(a=(s=(i=this._def).errorMap)==null?void 0:s.call(i,n,r).message)!=null?a:r.defaultError;return n.code==="unrecognized_keys"?{message:(o=_.errToObj(e).message)!=null?o:u}:{message:u}}}:{}))}strip(){return new Q(f(c({},this._def),{unknownKeys:"strip"}))}passthrough(){return new Q(f(c({},this._def),{unknownKeys:"passthrough"}))}additionalProperties(){if(typeof this._def.unknownKeys=="object")return this._def.unknownKeys;if(this._def.unknownKeys==="passthrough")return A.any();if(this._def.unknownKeys==="strict")return A.never()}extend(e){return new Q(f(c({},this._def),{shape:()=>c(c({},this._def.shape()),e)}))}merge(e){return new Q({unknownKeys:e._def.unknownKeys,shape:()=>c(c({},this._def.shape()),e._def.shape()),typeName:"ZodObject"})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new Q(f(c({},this._def),{unknownKeys:e}))}pick(e){let n={};return Object.keys(e).forEach(i=>{e[i]&&this.shape[i]&&(n[i]=this.shape[i])}),new Q(f(c({},this._def),{shape:()=>n}))}omit(e){let n={};return Object.entries(this.shape).forEach(([i,s])=>{e[i]||(n[i]=s)}),new Q(f(c({},this._def),{shape:()=>n}))}partial(e){let n={};return Object.keys(this.shape).forEach(i=>{let s=this.shape[i];e&&!e[i]?n[i]=s:n[i]=s?.optional()}),new Q(f(c({},this._def),{shape:()=>n}))}required(e){let n={};return Object.entries(this.shape).forEach(([r,i])=>{if(e&&!e[r])n[r]=i;else{let a=i;for(;K.zuiOptional(a);)a=a._def.innerType;n[r]=a}}),new Q(f(c({},this._def),{shape:()=>n}))}keyof(){let e=Object.keys(this.shape);return A.enum(e)}isEqual(e){if(!(e instanceof Q)||!this._unknownKeysEqual(e))return!1;let n=this._def.shape(),r=e._def.shape(),i=l((o,u)=>o[0]===u[0]&&o[1].isEqual(u[1]),"compare"),s=new $.CustomSet(Object.entries(n),{compare:i}),a=new $.CustomSet(Object.entries(r),{compare:i});return s.isEqual(a)}_unknownKeysEqual(e){let n=this.additionalProperties(),r=e.additionalProperties();return n===void 0||r===void 0?n===r:n.isEqual(r)}};l(gl,"ZodObjectImpl");var ml=gl,hl=class Qt extends P{dereference(e){return new Qt(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new Qt(f(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)==="undefined"?{status:"valid",value:void 0}:this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof Qt?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return this._def.innerType.mandatory()}};l(hl,"ZodOptionalImpl");var dm=hl,yl=class en extends P{dereference(e){return new en(f(c({},this._def),{in:this._def.in.dereference(e),out:this._def.out.dereference(e)}))}getReferences(){return me.unique([...this._def.in.getReferences(),...this._def.out.getReferences()])}clone(){return new en(f(c({},this._def),{in:this._def.in.clone(),out:this._def.out.clone()}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return l(async()=>{let s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?{status:"aborted"}:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})},"handleAsync")();{let i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?{status:"aborted"}:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}isEqual(e){return!(!(e instanceof en)||!this._def.in.isEqual(e._def.in)||!this._def.out.isEqual(e._def.out))}};l(yl,"ZodPipelineImpl");var pm=yl,vl=class tn extends P{unwrap(){return this._def.type}dereference(e){return new tn(f(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new tn(f(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:n}=this._processInputParams(e);return n.parsedType!=="promise"&&n.common.async===!1?(m(n,{code:"invalid_type",expected:"promise",received:n.parsedType}),{status:"aborted"}):{status:"valid",value:(n.parsedType==="promise"?n.data:Promise.resolve(n.data)).then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap}))}}isEqual(e){return e instanceof tn?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}};l(vl,"ZodPromiseImpl");var fm=vl,_l=class xt extends P{constructor(){super(...arguments),this._freeze=l(e=>e.status!=="valid"?e:f(c({},e),{value:Object.freeze(e.value)}),"_freeze")}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){let n=this._def.innerType._parse(e);return ln(n)?n.then(this._freeze):this._freeze(n)}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()}))}};l(_l,"ZodReadonlyImpl");var gm=_l,Tl=class nn extends P{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}dereference(e){let n=this._def.keyType.dereference(e),r=this._def.valueType.dereference(e);return new nn(f(c({},this._def),{keyType:n,valueType:r}))}getReferences(){return me.unique([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new nn(f(c({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!=="object")return m(r,{code:"invalid_type",expected:"object",received:r.parsedType}),{status:"aborted"};let i=[],s=this._def.keyType,a=this._def.valueType;for(let o in r.data)i.push({key:s._parse(new ge(r,o,r.path,o)),value:a._parse(new ge(r,r.data[o],r.path,o))});return r.common.async?ne.mergeObjectAsync(n,i):ne.mergeObjectSync(n,i)}get element(){return this._def.valueType}isEqual(e){return!(!(e instanceof nn)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};l(Tl,"ZodRecordImpl");var Ki=Tl,bl=class wl extends P{dereference(e){let n=e[this._def.uri];return n||this}getReferences(){return[this._def.uri]}_parse(e){let n=this._getOrReturnCtx(e);return m(n,{code:"unresolved_reference"}),{status:"aborted"}}isOptional(){return!1}isNullable(){return!1}isEqual(e){return e instanceof wl?this._def.uri===e._def.uri:!1}};l(bl,"ZodRefImpl");var mm=bl,xl=class rt extends P{dereference(e){return new rt(f(c({},this._def),{valueType:this._def.valueType.dereference(e)}))}getReferences(){return this._def.valueType.getReferences()}clone(){return new rt(f(c({},this._def),{valueType:this._def.valueType.clone()}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!=="set")return m(r,{code:"invalid_type",expected:"set",received:r.parsedType}),{status:"aborted"};let i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(m(r,{code:"too_small",minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(m(r,{code:"too_big",maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());let s=this._def.valueType;function a(u){let d=new Set;for(let p of u){if(p.status==="aborted")return{status:"aborted"};p.status==="dirty"&&n.dirty(),d.add(p.value)}return{status:n.value,value:d}}l(a,"finalizeSet");let o=[...r.data.values()].map((u,d)=>s._parse(new ge(r,u,r.path,d)));return r.common.async?Promise.all(o).then(u=>a(u)):a(o)}min(e,n){return new rt(f(c({},this._def),{minSize:{value:e,message:_.toString(n)}}))}max(e,n){return new rt(f(c({},this._def),{maxSize:{value:e,message:_.toString(n)}}))}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}isEqual(e){var n,r,i,s;if(!(e instanceof rt))return!1;let a=(n=this._def.minSize)==null?void 0:n.value,o=(r=e._def.minSize)==null?void 0:r.value;if(a!==o)return!1;let u=(i=this._def.maxSize)==null?void 0:i.value,d=(s=e._def.maxSize)==null?void 0:s.value;return u!==d?!1:this._def.valueType.isEqual(e._def.valueType)}};l(xl,"ZodSetImpl");var hm=xl,ym=/^c[^\s-]{8,}$/i,vm=/^[a-z][a-z0-9]*$/,_m=/^[0-9A-HJKMNP-TV-Z]{26}$/,Tm=/^[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,bm=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,wm="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Gn,xm=/^(((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}))$/,Pm=/^(([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 Pl(t,e){return!!((e==="v4"||!e)&&xm.test(t)||(e==="v6"||!e)&&Pm.test(t))}l(Pl,"isValidIP");var kl=class it extends P{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!=="string"){let s=this._getOrReturnCtx(e);return m(s,{code:"invalid_type",expected:"string",received:s.parsedType}),{status:"aborted"}}let r=new ne,i;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),m(i,{code:"too_small",minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),m(i,{code:"too_big",maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){let a=e.data.length>s.value,o=e.data.length<s.value;(a||o)&&(i=this._getOrReturnCtx(e,i),a?m(i,{code:"too_big",maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&m(i,{code:"too_small",minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")bm.test(e.data)||(i=this._getOrReturnCtx(e,i),m(i,{validation:"email",code:"invalid_string",message:s.message}),r.dirty());else if(s.kind==="emoji")Gn||(Gn=new RegExp(wm,"u")),Gn.test(e.data)||(i=this._getOrReturnCtx(e,i),m(i,{validation:"emoji",code:"invalid_string",message:s.message}),r.dirty());else if(s.kind==="uuid")Tm.test(e.data)||(i=this._getOrReturnCtx(e,i),m(i,{validation:"uuid",code:"invalid_string",message:s.message}),r.dirty());else if(s.kind==="cuid")ym.test(e.data)||(i=this._getOrReturnCtx(e,i),m(i,{validation:"cuid",code:"invalid_string",message:s.message}),r.dirty());else if(s.kind==="cuid2")vm.test(e.data)||(i=this._getOrReturnCtx(e,i),m(i,{validation:"cuid2",code:"invalid_string",message:s.message}),r.dirty());else if(s.kind==="ulid")_m.test(e.data)||(i=this._getOrReturnCtx(e,i),m(i,{validation:"ulid",code:"invalid_string",message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),m(i,{validation:"url",code:"invalid_string",message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),m(i,{validation:"regex",code:"invalid_string",message:s.message}),r.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),m(i,{code:"invalid_string",validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),m(i,{code:"invalid_string",validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),m(i,{code:"invalid_string",validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?So.generateDatetimeRegex(s).test(e.data)||(i=this._getOrReturnCtx(e,i),m(i,{code:"invalid_string",validation:"datetime",message:s.message}),r.dirty()):s.kind==="ip"?Pl(e.data,s.version)||(i=this._getOrReturnCtx(e,i),m(i,{validation:"ip",code:"invalid_string",message:s.message}),r.dirty()):ce.assertNever(s);return{status:r.value,value:e.data}}_addCheck(e){return new it(f(c({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(c({kind:"email"},_.errToObj(e)))}url(e){return this._addCheck(c({kind:"url"},_.errToObj(e)))}emoji(e){return this._addCheck(c({kind:"emoji"},_.errToObj(e)))}uuid(e){return this._addCheck(c({kind:"uuid"},_.errToObj(e)))}cuid(e){return this._addCheck(c({kind:"cuid"},_.errToObj(e)))}cuid2(e){return this._addCheck(c({kind:"cuid2"},_.errToObj(e)))}ulid(e){return this._addCheck(c({kind:"ulid"},_.errToObj(e)))}ip(e){return this._addCheck(c({kind:"ip"},_.errToObj(e)))}datetime(e){var n;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:(n=e?.offset)!=null?n:!1},_.errToObj(e?.message)))}regex(e,n){return this._addCheck(c({kind:"regex",regex:e},_.errToObj(n)))}includes(e,n){return this._addCheck(c({kind:"includes",value:e,position:n?.position},_.errToObj(n?.message)))}startsWith(e,n){return this._addCheck(c({kind:"startsWith",value:e},_.errToObj(n)))}endsWith(e,n){return this._addCheck(c({kind:"endsWith",value:e},_.errToObj(n)))}min(e,n){return this._addCheck(c({kind:"min",value:e},_.errToObj(n)))}max(e,n){return this._addCheck(c({kind:"max",value:e},_.errToObj(n)))}length(e,n){return this._addCheck(c({kind:"length",value:e},_.errToObj(n)))}nonempty(e){return this.min(1,_.errToObj(e))}trim(){return new it(f(c({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}secret(){return this._def[B]=f(c({},this._def[B]),{secret:!0}),this}toLowerCase(){return new it(f(c({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new it(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 n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}isEqual(e){if(!(e instanceof it))return!1;let n=new $.CustomSet(this._def.checks),r=new $.CustomSet(e._def.checks);return n.isEqual(r)}};l(kl,"ZodStringImpl");var km=kl,Sl=class Ol extends P{_parse(e){if(this._getType(e)!=="symbol"){let r=this._getOrReturnCtx(e);return m(r,{code:"invalid_type",expected:"symbol",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof Ol}};l(Sl,"ZodSymbolImpl");var Sm=Sl,El=class Pt extends P{innerType(){return this._def.schema}sourceType(){return K.zuiEffects(this._def.schema)?this._def.schema.sourceType():this._def.schema}dereference(e){return new Pt(f(c({},this._def),{schema:this._def.schema.dereference(e)}))}getReferences(){return this._def.schema.getReferences()}clone(){return new Pt(f(c({},this._def),{schema:this._def.schema.clone()}))}_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.effect;if(r.type==="upstream"){let i=r.effect(n.data,{path:n.path});if(n.common.async)return Promise.resolve(i).then(async s=>{if(s??(s={status:"valid",value:n.data}),this._processResult(n,s),s.status==="aborted")return{status:"aborted"};let a=await this._def.schema._parseAsync({data:s.value,path:n.path,parent:n});return a.status==="aborted"?{status:"aborted"}:a.status==="dirty"?{status:"dirty",value:a.value}:s.status==="dirty"?{status:"dirty",value:a.value}:a});{if(i instanceof Promise)throw new Error("Asynchronous upstream transform encountered during synchronous parse operation. Use .parseAsync instead.");if(i??(i={status:"valid",value:n.data}),this._processResult(n,i),i.status==="aborted")return{status:"aborted"};let s=this._def.schema._parseSync({data:i.value,path:n.path,parent:n});return s.status==="aborted"?{status:"aborted"}:s.status==="dirty"?{status:"dirty",value:s.value}:i.status==="dirty"?{status:"dirty",value:s.value}:s}}if(r.type==="downstream")if(n.common.async===!1){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(i.status==="aborted"||i.status==="dirty"&&r.failFast)return i;let s=r.effect(i.value,{path:n.path});if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return s??(s={status:"valid",value:i.value}),this._processResult(n,s),s.status==="aborted"?{status:"aborted"}:s.status==="dirty"?{status:"dirty",value:s.value}:i.status==="dirty"?{status:"dirty",value:s.value}:s}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>i.status==="aborted"||i.status==="dirty"&&r.failFast?i:Promise.resolve(r.effect(i.value,{path:n.path})).then(s=>(s??(s={status:"valid",value:i.value}),this._processResult(n,s),s.status==="aborted"?{status:"aborted"}:s.status==="dirty"?{status:"dirty",value:s.value}:i.status==="dirty"?{status:"dirty",value:s.value}:s)));ce.assertNever(r)}_processResult(e,n){if(n.status!=="valid")for(let r of n.issues)m(e,r)}isEqual(e){return!(e instanceof Pt)||!this._def.schema.isEqual(e._def.schema)?!1:this._def.effect.type==="upstream"?e._def.effect.type!=="upstream"?!1:ue.compareFunctions(this._def.effect.effect,e._def.effect.effect):this._def.effect.type==="downstream"?e._def.effect.type!=="downstream"||this._def.effect.failFast!==e._def.effect.failFast?!1:ue.compareFunctions(this._def.effect.effect,e._def.effect.effect):(this._def.effect,!1)}naked(){return this._def.schema.naked()}mandatory(){return new Pt(f(c({},this._def),{schema:this._def.schema.mandatory()}))}};l(El,"ZodEffectsImpl");var Or=El,Il=class kt extends P{dereference(e){let n=this._def.items.map(i=>i.dereference(e)),r=this._def.rest?this._def.rest.dereference(e):null;return new kt(f(c({},this._def),{items:n,rest:r}))}getReferences(){return me.unique([...this._def.items.flatMap(e=>e.getReferences()),...this._def.rest?this._def.rest.getReferences():[]])}clone(){let e=this._def.items.map(r=>r.clone()),n=this._def.rest?this._def.rest.clone():null;return new kt(f(c({},this._def),{items:e,rest:n}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!=="array")return m(r,{code:"invalid_type",expected:"array",received:r.parsedType}),{status:"aborted"};if(r.data.length<this._def.items.length)return m(r,{code:"too_small",minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),{status:"aborted"};!this._def.rest&&r.data.length>this._def.items.length&&(m(r,{code:"too_big",maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let s=[...r.data].map((a,o)=>{let u=this._def.items[o]||this._def.rest;return u?u._parse(new ge(r,a,r.path,o)):null}).filter(a=>!!a);return r.common.async?Promise.all(s).then(a=>ne.mergeArray(n,a)):ne.mergeArray(n,s)}get items(){return this._def.items}rest(e){return new kt(f(c({},this._def),{rest:e}))}isEqual(e){if(!(e instanceof kt)||!this._restEquals(e))return!1;let n=l((s,a)=>s.isEqual(a),"compare"),r=new $.CustomSet(this._def.items,{compare:n}),i=new $.CustomSet(e._def.items,{compare:n});return r.isEqual(i)}_restEquals(e){return this._def.rest===null?e._def.rest===null:e._def.rest!==null&&this._def.rest.isEqual(e._def.rest)}};l(Il,"ZodTupleImpl");var Om=Il,Bl=class Cl extends P{_parse(e){if(this._getType(e)!=="undefined"){let r=this._getOrReturnCtx(e);return m(r,{code:"invalid_type",expected:"undefined",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof Cl}mandatory(){return A.never(c({},this._def))}};l(Bl,"ZodUndefinedImpl");var Em=Bl,Al=class St extends P{dereference(e){let n=this._def.options.map(r=>r.dereference(e));return new St(f(c({},this._def),{options:n}))}getReferences(){return me.unique(this._def.options.reduce((e,n)=>[...e,...n.getReferences()],[]))}clone(){let e=this._def.options.map(n=>n.clone());return new St(f(c({},this._def),{options:e}))}_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function i(s){for(let o of s)if(o.result.status==="valid")return o.result;for(let o of s)if(o.result.status==="dirty")return n.common.issues.push(...o.ctx.common.issues),o.result;let a=s.map(o=>new be(o.ctx.common.issues));return m(n,{code:"invalid_union",unionErrors:a}),{status:"aborted"}}if(l(i,"handleResults"),n.common.async)return Promise.all(r.map(async s=>{let a=f(c({},n),{common:f(c({},n.common),{issues:[]}),parent:null});return{result:await s._parseAsync({data:n.data,path:n.path,parent:a}),ctx:a}})).then(i);{let s,a=[];for(let u of r){let d=f(c({},n),{common:f(c({},n.common),{issues:[]}),parent:null}),p=u._parseSync({data:n.data,path:n.path,parent:d});if(p.status==="valid")return p;p.status==="dirty"&&!s&&(s={result:p,ctx:d}),d.common.issues.length&&a.push(d.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;let o=a.map(u=>new be(u));return m(n,{code:"invalid_union",unionErrors:o}),{status:"aborted"}}}get options(){return this._def.options}isEqual(e){if(!(e instanceof St))return!1;let n=l((s,a)=>s.isEqual(a),"compare"),r=new $.CustomSet([...this._def.options],{compare:n}),i=new $.CustomSet([...e._def.options],{compare:n});return r.isEqual(i)}mandatory(){let e=this._def.options.filter(s=>!K.zuiUndefined(s)).map(s=>s.mandatory()),[n,r,...i]=e;return n?r?new St(f(c({},this._def),{options:[n,r,...i]})):n:A.never(c({},this._def))}};l(Al,"ZodUnionImpl");var Im=Al,Zl=class Rl extends P{constructor(){super(...arguments),this._unknown=!0}_parse(e){return{status:"valid",value:e.data}}isEqual(e){return e instanceof Rl}};l(Zl,"ZodUnknownImpl");var Bm=Zl,Nl=class Dl extends P{_parse(e){if(this._getType(e)!=="undefined"){let r=this._getOrReturnCtx(e);return m(r,{code:"invalid_type",expected:"void",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof Dl}};l(Nl,"ZodVoidImpl");var Cm=Nl,Am=l(t=>t instanceof Error,"_isError"),Zm=l(t=>typeof t=="object"&&t!==null,"_isObject"),K={zuiError:t=>t instanceof be||Am(t)&&"__type__"in t&&t.__type__==="ZuiError",zuiType:t=>t instanceof P||Zm(t)&&"__type__"in t&&t.__type__==="ZuiType",zuiAny:t=>t.typeName==="ZodAny",zuiArray:t=>t.typeName==="ZodArray",zuiBigInt:t=>t.typeName==="ZodBigInt",zuiBoolean:t=>t.typeName==="ZodBoolean",zuiBranded:t=>t.typeName==="ZodBranded",zuiCatch:t=>t.typeName==="ZodCatch",zuiDate:t=>t.typeName==="ZodDate",zuiDefault:t=>t.typeName==="ZodDefault",zuiDiscriminatedUnion:t=>t.typeName==="ZodDiscriminatedUnion",zuiEnum:t=>t.typeName==="ZodEnum",zuiFunction:t=>t.typeName==="ZodFunction",zuiIntersection:t=>t.typeName==="ZodIntersection",zuiLazy:t=>t.typeName==="ZodLazy",zuiLiteral:t=>t.typeName==="ZodLiteral",zuiMap:t=>t.typeName==="ZodMap",zuiNaN:t=>t.typeName==="ZodNaN",zuiNativeEnum:t=>t.typeName==="ZodNativeEnum",zuiNever:t=>t.typeName==="ZodNever",zuiNull:t=>t.typeName==="ZodNull",zuiNullable:t=>t.typeName==="ZodNullable",zuiNumber:t=>t.typeName==="ZodNumber",zuiObject:t=>t.typeName==="ZodObject",zuiOptional:t=>t.typeName==="ZodOptional",zuiPipeline:t=>t.typeName==="ZodPipeline",zuiPromise:t=>t.typeName==="ZodPromise",zuiReadonly:t=>t.typeName==="ZodReadonly",zuiRecord:t=>t.typeName==="ZodRecord",zuiRef:t=>t.typeName==="ZodRef",zuiSet:t=>t.typeName==="ZodSet",zuiString:t=>t.typeName==="ZodString",zuiSymbol:t=>t.typeName==="ZodSymbol",zuiEffects:t=>t.typeName==="ZodEffects",zuiTuple:t=>t.typeName==="ZodTuple",zuiUndefined:t=>t.typeName==="ZodUndefined",zuiUnion:t=>t.typeName==="ZodUnion",zuiUnknown:t=>t.typeName==="ZodUnknown",zuiVoid:t=>t.typeName==="ZodVoid"},k=l(t=>{if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:i,supportsExtensions:s,[B]:a}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);let o=a?Object.fromEntries(Object.entries(a).filter(([d])=>d!=="secret"||s?.includes("secret"))):void 0;return e?{errorMap:e,description:i,[B]:o}:{errorMap:l((d,p)=>d.code!=="invalid_type"?{message:p.defaultError}:typeof p.data>"u"?{message:r??p.defaultError}:{message:n??p.defaultError},"customMap"),description:i,[B]:o}},"_processCreateParams"),vn=l((t,e={},n)=>t?We().downstream(r=>{var i,s;if(!t(r)){let a=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e;return((s=(i=a.fatal)!=null?i:n)!=null?s:!0)?Vr(c({code:"custom"},a)):Gr(r,c({code:"custom"},a))}}):We(),"customType"),Er=l((t,e={message:`Input not instance of ${t.name}`})=>vn(n=>n instanceof t,e),"instanceOfType"),We=l(t=>new Wg(c({typeName:"ZodAny"},k(t))),"anyType"),Ce=l(t=>new Bm(c({typeName:"ZodUnknown"},k(t))),"unknownType"),Nt=l(t=>new om(c({typeName:"ZodNever"},k(t))),"neverType"),Ir=l(t=>new Cm(c({typeName:"ZodVoid"},k(t))),"voidType"),Ut=l(t=>new lm(c({typeName:"ZodNull"},k(t))),"nullType"),_n=l(t=>new Em(c({typeName:"ZodUndefined"},k(t))),"undefinedType"),Br=l(t=>new Sm(c({typeName:"ZodSymbol"},k(t))),"symbolType"),Cr=l(t=>new sm(c({typeName:"ZodNaN"},k(t))),"nanType"),xe=l(t=>{var e;return new km(c({checks:[],typeName:"ZodString",coerce:(e=t?.coerce)!=null?e:!1},k(f(c({},t),{supportsExtensions:["secret"]}))))},"stringType"),Xe=l(t=>new cm(c({checks:[],typeName:"ZodNumber",coerce:t?.coerce||!1},k(t))),"numberType"),Qe=l(t=>new qg(c({typeName:"ZodBoolean",coerce:t?.coerce||!1},k(t))),"booleanType"),Tn=l(t=>{var e;return new Fg(c({checks:[],typeName:"ZodBigInt",coerce:(e=t?.coerce)!=null?e:!1},k(t)))},"bigIntType"),bn=l(t=>new Jg(c({checks:[],coerce:t?.coerce||!1,typeName:"ZodDate"},k(t))),"dateType"),wn=l(t=>new mm({typeName:"ZodRef",uri:t}),"refType"),Dt=l((t,e)=>new rm(c({value:t,typeName:"ZodLiteral"},k(e))),"literalType"),xn=l((t,e)=>new Qg(c({values:t,typeName:"ZodEnum"},k(e))),"enumType"),Ar=l((t,e)=>new am(c({values:t,typeName:"ZodNativeEnum"},k(e))),"nativeEnumType"),Ue=l((t,e)=>new Lg(c({type:t,minLength:null,maxLength:null,exactLength:null,typeName:"ZodArray"},k(e))),"arrayType"),ot=l((t,e)=>new ml(c({shape:()=>t,unknownKeys:"strip",typeName:"ZodObject"},k(e))),"objectType"),Zr=l((t,e)=>new ml(c({shape:()=>t,unknownKeys:"strict",typeName:"ZodObject"},k(e))),"strictObjectType"),ze=l((t,e)=>new Im(c({options:t,typeName:"ZodUnion"},k(e))),"unionType"),Ht=l((t,e,n)=>new Xg(c({typeName:"ZodDiscriminatedUnion",discriminator:t,options:e},k(n))),"discriminatedUnionType"),Pn=l((t,e,n)=>new tm(c({left:t,right:e,typeName:"ZodIntersection"},k(n))),"intersectionType"),zt=l((t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Om(c({items:t,typeName:"ZodTuple",rest:null},k(e)))},"tupleType"),Mt=l((t,e,n)=>e instanceof P?new Ki(c({keyType:t,valueType:e,typeName:"ZodRecord"},k(n))):new Ki(c({keyType:xe(),valueType:t,typeName:"ZodRecord"},k(e))),"recordType"),Rr=l((t,e,n)=>new im(c({valueType:e,keyType:t,typeName:"ZodMap"},k(n))),"mapType"),kn=l((t,e)=>new hm(c({valueType:t,minSize:null,maxSize:null,typeName:"ZodSet"},k(e))),"setType"),Nr=l((t,e)=>new nm(c({getter:t,typeName:"ZodLazy"},k(e))),"lazyType"),Dr=l((t,e)=>new fm(c({type:t,typeName:"ZodPromise"},k(e))),"promiseType"),Hr=l((t,e,n)=>new em(c({args:t||zt([]).rest(Ce()),returns:e||Ce(),typeName:"ZodFunction"},k(n))),"functionType"),Mr=l((t,e,n)=>new Or(c({schema:e,effect:{type:"upstream",effect:(r,i)=>{let s=t(r,i);return s instanceof Promise?s.then(a=>un(a)):un(s)}},typeName:"ZodEffects"},k(n))),"preprocessType"),jr=l((t,e,n)=>new Or(c({schema:e,effect:{type:"upstream",effect:t},typeName:"ZodEffects"},k(n))),"upstreamType"),$r=l((t,e,n)=>new Or(c({schema:t,effect:{type:"downstream",effect:e,failFast:n?.failFast},typeName:"ZodEffects"},k(n))),"downstreamType"),Ur=l((t,e)=>new dm(c({innerType:t,typeName:"ZodOptional"},k(e))),"optionalType"),zr=l((t,e)=>new um(c({innerType:t,typeName:"ZodNullable"},k(e))),"nullableType"),Kr=l((t,e)=>new gm(c({innerType:t,typeName:"ZodReadonly"},k(e))),"readonlyType"),Wr=l((t,e,n)=>new Yg(c({innerType:t,typeName:"ZodDefault",defaultValue:typeof e=="function"?e:()=>e},k(n))),"defaultType"),Lr=l((t,e,n)=>new Gg(c({innerType:t,typeName:"ZodCatch",catchValue:typeof e=="function"?e:()=>e},k(n))),"catchType"),Fr=l((t,e)=>new pm({in:t,out:e,typeName:"ZodPipeline"}),"pipelineType"),qr=l(t=>new Vg(c({typeName:"ZodBranded",type:t},k({supportsExtensions:["secret"]}))),"brandedType");Zo({any:We,array:Ue,bigint:Tn,boolean:Qe,branded:qr,catch:Lr,custom:vn,date:bn,default:Wr,discriminatedUnion:Ht,enum:xn,function:Hr,instanceof:Er,intersection:Pn,lazy:Nr,literal:Dt,map:Rr,nan:Cr,nativeEnum:Ar,never:Nt,null:Ut,nullable:zr,number:Xe,object:ot,optional:Ur,pipeline:Fr,preprocess:Mr,upstream:jr,downstream:$r,promise:Dr,record:Mt,ref:wn,readonly:Kr,set:kn,strictObject:Zr,string:xe,symbol:Br,tuple:zt,undefined:_n,union:ze,unknown:Ce,void:Ir});var Hl={string(t){return xe(f(c({},t),{coerce:!0}))},number(t){return Xe(f(c({},t),{coerce:!0}))},boolean(t){return Qe(f(c({},t),{coerce:!0}))},bigint(t){return Tn(f(c({},t),{coerce:!0}))},date(t){return bn(f(c({},t),{coerce:!0}))}},un=l(t=>({status:"valid",value:t}),"OK"),Vr=l((t,...e)=>({status:"aborted",issues:[t,...e]}),"ERR"),Gr=l((t,e,...n)=>({status:"dirty",value:t,issues:[e,...n]}),"DIRTY"),Ml={};de(Ml,{JSONSchemaToZuiError:()=>Sn,ObjectToZuiError:()=>dr,UnrepresentableGenericError:()=>pr,UnsupportedJSONSchemaToZuiError:()=>Me,UnsupportedZuiCheckToJSONSchemaError:()=>Ll,UnsupportedZuiToJSONSchemaError:()=>Y,UnsupportedZuiToTypescriptSchemaError:()=>je,UnsupportedZuiToTypescriptTypeError:()=>Xl,UntitledDeclarationError:()=>eu,ZuiToJSONSchemaError:()=>On,ZuiToTypescriptSchemaError:()=>Vl,ZuiToTypescriptTypeError:()=>En,ZuiTransformError:()=>lt});var jl=class extends Error{constructor(e,n){super(n),this.transform=e}};l(jl,"ZuiTransformError");var lt=jl,$l=class extends lt{constructor(e){super("json-schema-to-zui",e)}};l($l,"JSONSchemaToZuiError");var Sn=$l,Ul=class extends lt{constructor(e){super("object-to-zui",e)}};l(Ul,"ObjectToZuiError");var dr=Ul,zl=class extends lt{constructor(e){super("zui-to-json-schema",e)}};l(zl,"ZuiToJSONSchemaError");var On=zl,Kl=class extends On{constructor(e,{suggestedAlternative:n}={}){super(`Zod type ${e} cannot be transformed to JSON Schema.`+(n?` Suggested alternative: ${n}`:""))}};l(Kl,"UnsupportedZuiToJSONSchemaError");var Y=Kl,Wl=class extends On{constructor({zodType:e,checkKind:n}){super(`Zod check .${n}() of type ${e} cannot be transformed to JSON Schema.`)}};l(Wl,"UnsupportedZuiCheckToJSONSchemaError");var Ll=Wl,Fl=class extends Sn{constructor(e){super(`JSON Schema ${JSON.stringify(e)} cannot be transformed to ZUI type.`)}};l(Fl,"UnsupportedJSONSchemaToZuiError");var Me=Fl,ql=class extends lt{constructor(e){super("zui-to-typescript-schema",e)}};l(ql,"ZuiToTypescriptSchemaError");var Vl=ql,Gl=class extends Vl{constructor(e){super(`Zod type ${e} cannot be transformed to TypeScript schema.`)}};l(Gl,"UnsupportedZuiToTypescriptSchemaError");var je=Gl,Jl=class extends lt{constructor(e){super("zui-to-typescript-type",e)}};l(Jl,"ZuiToTypescriptTypeError");var En=Jl,Yl=class extends En{constructor(e){super(`Zod type ${e} cannot be transformed to TypeScript type.`)}};l(Yl,"UnsupportedZuiToTypescriptTypeError");var Xl=Yl,Ql=class extends En{constructor(){super("Schema must have a title to be transformed to a TypeScript type with a declaration.")}};l(Ql,"UntitledDeclarationError");var eu=Ql,tu=class extends En{constructor(){super('ZodRef can only be transformed to a TypeScript type with a "type" declaration.')}};l(tu,"UnrepresentableGenericError");var pr=tu,Rm=l(t=>{let e;try{e=new Function("z",`return ${t}`)(Pe)}catch(n){return{sucess:!1,error:`Failed to evaluate schema: ${(n instanceof Error?n:new Error(String(n))).message}`}}return K.zuiType(e)?{sucess:!0,value:e}:{sucess:!1,error:`String "${t}" does not evaluate to a Zod schema`}},"evalZuiString"),x={ZodString:"ZodString",ZodNumber:"ZodNumber",ZodNaN:"ZodNaN",ZodBigInt:"ZodBigInt",ZodBoolean:"ZodBoolean",ZodDate:"ZodDate",ZodSymbol:"ZodSymbol",ZodUndefined:"ZodUndefined",ZodNull:"ZodNull",ZodAny:"ZodAny",ZodUnknown:"ZodUnknown",ZodNever:"ZodNever",ZodVoid:"ZodVoid",ZodArray:"ZodArray",ZodObject:"ZodObject",ZodUnion:"ZodUnion",ZodDiscriminatedUnion:"ZodDiscriminatedUnion",ZodIntersection:"ZodIntersection",ZodTuple:"ZodTuple",ZodRecord:"ZodRecord",ZodRef:"ZodRef",ZodMap:"ZodMap",ZodSet:"ZodSet",ZodFunction:"ZodFunction",ZodLazy:"ZodLazy",ZodLiteral:"ZodLiteral",ZodEnum:"ZodEnum",ZodEffects:"ZodEffects",ZodNativeEnum:"ZodNativeEnum",ZodOptional:"ZodOptional",ZodNullable:"ZodNullable",ZodDefault:"ZodDefault",ZodCatch:"ZodCatch",ZodPromise:"ZodPromise",ZodBranded:"ZodBranded",ZodPipeline:"ZodPipeline",ZodReadonly:"ZodReadonly"},Nm=l(t=>[t.slice(0,t.length/2),t.slice(t.length/2)],"half"),Dm=l((t,...e)=>Object.keys(t).reduce((n,r)=>(e.includes(r)||(n[r]=t[r]),n),{}),"omit");function q(t,e,n){var r;let i=t[e],s="";if(i!==void 0){let a=n({value:i,json:JSON.stringify(i)});if(a){let o=a[0],u=a.length===3?a[1]:"",d=a.length===3?a[2]:a[1];s+=o,((r=t.errorMessage)==null?void 0:r[e])!==void 0&&(s+=u+JSON.stringify(t.errorMessage[e])),s+=d}}return s}l(q,"withMessage");var Ot=Symbol("Original index"),Hm=l(t=>{let e=[];for(let n=0;n<t.length;n++){let r=t[n];if(typeof r=="boolean")e.push(r?{[Ot]:n}:{[Ot]:n,not:{}});else{if(Ot in r)return t;e.push(f(c({},r),{[Ot]:n}))}}return e},"ensureOriginalIndex");function jt(t,e){if(t.allOf.length===0)return"z.never()";if(t.allOf.length===1){let n=t.allOf[0];return W(n,f(c({},e),{path:[...e.path,"allOf",n[Ot]]}))}else{let[n,r]=Nm(Hm(t.allOf));return`z.intersection(${jt({allOf:n},e)}, ${jt({allOf:r},e)})`}}l(jt,"parseAllOf");var nu=l((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((n,r)=>W(n,f(c({},e),{path:[...e.path,"anyOf",r]}))).join(", ")}])`:"z.any()","parseAnyOf"),Mm=l((t,e)=>{if(Array.isArray(t.items))return`z.tuple([${t.items.map((r,i)=>W(r,f(c({},e),{path:[...e.path,"items",i]})))}])`;let n=t.items?`z.array(${W(t.items,f(c({},e),{path:[...e.path,"items"]}))})`:"z.array(z.any())";return n+=q(t,"minItems",({json:r})=>[`.min(${r}`,", ",")"]),n+=q(t,"maxItems",({json:r})=>[`.max(${r}`,", ",")"]),n},"parseArray"),jm=l(t=>{var e;return(e=t[B])!=null&&e.coerce?"z.coerce.boolean()":"z.boolean()"},"parseBoolean"),$m=l(t=>`z.literal(${JSON.stringify(t.const)})`,"parseConst"),Um=l(t=>"z.any()","parseDefault"),Jr=l((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) => {
2
2
  const schemas = [${t.oneOf.map((n,r)=>W(n,f(c({},e),{path:[...e.path,"oneOf",r]}))).join(", ")}];
3
3
  const errors = schemas.reduce(
4
4
  (errors: z.ZodError[], schema) =>
@@ -15,14 +15,14 @@
15
15
  message: "Invalid input: Should pass single schema",
16
16
  });
17
17
  }
18
- })`:"z.any()","parseOneOf"),$m=l((t,e)=>{var n,r;if(t.oneOf.length<=1||!((n=t.discriminator)!=null&&n.propertyName))return Gr(t,e);let i=t.oneOf.map((s,a)=>W(s,f(c({},e),{path:[...e.path,"oneOf",a]})));return`z.discriminatedUnion("${(r=t.discriminator)==null?void 0:r.propertyName}", [${i.join(", ")}])`},"parseDiscriminator"),Um=l(t=>t.enum.length===0?"z.never()":t.enum.length===1?`z.literal(${JSON.stringify(t.enum[0])})`:t.enum.every(e=>typeof e=="string")?`z.enum([${t.enum.map(e=>JSON.stringify(e))}])`:`z.union([${t.enum.map(e=>`z.literal(${JSON.stringify(e)})`).join(", ")}])`,"parseEnum"),zm=l((t,e)=>{let n=W(t.if,f(c({},e),{path:[...e.path,"if"]})),r=W(t.then,f(c({},e),{path:[...e.path,"then"]})),i=W(t.else,f(c({},e),{path:[...e.path,"else"]}));return`z.union([${r}, ${i}]).superRefine((value,ctx) => {
18
+ })`:"z.any()","parseOneOf"),zm=l((t,e)=>{var n,r;if(t.oneOf.length<=1||!((n=t.discriminator)!=null&&n.propertyName))return Jr(t,e);let i=t.oneOf.map((s,a)=>W(s,f(c({},e),{path:[...e.path,"oneOf",a]})));return`z.discriminatedUnion("${(r=t.discriminator)==null?void 0:r.propertyName}", [${i.join(", ")}])`},"parseDiscriminator"),Km=l(t=>t.enum.length===0?"z.never()":t.enum.length===1?`z.literal(${JSON.stringify(t.enum[0])})`:t.enum.every(e=>typeof e=="string")?`z.enum([${t.enum.map(e=>JSON.stringify(e))}])`:`z.union([${t.enum.map(e=>`z.literal(${JSON.stringify(e)})`).join(", ")}])`,"parseEnum"),Wm=l((t,e)=>{let n=W(t.if,f(c({},e),{path:[...e.path,"if"]})),r=W(t.then,f(c({},e),{path:[...e.path,"then"]})),i=W(t.else,f(c({},e),{path:[...e.path,"else"]}));return`z.union([${r}, ${i}]).superRefine((value,ctx) => {
19
19
  const result = ${n}.safeParse(value).success
20
20
  ? ${r}.safeParse(value)
21
21
  : ${i}.safeParse(value);
22
22
  if (!result.success) {
23
23
  result.error.errors.forEach((error) => ctx.addIssue(error))
24
24
  }
25
- })`},"parseIfThenElse"),Km=l((t,e)=>`z.union([${t.type.map(n=>W(f(c({},t),{type:n}),e)).join(", ")}])`,"parseMultipleType"),Wm=l((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"),Lm=l(t=>"z.null()","parseNull"),Fm=l((t,e)=>`${W(Rm(t,"nullable"),e,!0)}.nullable()`,"parseNullable"),qm=l(t=>{var e;let n="z.number()";return(e=t[B])!=null&&e.coerce&&(n="z.coerce.number()"),t.type==="integer"?n+=q(t,"type",()=>[".int(",")"]):n+=q(t,"format",({value:r})=>{if(r==="int64")return[".int(",")"]}),n+=q(t,"multipleOf",({value:r,json:i})=>r===1?n.startsWith("z.number().int(")?void 0:[".int(",")"]:[`.multipleOf(${i}`,", ",")"]),typeof t.minimum=="number"?t.exclusiveMinimum===!0?n+=q(t,"minimum",({json:r})=>[`.gt(${r}`,", ",")"]):n+=q(t,"minimum",({json:r})=>[`.gte(${r}`,", ",")"]):typeof t.exclusiveMinimum=="number"&&(n+=q(t,"exclusiveMinimum",({json:r})=>[`.gt(${r}`,", ",")"])),typeof t.maximum=="number"?t.exclusiveMaximum===!0?n+=q(t,"maximum",({json:r})=>[`.lt(${r}`,", ",")"]):n+=q(t,"maximum",({json:r})=>[`.lte(${r}`,", ",")"]):typeof t.exclusiveMaximum=="number"&&(n+=q(t,"exclusiveMaximum",({json:r})=>[`.lt(${r}`,", ",")"])),n},"parseNumber");function tu(t,e){let n;t.properties&&(Object.keys(t.properties).length?(n="z.object({ ",n+=Object.keys(t.properties).map(a=>{let o=t.properties[a],u=`${JSON.stringify(a)}: ${W(o,f(c({},e),{path:[...e.path,"properties",a]}))}`,d=typeof o=="object"&&o.default!==void 0||typeof t.default=="object"&&t.default!==null&&a in t.default,p=Array.isArray(t.required)?t.required.includes(a):typeof o=="object"&&o.required===!0;return!d&&!p?`${u}.optional()`:u}).join(", "),n+=" })"):n="z.object({})");let r=t.additionalProperties!==void 0?W(t.additionalProperties,f(c({},e),{path:[...e.path,"additionalProperties"]})):void 0,i;if(t.patternProperties){let a=Object.fromEntries(Object.entries(t.patternProperties).map(([o,u])=>[o,W(u,f(c({},e),{path:[...e.path,"patternProperties",o]}))],{}));i="",n?r?i+=`.catchall(z.union([${[...Object.values(a),r].join(", ")}]))`:Object.keys(a).length>1?i+=`.catchall(z.union([${Object.values(a).join(", ")}]))`:i+=`.catchall(${Object.values(a)})`:r?i+=`z.record(z.union([${[...Object.values(a),r].join(", ")}]))`:Object.keys(a).length>1?i+=`z.record(z.union([${Object.values(a).join(", ")}]))`:i+=`z.record(${Object.values(a)})`,i+=`.superRefine((value, ctx) => {
25
+ })`},"parseIfThenElse"),Lm=l((t,e)=>`z.union([${t.type.map(n=>W(f(c({},t),{type:n}),e)).join(", ")}])`,"parseMultipleType"),Fm=l((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"),qm=l(t=>"z.null()","parseNull"),Vm=l((t,e)=>`${W(Dm(t,"nullable"),e,!0)}.nullable()`,"parseNullable"),Gm=l(t=>{var e;let n="z.number()";return(e=t[B])!=null&&e.coerce&&(n="z.coerce.number()"),t.type==="integer"?n+=q(t,"type",()=>[".int(",")"]):n+=q(t,"format",({value:r})=>{if(r==="int64")return[".int(",")"]}),n+=q(t,"multipleOf",({value:r,json:i})=>r===1?n.startsWith("z.number().int(")?void 0:[".int(",")"]:[`.multipleOf(${i}`,", ",")"]),typeof t.minimum=="number"?t.exclusiveMinimum===!0?n+=q(t,"minimum",({json:r})=>[`.gt(${r}`,", ",")"]):n+=q(t,"minimum",({json:r})=>[`.gte(${r}`,", ",")"]):typeof t.exclusiveMinimum=="number"&&(n+=q(t,"exclusiveMinimum",({json:r})=>[`.gt(${r}`,", ",")"])),typeof t.maximum=="number"?t.exclusiveMaximum===!0?n+=q(t,"maximum",({json:r})=>[`.lt(${r}`,", ",")"]):n+=q(t,"maximum",({json:r})=>[`.lte(${r}`,", ",")"]):typeof t.exclusiveMaximum=="number"&&(n+=q(t,"exclusiveMaximum",({json:r})=>[`.lt(${r}`,", ",")"])),n},"parseNumber");function ru(t,e){let n;t.properties&&(Object.keys(t.properties).length?(n="z.object({ ",n+=Object.keys(t.properties).map(a=>{let o=t.properties[a],u=`${JSON.stringify(a)}: ${W(o,f(c({},e),{path:[...e.path,"properties",a]}))}`,d=typeof o=="object"&&o.default!==void 0||typeof t.default=="object"&&t.default!==null&&a in t.default,p=Array.isArray(t.required)?t.required.includes(a):typeof o=="object"&&o.required===!0;return!d&&!p?`${u}.optional()`:u}).join(", "),n+=" })"):n="z.object({})");let r=t.additionalProperties!==void 0?W(t.additionalProperties,f(c({},e),{path:[...e.path,"additionalProperties"]})):void 0,i;if(t.patternProperties){let a=Object.fromEntries(Object.entries(t.patternProperties).map(([o,u])=>[o,W(u,f(c({},e),{path:[...e.path,"patternProperties",o]}))],{}));i="",n?r?i+=`.catchall(z.union([${[...Object.values(a),r].join(", ")}]))`:Object.keys(a).length>1?i+=`.catchall(z.union([${Object.values(a).join(", ")}]))`:i+=`.catchall(${Object.values(a)})`:r?i+=`z.record(z.union([${[...Object.values(a),r].join(", ")}]))`:Object.keys(a).length>1?i+=`z.record(z.union([${Object.values(a).join(", ")}]))`:i+=`z.record(${Object.values(a)})`,i+=`.superRefine((value, ctx) => {
26
26
  `,i+=`for (const key in value) {
27
27
  `,r&&(t.properties?i+=`let evaluated = [${Object.keys(t.properties).map(o=>JSON.stringify(o)).join(", ")}].includes(key)
28
28
  `:i+=`let evaluated = false
@@ -54,25 +54,25 @@
54
54
  `,i+=`}
55
55
  `,i+=`}
56
56
  `),i+=`}
57
- `,i+="})"}let s=n?i?n+i:r?r==="z.never()"?n+".strict()":n+`.catchall(${r})`:n:i||(r?`z.record(${r})`:"z.record(z.any())");return M.an.anyOf(t)&&(s+=`.and(${eu(f(c({},t),{anyOf:t.anyOf.map(a=>typeof a=="object"&&!a.type&&(a.properties||a.additionalProperties||a.patternProperties)?f(c({},a),{type:"object"}):a)}),e)})`),M.a.oneOf(t)&&(s+=`.and(${Gr(f(c({},t),{oneOf:t.oneOf.map(a=>typeof a=="object"&&!a.type&&(a.properties||a.additionalProperties||a.patternProperties)?f(c({},a),{type:"object"}):a)}),e)})`),M.an.allOf(t)&&(s+=`.and(${Mt(f(c({},t),{allOf:t.allOf.map(a=>typeof a=="object"&&!a.type&&(a.properties||a.additionalProperties||a.patternProperties)?f(c({},a),{type:"object"}):a)}),e)})`),s}l(tu,"parseObject");var Vm=l(t=>`z.ref('${t.$ref}')`,"parseRef"),Gm=l(t=>{var e;let n="z.string()";if((e=t[B])!=null&&e.coerce){if(t.format==="date-time")return"z.coerce.date()";n="z.coerce.string()"}return n+=q(t,"format",({value:r})=>{switch(r){case"email":return[".email(",")"];case"ip":return[".ip(",")"];case"ipv4":return['.ip({ version: "v4"',", message: "," })"];case"ipv6":return['.ip({ version: "v6"',", message: "," })"];case"uri":return[".url(",")"];case"uuid":return[".uuid(",")"];case"date-time":return[".datetime(",")"]}}),n+=q(t,"pattern",({json:r})=>[`.regex(new RegExp(${r})`,", ",")"]),n+=q(t,"minLength",({json:r})=>[`.min(${r}`,", ",")"]),n+=q(t,"maxLength",({json:r})=>[`.max(${r}`,", ",")"]),n},"parseString"),W=l((t,e={seen:new Map,path:[]},n)=>{if(typeof t!="object")return t?"z.any()":"z.never()";if(e.parserOverride){let s=e.parserOverride(t,e);if(typeof s=="string")return s}let r=e.seen.get(t);if(r){if(r.r!==void 0)return r.r;if(e.depth===void 0||r.n>=e.depth)return"z.any()";r.n+=1}else r={r:void 0,n:0},e.seen.set(t,r);let i=Xm(t,e);return n||(i=Jm(t,i),e.withoutDefaults||(i=Ym(t,i))),r.r=i,i},"parseSchema"),Jm=l((t,e)=>(t.description&&(e+=`.describe(${JSON.stringify(t.description)})`),e),"addMeta"),Ym=l((t,e)=>(t.default!==void 0&&(e+=`.default(${JSON.stringify(t.default)})`),e),"addDefaults"),Xm=l((t,e)=>M.a.nullable(t)?Fm(t,e):M.an.object(t)?tu(t,e):M.an.array(t)?Dm(t,e):M.an.anyOf(t)?eu(t,e):M.an.allOf(t)?Mt(t,e):M.a.discriminator(t)?$m(t,e):M.a.oneOf(t)?Gr(t,e):M.a.not(t)?Wm(t,e):M.an.enum(t)?Um(t):M.a.const(t)?Mm(t):M.a.multipleType(t)?Km(t,e):M.a.primitive(t,"string")?Gm(t):M.a.primitive(t,"number")||M.a.primitive(t,"integer")?qm(t):M.a.primitive(t,"boolean")?Hm(t):M.a.primitive(t,"null")?Lm(t):M.a.conditional(t)?zm(t,e):M.a.ref(t)?Vm(t):jm(t),"selectParser"),M={an:{object:t=>t.type==="object",array:t=>t.type==="array",anyOf:t=>t.anyOf!==void 0,allOf:t=>t.allOf!==void 0,enum:t=>t.enum!==void 0},a:{nullable:t=>t.nullable===!0,multipleType:t=>Array.isArray(t.type),not:t=>t.not!==void 0,const:t=>t.const!==void 0,primitive:(t,e)=>t.type===e,conditional:t=>!!("if"in t&&t.if&&"then"in t&&"else"in t&&t.then&&t.else),discriminator:t=>{var e;return t.oneOf!==void 0&&((e=t.discriminator)==null?void 0:e.propertyName)!==void 0},oneOf:t=>t.oneOf!==void 0,ref:t=>t.$ref!==void 0}},Qm=l(t=>W(t,{seen:new Map,path:[]}),"jsonSchemaToZodStr"),eh=l(t=>{let e=Qm(t);e=e.replaceAll("errors: z.ZodError[]","errors");let n=Am(e);if(!n.sucess)throw new kn(n.error);return n.value},"jsonSchemaToZod"),Ot=l((t,e)=>{var n,r;if(e[B]&&t._def&&(t.naked()._def[B]=e[B]),((n=t._def)==null?void 0:n.typeName)==="ZodObject"&&e.type==="object"&&e.properties&&Object.entries(e.properties).forEach(([i,s])=>{let a=typeof t._def.shape=="function"?t._def.shape():t._def.shape;a[i]&&Ot(a[i],s)}),((r=t._def)==null?void 0:r.typeName)==="ZodRecord"&&e.type==="object"&&e.additionalProperties&&Ot(t._def.valueType,e.additionalProperties),e.type==="array"&&e.items){let i=e.items;if(typeof i=="object"&&!Array.isArray(i)){let s=t._def.type;s&&Ot(s,i)}else Array.isArray(i)&&i.forEach((s,a)=>{let o=t._def;o.typeName===x.ZodTuple&&Ot(o.items[a],s)})}},"applyZuiPropsRecursively"),th=l(t=>{let e=eh(t);return Ot(e,t),e},"fromJSONSchemaLegacy"),nh=l(t=>{var e,n;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(r=>typeof r!="boolean"&&nu(r))&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)==="ZodOptional"},"isOptionalSchema"),rh=l(t=>{var e,n;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(r=>typeof r!="boolean"&&r.type==="null")&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)==="ZodNullable"},"isNullableSchema"),nu=l(t=>{var e,n;return t.not===!0&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)==="ZodUndefined"},"isUndefinedSchema"),ih=l(t=>{var e,n;return!t.not&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)==="ZodUnknown"},"isUnknownSchema"),sh=l(t=>{var e,n;return t.anyOf!==void 0&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)==="ZodDiscriminatedUnion"},"isDiscriminatedUnionSchema"),ah=l(t=>{var e,n;return t.oneOf!==void 0&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)==="ZodDiscriminatedUnion"},"isExclusiveDiscriminatedUnionSchema"),oh=l((t,e)=>lh(t)?ch(t,e):uh(t)?dh(t,e):ph(t,e),"arrayJSONSchemaToZuiArray"),lh=l(t=>Array.isArray(t.items),"_isTuple"),uh=l(t=>t.items!==void 0&&t.uniqueItems,"_isSet"),ch=l(({items:t,additionalItems:e},n)=>{let r=t.map(n),i=Ut(r);return e!==void 0&&(i=i.rest(n(e))),i},"_handleTuple"),dh=l(({items:t,minItems:e,maxItems:n},r)=>{let i=Pn(r(t));return e&&(i=i.min(e)),n&&(i=i.max(n)),i},"_handleSet"),ph=l(({minItems:t,maxItems:e,items:n},r)=>{let i=je(r(n));return t&&t===e?i.length(t):(t&&(i=i.min(t)),e&&(i=i.max(e)),i)},"_handleArray"),fh=l(({type:t,minimum:e,exclusiveMinimum:n,maximum:r,exclusiveMaximum:i,multipleOf:s,format:a})=>{let o=Je();return t==="integer"&&(o=o.int()),a==="finite"&&(o=o.finite()),n!==void 0?o=o.gt(n):e!==void 0&&(o=o.gte(e)),i!==void 0?o=o.lt(i):r!==void 0&&(o=o.lte(r)),s!==void 0&&(o=o.multipleOf(s)),o},"numberJSONSchemaToZuiNumber"),It={};ce(It,{escapeSpecialChars:()=>gh});var gh=l(t=>t.replaceAll(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeSpecialChars");function Jr(t,e,n,r){r?.errorMessages&&n&&(t.errorMessage=f(c({},t.errorMessage),{[e]:n}))}l(Jr,"addErrorMessage");function I(t,e,n,r,i){t[e]=n,Jr(t,e,r,i)}l(I,"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 Yr(t,e){let n=c({type:"string"},t.coerce?{[B]:{coerce:t.coerce||void 0}}:{});function r(i){return e.patternStrategy==="escape"?It.escapeSpecialChars(i):i}if(l(r,"processPattern"),t.checks)for(let i of t.checks)switch(i.kind){case"min":I(n,"minLength",typeof n.minLength=="number"?Math.max(n.minLength,i.value):i.value,i.message,e);break;case"max":I(n,"maxLength",typeof n.maxLength=="number"?Math.min(n.maxLength,i.value):i.value,i.message,e);break;case"email":switch(e.emailStrategy){case"format:email":Ae(n,"email",i.message,e);break;case"format:idn-email":Ae(n,"idn-email",i.message,e);break;case"pattern:zod":ve(n,j.email,i.message,e);break}break;case"url":Ae(n,"uri",i.message,e);break;case"uuid":Ae(n,"uuid",i.message,e);break;case"regex":ve(n,i.regex.source,i.message,e);break;case"cuid":ve(n,j.cuid,i.message,e);break;case"cuid2":ve(n,j.cuid2,i.message,e);break;case"startsWith":ve(n,"^"+r(i.value),i.message,e);break;case"endsWith":ve(n,r(i.value)+"$",i.message,e);break;case"datetime":Ae(n,"date-time",i.message,e);break;case"length":I(n,"minLength",typeof n.minLength=="number"?Math.max(n.minLength,i.value):i.value,i.message,e),I(n,"maxLength",typeof n.maxLength=="number"?Math.min(n.maxLength,i.value):i.value,i.message,e);break;case"includes":{ve(n,r(i.value),i.message,e);break}case"ip":{i.version!=="v6"&&Ae(n,"ipv4",i.message,e),i.version!=="v4"&&Ae(n,"ipv6",i.message,e);break}case"emoji":ve(n,j.emoji,i.message,e);break;case"ulid":{ve(n,j.ulid,i.message,e);break}case"toLowerCase":case"toUpperCase":case"trim":break;default:}return n}l(Yr,"parseStringDef");var Ae=l((t,e,n,r)=>{var i;t.format||(i=t.anyOf)!=null&&i.some(s=>s.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push(c({format:t.format},t.errorMessage&&r.errorMessages&&{errorMessage:{format:t.errorMessage.format}})),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push(c({format:e},n&&r.errorMessages&&{errorMessage:{format:n}}))):I(t,"format",e,n,r)},"addFormat"),ve=l((t,e,n,r)=>{var i;t.pattern||(i=t.allOf)!=null&&i.some(s=>s.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push(c({pattern:t.pattern},t.errorMessage&&r.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}})),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push(c({pattern:e},n&&r.errorMessages&&{errorMessage:{pattern:n}}))):I(t,"pattern",e,n,r)},"addPattern"),mh=l(({format:t,pattern:e,minLength:n,maxLength:r})=>{let i=we();if(n&&r&&n===r?i=i.length(n):(n&&(i=i.min(n)),r&&(i=i.max(r))),t==="cuid"||e===j.cuid)i=i.cuid();else if(t==="cuid2"||e===j.cuid2)i=i.cuid2();else if(t==="emoji"||e===j.emoji)i=i.emoji();else if(t==="ulid"||e===j.ulid)i=i.ulid();else if(t==="date-time"){let{precision:s,offset:a}=e?So(e):{};i=i.datetime({precision:s,offset:a})}else t==="email"||e===j.email?i=i.email():t==="ipv4"||e===j.ipv4?i=i.ip():t==="ipv6"||e===j.ipv6?i=i.ip("v6"):t==="uri"?i=i.url():t==="uuid"||e===j.uuid?i=i.uuid():e&&(i=i.regex(new RegExp(e)));return i},"stringJSONSchemaToZuiString"),gt=l((t,e)=>{let n=[];e.enum!==void 0&&n.push(...e.enum),e.const!==void 0&&n.push(e.const);let r,i=n.filter(a=>typeof a===t),[s]=i;if(s)if(i.length===1)r=Nt(s);else{let a=i.map(o=>Nt(o));r=$e(a)}else if(t==="string"&&e.type==="string"&&(r=mh(e)),t==="number"&&(e.type==="number"||e.type==="integer")&&(r=fh(e)),t==="boolean"&&(r=Ye()),t==="null"&&(r=$t()),!r)throw new kn(`Unknown primitive type: "${t}"`);return e.description&&(r=r.describe(e.description)),r},"toZuiPrimitive"),Ze=ze();function ru(t){return R(t)}l(ru,"fromJSONSchema");function R(t){var e,n,r,i,s,a;if(t===void 0)return Ze;if(t===!0)return ze();if(t===!1)return Rt();if(t.default!==void 0)return R(f(c({},t),{default:void 0})).default(t.default);if(t.readOnly)return R(f(c({},t),{readOnly:void 0})).readonly();if(t.description!==void 0)return R(f(c({},t),{description:void 0})).describe(t.description);if(t.patternProperties!==void 0)throw new De({patternProperties:t.patternProperties});if(t.propertyNames!==void 0)throw new De({propertyNames:t.propertyNames});if(t.if!==void 0)throw new De({if:t.if});if(t.then!==void 0)throw new De({then:t.then});if(t.else!==void 0)throw new De({else:t.else});if(t.$ref!==void 0)return bn(t.$ref);if(t.not!==void 0){if(nu(t))return vn();if(t.not===!0)return Rt();throw new De({not:t.not})}if(Array.isArray(t.type)){if(t.type.length===0)return Ze;if(t.type.length===1)return R(f(c({},t),{type:t.type[0]}));let o=t,{type:u}=o,d=Yi(o,["type"]),p=t.type.map(g=>R(f(c({},d),{type:g})));return $e(p)}if(t.type==="string")return t.enum&&t.enum.length>0?wn(t.enum):gt("string",t);if(t.type==="integer"){let o=gt("number",t);return o.typeName==="ZodNumber"?o.int():o}if(t.type==="number")return gt("number",t);if(t.type==="boolean")return gt("boolean",t);if(t.type==="null")return gt("null",t);if(t.type==="array")return oh(t,R);if(t.type==="object"){if(t.additionalProperties!==void 0&&t.properties!==void 0){let o=R(t.additionalProperties);return R(f(c({},t),{additionalProperties:void 0})).catchall(o)}if(t.properties!==void 0){let o={};for(let[u,d]of Object.entries(t.properties)){let p=R(d),g=(e=t.required)!=null?e:[];o[u]=g.includes(u)||p.isOptional()?p:p.optional()}return at(o)}if(t.additionalProperties!==void 0){let o=R(t.additionalProperties);return Ht(o)}return Ht(Ze)}if(t.anyOf!==void 0){if(t.anyOf.length===0)return Ze;if(t.anyOf.length===1)return R(t.anyOf[0]);if(nh(t))return R(t.anyOf[0]).optional();if(rh(t))return R(t.anyOf[0]).nullable();if(sh(t)&&((r=(n=t["x-zui"])==null?void 0:n.def)!=null&&r.discriminator)){let{discriminator:u}=t["x-zui"].def,d=t.anyOf.map(R);return Dt(u,d)}let o=t.anyOf.map(R);return $e(o)}if(t.oneOf!==void 0){if(t.oneOf.length===0)return Ze;if(t.oneOf.length===1)return R(t.oneOf[0]);if(ah(t)){let u=((i=t.discriminator)==null?void 0:i.propertyName)||((a=(s=t["x-zui"])==null?void 0:s.def)==null?void 0:a.discriminator);if(u){let d=t.oneOf.map(R);return Dt(u,d)}}let o=t.oneOf.map(R);return $e(o)}if(t.allOf!==void 0){if(t.allOf.length===0)return Ze;if(t.allOf.length===1)return R(t.allOf[0]);let[o,...u]=t.allOf,d=R(o),p=R({allOf:u});return xn(d,p)}return t.type,ih(t)?Be():Ze}l(R,"_fromJSONSchema");var hh=/^\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))?$/,pr=l((t,e,n=!0)=>{if(typeof t!="object")throw new cr("Input must be an object");let r=l(a=>{let o=a;return e?.nullable&&(o=o.nullable()),e?.optional&&(o=o.optional()),e?.passtrough&&K.zuiObject(o)&&(o=o.passthrough()),o},"applyOptions"),i=Object.entries(t).reduce((a,[o,u])=>{if(u===null)a[o]=r($t());else switch(typeof u){case"string":a[o]=hh.test(u)?r(we().datetime()):r(we());break;case"number":a[o]=r(Je());break;case"boolean":a[o]=r(Ye());break;case"object":if(Array.isArray(u)){let[d]=u;if(d==null)a[o]=r(je(Be()));else if(typeof d=="object")a[o]=r(je(pr(d,e,!1)));else if(typeof d=="string"||typeof d=="number"||typeof d=="boolean"){let p=yh(d);a[o]=r(je(p))}}else a[o]=r(pr(u,e,!1));break;default:throw new cr(`Unsupported type for key ${o}`)}return a},{}),s=Object.keys(i).length>0;return e?.passtrough||!n&&!s?at(i).passthrough():at(i)},"fromObject"),yh=l(t=>typeof t=="string"?we():typeof t=="number"?Je():typeof t=="boolean"?Ye():Be(),"_getInnerType");function iu(){return{}}l(iu,"parseAnyDef");function su(t,e){var n,r;let i={type:"array"};return((r=(n=t.type)==null?void 0:n._def)==null?void 0:r.typeName)!==x.ZodAny&&(i.items=O(t.type._def,f(c({},e),{currentPath:[...e.currentPath,"items"]}))),t.minLength&&I(i,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&I(i,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(I(i,"minItems",t.exactLength.value,t.exactLength.message,e),I(i,"maxItems",t.exactLength.value,t.exactLength.message,e)),i}l(su,"parseArrayDef");function au(t,e){let n=c({type:"integer",format:"int64"},t.coerce?{[B]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return n;for(let r of t.checks)switch(r.kind){case"min":e.target==="jsonSchema7"?r.inclusive?I(n,"minimum",r.value,r.message,e):I(n,"exclusiveMinimum",r.value,r.message,e):(r.inclusive||(n.exclusiveMinimum=!0),I(n,"minimum",r.value,r.message,e));break;case"max":e.target==="jsonSchema7"?r.inclusive?I(n,"maximum",r.value,r.message,e):I(n,"exclusiveMaximum",r.value,r.message,e):(r.inclusive||(n.exclusiveMaximum=!0),I(n,"maximum",r.value,r.message,e));break;case"multipleOf":I(n,"multipleOf",r.value,r.message,e);break}return n}l(au,"parseBigintDef");function ou(t){return c({type:"boolean"},t.coerce?{[B]:{coerce:t.coerce||void 0}}:{})}l(ou,"parseBooleanDef");function lu(t,e){return O(t.type._def,e)}l(lu,"parseBrandedDef");var vh=l((t,e)=>O(t.innerType._def,e),"parseCatchDef");function uu(t,e){return e.dateStrategy==="integer"?_h(t,e):c({type:"string",format:"date-time"},t.coerce?{[B]:{coerce:t.coerce||void 0}}:{})}l(uu,"parseDateDef");var _h=l((t,e)=>{let n=c({type:"integer",format:"unix-time"},t.coerce?{[B]:{coerce:t.coerce||void 0}}:{});for(let r of t.checks)switch(r.kind){case"min":e.target==="jsonSchema7"&&I(n,"minimum",r.value,r.message,e);break;case"max":e.target==="jsonSchema7"&&I(n,"maximum",r.value,r.message,e);break}return n},"integerDateParser");function cu(t,e){return f(c({},O(t.innerType._def,e)),{default:t.defaultValue()})}l(cu,"parseDefaultDef");function du(t,e){return e.effectStrategy==="input"?O(t.schema._def,e):{}}l(du,"parseEffectsDef");function pu(t){return{type:"string",enum:t.values}}l(pu,"parseEnumDef");var Th=l(t=>"type"in t&&t.type==="string"?!1:"allOf"in t,"isJsonSchema7AllOfType");function fu(t,e){let n=[O(t.left._def,f(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),O(t.right._def,f(c({},e),{currentPath:[...e.currentPath,"allOf","1"]}))].filter(s=>!!s),r=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,i=[];return n.forEach(s=>{if(Th(s))i.push(...s.allOf),s.unevaluatedProperties===void 0&&(r=void 0);else{let a=s;if("additionalProperties"in s&&s.additionalProperties===!1){let o=s,{additionalProperties:u}=o;a=Yi(o,["additionalProperties"])}else r=void 0;i.push(a)}}),i.length?c({allOf:i},r):void 0}l(fu,"parseIntersectionDef");function gu(t,e){let n=typeof t.value;return n!=="bigint"&&n!=="number"&&n!=="boolean"&&n!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:n==="bigint"?"integer":n,enum:[t.value]}:{type:n==="bigint"?"integer":n,const:t.value}}l(gu,"parseLiteralDef");function Xr(t,e){var n,r,i,s,a;if(e.target==="openApi3"&&((n=t.keyType)==null?void 0:n._def.typeName)===x.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((u,d)=>{var p;return f(c({},u),{[d]:(p=O(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"properties",d]})))!=null?p:{}})},{}),additionalProperties:!1};let o={type:"object",additionalProperties:(r=O(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?r:{}};if(e.target==="openApi3")return o;if(((i=t.keyType)==null?void 0:i._def.typeName)===x.ZodString&&((s=t.keyType._def.checks)!=null&&s.length)){let u=Object.entries(Yr(t.keyType._def,e)).reduce((d,[p,g])=>p==="type"?d:f(c({},d),{[p]:g}),{});return f(c({},o),{propertyNames:u})}else if(((a=t.keyType)==null?void 0:a._def.typeName)===x.ZodEnum)return f(c({},o),{propertyNames:{enum:t.keyType._def.values}});return o}l(Xr,"parseRecordDef");function mu(t,e){if(e.mapStrategy==="record")return Xr(t,e);let n=O(t.keyType._def,f(c({},e),{currentPath:[...e.currentPath,"items","items","0"]}))||{},r=O(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"items","items","1"]}))||{};return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}l(mu,"parseMapDef");function hu(t){let e=t.values,r=Object.keys(t.values).filter(s=>typeof e[e[s]]!="number").map(s=>e[s]),i=Array.from(new Set(r.map(s=>typeof s)));return{type:i.length===1?i[0]==="string"?"string":"number":["string","number"],enum:r.filter(s=>typeof s=="string"||typeof s=="number")}}l(hu,"parseNativeEnumDef");function yu(){return{not:{}}}l(yu,"parseNeverDef");function vu(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}l(vu,"parseNullDef");var un={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function _u(t,e){if(e.target==="openApi3")return zi(t,e);let n=t.options instanceof Map?Array.from(t.options.values()):t.options;if(n.every(r=>r._def.typeName in un&&(!r._def.checks||!r._def.checks.length))){let r=n.reduce((i,s)=>{let a=un[s._def.typeName];return a&&!i.includes(a)?[...i,a]:i},[]);return{type:r.length>1?r:r[0]}}else if(n.every(r=>r._def.typeName==="ZodLiteral"&&!r.description)){let r=n.reduce((i,s)=>{let a=typeof s._def.value;switch(a){case"string":case"number":case"boolean":return[...i,a];case"bigint":return[...i,"integer"];case"object":if(s._def.value===null)return[...i,"null"];case"symbol":case"undefined":case"function":default:return i}},[]);if(r.length===n.length){let i=r.filter((s,a,o)=>o.indexOf(s)===a);return{type:i.length>1?i:i[0],enum:n.reduce((s,a)=>s.includes(a._def.value)?s:[...s,a._def.value],[])}}}else if(n.every(r=>r._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((r,i)=>[...r,...i._def.values.filter(s=>!r.includes(s))],[])};return zi(t,e)}l(_u,"parseUnionDef");var zi=l((t,e)=>{let n=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((i,s)=>O(i._def,f(c({},e),{currentPath:[...e.currentPath,e.unionStrategy,`${s}`]}))).filter(i=>!!i&&(!e.strictUnions||typeof i=="object"&&Object.keys(i).length>0)),r=e.discriminator&&t.typeName==="ZodDiscriminatedUnion"&&typeof t.discriminator=="string"?{discriminator:{propertyName:t.discriminator}}:{};if(n.length)return e.unionStrategy==="anyOf"?c({anyOf:n},r):c({oneOf:n},r)},"asUnionOf");function Tu(t,e){let n=t.innerType;if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(n._def.typeName)&&(!n._def.checks||!n._def.checks.length)){if(e.target==="openApi3"){let s={type:un[n._def.typeName],nullable:!0};return fr(n._def,e,s)}let i={type:[un[n._def.typeName],"null"]};return fr(n._def,e,i)}if(e.target==="openApi3"){let i=O(n._def,f(c({},e),{currentPath:[...e.currentPath]}));return i&&f(c({},i),{nullable:!0})}let r=O(n._def,f(c({},e),{currentPath:[...e.currentPath,"anyOf","0"]}));return r&&{anyOf:[r,{type:"null"}]}}l(Tu,"parseNullableDef");function bu(t,e){let n=c({type:"number"},t.coerce?{[B]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return n;for(let r of t.checks)switch(r.kind){case"int":n.type="integer",Jr(n,"type",r.message,e);break;case"min":e.target==="jsonSchema7"?r.inclusive?I(n,"minimum",r.value,r.message,e):I(n,"exclusiveMinimum",r.value,r.message,e):(r.inclusive||(n.exclusiveMinimum=!0),I(n,"minimum",r.value,r.message,e));break;case"max":e.target==="jsonSchema7"?r.inclusive?I(n,"maximum",r.value,r.message,e):I(n,"exclusiveMaximum",r.value,r.message,e):(r.inclusive||(n.exclusiveMaximum=!0),I(n,"maximum",r.value,r.message,e));break;case"multipleOf":I(n,"multipleOf",r.value,r.message,e);break}return n}l(bu,"parseNumberDef");var{zuiKey:kv}=xe,bh=l((t,e)=>{var n;return K.zuiType(t.unknownKeys)?(n=O(t.unknownKeys._def,f(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?n:!0:t.unknownKeys==="passthrough"},"getAdditionalProperties");function wu(t,e){let n=f(c({type:"object"},Object.entries(t.shape()).reduce((r,[i,s])=>{if(s===void 0||s._def===void 0)return r;let a=O(s._def,f(c({},e),{currentPath:[...e.currentPath,"properties",i],propertyPath:[...e.currentPath,"properties",i]}));return a===void 0?r:{properties:f(c({},r.properties),{[i]:a}),required:s.isOptional()?r.required:[...r.required,i]}},{properties:{},required:[]})),{additionalProperties:bh(t,e)});return n.required.length||delete n.required,n}l(wu,"parseObjectDef");var wh=l((t,e)=>{var n;if(e.currentPath.toString()===((n=e.propertyPath)==null?void 0:n.toString()))return O(t.innerType._def,e);let r=O(t.innerType._def,f(c({},e),{currentPath:[...e.currentPath,"anyOf","1"]}));return r?{anyOf:[{not:{}},r]}:{}},"parseOptionalDef"),xh=l((t,e)=>{if(e.pipeStrategy==="input")return O(t.in._def,e);if(e.pipeStrategy==="output")return O(t.out._def,e);let n=O(t.in._def,f(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),r=O(t.out._def,f(c({},e),{currentPath:[...e.currentPath,"allOf",n?"1":"0"]}));return{allOf:[n,r].filter(i=>i!==void 0)}},"parsePipelineDef");function xu(t,e){return O(t.type._def,e)}l(xu,"parsePromiseDef");var Ph=l((t,e)=>O(t.innerType._def,e),"parseReadonlyDef");function Pu(t){return{$ref:t.uri}}l(Pu,"parseRefDef");function ku(t,e){let r={type:"array",uniqueItems:!0,items:O(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"items"]}))};return t.minSize&&I(r,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&I(r,"maxItems",t.maxSize.value,t.maxSize.message,e),r}l(ku,"parseSetDef");function Su(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((n,r)=>O(n._def,f(c({},e),{currentPath:[...e.currentPath,"items",`${r}`]}))).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:O(t.rest._def,f(c({},e),{currentPath:[...e.currentPath,"additionalItems"]}))}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((n,r)=>O(n._def,f(c({},e),{currentPath:[...e.currentPath,"items",`${r}`]}))).reduce((n,r)=>r===void 0?n:[...n,r],[])}}l(Su,"parseTupleDef");function Ou(){return{not:{}}}l(Ou,"parseUndefinedDef");function Eu(){return{}}l(Eu,"parseUnknownDef");function O(t,e,n=!1){let r=e.seen.get(t);if(r&&!n){let a=kh(r,e);if(a!==void 0)return a}let i={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,i);let s=Oh(t,t.typeName,e);return s&&fr(t,e,s),i.jsonSchema=s,s}l(O,"parseDef");var kh=l((t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Sh(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((n,r)=>e.currentPath[r]===n)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),{}):e.$refStrategy==="seen"?{}:void 0}},"get$ref"),Sh=l((t,e)=>{let n=0;for(;n<t.length&&n<e.length&&t[n]===e[n];n++);return[(t.length-n).toString(),...e.slice(n)].join("/")},"getRelativePath"),Oh=l((t,e,n)=>{switch(e){case x.ZodString:return Yr(t,n);case x.ZodNumber:return bu(t,n);case x.ZodObject:return wu(t,n);case x.ZodBigInt:return au(t,n);case x.ZodBoolean:return ou(t);case x.ZodDate:return uu(t,n);case x.ZodUndefined:return Ou();case x.ZodNull:return vu(n);case x.ZodArray:return su(t,n);case x.ZodUnion:case x.ZodDiscriminatedUnion:return _u(t,n);case x.ZodIntersection:return fu(t,n);case x.ZodTuple:return Su(t,n);case x.ZodRecord:return Xr(t,n);case x.ZodRef:return Pu(t);case x.ZodLiteral:return gu(t,n);case x.ZodEnum:return pu(t);case x.ZodNativeEnum:return hu(t);case x.ZodNullable:return Tu(t,n);case x.ZodOptional:return wh(t,n);case x.ZodMap:return mu(t,n);case x.ZodSet:return ku(t,n);case x.ZodLazy:return O(t.getter()._def,n);case x.ZodPromise:return xu(t,n);case x.ZodNaN:case x.ZodNever:return yu();case x.ZodEffects:return du(t,n);case x.ZodAny:return iu();case x.ZodUnknown:return Eu();case x.ZodDefault:return cu(t,n);case x.ZodBranded:return lu(t,n);case x.ZodReadonly:return Ph(t,n);case x.ZodCatch:return vh(t,n);case x.ZodPipeline:return xh(t,n);case x.ZodFunction:case x.ZodVoid:case x.ZodSymbol:return;default:return(r=>{})(e)}},"selectParser"),fr=l((t,e,n)=>(t.description&&(n.description=t.description,e.markdownDescription&&(n.markdownDescription=t.description)),Object.assign(n,{[B]:c(c({},t[B]),n[B])}),n),"addMeta"),Ki={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"},Eh=l(t=>typeof t=="string"?f(c({},Ki),{name:t}):c(c({},Ki),t),"getDefaultOptions"),Ih=l(t=>{let e=Eh(t),n=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return f(c({},e),{currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([r,i])=>[i._def,{def:i._def,path:[...e.basePath,e.definitionPath,r],jsonSchema:void 0}]))})},"getRefs"),Bh=l((t,e)=>{var n;let r=Ih(e),i=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((u,[d,p])=>{var g;return f(c({},u),{[d]:(g=O(p._def,f(c({},r),{currentPath:[...r.basePath,r.definitionPath,d]}),!0))!=null?g:{}})},{}):void 0,s=typeof e=="string"?e:e?.name,a=(n=O(t._def,s===void 0?r:f(c({},r),{currentPath:[...r.basePath,r.definitionPath,s]}),!1))!=null?n:{},o=s===void 0?i?f(c({},a),{[r.definitionPath]:i}):a:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,s].join("/"),[r.definitionPath]:f(c({},i),{[s]:a})};return r.target==="jsonSchema7"?o.$schema="http://json-schema.org/draft-07/schema#":r.target==="jsonSchema2019-09"&&(o.$schema="https://json-schema.org/draft/2019-09/schema#"),o},"zodToJsonSchema"),Ch=l((t,e={target:"openApi3"})=>{let n=Bh(t,e);return e.$schemaUrl===!1?delete n.$schema:typeof e.$schemaUrl=="string"&&(n.$schema=e.$schemaUrl),n},"toJSONSchemaLegacy"),{zuiKey:Gn}=xe,Ah=l((t,e)=>{let n={type:"array",description:t.description,items:e(t._def.type),"x-zui":t._def["x-zui"]};return t._def[Gn]&&(n[Gn]=t._def[Gn]),t._def.minLength&&(n.minItems=t._def.minLength.value),t._def.maxLength&&(n.maxItems=t._def.maxLength.value),t._def.exactLength&&(n.minItems=t._def.exactLength.value,n.maxItems=t._def.exactLength.value),n},"zodArrayToJsonArray"),{zuiKey:Jn}=xe,Zh=l(t=>{let e={type:"number",description:t.description,"x-zui":t._def["x-zui"]};t._def[Jn]&&(e[Jn]=t._def[Jn]);for(let n of t._def.checks)switch(n.kind){case"min":{let r=n.inclusive?"minimum":"exclusiveMinimum",i=n.inclusive?"exclusiveMinimum":"minimum";e[r]=n.value,delete e[i];break}case"max":{let r=n.inclusive?"maximum":"exclusiveMaximum",i=n.inclusive?"exclusiveMaximum":"maximum";e[r]=n.value,delete e[i];break}case"int":e.type="integer";break;case"finite":{e.format="finite";break}case"multipleOf":e.multipleOf=n.value;break;default:}return e},"zodNumberToJsonNumber"),{zuiKey:Yn}=xe,Rh=l((t,e)=>{let n={type:"array",description:t.description,uniqueItems:!0,items:e(t._def.valueType),"x-zui":t._def["x-zui"]};return t._def[Yn]&&(n[Yn]=t._def[Yn]),t._def.minSize&&(n.minItems=t._def.minSize.value),t._def.maxSize&&(n.maxItems=t._def.maxSize.value),n},"zodSetToJsonSet"),{zuiKey:mt}=xe,Nh=l(t=>{let e={type:"string",description:t.description,"x-zui":t._def["x-zui"]};t._def[mt]&&(e[mt]=t._def[mt]);for(let n of t._def.checks)switch(n.kind){case"cuid":e.format="cuid",e.pattern=j.cuid;break;case"cuid2":e.format="cuid2",e.pattern=j.cuid2;break;case"ulid":e.format="ulid",e.pattern=j.ulid;break;case"uuid":e.format="uuid",e.pattern=j.uuid;break;case"emoji":e.format="emoji",e.pattern=j.emoji;break;case"email":e.format="email",e.pattern=j.email;break;case"ip":e.format=n.version==="v6"?"ipv6":"ipv4",e.pattern=n.version==="v6"?j.ipv6:j.ipv4;break;case"datetime":e.format="date-time",(n.precision!==null||n.offset)&&(e.pattern=ko(n).source,e[mt]=f(c({},e[mt]),{precision:n.precision,offset:n.offset}));break;case"url":e.format="uri";break;case"endsWith":e.pattern=`${It.escapeSpecialChars(n.value)}$`;break;case"startsWith":e.pattern=`^${It.escapeSpecialChars(n.value)}`;break;case"includes":let r=n.position&&n.position>=1?`^(?:.{${n.position}}).*`:"";e.pattern=`${r}${It.escapeSpecialChars(n.value)}`;break;case"regex":e.pattern=n.regex.source;break;case"length":e.minLength=e.maxLength=Math.max(0,n.value);break;case"min":e.minLength=Math.max(0,n.value);break;case"max":e.maxLength=Math.max(0,n.value);break;default:throw new Kl({zodType:"ZodString",checkKind:n.kind})}return e},"zodStringToJsonString"),{zuiKey:Xn}=xe,Dh=l((t,e)=>{let n={type:"array",description:t.description,items:t._def.items.map(r=>e(r))};return t._def[Xn]&&(n[Xn]=t._def[Xn]),t._def.rest&&(n.additionalItems=e(t._def.rest)),n},"zodTupleToJsonTuple"),Hh={unionStrategy:"anyOf",discriminatedUnionStrategy:"oneOf",discriminator:!0};function z(t,e={}){let n=c(c({},Hh),e),r=t;switch(r.typeName){case"ZodString":return Nh(r);case"ZodNumber":return Zh(r);case"ZodNaN":throw new Y("ZodNaN");case"ZodBigInt":throw new Y("ZodBigInt",{suggestedAlternative:"serialize bigint to string"});case"ZodBoolean":return{type:"boolean",description:r.description,"x-zui":r._def["x-zui"]};case"ZodDate":throw new Y("ZodDate",{suggestedAlternative:"use z.string().datetime() instead"});case"ZodUndefined":return Qn(r);case"ZodNull":return er(r);case"ZodAny":return{description:r.description,"x-zui":r._def["x-zui"]};case"ZodUnknown":return{description:r.description,"x-zui":f(c({},r._def["x-zui"]),{def:{typeName:"ZodUnknown"}})};case"ZodNever":return{not:!0,description:r.description,"x-zui":r._def["x-zui"]};case"ZodVoid":throw new Y("ZodVoid");case"ZodArray":return Ah(r,p=>z(p,n));case"ZodObject":let i=Object.entries(r.shape),s=i.filter(([p,g])=>!g.isOptional()),a=s.length?s.map(([p])=>p):void 0,o=i.map(([p,g])=>[p,g.mandatory()]).map(([p,g])=>[p,z(g,n)]);return{type:"object",description:r.description,properties:Object.fromEntries(o),required:a,additionalProperties:Mh(r._def,n),"x-zui":r._def["x-zui"]};case"ZodUnion":return n.unionStrategy==="oneOf"?{description:r.description,oneOf:r.options.map(p=>z(p,n)),"x-zui":r._def["x-zui"]}:{description:r.description,anyOf:r.options.map(p=>z(p,n)),"x-zui":r._def["x-zui"]};case"ZodDiscriminatedUnion":if(n.discriminatedUnionStrategy==="oneOf"){let p=n.discriminator?{propertyName:r.discriminator}:void 0;return{description:r.description,oneOf:r.options.map(g=>z(g,n)),discriminator:p,"x-zui":f(c({},r._def["x-zui"]),{def:{typeName:"ZodDiscriminatedUnion",discriminator:r.discriminator}})}}return{description:r.description,anyOf:r.options.map(p=>z(p,n)),"x-zui":f(c({},r._def["x-zui"]),{def:{typeName:"ZodDiscriminatedUnion",discriminator:r.discriminator}})};case"ZodIntersection":let u=z(r._def.left,n),d=z(r._def.right,n);return"additionalProperties"in u&&delete u.additionalProperties,"additionalProperties"in d&&delete d.additionalProperties,{description:r.description,allOf:[u,d],"x-zui":r._def["x-zui"]};case"ZodTuple":return Dh(r,p=>z(p,n));case"ZodRecord":return{type:"object",description:r.description,additionalProperties:z(r._def.valueType,n),"x-zui":r._def["x-zui"]};case"ZodMap":throw new Y("ZodMap");case"ZodSet":return Rh(r,p=>z(p,n));case"ZodFunction":throw new Y("ZodFunction");case"ZodLazy":throw new Y("ZodLazy");case"ZodLiteral":if(typeof r.value=="string")return{type:"string",description:r.description,const:r.value,"x-zui":r._def["x-zui"]};if(typeof r.value=="number")return{type:"number",description:r.description,const:r.value,"x-zui":r._def["x-zui"]};if(typeof r.value=="boolean")return{type:"boolean",description:r.description,const:r.value,"x-zui":r._def["x-zui"]};if(r.value===null)return er(r._def);if(r.value===void 0)return Qn(r._def);{r.value;let p=typeof r.value;throw new Sn(`Unsupported literal type: "${p}"`)}case"ZodEnum":return{type:"string",description:r.description,enum:r._def.values,"x-zui":r._def["x-zui"]};case"ZodEffects":throw new Y("ZodEffects");case"ZodNativeEnum":throw new Y("ZodNativeEnum");case"ZodOptional":return{description:r.description,anyOf:[z(r._def.innerType,n),Qn()],"x-zui":f(c({},r._def["x-zui"]),{def:{typeName:"ZodOptional"}})};case"ZodNullable":return{anyOf:[z(r._def.innerType,n),er()],"x-zui":f(c({},r._def["x-zui"]),{def:{typeName:"ZodNullable"}})};case"ZodDefault":return f(c({},z(r._def.innerType,n)),{default:r._def.defaultValue()});case"ZodCatch":throw new Y("ZodCatch");case"ZodPromise":throw new Y("ZodPromise");case"ZodBranded":throw new Y("ZodBranded");case"ZodPipeline":throw new Y("ZodPipeline");case"ZodSymbol":throw new Y("ZodPipeline");case"ZodReadonly":return f(c({},z(r._def.innerType,n)),{readOnly:!0});case"ZodRef":return{$ref:r._def.uri,description:r.description,"x-zui":r._def["x-zui"]};default:ue.assertNever(r)}}l(z,"toJSONSchema");var Qn=l(t=>({not:!0,description:t?.description,"x-zui":f(c({},t?.["x-zui"]),{def:{typeName:"ZodUndefined"}})}),"undefinedSchema"),er=l(t=>({type:"null",description:t?.description,"x-zui":t?.["x-zui"]}),"nullSchema"),Mh=l((t,e)=>t.unknownKeys==="passthrough"?!0:t.unknownKeys==="strict"||!K.zuiType(t.unknownKeys)||t.unknownKeys.typeName==="ZodNever"?!1:z(t.unknownKeys,e),"additionalPropertiesSchema");function Iu(t){return typeof t=="symbol"?"symbol":typeof t=="bigint"?`${t.toString()}n`:v(t)}l(Iu,"primitiveToTypscriptLiteralType");function v(t){return typeof t>"u"?"undefined":typeof t=="symbol"?t.description?`Symbol(${v(t.description)})`:"Symbol()":typeof t=="bigint"?`BigInt(${t.toString()})`:typeof t=="string"?Au(t):JSON.stringify(t)}l(v,"primitiveToTypescriptValue");function it(t){return typeof t>"u"?"undefined":JSON.stringify(t)}l(it,"unknownToTypescriptValue");var Bu=l((t,e)=>{let n=Object.entries(t),r=e?" as const":"";return`{ ${n.map(([i,s])=>`${gr(i)}: ${it(s)}`).join(", ")} }${r}`},"recordOfUnknownToTypescriptRecord"),gr=l(t=>/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t)?t:v(t),"toPropertyKey"),jh=l(t=>t.charAt(0).toUpperCase()+t.slice(1),"capitalize"),Cu=l(t=>{let e=/[^a-zA-Z0-9_]/g;return t.split(e).map(jh).filter(r=>!!r).join("")},"toTypeArgumentName"),Wi=l(t=>{for(var e;t.length&&!((e=t[0])!=null&&e.trim());)t.shift();for(;t.length&&!t[t.length-1].trim();)t.pop()},"trimEmptyLinesInPlace"),U=l(t=>{t=t?.replace(/(\n(\s*)?){3,}/g,`
57
+ `,i+="})"}let s=n?i?n+i:r?r==="z.never()"?n+".strict()":n+`.catchall(${r})`:n:i||(r?`z.record(${r})`:"z.record(z.any())");return M.an.anyOf(t)&&(s+=`.and(${nu(f(c({},t),{anyOf:t.anyOf.map(a=>typeof a=="object"&&!a.type&&(a.properties||a.additionalProperties||a.patternProperties)?f(c({},a),{type:"object"}):a)}),e)})`),M.a.oneOf(t)&&(s+=`.and(${Jr(f(c({},t),{oneOf:t.oneOf.map(a=>typeof a=="object"&&!a.type&&(a.properties||a.additionalProperties||a.patternProperties)?f(c({},a),{type:"object"}):a)}),e)})`),M.an.allOf(t)&&(s+=`.and(${jt(f(c({},t),{allOf:t.allOf.map(a=>typeof a=="object"&&!a.type&&(a.properties||a.additionalProperties||a.patternProperties)?f(c({},a),{type:"object"}):a)}),e)})`),s}l(ru,"parseObject");var Jm=l(t=>`z.ref('${t.$ref}')`,"parseRef"),Ym=l(t=>{var e;let n="z.string()";if((e=t[B])!=null&&e.coerce){if(t.format==="date-time")return"z.coerce.date()";n="z.coerce.string()"}return n+=q(t,"format",({value:r})=>{switch(r){case"email":return[".email(",")"];case"ip":return[".ip(",")"];case"ipv4":return['.ip({ version: "v4"',", message: "," })"];case"ipv6":return['.ip({ version: "v6"',", message: "," })"];case"uri":return[".url(",")"];case"uuid":return[".uuid(",")"];case"date-time":return[".datetime(",")"]}}),n+=q(t,"pattern",({json:r})=>[`.regex(new RegExp(${r})`,", ",")"]),n+=q(t,"minLength",({json:r})=>[`.min(${r}`,", ",")"]),n+=q(t,"maxLength",({json:r})=>[`.max(${r}`,", ",")"]),n},"parseString"),W=l((t,e={seen:new Map,path:[]},n)=>{if(typeof t!="object")return t?"z.any()":"z.never()";if(e.parserOverride){let s=e.parserOverride(t,e);if(typeof s=="string")return s}let r=e.seen.get(t);if(r){if(r.r!==void 0)return r.r;if(e.depth===void 0||r.n>=e.depth)return"z.any()";r.n+=1}else r={r:void 0,n:0},e.seen.set(t,r);let i=eh(t,e);return n||(i=Xm(t,i),e.withoutDefaults||(i=Qm(t,i))),r.r=i,i},"parseSchema"),Xm=l((t,e)=>(t.description&&(e+=`.describe(${JSON.stringify(t.description)})`),e),"addMeta"),Qm=l((t,e)=>(t.default!==void 0&&(e+=`.default(${JSON.stringify(t.default)})`),e),"addDefaults"),eh=l((t,e)=>M.a.nullable(t)?Vm(t,e):M.an.object(t)?ru(t,e):M.an.array(t)?Mm(t,e):M.an.anyOf(t)?nu(t,e):M.an.allOf(t)?jt(t,e):M.a.discriminator(t)?zm(t,e):M.a.oneOf(t)?Jr(t,e):M.a.not(t)?Fm(t,e):M.an.enum(t)?Km(t):M.a.const(t)?$m(t):M.a.multipleType(t)?Lm(t,e):M.a.primitive(t,"string")?Ym(t):M.a.primitive(t,"number")||M.a.primitive(t,"integer")?Gm(t):M.a.primitive(t,"boolean")?jm(t):M.a.primitive(t,"null")?qm(t):M.a.conditional(t)?Wm(t,e):M.a.ref(t)?Jm(t):Um(t),"selectParser"),M={an:{object:t=>t.type==="object",array:t=>t.type==="array",anyOf:t=>t.anyOf!==void 0,allOf:t=>t.allOf!==void 0,enum:t=>t.enum!==void 0},a:{nullable:t=>t.nullable===!0,multipleType:t=>Array.isArray(t.type),not:t=>t.not!==void 0,const:t=>t.const!==void 0,primitive:(t,e)=>t.type===e,conditional:t=>!!("if"in t&&t.if&&"then"in t&&"else"in t&&t.then&&t.else),discriminator:t=>{var e;return t.oneOf!==void 0&&((e=t.discriminator)==null?void 0:e.propertyName)!==void 0},oneOf:t=>t.oneOf!==void 0,ref:t=>t.$ref!==void 0}},th=l(t=>W(t,{seen:new Map,path:[]}),"jsonSchemaToZodStr"),nh=l(t=>{let e=th(t);e=e.replaceAll("errors: z.ZodError[]","errors");let n=Rm(e);if(!n.sucess)throw new Sn(n.error);return n.value},"jsonSchemaToZod"),Et=l((t,e)=>{var n,r;if(e[B]&&t._def&&(t.naked()._def[B]=e[B]),((n=t._def)==null?void 0:n.typeName)==="ZodObject"&&e.type==="object"&&e.properties&&Object.entries(e.properties).forEach(([i,s])=>{let a=typeof t._def.shape=="function"?t._def.shape():t._def.shape;a[i]&&Et(a[i],s)}),((r=t._def)==null?void 0:r.typeName)==="ZodRecord"&&e.type==="object"&&e.additionalProperties&&Et(t._def.valueType,e.additionalProperties),e.type==="array"&&e.items){let i=e.items;if(typeof i=="object"&&!Array.isArray(i)){let s=t._def.type;s&&Et(s,i)}else Array.isArray(i)&&i.forEach((s,a)=>{let o=t._def;o.typeName===x.ZodTuple&&Et(o.items[a],s)})}},"applyZuiPropsRecursively"),rh=l(t=>{let e=nh(t);return Et(e,t),e},"fromJSONSchemaLegacy"),ih=l(t=>{var e,n;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(r=>typeof r!="boolean"&&iu(r))&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)==="ZodOptional"},"isOptionalSchema"),sh=l(t=>{var e,n;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(r=>typeof r!="boolean"&&r.type==="null")&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)==="ZodNullable"},"isNullableSchema"),iu=l(t=>{var e,n;return t.not===!0&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)==="ZodUndefined"},"isUndefinedSchema"),ah=l(t=>{var e,n;return!t.not&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)==="ZodUnknown"},"isUnknownSchema"),oh=l(t=>{var e,n;return t.anyOf!==void 0&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)==="ZodDiscriminatedUnion"},"isDiscriminatedUnionSchema"),lh=l(t=>{var e,n;return t.oneOf!==void 0&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)==="ZodDiscriminatedUnion"},"isExclusiveDiscriminatedUnionSchema"),uh=l((t,e)=>ch(t)?ph(t,e):dh(t)?fh(t,e):gh(t,e),"arrayJSONSchemaToZuiArray"),ch=l(t=>Array.isArray(t.items),"_isTuple"),dh=l(t=>t.items!==void 0&&t.uniqueItems,"_isSet"),ph=l(({items:t,additionalItems:e},n)=>{let r=t.map(n),i=zt(r);return e!==void 0&&(i=i.rest(n(e))),i},"_handleTuple"),fh=l(({items:t,minItems:e,maxItems:n},r)=>{let i=kn(r(t));return e&&(i=i.min(e)),n&&(i=i.max(n)),i},"_handleSet"),gh=l(({minItems:t,maxItems:e,items:n},r)=>{let i=Ue(r(n));return t&&t===e?i.length(t):(t&&(i=i.min(t)),e&&(i=i.max(e)),i)},"_handleArray"),mh=l(({type:t,minimum:e,exclusiveMinimum:n,maximum:r,exclusiveMaximum:i,multipleOf:s,format:a})=>{let o=Xe();return t==="integer"&&(o=o.int()),a==="finite"&&(o=o.finite()),n!==void 0?o=o.gt(n):e!==void 0&&(o=o.gte(e)),i!==void 0?o=o.lt(i):r!==void 0&&(o=o.lte(r)),s!==void 0&&(o=o.multipleOf(s)),o},"numberJSONSchemaToZuiNumber"),Bt={};de(Bt,{escapeSpecialChars:()=>hh});var hh=l(t=>t.replaceAll(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeSpecialChars");function Yr(t,e,n,r){r?.errorMessages&&n&&(t.errorMessage=f(c({},t.errorMessage),{[e]:n}))}l(Yr,"addErrorMessage");function I(t,e,n,r,i){t[e]=n,Yr(t,e,r,i)}l(I,"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 Xr(t,e){let n=c({type:"string"},t.coerce?{[B]:{coerce:t.coerce||void 0}}:{});function r(i){return e.patternStrategy==="escape"?Bt.escapeSpecialChars(i):i}if(l(r,"processPattern"),t.checks)for(let i of t.checks)switch(i.kind){case"min":I(n,"minLength",typeof n.minLength=="number"?Math.max(n.minLength,i.value):i.value,i.message,e);break;case"max":I(n,"maxLength",typeof n.maxLength=="number"?Math.min(n.maxLength,i.value):i.value,i.message,e);break;case"email":switch(e.emailStrategy){case"format:email":Re(n,"email",i.message,e);break;case"format:idn-email":Re(n,"idn-email",i.message,e);break;case"pattern:zod":_e(n,j.email,i.message,e);break}break;case"url":Re(n,"uri",i.message,e);break;case"uuid":Re(n,"uuid",i.message,e);break;case"regex":_e(n,i.regex.source,i.message,e);break;case"cuid":_e(n,j.cuid,i.message,e);break;case"cuid2":_e(n,j.cuid2,i.message,e);break;case"startsWith":_e(n,"^"+r(i.value),i.message,e);break;case"endsWith":_e(n,r(i.value)+"$",i.message,e);break;case"datetime":Re(n,"date-time",i.message,e);break;case"length":I(n,"minLength",typeof n.minLength=="number"?Math.max(n.minLength,i.value):i.value,i.message,e),I(n,"maxLength",typeof n.maxLength=="number"?Math.min(n.maxLength,i.value):i.value,i.message,e);break;case"includes":{_e(n,r(i.value),i.message,e);break}case"ip":{i.version!=="v6"&&Re(n,"ipv4",i.message,e),i.version!=="v4"&&Re(n,"ipv6",i.message,e);break}case"emoji":_e(n,j.emoji,i.message,e);break;case"ulid":{_e(n,j.ulid,i.message,e);break}case"toLowerCase":case"toUpperCase":case"trim":break;default:}return n}l(Xr,"parseStringDef");var Re=l((t,e,n,r)=>{var i;t.format||(i=t.anyOf)!=null&&i.some(s=>s.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push(c({format:t.format},t.errorMessage&&r.errorMessages&&{errorMessage:{format:t.errorMessage.format}})),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push(c({format:e},n&&r.errorMessages&&{errorMessage:{format:n}}))):I(t,"format",e,n,r)},"addFormat"),_e=l((t,e,n,r)=>{var i;t.pattern||(i=t.allOf)!=null&&i.some(s=>s.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push(c({pattern:t.pattern},t.errorMessage&&r.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}})),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push(c({pattern:e},n&&r.errorMessages&&{errorMessage:{pattern:n}}))):I(t,"pattern",e,n,r)},"addPattern"),yh=l(({format:t,pattern:e,minLength:n,maxLength:r})=>{let i=xe();if(n&&r&&n===r?i=i.length(n):(n&&(i=i.min(n)),r&&(i=i.max(r))),t==="cuid"||e===j.cuid)i=i.cuid();else if(t==="cuid2"||e===j.cuid2)i=i.cuid2();else if(t==="emoji"||e===j.emoji)i=i.emoji();else if(t==="ulid"||e===j.ulid)i=i.ulid();else if(t==="date-time"){let{precision:s,offset:a}=e?Eo(e):{};i=i.datetime({precision:s,offset:a})}else t==="email"||e===j.email?i=i.email():t==="ipv4"||e===j.ipv4?i=i.ip():t==="ipv6"||e===j.ipv6?i=i.ip("v6"):t==="uri"?i=i.url():t==="uuid"||e===j.uuid?i=i.uuid():e&&(i=i.regex(new RegExp(e)));return i},"stringJSONSchemaToZuiString"),mt=l((t,e)=>{let n=[];e.enum!==void 0&&n.push(...e.enum),e.const!==void 0&&n.push(e.const);let r,i=n.filter(a=>typeof a===t),[s]=i;if(s)if(i.length===1)r=Dt(s);else{let a=i.map(o=>Dt(o));r=ze(a)}else if(t==="string"&&e.type==="string"&&(r=yh(e)),t==="number"&&(e.type==="number"||e.type==="integer")&&(r=mh(e)),t==="boolean"&&(r=Qe()),t==="null"&&(r=Ut()),!r)throw new Sn(`Unknown primitive type: "${t}"`);return e.description&&(r=r.describe(e.description)),r},"toZuiPrimitive"),Ne=We();function su(t){return R(t)}l(su,"fromJSONSchema");function R(t){var e,n,r,i,s,a;if(t===void 0)return Ne;if(t===!0)return We();if(t===!1)return Nt();if(t.default!==void 0)return R(f(c({},t),{default:void 0})).default(t.default);if(t.readOnly)return R(f(c({},t),{readOnly:void 0})).readonly();if(t.description!==void 0)return R(f(c({},t),{description:void 0})).describe(t.description);if(t.patternProperties!==void 0)throw new Me({patternProperties:t.patternProperties});if(t.propertyNames!==void 0)throw new Me({propertyNames:t.propertyNames});if(t.if!==void 0)throw new Me({if:t.if});if(t.then!==void 0)throw new Me({then:t.then});if(t.else!==void 0)throw new Me({else:t.else});if(t.$ref!==void 0)return wn(t.$ref);if(t.not!==void 0){if(iu(t))return _n();if(t.not===!0)return Nt();throw new Me({not:t.not})}if(Array.isArray(t.type)){if(t.type.length===0)return Ne;if(t.type.length===1)return R(f(c({},t),{type:t.type[0]}));let o=t,{type:u}=o,d=Qi(o,["type"]),p=t.type.map(g=>R(f(c({},d),{type:g})));return ze(p)}if(t.type==="string")return t.enum&&t.enum.length>0?xn(t.enum):mt("string",t);if(t.type==="integer"){let o=mt("number",t);return o.typeName==="ZodNumber"?o.int():o}if(t.type==="number")return mt("number",t);if(t.type==="boolean")return mt("boolean",t);if(t.type==="null")return mt("null",t);if(t.type==="array")return uh(t,R);if(t.type==="object"){if(t.additionalProperties!==void 0&&t.properties!==void 0){let o=R(t.additionalProperties);return R(f(c({},t),{additionalProperties:void 0})).catchall(o)}if(t.properties!==void 0){let o={};for(let[u,d]of Object.entries(t.properties)){let p=R(d),g=(e=t.required)!=null?e:[];o[u]=g.includes(u)||p.isOptional()?p:p.optional()}return ot(o)}if(t.additionalProperties!==void 0){let o=R(t.additionalProperties);return Mt(o)}return Mt(Ne)}if(t.anyOf!==void 0){if(t.anyOf.length===0)return Ne;if(t.anyOf.length===1)return R(t.anyOf[0]);if(ih(t))return R(t.anyOf[0]).optional();if(sh(t))return R(t.anyOf[0]).nullable();if(oh(t)&&((r=(n=t["x-zui"])==null?void 0:n.def)!=null&&r.discriminator)){let{discriminator:u}=t["x-zui"].def,d=t.anyOf.map(R);return Ht(u,d)}let o=t.anyOf.map(R);return ze(o)}if(t.oneOf!==void 0){if(t.oneOf.length===0)return Ne;if(t.oneOf.length===1)return R(t.oneOf[0]);if(lh(t)){let u=((i=t.discriminator)==null?void 0:i.propertyName)||((a=(s=t["x-zui"])==null?void 0:s.def)==null?void 0:a.discriminator);if(u){let d=t.oneOf.map(R);return Ht(u,d)}}let o=t.oneOf.map(R);return ze(o)}if(t.allOf!==void 0){if(t.allOf.length===0)return Ne;if(t.allOf.length===1)return R(t.allOf[0]);let[o,...u]=t.allOf,d=R(o),p=R({allOf:u});return Pn(d,p)}return t.type,ah(t)?Ce():Ne}l(R,"_fromJSONSchema");var vh=/^\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))?$/,fr=l((t,e,n=!0)=>{if(typeof t!="object")throw new dr("Input must be an object");let r=l(a=>{let o=a;return e?.nullable&&(o=o.nullable()),e?.optional&&(o=o.optional()),e?.passtrough&&K.zuiObject(o)&&(o=o.passthrough()),o},"applyOptions"),i=Object.entries(t).reduce((a,[o,u])=>{if(u===null)a[o]=r(Ut());else switch(typeof u){case"string":a[o]=vh.test(u)?r(xe().datetime()):r(xe());break;case"number":a[o]=r(Xe());break;case"boolean":a[o]=r(Qe());break;case"object":if(Array.isArray(u)){let[d]=u;if(d==null)a[o]=r(Ue(Ce()));else if(typeof d=="object")a[o]=r(Ue(fr(d,e,!1)));else if(typeof d=="string"||typeof d=="number"||typeof d=="boolean"){let p=_h(d);a[o]=r(Ue(p))}}else a[o]=r(fr(u,e,!1));break;default:throw new dr(`Unsupported type for key ${o}`)}return a},{}),s=Object.keys(i).length>0;return e?.passtrough||!n&&!s?ot(i).passthrough():ot(i)},"fromObject"),_h=l(t=>typeof t=="string"?xe():typeof t=="number"?Xe():typeof t=="boolean"?Qe():Ce(),"_getInnerType");function au(){return{}}l(au,"parseAnyDef");function ou(t,e){var n,r;let i={type:"array"};return((r=(n=t.type)==null?void 0:n._def)==null?void 0:r.typeName)!==x.ZodAny&&(i.items=O(t.type._def,f(c({},e),{currentPath:[...e.currentPath,"items"]}))),t.minLength&&I(i,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&I(i,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(I(i,"minItems",t.exactLength.value,t.exactLength.message,e),I(i,"maxItems",t.exactLength.value,t.exactLength.message,e)),i}l(ou,"parseArrayDef");function lu(t,e){let n=c({type:"integer",format:"int64"},t.coerce?{[B]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return n;for(let r of t.checks)switch(r.kind){case"min":e.target==="jsonSchema7"?r.inclusive?I(n,"minimum",r.value,r.message,e):I(n,"exclusiveMinimum",r.value,r.message,e):(r.inclusive||(n.exclusiveMinimum=!0),I(n,"minimum",r.value,r.message,e));break;case"max":e.target==="jsonSchema7"?r.inclusive?I(n,"maximum",r.value,r.message,e):I(n,"exclusiveMaximum",r.value,r.message,e):(r.inclusive||(n.exclusiveMaximum=!0),I(n,"maximum",r.value,r.message,e));break;case"multipleOf":I(n,"multipleOf",r.value,r.message,e);break}return n}l(lu,"parseBigintDef");function uu(t){return c({type:"boolean"},t.coerce?{[B]:{coerce:t.coerce||void 0}}:{})}l(uu,"parseBooleanDef");function cu(t,e){return O(t.type._def,e)}l(cu,"parseBrandedDef");var Th=l((t,e)=>O(t.innerType._def,e),"parseCatchDef");function du(t,e){return e.dateStrategy==="integer"?bh(t,e):c({type:"string",format:"date-time"},t.coerce?{[B]:{coerce:t.coerce||void 0}}:{})}l(du,"parseDateDef");var bh=l((t,e)=>{let n=c({type:"integer",format:"unix-time"},t.coerce?{[B]:{coerce:t.coerce||void 0}}:{});for(let r of t.checks)switch(r.kind){case"min":e.target==="jsonSchema7"&&I(n,"minimum",r.value,r.message,e);break;case"max":e.target==="jsonSchema7"&&I(n,"maximum",r.value,r.message,e);break}return n},"integerDateParser");function pu(t,e){return f(c({},O(t.innerType._def,e)),{default:t.defaultValue()})}l(pu,"parseDefaultDef");function fu(t,e){return e.effectStrategy==="input"?O(t.schema._def,e):{}}l(fu,"parseEffectsDef");function gu(t){return{type:"string",enum:t.values}}l(gu,"parseEnumDef");var wh=l(t=>"type"in t&&t.type==="string"?!1:"allOf"in t,"isJsonSchema7AllOfType");function mu(t,e){let n=[O(t.left._def,f(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),O(t.right._def,f(c({},e),{currentPath:[...e.currentPath,"allOf","1"]}))].filter(s=>!!s),r=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,i=[];return n.forEach(s=>{if(wh(s))i.push(...s.allOf),s.unevaluatedProperties===void 0&&(r=void 0);else{let a=s;if("additionalProperties"in s&&s.additionalProperties===!1){let o=s,{additionalProperties:u}=o;a=Qi(o,["additionalProperties"])}else r=void 0;i.push(a)}}),i.length?c({allOf:i},r):void 0}l(mu,"parseIntersectionDef");function hu(t,e){let n=typeof t.value;return n!=="bigint"&&n!=="number"&&n!=="boolean"&&n!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:n==="bigint"?"integer":n,enum:[t.value]}:{type:n==="bigint"?"integer":n,const:t.value}}l(hu,"parseLiteralDef");function Qr(t,e){var n,r,i,s,a;if(e.target==="openApi3"&&((n=t.keyType)==null?void 0:n._def.typeName)===x.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((u,d)=>{var p;return f(c({},u),{[d]:(p=O(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"properties",d]})))!=null?p:{}})},{}),additionalProperties:!1};let o={type:"object",additionalProperties:(r=O(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?r:{}};if(e.target==="openApi3")return o;if(((i=t.keyType)==null?void 0:i._def.typeName)===x.ZodString&&((s=t.keyType._def.checks)!=null&&s.length)){let u=Object.entries(Xr(t.keyType._def,e)).reduce((d,[p,g])=>p==="type"?d:f(c({},d),{[p]:g}),{});return f(c({},o),{propertyNames:u})}else if(((a=t.keyType)==null?void 0:a._def.typeName)===x.ZodEnum)return f(c({},o),{propertyNames:{enum:t.keyType._def.values}});return o}l(Qr,"parseRecordDef");function yu(t,e){if(e.mapStrategy==="record")return Qr(t,e);let n=O(t.keyType._def,f(c({},e),{currentPath:[...e.currentPath,"items","items","0"]}))||{},r=O(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"items","items","1"]}))||{};return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}l(yu,"parseMapDef");function vu(t){let e=t.values,r=Object.keys(t.values).filter(s=>typeof e[e[s]]!="number").map(s=>e[s]),i=Array.from(new Set(r.map(s=>typeof s)));return{type:i.length===1?i[0]==="string"?"string":"number":["string","number"],enum:r.filter(s=>typeof s=="string"||typeof s=="number")}}l(vu,"parseNativeEnumDef");function _u(){return{not:{}}}l(_u,"parseNeverDef");function Tu(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}l(Tu,"parseNullDef");var cn={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function bu(t,e){if(e.target==="openApi3")return Wi(t,e);let n=t.options instanceof Map?Array.from(t.options.values()):t.options;if(n.every(r=>r._def.typeName in cn&&(!r._def.checks||!r._def.checks.length))){let r=n.reduce((i,s)=>{let a=cn[s._def.typeName];return a&&!i.includes(a)?[...i,a]:i},[]);return{type:r.length>1?r:r[0]}}else if(n.every(r=>r._def.typeName==="ZodLiteral"&&!r.description)){let r=n.reduce((i,s)=>{let a=typeof s._def.value;switch(a){case"string":case"number":case"boolean":return[...i,a];case"bigint":return[...i,"integer"];case"object":if(s._def.value===null)return[...i,"null"];case"symbol":case"undefined":case"function":default:return i}},[]);if(r.length===n.length){let i=r.filter((s,a,o)=>o.indexOf(s)===a);return{type:i.length>1?i:i[0],enum:n.reduce((s,a)=>s.includes(a._def.value)?s:[...s,a._def.value],[])}}}else if(n.every(r=>r._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((r,i)=>[...r,...i._def.values.filter(s=>!r.includes(s))],[])};return Wi(t,e)}l(bu,"parseUnionDef");var Wi=l((t,e)=>{let n=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((i,s)=>O(i._def,f(c({},e),{currentPath:[...e.currentPath,e.unionStrategy,`${s}`]}))).filter(i=>!!i&&(!e.strictUnions||typeof i=="object"&&Object.keys(i).length>0)),r=e.discriminator&&t.typeName==="ZodDiscriminatedUnion"&&typeof t.discriminator=="string"?{discriminator:{propertyName:t.discriminator}}:{};if(n.length)return e.unionStrategy==="anyOf"?c({anyOf:n},r):c({oneOf:n},r)},"asUnionOf");function wu(t,e){let n=t.innerType;if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(n._def.typeName)&&(!n._def.checks||!n._def.checks.length)){if(e.target==="openApi3"){let s={type:cn[n._def.typeName],nullable:!0};return gr(n._def,e,s)}let i={type:[cn[n._def.typeName],"null"]};return gr(n._def,e,i)}if(e.target==="openApi3"){let i=O(n._def,f(c({},e),{currentPath:[...e.currentPath]}));return i&&f(c({},i),{nullable:!0})}let r=O(n._def,f(c({},e),{currentPath:[...e.currentPath,"anyOf","0"]}));return r&&{anyOf:[r,{type:"null"}]}}l(wu,"parseNullableDef");function xu(t,e){let n=c({type:"number"},t.coerce?{[B]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return n;for(let r of t.checks)switch(r.kind){case"int":n.type="integer",Yr(n,"type",r.message,e);break;case"min":e.target==="jsonSchema7"?r.inclusive?I(n,"minimum",r.value,r.message,e):I(n,"exclusiveMinimum",r.value,r.message,e):(r.inclusive||(n.exclusiveMinimum=!0),I(n,"minimum",r.value,r.message,e));break;case"max":e.target==="jsonSchema7"?r.inclusive?I(n,"maximum",r.value,r.message,e):I(n,"exclusiveMaximum",r.value,r.message,e):(r.inclusive||(n.exclusiveMaximum=!0),I(n,"maximum",r.value,r.message,e));break;case"multipleOf":I(n,"multipleOf",r.value,r.message,e);break}return n}l(xu,"parseNumberDef");var{zuiKey:Ev}=Pe,xh=l((t,e)=>{var n;return K.zuiType(t.unknownKeys)?t.unknownKeys.typeName==="ZodNever"?!1:(n=O(t.unknownKeys._def,f(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?n:!0:t.unknownKeys==="passthrough"},"getAdditionalProperties");function Pu(t,e){let n=f(c({type:"object"},Object.entries(t.shape()).reduce((r,[i,s])=>{if(s===void 0||s._def===void 0)return r;let a=O(s._def,f(c({},e),{currentPath:[...e.currentPath,"properties",i],propertyPath:[...e.currentPath,"properties",i]}));return a===void 0?r:{properties:f(c({},r.properties),{[i]:a}),required:s.isOptional()?r.required:[...r.required,i]}},{properties:{},required:[]})),{additionalProperties:xh(t,e)});return n.required.length||delete n.required,n}l(Pu,"parseObjectDef");var Ph=l((t,e)=>{var n;if(e.currentPath.toString()===((n=e.propertyPath)==null?void 0:n.toString()))return O(t.innerType._def,e);let r=O(t.innerType._def,f(c({},e),{currentPath:[...e.currentPath,"anyOf","1"]}));return r?{anyOf:[{not:{}},r]}:{}},"parseOptionalDef"),kh=l((t,e)=>{if(e.pipeStrategy==="input")return O(t.in._def,e);if(e.pipeStrategy==="output")return O(t.out._def,e);let n=O(t.in._def,f(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),r=O(t.out._def,f(c({},e),{currentPath:[...e.currentPath,"allOf",n?"1":"0"]}));return{allOf:[n,r].filter(i=>i!==void 0)}},"parsePipelineDef");function ku(t,e){return O(t.type._def,e)}l(ku,"parsePromiseDef");var Sh=l((t,e)=>O(t.innerType._def,e),"parseReadonlyDef");function Su(t){return{$ref:t.uri}}l(Su,"parseRefDef");function Ou(t,e){let r={type:"array",uniqueItems:!0,items:O(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"items"]}))};return t.minSize&&I(r,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&I(r,"maxItems",t.maxSize.value,t.maxSize.message,e),r}l(Ou,"parseSetDef");function Eu(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((n,r)=>O(n._def,f(c({},e),{currentPath:[...e.currentPath,"items",`${r}`]}))).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:O(t.rest._def,f(c({},e),{currentPath:[...e.currentPath,"additionalItems"]}))}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((n,r)=>O(n._def,f(c({},e),{currentPath:[...e.currentPath,"items",`${r}`]}))).reduce((n,r)=>r===void 0?n:[...n,r],[])}}l(Eu,"parseTupleDef");function Iu(){return{not:{}}}l(Iu,"parseUndefinedDef");function Bu(){return{}}l(Bu,"parseUnknownDef");function O(t,e,n=!1){let r=e.seen.get(t);if(r&&!n){let a=Oh(r,e);if(a!==void 0)return a}let i={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,i);let s=Ih(t,t.typeName,e);return s&&gr(t,e,s),i.jsonSchema=s,s}l(O,"parseDef");var Oh=l((t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Eh(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((n,r)=>e.currentPath[r]===n)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),{}):e.$refStrategy==="seen"?{}:void 0}},"get$ref"),Eh=l((t,e)=>{let n=0;for(;n<t.length&&n<e.length&&t[n]===e[n];n++);return[(t.length-n).toString(),...e.slice(n)].join("/")},"getRelativePath"),Ih=l((t,e,n)=>{switch(e){case x.ZodString:return Xr(t,n);case x.ZodNumber:return xu(t,n);case x.ZodObject:return Pu(t,n);case x.ZodBigInt:return lu(t,n);case x.ZodBoolean:return uu(t);case x.ZodDate:return du(t,n);case x.ZodUndefined:return Iu();case x.ZodNull:return Tu(n);case x.ZodArray:return ou(t,n);case x.ZodUnion:case x.ZodDiscriminatedUnion:return bu(t,n);case x.ZodIntersection:return mu(t,n);case x.ZodTuple:return Eu(t,n);case x.ZodRecord:return Qr(t,n);case x.ZodRef:return Su(t);case x.ZodLiteral:return hu(t,n);case x.ZodEnum:return gu(t);case x.ZodNativeEnum:return vu(t);case x.ZodNullable:return wu(t,n);case x.ZodOptional:return Ph(t,n);case x.ZodMap:return yu(t,n);case x.ZodSet:return Ou(t,n);case x.ZodLazy:return O(t.getter()._def,n);case x.ZodPromise:return ku(t,n);case x.ZodNaN:case x.ZodNever:return _u();case x.ZodEffects:return fu(t,n);case x.ZodAny:return au();case x.ZodUnknown:return Bu();case x.ZodDefault:return pu(t,n);case x.ZodBranded:return cu(t,n);case x.ZodReadonly:return Sh(t,n);case x.ZodCatch:return Th(t,n);case x.ZodPipeline:return kh(t,n);case x.ZodFunction:case x.ZodVoid:case x.ZodSymbol:return;default:return(r=>{})(e)}},"selectParser"),gr=l((t,e,n)=>(t.description&&(n.description=t.description,e.markdownDescription&&(n.markdownDescription=t.description)),Object.assign(n,{[B]:c(c({},t[B]),n[B])}),n),"addMeta"),Li={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"},Bh=l(t=>typeof t=="string"?f(c({},Li),{name:t}):c(c({},Li),t),"getDefaultOptions"),Ch=l(t=>{let e=Bh(t),n=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return f(c({},e),{currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([r,i])=>[i._def,{def:i._def,path:[...e.basePath,e.definitionPath,r],jsonSchema:void 0}]))})},"getRefs"),Ah=l((t,e)=>{var n;let r=Ch(e),i=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((u,[d,p])=>{var g;return f(c({},u),{[d]:(g=O(p._def,f(c({},r),{currentPath:[...r.basePath,r.definitionPath,d]}),!0))!=null?g:{}})},{}):void 0,s=typeof e=="string"?e:e?.name,a=(n=O(t._def,s===void 0?r:f(c({},r),{currentPath:[...r.basePath,r.definitionPath,s]}),!1))!=null?n:{},o=s===void 0?i?f(c({},a),{[r.definitionPath]:i}):a:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,s].join("/"),[r.definitionPath]:f(c({},i),{[s]:a})};return r.target==="jsonSchema7"?o.$schema="http://json-schema.org/draft-07/schema#":r.target==="jsonSchema2019-09"&&(o.$schema="https://json-schema.org/draft/2019-09/schema#"),o},"zodToJsonSchema"),Zh=l((t,e={target:"openApi3"})=>{let n=Ah(t,e);return e.$schemaUrl===!1?delete n.$schema:typeof e.$schemaUrl=="string"&&(n.$schema=e.$schemaUrl),n},"toJSONSchemaLegacy"),{zuiKey:Jn}=Pe,Rh=l((t,e)=>{let n={type:"array",description:t.description,items:e(t._def.type),"x-zui":t._def["x-zui"]};return t._def[Jn]&&(n[Jn]=t._def[Jn]),t._def.minLength&&(n.minItems=t._def.minLength.value),t._def.maxLength&&(n.maxItems=t._def.maxLength.value),t._def.exactLength&&(n.minItems=t._def.exactLength.value,n.maxItems=t._def.exactLength.value),n},"zodArrayToJsonArray"),{zuiKey:Yn}=Pe,Nh=l(t=>{let e={type:"number",description:t.description,"x-zui":t._def["x-zui"]};t._def[Yn]&&(e[Yn]=t._def[Yn]);for(let n of t._def.checks)switch(n.kind){case"min":{let r=n.inclusive?"minimum":"exclusiveMinimum",i=n.inclusive?"exclusiveMinimum":"minimum";e[r]=n.value,delete e[i];break}case"max":{let r=n.inclusive?"maximum":"exclusiveMaximum",i=n.inclusive?"exclusiveMaximum":"maximum";e[r]=n.value,delete e[i];break}case"int":e.type="integer";break;case"finite":{e.format="finite";break}case"multipleOf":e.multipleOf=n.value;break;default:}return e},"zodNumberToJsonNumber"),{zuiKey:Xn}=Pe,Dh=l((t,e)=>{let n={type:"array",description:t.description,uniqueItems:!0,items:e(t._def.valueType),"x-zui":t._def["x-zui"]};return t._def[Xn]&&(n[Xn]=t._def[Xn]),t._def.minSize&&(n.minItems=t._def.minSize.value),t._def.maxSize&&(n.maxItems=t._def.maxSize.value),n},"zodSetToJsonSet"),{zuiKey:ht}=Pe,Hh=l(t=>{let e={type:"string",description:t.description,"x-zui":t._def["x-zui"]};t._def[ht]&&(e[ht]=t._def[ht]);for(let n of t._def.checks)switch(n.kind){case"cuid":e.format="cuid",e.pattern=j.cuid;break;case"cuid2":e.format="cuid2",e.pattern=j.cuid2;break;case"ulid":e.format="ulid",e.pattern=j.ulid;break;case"uuid":e.format="uuid",e.pattern=j.uuid;break;case"emoji":e.format="emoji",e.pattern=j.emoji;break;case"email":e.format="email",e.pattern=j.email;break;case"ip":e.format=n.version==="v6"?"ipv6":"ipv4",e.pattern=n.version==="v6"?j.ipv6:j.ipv4;break;case"datetime":e.format="date-time",(n.precision!==null||n.offset)&&(e.pattern=Oo(n).source,e[ht]=f(c({},e[ht]),{precision:n.precision,offset:n.offset}));break;case"url":e.format="uri";break;case"endsWith":e.pattern=`${Bt.escapeSpecialChars(n.value)}$`;break;case"startsWith":e.pattern=`^${Bt.escapeSpecialChars(n.value)}`;break;case"includes":let r=n.position&&n.position>=1?`^(?:.{${n.position}}).*`:"";e.pattern=`${r}${Bt.escapeSpecialChars(n.value)}`;break;case"regex":e.pattern=n.regex.source;break;case"length":e.minLength=e.maxLength=Math.max(0,n.value);break;case"min":e.minLength=Math.max(0,n.value);break;case"max":e.maxLength=Math.max(0,n.value);break;default:throw new Ll({zodType:"ZodString",checkKind:n.kind})}return e},"zodStringToJsonString"),{zuiKey:Qn}=Pe,Mh=l((t,e)=>{let n={type:"array",description:t.description,items:t._def.items.map(r=>e(r))};return t._def[Qn]&&(n[Qn]=t._def[Qn]),t._def.rest&&(n.additionalItems=e(t._def.rest)),n},"zodTupleToJsonTuple"),jh={unionStrategy:"anyOf",discriminatedUnionStrategy:"oneOf",discriminator:!0};function z(t,e={}){let n=c(c({},jh),e),r=t;switch(r.typeName){case"ZodString":return Hh(r);case"ZodNumber":return Nh(r);case"ZodNaN":throw new Y("ZodNaN");case"ZodBigInt":throw new Y("ZodBigInt",{suggestedAlternative:"serialize bigint to string"});case"ZodBoolean":return{type:"boolean",description:r.description,"x-zui":r._def["x-zui"]};case"ZodDate":throw new Y("ZodDate",{suggestedAlternative:"use z.string().datetime() instead"});case"ZodUndefined":return er(r);case"ZodNull":return tr(r);case"ZodAny":return{description:r.description,"x-zui":r._def["x-zui"]};case"ZodUnknown":return{description:r.description,"x-zui":f(c({},r._def["x-zui"]),{def:{typeName:"ZodUnknown"}})};case"ZodNever":return{not:!0,description:r.description,"x-zui":r._def["x-zui"]};case"ZodVoid":throw new Y("ZodVoid");case"ZodArray":return Rh(r,p=>z(p,n));case"ZodObject":let i=Object.entries(r.shape),s=i.filter(([p,g])=>!g.isOptional()),a=s.length?s.map(([p])=>p):void 0,o=i.map(([p,g])=>[p,g.mandatory()]).map(([p,g])=>[p,z(g,n)]);return{type:"object",description:r.description,properties:Object.fromEntries(o),required:a,additionalProperties:$h(r._def,n),"x-zui":r._def["x-zui"]};case"ZodUnion":return n.unionStrategy==="oneOf"?{description:r.description,oneOf:r.options.map(p=>z(p,n)),"x-zui":r._def["x-zui"]}:{description:r.description,anyOf:r.options.map(p=>z(p,n)),"x-zui":r._def["x-zui"]};case"ZodDiscriminatedUnion":if(n.discriminatedUnionStrategy==="oneOf"){let p=n.discriminator?{propertyName:r.discriminator}:void 0;return{description:r.description,oneOf:r.options.map(g=>z(g,n)),discriminator:p,"x-zui":f(c({},r._def["x-zui"]),{def:{typeName:"ZodDiscriminatedUnion",discriminator:r.discriminator}})}}return{description:r.description,anyOf:r.options.map(p=>z(p,n)),"x-zui":f(c({},r._def["x-zui"]),{def:{typeName:"ZodDiscriminatedUnion",discriminator:r.discriminator}})};case"ZodIntersection":let u=z(r._def.left,n),d=z(r._def.right,n);return"additionalProperties"in u&&delete u.additionalProperties,"additionalProperties"in d&&delete d.additionalProperties,{description:r.description,allOf:[u,d],"x-zui":r._def["x-zui"]};case"ZodTuple":return Mh(r,p=>z(p,n));case"ZodRecord":return{type:"object",description:r.description,additionalProperties:z(r._def.valueType,n),"x-zui":r._def["x-zui"]};case"ZodMap":throw new Y("ZodMap");case"ZodSet":return Dh(r,p=>z(p,n));case"ZodFunction":throw new Y("ZodFunction");case"ZodLazy":throw new Y("ZodLazy");case"ZodLiteral":if(typeof r.value=="string")return{type:"string",description:r.description,const:r.value,"x-zui":r._def["x-zui"]};if(typeof r.value=="number")return{type:"number",description:r.description,const:r.value,"x-zui":r._def["x-zui"]};if(typeof r.value=="boolean")return{type:"boolean",description:r.description,const:r.value,"x-zui":r._def["x-zui"]};if(r.value===null)return tr(r._def);if(r.value===void 0)return er(r._def);{r.value;let p=typeof r.value;throw new On(`Unsupported literal type: "${p}"`)}case"ZodEnum":return{type:"string",description:r.description,enum:r._def.values,"x-zui":r._def["x-zui"]};case"ZodEffects":throw new Y("ZodEffects");case"ZodNativeEnum":throw new Y("ZodNativeEnum");case"ZodOptional":return{description:r.description,anyOf:[z(r._def.innerType,n),er()],"x-zui":f(c({},r._def["x-zui"]),{def:{typeName:"ZodOptional"}})};case"ZodNullable":return{anyOf:[z(r._def.innerType,n),tr()],"x-zui":f(c({},r._def["x-zui"]),{def:{typeName:"ZodNullable"}})};case"ZodDefault":return f(c({},z(r._def.innerType,n)),{default:r._def.defaultValue()});case"ZodCatch":throw new Y("ZodCatch");case"ZodPromise":throw new Y("ZodPromise");case"ZodBranded":throw new Y("ZodBranded");case"ZodPipeline":throw new Y("ZodPipeline");case"ZodSymbol":throw new Y("ZodPipeline");case"ZodReadonly":return f(c({},z(r._def.innerType,n)),{readOnly:!0});case"ZodRef":return{$ref:r._def.uri,description:r.description,"x-zui":r._def["x-zui"]};default:ce.assertNever(r)}}l(z,"toJSONSchema");var er=l(t=>({not:!0,description:t?.description,"x-zui":f(c({},t?.["x-zui"]),{def:{typeName:"ZodUndefined"}})}),"undefinedSchema"),tr=l(t=>({type:"null",description:t?.description,"x-zui":t?.["x-zui"]}),"nullSchema"),$h=l((t,e)=>t.unknownKeys==="passthrough"?!0:t.unknownKeys==="strict"||!K.zuiType(t.unknownKeys)||t.unknownKeys.typeName==="ZodNever"?!1:z(t.unknownKeys,e),"additionalPropertiesSchema");function Cu(t){return typeof t=="symbol"?"symbol":typeof t=="bigint"?`${t.toString()}n`:v(t)}l(Cu,"primitiveToTypscriptLiteralType");function v(t){return typeof t>"u"?"undefined":typeof t=="symbol"?t.description?`Symbol(${v(t.description)})`:"Symbol()":typeof t=="bigint"?`BigInt(${t.toString()})`:typeof t=="string"?Ru(t):JSON.stringify(t)}l(v,"primitiveToTypescriptValue");function st(t){return typeof t>"u"?"undefined":JSON.stringify(t)}l(st,"unknownToTypescriptValue");var Au=l((t,e)=>{let n=Object.entries(t),r=e?" as const":"";return`{ ${n.map(([i,s])=>`${mr(i)}: ${st(s)}`).join(", ")} }${r}`},"recordOfUnknownToTypescriptRecord"),mr=l(t=>/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t)?t:v(t),"toPropertyKey"),Uh=l(t=>t.charAt(0).toUpperCase()+t.slice(1),"capitalize"),Zu=l(t=>{let e=/[^a-zA-Z0-9_]/g;return t.split(e).map(Uh).filter(r=>!!r).join("")},"toTypeArgumentName"),Fi=l(t=>{for(var e;t.length&&!((e=t[0])!=null&&e.trim());)t.shift();for(;t.length&&!t[t.length-1].trim();)t.pop()},"trimEmptyLinesInPlace"),U=l(t=>{t=t?.replace(/(\n(\s*)?){3,}/g,`
58
58
 
59
59
  `);let e=l(i=>i.startsWith("* ")?` ${i}`:` * ${i}`,"ensureLineStartsWithAsterisk"),n=l(i=>i.replace(/\*\//g,"*\\/"),"escapeCommentEnd"),r=(t??"").split(`
60
- `).map(i=>i.trim());return Wi(r),r.length&&(r[0]=r[0].replace(/^\/\*\*?/,""),r[r.length-1]=r[r.length-1].replace(/\*\/$/,"")),Wi(r),r.length===0?"":r.length===1?`/** ${n(r[0])} */`:`/**
60
+ `).map(i=>i.trim());return Fi(r),r.length&&(r[0]=r[0].replace(/^\/\*\*?/,""),r[r.length-1]=r[r.length-1].replace(/\*\/$/,"")),Fi(r),r.length===0?"":r.length===1?`/** ${n(r[0])} */`:`/**
61
61
  ${r.map(e).map(n).join(`
62
62
  `)}
63
- */`},"getMultilineComment");function Au(t){if(typeof t!="string")return"";let n=String.raw`${t}`.replace(/\\/g,"\\\\").replace(/\n/g,"\\n").replace(/"/g,'\\"').replace(/'/g,"\\'");return n.includes("`")?`"${n}"`:n.includes("'")?`"${n}"`:`'${n}'`}l(Au,"escapeString");var Zu=["string","number","boolean","unknown","void","any","null","undefined","never","bigint","symbol","object"],$h=5,Uh=l(t=>Zu.includes(t),"isPrimitive"),zh=l(t=>Zu.map(e=>`${e}[]`).includes(t),"isArrayOfPrimitives"),tr=l(t=>t.replace(/ +/g," ").trim(),"stripSpaces"),Ru=class{constructor(e,n){this.key=e,this.value=n}};l(Ru,"KeyValue");var Ft=Ru,Nu=class{constructor(e){this.schema=e}};l(Nu,"FnParameters");var Li=Nu,Du=class{constructor(e){this.schema=e}};l(Du,"FnReturn");var Fi=Du,Hu=class{constructor(e){this.props=e}};l(Hu,"Declaration");var Bt=Hu;function Qr(t,e={}){let n=Lh(t,e),r=S(n,e);return e.formatter&&(r=e.formatter(r)),r}l(Qr,"toTypescriptType");var qi=l(t=>t.endsWith("?")?t:`${t}?`,"_optionalKey");function S(t,e){var n,r,i;let s=f(c({},e),{declaration:!1,parent:t});if(t===null)return"";if(t instanceof Bt)return Kh(t,s);if(t instanceof Ft){let o;if(K.zuiOptional(t.value)?o=t.value:K.zuiDefault(t.value)&&e.treatDefaultAsOptional&&(o=t.value._def.innerType.optional()),o){let w=o._def.innerType;return K.zuiType(w)&&!w.description&&o.description&&(w=w?.describe(o.description)),S(new Ft(qi(t.key),w),s)}let u=U(t.value._def.description||t.value.description),d=u?.trim().length>0?`
64
- `:"",p=t.value.describe(""),h=K.zuiAny(t.value)?qi(t.key):t.key;return`${d}${u}${d}${h}: ${S(p,s)}${d}`}if(t instanceof Li){if(K.zuiTuple(t.schema)){let p="";for(let g=0;g<t.schema.items.length;g++){let h=(i=(r=(n=t.schema.items[g])==null?void 0:n.ui)==null?void 0:r.title)!=null?i:`arg${g}`,w=t.schema.items[g];p+=`${S(new Ft(gr(h),w),s)}${g<t.schema.items.length-1?", ":""} `}return p}let o=K.zuiLiteral(t.schema.naked()),u=S(t.schema,s).trim();return u.startsWith("{")&&u.endsWith("}")||u.startsWith("[")&&u.endsWith("]")||u.startsWith("(")&&u.endsWith(")")||u.startsWith("Array<")&&u.endsWith(">")||u.startsWith("Record<")&&u.endsWith(">")||zh(u)||o?`args: ${u}`:u}if(t instanceof Fi)return K.zuiOptional(t.schema)?`${S(t.schema.unwrap(),s)} | undefined`:S(t.schema,s);let a=t;switch(a.typeName){case"ZodString":return`${U(a.description)} string`.trim();case"ZodNumber":case"ZodNaN":case"ZodBigInt":return`${U(a.description)} number`.trim();case"ZodBoolean":return`${U(a.description)} boolean`.trim();case"ZodDate":return`${U(a.description)} Date`.trim();case"ZodUndefined":return`${U(a.description)} undefined`.trim();case"ZodNull":return`${U(a.description)} null`.trim();case"ZodAny":return`${U(a.description)} any`.trim();case"ZodUnknown":return`${U(a.description)} unknown`.trim();case"ZodNever":return`${U(a.description)} never`.trim();case"ZodVoid":return`${U(a.description)} void`.trim();case"ZodArray":let o=S(a._def.type,s);return Uh(o)?`${o}[]`:`Array<${o}>`;case"ZodObject":return`{ ${Object.entries(a._def.shape()).map(([H,Oe])=>K.zuiType(Oe)?S(new Ft(gr(H),Oe),s):`${H}: unknown`).join("; ")} }`;case"ZodUnion":let d=a._def.options.map(H=>S(H,s));return`${U(a.description)}
63
+ */`},"getMultilineComment");function Ru(t){if(typeof t!="string")return"";let n=String.raw`${t}`.replace(/\\/g,"\\\\").replace(/\n/g,"\\n").replace(/"/g,'\\"').replace(/'/g,"\\'");return n.includes("`")?`"${n}"`:n.includes("'")?`"${n}"`:`'${n}'`}l(Ru,"escapeString");var Nu=["string","number","boolean","unknown","void","any","null","undefined","never","bigint","symbol","object"],zh=5,Kh=l(t=>Nu.includes(t),"isPrimitive"),Wh=l(t=>Nu.map(e=>`${e}[]`).includes(t),"isArrayOfPrimitives"),nr=l(t=>t.replace(/ +/g," ").trim(),"stripSpaces"),Du=class{constructor(e,n){this.key=e,this.value=n}};l(Du,"KeyValue");var qt=Du,Hu=class{constructor(e){this.schema=e}};l(Hu,"FnParameters");var qi=Hu,Mu=class{constructor(e){this.schema=e}};l(Mu,"FnReturn");var Vi=Mu,ju=class{constructor(e){this.props=e}};l(ju,"Declaration");var Ct=ju;function ei(t,e={}){let n=qh(t,e),r=S(n,e);return e.formatter&&(r=e.formatter(r)),r}l(ei,"toTypescriptType");var Gi=l(t=>t.endsWith("?")?t:`${t}?`,"_optionalKey");function S(t,e){var n,r,i;let s=f(c({},e),{declaration:!1,parent:t});if(t===null)return"";if(t instanceof Ct)return Lh(t,s);if(t instanceof qt){let o;if(K.zuiOptional(t.value)?o=t.value:K.zuiDefault(t.value)&&e.treatDefaultAsOptional&&(o=t.value._def.innerType.optional()),o){let w=o._def.innerType;return K.zuiType(w)&&!w.description&&o.description&&(w=w?.describe(o.description)),S(new qt(Gi(t.key),w),s)}let u=U(t.value._def.description||t.value.description),d=u?.trim().length>0?`
64
+ `:"",p=t.value.describe(""),h=K.zuiAny(t.value)?Gi(t.key):t.key;return`${d}${u}${d}${h}: ${S(p,s)}${d}`}if(t instanceof qi){if(K.zuiTuple(t.schema)){let p="";for(let g=0;g<t.schema.items.length;g++){let h=(i=(r=(n=t.schema.items[g])==null?void 0:n.ui)==null?void 0:r.title)!=null?i:`arg${g}`,w=t.schema.items[g];p+=`${S(new qt(mr(h),w),s)}${g<t.schema.items.length-1?", ":""} `}return p}let o=K.zuiLiteral(t.schema.naked()),u=S(t.schema,s).trim();return u.startsWith("{")&&u.endsWith("}")||u.startsWith("[")&&u.endsWith("]")||u.startsWith("(")&&u.endsWith(")")||u.startsWith("Array<")&&u.endsWith(">")||u.startsWith("Record<")&&u.endsWith(">")||Wh(u)||o?`args: ${u}`:u}if(t instanceof Vi)return K.zuiOptional(t.schema)?`${S(t.schema.unwrap(),s)} | undefined`:S(t.schema,s);let a=t;switch(a.typeName){case"ZodString":return`${U(a.description)} string`.trim();case"ZodNumber":case"ZodNaN":case"ZodBigInt":return`${U(a.description)} number`.trim();case"ZodBoolean":return`${U(a.description)} boolean`.trim();case"ZodDate":return`${U(a.description)} Date`.trim();case"ZodUndefined":return`${U(a.description)} undefined`.trim();case"ZodNull":return`${U(a.description)} null`.trim();case"ZodAny":return`${U(a.description)} any`.trim();case"ZodUnknown":return`${U(a.description)} unknown`.trim();case"ZodNever":return`${U(a.description)} never`.trim();case"ZodVoid":return`${U(a.description)} void`.trim();case"ZodArray":let o=S(a._def.type,s);return Kh(o)?`${o}[]`:`Array<${o}>`;case"ZodObject":return`{ ${Object.entries(a._def.shape()).map(([H,Ee])=>K.zuiType(Ee)?S(new qt(mr(H),Ee),s):`${H}: unknown`).join("; ")} }`;case"ZodUnion":let d=a._def.options.map(H=>S(H,s));return`${U(a.description)}
65
65
  ${d.join(" | ")}`;case"ZodDiscriminatedUnion":let p=a._def.options.map(H=>S(H,s));return`${U(a.description)}
66
- ${p.join(" | ")}`;case"ZodIntersection":return`${S(a._def.left,s)} & ${S(a._def.right,s)}`;case"ZodTuple":return a._def.items.length===0?"[]":`[${a._def.items.map(H=>S(H,s)).join(", ")}]`;case"ZodRecord":let h=S(a._def.keyType,s),w=S(a._def.valueType,s);return`${U(a.description)} { [key: ${h}]: ${w} }`;case"ZodMap":return`Map<${S(a._def.keyType,s)}, ${S(a._def.valueType,s)}>`;case"ZodSet":return`Set<${S(a._def.valueType,s)}>`;case"ZodFunction":let T=S(new Li(a._def.args),s),D=S(new Fi(a._def.returns),s),F=e?.parent instanceof Bt&&e?.parent.props.type==="type";return e?.declaration&&!F?`${U(a.description)}
66
+ ${p.join(" | ")}`;case"ZodIntersection":return`${S(a._def.left,s)} & ${S(a._def.right,s)}`;case"ZodTuple":return a._def.items.length===0?"[]":`[${a._def.items.map(H=>S(H,s)).join(", ")}]`;case"ZodRecord":let h=S(a._def.keyType,s),w=S(a._def.valueType,s);return`${U(a.description)} { [key: ${h}]: ${w} }`;case"ZodMap":return`Map<${S(a._def.keyType,s)}, ${S(a._def.valueType,s)}>`;case"ZodSet":return`Set<${S(a._def.valueType,s)}>`;case"ZodFunction":let T=S(new qi(a._def.args),s),D=S(new Vi(a._def.returns),s),F=e?.parent instanceof Ct&&e?.parent.props.type==="type";return e?.declaration&&!F?`${U(a.description)}
67
67
  (${T}): ${D}`:`${U(a.description)}
68
- (${T}) => ${D}`;case"ZodLazy":return S(a._def.getter(),s);case"ZodLiteral":let J=Iu(a._def.value);return`${U(a.description)}
69
- ${J}`.trim();case"ZodEnum":return a._def.values.map(v).join(" | ");case"ZodEffects":return S(a._def.schema,s);case"ZodNativeEnum":throw new Jl("ZodNativeEnum");case"ZodOptional":return`${S(a._def.innerType,s)} | undefined`;case"ZodNullable":return`${S(a._def.innerType,s)} | null`;case"ZodDefault":let oe=e.treatDefaultAsOptional?a._def.innerType.optional():a._def.innerType;return S(oe,s);case"ZodCatch":return S(a._def.innerType,s);case"ZodPromise":return`Promise<${S(a._def.type,s)}>`;case"ZodBranded":return S(a._def.type,s);case"ZodPipeline":return S(a._def.in,s);case"ZodSymbol":return`${U(a.description)} symbol`.trim();case"ZodReadonly":return`Readonly<${S(a._def.innerType,s)}>`;case"ZodRef":return Cu(a._def.uri);default:ue.assertNever(a)}}l(S,"sUnwrapZod");var Kh=l((t,e)=>{if(t.props.type==="none")return S(t.props.schema,e);let{schema:n,identifier:r}=t.props,i=U(n.description),s=n.describe(""),a=S(s,f(c({},e),{declaration:!0})),u=a.split(`
70
- `).length>=$h&&e.includeClosingTags?`// end of ${r}`:"";if(t.props.type!=="type"&&n.typeName==="ZodFunction")return tr(`${i}
71
- declare function ${r}${a};${u}`);if(t.props.type==="variable")return tr(`${i}declare const ${r}: ${a};${u}`);let d=t.props.args.length>0?`<${t.props.args.map(Cu).join(", ")}>`:"";return tr(`${i}type ${t.props.identifier}${d} = ${a};${u}`)},"unwrapDeclaration"),Wh=l(t=>t.declaration?t.declaration===!0?"variable":t.declaration:"none","getDeclarationType"),Lh=l((t,e)=>{let n=Wh(e),r=t.getReferences();if(n==="none"){if(r.length>0)throw new dr;return new Bt({type:"none",schema:t})}let i="title"in t.ui?t.ui.title:null;if(!i)throw new Xl;if(n==="variable"){if(r.length>0)throw new dr;return new Bt({type:"variable",identifier:i,schema:t})}return new Bt({type:"type",identifier:i,schema:t,args:r})},"getDeclarationProps"),Fh=l(t=>{let e=[];if(t.exactLength){let{value:n,message:r}=t.exactLength;e.push(`.length(${v(n)}, ${v(r)})`)}if(t.minLength){let{value:n,message:r}=t.minLength;e.push(`.min(${v(n)}, ${v(r)})`)}if(t.maxLength){let{value:n,message:r}=t.maxLength;e.push(`.max(${v(n)}, ${v(r)})`)}return e.join("")},"generateArrayChecks"),qh=l(t=>{let e=t.checks;return e.length===0?"":e.map(Vh).join("")},"generateBigIntChecks"),Vh=l(t=>{switch(t.kind){case"min":return`.min(${v(t.value)}, ${v(t.message)})`;case"max":return`.max(${v(t.value)}, ${v(t.message)})`;case"multipleOf":return`.multipleOf(${v(t.value)}, ${v(t.message)})`;default:return""}},"_generateBigIntCheck"),Gh=l(t=>{let e=t.checks;return e.length===0?"":e.map(Jh).join("")},"generateDateChecks"),Jh=l(t=>{switch(t.kind){case"min":return`.min(${Vi(t.value)}, ${v(t.message)})`;case"max":return`.max(${Vi(t.value)}, ${v(t.message)})`;default:return""}},"_generateDateCheck"),Vi=l(t=>`new Date(${t})`,"dateTs"),Yh=l(t=>{let e=t.checks;return e.length===0?"":e.map(Xh).join("")},"generateNumberChecks"),Xh=l(t=>{switch(t.kind){case"min":return`.min(${v(t.value)}, ${v(t.message)})`;case"max":return`.max(${v(t.value)}, ${v(t.message)})`;case"int":return`.int(${v(t.message)})`;case"multipleOf":return`.multipleOf(${v(t.value)}, ${v(t.message)})`;case"finite":return`.finite(${v(t.message)})`;default:return""}},"_generateNumberCheck"),Qh=l(t=>{let e=[];if(t.minSize){let{value:n,message:r}=t.minSize;e.push(`.min(${v(n)}, ${v(r)})`)}if(t.maxSize){let{value:n,message:r}=t.maxSize;e.push(`.max(${v(n)}, ${v(r)})`)}return e.join("")},"generateSetChecks"),ey=l(t=>{let e=t.checks;return e.length===0?"":e.map(ty).join("")},"generateStringChecks"),ty=l(t=>{switch(t.kind){case"min":return`.min(${v(t.value)}, ${v(t.message)})`;case"max":return`.max(${v(t.value)}, ${v(t.message)})`;case"length":return`.length(${v(t.value)}, ${v(t.message)})`;case"email":return`.email(${v(t.message)})`;case"url":return`.url(${v(t.message)})`;case"emoji":return`.emoji(${v(t.message)})`;case"uuid":return`.uuid(${v(t.message)})`;case"cuid":return`.cuid(${v(t.message)})`;case"cuid2":return`.cuid2(${v(t.message)})`;case"ulid":return`.ulid(${v(t.message)})`;case"includes":let e=it({message:t.message,position:t.position});return`.includes(${v(t.value)}, ${e})`;case"startsWith":return`.startsWith(${v(t.value)}, ${v(t.message)})`;case"endsWith":return`.endsWith(${v(t.value)}, ${v(t.message)})`;case"regex":return`.regex(${String(t.regex)}, ${v(t.message)})`;case"trim":return".trim()";case"toLowerCase":return".toLowerCase()";case"toUpperCase":return".toUpperCase()";case"datetime":let r=t.precision===null?void 0:t.precision;return`.datetime(${it({message:t.message,precision:r,offset:t.offset})})`;case"ip":return`.ip(${it({message:t.message,version:t.version})})`;default:return""}},"_generateStringCheck"),{zuiKey:ee}=xe;function ei(t){return N(t)}l(ei,"toTypescriptSchema");function N(t){let e=t;switch(e.typeName){case"ZodString":return`z.string()${ey(e._def)}${E(e._def)}`.trim();case"ZodNumber":return`z.number()${Yh(e._def)}${E(e._def)}`.trim();case"ZodNaN":return`z.nan()${E(e._def)}`.trim();case"ZodBigInt":return`z.bigint()${qh(e._def)}${E(e._def)}`.trim();case"ZodBoolean":return`z.boolean()${E(e._def)}`.trim();case"ZodDate":return`z.date()${Gh(e._def)}${E(e._def)}`.trim();case"ZodUndefined":return`z.undefined()${E(e._def)}`.trim();case"ZodNull":return`z.null()${E(e._def)}`.trim();case"ZodAny":return`z.any()${E(e._def)}`.trim();case"ZodUnknown":return`z.unknown()${E(e._def)}`.trim();case"ZodNever":return`z.never()${E(e._def)}`.trim();case"ZodVoid":return`z.void()${E(e._def)}`.trim();case"ZodArray":return`z.array(${N(e._def.type)})${Fh(e._def)}${E(e._def,e._def.type)}`;case"ZodObject":let n=Pg(e.shape,N),r=e.additionalProperties(),i=r?`.catchall(${N(r)})`:"";return["z.object({",...Object.entries(n).map(([hc,yc])=>` ${hc}: ${yc},`),`})${i}${E(e._def)}`].join(`
72
- `).trim();case"ZodUnion":return`z.union([${e._def.options.map(N).join(", ")}])${E(e._def)}`.trim();case"ZodDiscriminatedUnion":let a=e._def.options.map(N);return`z.discriminatedUnion(${v(e._def.discriminator)}, [${a.join(", ")}])${E(e._def)}`.trim();case"ZodIntersection":let u=N(e._def.left),d=N(e._def.right);return`z.intersection(${u}, ${d})${E(e._def)}`.trim();case"ZodTuple":return`z.tuple([${e._def.items.map(N).join(", ")}])${E(e._def)}`.trim();case"ZodRecord":let g=N(e._def.keyType),h=N(e._def.valueType);return`z.record(${g}, ${h})${E(e._def)}`.trim();case"ZodMap":let w=N(e._def.keyType),T=N(e._def.valueType);return`z.map(${w}, ${T})${E(e._def)}`.trim();case"ZodSet":return`z.set(${N(e._def.valueType)})${Qh(e._def)}${E(e._def)}`.trim();case"ZodFunction":let D=e._def.args.items.map(N),F=D.length?`.args(${D.join(", ")})`:"",J=N(e._def.returns);return`z.function()${F}.returns(${J})${E(e._def)}`.trim();case"ZodLazy":return`z.lazy(() => ${N(e._def.getter())})${E(e._def)}`.trim();case"ZodLiteral":return`z.literal(${v(e._def.value)})${E(e._def)}`.trim();case"ZodEnum":return`z.enum([${e._def.values.map(v).join(", ")}])${E(e._def)}`.trim();case"ZodEffects":throw new He("ZodEffects");case"ZodNativeEnum":throw new He("ZodNativeEnum");case"ZodOptional":return`z.optional(${N(e._def.innerType)})${E(e._def,e._def.innerType)}`.trim();case"ZodNullable":return`z.nullable(${N(e._def.innerType)})${E(e._def,e._def.innerType)}`.trim();case"ZodDefault":let H=it(e._def.defaultValue());return`z.default(${N(e._def.innerType)}, ${H})${E(e._def,e._def.innerType)}`.trim();case"ZodCatch":throw new He("ZodCatch");case"ZodPromise":return`z.promise(${N(e._def.type)})${E(e._def,e._def.type)}`.trim();case"ZodBranded":throw new He("ZodBranded");case"ZodPipeline":throw new He("ZodPipeline");case"ZodSymbol":throw new He("ZodSymbol");case"ZodReadonly":return`z.readonly(${N(e._def.innerType)})${E(e._def,e._def.innerType)}`.trim();case"ZodRef":return`z.ref(${v(e._def.uri)})${E(e._def)}`.trim();default:ue.assertNever(e)}}l(N,"sUnwrapZod");var E=l((t,e)=>{let n=e?._def;return`${ry(t,n)}${ny(t,n)}`},"_addMetadata"),ny=l((t,e)=>!t.description||e&&e.description===t.description?"":`.describe(${v(t.description)})`,"_maybeDescribe"),ry=l((t,e)=>`${iy(t,e)}${sy(t,e)}${ay(t,e)}${oy(t,e)}${ly(t,e)}${uy(t,e)}${cy(t,e)}`,"_addZuiExtensions"),iy=l((t,e)=>{var n,r;let i=(n=t[ee])==null?void 0:n.title;return!i||e&&((r=e[ee])==null?void 0:r.title)===i?"":`.title(${v(i)})`},"_maybeTitle"),sy=l((t,e)=>{var n,r;let i=(n=t[ee])==null?void 0:n.displayAs;return!i||e&&Ee((r=e[ee])==null?void 0:r.displayAs,i)?"":`.displayAs(${Bu({id:i[0],params:i[1]})})`},"_maybeDisplayAs"),ay=l((t,e)=>{var n,r;let i=(n=t[ee])==null?void 0:n.disabled;return!i||e&&((r=e[ee])==null?void 0:r.disabled)===i?"":`.disabled(${i})`},"_maybeDisabled"),oy=l((t,e)=>{var n,r;let i=(n=t[ee])==null?void 0:n.hidden;return!i||e&&((r=e[ee])==null?void 0:r.hidden)===i?"":`.hidden(${i})`},"_maybeHidden"),ly=l((t,e)=>{var n,r;let i=(n=t[ee])==null?void 0:n.placeholder;return!i||e&&((r=e[ee])==null?void 0:r.placeholder)===i?"":`.placeholder(${v(i)})`},"_maybePlaceholder"),uy=l((t,e)=>{var n,r;let i=(n=t[ee])==null?void 0:n.secret;return!i||e&&((r=e[ee])==null?void 0:r.secret)===i?"":".secret()"},"_maybeSecret"),cy=l((t,e)=>{var n,r;let i=["title","tooltip","displayAs","disabled","hidden","placeholder","secret","coerce"],s=Object.entries((n=t[ee])!=null?n:{}).filter(([a])=>!i.includes(a));if(s.length===0)return"";if(e){let a=Object.entries((r=e[ee])!=null?r:{}).filter(([o])=>!i.includes(o));if(Ee(Object.fromEntries(s),Object.fromEntries(a)))return""}return`.metadata(${Bu(Object.fromEntries(s))})`},"_maybeSetMetadata"),dy={};P.prototype.toJSONSchema=function(t={}){return z(this,t)};P.prototype.toTypescriptType=function(t={}){return Qr(this,t)};P.prototype.toTypescriptSchema=function(){return ei(this)};var L=y.string().min(1),ju=y.object({text:L}),$u=y.object({markdown:L}),Uu=y.object({imageUrl:L,title:L.optional()}),zu=y.object({audioUrl:L,title:L.optional()}),Ku=y.object({videoUrl:L,title:L.optional()}),Wu=y.object({fileUrl:L,title:L.optional()}),Lu=y.object({latitude:y.number(),longitude:y.number(),address:y.string().optional(),title:y.string().optional()}),Fu=y.object({title:L,subtitle:L.optional(),imageUrl:L.optional(),actions:y.array(y.object({action:y.enum(["postback","url","say"]),label:L,value:L}))}),Mu=y.object({text:L,options:y.array(y.object({label:L,value:L}))}),py=y.object({items:y.array(Fu)}),qu=y.union([y.object({type:y.literal("text"),payload:ju}),y.object({type:y.literal("image"),payload:Uu}),y.object({type:y.literal("audio"),payload:zu}),y.object({type:y.literal("video"),payload:Ku}),y.object({type:y.literal("file"),payload:Wu}),y.object({type:y.literal("location"),payload:Lu})]),fy=y.object({items:y.array(qu)}),gy={schema:$u},my={schema:y.object({items:y.array(y.union([...qu.options,y.object({type:y.literal("markdown"),payload:$u})]))})},hy={text:{schema:ju},image:{schema:Uu},audio:{schema:zu},video:{schema:Ku},file:{schema:Wu},location:{schema:Lu},carousel:{schema:py},card:{schema:Fu},dropdown:{schema:Mu},choice:{schema:Mu},bloc:{schema:fy}};var yy={HIDDEN_IN_STUDIO:{bpActionHiddenInStudio:"true"},AWAIT_RETURN:{bpActionAwaitReturn:"true"}};var Vu=require("browser-or-node");var ni=console;function ne(t){if(!t.body)throw new Error("Missing body");return JSON.parse(t.body)}async function zt(t,e=8072,n=by){if(!Vu.isNode)throw new Error("This function can only be called in Node.js");let i=require("http").createServer(async(s,a)=>{try{let o=await vy(s);if(o.path==="/health"){a.writeHead(200).end("ok");return}let u=await t(o);a.writeHead(u?.status??200,u?.headers??{}).end(u?.body??"{}")}catch(o){let u=o instanceof Error?o.message:String(o);ni.error("Error while handling request",{error:u??"Internal error occured"}),a.writeHead(500).end(JSON.stringify({error:u??"Internal error occured"}))}});return i.listen(e,()=>n(e)),i}async function vy(t){let e=await Ty(t),n={};for(let i=0;i<t.rawHeaders.length;i+=2){let s=t.rawHeaders[i].toLowerCase(),a=t.rawHeaders[i+1];n[s]=a}let r=new URL(t.url??"",t.headers.host?`http://${t.headers.host}`:"http://botpress.cloud");return{body:e,path:r.pathname,query:_y(r.search,"?"),headers:n,method:t.method?.toUpperCase()??"GET"}}function _y(t,e){return t.indexOf(e)===0?t.slice(e.length):t}async function Ty(t){return new Promise((e,n)=>{if(t.method!=="POST"&&t.method!=="PUT"&&t.method!=="PATCH")return e(void 0);let r="";t.on("data",i=>r+=i.toString()),t.on("error",i=>n(i)),t.on("end",()=>e(r))})}function by(t){ni.info(`Listening on port ${t}`)}var zn=require("@botpress/client");var Z={};et(Z,{mapKeys:()=>Py,mapValues:()=>xy,mergeRecords:()=>Sy,pairs:()=>En,stripUndefinedProps:()=>ky,values:()=>wy});var En=t=>Object.entries(t),wy=t=>Object.values(t),xy=(t,e)=>Object.fromEntries(En(t).map(([n,r])=>[n,e(r,n)])),Py=(t,e)=>Object.fromEntries(En(t).map(([n,r])=>[e(n),r])),ky=t=>Object.fromEntries(En(t).filter(([,e])=>e!==void 0)),Sy=(t,e,n)=>{let r=[...Object.keys(t),...Object.keys(e)],i=[...new Set(r)],s={};for(let a of i){let o=t[a],u=e[a];o&&u?s[a]=n(o,u):o?s[a]=o:u&&(s[a]=u)}return s};var b={};et(b,{safePush:()=>Oy,unique:()=>Ey});var Oy=(t,...e)=>t?[...t,...e]:[...e],Ey=t=>Array.from(new Set(t));var V={};et(V,{setName:()=>Iy});var Iy=(t,e)=>(Object.defineProperty(t,"name",{value:e}),t);var Gu=t=>{let{name:e,version:n}=t,r={actions:{},events:{},channels:{}},i={name:e,version:n,entities:Z.mapValues(t.entities,a=>({name:a.name})),actions:{},events:{},channels:{}},s=Z.mapValues(t.entities,a=>a.schema);for(let[a,o]of Object.entries(t.definition.actions??{})){let u=o.input.schema.dereference(s),d=o.output.schema.dereference(s),p=t.actions?.[a]?.name??a;r.actions[p]={...o,...t.actions?.[a]??{},input:{schema:u},output:{schema:d}},i.actions[a]={name:p}}for(let[a,o]of Object.entries(t.definition.events??{})){let u=o.schema.dereference(s),d=t.events?.[a]?.name??a;r.events[d]={...o,...t.events?.[a]??{},schema:u},i.events[a]={name:d}}for(let[a,o]of Object.entries(t.definition.channels??{})){let u={};for(let[p,g]of Object.entries(o.messages)){let h=g.schema.dereference(s);u[p]={...g,schema:h}}let d=t.channels?.[a]?.name??a;r.channels[d]={...o,...t.channels?.[a]??{},message:{...o.message??{},tags:{...o.message?.tags??{},...t.channels?.[a]?.message?.tags??{}}},conversation:{...o.conversation??{},tags:{...o.conversation?.tags??{},...t.channels?.[a]?.conversation?.tags??{}}},messages:u},i.channels[a]={name:d}}return{resolved:r,statement:i}};var Ju="6.4.0";var Ce=Ju;var In=Symbol("schemaName"),Yu=t=>t?Z.mapValues(t,(n,r)=>({...n,[In]:r})):{},Xu=t=>In in t&&t[In]!==void 0,Qu=t=>t[In];var Bn=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.readme=e.readme,this.title=e.title,this.identifier=e.identifier,this.description=e.description,this.configuration=e.configuration,this.configurations=e.configurations,this.events=e.events,this.actions=e.actions,this.channels=e.channels,this.states=e.states,this.user=e.user,this.secrets=e.secrets,this.entities=e.entities,this.interfaces=e.interfaces,this.__advanced=e.__advanced,this.attributes=e.attributes}name;version;title;description;icon;readme;configuration;configurations;events;actions;channels;states;user;secrets;identifier;entities;interfaces;__advanced;attributes;get metadata(){return{sdkVersion:Ce}}extend(e,n){let{entities:r,actions:i,events:s,channels:a}=this._callBuilder(e,n),o=this;o.interfaces??={};let u=Object.values(r).map(h=>h.name),d=u.length===0?e.name:`${e.name}<${u.join(",")}>`,{resolved:p,statement:g}=Gu({...e,entities:r,actions:Z.stripUndefinedProps(i),events:Z.stripUndefinedProps(s),channels:Z.stripUndefinedProps(a)});return o.actions=Z.mergeRecords(o.actions??{},p.actions,this._mergeActions),o.channels=Z.mergeRecords(o.channels??{},p.channels,this._mergeChannels),o.events=Z.mergeRecords(o.events??{},p.events,this._mergeEvents),o.interfaces[d]={id:e.id,...g},this}_callBuilder(e,n){let i={entities:Yu(this.entities)},s=n(i),a=Z.pairs(s.entities).find(([u,d])=>!Xu(d));if(a)throw new Error(`Cannot extend interface "${e.name}" with entity "${a[0]}"; the provided schema is not part of the integration's entities.`);return{entities:Z.mapValues(s.entities,u=>({name:Qu(u),schema:u.schema})),actions:s.actions??{},events:s.events??{},channels:s.channels??{}}}_mergeActions=(e,n)=>({...e,...n,input:{schema:this._mergeObjectSchemas(e.input.schema,n.input.schema)},output:{schema:this._mergeObjectSchemas(e.output.schema,n.output.schema)}});_mergeEvents=(e,n)=>({...e,...n,schema:this._mergeObjectSchemas(e.schema,n.schema)});_mergeChannels=(e,n)=>{let r=Z.mergeRecords(e.messages,n.messages,this._mergeMessage),i;(e.conversation||n.conversation)&&(i={tags:{...e.conversation?.tags,...n.conversation?.tags}});let s;return(e.message||n.message)&&(s={tags:{...e.message?.tags,...n.message?.tags}}),{...e,...n,messages:r,conversation:i,message:s}};_mergeMessage=(e,n)=>({schema:this._mergeObjectSchemas(e.schema,n.schema)});_mergeObjectSchemas=(e,n)=>{let r=e._def,i=n._def;if(r.typeName==="ZodObject"&&i.typeName==="ZodObject"){let s=r.shape(),a=i.shape();return y.object({...s,...a})}if(r.typeName==="ZodRecord"&&i.typeName==="ZodRecord")return y.record(y.intersection(r.valueType,i.valueType));throw new Error("Cannot merge object schemas with record schemas")}};var ke=require("@botpress/client");var ec=Kn(require("@botpress/client")),Cn={retries:3,retryCondition:t=>ec.axiosRetry.isNetworkOrIdempotentRequestError(t)||[429,502].includes(t.response?.status??0),retryDelay:(t,e)=>(Cy(e.response?.headers??{})??t)*1e3},Cy=t=>{let e=["RateLimit-Reset","X-RateLimit-Reset","Retry-After","ratelimit-reset","x-ratelimit-reset","retry-after"];for(let n of e){let r=t[n];if(r!==void 0)return Ay(String(r))}},Ay=t=>{let e=Zy(t)?Ry(t):t.length>0?parseInt(t,10):void 0;return e===void 0||isNaN(e)?void 0:e},Zy=t=>t.includes(" "),Ry=t=>{let e=Ny(t);if(!e)return;let n=new Date;return Math.max(0,Math.floor((e.getTime()-n.getTime())/1e3))},Ny=t=>{let e=new Date(t);return isNaN(e.getTime())?void 0:e};var lt=class{constructor(e){this._client=e}get _inner(){return this._client}createConversation=(e=>this._client.createConversation(e));getConversation=(e=>this._client.getConversation(e));listConversations=(e=>this._client.listConversations(e));getOrCreateConversation=(e=>this._client.getOrCreateConversation(e));updateConversation=(e=>this._client.updateConversation(e));deleteConversation=(e=>this._client.deleteConversation(e));listParticipants=(e=>this._client.listParticipants(e));addParticipant=(e=>this._client.addParticipant(e));getParticipant=(e=>this._client.getParticipant(e));removeParticipant=(e=>this._client.removeParticipant(e));createEvent=(e=>this._client.createEvent(e));getEvent=(e=>this._client.getEvent(e));listEvents=(e=>this._client.listEvents(e));createMessage=(e=>this._client.createMessage(e));getOrCreateMessage=(e=>this._client.getOrCreateMessage(e));getMessage=(e=>this._client.getMessage(e).then(n=>n));updateMessage=(e=>this._client.updateMessage(e).then(n=>n));listMessages=(e=>this._client.listMessages(e));deleteMessage=(e=>this._client.deleteMessage(e));initializeIncomingMessage=(e=>this._client.initializeIncomingMessage(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 An=class{_cost=0;get cost(){return this._cost}setCost(e){this._cost=e}toJSON(){return{cost:this.cost}}};var de="#",Zn="x-bot-id",tc="x-bot-user-id",nc="x-integration-id",rc="x-integration-alias",ic="x-webhook-id",sc="x-bp-configuration-type",Rn="x-bp-configuration",Nn="x-bp-operation",ac="x-bp-type";var re=t=>{throw t instanceof Error?t:new Error(t)};var l_=y.enum(["webhook_received","message_created","action_triggered","register","unregister","ping","create_user","create_conversation"]),oc=t=>({botId:t[Zn]||re("Missing bot header"),botUserId:t[tc]||re("Missing bot user header"),integrationId:t[nc]||re("Missing integration header"),integrationAlias:t[rc]||re("Missing integration alias header"),webhookId:t[ic]||re("Missing webhook header"),operation:t[Nn]||re("Missing operation header"),configurationType:t[sc]??null,configuration:JSON.parse(Buffer.from(t[Rn]||re("Missing configuration header"),"base64").toString("utf-8"))});var lc=Kn(require("util")),ut=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)}issue(e){console.info(JSON.stringify(e))}_log(e,n){this._getConsoleMethod(e)(this._serializeMessage(n))}_serializeMessage(e){let n=lc.default.format(...e);return process.env.BP_LOG_FORMAT==="json"?this.getJsonMessage(n):n}getJsonMessage(e){return JSON.stringify({msg:e,options:this.defaultOptions})}_getConsoleMethod(e){switch(e){case"debug":return console.debug;case"warn":return console.warn;case"error":return console.error;default:return console.info}}};var ct=class t extends ut{constructor(e){super({visibleToBotOwners:!1,hiddenToIntegrationOwners:!1,...e})}with(e){return new t({...this.defaultOptions,...e})}withUserId(e){return this.with({userId:e})}withConversationId(e){return this.with({conversationId:e})}withVisibleToBotOwners(e){return this.with({visibleToBotOwners:e})}withHiddenToIntegrationOwners(e){return this.with({hiddenToIntegrationOwners:e})}forBot(){return this.with({hiddenToIntegrationOwners:!1,visibleToBotOwners:!0})}forBotOnly(){return this.with({hiddenToIntegrationOwners:!0,visibleToBotOwners:!0})}getJsonMessage(e){return JSON.stringify({msg:e,visible_to_bot_owner:this.defaultOptions.visibleToBotOwners,hidden_to_integration_owner:this.defaultOptions.hiddenToIntegrationOwners,options:this.defaultOptions})}};var Dy=t=>["traceparent","tracestate","sentry-trace"].reduce((e,n)=>(t[n]&&(e[n]=t[n]),e),{}),Hy=(t,e,n)=>{let[,r]=(e.headers.traceparent||"").split("-"),i=new ke.Client({botId:t.botId,integrationId:t.integrationId,integrationAlias:t.integrationAlias,retry:Cn,headers:Dy(e.headers)}),s=new lt(i),a=new ct({traceId:r});return{ctx:t,req:e,client:s,logger:a,instance:n}},My=async t=>{let{ctx:e}=t;switch(e.operation){case"webhook_received":return await $y(t);case"register":return await Uy(t);case"unregister":return await zy(t);case"message_created":return await Ly(t);case"action_triggered":return await Fy(t);case"ping":return await jy(t);case"create_user":return await Ky(t);case"create_conversation":return await Wy(t);default:throw new ke.InvalidPayloadError(`Unknown operation ${e.operation}`)}},uc=t=>async e=>{let n=oc(e.headers),r=Hy(n,e,t),{logger:i}=r;try{let s;return s=await qy(r),s?{...s,status:s.status??200}:(s=await My(r),s?{...s,status:s.status??200}:{status:200})}catch(s){if((0,ke.isApiError)(s)){let o=s.type==="Runtime"?s:new ke.RuntimeError(s.message,s);return i.forBot().error(o.message),{status:o.code,body:JSON.stringify(o.toJSON())}}console.error(s);let a=new ke.RuntimeError("An unexpected error occurred in the integration. Bot owners: Check logs for more informations. Integration owners: throw a RuntimeError to return a custom error message instead.");return i.forBot().error(a.message),{status:a.code,body:JSON.stringify(a.toJSON())}}},jy=async t=>{},$y=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{let{req:s}=ne(n);return i.webhook({client:t,ctx:e,req:s,logger:r})},Uy=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{if(!i.register)return;let{webhookUrl:s}=ne(n);await i.register({client:t,ctx:e,webhookUrl:s,logger:r})},zy=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{if(!i.unregister)return;let{webhookUrl:s}=ne(n);await i.unregister({ctx:e,webhookUrl:s,client:t,logger:r})},Ky=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{if(!i.createUser)return;let{tags:s}=ne(n);return await i.createUser({ctx:e,client:t,tags:s,logger:r})},Wy=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{if(!i.createConversation)return;let{channel:s,tags:a}=ne(n);return await i.createConversation({ctx:e,client:t,channel:s,tags:a,logger:r})},Ly=async({ctx:t,req:e,client:n,logger:r,instance:i})=>{let{conversation:s,user:a,type:o,payload:u,message:d}=ne(e),p=i.channels[s.channel];if(!p)throw new Error(`Channel ${s.channel} not found`);let g=p.messages[o];if(!g)throw new Error(`Message of type ${o} not found in channel ${s.channel}`);await g({ctx:t,conversation:s,message:d,user:a,type:o,client:n,payload:u,ack:async({tags:w})=>{await n.updateMessage({id:d.id,tags:w})},logger:r})},Fy=async({req:t,ctx:e,client:n,logger:r,instance:i})=>{let{input:s,type:a}=ne(t);if(!a)throw new Error("Missing action type");let o=i.actions[a];if(!o)throw new Error(`Action ${a} not found`);let u=new An,p={output:await o({ctx:e,input:s,client:n,type:a,logger:r,metadata:u}),meta:u.toJSON()};return{body:JSON.stringify(p)}},qy=async({instance:t,client:e,ctx:n,logger:r,req:i})=>{let s=t.unknownOperationHandler;if(s)return await s({client:e,ctx:n,logger:r,req:i})};var Dn=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=uc(this);start=e=>zt(this.handler,e)};var Hn=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.secrets=e.secrets,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;secrets;workflows;attributes;__advanced;withPlugins;get metadata(){return{sdkVersion:Ce}}addIntegration(e,n){let r=this;r.integrations||(r.integrations={});let i=n?.alias??e.name;if(r.integrations[i])throw new Error(`Another integration with alias "${i}" is already installed in the bot`);return r.integrations[i]={...e,alias:i,enabled:n?.enabled,configurationType:n&&"configurationType"in n?n.configurationType:void 0,configuration:n&&"configuration"in n?n.configuration??{}:{},disabledChannels:n?.disabledChannels},this}addPlugin(e,n){let r=this;r.plugins||(r.plugins={});let i=n.alias??e.name;if(r.plugins[i])throw new Error(`Another plugin with alias "${i}" is already installed in the bot`);let s=Object.fromEntries(Object.entries(n.dependencies??{}).filter(([o,u])=>"integrationInterfaceAlias"in u).map(([o,u])=>{let d=this.integrations?.[u.integrationAlias];if(!d){let g=Object.keys(this.integrations??{}).join(", ")||"(none)";throw new Error(`Interface with alias "${o}" of plugin with alias "${i}" references integration with alias "${u.integrationAlias}" which is not installed. Please make sure to add the integration via addIntegration() before calling addPlugin().
73
- Available integration aliases: ${g}`)}let p=d.definition.interfaces?.[u.integrationInterfaceAlias];if(!p){let g=Object.keys(d.definition.interfaces??{}).join(", ")||"(none)";throw new Error(`Interface with alias "${u.integrationInterfaceAlias}" does not exist in integration "${d.name}" referenced by interface with alias "${o}" of plugin with alias "${i}".
68
+ (${T}) => ${D}`;case"ZodLazy":return S(a._def.getter(),s);case"ZodLiteral":let J=Cu(a._def.value);return`${U(a.description)}
69
+ ${J}`.trim();case"ZodEnum":return a._def.values.map(v).join(" | ");case"ZodEffects":return S(a._def.schema,s);case"ZodNativeEnum":throw new Xl("ZodNativeEnum");case"ZodOptional":return`${S(a._def.innerType,s)} | undefined`;case"ZodNullable":return`${S(a._def.innerType,s)} | null`;case"ZodDefault":let le=e.treatDefaultAsOptional?a._def.innerType.optional():a._def.innerType;return S(le,s);case"ZodCatch":return S(a._def.innerType,s);case"ZodPromise":return`Promise<${S(a._def.type,s)}>`;case"ZodBranded":return S(a._def.type,s);case"ZodPipeline":return S(a._def.in,s);case"ZodSymbol":return`${U(a.description)} symbol`.trim();case"ZodReadonly":return`Readonly<${S(a._def.innerType,s)}>`;case"ZodRef":return Zu(a._def.uri);default:ce.assertNever(a)}}l(S,"sUnwrapZod");var Lh=l((t,e)=>{if(t.props.type==="none")return S(t.props.schema,e);let{schema:n,identifier:r}=t.props,i=U(n.description),s=n.describe(""),a=S(s,f(c({},e),{declaration:!0})),u=a.split(`
70
+ `).length>=zh&&e.includeClosingTags?`// end of ${r}`:"";if(t.props.type!=="type"&&n.typeName==="ZodFunction")return nr(`${i}
71
+ declare function ${r}${a};${u}`);if(t.props.type==="variable")return nr(`${i}declare const ${r}: ${a};${u}`);let d=t.props.args.length>0?`<${t.props.args.map(Zu).join(", ")}>`:"";return nr(`${i}type ${t.props.identifier}${d} = ${a};${u}`)},"unwrapDeclaration"),Fh=l(t=>t.declaration?t.declaration===!0?"variable":t.declaration:"none","getDeclarationType"),qh=l((t,e)=>{let n=Fh(e),r=t.getReferences();if(n==="none"){if(r.length>0)throw new pr;return new Ct({type:"none",schema:t})}let i="title"in t.ui?t.ui.title:null;if(!i)throw new eu;if(n==="variable"){if(r.length>0)throw new pr;return new Ct({type:"variable",identifier:i,schema:t})}return new Ct({type:"type",identifier:i,schema:t,args:r})},"getDeclarationProps"),Vh=l(t=>{let e=[];if(t.exactLength){let{value:n,message:r}=t.exactLength;e.push(`.length(${v(n)}, ${v(r)})`)}if(t.minLength){let{value:n,message:r}=t.minLength;e.push(`.min(${v(n)}, ${v(r)})`)}if(t.maxLength){let{value:n,message:r}=t.maxLength;e.push(`.max(${v(n)}, ${v(r)})`)}return e.join("")},"generateArrayChecks"),Gh=l(t=>{let e=t.checks;return e.length===0?"":e.map(Jh).join("")},"generateBigIntChecks"),Jh=l(t=>{switch(t.kind){case"min":return`.min(${v(t.value)}, ${v(t.message)})`;case"max":return`.max(${v(t.value)}, ${v(t.message)})`;case"multipleOf":return`.multipleOf(${v(t.value)}, ${v(t.message)})`;default:return""}},"_generateBigIntCheck"),Yh=l(t=>{let e=t.checks;return e.length===0?"":e.map(Xh).join("")},"generateDateChecks"),Xh=l(t=>{switch(t.kind){case"min":return`.min(${Ji(t.value)}, ${v(t.message)})`;case"max":return`.max(${Ji(t.value)}, ${v(t.message)})`;default:return""}},"_generateDateCheck"),Ji=l(t=>`new Date(${t})`,"dateTs"),Qh=l(t=>{let e=t.checks;return e.length===0?"":e.map(ey).join("")},"generateNumberChecks"),ey=l(t=>{switch(t.kind){case"min":return`.min(${v(t.value)}, ${v(t.message)})`;case"max":return`.max(${v(t.value)}, ${v(t.message)})`;case"int":return`.int(${v(t.message)})`;case"multipleOf":return`.multipleOf(${v(t.value)}, ${v(t.message)})`;case"finite":return`.finite(${v(t.message)})`;default:return""}},"_generateNumberCheck"),ty=l(t=>{let e=[];if(t.minSize){let{value:n,message:r}=t.minSize;e.push(`.min(${v(n)}, ${v(r)})`)}if(t.maxSize){let{value:n,message:r}=t.maxSize;e.push(`.max(${v(n)}, ${v(r)})`)}return e.join("")},"generateSetChecks"),ny=l(t=>{let e=t.checks;return e.length===0?"":e.map(ry).join("")},"generateStringChecks"),ry=l(t=>{switch(t.kind){case"min":return`.min(${v(t.value)}, ${v(t.message)})`;case"max":return`.max(${v(t.value)}, ${v(t.message)})`;case"length":return`.length(${v(t.value)}, ${v(t.message)})`;case"email":return`.email(${v(t.message)})`;case"url":return`.url(${v(t.message)})`;case"emoji":return`.emoji(${v(t.message)})`;case"uuid":return`.uuid(${v(t.message)})`;case"cuid":return`.cuid(${v(t.message)})`;case"cuid2":return`.cuid2(${v(t.message)})`;case"ulid":return`.ulid(${v(t.message)})`;case"includes":let e=st({message:t.message,position:t.position});return`.includes(${v(t.value)}, ${e})`;case"startsWith":return`.startsWith(${v(t.value)}, ${v(t.message)})`;case"endsWith":return`.endsWith(${v(t.value)}, ${v(t.message)})`;case"regex":return`.regex(${String(t.regex)}, ${v(t.message)})`;case"trim":return".trim()";case"toLowerCase":return".toLowerCase()";case"toUpperCase":return".toUpperCase()";case"datetime":let r=t.precision===null?void 0:t.precision;return`.datetime(${st({message:t.message,precision:r,offset:t.offset})})`;case"ip":return`.ip(${st({message:t.message,version:t.version})})`;default:return""}},"_generateStringCheck"),{zuiKey:ee}=Pe;function ti(t){return N(t)}l(ti,"toTypescriptSchema");function N(t){let e=t;switch(e.typeName){case"ZodString":return`z.string()${ny(e._def)}${E(e._def)}`.trim();case"ZodNumber":return`z.number()${Qh(e._def)}${E(e._def)}`.trim();case"ZodNaN":return`z.nan()${E(e._def)}`.trim();case"ZodBigInt":return`z.bigint()${Gh(e._def)}${E(e._def)}`.trim();case"ZodBoolean":return`z.boolean()${E(e._def)}`.trim();case"ZodDate":return`z.date()${Yh(e._def)}${E(e._def)}`.trim();case"ZodUndefined":return`z.undefined()${E(e._def)}`.trim();case"ZodNull":return`z.null()${E(e._def)}`.trim();case"ZodAny":return`z.any()${E(e._def)}`.trim();case"ZodUnknown":return`z.unknown()${E(e._def)}`.trim();case"ZodNever":return`z.never()${E(e._def)}`.trim();case"ZodVoid":return`z.void()${E(e._def)}`.trim();case"ZodArray":return`z.array(${N(e._def.type)})${Vh(e._def)}${E(e._def,e._def.type)}`;case"ZodObject":let n=Sg(e.shape,N),r=e.additionalProperties(),i=r?`.catchall(${N(r)})`:"";return["z.object({",...Object.entries(n).map(([vc,_c])=>` ${vc}: ${_c},`),`})${i}${E(e._def)}`].join(`
72
+ `).trim();case"ZodUnion":return`z.union([${e._def.options.map(N).join(", ")}])${E(e._def)}`.trim();case"ZodDiscriminatedUnion":let a=e._def.options.map(N);return`z.discriminatedUnion(${v(e._def.discriminator)}, [${a.join(", ")}])${E(e._def)}`.trim();case"ZodIntersection":let u=N(e._def.left),d=N(e._def.right);return`z.intersection(${u}, ${d})${E(e._def)}`.trim();case"ZodTuple":return`z.tuple([${e._def.items.map(N).join(", ")}])${E(e._def)}`.trim();case"ZodRecord":let g=N(e._def.keyType),h=N(e._def.valueType);return`z.record(${g}, ${h})${E(e._def)}`.trim();case"ZodMap":let w=N(e._def.keyType),T=N(e._def.valueType);return`z.map(${w}, ${T})${E(e._def)}`.trim();case"ZodSet":return`z.set(${N(e._def.valueType)})${ty(e._def)}${E(e._def)}`.trim();case"ZodFunction":let D=e._def.args.items.map(N),F=D.length?`.args(${D.join(", ")})`:"",J=N(e._def.returns);return`z.function()${F}.returns(${J})${E(e._def)}`.trim();case"ZodLazy":return`z.lazy(() => ${N(e._def.getter())})${E(e._def)}`.trim();case"ZodLiteral":return`z.literal(${v(e._def.value)})${E(e._def)}`.trim();case"ZodEnum":return`z.enum([${e._def.values.map(v).join(", ")}])${E(e._def)}`.trim();case"ZodEffects":throw new je("ZodEffects");case"ZodNativeEnum":throw new je("ZodNativeEnum");case"ZodOptional":return`z.optional(${N(e._def.innerType)})${E(e._def,e._def.innerType)}`.trim();case"ZodNullable":return`z.nullable(${N(e._def.innerType)})${E(e._def,e._def.innerType)}`.trim();case"ZodDefault":let H=st(e._def.defaultValue());return`z.default(${N(e._def.innerType)}, ${H})${E(e._def,e._def.innerType)}`.trim();case"ZodCatch":throw new je("ZodCatch");case"ZodPromise":return`z.promise(${N(e._def.type)})${E(e._def,e._def.type)}`.trim();case"ZodBranded":throw new je("ZodBranded");case"ZodPipeline":throw new je("ZodPipeline");case"ZodSymbol":throw new je("ZodSymbol");case"ZodReadonly":return`z.readonly(${N(e._def.innerType)})${E(e._def,e._def.innerType)}`.trim();case"ZodRef":return`z.ref(${v(e._def.uri)})${E(e._def)}`.trim();default:ce.assertNever(e)}}l(N,"sUnwrapZod");var E=l((t,e)=>{let n=e?._def;return`${sy(t,n)}${iy(t,n)}`},"_addMetadata"),iy=l((t,e)=>!t.description||e&&e.description===t.description?"":`.describe(${v(t.description)})`,"_maybeDescribe"),sy=l((t,e)=>`${ay(t,e)}${oy(t,e)}${ly(t,e)}${uy(t,e)}${cy(t,e)}${dy(t,e)}${py(t,e)}`,"_addZuiExtensions"),ay=l((t,e)=>{var n,r;let i=(n=t[ee])==null?void 0:n.title;return!i||e&&((r=e[ee])==null?void 0:r.title)===i?"":`.title(${v(i)})`},"_maybeTitle"),oy=l((t,e)=>{var n,r;let i=(n=t[ee])==null?void 0:n.displayAs;return!i||e&&Ie((r=e[ee])==null?void 0:r.displayAs,i)?"":`.displayAs(${Au({id:i[0],params:i[1]})})`},"_maybeDisplayAs"),ly=l((t,e)=>{var n,r;let i=(n=t[ee])==null?void 0:n.disabled;return!i||e&&((r=e[ee])==null?void 0:r.disabled)===i?"":`.disabled(${i})`},"_maybeDisabled"),uy=l((t,e)=>{var n,r;let i=(n=t[ee])==null?void 0:n.hidden;return!i||e&&((r=e[ee])==null?void 0:r.hidden)===i?"":`.hidden(${i})`},"_maybeHidden"),cy=l((t,e)=>{var n,r;let i=(n=t[ee])==null?void 0:n.placeholder;return!i||e&&((r=e[ee])==null?void 0:r.placeholder)===i?"":`.placeholder(${v(i)})`},"_maybePlaceholder"),dy=l((t,e)=>{var n,r;let i=(n=t[ee])==null?void 0:n.secret;return!i||e&&((r=e[ee])==null?void 0:r.secret)===i?"":".secret()"},"_maybeSecret"),py=l((t,e)=>{var n,r;let i=["title","tooltip","displayAs","disabled","hidden","placeholder","secret","coerce"],s=Object.entries((n=t[ee])!=null?n:{}).filter(([a])=>!i.includes(a));if(s.length===0)return"";if(e){let a=Object.entries((r=e[ee])!=null?r:{}).filter(([o])=>!i.includes(o));if(Ie(Object.fromEntries(s),Object.fromEntries(a)))return""}return`.metadata(${Au(Object.fromEntries(s))})`},"_maybeSetMetadata"),fy={};P.prototype.toJSONSchema=function(t={}){return z(this,t)};P.prototype.toTypescriptType=function(t={}){return ei(this,t)};P.prototype.toTypescriptSchema=function(){return ti(this)};var L=y.string().min(1),Uu=y.object({text:L}),zu=y.object({markdown:L}),Ku=y.object({imageUrl:L,title:L.optional()}),Wu=y.object({audioUrl:L,title:L.optional()}),Lu=y.object({videoUrl:L,title:L.optional()}),Fu=y.object({fileUrl:L,title:L.optional()}),qu=y.object({latitude:y.number(),longitude:y.number(),address:y.string().optional(),title:y.string().optional()}),Vu=y.object({title:L,subtitle:L.optional(),imageUrl:L.optional(),actions:y.array(y.object({action:y.enum(["postback","url","say"]),label:L,value:L}))}),$u=y.object({text:L,options:y.array(y.object({label:L,value:L}))}),gy=y.object({items:y.array(Vu)}),Gu=y.union([y.object({type:y.literal("text"),payload:Uu}),y.object({type:y.literal("image"),payload:Ku}),y.object({type:y.literal("audio"),payload:Wu}),y.object({type:y.literal("video"),payload:Lu}),y.object({type:y.literal("file"),payload:Fu}),y.object({type:y.literal("location"),payload:qu})]),my=y.object({items:y.array(Gu)}),hy={schema:zu},yy={schema:y.object({items:y.array(y.union([...Gu.options,y.object({type:y.literal("markdown"),payload:zu})]))})},vy={text:{schema:Uu},image:{schema:Ku},audio:{schema:Wu},video:{schema:Lu},file:{schema:Fu},location:{schema:qu},carousel:{schema:gy},card:{schema:Vu},dropdown:{schema:$u},choice:{schema:$u},bloc:{schema:my}};var _y={HIDDEN_IN_STUDIO:{bpActionHiddenInStudio:"true"},AWAIT_RETURN:{bpActionAwaitReturn:"true"}};var Ju=require("browser-or-node");var ri=console;function re(t){if(!t.body)throw new Error("Missing body");return JSON.parse(t.body)}async function Kt(t,e=8072,n=xy){if(!Ju.isNode)throw new Error("This function can only be called in Node.js");let i=require("http").createServer(async(s,a)=>{try{let o=await Ty(s);if(o.path==="/health"){a.writeHead(200).end("ok");return}let u=await t(o);a.writeHead(u?.status??200,u?.headers??{}).end(u?.body??"{}")}catch(o){let u=o instanceof Error?o.message:String(o);ri.error("Error while handling request",{error:u??"Internal error occured"}),a.writeHead(500).end(JSON.stringify({error:u??"Internal error occured"}))}});return i.listen(e,()=>n(e)),i}async function Ty(t){let e=await wy(t),n={};for(let i=0;i<t.rawHeaders.length;i+=2){let s=t.rawHeaders[i].toLowerCase(),a=t.rawHeaders[i+1];n[s]=a}let r=new URL(t.url??"",t.headers.host?`http://${t.headers.host}`:"http://botpress.cloud");return{body:e,path:r.pathname,query:by(r.search,"?"),headers:n,method:t.method?.toUpperCase()??"GET"}}function by(t,e){return t.indexOf(e)===0?t.slice(e.length):t}async function wy(t){return new Promise((e,n)=>{if(t.method!=="POST"&&t.method!=="PUT"&&t.method!=="PATCH")return e(void 0);let r="";t.on("data",i=>r+=i.toString()),t.on("error",i=>n(i)),t.on("end",()=>e(r))})}function xy(t){ri.info(`Listening on port ${t}`)}var Kn=require("@botpress/client");var ii={};Ze(ii,{DefinitionError:()=>te,isDefinitionError:()=>Py});var te=class extends Error{__IS_SDK_ERROR__=!0;type="definition_error"},Py=t=>t instanceof te||typeof t=="object"&&t!==null&&"__IS_SDK_ERROR__"in t&&t.__IS_SDK_ERROR__===!0&&"type"in t&&t.type==="definition_error";var Z={};Ze(Z,{mapKeys:()=>Oy,mapValues:()=>Sy,mergeRecords:()=>Iy,pairs:()=>In,stripUndefinedProps:()=>Ey,values:()=>ky});var In=t=>Object.entries(t),ky=t=>Object.values(t),Sy=(t,e)=>Object.fromEntries(In(t).map(([n,r])=>[n,e(r,n)])),Oy=(t,e)=>Object.fromEntries(In(t).map(([n,r])=>[e(n),r])),Ey=t=>Object.fromEntries(In(t).filter(([,e])=>e!==void 0)),Iy=(t,e,n)=>{let r=[...Object.keys(t),...Object.keys(e)],i=[...new Set(r)],s={};for(let a of i){let o=t[a],u=e[a];o&&u?s[a]=n(o,u):o?s[a]=o:u&&(s[a]=u)}return s};var b={};Ze(b,{safePush:()=>By,unique:()=>Cy});var By=(t,...e)=>t?[...t,...e]:[...e],Cy=t=>Array.from(new Set(t));var V={};Ze(V,{setName:()=>Ay});var Ay=(t,e)=>(Object.defineProperty(t,"name",{value:e}),t);var Yu=t=>{let{name:e,version:n}=t,r={actions:{},events:{},channels:{}},i={name:e,version:n,entities:Z.mapValues(t.entities,a=>({name:a.name})),actions:{},events:{},channels:{}},s=Z.mapValues(t.entities,a=>a.schema);for(let[a,o]of Object.entries(t.definition.actions??{})){let u=o.input.schema.dereference(s),d=o.output.schema.dereference(s),p=t.actions?.[a]?.name??a;r.actions[p]={...o,...t.actions?.[a]??{},input:{schema:u},output:{schema:d}},i.actions[a]={name:p}}for(let[a,o]of Object.entries(t.definition.events??{})){let u=o.schema.dereference(s),d=t.events?.[a]?.name??a;r.events[d]={...o,...t.events?.[a]??{},schema:u},i.events[a]={name:d}}for(let[a,o]of Object.entries(t.definition.channels??{})){let u={};for(let[p,g]of Object.entries(o.messages)){let h=g.schema.dereference(s);u[p]={...g,schema:h}}let d=t.channels?.[a]?.name??a;r.channels[d]={...o,...t.channels?.[a]??{},message:{...o.message??{},tags:{...o.message?.tags??{},...t.channels?.[a]?.message?.tags??{}}},conversation:{...o.conversation??{},tags:{...o.conversation?.tags??{},...t.channels?.[a]?.conversation?.tags??{}}},messages:u},i.channels[a]={name:d}}return{resolved:r,statement:i}};var Xu="6.4.2";var Ae=Xu;var Bn=Symbol("schemaName"),Qu=t=>t?Z.mapValues(t,(n,r)=>({...n,[Bn]:r})):{},ec=t=>Bn in t&&t[Bn]!==void 0,tc=t=>t[Bn];var Cn=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.readme=e.readme,this.title=e.title,this.identifier=e.identifier,this.description=e.description,this.configuration=e.configuration,this.configurations=e.configurations,this.events=e.events,this.actions=e.actions,this.channels=e.channels,this.states=e.states,this.user=e.user,this.secrets=e.secrets,this.entities=e.entities,this.interfaces=e.interfaces,this.__advanced=e.__advanced,this.attributes=e.attributes}name;version;title;description;icon;readme;configuration;configurations;events;actions;channels;states;user;secrets;identifier;entities;interfaces;__advanced;attributes;get metadata(){return{sdkVersion:Ae}}extend(e,n){let{entities:r,actions:i,events:s,channels:a}=this._callBuilder(e,n),o=this;o.interfaces??={};let u=Object.values(r).map(h=>h.name),d=u.length===0?e.name:`${e.name}<${u.join(",")}>`,{resolved:p,statement:g}=Yu({...e,entities:r,actions:Z.stripUndefinedProps(i),events:Z.stripUndefinedProps(s),channels:Z.stripUndefinedProps(a)});return o.actions=Z.mergeRecords(o.actions??{},p.actions,this._mergeActions),o.channels=Z.mergeRecords(o.channels??{},p.channels,this._mergeChannels),o.events=Z.mergeRecords(o.events??{},p.events,this._mergeEvents),o.interfaces[d]={id:e.id,...g},this}_callBuilder(e,n){let i={entities:Qu(this.entities)},s=n(i),a=Z.pairs(s.entities).find(([u,d])=>!ec(d));if(a)throw new te(`Cannot extend interface "${e.name}" with entity "${a[0]}"; the provided schema is not part of the integration's entities.`);return{entities:Z.mapValues(s.entities,u=>({name:tc(u),schema:u.schema})),actions:s.actions??{},events:s.events??{},channels:s.channels??{}}}_mergeActions=(e,n)=>({...e,...n,input:{schema:this._mergeObjectSchemas(e.input.schema,n.input.schema)},output:{schema:this._mergeObjectSchemas(e.output.schema,n.output.schema)}});_mergeEvents=(e,n)=>({...e,...n,schema:this._mergeObjectSchemas(e.schema,n.schema)});_mergeChannels=(e,n)=>{let r=Z.mergeRecords(e.messages,n.messages,this._mergeMessage),i;(e.conversation||n.conversation)&&(i={tags:{...e.conversation?.tags,...n.conversation?.tags}});let s;return(e.message||n.message)&&(s={tags:{...e.message?.tags,...n.message?.tags}}),{...e,...n,messages:r,conversation:i,message:s}};_mergeMessage=(e,n)=>({schema:this._mergeObjectSchemas(e.schema,n.schema)});_mergeObjectSchemas=(e,n)=>{let r=e._def,i=n._def;if(r.typeName==="ZodObject"&&i.typeName==="ZodObject"){let s=r.shape(),a=i.shape();return y.object({...s,...a})}if(r.typeName==="ZodRecord"&&i.typeName==="ZodRecord")return y.record(y.intersection(r.valueType,i.valueType));throw new Error("Cannot merge object schemas with record schemas")}};var Se=require("@botpress/client");var nc=Wn(require("@botpress/client")),An={retries:3,retryCondition:t=>nc.axiosRetry.isNetworkOrIdempotentRequestError(t)||[429,502].includes(t.response?.status??0),retryDelay:(t,e)=>(Ry(e.response?.headers??{})??t)*1e3},Ry=t=>{let e=["RateLimit-Reset","X-RateLimit-Reset","Retry-After","ratelimit-reset","x-ratelimit-reset","retry-after"];for(let n of e){let r=t[n];if(r!==void 0)return Ny(String(r))}},Ny=t=>{let e=Dy(t)?Hy(t):t.length>0?parseInt(t,10):void 0;return e===void 0||isNaN(e)?void 0:e},Dy=t=>t.includes(" "),Hy=t=>{let e=My(t);if(!e)return;let n=new Date;return Math.max(0,Math.floor((e.getTime()-n.getTime())/1e3))},My=t=>{let e=new Date(t);return isNaN(e.getTime())?void 0:e};var ut=class{constructor(e){this._client=e}get _inner(){return this._client}createConversation=(e=>this._client.createConversation(e));getConversation=(e=>this._client.getConversation(e));listConversations=(e=>this._client.listConversations(e));getOrCreateConversation=(e=>this._client.getOrCreateConversation(e));updateConversation=(e=>this._client.updateConversation(e));deleteConversation=(e=>this._client.deleteConversation(e));listParticipants=(e=>this._client.listParticipants(e));addParticipant=(e=>this._client.addParticipant(e));getParticipant=(e=>this._client.getParticipant(e));removeParticipant=(e=>this._client.removeParticipant(e));createEvent=(e=>this._client.createEvent(e));getEvent=(e=>this._client.getEvent(e));listEvents=(e=>this._client.listEvents(e));createMessage=(e=>this._client.createMessage(e));getOrCreateMessage=(e=>this._client.getOrCreateMessage(e));getMessage=(e=>this._client.getMessage(e).then(n=>n));updateMessage=(e=>this._client.updateMessage(e).then(n=>n));listMessages=(e=>this._client.listMessages(e));deleteMessage=(e=>this._client.deleteMessage(e));initializeIncomingMessage=(e=>this._client.initializeIncomingMessage(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 Zn=class{_cost=0;get cost(){return this._cost}setCost(e){this._cost=e}toJSON(){return{cost:this.cost}}};var pe="#",Rn="x-bot-id",rc="x-bot-user-id",ic="x-integration-id",sc="x-integration-alias",ac="x-webhook-id",oc="x-bp-configuration-type",Nn="x-bp-configuration",Dn="x-bp-operation",lc="x-bp-type";var ie=t=>{throw t instanceof Error?t:new Error(t)};var p_=y.enum(["webhook_received","message_created","action_triggered","register","unregister","ping","create_user","create_conversation"]),uc=t=>({botId:t[Rn]||ie("Missing bot header"),botUserId:t[rc]||ie("Missing bot user header"),integrationId:t[ic]||ie("Missing integration header"),integrationAlias:t[sc]||ie("Missing integration alias header"),webhookId:t[ac]||ie("Missing webhook header"),operation:t[Dn]||ie("Missing operation header"),configurationType:t[oc]??null,configuration:JSON.parse(Buffer.from(t[Nn]||ie("Missing configuration header"),"base64").toString("utf-8"))});var cc=Wn(require("util")),ct=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)}issue(e){console.info(JSON.stringify(e))}_log(e,n){this._getConsoleMethod(e)(this._serializeMessage(n))}_serializeMessage(e){let n=cc.default.format(...e);return process.env.BP_LOG_FORMAT==="json"?this.getJsonMessage(n):n}getJsonMessage(e){return JSON.stringify({msg:e,options:this.defaultOptions})}_getConsoleMethod(e){switch(e){case"debug":return console.debug;case"warn":return console.warn;case"error":return console.error;default:return console.info}}};var dt=class t extends ct{constructor(e){super({visibleToBotOwners:!1,hiddenToIntegrationOwners:!1,...e})}with(e){return new t({...this.defaultOptions,...e})}withUserId(e){return this.with({userId:e})}withConversationId(e){return this.with({conversationId:e})}withVisibleToBotOwners(e){return this.with({visibleToBotOwners:e})}withHiddenToIntegrationOwners(e){return this.with({hiddenToIntegrationOwners:e})}forBot(){return this.with({hiddenToIntegrationOwners:!1,visibleToBotOwners:!0})}forBotOnly(){return this.with({hiddenToIntegrationOwners:!0,visibleToBotOwners:!0})}getJsonMessage(e){return JSON.stringify({msg:e,visible_to_bot_owner:this.defaultOptions.visibleToBotOwners,hidden_to_integration_owner:this.defaultOptions.hiddenToIntegrationOwners,options:this.defaultOptions})}};var jy=t=>["traceparent","tracestate","sentry-trace"].reduce((e,n)=>(t[n]&&(e[n]=t[n]),e),{}),$y=(t,e,n)=>{let[,r]=(e.headers.traceparent||"").split("-"),i=new Se.Client({botId:t.botId,integrationId:t.integrationId,integrationAlias:t.integrationAlias,retry:An,headers:jy(e.headers)}),s=new ut(i),a=new dt({traceId:r});return{ctx:t,req:e,client:s,logger:a,instance:n}},Uy=async t=>{let{ctx:e}=t;switch(e.operation){case"webhook_received":return await Ky(t);case"register":return await Wy(t);case"unregister":return await Ly(t);case"message_created":return await Vy(t);case"action_triggered":return await Gy(t);case"ping":return await zy(t);case"create_user":return await Fy(t);case"create_conversation":return await qy(t);default:throw new Se.InvalidPayloadError(`Unknown operation ${e.operation}`)}},dc=t=>async e=>{let n=uc(e.headers),r=$y(n,e,t),{logger:i}=r;try{let s;return s=await Jy(r),s?{...s,status:s.status??200}:(s=await Uy(r),s?{...s,status:s.status??200}:{status:200})}catch(s){if((0,Se.isApiError)(s)){let o=s.type==="Runtime"?s:new Se.RuntimeError(s.message,s);return i.forBot().error(o.message),{status:o.code,body:JSON.stringify(o.toJSON())}}console.error(s);let a=new Se.RuntimeError("An unexpected error occurred in the integration. Bot owners: Check logs for more informations. Integration owners: throw a RuntimeError to return a custom error message instead.");return i.forBot().error(a.message),{status:a.code,body:JSON.stringify(a.toJSON())}}},zy=async t=>{},Ky=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{let{req:s}=re(n);return i.webhook({client:t,ctx:e,req:s,logger:r})},Wy=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{if(!i.register)return;let{webhookUrl:s}=re(n);await i.register({client:t,ctx:e,webhookUrl:s,logger:r})},Ly=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{if(!i.unregister)return;let{webhookUrl:s}=re(n);await i.unregister({ctx:e,webhookUrl:s,client:t,logger:r})},Fy=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{if(!i.createUser)return;let{tags:s}=re(n);return await i.createUser({ctx:e,client:t,tags:s,logger:r})},qy=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{if(!i.createConversation)return;let{channel:s,tags:a}=re(n);return await i.createConversation({ctx:e,client:t,channel:s,tags:a,logger:r})},Vy=async({ctx:t,req:e,client:n,logger:r,instance:i})=>{let{conversation:s,user:a,type:o,payload:u,message:d}=re(e),p=i.channels[s.channel];if(!p)throw new Error(`Channel ${s.channel} not found`);let g=p.messages[o];if(!g)throw new Error(`Message of type ${o} not found in channel ${s.channel}`);await g({ctx:t,conversation:s,message:d,user:a,type:o,client:n,payload:u,ack:async({tags:w})=>{await n.updateMessage({id:d.id,tags:w})},logger:r})},Gy=async({req:t,ctx:e,client:n,logger:r,instance:i})=>{let{input:s,type:a}=re(t);if(!a)throw new Error("Missing action type");let o=i.actions[a];if(!o)throw new Error(`Action ${a} not found`);let u=new Zn,p={output:await o({ctx:e,input:s,client:n,type:a,logger:r,metadata:u}),meta:u.toJSON()};return{body:JSON.stringify(p)}},Jy=async({instance:t,client:e,ctx:n,logger:r,req:i})=>{let s=t.unknownOperationHandler;if(s)return await s({client:e,ctx:n,logger:r,req:i})};var Hn=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=dc(this);start=e=>Kt(this.handler,e)};var Mn=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.secrets=e.secrets,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;secrets;workflows;attributes;__advanced;withPlugins;get metadata(){return{sdkVersion:Ae}}addIntegration(e,n){let r=this;r.integrations||(r.integrations={});let i=n?.alias??e.name;if(r.integrations[i])throw new te(`Another integration with alias "${i}" is already installed in the bot`);return r.integrations[i]={...e,alias:i,enabled:n?.enabled,configurationType:n&&"configurationType"in n?n.configurationType:void 0,configuration:n&&"configuration"in n?n.configuration??{}:{},disabledChannels:n?.disabledChannels},this}addPlugin(e,n){let r=this;r.plugins||(r.plugins={});let i=n.alias??e.name;if(r.plugins[i])throw new te(`Another plugin with alias "${i}" is already installed in the bot`);let s=Object.fromEntries(Object.entries(n.dependencies??{}).filter(([o,u])=>"integrationInterfaceAlias"in u).map(([o,u])=>{let d=this.integrations?.[u.integrationAlias];if(!d){let g=Object.keys(this.integrations??{}).join(", ")||"(none)";throw new te(`Interface with alias "${o}" of plugin with alias "${i}" references integration with alias "${u.integrationAlias}" which is not installed. Please make sure to add the integration via addIntegration() before calling addPlugin().
73
+ Available integration aliases: ${g}`)}let p=d.definition.interfaces?.[u.integrationInterfaceAlias];if(!p){let g=Object.keys(d.definition.interfaces??{}).join(", ")||"(none)";throw new te(`Interface with alias "${u.integrationInterfaceAlias}" does not exist in integration "${d.name}" referenced by interface with alias "${o}" of plugin with alias "${i}".
74
74
  Available interface aliases: ${g}`)}return[o,{...p,id:d.id,name:d.name,version:d.version,...u}]})),a=Object.fromEntries(Object.entries(n.dependencies??{}).filter(([o,u])=>!("integrationInterfaceAlias"in u)).map(([o,u])=>{let d=this.integrations?.[u.integrationAlias];if(!d){let p=Object.keys(this.integrations??{}).join(", ")||"(none)";throw new Error(`Integration with alias "${o}" of plugin with alias "${i}" references integration with alias "${u.integrationAlias}" which is not installed. Please make sure to add the integration via addIntegration() before calling addPlugin().
75
- Available integration aliases: ${p}`)}return[o,{...d,...u}]}));return r.plugins[i]={...e,alias:i,configuration:n.configuration??{},interfaces:s,integrations:a},r.withPlugins.user=this._mergeUser(r.withPlugins.user,e.definition.user),r.withPlugins.conversation=this._mergeConversation(r.withPlugins.conversation,e.definition.conversation),r.withPlugins.message=this._mergeMessage(r.withPlugins.message,e.definition.message),r.withPlugins.recurringEvents=this._mergeRecurringEvents(r.withPlugins.recurringEvents,e.definition.recurringEvents),r.withPlugins.tables=this._mergeTables(r.withPlugins.tables,e.definition.tables),r.withPlugins.workflows=this._mergeWorkflows(r.withPlugins.workflows,e.definition.workflows),r.withPlugins.states=this._mergeStates(r.withPlugins.states,this._prefixKeysWithPluginAlias(e.definition.states,i)),r.withPlugins.events=this._mergeEvents(r.withPlugins.events,this._prefixKeysWithPluginAlias(e.definition.events,i)),r.withPlugins.actions=this._mergeActions(r.withPlugins.actions,this._prefixKeysWithPluginAlias(e.definition.actions,i)),this}_mergeUser=(e,n)=>({tags:{...e?.tags,...n?.tags}});_mergeConversation=(e,n)=>({tags:{...e?.tags,...n?.tags}});_mergeMessage=(e,n)=>({tags:{...e?.tags,...n?.tags}});_mergeStates=(e,n)=>({...e,...n});_mergeEvents=(e,n)=>({...e,...n});_mergeRecurringEvents=(e,n)=>({...e,...n});_mergeActions=(e,n)=>({...e,...n});_mergeTables=(e,n)=>({...e,...n});_mergeWorkflows=(e,n)=>({...e,...n});_prefixKeysWithPluginAlias=(e,n)=>Z.mapKeys(e??{},r=>`${n}${de}${r}`);dereferencePluginEntities(){let e=this._buildZuiReferenceMap();return{...this,withPlugins:{...this.withPlugins,events:this._dereferenceDefinitionSchemas(this.withPlugins.events,e),states:this._dereferenceDefinitionSchemas(this.withPlugins.states,e),tables:this._dereferenceDefinitionSchemas(this.withPlugins.tables,e),actions:this._dereferenceActionDefinitionSchemas(this.withPlugins.actions,e)},plugins:Object.fromEntries(Object.entries(this.plugins??{}).map(([n,r])=>[n,{...r,definition:{...r.definition,configuration:this._dereferenceDefinitionSchema(r.definition.configuration,e),events:this._dereferenceDefinitionSchemas(r.definition.events,e),states:this._dereferenceDefinitionSchemas(r.definition.states,e),tables:this._dereferenceDefinitionSchemas(r.definition.tables,e),actions:this._dereferenceActionDefinitionSchemas(r.definition.actions,e)}}]))}}_buildZuiReferenceMap(){let e={},n=Object.entries(this.plugins??{});for(let[r,i]of n){let s=Object.entries(i.interfaces??{});for(let[a,o]of s){let u=this.integrations?.[o.integrationAlias];if(!u)throw new Error(`Interface with alias "${a}" of plugin with alias "${r}" references integration "${o.name}" which is not installed`);let d=Object.entries(o.entities??{});for(let[p,{name:g}]of d){let h=u.definition.entities?.[g]?.schema;if(!h)throw new Error(`Interface entity "${g}" does not exist in integration "${u.name}"`);e[`interface:${a}/entities/${p}`]=h}}}return e}_dereferenceZuiSchema(e,n){return e.dereference(n)}_dereferenceDefinitionSchemas(e,n){return Object.fromEntries(Object.entries(e??{}).map(([r,i])=>[r,this._dereferenceDefinitionSchema(i,n)]))}_dereferenceDefinitionSchema(e,n){return e&&{...e,schema:this._dereferenceZuiSchema(e.schema,n)}}_dereferenceActionDefinitionSchemas(e,n){return Object.fromEntries(Object.entries(e??{}).map(([r,i])=>[r,{...i,input:{schema:this._dereferenceZuiSchema(i.input.schema,n)},output:{schema:this._dereferenceZuiSchema(i.output.schema,n)}}]))}};var Qe=require("@botpress/client");var dt=class t extends ut{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 me=class{constructor(e,n={before:{},after:{}}){this._client=e;this._hooks=n}get _inner(){return this._client}getConversation=(e=>this._run("getConversation",e));listConversations=(e=>this._run("listConversations",e));updateConversation=(e=>this._run("updateConversation",e));deleteConversation=(e=>this._run("deleteConversation",e));listParticipants=(e=>this._run("listParticipants",e));addParticipant=(e=>this._run("addParticipant",e));getParticipant=(e=>this._run("getParticipant",e));removeParticipant=(e=>this._run("removeParticipant",e));createEvent=(e=>this._run("createEvent",e));getEvent=(e=>this._run("getEvent",e));listEvents=(e=>this._run("listEvents",e));createMessage=(e=>this._run("createMessage",e));getMessage=(e=>this._run("getMessage",e));updateMessage=(e=>this._run("updateMessage",e));listMessages=(e=>this._run("listMessages",e));deleteMessage=(e=>this._run("deleteMessage",e));getUser=(e=>this._run("getUser",e));listUsers=(e=>this._run("listUsers",e));updateUser=(e=>this._run("updateUser",e));deleteUser=(e=>this._run("deleteUser",e));getState=(e=>this._run("getState",e));setState=(e=>this._run("setState",e));getOrSetState=(e=>this._run("getOrSetState",e));patchState=(e=>this._run("patchState",e));callAction=(e=>this._run("callAction",e));uploadFile=(e=>this._run("uploadFile",e));upsertFile=(e=>this._run("upsertFile",e));deleteFile=(e=>this._run("deleteFile",e));listFiles=(e=>this._run("listFiles",e));getFile=(e=>this._run("getFile",e));updateFileMetadata=(e=>this._run("updateFileMetadata",e));searchFiles=(e=>this._run("searchFiles",e));trackAnalytics=(e=>this._run("trackAnalytics",e));getTableRow=(e=>this._run("getTableRow",e));createTableRows=(e=>this._run("createTableRows",e));findTableRows=(e=>this._run("findTableRows",e));deleteTableRows=(e=>this._run("deleteTableRows",e));updateTableRows=(e=>this._run("updateTableRows",e));upsertTableRows=(e=>this._run("upsertTableRows",e));createWorkflow=(e=>this._run("createWorkflow",e));getOrCreateWorkflow=(e=>this._run("getOrCreateWorkflow",e));getWorkflow=(e=>this._run("getWorkflow",e));updateWorkflow=(e=>this._run("updateWorkflow",e));deleteWorkflow=(e=>this._run("deleteWorkflow",e));listWorkflows=(e=>this._run("listWorkflows",e));createConversation=e=>this._client.createConversation(e);getOrCreateConversation=e=>this._client.getOrCreateConversation(e);createUser=e=>this._client.createUser(e);getOrCreateUser=e=>this._client.getOrCreateUser(e);_run=async(e,n)=>{let r=this._hooks.before[e];r&&(n=await r(n));let i=await this._client[e](n),s=this._hooks.after[e];return s&&(i=await s(i,n)),i}};var Vy=y.enum(["event_received","register","unregister","ping","action_triggered"]),cc=t=>({botId:t[Zn]||re("Missing bot id header"),operation:Vy.parse(t[Nn]),type:t[ac]||re("Missing type header"),configuration:JSON.parse(Buffer.from(t[Rn]||re("Missing configuration header"),"base64").toString("utf-8"))});var G={status:200};var ii=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 Gy=["child_workflow_deleted","child_workflow_finished","workflow_timedout","workflow_started","workflow_continued"],dc=async(t,e)=>{if(t.ctx.type!=="workflow_update"||!Gy.includes(e.payload.type))throw new Error("Unexpected event type");let n={...t,logger:Jy(t,e)};if(!e.payload.workflow.name)return n.logger.warn("Received workflow update event without a workflow name. Assuming this workflow was not defined by the bot.",e.payload.workflow),G;switch(e.payload.type){case"child_workflow_deleted":case"child_workflow_finished":n.logger.info(`Received child workflow event "${e.payload.type}", but child workflows are not yet supported`);break;case"workflow_timedout":case"workflow_started":case"workflow_continued":return await Yy(n,e);default:e.payload.type}return G},Jy=(t,e)=>t.logger.with({eventId:e.id,workflowId:e.payload.workflow.id,conversationId:e.payload.conversation?.id,userId:e.payload.user?.id}),Yy=async(t,e)=>{let n=ii(e.payload.type),r=t.self.workflowHandlers[n]?.[e.payload.workflow.name];if(!r||r.length===0)return t.logger.warn(`No ${n} handler found for workflow "${e.payload.workflow.name}"`),G;let{updatedWorkflow:i}=await Xy(t,e);return i.status==="pending"&&t.logger.warn(`Workflow "${e.payload.workflow.name}" is still in pending status after processing "${n}" event. This may indicate that the workflow was not properly acknowledged or terminated by the handler. `),G},Xy=async(t,e)=>{let n=ii(e.payload.type),r=t.self.workflowHandlers[n]?.[e.payload.workflow.name],i=structuredClone(e.payload.workflow);for(let s of r??[])i=await s({...t,event:e,conversation:e.payload.conversation,user:e.payload.user,workflow:i});return{updatedWorkflow:i}};var pc=t=>async e=>{let n=cc(e.headers),r=new dt,i=new Qe.Client({botId:n.botId,retry:Cn}),s=new me(i,{before:{createMessage:async o=>{let u=t.hookHandlers.before_outgoing_message[o.type]??[];for(let d of u){let p=new me(i);o=(await d({client:p,ctx:n,logger:r.with({conversationId:o.conversationId,userId:o.userId}),data:o}))?.data??o}return o},callAction:async o=>{let u=t.hookHandlers.before_outgoing_call_action[o.type]??[];for(let d of u){let p=new me(i);o=(await d({client:p,ctx:n,logger:r,data:o}))?.data??o}return o}},after:{createMessage:async o=>{let u=t.hookHandlers.after_outgoing_message[o.message.type]??[];for(let d of u){let p=new me(i);o=(await d({client:p,ctx:n,logger:r.with({messageId:o.message.id,conversationId:o.message.conversationId,userId:o.message.userId}),data:o}))?.data??o}return o},callAction:async(o,u)=>{let{type:d}=u,p=t.hookHandlers.after_outgoing_call_action[d]??[];for(let g of p){let h=new me(i);o=(await g({client:h,ctx:n,logger:r,data:{type:d,...o}}))?.data??o}return o}}}),a={req:e,ctx:n,logger:r,client:s,self:t};try{switch(n.operation){case"action_triggered":return await rv(a);case"event_received":return await nv(a);case"register":return await ev(a);case"unregister":return await tv(a);case"ping":return await Qy(a);default:throw new Error(`Unknown operation ${n.operation}`)}}catch(o){let u=o instanceof Error?o:new Error(String(o));if((0,Qe.isApiError)(u)){let p=u.type==="Runtime"?u:new Qe.RuntimeError(u.message,u);return r.error(p.message),{status:p.code,body:JSON.stringify(p.toJSON())}}let d=new Qe.RuntimeError("An unexpected error occurred in the bot.",u);return r.error(d.message,u),{status:d.code,body:JSON.stringify(d.toJSON())}}},Qy=async t=>G,ev=async t=>(await t.self.registerHandler?.({client:t.client,ctx:t.ctx,logger:t.logger}),G),tv=async t=>G,nv=async t=>{let{ctx:e,logger:n,req:r,client:i,self:s}=t,a={client:i,ctx:e,logger:n},o=ne(r);if(a.logger=a.logger.with({eventId:o.event.id,messageId:o.event.messageId,conversationId:o.event.conversationId,userId:o.event.userId}),e.type==="workflow_update")return await dc(t,o.event);if(e.type==="message_created"){let w=o.event,T=w.payload.message;a.logger=a.logger.with({messageId:T.id,conversationId:T.conversationId,userId:T.userId});let D=s.hookHandlers.before_incoming_message[T.type]??[];for(let oe of D){let H=await oe({...a,data:T});if(T=H?.data??T,H?.stop)return G}let F={...a,user:w.payload.user,conversation:w.payload.conversation,message:T,event:w},J=s.messageHandlers[T.type]??[];for(let oe of J)await oe(F);let ae=s.hookHandlers.after_incoming_message[T.type]??[];for(let oe of ae){let H=await oe({...a,data:T});if(T=H?.data??T,H?.stop)return G}return G}if(e.type==="state_expired"){let T=o.event.payload.state,D={...a,state:T},F=s.stateExpiredHandlers[T.name]??[];for(let J of F)await J(D);return G}let u=o.event,d=s.hookHandlers.before_incoming_event[u.type]??[];for(let w of d){let T=await w({...a,data:u});if(u=T?.data??u,T?.stop)return G}let p={...a,event:u},g=s.eventHandlers[u.type]??[];for(let w of g)await w(p);let h=s.hookHandlers.after_incoming_event[u.type]??[];for(let w of h){let T=await w({...a,data:u});if(u=T?.data??u,T?.stop)return G}return G},rv=async({ctx:t,logger:e,req:n,client:r,self:i})=>{let{input:s,type:a}=ne(n);if(!a)throw new Error("Missing action type");let o=i.hookHandlers.before_incoming_call_action[a]??[];for(let h of o){let w=await h({ctx:t,logger:e,client:r,data:{type:a,input:s}});s=w?.data?.input??s,a=w?.data?.type??a}let u=i.actionHandlers[a];if(!u)throw new Error(`Action ${a} not found`);let d=await u({ctx:t,logger:e,input:s,client:r,type:a}),p=i.hookHandlers.after_incoming_call_action[a]??[];for(let h of p){let w=await h({ctx:t,logger:e,client:r,data:{type:a,output:d}});a=w?.data?.type??a,d=w?.data?.output??d}return{status:200,body:JSON.stringify({output:d})}};var he=(t,{alias:e})=>{if(!("tags"in t)||!e)return t;let n=`${e}${de}`,r=Object.fromEntries(Object.entries(t.tags??{}).flatMap(([i,s])=>i.startsWith(n)?[[i.slice(n.length),s]]:[]));return{...t,tags:r}},X=(t,{alias:e})=>{if(!("tags"in t)||!e)return t;let n=`${e}${de}`,r=Object.fromEntries(Object.entries(t.tags??{}).map(([i,s])=>[i.startsWith(n)?i:`${n}${i}`,s]));return{...t,tags:r}};var si=class{constructor(e){this._list=e}_nextToken;_elementsBuffer=[];_isExhausted=!1;[Symbol.asyncIterator](){return this}async next(){return this._bufferIsEmpty&&!this._isExhausted&&await this._fetchNextPageIntoBuffer(),this._bufferIsEmpty?{done:!0,value:void 0}:{done:!1,value:this._elementsBuffer.shift()}}async take(e){let n=[];for(let r=0;r<e;++r){let i=await this.next();if(i.done)break;n.push(i.value)}return n}async takePage(e){for(let r=0;r<e;++r)this._isExhausted||await this._fetchNextPageIntoBuffer();let n=[...this._elementsBuffer];return this._elementsBuffer.length=0,n}async takeAll(){return this.take(Number.POSITIVE_INFINITY)}get isExhausted(){return this._isExhausted}async _fetchNextPageIntoBuffer(){let{items:e,meta:n}=await this._list({nextToken:this._nextToken});this._elementsBuffer.push(...e),this._nextToken=n.nextToken,n.nextToken||(this._isExhausted=!0)}get _bufferIsEmpty(){return this._elementsBuffer.length===0}},ie=t=>new si(t);var Se=t=>new Proxy({},{get:(e,n)=>({listInstances:r=>ie(({nextToken:i})=>t.client.listWorkflows({...r,name:n,nextToken:i}).then(({meta:s,workflows:a})=>({meta:s,items:a.map(o=>se({...t,workflow:o}))}))),startNewInstance:async r=>{let{workflow:i}=await t.client.createWorkflow({name:n,status:"pending",...X(r,{alias:void 0})});return{workflow:se({...t,workflow:i})}}})}),se=t=>{let e=!1;return{...he(t.workflow,{alias:void 0}),async update(n){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,...X(n,{alias:void 0})});return await t.onWorkflowUpdate?.(r),{workflow:se({...t,workflow:r})}},async acknowledgeStartOfProcessing(){if(!t.event||t.workflow.status!=="pending"||e)return{workflow:se(t)};let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,status:"in_progress",eventId:t.event.id});return e=!0,await t.onWorkflowUpdate?.(n),{workflow:se({...t,workflow:n})}},async setFailed({failureReason:n}){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,status:"failed",failureReason:n});return await t.onWorkflowUpdate?.(r),{workflow:se({...t,workflow:r})}},async setCompleted({output:n}={}){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,status:"completed",output:n});return await t.onWorkflowUpdate?.(r),{workflow:se({...t,workflow:r})}},async cancel(){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,status:"cancelled"});return await t.onWorkflowUpdate?.(n),{workflow:se({...t,workflow:n})}}}};var Mn=class{constructor(e){this.props=e;this._registerHandler=e.register,this._actionHandlers=e.actions,this._plugins=e.plugins}_registerHandler;_actionHandlers;_messageHandlers={};_eventHandlers={};_stateExpiredHandlers={};_hookHandlers={before_incoming_event:{},before_incoming_message:{},before_outgoing_message:{},before_outgoing_call_action:{},before_incoming_call_action:{},after_incoming_event:{},after_incoming_message:{},after_outgoing_message:{},after_outgoing_call_action:{},after_incoming_call_action:{}};_workflowHandlers={started:{},continued:{},timed_out:{}};_plugins={};_registerOrder=0;get registerHandler(){return this._registerHandler}get actionHandlers(){return new Proxy({},{get:(e,n)=>{let r=this._actionHandlers[n];if(r)return V.setName(i=>r({...i,workflows:Se(i)}),r.name);for(let[i,s]of Object.entries(this._plugins)){let[a,o]=n.split(de);if(!(a!==i||!o))return s.actionHandlers[o]}}})}get messageHandlers(){return new Proxy({},{get:(e,n)=>{let r=Object.values(this._plugins).flatMap(o=>o.messageHandlers[n]??[]),i=n==="*"?[]:this._messageHandlers[n]??[],s=this._messageHandlers["*"]??[],a=[...i,...s].sort((o,u)=>o.order-u.order).map(({handler:o})=>V.setName(u=>o({...u,workflows:Se(u)}),o.name));return b.unique([...r,...a])}})}get eventHandlers(){return new Proxy({},{get:(e,n)=>{let r=Object.values(this._plugins).flatMap(o=>o.eventHandlers[n]??[]),i=n==="*"?[]:this._eventHandlers[n]??[],s=this._eventHandlers["*"]??[],a=[...i,...s].sort((o,u)=>o.order-u.order).map(({handler:o})=>V.setName(u=>o({...u,workflows:Se(u)}),o.name));return b.unique([...r,...a])}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,n)=>{let r=Object.values(this._plugins).flatMap(o=>o.stateExpiredHandlers[n]??[]),i=n==="*"?[]:this._stateExpiredHandlers[n]??[],s=this._stateExpiredHandlers["*"]??[],a=[...i,...s].sort((o,u)=>o.order-u.order).map(({handler:o})=>V.setName(u=>o({...u,workflows:Se(u)}),o.name));return b.unique([...r,...a])}})}get hookHandlers(){return new Proxy({},{get:(e,n)=>{if(this._hookHandlers[n])return new Proxy({},{get:(i,s)=>{let a=Object.values(this._plugins).flatMap(g=>g.hookHandlers[n]?.[s]??[]),o=this._hookHandlers[n]??{},u=s==="*"?[]:o[s]??[],d=o["*"]??[],p=[...u,...d].sort((g,h)=>g.order-h.order).map(({handler:g})=>V.setName(h=>g({...h,workflows:Se(h)}),g.name));return b.unique([...a,...p])}})}})}get workflowHandlers(){return new Proxy({},{get:(e,n)=>{let r=this._workflowHandlers[n];if(r)return new Proxy({},{get:(i,s)=>{let a=r[s]?.sort((u,d)=>u.order-d.order).map(({handler:u})=>V.setName(async d=>{let p=d.workflow;return await u({...d,workflow:se({...d,onWorkflowUpdate(g){p=g}}),workflows:Se(d)}),p},u.name))??[],o=Object.values(this._plugins).flatMap(u=>u.workflowHandlers[n]?.[s]??[]);return b.unique([...a,...o])}})}})}on={message:(e,n)=>{this._messageHandlers[e]=b.safePush(this._messageHandlers[e],{handler:n,order:this._registerOrder++})},event:(e,n)=>{this._eventHandlers[e]=b.safePush(this._eventHandlers[e],{handler:n,order:this._registerOrder++})},stateExpired:(e,n)=>{this._stateExpiredHandlers[e]=b.safePush(this._stateExpiredHandlers[e],{handler:n,order:this._registerOrder++})},beforeIncomingEvent:(e,n)=>{this._hookHandlers.before_incoming_event[e]=b.safePush(this._hookHandlers.before_incoming_event[e],{handler:n,order:this._registerOrder++})},beforeIncomingMessage:(e,n)=>{this._hookHandlers.before_incoming_message[e]=b.safePush(this._hookHandlers.before_incoming_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingMessage:(e,n)=>{this._hookHandlers.before_outgoing_message[e]=b.safePush(this._hookHandlers.before_outgoing_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingCallAction:(e,n)=>{this._hookHandlers.before_outgoing_call_action[e]=b.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},beforeIncomingCallAction:(e,n)=>{this._hookHandlers.before_incoming_call_action[e]=b.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingEvent:(e,n)=>{this._hookHandlers.after_incoming_event[e]=b.safePush(this._hookHandlers.after_incoming_event[e],{handler:n,order:this._registerOrder++})},afterIncomingMessage:(e,n)=>{this._hookHandlers.after_incoming_message[e]=b.safePush(this._hookHandlers.after_incoming_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingMessage:(e,n)=>{this._hookHandlers.after_outgoing_message[e]=b.safePush(this._hookHandlers.after_outgoing_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingCallAction:(e,n)=>{this._hookHandlers.after_outgoing_call_action[e]=b.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingCallAction:(e,n)=>{this._hookHandlers.after_incoming_call_action[e]=b.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:n,order:this._registerOrder++})},workflowStart:(e,n)=>{this._workflowHandlers.started[e]=b.safePush(this._workflowHandlers.started[e],{handler:n,order:this._registerOrder++})},workflowContinue:(e,n)=>{this._workflowHandlers.continued[e]=b.safePush(this._workflowHandlers.continued[e],{handler:n,order:this._registerOrder++})},workflowTimeout:(e,n)=>{this._workflowHandlers.timed_out[e]=b.safePush(this._workflowHandlers.timed_out[e],{handler:n,order:this._registerOrder++})}};handler=pc(this);start=e=>zt(this.handler,e)};var jn=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.title=e.title,this.description=e.description,this.readme=e.readme,this.entities=e.entities??{},this.attributes=e.attributes,this.__advanced=e.__advanced;let n=this._getEntityReference(this.entities),r=e.events===void 0?{}:Z.mapValues(e.events,a=>({...a,schema:a.schema(n)})),i=e.actions===void 0?{}:Z.mapValues(e.actions,a=>({...a,input:{...a.input,schema:a.input.schema(n)},output:{...a.output,schema:a.output.schema(n)}})),s=e.channels===void 0?{}:Z.mapValues(e.channels,a=>({...a,messages:Z.mapValues(a.messages,o=>({...o,schema:o.schema(n)}))}));this.events=r,this.actions=i,this.channels=s}name;version;title;description;icon;readme;attributes;entities;events;actions;channels;__advanced;get metadata(){return{sdkVersion:Ce}}_getEntityReference=e=>{let n={};for(let[r,i]of Object.entries(e)){let s=i.schema._def["x-zui"]?.title,a=i.schema._def.description,o=y.ref(r);s&&o.title(s),a&&o.describe(a),n[r]=o}return n}};var $n=class{constructor(e){this.props=e;let n=Object.fromEntries(Object.entries(e.interfaces??{}).map(([i,s])=>[i,Object.fromEntries(Object.entries(s.definition.entities??{}).map(([a])=>[a,y.ref(`interface:${i}/entities/${a}`)]))]));this.name=e.name,this.version=e.version,this.icon=e.icon,this.readme=e.readme,this.title=e.title,this.description=e.description,this.integrations=e.integrations,this.interfaces=e.interfaces,this.user=e.user,this.conversation=e.conversation,this.message=e.message,this.recurringEvents=e.recurringEvents,this.workflows=e.workflows,this.attributes=e.attributes,this.__advanced=e.__advanced;let r=new Set;for(let i of[...Object.keys(e.integrations??{}),...Object.keys(e.interfaces??{})]){if(r.has(i))throw new Error(`Duplicate interface or integration alias detected in plugin definition: '${i}'. Please use unique aliases for each interface and integration.`);r.add(i)}this.configuration=e.configuration?{...e.configuration,schema:typeof e.configuration.schema=="object"?e.configuration.schema:e.configuration.schema({entities:n})}:void 0,this.states=Object.fromEntries(Object.entries(e.states??{}).map(([i,s])=>[i,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:n})}])),this.events=Object.fromEntries(Object.entries(e.events??{}).map(([i,s])=>[i,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:n})}])),this.actions=Object.fromEntries(Object.entries(e.actions??{}).map(([i,s])=>[i,{...s,input:{...s.input,schema:typeof s.input.schema=="object"?s.input.schema:s.input.schema({entities:n})},output:{...s.output,schema:typeof s.output.schema=="object"?s.output.schema:s.output.schema({entities:n})}}])),this.tables=Object.fromEntries(Object.entries(e.tables??{}).map(([i,s])=>[i,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:n})}]))}name;version;title;description;icon;readme;attributes;integrations;interfaces;user;conversation;message;states;configuration;events;recurringEvents;actions;tables;workflows;__advanced;get metadata(){return{sdkVersion:Ce}}dereferenceEntities({intersectWithUnknownRecord:e}={intersectWithUnknownRecord:!0}){let n=this._buildZuiReferenceMap(e);return{...this,configuration:this.configuration?{...this.configuration,schema:this._dereferenceZuiSchema(this.configuration.schema,n)}:void 0,events:this._dereferenceDefinitionSchemas(this.events,n),states:this._dereferenceDefinitionSchemas(this.states,n),tables:this._dereferenceDefinitionSchemas(this.tables,n),actions:this._dereferenceActionDefinitionSchemas(this.actions,n)}}_buildZuiReferenceMap(e){return Object.fromEntries(Object.entries(this.interfaces??{}).flatMap(([n,r])=>Object.entries(r.definition.entities??{}).map(([i,s])=>[`interface:${n}/entities/${i}`,e?s.schema.and(y.record(y.string(),y.unknown())):s.schema])))}_dereferenceZuiSchema(e,n){return e.dereference(n)}_dereferenceDefinitionSchemas(e,n){return Object.fromEntries(Object.entries(e??{}).map(([r,i])=>[r,{...i,schema:this._dereferenceZuiSchema(i.schema,n)}]))}_dereferenceActionDefinitionSchemas(e,n){return Object.fromEntries(Object.entries(e??{}).map(([r,i])=>[r,{...i,input:{schema:this._dereferenceZuiSchema(i.input.schema,n)},output:{schema:this._dereferenceZuiSchema(i.output.schema,n)}}]))}};var fc=(t,e)=>new Proxy({},{get:(n,r)=>new Proxy({},{get:(i,s)=>a=>{let o=(e.integrations[r]??e.interfaces[r])?.integrationAlias,u=e.interfaces[r]?.actions?.[s]?.name??s;return t.callAction({type:`${o}:${u}`,input:a}).then(d=>d.output)}})});var ai=t=>({async getById({id:e}){let n=await t.client.getMessage({id:e});return pe({...t,message:n.message})},list(e){return ie(({nextToken:n})=>t.client.listMessages({...X(e??{},{alias:t.plugin?.alias}),nextToken:n}).then(({meta:r,messages:i})=>({meta:r,items:i.map(s=>pe({...t,message:s}))})))}}),pe=t=>({...he(t.message,{alias:t.plugin?.alias}),async delete(){await t.client.deleteMessage({id:t.message.id})},async update(e){let{message:n}=await t.client.updateMessage({...X(e,{alias:t.plugin?.alias}),id:t.message.id});return pe({...t,message:n})}});var oi=t=>({list(e){return ie(({nextToken:n})=>t.client.listUsers({...X(e??{},{alias:t.pluginAlias}),nextToken:n}).then(({meta:r,users:i})=>({meta:r,items:i.map(s=>ye({...t,conversationId:e?.conversationId,user:s}))})))},async getById({id:e}){let n=await t.client.getUser({id:e});return ye({...t,user:n.user,conversationId:void 0})}}),ye=t=>{let e={...he(t.user,{alias:t.pluginAlias}),async update(n){let{user:r}=await t.client.updateUser({...X(n,{alias:t.pluginAlias}),id:t.user.id});return ye({...t,user:r})}};return t.conversationId?{...e,async removeFromConversation(){return await t.client.removeParticipant({id:t.conversationId,userId:t.user.id}),ye({...t,conversationId:void 0})}}:{...e,async addToConversation({conversationId:n}){let{participant:r}=await t.client.addParticipant({id:n,userId:t.user.id});return ye({...t,user:r,conversationId:n})}}};var li=t=>new Proxy({},{get:(e,n)=>new Proxy({},{get:(r,i)=>({list(s){let a=t.plugin?.interfaces[n]?.integrationAlias??t.plugin?.integrations[n]?.integrationAlias,o=t.plugin?.interfaces[n]?.channels?.[i]?.name??i;return ie(({nextToken:u})=>t.client.listConversations({...X(s??{},{alias:t.plugin?.alias}),channel:o==="*"?void 0:o,integrationName:a==="*"?void 0:a,nextToken:u}).then(({meta:d,conversations:p})=>({meta:d,items:p.map(g=>pt({...t,conversation:g}))})))},async getById({id:s}){let a=await t.client.getConversation({id:s});return pt({...t,conversation:a.conversation})}})})}),pt=t=>{let e=t.client;return{...he(t.conversation,{alias:t.plugin?.alias}),async delete(){await e.deleteConversation({id:t.conversation.id})},async update(n){let{conversation:r}=await e.updateConversation({...X(n,{alias:t.plugin?.alias}),id:t.conversation.id});return pt({...t,conversation:r})},async getMessage({id:n}){let r=await e.getMessage({id:n});return pe({...t,message:r.message})},async getOrCreateMessage(n){let{message:r}=await e.getOrCreateMessage({...X(n,{alias:t.plugin?.alias}),conversationId:t.conversation.id});return pe({...t,message:r})},async createMessage(n){let{message:r}=await e.createMessage({...X(n,{alias:t.plugin?.alias}),conversationId:t.conversation.id});return pe({...t,message:r})},listMessages(n){return ie(({nextToken:r})=>e.listMessages({...X(n??{},{alias:t.plugin?.alias}),conversationId:t.conversation.id,nextToken:r}).then(({meta:i,messages:s})=>({meta:i,items:s.map(a=>pe({...t,message:a}))})))},listParticipants(){return ie(({nextToken:n})=>e.listParticipants({id:t.conversation.id,nextToken:n}).then(({meta:r,participants:i})=>({meta:r,items:i.map(s=>ye({...t,user:s,conversationId:t.conversation.id}))})))}}};var ui=class t{constructor(e){this._props=e}async emit(e){let{conversationId:n,userId:r,messageId:i}=this._props,{event:s}=await this._props.client.createEvent({type:this._props.eventName,payload:e,conversationId:n,userId:r,messageId:i});return s}async schedule(e,n){let{conversationId:r,userId:i,messageId:s}=this._props,{event:a}=await this._props.client.createEvent({type:this._props.eventName,payload:e,conversationId:r,userId:i,messageId:s,schedule:n});return a}withConversationId(e){return new t({...this._props,conversationId:e})}withUserId(e){return new t({...this._props,userId:e})}withMessageId(e){return new t({...this._props,messageId:e})}async getById(e){return(await this._props.client.getEvent({id:e.id})).event}list(e){return ie(({nextToken:n})=>this._props.client.listEvents({...e,type:this._props.eventName,conversationId:this._props.conversationId,userId:this._props.userId,messageId:this._props.messageId,nextToken:n}).then(({meta:r,events:i})=>({meta:r,items:i})))}},gc=(t,e)=>new Proxy({},{get:(n,r)=>{let i=e.alias!==void 0?`${e.alias}${de}${r}`:r;return new ui({client:t,eventName:i})}});var ci=class{constructor(e,n,r){this._client=e;this._stateType=n;this._stateName=r}async get(e){return await this._client.getState({type:this._stateType,name:this._stateName,id:e}).then(n=>n.state.payload)}async set(e,n,r){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:n,expiry:r?.expiryMs})}async getOrSet(e,n,r){return await this._client.getOrSetState({type:this._stateType,name:this._stateName,id:e,payload:n,expiry:r?.expiryMs}).then(i=>i.state.payload)}async delete(e){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:null})}async patch(e,n){await this._client.patchState({type:this._stateType,name:this._stateName,id:e,payload:n})}},mc=(t,e)=>new Proxy({},{get:(n,r)=>new Proxy({},{get:(i,s)=>{let a=e.alias!==void 0?`${e.alias}${de}${s}`:s;return new ci(t,r,a)}})});var Un=class{constructor(e){this.props=e;this._actionHandlers=e.actions}_runtimeProps;_actionHandlers;_messageHandlers={};_eventHandlers={};_stateExpiredHandlers={};_hookHandlers={before_incoming_event:{},before_incoming_message:{},before_outgoing_message:{},before_outgoing_call_action:{},before_incoming_call_action:{},after_incoming_event:{},after_incoming_message:{},after_outgoing_message:{},after_outgoing_call_action:{},after_incoming_call_action:{}};_workflowHandlers={started:{},continued:{},timed_out:{}};_registerOrder=0;initialize(e){return this._runtimeProps=e,this}get _runtime(){if(!this._runtimeProps)throw new Error("Plugin not correctly initialized. This is likely because you access your plugin config outside of an handler.");return this._runtimeProps}_getTools(e){let{configuration:n,interfaces:r,integrations:i,alias:s}=this._runtime,a=fc(e,this._runtime),o=mc(e,this._runtime),u=Se({client:e,pluginAlias:this._runtime.alias}),d=gc(e,this._runtime),p=oi({client:e,pluginAlias:this._runtime.alias}),g=li({client:e,plugin:this._runtime}),h=ai({client:e,plugin:this._runtime});return{configuration:n,interfaces:r,integrations:i,actions:a,states:o,alias:s,workflows:u,events:d,users:p,conversations:g,messages:h}}get actionHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=this._actionHandlers[n];if(r)return V.setName(i=>r({...i,...this._getTools(i.client)}),r.name)}})}get messageHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=n==="*"?[]:this._messageHandlers[n]??[],i=this._messageHandlers["*"]??[];return b.unique([...r,...i]).sort((a,o)=>a.order-o.order).map(({handler:a})=>V.setName(o=>a({...o,user:ye({...o,conversationId:o.conversation.id,pluginAlias:this._runtime.alias}),message:pe({...o,plugin:this._runtime,message:o.message}),conversation:pt({...o,plugin:this._runtime,conversation:o.conversation}),...this._getTools(o.client)}),a.name))}})}get eventHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=n==="*"?[]:this._eventHandlers[n]??[],i=Object.entries(this._eventHandlers).filter(([o])=>this._eventResolvesTo(o,n)).flatMap(([,o])=>o??[]),s=this._eventHandlers["*"]??[];return b.unique([...r,...i,...s]).sort((o,u)=>o.order-u.order).map(({handler:o})=>V.setName(u=>o({...u,...this._getTools(u.client)}),o.name))}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=n==="*"?[]:this._stateExpiredHandlers[n]??[],i=this._stateExpiredHandlers["*"]??[];return b.unique([...r,...i]).sort((a,o)=>a.order-o.order).map(({handler:a})=>V.setName(o=>a({...o,...this._getTools(o.client)}),a.name))}})}get hookHandlers(){return new Proxy({},{get:(e,n)=>{let r=this._hookHandlers[n];if(r)return new Proxy({},{get:(i,s)=>{s=this._stripAliasPrefix(s);let a=s==="*"?[]:r[s]??[],o=Object.entries(r).filter(([p])=>this._eventResolvesTo(p,s)).flatMap(([,p])=>p??[]),u=r["*"]??[];return b.unique([...a,...o,...u]).sort((p,g)=>p.order-g.order).map(({handler:p})=>V.setName(g=>p({...g,data:he(g.data,{alias:this._runtime.alias}),...this._getTools(g.client)}),p.name))}})}})}get workflowHandlers(){return new Proxy({},{get:(e,n)=>{let r=this._workflowHandlers[n];if(r)return new Proxy({},{get:(i,s)=>(r[s]?.sort((o,u)=>o.order-u.order)??[]).map(({handler:o})=>V.setName(async u=>{let d=u.workflow;return await o({...u,workflow:se({...u,workflow:d,onWorkflowUpdate(p){d=p},pluginAlias:this._runtime.alias}),...this._getTools(u.client)}),d},o.name))})}})}on={message:(e,n)=>{this._messageHandlers[e]=b.safePush(this._messageHandlers[e],{handler:n,order:this._registerOrder++})},event:(e,n)=>{this._eventHandlers[e]=b.safePush(this._eventHandlers[e],{handler:n,order:this._registerOrder++})},stateExpired:(e,n)=>{this._stateExpiredHandlers[e]=b.safePush(this._stateExpiredHandlers[e],{handler:n,order:this._registerOrder++})},beforeIncomingEvent:(e,n)=>{this._hookHandlers.before_incoming_event[e]=b.safePush(this._hookHandlers.before_incoming_event[e],{handler:n,order:this._registerOrder++})},beforeIncomingMessage:(e,n)=>{this._hookHandlers.before_incoming_message[e]=b.safePush(this._hookHandlers.before_incoming_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingMessage:(e,n)=>{this._hookHandlers.before_outgoing_message[e]=b.safePush(this._hookHandlers.before_outgoing_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingCallAction:(e,n)=>{this._hookHandlers.before_outgoing_call_action[e]=b.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},beforeIncomingCallAction:(e,n)=>{this._hookHandlers.before_incoming_call_action[e]=b.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingEvent:(e,n)=>{this._hookHandlers.after_incoming_event[e]=b.safePush(this._hookHandlers.after_incoming_event[e],{handler:n,order:this._registerOrder++})},afterIncomingMessage:(e,n)=>{this._hookHandlers.after_incoming_message[e]=b.safePush(this._hookHandlers.after_incoming_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingMessage:(e,n)=>{this._hookHandlers.after_outgoing_message[e]=b.safePush(this._hookHandlers.after_outgoing_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingCallAction:(e,n)=>{this._hookHandlers.after_outgoing_call_action[e]=b.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingCallAction:(e,n)=>{this._hookHandlers.after_incoming_call_action[e]=b.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:n,order:this._registerOrder++})},workflowStart:(e,n)=>{this._workflowHandlers.started[e]=b.safePush(this._workflowHandlers.started[e],{handler:n,order:this._registerOrder++})},workflowContinue:(e,n)=>{this._workflowHandlers.continued[e]=b.safePush(this._workflowHandlers.continued[e],{handler:n,order:this._registerOrder++})},workflowTimeout:(e,n)=>{this._workflowHandlers.timed_out[e]=b.safePush(this._workflowHandlers.timed_out[e],{handler:n,order:this._registerOrder++})}};_eventResolvesTo=(e,n)=>{let[i,s]=e.split(":");if(!i||!s)return!1;let a=this._runtime.interfaces[i];if(a&&n===`${a.integrationAlias}:${a?.events?.[s]?.name}`)return!0;let o=this._runtime.integrations[i];return!!(o&&n===`${o.integrationAlias}:${s}`)};_stripAliasPrefix=e=>{let{alias:n}=this._runtime;if(!n)return e;let r=`${n}#`;return e.startsWith(r)?e.slice(r.length):e}};var di={};et(di,{allWithinMajorOf:()=>iv,allWithinMinorOf:()=>sv});var Kt=Kn(require("semver"));function iv(t){let e=Kt.major(t.version);return{...t,version:`>=${e}.0.0 <${e+1}.0.0`}}function sv(t){let e=Kt.major(t.version),n=Kt.minor(t.version);return{...t,version:`>=${e}.${n}.0 <${e}.${n+1}.0`}}0&&(module.exports={Bot,BotDefinition,BotLogger,BotSpecificClient,Integration,IntegrationDefinition,IntegrationLogger,IntegrationSpecificClient,InterfaceDefinition,Plugin,PluginDefinition,RuntimeError,WELL_KNOWN_ATTRIBUTES,isApiError,messages,parseBody,serve,version,z});
75
+ Available integration aliases: ${p}`)}return[o,{...d,...u}]}));return r.plugins[i]={...e,alias:i,configuration:n.configuration??{},interfaces:s,integrations:a},r.withPlugins.user=this._mergeUser(r.withPlugins.user,e.definition.user),r.withPlugins.conversation=this._mergeConversation(r.withPlugins.conversation,e.definition.conversation),r.withPlugins.message=this._mergeMessage(r.withPlugins.message,e.definition.message),r.withPlugins.recurringEvents=this._mergeRecurringEvents(r.withPlugins.recurringEvents,e.definition.recurringEvents),r.withPlugins.tables=this._mergeTables(r.withPlugins.tables,e.definition.tables),r.withPlugins.workflows=this._mergeWorkflows(r.withPlugins.workflows,e.definition.workflows),r.withPlugins.states=this._mergeStates(r.withPlugins.states,this._prefixKeysWithPluginAlias(e.definition.states,i)),r.withPlugins.events=this._mergeEvents(r.withPlugins.events,this._prefixKeysWithPluginAlias(e.definition.events,i)),r.withPlugins.actions=this._mergeActions(r.withPlugins.actions,this._prefixKeysWithPluginAlias(e.definition.actions,i)),this}_mergeUser=(e,n)=>({tags:{...e?.tags,...n?.tags}});_mergeConversation=(e,n)=>({tags:{...e?.tags,...n?.tags}});_mergeMessage=(e,n)=>({tags:{...e?.tags,...n?.tags}});_mergeStates=(e,n)=>({...e,...n});_mergeEvents=(e,n)=>({...e,...n});_mergeRecurringEvents=(e,n)=>({...e,...n});_mergeActions=(e,n)=>({...e,...n});_mergeTables=(e,n)=>({...e,...n});_mergeWorkflows=(e,n)=>({...e,...n});_prefixKeysWithPluginAlias=(e,n)=>Z.mapKeys(e??{},r=>`${n}${pe}${r}`);dereferencePluginEntities(){let e=this._buildZuiReferenceMap();return{...this,withPlugins:{...this.withPlugins,events:this._dereferenceDefinitionSchemas(this.withPlugins.events,e),states:this._dereferenceDefinitionSchemas(this.withPlugins.states,e),tables:this._dereferenceDefinitionSchemas(this.withPlugins.tables,e),actions:this._dereferenceActionDefinitionSchemas(this.withPlugins.actions,e)},plugins:Object.fromEntries(Object.entries(this.plugins??{}).map(([n,r])=>[n,{...r,definition:{...r.definition,configuration:this._dereferenceDefinitionSchema(r.definition.configuration,e),events:this._dereferenceDefinitionSchemas(r.definition.events,e),states:this._dereferenceDefinitionSchemas(r.definition.states,e),tables:this._dereferenceDefinitionSchemas(r.definition.tables,e),actions:this._dereferenceActionDefinitionSchemas(r.definition.actions,e)}}]))}}_buildZuiReferenceMap(){let e={},n=Object.entries(this.plugins??{});for(let[r,i]of n){let s=Object.entries(i.interfaces??{});for(let[a,o]of s){let u=this.integrations?.[o.integrationAlias];if(!u)throw new te(`Interface with alias "${a}" of plugin with alias "${r}" references integration "${o.name}" which is not installed`);let d=Object.entries(o.entities??{});for(let[p,{name:g}]of d){let h=u.definition.entities?.[g]?.schema;if(!h)throw new Error(`Interface entity "${g}" does not exist in integration "${u.name}"`);e[`interface:${a}/entities/${p}`]=h}}}return e}_dereferenceZuiSchema(e,n){return e.dereference(n)}_dereferenceDefinitionSchemas(e,n){return Object.fromEntries(Object.entries(e??{}).map(([r,i])=>[r,this._dereferenceDefinitionSchema(i,n)]))}_dereferenceDefinitionSchema(e,n){return e&&{...e,schema:this._dereferenceZuiSchema(e.schema,n)}}_dereferenceActionDefinitionSchemas(e,n){return Object.fromEntries(Object.entries(e??{}).map(([r,i])=>[r,{...i,input:{schema:this._dereferenceZuiSchema(i.input.schema,n)},output:{schema:this._dereferenceZuiSchema(i.output.schema,n)}}]))}};var tt=require("@botpress/client");var pt=class t extends ct{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 he=class{constructor(e,n={before:{},after:{}}){this._client=e;this._hooks=n}get _inner(){return this._client}getConversation=(e=>this._run("getConversation",e));listConversations=(e=>this._run("listConversations",e));updateConversation=(e=>this._run("updateConversation",e));deleteConversation=(e=>this._run("deleteConversation",e));listParticipants=(e=>this._run("listParticipants",e));addParticipant=(e=>this._run("addParticipant",e));getParticipant=(e=>this._run("getParticipant",e));removeParticipant=(e=>this._run("removeParticipant",e));createEvent=(e=>this._run("createEvent",e));getEvent=(e=>this._run("getEvent",e));listEvents=(e=>this._run("listEvents",e));createMessage=(e=>this._run("createMessage",e));getMessage=(e=>this._run("getMessage",e));updateMessage=(e=>this._run("updateMessage",e));listMessages=(e=>this._run("listMessages",e));deleteMessage=(e=>this._run("deleteMessage",e));getUser=(e=>this._run("getUser",e));listUsers=(e=>this._run("listUsers",e));updateUser=(e=>this._run("updateUser",e));deleteUser=(e=>this._run("deleteUser",e));getState=(e=>this._run("getState",e));setState=(e=>this._run("setState",e));getOrSetState=(e=>this._run("getOrSetState",e));patchState=(e=>this._run("patchState",e));callAction=(e=>this._run("callAction",e));uploadFile=(e=>this._run("uploadFile",e));upsertFile=(e=>this._run("upsertFile",e));deleteFile=(e=>this._run("deleteFile",e));listFiles=(e=>this._run("listFiles",e));getFile=(e=>this._run("getFile",e));updateFileMetadata=(e=>this._run("updateFileMetadata",e));searchFiles=(e=>this._run("searchFiles",e));trackAnalytics=(e=>this._run("trackAnalytics",e));getTableRow=(e=>this._run("getTableRow",e));createTableRows=(e=>this._run("createTableRows",e));findTableRows=(e=>this._run("findTableRows",e));deleteTableRows=(e=>this._run("deleteTableRows",e));updateTableRows=(e=>this._run("updateTableRows",e));upsertTableRows=(e=>this._run("upsertTableRows",e));createWorkflow=(e=>this._run("createWorkflow",e));getOrCreateWorkflow=(e=>this._run("getOrCreateWorkflow",e));getWorkflow=(e=>this._run("getWorkflow",e));updateWorkflow=(e=>this._run("updateWorkflow",e));deleteWorkflow=(e=>this._run("deleteWorkflow",e));listWorkflows=(e=>this._run("listWorkflows",e));createConversation=e=>this._client.createConversation(e);getOrCreateConversation=e=>this._client.getOrCreateConversation(e);createUser=e=>this._client.createUser(e);getOrCreateUser=e=>this._client.getOrCreateUser(e);_run=async(e,n)=>{let r=this._hooks.before[e];r&&(n=await r(n));let i=await this._client[e](n),s=this._hooks.after[e];return s&&(i=await s(i,n)),i}};var Yy=y.enum(["event_received","register","unregister","ping","action_triggered"]),pc=t=>({botId:t[Rn]||ie("Missing bot id header"),operation:Yy.parse(t[Dn]),type:t[lc]||ie("Missing type header"),configuration:JSON.parse(Buffer.from(t[Nn]||ie("Missing configuration header"),"base64").toString("utf-8"))});var G={status:200};var ai=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 Xy=["child_workflow_deleted","child_workflow_finished","workflow_timedout","workflow_started","workflow_continued"],fc=async(t,e)=>{if(t.ctx.type!=="workflow_update"||!Xy.includes(e.payload.type))throw new Error("Unexpected event type");let n={...t,logger:Qy(t,e)};if(!e.payload.workflow.name)return n.logger.warn("Received workflow update event without a workflow name. Assuming this workflow was not defined by the bot.",e.payload.workflow),G;switch(e.payload.type){case"child_workflow_deleted":case"child_workflow_finished":n.logger.info(`Received child workflow event "${e.payload.type}", but child workflows are not yet supported`);break;case"workflow_timedout":case"workflow_started":case"workflow_continued":return await ev(n,e);default:e.payload.type}return G},Qy=(t,e)=>t.logger.with({eventId:e.id,workflowId:e.payload.workflow.id,conversationId:e.payload.conversation?.id,userId:e.payload.user?.id}),ev=async(t,e)=>{let n=ai(e.payload.type),r=t.self.workflowHandlers[n]?.[e.payload.workflow.name];if(!r||r.length===0)return t.logger.warn(`No ${n} handler found for workflow "${e.payload.workflow.name}"`),G;let{updatedWorkflow:i}=await tv(t,e);return i.status==="pending"&&t.logger.warn(`Workflow "${e.payload.workflow.name}" is still in pending status after processing "${n}" event. This may indicate that the workflow was not properly acknowledged or terminated by the handler. `),G},tv=async(t,e)=>{let n=ai(e.payload.type),r=t.self.workflowHandlers[n]?.[e.payload.workflow.name],i=structuredClone(e.payload.workflow);for(let s of r??[])i=await s({...t,event:e,conversation:e.payload.conversation,user:e.payload.user,workflow:i});return{updatedWorkflow:i}};var gc=t=>async e=>{let n=pc(e.headers),r=new pt,i=new tt.Client({botId:n.botId,retry:An}),s=new he(i,{before:{createMessage:async o=>{let u=t.hookHandlers.before_outgoing_message[o.type]??[];for(let d of u){let p=new he(i);o=(await d({client:p,ctx:n,logger:r.with({conversationId:o.conversationId,userId:o.userId}),data:o}))?.data??o}return o},callAction:async o=>{let u=t.hookHandlers.before_outgoing_call_action[o.type]??[];for(let d of u){let p=new he(i);o=(await d({client:p,ctx:n,logger:r,data:o}))?.data??o}return o}},after:{createMessage:async o=>{let u=t.hookHandlers.after_outgoing_message[o.message.type]??[];for(let d of u){let p=new he(i);o=(await d({client:p,ctx:n,logger:r.with({messageId:o.message.id,conversationId:o.message.conversationId,userId:o.message.userId}),data:o}))?.data??o}return o},callAction:async(o,u)=>{let{type:d}=u,p=t.hookHandlers.after_outgoing_call_action[d]??[];for(let g of p){let h=new he(i);o=(await g({client:h,ctx:n,logger:r,data:{type:d,...o}}))?.data??o}return o}}}),a={req:e,ctx:n,logger:r,client:s,self:t};try{switch(n.operation){case"action_triggered":return await av(a);case"event_received":return await sv(a);case"register":return await rv(a);case"unregister":return await iv(a);case"ping":return await nv(a);default:throw new Error(`Unknown operation ${n.operation}`)}}catch(o){let u=o instanceof Error?o:new Error(String(o));if((0,tt.isApiError)(u)){let p=u.type==="Runtime"?u:new tt.RuntimeError(u.message,u);return r.error(p.message),{status:p.code,body:JSON.stringify(p.toJSON())}}let d=new tt.RuntimeError("An unexpected error occurred in the bot.",u);return r.error(d.message,u),{status:d.code,body:JSON.stringify(d.toJSON())}}},nv=async t=>G,rv=async t=>(await t.self.registerHandler?.({client:t.client,ctx:t.ctx,logger:t.logger}),G),iv=async t=>G,sv=async t=>{let{ctx:e,logger:n,req:r,client:i,self:s}=t,a={client:i,ctx:e,logger:n},o=re(r);if(a.logger=a.logger.with({eventId:o.event.id,messageId:o.event.messageId,conversationId:o.event.conversationId,userId:o.event.userId}),e.type==="workflow_update")return await fc(t,o.event);if(e.type==="message_created"){let w=o.event,T=w.payload.message;a.logger=a.logger.with({messageId:T.id,conversationId:T.conversationId,userId:T.userId});let D=s.hookHandlers.before_incoming_message[T.type]??[];for(let le of D){let H=await le({...a,data:T});if(T=H?.data??T,H?.stop)return G}let F={...a,user:w.payload.user,conversation:w.payload.conversation,message:T,event:w},J=s.messageHandlers[T.type]??[];for(let le of J)await le(F);let oe=s.hookHandlers.after_incoming_message[T.type]??[];for(let le of oe){let H=await le({...a,data:T});if(T=H?.data??T,H?.stop)return G}return G}if(e.type==="state_expired"){let T=o.event.payload.state,D={...a,state:T},F=s.stateExpiredHandlers[T.name]??[];for(let J of F)await J(D);return G}let u=o.event,d=s.hookHandlers.before_incoming_event[u.type]??[];for(let w of d){let T=await w({...a,data:u});if(u=T?.data??u,T?.stop)return G}let p={...a,event:u},g=s.eventHandlers[u.type]??[];for(let w of g)await w(p);let h=s.hookHandlers.after_incoming_event[u.type]??[];for(let w of h){let T=await w({...a,data:u});if(u=T?.data??u,T?.stop)return G}return G},av=async({ctx:t,logger:e,req:n,client:r,self:i})=>{let{input:s,type:a}=re(n);if(!a)throw new Error("Missing action type");let o=i.hookHandlers.before_incoming_call_action[a]??[];for(let h of o){let w=await h({ctx:t,logger:e,client:r,data:{type:a,input:s}});s=w?.data?.input??s,a=w?.data?.type??a}let u=i.actionHandlers[a];if(!u)throw new Error(`Action ${a} not found`);let d=await u({ctx:t,logger:e,input:s,client:r,type:a}),p=i.hookHandlers.after_incoming_call_action[a]??[];for(let h of p){let w=await h({ctx:t,logger:e,client:r,data:{type:a,output:d}});a=w?.data?.type??a,d=w?.data?.output??d}return{status:200,body:JSON.stringify({output:d})}};var ye=(t,{alias:e})=>{if(!("tags"in t)||!e)return t;let n=`${e}${pe}`,r=Object.fromEntries(Object.entries(t.tags??{}).flatMap(([i,s])=>i.startsWith(n)?[[i.slice(n.length),s]]:[]));return{...t,tags:r}},X=(t,{alias:e})=>{if(!("tags"in t)||!e)return t;let n=`${e}${pe}`,r=Object.fromEntries(Object.entries(t.tags??{}).map(([i,s])=>[i.startsWith(n)?i:`${n}${i}`,s]));return{...t,tags:r}};var oi=class{constructor(e){this._list=e}_nextToken;_elementsBuffer=[];_isExhausted=!1;[Symbol.asyncIterator](){return this}async next(){return this._bufferIsEmpty&&!this._isExhausted&&await this._fetchNextPageIntoBuffer(),this._bufferIsEmpty?{done:!0,value:void 0}:{done:!1,value:this._elementsBuffer.shift()}}async take(e){let n=[];for(let r=0;r<e;++r){let i=await this.next();if(i.done)break;n.push(i.value)}return n}async takePage(e){for(let r=0;r<e;++r)this._isExhausted||await this._fetchNextPageIntoBuffer();let n=[...this._elementsBuffer];return this._elementsBuffer.length=0,n}async takeAll(){return this.take(Number.POSITIVE_INFINITY)}get isExhausted(){return this._isExhausted}async _fetchNextPageIntoBuffer(){let{items:e,meta:n}=await this._list({nextToken:this._nextToken});this._elementsBuffer.push(...e),this._nextToken=n.nextToken,n.nextToken||(this._isExhausted=!0)}get _bufferIsEmpty(){return this._elementsBuffer.length===0}},se=t=>new oi(t);var Oe=t=>new Proxy({},{get:(e,n)=>({listInstances:r=>se(({nextToken:i})=>t.client.listWorkflows({...r,name:n,nextToken:i}).then(({meta:s,workflows:a})=>({meta:s,items:a.map(o=>ae({...t,workflow:o}))}))),startNewInstance:async r=>{let{workflow:i}=await t.client.createWorkflow({name:n,status:"pending",...X(r,{alias:void 0})});return{workflow:ae({...t,workflow:i})}}})}),ae=t=>{let e=!1;return{...ye(t.workflow,{alias:void 0}),async update(n){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,...X(n,{alias:void 0})});return await t.onWorkflowUpdate?.(r),{workflow:ae({...t,workflow:r})}},async acknowledgeStartOfProcessing(){if(!t.event||t.workflow.status!=="pending"||e)return{workflow:ae(t)};let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,status:"in_progress",eventId:t.event.id});return e=!0,await t.onWorkflowUpdate?.(n),{workflow:ae({...t,workflow:n})}},async setFailed({failureReason:n}){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,status:"failed",failureReason:n});return await t.onWorkflowUpdate?.(r),{workflow:ae({...t,workflow:r})}},async setCompleted({output:n}={}){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,status:"completed",output:n});return await t.onWorkflowUpdate?.(r),{workflow:ae({...t,workflow:r})}},async cancel(){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,status:"cancelled"});return await t.onWorkflowUpdate?.(n),{workflow:ae({...t,workflow:n})}}}};var jn=class{constructor(e){this.props=e;this._registerHandler=e.register,this._actionHandlers=e.actions,this._plugins=e.plugins}_registerHandler;_actionHandlers;_messageHandlers={};_eventHandlers={};_stateExpiredHandlers={};_hookHandlers={before_incoming_event:{},before_incoming_message:{},before_outgoing_message:{},before_outgoing_call_action:{},before_incoming_call_action:{},after_incoming_event:{},after_incoming_message:{},after_outgoing_message:{},after_outgoing_call_action:{},after_incoming_call_action:{}};_workflowHandlers={started:{},continued:{},timed_out:{}};_plugins={};_registerOrder=0;get registerHandler(){return this._registerHandler}get actionHandlers(){return new Proxy({},{get:(e,n)=>{let r=this._actionHandlers[n];if(r)return V.setName(i=>r({...i,workflows:Oe(i)}),r.name);for(let[i,s]of Object.entries(this._plugins)){let[a,o]=n.split(pe);if(!(a!==i||!o))return s.actionHandlers[o]}}})}get messageHandlers(){return new Proxy({},{get:(e,n)=>{let r=Object.values(this._plugins).flatMap(o=>o.messageHandlers[n]??[]),i=n==="*"?[]:this._messageHandlers[n]??[],s=this._messageHandlers["*"]??[],a=[...i,...s].sort((o,u)=>o.order-u.order).map(({handler:o})=>V.setName(u=>o({...u,workflows:Oe(u)}),o.name));return b.unique([...r,...a])}})}get eventHandlers(){return new Proxy({},{get:(e,n)=>{let r=Object.values(this._plugins).flatMap(o=>o.eventHandlers[n]??[]),i=n==="*"?[]:this._eventHandlers[n]??[],s=this._eventHandlers["*"]??[],a=[...i,...s].sort((o,u)=>o.order-u.order).map(({handler:o})=>V.setName(u=>o({...u,workflows:Oe(u)}),o.name));return b.unique([...r,...a])}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,n)=>{let r=Object.values(this._plugins).flatMap(o=>o.stateExpiredHandlers[n]??[]),i=n==="*"?[]:this._stateExpiredHandlers[n]??[],s=this._stateExpiredHandlers["*"]??[],a=[...i,...s].sort((o,u)=>o.order-u.order).map(({handler:o})=>V.setName(u=>o({...u,workflows:Oe(u)}),o.name));return b.unique([...r,...a])}})}get hookHandlers(){return new Proxy({},{get:(e,n)=>{if(this._hookHandlers[n])return new Proxy({},{get:(i,s)=>{let a=Object.values(this._plugins).flatMap(g=>g.hookHandlers[n]?.[s]??[]),o=this._hookHandlers[n]??{},u=s==="*"?[]:o[s]??[],d=o["*"]??[],p=[...u,...d].sort((g,h)=>g.order-h.order).map(({handler:g})=>V.setName(h=>g({...h,workflows:Oe(h)}),g.name));return b.unique([...a,...p])}})}})}get workflowHandlers(){return new Proxy({},{get:(e,n)=>{let r=this._workflowHandlers[n];if(r)return new Proxy({},{get:(i,s)=>{let a=r[s]?.sort((u,d)=>u.order-d.order).map(({handler:u})=>V.setName(async d=>{let p=d.workflow;return await u({...d,workflow:ae({...d,onWorkflowUpdate(g){p=g}}),workflows:Oe(d)}),p},u.name))??[],o=Object.values(this._plugins).flatMap(u=>u.workflowHandlers[n]?.[s]??[]);return b.unique([...a,...o])}})}})}on={message:(e,n)=>{this._messageHandlers[e]=b.safePush(this._messageHandlers[e],{handler:n,order:this._registerOrder++})},event:(e,n)=>{this._eventHandlers[e]=b.safePush(this._eventHandlers[e],{handler:n,order:this._registerOrder++})},stateExpired:(e,n)=>{this._stateExpiredHandlers[e]=b.safePush(this._stateExpiredHandlers[e],{handler:n,order:this._registerOrder++})},beforeIncomingEvent:(e,n)=>{this._hookHandlers.before_incoming_event[e]=b.safePush(this._hookHandlers.before_incoming_event[e],{handler:n,order:this._registerOrder++})},beforeIncomingMessage:(e,n)=>{this._hookHandlers.before_incoming_message[e]=b.safePush(this._hookHandlers.before_incoming_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingMessage:(e,n)=>{this._hookHandlers.before_outgoing_message[e]=b.safePush(this._hookHandlers.before_outgoing_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingCallAction:(e,n)=>{this._hookHandlers.before_outgoing_call_action[e]=b.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},beforeIncomingCallAction:(e,n)=>{this._hookHandlers.before_incoming_call_action[e]=b.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingEvent:(e,n)=>{this._hookHandlers.after_incoming_event[e]=b.safePush(this._hookHandlers.after_incoming_event[e],{handler:n,order:this._registerOrder++})},afterIncomingMessage:(e,n)=>{this._hookHandlers.after_incoming_message[e]=b.safePush(this._hookHandlers.after_incoming_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingMessage:(e,n)=>{this._hookHandlers.after_outgoing_message[e]=b.safePush(this._hookHandlers.after_outgoing_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingCallAction:(e,n)=>{this._hookHandlers.after_outgoing_call_action[e]=b.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingCallAction:(e,n)=>{this._hookHandlers.after_incoming_call_action[e]=b.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:n,order:this._registerOrder++})},workflowStart:(e,n)=>{this._workflowHandlers.started[e]=b.safePush(this._workflowHandlers.started[e],{handler:n,order:this._registerOrder++})},workflowContinue:(e,n)=>{this._workflowHandlers.continued[e]=b.safePush(this._workflowHandlers.continued[e],{handler:n,order:this._registerOrder++})},workflowTimeout:(e,n)=>{this._workflowHandlers.timed_out[e]=b.safePush(this._workflowHandlers.timed_out[e],{handler:n,order:this._registerOrder++})}};handler=gc(this);start=e=>Kt(this.handler,e)};var $n=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.title=e.title,this.description=e.description,this.readme=e.readme,this.entities=e.entities??{},this.attributes=e.attributes,this.__advanced=e.__advanced;let n=this._getEntityReference(this.entities),r=e.events===void 0?{}:Z.mapValues(e.events,a=>({...a,schema:a.schema(n)})),i=e.actions===void 0?{}:Z.mapValues(e.actions,a=>({...a,input:{...a.input,schema:a.input.schema(n)},output:{...a.output,schema:a.output.schema(n)}})),s=e.channels===void 0?{}:Z.mapValues(e.channels,a=>({...a,messages:Z.mapValues(a.messages,o=>({...o,schema:o.schema(n)}))}));this.events=r,this.actions=i,this.channels=s}name;version;title;description;icon;readme;attributes;entities;events;actions;channels;__advanced;get metadata(){return{sdkVersion:Ae}}_getEntityReference=e=>{let n={};for(let[r,i]of Object.entries(e)){let s=i.schema._def["x-zui"]?.title,a=i.schema._def.description,o=y.ref(r);s&&o.title(s),a&&o.describe(a),n[r]=o}return n}};var Un=class{constructor(e){this.props=e;let n=Object.fromEntries(Object.entries(e.interfaces??{}).map(([i,s])=>[i,Object.fromEntries(Object.entries(s.definition.entities??{}).map(([a])=>[a,y.ref(`interface:${i}/entities/${a}`)]))]));this.name=e.name,this.version=e.version,this.icon=e.icon,this.readme=e.readme,this.title=e.title,this.description=e.description,this.integrations=e.integrations,this.interfaces=e.interfaces,this.user=e.user,this.conversation=e.conversation,this.message=e.message,this.recurringEvents=e.recurringEvents,this.workflows=e.workflows,this.attributes=e.attributes,this.__advanced=e.__advanced;let r=new Set;for(let i of[...Object.keys(e.integrations??{}),...Object.keys(e.interfaces??{})]){if(r.has(i))throw new te(`Duplicate interface or integration alias detected in plugin definition: '${i}'. Please use unique aliases for each interface and integration.`);r.add(i)}this.configuration=e.configuration?{...e.configuration,schema:typeof e.configuration.schema=="object"?e.configuration.schema:e.configuration.schema({entities:n})}:void 0,this.states=Object.fromEntries(Object.entries(e.states??{}).map(([i,s])=>[i,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:n})}])),this.events=Object.fromEntries(Object.entries(e.events??{}).map(([i,s])=>[i,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:n})}])),this.actions=Object.fromEntries(Object.entries(e.actions??{}).map(([i,s])=>[i,{...s,input:{...s.input,schema:typeof s.input.schema=="object"?s.input.schema:s.input.schema({entities:n})},output:{...s.output,schema:typeof s.output.schema=="object"?s.output.schema:s.output.schema({entities:n})}}])),this.tables=Object.fromEntries(Object.entries(e.tables??{}).map(([i,s])=>[i,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:n})}]))}name;version;title;description;icon;readme;attributes;integrations;interfaces;user;conversation;message;states;configuration;events;recurringEvents;actions;tables;workflows;__advanced;get metadata(){return{sdkVersion:Ae}}dereferenceEntities({intersectWithUnknownRecord:e}={intersectWithUnknownRecord:!0}){let n=this._buildZuiReferenceMap(e);return{...this,configuration:this.configuration?{...this.configuration,schema:this._dereferenceZuiSchema(this.configuration.schema,n)}:void 0,events:this._dereferenceDefinitionSchemas(this.events,n),states:this._dereferenceDefinitionSchemas(this.states,n),tables:this._dereferenceDefinitionSchemas(this.tables,n),actions:this._dereferenceActionDefinitionSchemas(this.actions,n)}}_buildZuiReferenceMap(e){return Object.fromEntries(Object.entries(this.interfaces??{}).flatMap(([n,r])=>Object.entries(r.definition.entities??{}).map(([i,s])=>[`interface:${n}/entities/${i}`,e?s.schema.and(y.record(y.string(),y.unknown())):s.schema])))}_dereferenceZuiSchema(e,n){return e.dereference(n)}_dereferenceDefinitionSchemas(e,n){return Object.fromEntries(Object.entries(e??{}).map(([r,i])=>[r,{...i,schema:this._dereferenceZuiSchema(i.schema,n)}]))}_dereferenceActionDefinitionSchemas(e,n){return Object.fromEntries(Object.entries(e??{}).map(([r,i])=>[r,{...i,input:{schema:this._dereferenceZuiSchema(i.input.schema,n)},output:{schema:this._dereferenceZuiSchema(i.output.schema,n)}}]))}};var mc=(t,e)=>new Proxy({},{get:(n,r)=>new Proxy({},{get:(i,s)=>a=>{let o=(e.integrations[r]??e.interfaces[r])?.integrationAlias,u=e.interfaces[r]?.actions?.[s]?.name??s;return t.callAction({type:`${o}:${u}`,input:a}).then(d=>d.output)}})});var li=t=>({async getById({id:e}){let n=await t.client.getMessage({id:e});return fe({...t,message:n.message})},list(e){return se(({nextToken:n})=>t.client.listMessages({...X(e??{},{alias:t.plugin?.alias}),nextToken:n}).then(({meta:r,messages:i})=>({meta:r,items:i.map(s=>fe({...t,message:s}))})))}}),fe=t=>({...ye(t.message,{alias:t.plugin?.alias}),async delete(){await t.client.deleteMessage({id:t.message.id})},async update(e){let{message:n}=await t.client.updateMessage({...X(e,{alias:t.plugin?.alias}),id:t.message.id});return fe({...t,message:n})}});var ui=t=>({list(e){return se(({nextToken:n})=>t.client.listUsers({...X(e??{},{alias:t.pluginAlias}),nextToken:n}).then(({meta:r,users:i})=>({meta:r,items:i.map(s=>ve({...t,conversationId:e?.conversationId,user:s}))})))},async getById({id:e}){let n=await t.client.getUser({id:e});return ve({...t,user:n.user,conversationId:void 0})}}),ve=t=>{let e={...ye(t.user,{alias:t.pluginAlias}),async update(n){let{user:r}=await t.client.updateUser({...X(n,{alias:t.pluginAlias}),id:t.user.id});return ve({...t,user:r})}};return t.conversationId?{...e,async removeFromConversation(){return await t.client.removeParticipant({id:t.conversationId,userId:t.user.id}),ve({...t,conversationId:void 0})}}:{...e,async addToConversation({conversationId:n}){let{participant:r}=await t.client.addParticipant({id:n,userId:t.user.id});return ve({...t,user:r,conversationId:n})}}};var ci=t=>new Proxy({},{get:(e,n)=>new Proxy({},{get:(r,i)=>({list(s){let a=t.plugin?.interfaces[n]?.integrationAlias??t.plugin?.integrations[n]?.integrationAlias,o=t.plugin?.interfaces[n]?.channels?.[i]?.name??i;return se(({nextToken:u})=>t.client.listConversations({...X(s??{},{alias:t.plugin?.alias}),channel:o==="*"?void 0:o,integrationName:a==="*"?void 0:a,nextToken:u}).then(({meta:d,conversations:p})=>({meta:d,items:p.map(g=>ft({...t,conversation:g}))})))},async getById({id:s}){let a=await t.client.getConversation({id:s});return ft({...t,conversation:a.conversation})}})})}),ft=t=>{let e=t.client;return{...ye(t.conversation,{alias:t.plugin?.alias}),async delete(){await e.deleteConversation({id:t.conversation.id})},async update(n){let{conversation:r}=await e.updateConversation({...X(n,{alias:t.plugin?.alias}),id:t.conversation.id});return ft({...t,conversation:r})},async getMessage({id:n}){let r=await e.getMessage({id:n});return fe({...t,message:r.message})},async getOrCreateMessage(n){let{message:r}=await e.getOrCreateMessage({...X(n,{alias:t.plugin?.alias}),conversationId:t.conversation.id});return fe({...t,message:r})},async createMessage(n){let{message:r}=await e.createMessage({...X(n,{alias:t.plugin?.alias}),conversationId:t.conversation.id});return fe({...t,message:r})},listMessages(n){return se(({nextToken:r})=>e.listMessages({...X(n??{},{alias:t.plugin?.alias}),conversationId:t.conversation.id,nextToken:r}).then(({meta:i,messages:s})=>({meta:i,items:s.map(a=>fe({...t,message:a}))})))},listParticipants(){return se(({nextToken:n})=>e.listParticipants({id:t.conversation.id,nextToken:n}).then(({meta:r,participants:i})=>({meta:r,items:i.map(s=>ve({...t,user:s,conversationId:t.conversation.id}))})))}}};var di=class t{constructor(e){this._props=e}async emit(e){let{conversationId:n,userId:r,messageId:i}=this._props,{event:s}=await this._props.client.createEvent({type:this._props.eventName,payload:e,conversationId:n,userId:r,messageId:i});return s}async schedule(e,n){let{conversationId:r,userId:i,messageId:s}=this._props,{event:a}=await this._props.client.createEvent({type:this._props.eventName,payload:e,conversationId:r,userId:i,messageId:s,schedule:n});return a}withConversationId(e){return new t({...this._props,conversationId:e})}withUserId(e){return new t({...this._props,userId:e})}withMessageId(e){return new t({...this._props,messageId:e})}async getById(e){return(await this._props.client.getEvent({id:e.id})).event}list(e){return se(({nextToken:n})=>this._props.client.listEvents({...e,type:this._props.eventName,conversationId:this._props.conversationId,userId:this._props.userId,messageId:this._props.messageId,nextToken:n}).then(({meta:r,events:i})=>({meta:r,items:i})))}},hc=(t,e)=>new Proxy({},{get:(n,r)=>{let i=e.alias!==void 0?`${e.alias}${pe}${r}`:r;return new di({client:t,eventName:i})}});var pi=class{constructor(e,n,r){this._client=e;this._stateType=n;this._stateName=r}async get(e){return await this._client.getState({type:this._stateType,name:this._stateName,id:e}).then(n=>n.state.payload)}async set(e,n,r){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:n,expiry:r?.expiryMs})}async getOrSet(e,n,r){return await this._client.getOrSetState({type:this._stateType,name:this._stateName,id:e,payload:n,expiry:r?.expiryMs}).then(i=>i.state.payload)}async delete(e){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:null})}async patch(e,n){await this._client.patchState({type:this._stateType,name:this._stateName,id:e,payload:n})}},yc=(t,e)=>new Proxy({},{get:(n,r)=>new Proxy({},{get:(i,s)=>{let a=e.alias!==void 0?`${e.alias}${pe}${s}`:s;return new pi(t,r,a)}})});var zn=class{constructor(e){this.props=e;this._actionHandlers=e.actions}_runtimeProps;_actionHandlers;_messageHandlers={};_eventHandlers={};_stateExpiredHandlers={};_hookHandlers={before_incoming_event:{},before_incoming_message:{},before_outgoing_message:{},before_outgoing_call_action:{},before_incoming_call_action:{},after_incoming_event:{},after_incoming_message:{},after_outgoing_message:{},after_outgoing_call_action:{},after_incoming_call_action:{}};_workflowHandlers={started:{},continued:{},timed_out:{}};_registerOrder=0;initialize(e){return this._runtimeProps=e,this}get _runtime(){if(!this._runtimeProps)throw new Error("Plugin not correctly initialized. This is likely because you access your plugin config outside of an handler.");return this._runtimeProps}_getTools(e){let{configuration:n,interfaces:r,integrations:i,alias:s}=this._runtime,a=mc(e,this._runtime),o=yc(e,this._runtime),u=Oe({client:e,pluginAlias:this._runtime.alias}),d=hc(e,this._runtime),p=ui({client:e,pluginAlias:this._runtime.alias}),g=ci({client:e,plugin:this._runtime}),h=li({client:e,plugin:this._runtime});return{configuration:n,interfaces:r,integrations:i,actions:a,states:o,alias:s,workflows:u,events:d,users:p,conversations:g,messages:h}}get actionHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=this._actionHandlers[n];if(r)return V.setName(i=>r({...i,...this._getTools(i.client)}),r.name)}})}get messageHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=n==="*"?[]:this._messageHandlers[n]??[],i=this._messageHandlers["*"]??[];return b.unique([...r,...i]).sort((a,o)=>a.order-o.order).map(({handler:a})=>V.setName(o=>a({...o,user:ve({...o,conversationId:o.conversation.id,pluginAlias:this._runtime.alias}),message:fe({...o,plugin:this._runtime,message:o.message}),conversation:ft({...o,plugin:this._runtime,conversation:o.conversation}),...this._getTools(o.client)}),a.name))}})}get eventHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=n==="*"?[]:this._eventHandlers[n]??[],i=Object.entries(this._eventHandlers).filter(([o])=>this._eventResolvesTo(o,n)).flatMap(([,o])=>o??[]),s=this._eventHandlers["*"]??[];return b.unique([...r,...i,...s]).sort((o,u)=>o.order-u.order).map(({handler:o})=>V.setName(u=>o({...u,...this._getTools(u.client)}),o.name))}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=n==="*"?[]:this._stateExpiredHandlers[n]??[],i=this._stateExpiredHandlers["*"]??[];return b.unique([...r,...i]).sort((a,o)=>a.order-o.order).map(({handler:a})=>V.setName(o=>a({...o,...this._getTools(o.client)}),a.name))}})}get hookHandlers(){return new Proxy({},{get:(e,n)=>{let r=this._hookHandlers[n];if(r)return new Proxy({},{get:(i,s)=>{s=this._stripAliasPrefix(s);let a=s==="*"?[]:r[s]??[],o=Object.entries(r).filter(([p])=>this._eventResolvesTo(p,s)).flatMap(([,p])=>p??[]),u=r["*"]??[];return b.unique([...a,...o,...u]).sort((p,g)=>p.order-g.order).map(({handler:p})=>V.setName(g=>p({...g,data:ye(g.data,{alias:this._runtime.alias}),...this._getTools(g.client)}),p.name))}})}})}get workflowHandlers(){return new Proxy({},{get:(e,n)=>{let r=this._workflowHandlers[n];if(r)return new Proxy({},{get:(i,s)=>(r[s]?.sort((o,u)=>o.order-u.order)??[]).map(({handler:o})=>V.setName(async u=>{let d=u.workflow;return await o({...u,workflow:ae({...u,workflow:d,onWorkflowUpdate(p){d=p},pluginAlias:this._runtime.alias}),...this._getTools(u.client)}),d},o.name))})}})}on={message:(e,n)=>{this._messageHandlers[e]=b.safePush(this._messageHandlers[e],{handler:n,order:this._registerOrder++})},event:(e,n)=>{this._eventHandlers[e]=b.safePush(this._eventHandlers[e],{handler:n,order:this._registerOrder++})},stateExpired:(e,n)=>{this._stateExpiredHandlers[e]=b.safePush(this._stateExpiredHandlers[e],{handler:n,order:this._registerOrder++})},beforeIncomingEvent:(e,n)=>{this._hookHandlers.before_incoming_event[e]=b.safePush(this._hookHandlers.before_incoming_event[e],{handler:n,order:this._registerOrder++})},beforeIncomingMessage:(e,n)=>{this._hookHandlers.before_incoming_message[e]=b.safePush(this._hookHandlers.before_incoming_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingMessage:(e,n)=>{this._hookHandlers.before_outgoing_message[e]=b.safePush(this._hookHandlers.before_outgoing_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingCallAction:(e,n)=>{this._hookHandlers.before_outgoing_call_action[e]=b.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},beforeIncomingCallAction:(e,n)=>{this._hookHandlers.before_incoming_call_action[e]=b.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingEvent:(e,n)=>{this._hookHandlers.after_incoming_event[e]=b.safePush(this._hookHandlers.after_incoming_event[e],{handler:n,order:this._registerOrder++})},afterIncomingMessage:(e,n)=>{this._hookHandlers.after_incoming_message[e]=b.safePush(this._hookHandlers.after_incoming_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingMessage:(e,n)=>{this._hookHandlers.after_outgoing_message[e]=b.safePush(this._hookHandlers.after_outgoing_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingCallAction:(e,n)=>{this._hookHandlers.after_outgoing_call_action[e]=b.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingCallAction:(e,n)=>{this._hookHandlers.after_incoming_call_action[e]=b.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:n,order:this._registerOrder++})},workflowStart:(e,n)=>{this._workflowHandlers.started[e]=b.safePush(this._workflowHandlers.started[e],{handler:n,order:this._registerOrder++})},workflowContinue:(e,n)=>{this._workflowHandlers.continued[e]=b.safePush(this._workflowHandlers.continued[e],{handler:n,order:this._registerOrder++})},workflowTimeout:(e,n)=>{this._workflowHandlers.timed_out[e]=b.safePush(this._workflowHandlers.timed_out[e],{handler:n,order:this._registerOrder++})}};_eventResolvesTo=(e,n)=>{let[i,s]=e.split(":");if(!i||!s)return!1;let a=this._runtime.interfaces[i];if(a&&n===`${a.integrationAlias}:${a?.events?.[s]?.name}`)return!0;let o=this._runtime.integrations[i];return!!(o&&n===`${o.integrationAlias}:${s}`)};_stripAliasPrefix=e=>{let{alias:n}=this._runtime;if(!n)return e;let r=`${n}#`;return e.startsWith(r)?e.slice(r.length):e}};var fi={};Ze(fi,{allWithinMajorOf:()=>ov,allWithinMinorOf:()=>lv});var Wt=Wn(require("semver"));function ov(t){let e=Wt.major(t.version);return{...t,version:`>=${e}.0.0 <${e+1}.0.0`}}function lv(t){let e=Wt.major(t.version),n=Wt.minor(t.version);return{...t,version:`>=${e}.${n}.0 <${e}.${n+1}.0`}}0&&(module.exports={Bot,BotDefinition,BotLogger,BotSpecificClient,Integration,IntegrationDefinition,IntegrationLogger,IntegrationSpecificClient,InterfaceDefinition,Plugin,PluginDefinition,RuntimeError,WELL_KNOWN_ATTRIBUTES,errors,isApiError,messages,parseBody,serve,version,z});
76
76
  /*! Bundled license information:
77
77
 
78
78
  lodash-es/lodash.js: