@botpress/sdk 6.11.2 → 6.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +5 -5
- package/dist/bot/definition.d.ts +5 -0
- package/dist/common/recurring-events.d.ts +9 -0
- package/dist/common/recurring-events.test.d.ts +1 -0
- package/dist/index.cjs +15 -15
- package/dist/index.cjs.map +4 -4
- package/dist/index.mjs +20 -20
- package/dist/index.mjs.map +4 -4
- package/dist/plugin/definition.d.ts +1 -0
- package/dist/plugin/definition.test.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Pc=Object.create;var Jt=Object.defineProperty;var Sc=Object.getOwnPropertyDescriptor;var kc=Object.getOwnPropertyNames;var Ic=Object.getPrototypeOf,Oc=Object.prototype.hasOwnProperty;var Ne=(t,e)=>{for(var n in e)Jt(t,n,{get:e[n],enumerable:!0})},vi=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of kc(e))!Oc.call(t,i)&&i!==n&&Jt(t,i,{get:()=>e[i],enumerable:!(r=Sc(e,i))||r.enumerable});return t};var Gn=(t,e,n)=>(n=t!=null?Pc(Ic(t)):{},vi(e||!t||!t.__esModule?Jt(n,"default",{value:t,enumerable:!0}):n,t)),Ec=t=>vi(Jt({},"__esModule",{value:!0}),t);var pv={};Ne(pv,{Bot:()=>Wn,BotDefinition:()=>Kn,BotLogger:()=>yt,BotSpecificClient:()=>Te,Integration:()=>zn,IntegrationDefinition:()=>Dn,IntegrationLogger:()=>mt,IntegrationSpecificClient:()=>ft,InterfaceDefinition:()=>Ln,OAUTH_IDENTIFIER_HEADER:()=>bh,Plugin:()=>qn,PluginDefinition:()=>Fn,RuntimeError:()=>Vn.RuntimeError,WELL_KNOWN_ATTRIBUTES:()=>Th,errors:()=>li,isApiError:()=>Vn.isApiError,messages:()=>ai,parseBody:()=>oe,serve:()=>Vt,version:()=>hi,z:()=>v});module.exports=Ec(pv);var ai={};Ne(ai,{defaults:()=>_h,markdown:()=>hh,markdownBloc:()=>vh});var br=Object.defineProperty,Bc=Object.defineProperties,Cc=Object.getOwnPropertyDescriptors,cn=Object.getOwnPropertySymbols,ts=Object.prototype.hasOwnProperty,ns=Object.prototype.propertyIsEnumerable,_i=(t,e,n)=>e in t?br(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,c=(t,e)=>{for(var n in e||(e={}))ts.call(e,n)&&_i(t,n,e[n]);if(cn)for(var n of cn(e))ns.call(e,n)&&_i(t,n,e[n]);return t},f=(t,e)=>Bc(t,Cc(e)),l=(t,e)=>br(t,"name",{value:e,configurable:!0}),rs=(t,e)=>{var n={};for(var r in t)ts.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&cn)for(var r of cn(t))e.indexOf(r)<0&&ns.call(t,r)&&(n[r]=t[r]);return n},ge=(t,e)=>{for(var n in e)br(t,n,{get:e[n],enumerable:!0})},v={};ge(v,{DIRTY:()=>Xr,ERR:()=>Yr,OK:()=>mn,any:()=>Fe,array:()=>Ke,bigint:()=>kn,boolean:()=>tt,branded:()=>Jr,catch:()=>Vr,coerce:()=>jl,custom:()=>Pn,date:()=>In,default:()=>qr,discriminatedUnion:()=>$t,downstream:()=>Kr,enum:()=>En,function:()=>$r,instanceof:()=>Cr,intersection:()=>Ut,is:()=>E,lazy:()=>Mr,literal:()=>jt,map:()=>Hr,nan:()=>Rr,nativeEnum:()=>Nr,never:()=>Mt,null:()=>Lt,nullable:()=>Lr,number:()=>et,object:()=>dt,optional:()=>Wr,pipeline:()=>Gr,preprocess:()=>Ur,promise:()=>jr,readonly:()=>Fr,record:()=>zt,ref:()=>On,set:()=>Bn,strictObject:()=>Dr,string:()=>ke,symbol:()=>Zr,transforms:()=>is,tuple:()=>Ft,undefined:()=>Sn,union:()=>We,unknown:()=>Ze,upstream:()=>zr,void:()=>Ar,zuiKey:()=>C});var is={};ge(is,{errors:()=>$l,fromJSONSchema:()=>lu,fromJSONSchemaLegacy:()=>ry,fromObject:()=>_y,json:()=>gh,toJSONSchema:()=>ri,toJSONSchemaLegacy:()=>Ry,toTypescriptSchema:()=>si,toTypescriptType:()=>ii});var Ie={};ge(Ie,{DIRTY:()=>Xr,ERR:()=>Yr,OK:()=>mn,any:()=>Fe,array:()=>Ke,bigint:()=>kn,boolean:()=>tt,branded:()=>Jr,catch:()=>Vr,coerce:()=>jl,custom:()=>Pn,date:()=>In,default:()=>qr,discriminatedUnion:()=>$t,downstream:()=>Kr,enum:()=>En,function:()=>$r,instanceof:()=>Cr,intersection:()=>Ut,is:()=>E,lazy:()=>Mr,literal:()=>jt,map:()=>Hr,nan:()=>Rr,nativeEnum:()=>Nr,never:()=>Mt,null:()=>Lt,nullable:()=>Lr,number:()=>et,object:()=>dt,optional:()=>Wr,pipeline:()=>Gr,preprocess:()=>Ur,promise:()=>jr,readonly:()=>Fr,record:()=>zt,ref:()=>On,set:()=>Bn,strictObject:()=>Dr,string:()=>ke,symbol:()=>Zr,tuple:()=>Ft,undefined:()=>Sn,union:()=>We,unknown:()=>Ze,upstream:()=>zr,void:()=>Ar,zuiKey:()=>C});var C="x-zui",$={};ge($,{CustomSet:()=>Ng});var _e={};ge(_e,{isEqual:()=>xo,unique:()=>Zg});var Ac=typeof global=="object"&&global&&global.Object===Object&&global,ss=Ac,Zc=typeof self=="object"&&self&&self.Object===Object&&self,Rc=ss||Zc||Function("return this")(),Oe=Rc,Nc=Oe.Symbol,Ae=Nc,as=Object.prototype,Dc=as.hasOwnProperty,Hc=as.toString,ht=Ae?Ae.toStringTag:void 0;function os(t){var e=Dc.call(t,ht),n=t[ht];try{t[ht]=void 0;var r=!0}catch{}var i=Hc.call(t);return r&&(e?t[ht]=n:delete t[ht]),i}l(os,"getRawTag");var Mc=os,jc=Object.prototype,$c=jc.toString;function ls(t){return $c.call(t)}l(ls,"objectToString");var Uc=ls,zc="[object Null]",Kc="[object Undefined]",Ti=Ae?Ae.toStringTag:void 0;function us(t){return t==null?t===void 0?Kc:zc:Ti&&Ti in Object(t)?Mc(t):Uc(t)}l(us,"baseGetTag");var qe=us;function cs(t){return t!=null&&typeof t=="object"}l(cs,"isObjectLike");var Le=cs,Wc="[object Symbol]";function ds(t){return typeof t=="symbol"||Le(t)&&qe(t)==Wc}l(ds,"isSymbol");var wr=ds;function ps(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(ps,"arrayMap");var fs=ps,Lc=Array.isArray,Se=Lc,Fc=1/0,bi=Ae?Ae.prototype:void 0,wi=bi?bi.toString:void 0;function xr(t){if(typeof t=="string")return t;if(Se(t))return fs(t,xr)+"";if(wr(t))return wi?wi.call(t):"";var e=t+"";return e=="0"&&1/t==-Fc?"-0":e}l(xr,"baseToString");var qc=xr;function gs(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}l(gs,"isObject");var ct=gs;function ms(t){return t}l(ms,"identity");var Vc=ms,Gc="[object AsyncFunction]",Jc="[object Function]",Yc="[object GeneratorFunction]",Xc="[object Proxy]";function ys(t){if(!ct(t))return!1;var e=qe(t);return e==Jc||e==Yc||e==Gc||e==Xc}l(ys,"isFunction");var hs=ys,Qc=Oe["__core-js_shared__"],Jn=Qc,xi=(function(){var t=/[^.]+$/.exec(Jn&&Jn.keys&&Jn.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function vs(t){return!!xi&&xi in t}l(vs,"isMasked");var ed=vs,td=Function.prototype,nd=td.toString;function _s(t){if(t!=null){try{return nd.call(t)}catch{}try{return t+""}catch{}}return""}l(_s,"toSource");var Ve=_s,rd=/[\\^$.*+?()[\]{}|]/g,id=/^\[object .+?Constructor\]$/,sd=Function.prototype,ad=Object.prototype,od=sd.toString,ld=ad.hasOwnProperty,ud=RegExp("^"+od.call(ld).replace(rd,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ts(t){if(!ct(t)||ed(t))return!1;var e=hs(t)?ud:id;return e.test(Ve(t))}l(Ts,"baseIsNative");var cd=Ts;function bs(t,e){return t?.[e]}l(bs,"getValue");var dd=bs;function ws(t,e){var n=dd(t,e);return cd(n)?n:void 0}l(ws,"getNative");var Ge=ws,pd=Ge(Oe,"WeakMap"),lr=pd,fd=(function(){try{var t=Ge(Object,"defineProperty");return t({},"",{}),t}catch{}})(),Pi=fd,gd=9007199254740991,md=/^(?:0|[1-9]\d*)$/;function xs(t,e){var n=typeof t;return e=e??gd,!!e&&(n=="number"||n!="symbol"&&md.test(t))&&t>-1&&t%1==0&&t<e}l(xs,"isIndex");var Pr=xs;function Ps(t,e,n){e=="__proto__"&&Pi?Pi(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}l(Ps,"baseAssignValue");var yd=Ps;function Ss(t,e){return t===e||t!==t&&e!==e}l(Ss,"eq");var Sr=Ss,hd=Object.prototype,vd=hd.hasOwnProperty;function ks(t,e,n){var r=t[e];(!(vd.call(t,e)&&Sr(r,n))||n===void 0&&!(e in t))&&yd(t,e,n)}l(ks,"assignValue");var _d=ks,Td=9007199254740991;function Is(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Td}l(Is,"isLength");var kr=Is;function Os(t){return t!=null&&kr(t.length)&&!hs(t)}l(Os,"isArrayLike");var Es=Os,bd=Object.prototype;function Bs(t){var e=t&&t.constructor,n=typeof e=="function"&&e.prototype||bd;return t===n}l(Bs,"isPrototype");var Cs=Bs;function As(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}l(As,"baseTimes");var wd=As,xd="[object Arguments]";function Zs(t){return Le(t)&&qe(t)==xd}l(Zs,"baseIsArguments");var Si=Zs,Rs=Object.prototype,Pd=Rs.hasOwnProperty,Sd=Rs.propertyIsEnumerable,kd=Si((function(){return arguments})())?Si:function(t){return Le(t)&&Pd.call(t,"callee")&&!Sd.call(t,"callee")},Ns=kd;function Ds(){return!1}l(Ds,"stubFalse");var Id=Ds,Hs=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ki=Hs&&typeof module=="object"&&module&&!module.nodeType&&module,Od=ki&&ki.exports===Hs,Ii=Od?Oe.Buffer:void 0,Ed=Ii?Ii.isBuffer:void 0,Bd=Ed||Id,ur=Bd,Cd="[object Arguments]",Ad="[object Array]",Zd="[object Boolean]",Rd="[object Date]",Nd="[object Error]",Dd="[object Function]",Hd="[object Map]",Md="[object Number]",jd="[object Object]",$d="[object RegExp]",Ud="[object Set]",zd="[object String]",Kd="[object WeakMap]",Wd="[object ArrayBuffer]",Ld="[object DataView]",Fd="[object Float32Array]",qd="[object Float64Array]",Vd="[object Int8Array]",Gd="[object Int16Array]",Jd="[object Int32Array]",Yd="[object Uint8Array]",Xd="[object Uint8ClampedArray]",Qd="[object Uint16Array]",ep="[object Uint32Array]",Z={};Z[Fd]=Z[qd]=Z[Vd]=Z[Gd]=Z[Jd]=Z[Yd]=Z[Xd]=Z[Qd]=Z[ep]=!0;Z[Cd]=Z[Ad]=Z[Wd]=Z[Zd]=Z[Ld]=Z[Rd]=Z[Nd]=Z[Dd]=Z[Hd]=Z[Md]=Z[jd]=Z[$d]=Z[Ud]=Z[zd]=Z[Kd]=!1;function Ms(t){return Le(t)&&kr(t.length)&&!!Z[qe(t)]}l(Ms,"baseIsTypedArray");var tp=Ms;function js(t){return function(e){return t(e)}}l(js,"baseUnary");var np=js,$s=typeof exports=="object"&&exports&&!exports.nodeType&&exports,At=$s&&typeof module=="object"&&module&&!module.nodeType&&module,rp=At&&At.exports===$s,Yn=rp&&ss.process,ip=(function(){try{var t=At&&At.require&&At.require("util").types;return t||Yn&&Yn.binding&&Yn.binding("util")}catch{}})(),Oi=ip,Ei=Oi&&Oi.isTypedArray,sp=Ei?np(Ei):tp,Us=sp,ap=Object.prototype,op=ap.hasOwnProperty;function zs(t,e){var n=Se(t),r=!n&&Ns(t),i=!n&&!r&&ur(t),s=!n&&!r&&!i&&Us(t),a=n||r||i||s,o=a?wd(t.length,String):[],u=o.length;for(var d in t)(e||op.call(t,d))&&!(a&&(d=="length"||i&&(d=="offset"||d=="parent")||s&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||Pr(d,u)))&&o.push(d);return o}l(zs,"arrayLikeKeys");var Ks=zs;function Ws(t,e){return function(n){return t(e(n))}}l(Ws,"overArg");var Ls=Ws,lp=Ls(Object.keys,Object),up=lp,cp=Object.prototype,dp=cp.hasOwnProperty;function Fs(t){if(!Cs(t))return up(t);var e=[];for(var n in Object(t))dp.call(t,n)&&n!="constructor"&&e.push(n);return e}l(Fs,"baseKeys");var pp=Fs;function qs(t){return Es(t)?Ks(t):pp(t)}l(qs,"keys");var Vs=qs;function Gs(t){var e=[];if(t!=null)for(var n in Object(t))e.push(n);return e}l(Gs,"nativeKeysIn");var fp=Gs,gp=Object.prototype,mp=gp.hasOwnProperty;function Js(t){if(!ct(t))return fp(t);var e=Cs(t),n=[];for(var r in t)r=="constructor"&&(e||!mp.call(t,r))||n.push(r);return n}l(Js,"baseKeysIn");var yp=Js;function Ys(t){return Es(t)?Ks(t,!0):yp(t)}l(Ys,"keysIn");var hp=Ys,vp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,_p=/^\w*$/;function Xs(t,e){if(Se(t))return!1;var n=typeof t;return n=="number"||n=="symbol"||n=="boolean"||t==null||wr(t)?!0:_p.test(t)||!vp.test(t)||e!=null&&t in Object(e)}l(Xs,"isKey");var Ir=Xs,Tp=Ge(Object,"create"),Nt=Tp;function Qs(){this.__data__=Nt?Nt(null):{},this.size=0}l(Qs,"hashClear");var bp=Qs;function ea(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}l(ea,"hashDelete");var wp=ea,xp="__lodash_hash_undefined__",Pp=Object.prototype,Sp=Pp.hasOwnProperty;function ta(t){var e=this.__data__;if(Nt){var n=e[t];return n===xp?void 0:n}return Sp.call(e,t)?e[t]:void 0}l(ta,"hashGet");var kp=ta,Ip=Object.prototype,Op=Ip.hasOwnProperty;function na(t){var e=this.__data__;return Nt?e[t]!==void 0:Op.call(e,t)}l(na,"hashHas");var Ep=na,Bp="__lodash_hash_undefined__";function ra(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=Nt&&e===void 0?Bp:e,this}l(ra,"hashSet");var Cp=ra;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,"Hash");Je.prototype.clear=bp;Je.prototype.delete=wp;Je.prototype.get=kp;Je.prototype.has=Ep;Je.prototype.set=Cp;var Bi=Je;function ia(){this.__data__=[],this.size=0}l(ia,"listCacheClear");var Ap=ia;function sa(t,e){for(var n=t.length;n--;)if(Sr(t[n][0],e))return n;return-1}l(sa,"assocIndexOf");var hn=sa,Zp=Array.prototype,Rp=Zp.splice;function aa(t){var e=this.__data__,n=hn(e,t);if(n<0)return!1;var r=e.length-1;return n==r?e.pop():Rp.call(e,n,1),--this.size,!0}l(aa,"listCacheDelete");var Np=aa;function oa(t){var e=this.__data__,n=hn(e,t);return n<0?void 0:e[n][1]}l(oa,"listCacheGet");var Dp=oa;function la(t){return hn(this.__data__,t)>-1}l(la,"listCacheHas");var Hp=la;function ua(t,e){var n=this.__data__,r=hn(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}l(ua,"listCacheSet");var Mp=ua;function Ye(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}l(Ye,"ListCache");Ye.prototype.clear=Ap;Ye.prototype.delete=Np;Ye.prototype.get=Dp;Ye.prototype.has=Hp;Ye.prototype.set=Mp;var vn=Ye,jp=Ge(Oe,"Map"),Dt=jp;function ca(){this.size=0,this.__data__={hash:new Bi,map:new(Dt||vn),string:new Bi}}l(ca,"mapCacheClear");var $p=ca;function da(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}l(da,"isKeyable");var Up=da;function pa(t,e){var n=t.__data__;return Up(e)?n[typeof e=="string"?"string":"hash"]:n.map}l(pa,"getMapData");var _n=pa;function fa(t){var e=_n(this,t).delete(t);return this.size-=e?1:0,e}l(fa,"mapCacheDelete");var zp=fa;function ga(t){return _n(this,t).get(t)}l(ga,"mapCacheGet");var Kp=ga;function ma(t){return _n(this,t).has(t)}l(ma,"mapCacheHas");var Wp=ma;function ya(t,e){var n=_n(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this}l(ya,"mapCacheSet");var Lp=ya;function Xe(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(Xe,"MapCache");Xe.prototype.clear=$p;Xe.prototype.delete=zp;Xe.prototype.get=Kp;Xe.prototype.has=Wp;Xe.prototype.set=Lp;var Tn=Xe,Fp="Expected a function";function bn(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(Fp);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(bn.Cache||Tn),n}l(bn,"memoize");bn.Cache=Tn;var qp=bn,Vp=500;function ha(t){var e=qp(t,function(r){return n.size===Vp&&n.clear(),r}),n=e.cache;return e}l(ha,"memoizeCapped");var Gp=ha,Jp=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Yp=/\\(\\)?/g,Xp=Gp(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(Jp,function(n,r,i,s){e.push(i?s.replace(Yp,"$1"):r||n)}),e}),Qp=Xp;function va(t){return t==null?"":qc(t)}l(va,"toString");var ef=va;function _a(t,e){return Se(t)?t:Ir(t,e)?[t]:Qp(ef(t))}l(_a,"castPath");var wn=_a,tf=1/0;function Ta(t){if(typeof t=="string"||wr(t))return t;var e=t+"";return e=="0"&&1/t==-tf?"-0":e}l(Ta,"toKey");var Wt=Ta;function ba(t,e){e=wn(e,t);for(var n=0,r=e.length;t!=null&&n<r;)t=t[Wt(e[n++])];return n&&n==r?t:void 0}l(ba,"baseGet");var Or=ba;function wa(t,e,n){var r=t==null?void 0:Or(t,e);return r===void 0?n:r}l(wa,"get");var nf=wa;function xa(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t}l(xa,"arrayPush");var Pa=xa,rf=Ls(Object.getPrototypeOf,Object),Sa=rf,sf="[object Object]",af=Function.prototype,of=Object.prototype,ka=af.toString,lf=of.hasOwnProperty,uf=ka.call(Object);function Ia(t){if(!Le(t)||qe(t)!=sf)return!1;var e=Sa(t);if(e===null)return!0;var n=lf.call(e,"constructor")&&e.constructor;return typeof n=="function"&&n instanceof n&&ka.call(n)==uf}l(Ia,"isPlainObject");var cf=Ia;function Oa(){this.__data__=new vn,this.size=0}l(Oa,"stackClear");var df=Oa;function Ea(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}l(Ea,"stackDelete");var pf=Ea;function Ba(t){return this.__data__.get(t)}l(Ba,"stackGet");var ff=Ba;function Ca(t){return this.__data__.has(t)}l(Ca,"stackHas");var gf=Ca,mf=200;function Aa(t,e){var n=this.__data__;if(n instanceof vn){var r=n.__data__;if(!Dt||r.length<mf-1)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new Tn(r)}return n.set(t,e),this.size=n.size,this}l(Aa,"stackSet");var yf=Aa;function Qe(t){var e=this.__data__=new vn(t);this.size=e.size}l(Qe,"Stack");Qe.prototype.clear=df;Qe.prototype.delete=pf;Qe.prototype.get=ff;Qe.prototype.has=gf;Qe.prototype.set=yf;var Qt=Qe;function Za(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(Za,"arrayFilter");var hf=Za;function Ra(){return[]}l(Ra,"stubArray");var Na=Ra,vf=Object.prototype,_f=vf.propertyIsEnumerable,Ci=Object.getOwnPropertySymbols,Tf=Ci?function(t){return t==null?[]:(t=Object(t),hf(Ci(t),function(e){return _f.call(t,e)}))}:Na,Da=Tf,bf=Object.getOwnPropertySymbols,wf=bf?function(t){for(var e=[];t;)Pa(e,Da(t)),t=Sa(t);return e}:Na,xf=wf;function Ha(t,e,n){var r=e(t);return Se(t)?r:Pa(r,n(t))}l(Ha,"baseGetAllKeys");var Ma=Ha;function ja(t){return Ma(t,Vs,Da)}l(ja,"getAllKeys");var Ai=ja;function $a(t){return Ma(t,hp,xf)}l($a,"getAllKeysIn");var Pf=$a,Sf=Ge(Oe,"DataView"),cr=Sf,kf=Ge(Oe,"Promise"),dr=kf,If=Ge(Oe,"Set"),pr=If,Zi="[object Map]",Of="[object Object]",Ri="[object Promise]",Ni="[object Set]",Di="[object WeakMap]",Hi="[object DataView]",Ef=Ve(cr),Bf=Ve(Dt),Cf=Ve(dr),Af=Ve(pr),Zf=Ve(lr),Me=qe;(cr&&Me(new cr(new ArrayBuffer(1)))!=Hi||Dt&&Me(new Dt)!=Zi||dr&&Me(dr.resolve())!=Ri||pr&&Me(new pr)!=Ni||lr&&Me(new lr)!=Di)&&(Me=l(function(t){var e=qe(t),n=e==Of?t.constructor:void 0,r=n?Ve(n):"";if(r)switch(r){case Ef:return Hi;case Bf:return Zi;case Cf:return Ri;case Af:return Ni;case Zf:return Di}return e},"getTag"));var Mi=Me,Rf=Oe.Uint8Array,ji=Rf,Nf="__lodash_hash_undefined__";function Ua(t){return this.__data__.set(t,Nf),this}l(Ua,"setCacheAdd");var Df=Ua;function za(t){return this.__data__.has(t)}l(za,"setCacheHas");var Hf=za;function Ht(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new Tn;++e<n;)this.add(t[e])}l(Ht,"SetCache");Ht.prototype.add=Ht.prototype.push=Df;Ht.prototype.has=Hf;var Mf=Ht;function Ka(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(Ka,"arraySome");var jf=Ka;function Wa(t,e){return t.has(e)}l(Wa,"cacheHas");var $f=Wa,Uf=1,zf=2;function La(t,e,n,r,i,s){var a=n&Uf,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,m=!0,_=n&zf?new Mf:void 0;for(s.set(t,e),s.set(e,t);++g<o;){var h=t[g],A=e[g];if(r)var U=a?r(A,h,g,e,t,s):r(h,A,g,t,e,s);if(U!==void 0){if(U)continue;m=!1;break}if(_){if(!jf(e,function(Q,ee){if(!$f(_,ee)&&(h===Q||i(h,Q,n,r,s)))return _.push(ee)})){m=!1;break}}else if(!(h===A||i(h,A,n,r,s))){m=!1;break}}return s.delete(t),s.delete(e),m}l(La,"equalArrays");var Fa=La;function qa(t){var e=-1,n=Array(t.size);return t.forEach(function(r,i){n[++e]=[i,r]}),n}l(qa,"mapToArray");var Kf=qa;function Va(t){var e=-1,n=Array(t.size);return t.forEach(function(r){n[++e]=r}),n}l(Va,"setToArray");var Wf=Va,Lf=1,Ff=2,qf="[object Boolean]",Vf="[object Date]",Gf="[object Error]",Jf="[object Map]",Yf="[object Number]",Xf="[object RegExp]",Qf="[object Set]",eg="[object String]",tg="[object Symbol]",ng="[object ArrayBuffer]",rg="[object DataView]",$i=Ae?Ae.prototype:void 0,Xn=$i?$i.valueOf:void 0;function Ga(t,e,n,r,i,s,a){switch(n){case rg:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case ng:return!(t.byteLength!=e.byteLength||!s(new ji(t),new ji(e)));case qf:case Vf:case Yf:return Sr(+t,+e);case Gf:return t.name==e.name&&t.message==e.message;case Xf:case eg:return t==e+"";case Jf:var o=Kf;case Qf:var u=r&Lf;if(o||(o=Wf),t.size!=e.size&&!u)return!1;var d=a.get(t);if(d)return d==e;r|=Ff,a.set(t,e);var p=Fa(o(t),o(e),r,i,s,a);return a.delete(t),p;case tg:if(Xn)return Xn.call(t)==Xn.call(e)}return!1}l(Ga,"equalByTag");var ig=Ga,sg=1,ag=Object.prototype,og=ag.hasOwnProperty;function Ja(t,e,n,r,i,s){var a=n&sg,o=Ai(t),u=o.length,d=Ai(e),p=d.length;if(u!=p&&!a)return!1;for(var g=u;g--;){var m=o[g];if(!(a?m in e:og.call(e,m)))return!1}var _=s.get(t),h=s.get(e);if(_&&h)return _==e&&h==t;var A=!0;s.set(t,e),s.set(e,t);for(var U=a;++g<u;){m=o[g];var Q=t[m],ee=e[m];if(r)var z=a?r(ee,Q,m,e,t,s):r(Q,ee,m,t,e,s);if(!(z===void 0?Q===ee||i(Q,ee,n,r,s):z)){A=!1;break}U||(U=m=="constructor")}if(A&&!U){var K=t.constructor,ie=e.constructor;K!=ie&&"constructor"in t&&"constructor"in e&&!(typeof K=="function"&&K instanceof K&&typeof ie=="function"&&ie instanceof ie)&&(A=!1)}return s.delete(t),s.delete(e),A}l(Ja,"equalObjects");var lg=Ja,ug=1,Ui="[object Arguments]",zi="[object Array]",Yt="[object Object]",cg=Object.prototype,Ki=cg.hasOwnProperty;function Ya(t,e,n,r,i,s){var a=Se(t),o=Se(e),u=a?zi:Mi(t),d=o?zi:Mi(e);u=u==Ui?Yt:u,d=d==Ui?Yt:d;var p=u==Yt,g=d==Yt,m=u==d;if(m&&ur(t)){if(!ur(e))return!1;a=!0,p=!1}if(m&&!p)return s||(s=new Qt),a||Us(t)?Fa(t,e,n,r,i,s):ig(t,e,u,n,r,i,s);if(!(n&ug)){var _=p&&Ki.call(t,"__wrapped__"),h=g&&Ki.call(e,"__wrapped__");if(_||h){var A=_?t.value():t,U=h?e.value():e;return s||(s=new Qt),i(A,U,n,r,s)}}return m?(s||(s=new Qt),lg(t,e,n,r,i,s)):!1}l(Ya,"baseIsEqualDeep");var dg=Ya;function Er(t,e,n,r,i){return t===e?!0:t==null||e==null||!Le(t)&&!Le(e)?t!==t&&e!==e:dg(t,e,n,r,Er,i)}l(Er,"baseIsEqual");var xn=Er,pg=1,fg=2;function Xa(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 m=r(d,p,u,t,e,g);if(!(m===void 0?xn(p,d,pg|fg,r,g):m))return!1}}return!0}l(Xa,"baseIsMatch");var gg=Xa;function Qa(t){return t===t&&!ct(t)}l(Qa,"isStrictComparable");var eo=Qa;function to(t){for(var e=Vs(t),n=e.length;n--;){var r=e[n],i=t[r];e[n]=[r,i,eo(i)]}return e}l(to,"getMatchData");var mg=to;function no(t,e){return function(n){return n==null?!1:n[t]===e&&(e!==void 0||t in Object(n))}}l(no,"matchesStrictComparable");var ro=no;function io(t){var e=mg(t);return e.length==1&&e[0][2]?ro(e[0][0],e[0][1]):function(n){return n===t||gg(n,t,e)}}l(io,"baseMatches");var yg=io;function so(t,e){return t!=null&&e in Object(t)}l(so,"baseHasIn");var hg=so;function ao(t,e,n){e=wn(e,t);for(var r=-1,i=e.length,s=!1;++r<i;){var a=Wt(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&&kr(i)&&Pr(a,i)&&(Se(t)||Ns(t)))}l(ao,"hasPath");var vg=ao;function oo(t,e){return t!=null&&vg(t,e,hg)}l(oo,"hasIn");var _g=oo,Tg=1,bg=2;function lo(t,e){return Ir(t)&&eo(e)?ro(Wt(t),e):function(n){var r=nf(n,t);return r===void 0&&r===e?_g(n,t):xn(e,r,Tg|bg)}}l(lo,"baseMatchesProperty");var wg=lo;function uo(t){return function(e){return e?.[t]}}l(uo,"baseProperty");var xg=uo;function co(t){return function(e){return Or(e,t)}}l(co,"basePropertyDeep");var Pg=co;function po(t){return Ir(t)?xg(Wt(t)):Pg(t)}l(po,"property");var Sg=po;function fo(t){return typeof t=="function"?t:t==null?Vc:typeof t=="object"?Se(t)?wg(t[0],t[1]):yg(t):Sg(t)}l(fo,"baseIteratee");var go=fo;function mo(t,e){return xn(t,e)}l(mo,"isEqual");var Ce=mo;function yo(t,e,n){n=typeof n=="function"?n:void 0;var r=n?n(t,e):void 0;return r===void 0?xn(t,e,void 0,n):!!r}l(yo,"isEqualWith");var kg=yo;function ho(t){return t===void 0}l(ho,"isUndefined");var Wi=ho,Ig="Expected a function";function vo(t){if(typeof t!="function")throw new TypeError(Ig);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(vo,"negate");var Og=vo;function _o(t,e,n,r){if(!ct(t))return t;e=wn(e,t);for(var i=-1,s=e.length,a=s-1,o=t;o!=null&&++i<s;){var u=Wt(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=ct(p)?p:Pr(e[i+1])?[]:{})}_d(o,u,d),o=o[u]}return t}l(_o,"baseSet");var Eg=_o;function To(t,e,n){for(var r=-1,i=e.length,s={};++r<i;){var a=e[r],o=Or(t,a);n(o,a)&&Eg(s,wn(a,t),o)}return s}l(To,"basePickBy");var Bg=To;function bo(t,e){if(t==null)return{};var n=fs(Pf(t),function(r){return[r]});return e=go(e),Bg(t,n,function(r,i){return e(r,i[0])})}l(bo,"pickBy");var Cg=bo;function wo(t,e){return Cg(t,Og(go(e)))}l(wo,"omitBy");var Li=wo,xo=l((t,e)=>Po(t,e,new WeakSet),"isEqual"),Fi=l(t=>cf(t),"_isPlainObject"),Po=l((t,e,n)=>kg(t,e,Ag(n)),"_isEqualWithVisitedTracking"),Ag=l(t=>(e,n)=>{if(Fi(e)&&!t.has(e)&&Fi(n)&&!t.has(n)){let r=Li(e,Wi),i=Li(n,Wi);return t.add(r).add(i).add(e).add(n),Po(r,i,t)}},"_customizerWithVisitedTracking"),Zg=l(t=>Array.from(new Set(t)),"unique"),Rg={compare:xo},So=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(So,"CustomSet");var Ng=So,b={};ge(b,{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"),fe={};ge(fe,{assertNever:()=>ko});function ko(t){throw new Error("assertNever called")}l(ko,"assertNever");var pe={};ge(pe,{compareFunctions:()=>jg,joinValues:()=>Io,jsonStringifyReplacer:()=>Mg});function Io(t,e=" | "){return t.map(n=>typeof n=="string"?`'${n}'`:n).join(e)}l(Io,"joinValues");var Mg=l((t,e)=>typeof e=="bigint"?e.toString():e,"jsonStringifyReplacer"),jg=l((t,e)=>t.toString()===e.toString(),"compareFunctions"),Oo={};ge(Oo,{extractPrecisionAndOffset:()=>Bo,generateDatetimeRegex:()=>Eo});var Eo=l(t=>{let e=t.precision?fr+t.precision+Ug:t.precision===0?"":Zo,n=t.offset?Ao:$g;return new RegExp(`^${Co}${e}${n}$`)},"generateDatetimeRegex"),Bo=l(t=>({precision:zg(t),offset:t.endsWith(`${Ao}$`)}),"extractPrecisionAndOffset"),Co="\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}",Ao="(([+-]\\d{2}(:?\\d{2})?)|Z)",$g="Z",Zo="(\\.\\d+)?",fr="\\.\\d{",Ug="}",zg=l(t=>{let e=t.slice(1+Co.length);return e.startsWith(Zo)?null:e.startsWith(fr)?parseInt(e.slice(fr.length)):0},"_extractPrecision"),dn=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,pe.jsonStringifyReplacer)}`;break;case"unrecognized_keys":n=`Unrecognized key(s) in object: ${pe.joinValues(t.keys,", ")}`;break;case"invalid_union":n="Invalid input";break;case"invalid_union_discriminator":n=`Invalid discriminator value. Expected ${pe.joinValues(t.options)}`;break;case"invalid_enum_value":n=`Invalid enum value. Expected ${pe.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}"`:fe.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,fe.assertNever(t)}return{message:n}},"errorMap"),pn=class Ro 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 Ro))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,pe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}};l(pn,"ZodError");pn.create=l(t=>new pn(t),"create");var Pe=pn,Kg=dn;function fn(){return Kg}l(fn,"getErrorMap");var R={};function No(t){Object.assign(R,t)}l(No,"setBuilders");var gr=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 y(t,e){let n=gr({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,fn(),dn].filter(r=>!!r)});t.common.issues.push(n)}l(y,"addIssueToContext");var Do=class Ho{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 Ho.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(Do,"ParseStatus");var se=Do,gn=l(t=>typeof Promise<"u"&&t instanceof Promise,"isAsync"),ze=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"),Mo=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(Mo,"ParseInputLazyPath");var ve=Mo,jo=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(jo,"_CircularDependencyError");var Qn=jo,$o=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 Pe(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 ze(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:ze(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new se,ctx:{common:e.parent.common,data:e.data,parsedType:ze(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(gn(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:ze(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:ze(e)},i=this._parse({data:e,path:r.path,parent:r}),s=await(gn(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 R.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 R.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 R.downstream(this,e,n)}optional(){return R.optional(this,this._def)}nullable(){return R.nullable(this,this._def)}nullish(){return this.nullable().optional()}array(){return R.array(this,this._def)}promise(){return R.promise(this,this._def)}mandatory(){return this}or(e){return R.union([this,e])}and(e){return R.intersection(this,e)}transform(e){return R.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 R.default(this,n)}brand(){return R.branded(this)}catch(e){return R.catch(this,e)}describe(e){let n=this.clone();return n._metadataRoot._def.description=e,n}pipe(e){return R.pipeline(this,e)}readonly(){return R.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=C])!=null||(n[r]={});for(let[o,u]of Object.entries(e))a._def[C]=f(c({},a._def[C]),{[o]:u});return s}getMetadata(){return c({},this._metadataRoot._def[C])}setMetadata(e){this._metadataRoot._def[C]=c({},e)}get ui(){return c({},this._metadataRoot._def[C])}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($o,"ZodBaseTypeImpl");var P=$o,Uo=class zo extends P{constructor(){super(...arguments),this._any=!0}_parse(e){return{status:"valid",value:e.data}}isEqual(e){return e instanceof zo}};l(Uo,"ZodAnyImpl");var Wg=Uo,Ko=class je extends P{dereference(e){return new je(f(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new je(f(c({},this._def),{type:this._def.type.clone()}))}isEqual(e){var n,r,i,s,a,o;return e instanceof je?Ce((n=this._def.exactLength)==null?void 0:n.value,(r=e._def.exactLength)==null?void 0:r.value)&&Ce((i=this._def.maxLength)==null?void 0:i.value,(s=e._def.maxLength)==null?void 0:s.value)&&Ce((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 y(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)&&(y(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&&(y(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&&(y(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 ve(n,a,n.path,o)))).then(a=>se.mergeArray(r,a));let s=[...n.data].map((a,o)=>i.type._parseSync(new ve(n,a,n.path,o)));return se.mergeArray(r,s)}get element(){return this._def.type}min(e,n){return new je(f(c({},this._def),{minLength:{value:e,message:b.toString(n)}}))}max(e,n){return new je(f(c({},this._def),{maxLength:{value:e,message:b.toString(n)}}))}length(e,n){return new je(f(c({},this._def),{exactLength:{value:e,message:b.toString(n)}}))}nonempty(e){return this.min(1,e)}};l(Ko,"ZodArrayImpl");var Lg=Ko,Wo=class en 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 y(s,{code:"invalid_type",expected:"bigint",received:s.parsedType}),{status:"aborted"}}let r,i=new se;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),y(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),y(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),y(r,{code:"not_multiple_of",multipleOf:s.value,message:s.message}),i.dirty()):fe.assertNever(s);return{status:i.value,value:e.data}}isEqual(e){if(!(e instanceof en)||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,b.toString(n))}gt(e,n){return this.setLimit("min",e,!1,b.toString(n))}lte(e,n){return this.setLimit("max",e,!0,b.toString(n))}lt(e,n){return this.setLimit("max",e,!1,b.toString(n))}setLimit(e,n,r,i){return new en(f(c({},this._def),{checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:b.toString(i)}]}))}_addCheck(e){return new en(f(c({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:b.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:b.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(Wo,"ZodBigIntImpl");var Fg=Wo,Lo=class Fo extends P{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!=="boolean"){let r=this._getOrReturnCtx(e);return y(r,{code:"invalid_type",expected:"boolean",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof Fo?this._def.coerce===e._def.coerce:!1}};l(Lo,"ZodBooleanImpl");var qg=Lo,qo=class Tt extends P{dereference(e){return new Tt(f(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new Tt(f(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx: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 Tt?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}mandatory(){return new Tt(f(c({},this._def),{type:this._def.type.mandatory()}))}};l(qo,"ZodBrandedImpl");var Vg=qo,Vo=class bt 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 gn(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Pe(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Pe(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}isEqual(e){return e instanceof bt?this._def.innerType.isEqual(e._def.innerType)&&pe.compareFunctions(this._def.catchValue,e._def.catchValue):!1}dereference(e){return new bt(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new bt(f(c({},this._def),{innerType:this._def.innerType.clone()}))}naked(){return this._def.innerType.naked()}mandatory(){return new bt(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};l(Vo,"ZodCatchImpl");var Gg=Vo,Go=class mr extends P{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!=="date"){let s=this._getOrReturnCtx(e);return y(s,{code:"invalid_type",expected:"date",received:s.parsedType}),{status:"aborted"}}if(isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return y(s,{code:"invalid_date"}),{status:"aborted"}}let r=new se,i;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),y(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),y(i,{code:"too_big",message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):fe.assertNever(s);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new mr(f(c({},this._def),{checks:[...this._def.checks,e]}))}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:b.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:b.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 mr))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(Go,"ZodDateImpl");var Jg=Go,Jo=class wt 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 wt(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new wt(f(c({},this._def),{innerType:this._def.innerType.clone()}))}isEqual(e){return e instanceof wt?this._def.innerType.isEqual(e._def.innerType)&&Ce(this._def.defaultValue(),e._def.defaultValue()):!1}unwrap(){return this._def.innerType}naked(){return this._def.innerType.naked()}mandatory(){return new wt(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};l(Jo,"ZodDefaultImpl");var Yg=Jo,xe=l(t=>{let e=t;return e?e.typeName==="ZodLazy"?xe(e.schema):e.typeName==="ZodEffects"?xe(e.innerType()):e.typeName==="ZodLiteral"?[e.value]:e.typeName==="ZodEnum"?e.options:e.typeName==="ZodNativeEnum"?Object.values(e.enum):e.typeName==="ZodDefault"?xe(e._def.innerType):e.typeName==="ZodUndefined"?[void 0]:e.typeName==="ZodNull"?[null]:e.typeName==="ZodOptional"?[void 0,...xe(e.unwrap())]:e.typeName==="ZodNullable"?[null,...xe(e.unwrap())]:e.typeName==="ZodBranded"||e.typeName==="ZodReadonly"?xe(e.unwrap()):e.typeName==="ZodCatch"?xe(e._def.innerType):[]:[]},"getDiscriminator"),Yo=class xt extends P{constructor(e){let n=xt._getOptionsMap(e.discriminator,e.options);super(f(c({},e),{optionsMap:n}))}dereference(e){let n=this.options.map(r=>r.dereference(e));return new xt(f(c({},this._def),{options:n}))}getReferences(){return _e.unique(this.options.flatMap(e=>e.getReferences()))}clone(){let e=this.options.map(n=>n.clone());return new xt(f(c({},this._def),{options:e}))}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!=="object")return y(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}):(y(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=xe(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 xt)||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(Yo,"ZodDiscriminatedUnionImpl");var Xg=Yo,Xo=class Qo extends P{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return y(n,{expected:pe.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 y(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 R.enum(e,c(c({},this._def),n))}exclude(e,n=this._def){return R.enum(this.options.filter(r=>!e.includes(r)),c(c({},this._def),n))}isEqual(e){if(!(e instanceof Qo))return!1;let n=new $.CustomSet(this._def.values),r=new $.CustomSet(e._def.values);return n.isEqual(r)}};l(Xo,"ZodEnumImpl");var Qg=Xo,el=class at 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 at(f(c({},this._def),{args:n,returns:r}))}getReferences(){return _e.unique([...this._def.args.getReferences(),...this._def.returns.getReferences()])}clone(){return new at(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 y(n,{code:"invalid_type",expected:"function",received:n.parsedType}),{status:"aborted"};function r(d,p){return gr({data:d,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,fn(),dn].filter(g=>!!g),issueData:{code:"invalid_arguments",argumentsError:p}})}l(r,"makeArgsIssue");function i(d,p){return gr({data:d,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,fn(),dn].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 E.zuiPromise(u)?{status:"valid",async value(...d){let p=new Pe([]),g=await o._def.args.parseAsync(d,s).catch(h=>{throw p.addIssue(r(d,h)),p}),m=await Reflect.apply(a,this,g);return await u._def.type.parseAsync(m,s).catch(h=>{throw E.zuiError(h)?(p.addIssue(i(m,h)),p):h})}}:{status:"valid",value(...d){let p=o._def.args.safeParse(d,s);if(!p.success)throw new Pe([r(d,p.error)]);let g=Reflect.apply(a,this,p.data),m=o._def.returns.safeParse(g,s);if(!m.success)throw new Pe([i(g,m.error)]);return m.data}}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new at(f(c({},this._def),{args:R.tuple(e).rest(R.unknown())}))}returns(e){return new at(f(c({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}isEqual(e){return e instanceof at&&this._def.args.isEqual(e._def.args)&&this._def.returns.isEqual(e._def.returns)}};l(el,"ZodFunctionImpl");var em=el,tl=class tn extends P{dereference(e){return new tn(f(c({},this._def),{left:this._def.left.dereference(e),right:this._def.right.dereference(e)}))}getReferences(){return _e.unique([...this._def.left.getReferences(),...this._def.right.getReferences()])}clone(){return new tn(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}):(y(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 tn))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=ze(e),i=ze(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(tl,"ZodIntersectionImpl");var tm=tl,nl=class Pt extends P{get schema(){return this._def.getter()}dereference(e){return new Pt(f(c({},this._def),{getter:()=>this._def.getter().dereference(e)}))}getReferences(){return this._def.getter().getReferences()}clone(){return new Pt(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 Pt?this._def.getter().isEqual(e._def.getter()):!1}naked(){return this._def.getter().naked()}mandatory(){return new Pt(f(c({},this._def),{getter:()=>this._def.getter().mandatory()}))}};l(nl,"ZodLazyImpl");var nm=nl,rl=class il extends P{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return y(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 il?Ce(this._def.value,e._def.value):!1}};l(rl,"ZodLiteralImpl");var rm=rl,sl=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 _e.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!=="map")return y(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 ve(r,o,r.path,[d,"key"])),value:s._parse(new ve(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 nn)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};l(sl,"ZodMapImpl");var im=sl,al=class ol extends P{_parse(e){if(this._getType(e)!=="nan"){let r=this._getOrReturnCtx(e);return y(r,{code:"invalid_type",expected:"nan",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof ol}};l(al,"ZodNaNImpl");var sm=al,ll=class ul 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 y(r,{expected:pe.joinValues(i),received:r.parsedType,code:"invalid_type"}),{status:"aborted"}}if(n.indexOf(e.data)===-1){let i=Object.values(n);return y(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 ul?Ce(this._def.values,e._def.values):!1}};l(ll,"ZodNativeEnumImpl");var am=ll,cl=class dl extends P{_parse(e){let n=this._getOrReturnCtx(e);return y(n,{code:"invalid_type",expected:"never",received:n.parsedType}),{status:"aborted"}}isEqual(e){return e instanceof dl}};l(cl,"ZodNeverImpl");var om=cl,pl=class fl extends P{_parse(e){if(this._getType(e)!=="null"){let r=this._getOrReturnCtx(e);return y(r,{code:"invalid_type",expected:"null",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof fl}};l(pl,"ZodNullImpl");var lm=pl,gl=class St extends P{dereference(e){return new St(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new St(f(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)==="null"?{status:"valid",value:null}:this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof St?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new St(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};l(gl,"ZodNullableImpl");var um=gl,ml=class rn 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 y(s,{code:"invalid_type",expected:"number",received:s.parsedType}),{status:"aborted"}}let r,i=new se;for(let s of this._def.checks)s.kind==="int"?Number.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),y(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),y(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),y(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),y(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),y(r,{code:"not_finite",message:s.message}),i.dirty()):fe.assertNever(s);return{status:i.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,b.toString(n))}gt(e,n){return this.setLimit("min",e,!1,b.toString(n))}lte(e,n){return this.setLimit("max",e,!0,b.toString(n))}lt(e,n){return this.setLimit("max",e,!1,b.toString(n))}setLimit(e,n,r,i){return new rn(f(c({},this._def),{checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:b.toString(i)}]}))}_addCheck(e){return new rn(f(c({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:b.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:b.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:b.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:b.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:b.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 rn))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(ml,"ZodNumberImpl");var cm=ml,yl=class te 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 te(f(c({},this._def),{shape:()=>r}))}getReferences(){let e=this._def.shape(),n=[];for(let r in e)n.push(...e[r].getReferences());return _e.unique(n)}clone(){let e={},n=this._def.shape();for(let[i,s]of Object.entries(n))e[i]=s.clone();return new te(f(c({},this._def),{shape:()=>e}))}_parse(e){if(this._getType(e)!=="object"){let p=this._getOrReturnCtx(e);return y(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],m=i.data[p];u.push({key:{status:"valid",value:p},value:g._parse(new ve(i,m,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&&(y(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 ve(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 m=await g.key;p.push({key:m,value:await g.value,alwaysSet:g.alwaysSet})}return p}).then(p=>se.mergeObjectSync(r,p)):se.mergeObjectSync(r,u)}get shape(){return this._def.shape()}strict(e){return b.errToObj,new te(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=b.errToObj(e).message)!=null?o:u}:{message:u}}}:{}))}strip(){return new te(f(c({},this._def),{unknownKeys:"strip"}))}passthrough(){return new te(f(c({},this._def),{unknownKeys:"passthrough"}))}additionalProperties(){if(typeof this._def.unknownKeys=="object")return this._def.unknownKeys;if(this._def.unknownKeys==="passthrough")return R.any();if(this._def.unknownKeys==="strict")return R.never()}extend(e){return new te(f(c({},this._def),{shape:()=>c(c({},this._def.shape()),e)}))}merge(e){return new te({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 te(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 te(f(c({},this._def),{shape:()=>n}))}omit(e){let n={};return Object.entries(this.shape).forEach(([i,s])=>{e[i]||(n[i]=s)}),new te(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 te(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(;E.zuiOptional(a);)a=a._def.innerType;n[r]=a}}),new te(f(c({},this._def),{shape:()=>n}))}keyof(){let e=Object.keys(this.shape);return R.enum(e)}isEqual(e){if(!(e instanceof te)||!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(yl,"ZodObjectImpl");var hl=yl,vl=class sn extends P{dereference(e){return new sn(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new sn(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 sn?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return this._def.innerType.mandatory()}};l(vl,"ZodOptionalImpl");var dm=vl,_l=class an extends P{dereference(e){return new an(f(c({},this._def),{in:this._def.in.dereference(e),out:this._def.out.dereference(e)}))}getReferences(){return _e.unique([...this._def.in.getReferences(),...this._def.out.getReferences()])}clone(){return new an(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 an)||!this._def.in.isEqual(e._def.in)||!this._def.out.isEqual(e._def.out))}};l(_l,"ZodPipelineImpl");var pm=_l,Tl=class on extends P{unwrap(){return this._def.type}dereference(e){return new on(f(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new on(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?(y(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 on?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}};l(Tl,"ZodPromiseImpl");var fm=Tl,bl=class kt 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 kt(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new kt(f(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){let n=this._def.innerType._parse(e);return gn(n)?n.then(this._freeze):this._freeze(n)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof kt?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new kt(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};l(bl,"ZodReadonlyImpl");var gm=bl,wl=class ln 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 ln(f(c({},this._def),{keyType:n,valueType:r}))}getReferences(){return _e.unique([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new ln(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 y(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 ve(r,o,r.path,o)),value:a._parse(new ve(r,r.data[o],r.path,o))});return r.common.async?se.mergeObjectAsync(n,i):se.mergeObjectSync(n,i)}get element(){return this._def.valueType}isEqual(e){return!(!(e instanceof ln)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};l(wl,"ZodRecordImpl");var qi=wl,xl=class Pl 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 y(n,{code:"unresolved_reference"}),{status:"aborted"}}isOptional(){return!1}isNullable(){return!1}isEqual(e){return e instanceof Pl?this._def.uri===e._def.uri:!1}};l(xl,"ZodRefImpl");var mm=xl,Sl=class ot extends P{dereference(e){return new ot(f(c({},this._def),{valueType:this._def.valueType.dereference(e)}))}getReferences(){return this._def.valueType.getReferences()}clone(){return new ot(f(c({},this._def),{valueType:this._def.valueType.clone()}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!=="set")return y(r,{code:"invalid_type",expected:"set",received:r.parsedType}),{status:"aborted"};let i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(y(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&&(y(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 ve(r,u,r.path,d)));return r.common.async?Promise.all(o).then(u=>a(u)):a(o)}min(e,n){return new ot(f(c({},this._def),{minSize:{value:e,message:b.toString(n)}}))}max(e,n){return new ot(f(c({},this._def),{maxSize:{value:e,message:b.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 ot))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(Sl,"ZodSetImpl");var ym=Sl,hm=/^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})+$",er,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 kl(t,e){return!!((e==="v4"||!e)&&xm.test(t)||(e==="v6"||!e)&&Pm.test(t))}l(kl,"isValidIP");var Il=class lt extends P{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!=="string"){let s=this._getOrReturnCtx(e);return y(s,{code:"invalid_type",expected:"string",received:s.parsedType}),{status:"aborted"}}let r=new se,i;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),y(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),y(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?y(i,{code:"too_big",maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&y(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),y(i,{validation:"email",code:"invalid_string",message:s.message}),r.dirty());else if(s.kind==="emoji")er||(er=new RegExp(wm,"u")),er.test(e.data)||(i=this._getOrReturnCtx(e,i),y(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),y(i,{validation:"uuid",code:"invalid_string",message:s.message}),r.dirty());else if(s.kind==="cuid")hm.test(e.data)||(i=this._getOrReturnCtx(e,i),y(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),y(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),y(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),y(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),y(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),y(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),y(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),y(i,{code:"invalid_string",validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?Oo.generateDatetimeRegex(s).test(e.data)||(i=this._getOrReturnCtx(e,i),y(i,{code:"invalid_string",validation:"datetime",message:s.message}),r.dirty()):s.kind==="ip"?kl(e.data,s.version)||(i=this._getOrReturnCtx(e,i),y(i,{validation:"ip",code:"invalid_string",message:s.message}),r.dirty()):fe.assertNever(s);return{status:r.value,value:e.data}}_addCheck(e){return new lt(f(c({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(c({kind:"email"},b.errToObj(e)))}url(e){return this._addCheck(c({kind:"url"},b.errToObj(e)))}emoji(e){return this._addCheck(c({kind:"emoji"},b.errToObj(e)))}uuid(e){return this._addCheck(c({kind:"uuid"},b.errToObj(e)))}cuid(e){return this._addCheck(c({kind:"cuid"},b.errToObj(e)))}cuid2(e){return this._addCheck(c({kind:"cuid2"},b.errToObj(e)))}ulid(e){return this._addCheck(c({kind:"ulid"},b.errToObj(e)))}ip(e){return this._addCheck(c({kind:"ip"},b.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},b.errToObj(e?.message)))}regex(e,n){return this._addCheck(c({kind:"regex",regex:e},b.errToObj(n)))}includes(e,n){return this._addCheck(c({kind:"includes",value:e,position:n?.position},b.errToObj(n?.message)))}startsWith(e,n){return this._addCheck(c({kind:"startsWith",value:e},b.errToObj(n)))}endsWith(e,n){return this._addCheck(c({kind:"endsWith",value:e},b.errToObj(n)))}min(e,n){return this._addCheck(c({kind:"min",value:e},b.errToObj(n)))}max(e,n){return this._addCheck(c({kind:"max",value:e},b.errToObj(n)))}length(e,n){return this._addCheck(c({kind:"length",value:e},b.errToObj(n)))}nonempty(e){return this.min(1,b.errToObj(e))}trim(){return new lt(f(c({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}secret(){return this._def[C]=f(c({},this._def[C]),{secret:!0}),this}toLowerCase(){return new lt(f(c({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new lt(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 lt))return!1;let n=new $.CustomSet(this._def.checks),r=new $.CustomSet(e._def.checks);return n.isEqual(r)}};l(Il,"ZodStringImpl");var Sm=Il,Ol=class El extends P{_parse(e){if(this._getType(e)!=="symbol"){let r=this._getOrReturnCtx(e);return y(r,{code:"invalid_type",expected:"symbol",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof El}};l(Ol,"ZodSymbolImpl");var km=Ol,Bl=class It extends P{innerType(){return this._def.schema}sourceType(){return E.zuiEffects(this._def.schema)?this._def.schema.sourceType():this._def.schema}dereference(e){return new It(f(c({},this._def),{schema:this._def.schema.dereference(e)}))}getReferences(){return this._def.schema.getReferences()}clone(){return new It(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)));fe.assertNever(r)}_processResult(e,n){if(n.status!=="valid")for(let r of n.issues)y(e,r)}isEqual(e){return!(e instanceof It)||!this._def.schema.isEqual(e._def.schema)?!1:this._def.effect.type==="upstream"?e._def.effect.type!=="upstream"?!1:pe.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:pe.compareFunctions(this._def.effect.effect,e._def.effect.effect):(this._def.effect,!1)}naked(){return this._def.schema.naked()}mandatory(){return new It(f(c({},this._def),{schema:this._def.schema.mandatory()}))}};l(Bl,"ZodEffectsImpl");var Br=Bl,Cl=class Ot 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 Ot(f(c({},this._def),{items:n,rest:r}))}getReferences(){return _e.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 Ot(f(c({},this._def),{items:e,rest:n}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!=="array")return y(r,{code:"invalid_type",expected:"array",received:r.parsedType}),{status:"aborted"};if(r.data.length<this._def.items.length)return y(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&&(y(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 ve(r,a,r.path,o)):null}).filter(a=>!!a);return r.common.async?Promise.all(s).then(a=>se.mergeArray(n,a)):se.mergeArray(n,s)}get items(){return this._def.items}rest(e){return new Ot(f(c({},this._def),{rest:e}))}isEqual(e){if(!(e instanceof Ot)||!this._restEquals(e))return!1;let 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(Cl,"ZodTupleImpl");var Im=Cl,Al=class Zl extends P{_parse(e){if(this._getType(e)!=="undefined"){let r=this._getOrReturnCtx(e);return y(r,{code:"invalid_type",expected:"undefined",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof Zl}mandatory(){return R.never(c({},this._def))}};l(Al,"ZodUndefinedImpl");var Om=Al,Rl=class Et extends P{dereference(e){let n=this._def.options.map(r=>r.dereference(e));return new Et(f(c({},this._def),{options:n}))}getReferences(){return _e.unique(this._def.options.reduce((e,n)=>[...e,...n.getReferences()],[]))}clone(){let e=this._def.options.map(n=>n.clone());return new Et(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 Pe(o.ctx.common.issues));return y(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 Pe(u));return y(n,{code:"invalid_union",unionErrors:o}),{status:"aborted"}}}get options(){return this._def.options}isEqual(e){if(!(e instanceof Et))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=>!E.zuiUndefined(s)).map(s=>s.mandatory()),[n,r,...i]=e;return n?r?new Et(f(c({},this._def),{options:[n,r,...i]})):n:R.never(c({},this._def))}};l(Rl,"ZodUnionImpl");var Em=Rl,Nl=class Dl extends P{constructor(){super(...arguments),this._unknown=!0}_parse(e){return{status:"valid",value:e.data}}isEqual(e){return e instanceof Dl}};l(Nl,"ZodUnknownImpl");var Bm=Nl,Hl=class Ml extends P{_parse(e){if(this._getType(e)!=="undefined"){let r=this._getOrReturnCtx(e);return y(r,{code:"invalid_type",expected:"void",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof Ml}};l(Hl,"ZodVoidImpl");var Cm=Hl,Am=l(t=>t instanceof Error,"_isError"),Zm=l(t=>typeof t=="object"&&t!==null,"_isObject"),E={zuiError:t=>t instanceof Pe||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"},S=l(t=>{if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:i,supportsExtensions:s,[C]: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,[C]: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,[C]:o}},"_processCreateParams"),Pn=l((t,e={},n)=>t?Fe().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)?Yr(c({code:"custom"},a)):Xr(r,c({code:"custom"},a))}}):Fe(),"customType"),Cr=l((t,e={message:`Input not instance of ${t.name}`})=>Pn(n=>n instanceof t,e),"instanceOfType"),Fe=l(t=>new Wg(c({typeName:"ZodAny"},S(t))),"anyType"),Ze=l(t=>new Bm(c({typeName:"ZodUnknown"},S(t))),"unknownType"),Mt=l(t=>new om(c({typeName:"ZodNever"},S(t))),"neverType"),Ar=l(t=>new Cm(c({typeName:"ZodVoid"},S(t))),"voidType"),Lt=l(t=>new lm(c({typeName:"ZodNull"},S(t))),"nullType"),Sn=l(t=>new Om(c({typeName:"ZodUndefined"},S(t))),"undefinedType"),Zr=l(t=>new km(c({typeName:"ZodSymbol"},S(t))),"symbolType"),Rr=l(t=>new sm(c({typeName:"ZodNaN"},S(t))),"nanType"),ke=l(t=>{var e;return new Sm(c({checks:[],typeName:"ZodString",coerce:(e=t?.coerce)!=null?e:!1},S(f(c({},t),{supportsExtensions:["secret"]}))))},"stringType"),et=l(t=>new cm(c({checks:[],typeName:"ZodNumber",coerce:t?.coerce||!1},S(t))),"numberType"),tt=l(t=>new qg(c({typeName:"ZodBoolean",coerce:t?.coerce||!1},S(t))),"booleanType"),kn=l(t=>{var e;return new Fg(c({checks:[],typeName:"ZodBigInt",coerce:(e=t?.coerce)!=null?e:!1},S(t)))},"bigIntType"),In=l(t=>new Jg(c({checks:[],coerce:t?.coerce||!1,typeName:"ZodDate"},S(t))),"dateType"),On=l(t=>new mm({typeName:"ZodRef",uri:t}),"refType"),jt=l((t,e)=>new rm(c({value:t,typeName:"ZodLiteral"},S(e))),"literalType"),En=l((t,e)=>new Qg(c({values:t,typeName:"ZodEnum"},S(e))),"enumType"),Nr=l((t,e)=>new am(c({values:t,typeName:"ZodNativeEnum"},S(e))),"nativeEnumType"),Ke=l((t,e)=>new Lg(c({type:t,minLength:null,maxLength:null,exactLength:null,typeName:"ZodArray"},S(e))),"arrayType"),dt=l((t,e)=>new hl(c({shape:()=>t,unknownKeys:"strip",typeName:"ZodObject"},S(e))),"objectType"),Dr=l((t,e)=>new hl(c({shape:()=>t,unknownKeys:"strict",typeName:"ZodObject"},S(e))),"strictObjectType"),We=l((t,e)=>new Em(c({options:t,typeName:"ZodUnion"},S(e))),"unionType"),$t=l((t,e,n)=>new Xg(c({typeName:"ZodDiscriminatedUnion",discriminator:t,options:e},S(n))),"discriminatedUnionType"),Ut=l((t,e,n)=>new tm(c({left:t,right:e,typeName:"ZodIntersection"},S(n))),"intersectionType"),Ft=l((t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Im(c({items:t,typeName:"ZodTuple",rest:null},S(e)))},"tupleType"),zt=l((t,e,n)=>e instanceof P?new qi(c({keyType:t,valueType:e,typeName:"ZodRecord"},S(n))):new qi(c({keyType:ke(),valueType:t,typeName:"ZodRecord"},S(e))),"recordType"),Hr=l((t,e,n)=>new im(c({valueType:e,keyType:t,typeName:"ZodMap"},S(n))),"mapType"),Bn=l((t,e)=>new ym(c({valueType:t,minSize:null,maxSize:null,typeName:"ZodSet"},S(e))),"setType"),Mr=l((t,e)=>new nm(c({getter:t,typeName:"ZodLazy"},S(e))),"lazyType"),jr=l((t,e)=>new fm(c({type:t,typeName:"ZodPromise"},S(e))),"promiseType"),$r=l((t,e,n)=>new em(c({args:t||Ft([]).rest(Ze()),returns:e||Ze(),typeName:"ZodFunction"},S(n))),"functionType"),Ur=l((t,e,n)=>new Br(c({schema:e,effect:{type:"upstream",effect:(r,i)=>{let s=t(r,i);return s instanceof Promise?s.then(a=>mn(a)):mn(s)}},typeName:"ZodEffects"},S(n))),"preprocessType"),zr=l((t,e,n)=>new Br(c({schema:e,effect:{type:"upstream",effect:t},typeName:"ZodEffects"},S(n))),"upstreamType"),Kr=l((t,e,n)=>new Br(c({schema:t,effect:{type:"downstream",effect:e,failFast:n?.failFast},typeName:"ZodEffects"},S(n))),"downstreamType"),Wr=l((t,e)=>new dm(c({innerType:t,typeName:"ZodOptional"},S(e))),"optionalType"),Lr=l((t,e)=>new um(c({innerType:t,typeName:"ZodNullable"},S(e))),"nullableType"),Fr=l((t,e)=>new gm(c({innerType:t,typeName:"ZodReadonly"},S(e))),"readonlyType"),qr=l((t,e,n)=>new Yg(c({innerType:t,typeName:"ZodDefault",defaultValue:typeof e=="function"?e:()=>e},S(n))),"defaultType"),Vr=l((t,e,n)=>new Gg(c({innerType:t,typeName:"ZodCatch",catchValue:typeof e=="function"?e:()=>e},S(n))),"catchType"),Gr=l((t,e)=>new pm({in:t,out:e,typeName:"ZodPipeline"}),"pipelineType"),Jr=l(t=>new Vg(c({typeName:"ZodBranded",type:t},S({supportsExtensions:["secret"]}))),"brandedType");No({any:Fe,array:Ke,bigint:kn,boolean:tt,branded:Jr,catch:Vr,custom:Pn,date:In,default:qr,discriminatedUnion:$t,enum:En,function:$r,instanceof:Cr,intersection:Ut,lazy:Mr,literal:jt,map:Hr,nan:Rr,nativeEnum:Nr,never:Mt,null:Lt,nullable:Lr,number:et,object:dt,optional:Wr,pipeline:Gr,preprocess:Ur,upstream:zr,downstream:Kr,promise:jr,record:zt,ref:On,readonly:Fr,set:Bn,strictObject:Dr,string:ke,symbol:Zr,tuple:Ft,undefined:Sn,union:We,unknown:Ze,void:Ar});var jl={string(t){return ke(f(c({},t),{coerce:!0}))},number(t){return et(f(c({},t),{coerce:!0}))},boolean(t){return tt(f(c({},t),{coerce:!0}))},bigint(t){return kn(f(c({},t),{coerce:!0}))},date(t){return In(f(c({},t),{coerce:!0}))}},mn=l(t=>({status:"valid",value:t}),"OK"),Yr=l((t,...e)=>({status:"aborted",issues:[t,...e]}),"ERR"),Xr=l((t,e,...n)=>({status:"dirty",value:t,issues:[e,...n]}),"DIRTY"),$l={};ge($l,{JSONSchemaToZuiError:()=>Cn,ObjectToZuiError:()=>yr,UnrepresentableGenericError:()=>hr,UnsupportedJSONSchemaToZuiError:()=>$e,UnsupportedZuiCheckToJSONSchemaError:()=>Vl,UnsupportedZuiToJSONSchemaError:()=>Y,UnsupportedZuiToTypescriptSchemaError:()=>Ue,UnsupportedZuiToTypescriptTypeError:()=>eu,UntitledDeclarationError:()=>nu,ZuiToJSONSchemaError:()=>An,ZuiToTypescriptSchemaError:()=>Jl,ZuiToTypescriptTypeError:()=>Zn,ZuiTransformError:()=>pt});var Ul=class extends Error{constructor(e,n,r){let i=r?`${r} : ${n}`:n;super(i),this.transform=e,this.path=r}};l(Ul,"ZuiTransformError");var pt=Ul,zl=class extends pt{constructor(e,n){super("json-schema-to-zui",e,n)}};l(zl,"JSONSchemaToZuiError");var Cn=zl,Kl=class extends Cn{constructor(e,n){super(`JSON Schema ${JSON.stringify(e)} cannot be transformed to ZUI type.`,n)}};l(Kl,"UnsupportedJSONSchemaToZuiError");var $e=Kl,Wl=class extends pt{constructor(e,n){super("object-to-zui",e,n)}};l(Wl,"ObjectToZuiError");var yr=Wl,Ll=class extends pt{constructor(e,n){super("zui-to-json-schema",e,n)}};l(Ll,"ZuiToJSONSchemaError");var An=Ll,Fl=class extends An{constructor(e,n,{suggestedAlternative:r}={}){let i=r?`Zod type ${e} cannot be transformed to JSON Schema. Suggested alternative: ${r}`:`Zod type ${e} cannot be transformed to JSON Schema.`;super(i,n)}};l(Fl,"UnsupportedZuiToJSONSchemaError");var Y=Fl,ql=class extends An{constructor(e,n,r){super(`Zod check .${n}() of type ${e} cannot be transformed to JSON Schema.`,r)}};l(ql,"UnsupportedZuiCheckToJSONSchemaError");var Vl=ql,Gl=class extends pt{constructor(e,n){super("zui-to-typescript-schema",e,n)}};l(Gl,"ZuiToTypescriptSchemaError");var Jl=Gl,Yl=class extends Jl{constructor(e,n){super(`Zod type ${e} cannot be transformed to TypeScript schema.`,n)}};l(Yl,"UnsupportedZuiToTypescriptSchemaError");var Ue=Yl,Xl=class extends pt{constructor(e,n){super("zui-to-typescript-type",e,n)}};l(Xl,"ZuiToTypescriptTypeError");var Zn=Xl,Ql=class extends Zn{constructor(e,n){super(`Zod type ${e} cannot be transformed to TypeScript type.`,n)}};l(Ql,"UnsupportedZuiToTypescriptTypeError");var eu=Ql,tu=class extends Zn{constructor(){super("Schema must have a title to be transformed to a TypeScript type with a declaration.")}};l(tu,"UntitledDeclarationError");var nu=tu,ru=class extends Zn{constructor(){super('ZodRef can only be transformed to a TypeScript type with a "type" declaration.')}};l(ru,"UnrepresentableGenericError");var hr=ru,Rm=l(t=>{let e;try{e=new Function("z",`return ${t}`)(Ie)}catch(n){return{sucess:!1,error:`Failed to evaluate schema: ${(n instanceof Error?n:new Error(String(n))).message}`}}return E.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 V(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(V,"withMessage");var Bt=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?{[Bt]:n}:{[Bt]:n,not:{}});else{if(Bt in r)return t;e.push(f(c({},r),{[Bt]:n}))}}return e},"ensureOriginalIndex");function Kt(t,e){if(t.allOf.length===0)return"z.never()";if(t.allOf.length===1){let n=t.allOf[0];return F(n,f(c({},e),{path:[...e.path,"allOf",n[Bt]]}))}else{let[n,r]=Nm(Hm(t.allOf));return`z.intersection(${Kt({allOf:n},e)}, ${Kt({allOf:r},e)})`}}l(Kt,"parseAllOf");var iu=l((t,e)=>t.anyOf.length?t.anyOf.length===1?F(t.anyOf[0],f(c({},e),{path:[...e.path,"anyOf",0]})):`z.union([${t.anyOf.map((n,r)=>F(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)=>F(r,f(c({},e),{path:[...e.path,"items",i]})))}])`;let n=t.items?`z.array(${F(t.items,f(c({},e),{path:[...e.path,"items"]}))})`:"z.array(z.any())";return n+=V(t,"minItems",({json:r})=>[`.min(${r}`,", ",")"]),n+=V(t,"maxItems",({json:r})=>[`.max(${r}`,", ",")"]),n},"parseArray"),jm=l(t=>{var e;return(e=t[C])!=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"),Qr=l((t,e)=>t.oneOf.length?t.oneOf.length===1?F(t.oneOf[0],f(c({},e),{path:[...e.path,"oneOf",0]})):`z.any().superRefine((x, ctx) => {
|
|
1
|
+
"use strict";var kc=Object.create;var Jt=Object.defineProperty;var Ic=Object.getOwnPropertyDescriptor;var Oc=Object.getOwnPropertyNames;var Ec=Object.getPrototypeOf,Bc=Object.prototype.hasOwnProperty;var De=(t,e)=>{for(var n in e)Jt(t,n,{get:e[n],enumerable:!0})},Ti=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Oc(e))!Bc.call(t,i)&&i!==n&&Jt(t,i,{get:()=>e[i],enumerable:!(r=Ic(e,i))||r.enumerable});return t};var Yn=(t,e,n)=>(n=t!=null?kc(Ec(t)):{},Ti(e||!t||!t.__esModule?Jt(n,"default",{value:t,enumerable:!0}):n,t)),Cc=t=>Ti(Jt({},"__esModule",{value:!0}),t);var gv={};De(gv,{Bot:()=>Fn,BotDefinition:()=>Ln,BotLogger:()=>yt,BotSpecificClient:()=>Te,Integration:()=>Un,IntegrationDefinition:()=>Nn,IntegrationLogger:()=>mt,IntegrationSpecificClient:()=>ft,InterfaceDefinition:()=>qn,OAUTH_IDENTIFIER_HEADER:()=>xh,Plugin:()=>Gn,PluginDefinition:()=>Vn,RuntimeError:()=>Jn.RuntimeError,WELL_KNOWN_ATTRIBUTES:()=>wh,errors:()=>ci,isApiError:()=>Jn.isApiError,messages:()=>li,parseBody:()=>oe,serve:()=>Vt,version:()=>_i,z:()=>v});module.exports=Cc(gv);var li={};De(li,{defaults:()=>bh,markdown:()=>_h,markdownBloc:()=>Th});var xr=Object.defineProperty,Ac=Object.defineProperties,Rc=Object.getOwnPropertyDescriptors,cn=Object.getOwnPropertySymbols,rs=Object.prototype.hasOwnProperty,is=Object.prototype.propertyIsEnumerable,bi=(t,e,n)=>e in t?xr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,c=(t,e)=>{for(var n in e||(e={}))rs.call(e,n)&&bi(t,n,e[n]);if(cn)for(var n of cn(e))is.call(e,n)&&bi(t,n,e[n]);return t},f=(t,e)=>Ac(t,Rc(e)),l=(t,e)=>xr(t,"name",{value:e,configurable:!0}),ss=(t,e)=>{var n={};for(var r in t)rs.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&cn)for(var r of cn(t))e.indexOf(r)<0&&is.call(t,r)&&(n[r]=t[r]);return n},ge=(t,e)=>{for(var n in e)xr(t,n,{get:e[n],enumerable:!0})},v={};ge(v,{DIRTY:()=>ei,ERR:()=>Qr,OK:()=>mn,any:()=>Fe,array:()=>Ke,bigint:()=>kn,boolean:()=>tt,branded:()=>Xr,catch:()=>Jr,coerce:()=>zl,custom:()=>Pn,date:()=>In,default:()=>Gr,discriminatedUnion:()=>$t,downstream:()=>Lr,enum:()=>En,function:()=>Ur,instanceof:()=>Rr,intersection:()=>zt,is:()=>E,lazy:()=>$r,literal:()=>jt,map:()=>jr,nan:()=>Nr,nativeEnum:()=>Hr,never:()=>Mt,null:()=>Lt,nullable:()=>qr,number:()=>et,object:()=>dt,optional:()=>Fr,pipeline:()=>Yr,preprocess:()=>Kr,promise:()=>zr,readonly:()=>Vr,record:()=>Ut,ref:()=>On,set:()=>Bn,strictObject:()=>Mr,string:()=>ke,symbol:()=>Dr,transforms:()=>as,tuple:()=>Ft,undefined:()=>Sn,union:()=>We,unknown:()=>Re,upstream:()=>Wr,void:()=>Zr,zuiKey:()=>C});var as={};ge(as,{errors:()=>Ul,fromJSONSchema:()=>cu,fromJSONSchemaLegacy:()=>sy,fromObject:()=>by,json:()=>yh,toJSONSchema:()=>si,toJSONSchemaLegacy:()=>Ny,toTypescriptSchema:()=>oi,toTypescriptType:()=>ai});var Ie={};ge(Ie,{DIRTY:()=>ei,ERR:()=>Qr,OK:()=>mn,any:()=>Fe,array:()=>Ke,bigint:()=>kn,boolean:()=>tt,branded:()=>Xr,catch:()=>Jr,coerce:()=>zl,custom:()=>Pn,date:()=>In,default:()=>Gr,discriminatedUnion:()=>$t,downstream:()=>Lr,enum:()=>En,function:()=>Ur,instanceof:()=>Rr,intersection:()=>zt,is:()=>E,lazy:()=>$r,literal:()=>jt,map:()=>jr,nan:()=>Nr,nativeEnum:()=>Hr,never:()=>Mt,null:()=>Lt,nullable:()=>qr,number:()=>et,object:()=>dt,optional:()=>Fr,pipeline:()=>Yr,preprocess:()=>Kr,promise:()=>zr,readonly:()=>Vr,record:()=>Ut,ref:()=>On,set:()=>Bn,strictObject:()=>Mr,string:()=>ke,symbol:()=>Dr,tuple:()=>Ft,undefined:()=>Sn,union:()=>We,unknown:()=>Re,upstream:()=>Wr,void:()=>Zr,zuiKey:()=>C});var C="x-zui",$={};ge($,{CustomSet:()=>Hg});var _e={};ge(_e,{isEqual:()=>So,unique:()=>Dg});var Zc=typeof global=="object"&&global&&global.Object===Object&&global,os=Zc,Dc=typeof self=="object"&&self&&self.Object===Object&&self,Nc=os||Dc||Function("return this")(),Oe=Nc,Hc=Oe.Symbol,Ae=Hc,ls=Object.prototype,Mc=ls.hasOwnProperty,jc=ls.toString,ht=Ae?Ae.toStringTag:void 0;function us(t){var e=Mc.call(t,ht),n=t[ht];try{t[ht]=void 0;var r=!0}catch{}var i=jc.call(t);return r&&(e?t[ht]=n:delete t[ht]),i}l(us,"getRawTag");var $c=us,zc=Object.prototype,Uc=zc.toString;function cs(t){return Uc.call(t)}l(cs,"objectToString");var Kc=cs,Wc="[object Null]",Lc="[object Undefined]",wi=Ae?Ae.toStringTag:void 0;function ds(t){return t==null?t===void 0?Lc:Wc:wi&&wi in Object(t)?$c(t):Kc(t)}l(ds,"baseGetTag");var qe=ds;function ps(t){return t!=null&&typeof t=="object"}l(ps,"isObjectLike");var Le=ps,Fc="[object Symbol]";function fs(t){return typeof t=="symbol"||Le(t)&&qe(t)==Fc}l(fs,"isSymbol");var Pr=fs;function gs(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(gs,"arrayMap");var ms=gs,qc=Array.isArray,Se=qc,Vc=1/0,xi=Ae?Ae.prototype:void 0,Pi=xi?xi.toString:void 0;function Sr(t){if(typeof t=="string")return t;if(Se(t))return ms(t,Sr)+"";if(Pr(t))return Pi?Pi.call(t):"";var e=t+"";return e=="0"&&1/t==-Vc?"-0":e}l(Sr,"baseToString");var Gc=Sr;function ys(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}l(ys,"isObject");var ct=ys;function hs(t){return t}l(hs,"identity");var Jc=hs,Yc="[object AsyncFunction]",Xc="[object Function]",Qc="[object GeneratorFunction]",ed="[object Proxy]";function vs(t){if(!ct(t))return!1;var e=qe(t);return e==Xc||e==Qc||e==Yc||e==ed}l(vs,"isFunction");var _s=vs,td=Oe["__core-js_shared__"],Xn=td,Si=(function(){var t=/[^.]+$/.exec(Xn&&Xn.keys&&Xn.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function Ts(t){return!!Si&&Si in t}l(Ts,"isMasked");var nd=Ts,rd=Function.prototype,id=rd.toString;function bs(t){if(t!=null){try{return id.call(t)}catch{}try{return t+""}catch{}}return""}l(bs,"toSource");var Ve=bs,sd=/[\\^$.*+?()[\]{}|]/g,ad=/^\[object .+?Constructor\]$/,od=Function.prototype,ld=Object.prototype,ud=od.toString,cd=ld.hasOwnProperty,dd=RegExp("^"+ud.call(cd).replace(sd,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ws(t){if(!ct(t)||nd(t))return!1;var e=_s(t)?dd:ad;return e.test(Ve(t))}l(ws,"baseIsNative");var pd=ws;function xs(t,e){return t?.[e]}l(xs,"getValue");var fd=xs;function Ps(t,e){var n=fd(t,e);return pd(n)?n:void 0}l(Ps,"getNative");var Ge=Ps,gd=Ge(Oe,"WeakMap"),cr=gd,md=(function(){try{var t=Ge(Object,"defineProperty");return t({},"",{}),t}catch{}})(),ki=md,yd=9007199254740991,hd=/^(?:0|[1-9]\d*)$/;function Ss(t,e){var n=typeof t;return e=e??yd,!!e&&(n=="number"||n!="symbol"&&hd.test(t))&&t>-1&&t%1==0&&t<e}l(Ss,"isIndex");var kr=Ss;function ks(t,e,n){e=="__proto__"&&ki?ki(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}l(ks,"baseAssignValue");var vd=ks;function Is(t,e){return t===e||t!==t&&e!==e}l(Is,"eq");var Ir=Is,_d=Object.prototype,Td=_d.hasOwnProperty;function Os(t,e,n){var r=t[e];(!(Td.call(t,e)&&Ir(r,n))||n===void 0&&!(e in t))&&vd(t,e,n)}l(Os,"assignValue");var bd=Os,wd=9007199254740991;function Es(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=wd}l(Es,"isLength");var Or=Es;function Bs(t){return t!=null&&Or(t.length)&&!_s(t)}l(Bs,"isArrayLike");var Cs=Bs,xd=Object.prototype;function As(t){var e=t&&t.constructor,n=typeof e=="function"&&e.prototype||xd;return t===n}l(As,"isPrototype");var Rs=As;function Zs(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}l(Zs,"baseTimes");var Pd=Zs,Sd="[object Arguments]";function Ds(t){return Le(t)&&qe(t)==Sd}l(Ds,"baseIsArguments");var Ii=Ds,Ns=Object.prototype,kd=Ns.hasOwnProperty,Id=Ns.propertyIsEnumerable,Od=Ii((function(){return arguments})())?Ii:function(t){return Le(t)&&kd.call(t,"callee")&&!Id.call(t,"callee")},Hs=Od;function Ms(){return!1}l(Ms,"stubFalse");var Ed=Ms,js=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Oi=js&&typeof module=="object"&&module&&!module.nodeType&&module,Bd=Oi&&Oi.exports===js,Ei=Bd?Oe.Buffer:void 0,Cd=Ei?Ei.isBuffer:void 0,Ad=Cd||Ed,dr=Ad,Rd="[object Arguments]",Zd="[object Array]",Dd="[object Boolean]",Nd="[object Date]",Hd="[object Error]",Md="[object Function]",jd="[object Map]",$d="[object Number]",zd="[object Object]",Ud="[object RegExp]",Kd="[object Set]",Wd="[object String]",Ld="[object WeakMap]",Fd="[object ArrayBuffer]",qd="[object DataView]",Vd="[object Float32Array]",Gd="[object Float64Array]",Jd="[object Int8Array]",Yd="[object Int16Array]",Xd="[object Int32Array]",Qd="[object Uint8Array]",ep="[object Uint8ClampedArray]",tp="[object Uint16Array]",np="[object Uint32Array]",R={};R[Vd]=R[Gd]=R[Jd]=R[Yd]=R[Xd]=R[Qd]=R[ep]=R[tp]=R[np]=!0;R[Rd]=R[Zd]=R[Fd]=R[Dd]=R[qd]=R[Nd]=R[Hd]=R[Md]=R[jd]=R[$d]=R[zd]=R[Ud]=R[Kd]=R[Wd]=R[Ld]=!1;function $s(t){return Le(t)&&Or(t.length)&&!!R[qe(t)]}l($s,"baseIsTypedArray");var rp=$s;function zs(t){return function(e){return t(e)}}l(zs,"baseUnary");var ip=zs,Us=typeof exports=="object"&&exports&&!exports.nodeType&&exports,At=Us&&typeof module=="object"&&module&&!module.nodeType&&module,sp=At&&At.exports===Us,Qn=sp&&os.process,ap=(function(){try{var t=At&&At.require&&At.require("util").types;return t||Qn&&Qn.binding&&Qn.binding("util")}catch{}})(),Bi=ap,Ci=Bi&&Bi.isTypedArray,op=Ci?ip(Ci):rp,Ks=op,lp=Object.prototype,up=lp.hasOwnProperty;function Ws(t,e){var n=Se(t),r=!n&&Hs(t),i=!n&&!r&&dr(t),s=!n&&!r&&!i&&Ks(t),a=n||r||i||s,o=a?Pd(t.length,String):[],u=o.length;for(var d in t)(e||up.call(t,d))&&!(a&&(d=="length"||i&&(d=="offset"||d=="parent")||s&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||kr(d,u)))&&o.push(d);return o}l(Ws,"arrayLikeKeys");var Ls=Ws;function Fs(t,e){return function(n){return t(e(n))}}l(Fs,"overArg");var qs=Fs,cp=qs(Object.keys,Object),dp=cp,pp=Object.prototype,fp=pp.hasOwnProperty;function Vs(t){if(!Rs(t))return dp(t);var e=[];for(var n in Object(t))fp.call(t,n)&&n!="constructor"&&e.push(n);return e}l(Vs,"baseKeys");var gp=Vs;function Gs(t){return Cs(t)?Ls(t):gp(t)}l(Gs,"keys");var Js=Gs;function Ys(t){var e=[];if(t!=null)for(var n in Object(t))e.push(n);return e}l(Ys,"nativeKeysIn");var mp=Ys,yp=Object.prototype,hp=yp.hasOwnProperty;function Xs(t){if(!ct(t))return mp(t);var e=Rs(t),n=[];for(var r in t)r=="constructor"&&(e||!hp.call(t,r))||n.push(r);return n}l(Xs,"baseKeysIn");var vp=Xs;function Qs(t){return Cs(t)?Ls(t,!0):vp(t)}l(Qs,"keysIn");var _p=Qs,Tp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,bp=/^\w*$/;function ea(t,e){if(Se(t))return!1;var n=typeof t;return n=="number"||n=="symbol"||n=="boolean"||t==null||Pr(t)?!0:bp.test(t)||!Tp.test(t)||e!=null&&t in Object(e)}l(ea,"isKey");var Er=ea,wp=Ge(Object,"create"),Dt=wp;function ta(){this.__data__=Dt?Dt(null):{},this.size=0}l(ta,"hashClear");var xp=ta;function na(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}l(na,"hashDelete");var Pp=na,Sp="__lodash_hash_undefined__",kp=Object.prototype,Ip=kp.hasOwnProperty;function ra(t){var e=this.__data__;if(Dt){var n=e[t];return n===Sp?void 0:n}return Ip.call(e,t)?e[t]:void 0}l(ra,"hashGet");var Op=ra,Ep=Object.prototype,Bp=Ep.hasOwnProperty;function ia(t){var e=this.__data__;return Dt?e[t]!==void 0:Bp.call(e,t)}l(ia,"hashHas");var Cp=ia,Ap="__lodash_hash_undefined__";function sa(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=Dt&&e===void 0?Ap:e,this}l(sa,"hashSet");var Rp=sa;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,"Hash");Je.prototype.clear=xp;Je.prototype.delete=Pp;Je.prototype.get=Op;Je.prototype.has=Cp;Je.prototype.set=Rp;var Ai=Je;function aa(){this.__data__=[],this.size=0}l(aa,"listCacheClear");var Zp=aa;function oa(t,e){for(var n=t.length;n--;)if(Ir(t[n][0],e))return n;return-1}l(oa,"assocIndexOf");var hn=oa,Dp=Array.prototype,Np=Dp.splice;function la(t){var e=this.__data__,n=hn(e,t);if(n<0)return!1;var r=e.length-1;return n==r?e.pop():Np.call(e,n,1),--this.size,!0}l(la,"listCacheDelete");var Hp=la;function ua(t){var e=this.__data__,n=hn(e,t);return n<0?void 0:e[n][1]}l(ua,"listCacheGet");var Mp=ua;function ca(t){return hn(this.__data__,t)>-1}l(ca,"listCacheHas");var jp=ca;function da(t,e){var n=this.__data__,r=hn(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}l(da,"listCacheSet");var $p=da;function Ye(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}l(Ye,"ListCache");Ye.prototype.clear=Zp;Ye.prototype.delete=Hp;Ye.prototype.get=Mp;Ye.prototype.has=jp;Ye.prototype.set=$p;var vn=Ye,zp=Ge(Oe,"Map"),Nt=zp;function pa(){this.size=0,this.__data__={hash:new Ai,map:new(Nt||vn),string:new Ai}}l(pa,"mapCacheClear");var Up=pa;function fa(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}l(fa,"isKeyable");var Kp=fa;function ga(t,e){var n=t.__data__;return Kp(e)?n[typeof e=="string"?"string":"hash"]:n.map}l(ga,"getMapData");var _n=ga;function ma(t){var e=_n(this,t).delete(t);return this.size-=e?1:0,e}l(ma,"mapCacheDelete");var Wp=ma;function ya(t){return _n(this,t).get(t)}l(ya,"mapCacheGet");var Lp=ya;function ha(t){return _n(this,t).has(t)}l(ha,"mapCacheHas");var Fp=ha;function va(t,e){var n=_n(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this}l(va,"mapCacheSet");var qp=va;function Xe(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(Xe,"MapCache");Xe.prototype.clear=Up;Xe.prototype.delete=Wp;Xe.prototype.get=Lp;Xe.prototype.has=Fp;Xe.prototype.set=qp;var Tn=Xe,Vp="Expected a function";function bn(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(Vp);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(bn.Cache||Tn),n}l(bn,"memoize");bn.Cache=Tn;var Gp=bn,Jp=500;function _a(t){var e=Gp(t,function(r){return n.size===Jp&&n.clear(),r}),n=e.cache;return e}l(_a,"memoizeCapped");var Yp=_a,Xp=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Qp=/\\(\\)?/g,ef=Yp(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(Xp,function(n,r,i,s){e.push(i?s.replace(Qp,"$1"):r||n)}),e}),tf=ef;function Ta(t){return t==null?"":Gc(t)}l(Ta,"toString");var nf=Ta;function ba(t,e){return Se(t)?t:Er(t,e)?[t]:tf(nf(t))}l(ba,"castPath");var wn=ba,rf=1/0;function wa(t){if(typeof t=="string"||Pr(t))return t;var e=t+"";return e=="0"&&1/t==-rf?"-0":e}l(wa,"toKey");var Wt=wa;function xa(t,e){e=wn(e,t);for(var n=0,r=e.length;t!=null&&n<r;)t=t[Wt(e[n++])];return n&&n==r?t:void 0}l(xa,"baseGet");var Br=xa;function Pa(t,e,n){var r=t==null?void 0:Br(t,e);return r===void 0?n:r}l(Pa,"get");var sf=Pa;function Sa(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t}l(Sa,"arrayPush");var ka=Sa,af=qs(Object.getPrototypeOf,Object),Ia=af,of="[object Object]",lf=Function.prototype,uf=Object.prototype,Oa=lf.toString,cf=uf.hasOwnProperty,df=Oa.call(Object);function Ea(t){if(!Le(t)||qe(t)!=of)return!1;var e=Ia(t);if(e===null)return!0;var n=cf.call(e,"constructor")&&e.constructor;return typeof n=="function"&&n instanceof n&&Oa.call(n)==df}l(Ea,"isPlainObject");var pf=Ea;function Ba(){this.__data__=new vn,this.size=0}l(Ba,"stackClear");var ff=Ba;function Ca(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}l(Ca,"stackDelete");var gf=Ca;function Aa(t){return this.__data__.get(t)}l(Aa,"stackGet");var mf=Aa;function Ra(t){return this.__data__.has(t)}l(Ra,"stackHas");var yf=Ra,hf=200;function Za(t,e){var n=this.__data__;if(n instanceof vn){var r=n.__data__;if(!Nt||r.length<hf-1)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new Tn(r)}return n.set(t,e),this.size=n.size,this}l(Za,"stackSet");var vf=Za;function Qe(t){var e=this.__data__=new vn(t);this.size=e.size}l(Qe,"Stack");Qe.prototype.clear=ff;Qe.prototype.delete=gf;Qe.prototype.get=mf;Qe.prototype.has=yf;Qe.prototype.set=vf;var Qt=Qe;function Da(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(Da,"arrayFilter");var _f=Da;function Na(){return[]}l(Na,"stubArray");var Ha=Na,Tf=Object.prototype,bf=Tf.propertyIsEnumerable,Ri=Object.getOwnPropertySymbols,wf=Ri?function(t){return t==null?[]:(t=Object(t),_f(Ri(t),function(e){return bf.call(t,e)}))}:Ha,Ma=wf,xf=Object.getOwnPropertySymbols,Pf=xf?function(t){for(var e=[];t;)ka(e,Ma(t)),t=Ia(t);return e}:Ha,Sf=Pf;function ja(t,e,n){var r=e(t);return Se(t)?r:ka(r,n(t))}l(ja,"baseGetAllKeys");var $a=ja;function za(t){return $a(t,Js,Ma)}l(za,"getAllKeys");var Zi=za;function Ua(t){return $a(t,_p,Sf)}l(Ua,"getAllKeysIn");var kf=Ua,If=Ge(Oe,"DataView"),pr=If,Of=Ge(Oe,"Promise"),fr=Of,Ef=Ge(Oe,"Set"),gr=Ef,Di="[object Map]",Bf="[object Object]",Ni="[object Promise]",Hi="[object Set]",Mi="[object WeakMap]",ji="[object DataView]",Cf=Ve(pr),Af=Ve(Nt),Rf=Ve(fr),Zf=Ve(gr),Df=Ve(cr),Me=qe;(pr&&Me(new pr(new ArrayBuffer(1)))!=ji||Nt&&Me(new Nt)!=Di||fr&&Me(fr.resolve())!=Ni||gr&&Me(new gr)!=Hi||cr&&Me(new cr)!=Mi)&&(Me=l(function(t){var e=qe(t),n=e==Bf?t.constructor:void 0,r=n?Ve(n):"";if(r)switch(r){case Cf:return ji;case Af:return Di;case Rf:return Ni;case Zf:return Hi;case Df:return Mi}return e},"getTag"));var $i=Me,Nf=Oe.Uint8Array,zi=Nf,Hf="__lodash_hash_undefined__";function Ka(t){return this.__data__.set(t,Hf),this}l(Ka,"setCacheAdd");var Mf=Ka;function Wa(t){return this.__data__.has(t)}l(Wa,"setCacheHas");var jf=Wa;function Ht(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new Tn;++e<n;)this.add(t[e])}l(Ht,"SetCache");Ht.prototype.add=Ht.prototype.push=Mf;Ht.prototype.has=jf;var $f=Ht;function La(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(La,"arraySome");var zf=La;function Fa(t,e){return t.has(e)}l(Fa,"cacheHas");var Uf=Fa,Kf=1,Wf=2;function qa(t,e,n,r,i,s){var a=n&Kf,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,m=!0,_=n&Wf?new $f:void 0;for(s.set(t,e),s.set(e,t);++g<o;){var h=t[g],A=e[g];if(r)var z=a?r(A,h,g,e,t,s):r(h,A,g,t,e,s);if(z!==void 0){if(z)continue;m=!1;break}if(_){if(!zf(e,function(Q,ee){if(!Uf(_,ee)&&(h===Q||i(h,Q,n,r,s)))return _.push(ee)})){m=!1;break}}else if(!(h===A||i(h,A,n,r,s))){m=!1;break}}return s.delete(t),s.delete(e),m}l(qa,"equalArrays");var Va=qa;function Ga(t){var e=-1,n=Array(t.size);return t.forEach(function(r,i){n[++e]=[i,r]}),n}l(Ga,"mapToArray");var Lf=Ga;function Ja(t){var e=-1,n=Array(t.size);return t.forEach(function(r){n[++e]=r}),n}l(Ja,"setToArray");var Ff=Ja,qf=1,Vf=2,Gf="[object Boolean]",Jf="[object Date]",Yf="[object Error]",Xf="[object Map]",Qf="[object Number]",eg="[object RegExp]",tg="[object Set]",ng="[object String]",rg="[object Symbol]",ig="[object ArrayBuffer]",sg="[object DataView]",Ui=Ae?Ae.prototype:void 0,er=Ui?Ui.valueOf:void 0;function Ya(t,e,n,r,i,s,a){switch(n){case sg:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case ig:return!(t.byteLength!=e.byteLength||!s(new zi(t),new zi(e)));case Gf:case Jf:case Qf:return Ir(+t,+e);case Yf:return t.name==e.name&&t.message==e.message;case eg:case ng:return t==e+"";case Xf:var o=Lf;case tg:var u=r&qf;if(o||(o=Ff),t.size!=e.size&&!u)return!1;var d=a.get(t);if(d)return d==e;r|=Vf,a.set(t,e);var p=Va(o(t),o(e),r,i,s,a);return a.delete(t),p;case rg:if(er)return er.call(t)==er.call(e)}return!1}l(Ya,"equalByTag");var ag=Ya,og=1,lg=Object.prototype,ug=lg.hasOwnProperty;function Xa(t,e,n,r,i,s){var a=n&og,o=Zi(t),u=o.length,d=Zi(e),p=d.length;if(u!=p&&!a)return!1;for(var g=u;g--;){var m=o[g];if(!(a?m in e:ug.call(e,m)))return!1}var _=s.get(t),h=s.get(e);if(_&&h)return _==e&&h==t;var A=!0;s.set(t,e),s.set(e,t);for(var z=a;++g<u;){m=o[g];var Q=t[m],ee=e[m];if(r)var U=a?r(ee,Q,m,e,t,s):r(Q,ee,m,t,e,s);if(!(U===void 0?Q===ee||i(Q,ee,n,r,s):U)){A=!1;break}z||(z=m=="constructor")}if(A&&!z){var K=t.constructor,ie=e.constructor;K!=ie&&"constructor"in t&&"constructor"in e&&!(typeof K=="function"&&K instanceof K&&typeof ie=="function"&&ie instanceof ie)&&(A=!1)}return s.delete(t),s.delete(e),A}l(Xa,"equalObjects");var cg=Xa,dg=1,Ki="[object Arguments]",Wi="[object Array]",Yt="[object Object]",pg=Object.prototype,Li=pg.hasOwnProperty;function Qa(t,e,n,r,i,s){var a=Se(t),o=Se(e),u=a?Wi:$i(t),d=o?Wi:$i(e);u=u==Ki?Yt:u,d=d==Ki?Yt:d;var p=u==Yt,g=d==Yt,m=u==d;if(m&&dr(t)){if(!dr(e))return!1;a=!0,p=!1}if(m&&!p)return s||(s=new Qt),a||Ks(t)?Va(t,e,n,r,i,s):ag(t,e,u,n,r,i,s);if(!(n&dg)){var _=p&&Li.call(t,"__wrapped__"),h=g&&Li.call(e,"__wrapped__");if(_||h){var A=_?t.value():t,z=h?e.value():e;return s||(s=new Qt),i(A,z,n,r,s)}}return m?(s||(s=new Qt),cg(t,e,n,r,i,s)):!1}l(Qa,"baseIsEqualDeep");var fg=Qa;function Cr(t,e,n,r,i){return t===e?!0:t==null||e==null||!Le(t)&&!Le(e)?t!==t&&e!==e:fg(t,e,n,r,Cr,i)}l(Cr,"baseIsEqual");var xn=Cr,gg=1,mg=2;function eo(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 m=r(d,p,u,t,e,g);if(!(m===void 0?xn(p,d,gg|mg,r,g):m))return!1}}return!0}l(eo,"baseIsMatch");var yg=eo;function to(t){return t===t&&!ct(t)}l(to,"isStrictComparable");var no=to;function ro(t){for(var e=Js(t),n=e.length;n--;){var r=e[n],i=t[r];e[n]=[r,i,no(i)]}return e}l(ro,"getMatchData");var hg=ro;function io(t,e){return function(n){return n==null?!1:n[t]===e&&(e!==void 0||t in Object(n))}}l(io,"matchesStrictComparable");var so=io;function ao(t){var e=hg(t);return e.length==1&&e[0][2]?so(e[0][0],e[0][1]):function(n){return n===t||yg(n,t,e)}}l(ao,"baseMatches");var vg=ao;function oo(t,e){return t!=null&&e in Object(t)}l(oo,"baseHasIn");var _g=oo;function lo(t,e,n){e=wn(e,t);for(var r=-1,i=e.length,s=!1;++r<i;){var a=Wt(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&&Or(i)&&kr(a,i)&&(Se(t)||Hs(t)))}l(lo,"hasPath");var Tg=lo;function uo(t,e){return t!=null&&Tg(t,e,_g)}l(uo,"hasIn");var bg=uo,wg=1,xg=2;function co(t,e){return Er(t)&&no(e)?so(Wt(t),e):function(n){var r=sf(n,t);return r===void 0&&r===e?bg(n,t):xn(e,r,wg|xg)}}l(co,"baseMatchesProperty");var Pg=co;function po(t){return function(e){return e?.[t]}}l(po,"baseProperty");var Sg=po;function fo(t){return function(e){return Br(e,t)}}l(fo,"basePropertyDeep");var kg=fo;function go(t){return Er(t)?Sg(Wt(t)):kg(t)}l(go,"property");var Ig=go;function mo(t){return typeof t=="function"?t:t==null?Jc:typeof t=="object"?Se(t)?Pg(t[0],t[1]):vg(t):Ig(t)}l(mo,"baseIteratee");var yo=mo;function ho(t,e){return xn(t,e)}l(ho,"isEqual");var Ce=ho;function vo(t,e,n){n=typeof n=="function"?n:void 0;var r=n?n(t,e):void 0;return r===void 0?xn(t,e,void 0,n):!!r}l(vo,"isEqualWith");var Og=vo;function _o(t){return t===void 0}l(_o,"isUndefined");var Fi=_o,Eg="Expected a function";function To(t){if(typeof t!="function")throw new TypeError(Eg);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(To,"negate");var Bg=To;function bo(t,e,n,r){if(!ct(t))return t;e=wn(e,t);for(var i=-1,s=e.length,a=s-1,o=t;o!=null&&++i<s;){var u=Wt(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=ct(p)?p:kr(e[i+1])?[]:{})}bd(o,u,d),o=o[u]}return t}l(bo,"baseSet");var Cg=bo;function wo(t,e,n){for(var r=-1,i=e.length,s={};++r<i;){var a=e[r],o=Br(t,a);n(o,a)&&Cg(s,wn(a,t),o)}return s}l(wo,"basePickBy");var Ag=wo;function xo(t,e){if(t==null)return{};var n=ms(kf(t),function(r){return[r]});return e=yo(e),Ag(t,n,function(r,i){return e(r,i[0])})}l(xo,"pickBy");var Rg=xo;function Po(t,e){return Rg(t,Bg(yo(e)))}l(Po,"omitBy");var qi=Po,So=l((t,e)=>ko(t,e,new WeakSet),"isEqual"),Vi=l(t=>pf(t),"_isPlainObject"),ko=l((t,e,n)=>Og(t,e,Zg(n)),"_isEqualWithVisitedTracking"),Zg=l(t=>(e,n)=>{if(Vi(e)&&!t.has(e)&&Vi(n)&&!t.has(n)){let r=qi(e,Fi),i=qi(n,Fi);return t.add(r).add(i).add(e).add(n),ko(r,i,t)}},"_customizerWithVisitedTracking"),Dg=l(t=>Array.from(new Set(t)),"unique"),Ng={compare:So},Io=class{constructor(e=[],n={}){this._options=c(c({},Ng),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(Io,"CustomSet");var Hg=Io,b={};ge(b,{errToObj:()=>Mg,toString:()=>jg});var Mg=l(t=>typeof t=="string"?{message:t}:t||{},"errToObj"),jg=l(t=>typeof t=="string"?t:t?.message,"toString"),fe={};ge(fe,{assertNever:()=>Oo});function Oo(t){throw new Error("assertNever called")}l(Oo,"assertNever");var pe={};ge(pe,{compareFunctions:()=>zg,joinValues:()=>Eo,jsonStringifyReplacer:()=>$g});function Eo(t,e=" | "){return t.map(n=>typeof n=="string"?`'${n}'`:n).join(e)}l(Eo,"joinValues");var $g=l((t,e)=>typeof e=="bigint"?e.toString():e,"jsonStringifyReplacer"),zg=l((t,e)=>t.toString()===e.toString(),"compareFunctions"),Bo={};ge(Bo,{extractPrecisionAndOffset:()=>Ao,generateDatetimeRegex:()=>Co});var Co=l(t=>{let e=t.precision?mr+t.precision+Kg:t.precision===0?"":Do,n=t.offset?Zo:Ug;return new RegExp(`^${Ro}${e}${n}$`)},"generateDatetimeRegex"),Ao=l(t=>({precision:Wg(t),offset:t.endsWith(`${Zo}$`)}),"extractPrecisionAndOffset"),Ro="\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}",Zo="(([+-]\\d{2}(:?\\d{2})?)|Z)",Ug="Z",Do="(\\.\\d+)?",mr="\\.\\d{",Kg="}",Wg=l(t=>{let e=t.slice(1+Ro.length);return e.startsWith(Do)?null:e.startsWith(mr)?parseInt(e.slice(mr.length)):0},"_extractPrecision"),dn=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,pe.jsonStringifyReplacer)}`;break;case"unrecognized_keys":n=`Unrecognized key(s) in object: ${pe.joinValues(t.keys,", ")}`;break;case"invalid_union":n="Invalid input";break;case"invalid_union_discriminator":n=`Invalid discriminator value. Expected ${pe.joinValues(t.options)}`;break;case"invalid_enum_value":n=`Invalid enum value. Expected ${pe.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}"`:fe.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,fe.assertNever(t)}return{message:n}},"errorMap"),pn=class No 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 No))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,pe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}};l(pn,"ZodError");pn.create=l(t=>new pn(t),"create");var Pe=pn,Lg=dn;function fn(){return Lg}l(fn,"getErrorMap");var Z={};function Ho(t){Object.assign(Z,t)}l(Ho,"setBuilders");var yr=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 y(t,e){let n=yr({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,fn(),dn].filter(r=>!!r)});t.common.issues.push(n)}l(y,"addIssueToContext");var Mo=class jo{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 jo.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(Mo,"ParseStatus");var se=Mo,gn=l(t=>typeof Promise<"u"&&t instanceof Promise,"isAsync"),Ue=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"),$o=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($o,"ParseInputLazyPath");var ve=$o,zo=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(zo,"_CircularDependencyError");var tr=zo,Uo=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 Pe(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 Ue(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:Ue(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new se,ctx:{common:e.parent.common,data:e.data,parsedType:Ue(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(gn(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:Ue(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:Ue(e)},i=this._parse({data:e,path:r.path,parent:r}),s=await(gn(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 Z.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 Z.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 Z.downstream(this,e,n)}optional(){return Z.optional(this,this._def)}nullable(){return Z.nullable(this,this._def)}nullish(){return this.nullable().optional()}array(){return Z.array(this,this._def)}promise(){return Z.promise(this,this._def)}mandatory(){return this}or(e){return Z.union([this,e])}and(e){return Z.intersection(this,e)}transform(e){return Z.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 Z.default(this,n)}brand(){return Z.branded(this)}catch(e){return Z.catch(this,e)}describe(e){let n=this.clone();return n._metadataRoot._def.description=e,n}pipe(e){return Z.pipeline(this,e)}readonly(){return Z.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=C])!=null||(n[r]={});for(let[o,u]of Object.entries(e))a._def[C]=f(c({},a._def[C]),{[o]:u});return s}getMetadata(){return c({},this._metadataRoot._def[C])}setMetadata(e){this._metadataRoot._def[C]=c({},e)}get ui(){return c({},this._metadataRoot._def[C])}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 tr("toJSONSchema")}toTypescriptType(e){throw new tr("toTypescriptType")}toTypescriptSchema(){throw new tr("toTypescriptSchema")}naked(){return this}};l(Uo,"ZodBaseTypeImpl");var P=Uo,Ko=class Wo extends P{constructor(){super(...arguments),this._any=!0}_parse(e){return{status:"valid",value:e.data}}isEqual(e){return e instanceof Wo}};l(Ko,"ZodAnyImpl");var Fg=Ko,Lo=class je extends P{dereference(e){return new je(f(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new je(f(c({},this._def),{type:this._def.type.clone()}))}isEqual(e){var n,r,i,s,a,o;return e instanceof je?Ce((n=this._def.exactLength)==null?void 0:n.value,(r=e._def.exactLength)==null?void 0:r.value)&&Ce((i=this._def.maxLength)==null?void 0:i.value,(s=e._def.maxLength)==null?void 0:s.value)&&Ce((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 y(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)&&(y(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&&(y(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&&(y(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 ve(n,a,n.path,o)))).then(a=>se.mergeArray(r,a));let s=[...n.data].map((a,o)=>i.type._parseSync(new ve(n,a,n.path,o)));return se.mergeArray(r,s)}get element(){return this._def.type}min(e,n){return new je(f(c({},this._def),{minLength:{value:e,message:b.toString(n)}}))}max(e,n){return new je(f(c({},this._def),{maxLength:{value:e,message:b.toString(n)}}))}length(e,n){return new je(f(c({},this._def),{exactLength:{value:e,message:b.toString(n)}}))}nonempty(e){return this.min(1,e)}};l(Lo,"ZodArrayImpl");var qg=Lo,Fo=class en 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 y(s,{code:"invalid_type",expected:"bigint",received:s.parsedType}),{status:"aborted"}}let r,i=new se;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),y(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),y(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),y(r,{code:"not_multiple_of",multipleOf:s.value,message:s.message}),i.dirty()):fe.assertNever(s);return{status:i.value,value:e.data}}isEqual(e){if(!(e instanceof en)||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,b.toString(n))}gt(e,n){return this.setLimit("min",e,!1,b.toString(n))}lte(e,n){return this.setLimit("max",e,!0,b.toString(n))}lt(e,n){return this.setLimit("max",e,!1,b.toString(n))}setLimit(e,n,r,i){return new en(f(c({},this._def),{checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:b.toString(i)}]}))}_addCheck(e){return new en(f(c({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:b.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:b.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(Fo,"ZodBigIntImpl");var Vg=Fo,qo=class Vo extends P{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!=="boolean"){let r=this._getOrReturnCtx(e);return y(r,{code:"invalid_type",expected:"boolean",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof Vo?this._def.coerce===e._def.coerce:!1}};l(qo,"ZodBooleanImpl");var Gg=qo,Go=class Tt extends P{dereference(e){return new Tt(f(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new Tt(f(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx: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 Tt?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}mandatory(){return new Tt(f(c({},this._def),{type:this._def.type.mandatory()}))}};l(Go,"ZodBrandedImpl");var Jg=Go,Jo=class bt 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 gn(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Pe(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Pe(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}isEqual(e){return e instanceof bt?this._def.innerType.isEqual(e._def.innerType)&&pe.compareFunctions(this._def.catchValue,e._def.catchValue):!1}dereference(e){return new bt(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new bt(f(c({},this._def),{innerType:this._def.innerType.clone()}))}naked(){return this._def.innerType.naked()}mandatory(){return new bt(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};l(Jo,"ZodCatchImpl");var Yg=Jo,Yo=class hr extends P{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!=="date"){let s=this._getOrReturnCtx(e);return y(s,{code:"invalid_type",expected:"date",received:s.parsedType}),{status:"aborted"}}if(isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return y(s,{code:"invalid_date"}),{status:"aborted"}}let r=new se,i;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),y(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),y(i,{code:"too_big",message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):fe.assertNever(s);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new hr(f(c({},this._def),{checks:[...this._def.checks,e]}))}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:b.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:b.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 hr))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(Yo,"ZodDateImpl");var Xg=Yo,Xo=class wt 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 wt(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new wt(f(c({},this._def),{innerType:this._def.innerType.clone()}))}isEqual(e){return e instanceof wt?this._def.innerType.isEqual(e._def.innerType)&&Ce(this._def.defaultValue(),e._def.defaultValue()):!1}unwrap(){return this._def.innerType}naked(){return this._def.innerType.naked()}mandatory(){return new wt(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};l(Xo,"ZodDefaultImpl");var Qg=Xo,xe=l(t=>{let e=t;return e?e.typeName==="ZodLazy"?xe(e.schema):e.typeName==="ZodEffects"?xe(e.innerType()):e.typeName==="ZodLiteral"?[e.value]:e.typeName==="ZodEnum"?e.options:e.typeName==="ZodNativeEnum"?Object.values(e.enum):e.typeName==="ZodDefault"?xe(e._def.innerType):e.typeName==="ZodUndefined"?[void 0]:e.typeName==="ZodNull"?[null]:e.typeName==="ZodOptional"?[void 0,...xe(e.unwrap())]:e.typeName==="ZodNullable"?[null,...xe(e.unwrap())]:e.typeName==="ZodBranded"||e.typeName==="ZodReadonly"?xe(e.unwrap()):e.typeName==="ZodCatch"?xe(e._def.innerType):[]:[]},"getDiscriminator"),Qo=class xt extends P{constructor(e){let n=xt._getOptionsMap(e.discriminator,e.options);super(f(c({},e),{optionsMap:n}))}dereference(e){let n=this.options.map(r=>r.dereference(e));return new xt(f(c({},this._def),{options:n}))}getReferences(){return _e.unique(this.options.flatMap(e=>e.getReferences()))}clone(){let e=this.options.map(n=>n.clone());return new xt(f(c({},this._def),{options:e}))}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!=="object")return y(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}):(y(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=xe(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 xt)||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 em=Qo,el=class tl extends P{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return y(n,{expected:pe.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 y(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 Z.enum(e,c(c({},this._def),n))}exclude(e,n=this._def){return Z.enum(this.options.filter(r=>!e.includes(r)),c(c({},this._def),n))}isEqual(e){if(!(e instanceof tl))return!1;let n=new $.CustomSet(this._def.values),r=new $.CustomSet(e._def.values);return n.isEqual(r)}};l(el,"ZodEnumImpl");var tm=el,nl=class at 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 at(f(c({},this._def),{args:n,returns:r}))}getReferences(){return _e.unique([...this._def.args.getReferences(),...this._def.returns.getReferences()])}clone(){return new at(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 y(n,{code:"invalid_type",expected:"function",received:n.parsedType}),{status:"aborted"};function r(d,p){return yr({data:d,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,fn(),dn].filter(g=>!!g),issueData:{code:"invalid_arguments",argumentsError:p}})}l(r,"makeArgsIssue");function i(d,p){return yr({data:d,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,fn(),dn].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 E.zuiPromise(u)?{status:"valid",async value(...d){let p=new Pe([]),g=await o._def.args.parseAsync(d,s).catch(h=>{throw p.addIssue(r(d,h)),p}),m=await Reflect.apply(a,this,g);return await u._def.type.parseAsync(m,s).catch(h=>{throw E.zuiError(h)?(p.addIssue(i(m,h)),p):h})}}:{status:"valid",value(...d){let p=o._def.args.safeParse(d,s);if(!p.success)throw new Pe([r(d,p.error)]);let g=Reflect.apply(a,this,p.data),m=o._def.returns.safeParse(g,s);if(!m.success)throw new Pe([i(g,m.error)]);return m.data}}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new at(f(c({},this._def),{args:Z.tuple(e).rest(Z.unknown())}))}returns(e){return new at(f(c({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}isEqual(e){return e instanceof at&&this._def.args.isEqual(e._def.args)&&this._def.returns.isEqual(e._def.returns)}};l(nl,"ZodFunctionImpl");var nm=nl,rl=class tn extends P{dereference(e){return new tn(f(c({},this._def),{left:this._def.left.dereference(e),right:this._def.right.dereference(e)}))}getReferences(){return _e.unique([...this._def.left.getReferences(),...this._def.right.getReferences()])}clone(){return new tn(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}):(y(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 tn))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=Ue(e),i=Ue(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(rl,"ZodIntersectionImpl");var rm=rl,il=class Pt extends P{get schema(){return this._def.getter()}dereference(e){return new Pt(f(c({},this._def),{getter:()=>this._def.getter().dereference(e)}))}getReferences(){return this._def.getter().getReferences()}clone(){return new Pt(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 Pt?this._def.getter().isEqual(e._def.getter()):!1}naked(){return this._def.getter().naked()}mandatory(){return new Pt(f(c({},this._def),{getter:()=>this._def.getter().mandatory()}))}};l(il,"ZodLazyImpl");var im=il,sl=class al extends P{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return y(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 al?Ce(this._def.value,e._def.value):!1}};l(sl,"ZodLiteralImpl");var sm=sl,ol=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 _e.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!=="map")return y(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 ve(r,o,r.path,[d,"key"])),value:s._parse(new ve(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 nn)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};l(ol,"ZodMapImpl");var am=ol,ll=class ul extends P{_parse(e){if(this._getType(e)!=="nan"){let r=this._getOrReturnCtx(e);return y(r,{code:"invalid_type",expected:"nan",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof ul}};l(ll,"ZodNaNImpl");var om=ll,cl=class dl 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 y(r,{expected:pe.joinValues(i),received:r.parsedType,code:"invalid_type"}),{status:"aborted"}}if(n.indexOf(e.data)===-1){let i=Object.values(n);return y(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 dl?Ce(this._def.values,e._def.values):!1}};l(cl,"ZodNativeEnumImpl");var lm=cl,pl=class fl extends P{_parse(e){let n=this._getOrReturnCtx(e);return y(n,{code:"invalid_type",expected:"never",received:n.parsedType}),{status:"aborted"}}isEqual(e){return e instanceof fl}};l(pl,"ZodNeverImpl");var um=pl,gl=class ml extends P{_parse(e){if(this._getType(e)!=="null"){let r=this._getOrReturnCtx(e);return y(r,{code:"invalid_type",expected:"null",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof ml}};l(gl,"ZodNullImpl");var cm=gl,yl=class St extends P{dereference(e){return new St(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new St(f(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)==="null"?{status:"valid",value:null}:this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof St?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new St(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};l(yl,"ZodNullableImpl");var dm=yl,hl=class rn 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 y(s,{code:"invalid_type",expected:"number",received:s.parsedType}),{status:"aborted"}}let r,i=new se;for(let s of this._def.checks)s.kind==="int"?Number.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),y(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),y(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),y(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),y(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),y(r,{code:"not_finite",message:s.message}),i.dirty()):fe.assertNever(s);return{status:i.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,b.toString(n))}gt(e,n){return this.setLimit("min",e,!1,b.toString(n))}lte(e,n){return this.setLimit("max",e,!0,b.toString(n))}lt(e,n){return this.setLimit("max",e,!1,b.toString(n))}setLimit(e,n,r,i){return new rn(f(c({},this._def),{checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:b.toString(i)}]}))}_addCheck(e){return new rn(f(c({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:b.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:b.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:b.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:b.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:b.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 rn))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(hl,"ZodNumberImpl");var pm=hl,vl=class te 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 te(f(c({},this._def),{shape:()=>r}))}getReferences(){let e=this._def.shape(),n=[];for(let r in e)n.push(...e[r].getReferences());return _e.unique(n)}clone(){let e={},n=this._def.shape();for(let[i,s]of Object.entries(n))e[i]=s.clone();return new te(f(c({},this._def),{shape:()=>e}))}_parse(e){if(this._getType(e)!=="object"){let p=this._getOrReturnCtx(e);return y(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],m=i.data[p];u.push({key:{status:"valid",value:p},value:g._parse(new ve(i,m,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&&(y(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 ve(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 m=await g.key;p.push({key:m,value:await g.value,alwaysSet:g.alwaysSet})}return p}).then(p=>se.mergeObjectSync(r,p)):se.mergeObjectSync(r,u)}get shape(){return this._def.shape()}strict(e){return b.errToObj,new te(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=b.errToObj(e).message)!=null?o:u}:{message:u}}}:{}))}strip(){return new te(f(c({},this._def),{unknownKeys:"strip"}))}passthrough(){return new te(f(c({},this._def),{unknownKeys:"passthrough"}))}additionalProperties(){if(typeof this._def.unknownKeys=="object")return this._def.unknownKeys;if(this._def.unknownKeys==="passthrough")return Z.any();if(this._def.unknownKeys==="strict")return Z.never()}extend(e){return new te(f(c({},this._def),{shape:()=>c(c({},this._def.shape()),e)}))}merge(e){return new te({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 te(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 te(f(c({},this._def),{shape:()=>n}))}omit(e){let n={};return Object.entries(this.shape).forEach(([i,s])=>{e[i]||(n[i]=s)}),new te(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 te(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(;E.zuiOptional(a);)a=a._def.innerType;n[r]=a}}),new te(f(c({},this._def),{shape:()=>n}))}keyof(){let e=Object.keys(this.shape);return Z.enum(e)}isEqual(e){if(!(e instanceof te)||!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(vl,"ZodObjectImpl");var _l=vl,Tl=class sn extends P{dereference(e){return new sn(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new sn(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 sn?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return this._def.innerType.mandatory()}};l(Tl,"ZodOptionalImpl");var fm=Tl,bl=class an extends P{dereference(e){return new an(f(c({},this._def),{in:this._def.in.dereference(e),out:this._def.out.dereference(e)}))}getReferences(){return _e.unique([...this._def.in.getReferences(),...this._def.out.getReferences()])}clone(){return new an(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 an)||!this._def.in.isEqual(e._def.in)||!this._def.out.isEqual(e._def.out))}};l(bl,"ZodPipelineImpl");var gm=bl,wl=class on extends P{unwrap(){return this._def.type}dereference(e){return new on(f(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new on(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?(y(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 on?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}};l(wl,"ZodPromiseImpl");var mm=wl,xl=class kt 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 kt(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new kt(f(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){let n=this._def.innerType._parse(e);return gn(n)?n.then(this._freeze):this._freeze(n)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof kt?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new kt(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};l(xl,"ZodReadonlyImpl");var ym=xl,Pl=class ln 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 ln(f(c({},this._def),{keyType:n,valueType:r}))}getReferences(){return _e.unique([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new ln(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 y(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 ve(r,o,r.path,o)),value:a._parse(new ve(r,r.data[o],r.path,o))});return r.common.async?se.mergeObjectAsync(n,i):se.mergeObjectSync(n,i)}get element(){return this._def.valueType}isEqual(e){return!(!(e instanceof ln)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};l(Pl,"ZodRecordImpl");var Gi=Pl,Sl=class kl 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 y(n,{code:"unresolved_reference"}),{status:"aborted"}}isOptional(){return!1}isNullable(){return!1}isEqual(e){return e instanceof kl?this._def.uri===e._def.uri:!1}};l(Sl,"ZodRefImpl");var hm=Sl,Il=class ot extends P{dereference(e){return new ot(f(c({},this._def),{valueType:this._def.valueType.dereference(e)}))}getReferences(){return this._def.valueType.getReferences()}clone(){return new ot(f(c({},this._def),{valueType:this._def.valueType.clone()}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!=="set")return y(r,{code:"invalid_type",expected:"set",received:r.parsedType}),{status:"aborted"};let i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(y(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&&(y(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 ve(r,u,r.path,d)));return r.common.async?Promise.all(o).then(u=>a(u)):a(o)}min(e,n){return new ot(f(c({},this._def),{minSize:{value:e,message:b.toString(n)}}))}max(e,n){return new ot(f(c({},this._def),{maxSize:{value:e,message:b.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 ot))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(Il,"ZodSetImpl");var vm=Il,_m=/^c[^\s-]{8,}$/i,Tm=/^[a-z][a-z0-9]*$/,bm=/^[0-9A-HJKMNP-TV-Z]{26}$/,wm=/^[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,xm=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Pm="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",nr,Sm=/^(((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}))$/,km=/^(([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 Ol(t,e){return!!((e==="v4"||!e)&&Sm.test(t)||(e==="v6"||!e)&&km.test(t))}l(Ol,"isValidIP");var El=class lt extends P{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!=="string"){let s=this._getOrReturnCtx(e);return y(s,{code:"invalid_type",expected:"string",received:s.parsedType}),{status:"aborted"}}let r=new se,i;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),y(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),y(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?y(i,{code:"too_big",maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&y(i,{code:"too_small",minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")xm.test(e.data)||(i=this._getOrReturnCtx(e,i),y(i,{validation:"email",code:"invalid_string",message:s.message}),r.dirty());else if(s.kind==="emoji")nr||(nr=new RegExp(Pm,"u")),nr.test(e.data)||(i=this._getOrReturnCtx(e,i),y(i,{validation:"emoji",code:"invalid_string",message:s.message}),r.dirty());else if(s.kind==="uuid")wm.test(e.data)||(i=this._getOrReturnCtx(e,i),y(i,{validation:"uuid",code:"invalid_string",message:s.message}),r.dirty());else if(s.kind==="cuid")_m.test(e.data)||(i=this._getOrReturnCtx(e,i),y(i,{validation:"cuid",code:"invalid_string",message:s.message}),r.dirty());else if(s.kind==="cuid2")Tm.test(e.data)||(i=this._getOrReturnCtx(e,i),y(i,{validation:"cuid2",code:"invalid_string",message:s.message}),r.dirty());else if(s.kind==="ulid")bm.test(e.data)||(i=this._getOrReturnCtx(e,i),y(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),y(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),y(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),y(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),y(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),y(i,{code:"invalid_string",validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?Bo.generateDatetimeRegex(s).test(e.data)||(i=this._getOrReturnCtx(e,i),y(i,{code:"invalid_string",validation:"datetime",message:s.message}),r.dirty()):s.kind==="ip"?Ol(e.data,s.version)||(i=this._getOrReturnCtx(e,i),y(i,{validation:"ip",code:"invalid_string",message:s.message}),r.dirty()):fe.assertNever(s);return{status:r.value,value:e.data}}_addCheck(e){return new lt(f(c({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(c({kind:"email"},b.errToObj(e)))}url(e){return this._addCheck(c({kind:"url"},b.errToObj(e)))}emoji(e){return this._addCheck(c({kind:"emoji"},b.errToObj(e)))}uuid(e){return this._addCheck(c({kind:"uuid"},b.errToObj(e)))}cuid(e){return this._addCheck(c({kind:"cuid"},b.errToObj(e)))}cuid2(e){return this._addCheck(c({kind:"cuid2"},b.errToObj(e)))}ulid(e){return this._addCheck(c({kind:"ulid"},b.errToObj(e)))}ip(e){return this._addCheck(c({kind:"ip"},b.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},b.errToObj(e?.message)))}regex(e,n){return this._addCheck(c({kind:"regex",regex:e},b.errToObj(n)))}includes(e,n){return this._addCheck(c({kind:"includes",value:e,position:n?.position},b.errToObj(n?.message)))}startsWith(e,n){return this._addCheck(c({kind:"startsWith",value:e},b.errToObj(n)))}endsWith(e,n){return this._addCheck(c({kind:"endsWith",value:e},b.errToObj(n)))}min(e,n){return this._addCheck(c({kind:"min",value:e},b.errToObj(n)))}max(e,n){return this._addCheck(c({kind:"max",value:e},b.errToObj(n)))}length(e,n){return this._addCheck(c({kind:"length",value:e},b.errToObj(n)))}nonempty(e){return this.min(1,b.errToObj(e))}trim(){return new lt(f(c({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}secret(){return this._def[C]=f(c({},this._def[C]),{secret:!0}),this}toLowerCase(){return new lt(f(c({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new lt(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 lt))return!1;let n=new $.CustomSet(this._def.checks),r=new $.CustomSet(e._def.checks);return n.isEqual(r)}};l(El,"ZodStringImpl");var Im=El,Bl=class Cl extends P{_parse(e){if(this._getType(e)!=="symbol"){let r=this._getOrReturnCtx(e);return y(r,{code:"invalid_type",expected:"symbol",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof Cl}};l(Bl,"ZodSymbolImpl");var Om=Bl,Al=class It extends P{innerType(){return this._def.schema}sourceType(){return E.zuiEffects(this._def.schema)?this._def.schema.sourceType():this._def.schema}dereference(e){return new It(f(c({},this._def),{schema:this._def.schema.dereference(e)}))}getReferences(){return this._def.schema.getReferences()}clone(){return new It(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)));fe.assertNever(r)}_processResult(e,n){if(n.status!=="valid")for(let r of n.issues)y(e,r)}isEqual(e){return!(e instanceof It)||!this._def.schema.isEqual(e._def.schema)?!1:this._def.effect.type==="upstream"?e._def.effect.type!=="upstream"?!1:pe.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:pe.compareFunctions(this._def.effect.effect,e._def.effect.effect):(this._def.effect,!1)}naked(){return this._def.schema.naked()}mandatory(){return new It(f(c({},this._def),{schema:this._def.schema.mandatory()}))}};l(Al,"ZodEffectsImpl");var Ar=Al,Rl=class Ot 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 Ot(f(c({},this._def),{items:n,rest:r}))}getReferences(){return _e.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 Ot(f(c({},this._def),{items:e,rest:n}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!=="array")return y(r,{code:"invalid_type",expected:"array",received:r.parsedType}),{status:"aborted"};if(r.data.length<this._def.items.length)return y(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&&(y(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 ve(r,a,r.path,o)):null}).filter(a=>!!a);return r.common.async?Promise.all(s).then(a=>se.mergeArray(n,a)):se.mergeArray(n,s)}get items(){return this._def.items}rest(e){return new Ot(f(c({},this._def),{rest:e}))}isEqual(e){if(!(e instanceof Ot)||!this._restEquals(e))return!1;let 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(Rl,"ZodTupleImpl");var Em=Rl,Zl=class Dl extends P{_parse(e){if(this._getType(e)!=="undefined"){let r=this._getOrReturnCtx(e);return y(r,{code:"invalid_type",expected:"undefined",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof Dl}mandatory(){return Z.never(c({},this._def))}};l(Zl,"ZodUndefinedImpl");var Bm=Zl,Nl=class Et extends P{dereference(e){let n=this._def.options.map(r=>r.dereference(e));return new Et(f(c({},this._def),{options:n}))}getReferences(){return _e.unique(this._def.options.reduce((e,n)=>[...e,...n.getReferences()],[]))}clone(){let e=this._def.options.map(n=>n.clone());return new Et(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 Pe(o.ctx.common.issues));return y(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 Pe(u));return y(n,{code:"invalid_union",unionErrors:o}),{status:"aborted"}}}get options(){return this._def.options}isEqual(e){if(!(e instanceof Et))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=>!E.zuiUndefined(s)).map(s=>s.mandatory()),[n,r,...i]=e;return n?r?new Et(f(c({},this._def),{options:[n,r,...i]})):n:Z.never(c({},this._def))}};l(Nl,"ZodUnionImpl");var Cm=Nl,Hl=class Ml extends P{constructor(){super(...arguments),this._unknown=!0}_parse(e){return{status:"valid",value:e.data}}isEqual(e){return e instanceof Ml}};l(Hl,"ZodUnknownImpl");var Am=Hl,jl=class $l extends P{_parse(e){if(this._getType(e)!=="undefined"){let r=this._getOrReturnCtx(e);return y(r,{code:"invalid_type",expected:"void",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof $l}};l(jl,"ZodVoidImpl");var Rm=jl,Zm=l(t=>t instanceof Error,"_isError"),Dm=l(t=>typeof t=="object"&&t!==null,"_isObject"),E={zuiError:t=>t instanceof Pe||Zm(t)&&"__type__"in t&&t.__type__==="ZuiError",zuiType:t=>t instanceof P||Dm(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"},S=l(t=>{if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:i,supportsExtensions:s,[C]: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,[C]: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,[C]:o}},"_processCreateParams"),Pn=l((t,e={},n)=>t?Fe().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)):ei(r,c({code:"custom"},a))}}):Fe(),"customType"),Rr=l((t,e={message:`Input not instance of ${t.name}`})=>Pn(n=>n instanceof t,e),"instanceOfType"),Fe=l(t=>new Fg(c({typeName:"ZodAny"},S(t))),"anyType"),Re=l(t=>new Am(c({typeName:"ZodUnknown"},S(t))),"unknownType"),Mt=l(t=>new um(c({typeName:"ZodNever"},S(t))),"neverType"),Zr=l(t=>new Rm(c({typeName:"ZodVoid"},S(t))),"voidType"),Lt=l(t=>new cm(c({typeName:"ZodNull"},S(t))),"nullType"),Sn=l(t=>new Bm(c({typeName:"ZodUndefined"},S(t))),"undefinedType"),Dr=l(t=>new Om(c({typeName:"ZodSymbol"},S(t))),"symbolType"),Nr=l(t=>new om(c({typeName:"ZodNaN"},S(t))),"nanType"),ke=l(t=>{var e;return new Im(c({checks:[],typeName:"ZodString",coerce:(e=t?.coerce)!=null?e:!1},S(f(c({},t),{supportsExtensions:["secret"]}))))},"stringType"),et=l(t=>new pm(c({checks:[],typeName:"ZodNumber",coerce:t?.coerce||!1},S(t))),"numberType"),tt=l(t=>new Gg(c({typeName:"ZodBoolean",coerce:t?.coerce||!1},S(t))),"booleanType"),kn=l(t=>{var e;return new Vg(c({checks:[],typeName:"ZodBigInt",coerce:(e=t?.coerce)!=null?e:!1},S(t)))},"bigIntType"),In=l(t=>new Xg(c({checks:[],coerce:t?.coerce||!1,typeName:"ZodDate"},S(t))),"dateType"),On=l(t=>new hm({typeName:"ZodRef",uri:t}),"refType"),jt=l((t,e)=>new sm(c({value:t,typeName:"ZodLiteral"},S(e))),"literalType"),En=l((t,e)=>new tm(c({values:t,typeName:"ZodEnum"},S(e))),"enumType"),Hr=l((t,e)=>new lm(c({values:t,typeName:"ZodNativeEnum"},S(e))),"nativeEnumType"),Ke=l((t,e)=>new qg(c({type:t,minLength:null,maxLength:null,exactLength:null,typeName:"ZodArray"},S(e))),"arrayType"),dt=l((t,e)=>new _l(c({shape:()=>t,unknownKeys:"strip",typeName:"ZodObject"},S(e))),"objectType"),Mr=l((t,e)=>new _l(c({shape:()=>t,unknownKeys:"strict",typeName:"ZodObject"},S(e))),"strictObjectType"),We=l((t,e)=>new Cm(c({options:t,typeName:"ZodUnion"},S(e))),"unionType"),$t=l((t,e,n)=>new em(c({typeName:"ZodDiscriminatedUnion",discriminator:t,options:e},S(n))),"discriminatedUnionType"),zt=l((t,e,n)=>new rm(c({left:t,right:e,typeName:"ZodIntersection"},S(n))),"intersectionType"),Ft=l((t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Em(c({items:t,typeName:"ZodTuple",rest:null},S(e)))},"tupleType"),Ut=l((t,e,n)=>e instanceof P?new Gi(c({keyType:t,valueType:e,typeName:"ZodRecord"},S(n))):new Gi(c({keyType:ke(),valueType:t,typeName:"ZodRecord"},S(e))),"recordType"),jr=l((t,e,n)=>new am(c({valueType:e,keyType:t,typeName:"ZodMap"},S(n))),"mapType"),Bn=l((t,e)=>new vm(c({valueType:t,minSize:null,maxSize:null,typeName:"ZodSet"},S(e))),"setType"),$r=l((t,e)=>new im(c({getter:t,typeName:"ZodLazy"},S(e))),"lazyType"),zr=l((t,e)=>new mm(c({type:t,typeName:"ZodPromise"},S(e))),"promiseType"),Ur=l((t,e,n)=>new nm(c({args:t||Ft([]).rest(Re()),returns:e||Re(),typeName:"ZodFunction"},S(n))),"functionType"),Kr=l((t,e,n)=>new Ar(c({schema:e,effect:{type:"upstream",effect:(r,i)=>{let s=t(r,i);return s instanceof Promise?s.then(a=>mn(a)):mn(s)}},typeName:"ZodEffects"},S(n))),"preprocessType"),Wr=l((t,e,n)=>new Ar(c({schema:e,effect:{type:"upstream",effect:t},typeName:"ZodEffects"},S(n))),"upstreamType"),Lr=l((t,e,n)=>new Ar(c({schema:t,effect:{type:"downstream",effect:e,failFast:n?.failFast},typeName:"ZodEffects"},S(n))),"downstreamType"),Fr=l((t,e)=>new fm(c({innerType:t,typeName:"ZodOptional"},S(e))),"optionalType"),qr=l((t,e)=>new dm(c({innerType:t,typeName:"ZodNullable"},S(e))),"nullableType"),Vr=l((t,e)=>new ym(c({innerType:t,typeName:"ZodReadonly"},S(e))),"readonlyType"),Gr=l((t,e,n)=>new Qg(c({innerType:t,typeName:"ZodDefault",defaultValue:typeof e=="function"?e:()=>e},S(n))),"defaultType"),Jr=l((t,e,n)=>new Yg(c({innerType:t,typeName:"ZodCatch",catchValue:typeof e=="function"?e:()=>e},S(n))),"catchType"),Yr=l((t,e)=>new gm({in:t,out:e,typeName:"ZodPipeline"}),"pipelineType"),Xr=l(t=>new Jg(c({typeName:"ZodBranded",type:t},S({supportsExtensions:["secret"]}))),"brandedType");Ho({any:Fe,array:Ke,bigint:kn,boolean:tt,branded:Xr,catch:Jr,custom:Pn,date:In,default:Gr,discriminatedUnion:$t,enum:En,function:Ur,instanceof:Rr,intersection:zt,lazy:$r,literal:jt,map:jr,nan:Nr,nativeEnum:Hr,never:Mt,null:Lt,nullable:qr,number:et,object:dt,optional:Fr,pipeline:Yr,preprocess:Kr,upstream:Wr,downstream:Lr,promise:zr,record:Ut,ref:On,readonly:Vr,set:Bn,strictObject:Mr,string:ke,symbol:Dr,tuple:Ft,undefined:Sn,union:We,unknown:Re,void:Zr});var zl={string(t){return ke(f(c({},t),{coerce:!0}))},number(t){return et(f(c({},t),{coerce:!0}))},boolean(t){return tt(f(c({},t),{coerce:!0}))},bigint(t){return kn(f(c({},t),{coerce:!0}))},date(t){return In(f(c({},t),{coerce:!0}))}},mn=l(t=>({status:"valid",value:t}),"OK"),Qr=l((t,...e)=>({status:"aborted",issues:[t,...e]}),"ERR"),ei=l((t,e,...n)=>({status:"dirty",value:t,issues:[e,...n]}),"DIRTY"),Ul={};ge(Ul,{JSONSchemaToZuiError:()=>Cn,ObjectToZuiError:()=>vr,UnrepresentableGenericError:()=>_r,UnsupportedJSONSchemaToZuiError:()=>$e,UnsupportedZuiCheckToJSONSchemaError:()=>Jl,UnsupportedZuiToJSONSchemaError:()=>Y,UnsupportedZuiToTypescriptSchemaError:()=>ze,UnsupportedZuiToTypescriptTypeError:()=>nu,UntitledDeclarationError:()=>iu,ZuiToJSONSchemaError:()=>An,ZuiToTypescriptSchemaError:()=>Xl,ZuiToTypescriptTypeError:()=>Rn,ZuiTransformError:()=>pt});var Kl=class extends Error{constructor(e,n,r){let i=r?`${r} : ${n}`:n;super(i),this.transform=e,this.path=r}};l(Kl,"ZuiTransformError");var pt=Kl,Wl=class extends pt{constructor(e,n){super("json-schema-to-zui",e,n)}};l(Wl,"JSONSchemaToZuiError");var Cn=Wl,Ll=class extends Cn{constructor(e,n){super(`JSON Schema ${JSON.stringify(e)} cannot be transformed to ZUI type.`,n)}};l(Ll,"UnsupportedJSONSchemaToZuiError");var $e=Ll,Fl=class extends pt{constructor(e,n){super("object-to-zui",e,n)}};l(Fl,"ObjectToZuiError");var vr=Fl,ql=class extends pt{constructor(e,n){super("zui-to-json-schema",e,n)}};l(ql,"ZuiToJSONSchemaError");var An=ql,Vl=class extends An{constructor(e,n,{suggestedAlternative:r}={}){let i=r?`Zod type ${e} cannot be transformed to JSON Schema. Suggested alternative: ${r}`:`Zod type ${e} cannot be transformed to JSON Schema.`;super(i,n)}};l(Vl,"UnsupportedZuiToJSONSchemaError");var Y=Vl,Gl=class extends An{constructor(e,n,r){super(`Zod check .${n}() of type ${e} cannot be transformed to JSON Schema.`,r)}};l(Gl,"UnsupportedZuiCheckToJSONSchemaError");var Jl=Gl,Yl=class extends pt{constructor(e,n){super("zui-to-typescript-schema",e,n)}};l(Yl,"ZuiToTypescriptSchemaError");var Xl=Yl,Ql=class extends Xl{constructor(e,n){super(`Zod type ${e} cannot be transformed to TypeScript schema.`,n)}};l(Ql,"UnsupportedZuiToTypescriptSchemaError");var ze=Ql,eu=class extends pt{constructor(e,n){super("zui-to-typescript-type",e,n)}};l(eu,"ZuiToTypescriptTypeError");var Rn=eu,tu=class extends Rn{constructor(e,n){super(`Zod type ${e} cannot be transformed to TypeScript type.`,n)}};l(tu,"UnsupportedZuiToTypescriptTypeError");var nu=tu,ru=class extends Rn{constructor(){super("Schema must have a title to be transformed to a TypeScript type with a declaration.")}};l(ru,"UntitledDeclarationError");var iu=ru,su=class extends Rn{constructor(){super('ZodRef can only be transformed to a TypeScript type with a "type" declaration.')}};l(su,"UnrepresentableGenericError");var _r=su,Nm=l(t=>{let e;try{e=new Function("z",`return ${t}`)(Ie)}catch(n){return{sucess:!1,error:`Failed to evaluate schema: ${(n instanceof Error?n:new Error(String(n))).message}`}}return E.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"},Hm=l(t=>[t.slice(0,t.length/2),t.slice(t.length/2)],"half"),Mm=l((t,...e)=>Object.keys(t).reduce((n,r)=>(e.includes(r)||(n[r]=t[r]),n),{}),"omit");function V(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(V,"withMessage");var Bt=Symbol("Original index"),jm=l(t=>{let e=[];for(let n=0;n<t.length;n++){let r=t[n];if(typeof r=="boolean")e.push(r?{[Bt]:n}:{[Bt]:n,not:{}});else{if(Bt in r)return t;e.push(f(c({},r),{[Bt]:n}))}}return e},"ensureOriginalIndex");function Kt(t,e){if(t.allOf.length===0)return"z.never()";if(t.allOf.length===1){let n=t.allOf[0];return F(n,f(c({},e),{path:[...e.path,"allOf",n[Bt]]}))}else{let[n,r]=Hm(jm(t.allOf));return`z.intersection(${Kt({allOf:n},e)}, ${Kt({allOf:r},e)})`}}l(Kt,"parseAllOf");var au=l((t,e)=>t.anyOf.length?t.anyOf.length===1?F(t.anyOf[0],f(c({},e),{path:[...e.path,"anyOf",0]})):`z.union([${t.anyOf.map((n,r)=>F(n,f(c({},e),{path:[...e.path,"anyOf",r]}))).join(", ")}])`:"z.any()","parseAnyOf"),$m=l((t,e)=>{if(Array.isArray(t.items))return`z.tuple([${t.items.map((r,i)=>F(r,f(c({},e),{path:[...e.path,"items",i]})))}])`;let n=t.items?`z.array(${F(t.items,f(c({},e),{path:[...e.path,"items"]}))})`:"z.array(z.any())";return n+=V(t,"minItems",({json:r})=>[`.min(${r}`,", ",")"]),n+=V(t,"maxItems",({json:r})=>[`.max(${r}`,", ",")"]),n},"parseArray"),zm=l(t=>{var e;return(e=t[C])!=null&&e.coerce?"z.coerce.boolean()":"z.boolean()"},"parseBoolean"),Um=l(t=>`z.literal(${JSON.stringify(t.const)})`,"parseConst"),Km=l(t=>"z.any()","parseDefault"),ti=l((t,e)=>t.oneOf.length?t.oneOf.length===1?F(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)=>F(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"),
|
|
18
|
+
})`:"z.any()","parseOneOf"),Wm=l((t,e)=>{var n,r;if(t.oneOf.length<=1||!((n=t.discriminator)!=null&&n.propertyName))return ti(t,e);let i=t.oneOf.map((s,a)=>F(s,f(c({},e),{path:[...e.path,"oneOf",a]})));return`z.discriminatedUnion("${(r=t.discriminator)==null?void 0:r.propertyName}", [${i.join(", ")}])`},"parseDiscriminator"),Lm=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"),Fm=l((t,e)=>{let n=F(t.if,f(c({},e),{path:[...e.path,"if"]})),r=F(t.then,f(c({},e),{path:[...e.path,"then"]})),i=F(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"),
|
|
25
|
+
})`},"parseIfThenElse"),qm=l((t,e)=>`z.union([${t.type.map(n=>F(f(c({},t),{type:n}),e)).join(", ")}])`,"parseMultipleType"),Vm=l((t,e)=>`z.any().refine((value) => !${F(t.not,f(c({},e),{path:[...e.path,"not"]}))}.safeParse(value).success, "Invalid input: Should NOT be valid against schema")`,"parseNot"),Gm=l(t=>"z.null()","parseNull"),Jm=l((t,e)=>`${F(Mm(t,"nullable"),e,!0)}.nullable()`,"parseNullable"),Ym=l(t=>{var e;let n="z.number()";return(e=t[C])!=null&&e.coerce&&(n="z.coerce.number()"),t.type==="integer"?n+=V(t,"type",()=>[".int(",")"]):n+=V(t,"format",({value:r})=>{if(r==="int64")return[".int(",")"]}),n+=V(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+=V(t,"minimum",({json:r})=>[`.gt(${r}`,", ",")"]):n+=V(t,"minimum",({json:r})=>[`.gte(${r}`,", ",")"]):typeof t.exclusiveMinimum=="number"&&(n+=V(t,"exclusiveMinimum",({json:r})=>[`.gt(${r}`,", ",")"])),typeof t.maximum=="number"?t.exclusiveMaximum===!0?n+=V(t,"maximum",({json:r})=>[`.lt(${r}`,", ",")"]):n+=V(t,"maximum",({json:r})=>[`.lte(${r}`,", ",")"]):typeof t.exclusiveMaximum=="number"&&(n+=V(t,"exclusiveMaximum",({json:r})=>[`.lt(${r}`,", ",")"])),n},"parseNumber");function ou(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)}: ${F(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?F(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,F(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(${iu(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(${Qr(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(${Kt(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(su,"parseObject");var Jm=l(t=>`z.ref('${t.$ref}')`,"parseRef"),Ym=l(t=>{var e;let n="z.string()";if((e=t[C])!=null&&e.coerce){if(t.format==="date-time")return"z.coerce.date()";n="z.coerce.string()"}return n+=V(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+=V(t,"pattern",({json:r})=>[`.regex(new RegExp(${r})`,", ",")"]),n+=V(t,"minLength",({json:r})=>[`.min(${r}`,", ",")"]),n+=V(t,"maxLength",({json:r})=>[`.max(${r}`,", ",")"]),n},"parseString"),F=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=ey(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"),ey=l((t,e)=>M.a.nullable(t)?Vm(t,e):M.an.object(t)?su(t,e):M.an.array(t)?Mm(t,e):M.an.anyOf(t)?iu(t,e):M.an.allOf(t)?Kt(t,e):M.a.discriminator(t)?zm(t,e):M.a.oneOf(t)?Qr(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}},ty=l(t=>F(t,{seen:new Map,path:[]}),"jsonSchemaToZodStr"),ny=l(t=>{let e=ty(t);e=e.replaceAll("errors: z.ZodError[]","errors");let n=Rm(e);if(!n.sucess)throw new Cn(n.error);return n.value},"jsonSchemaToZod"),Ct=l((t,e)=>{var n,r;if(e[C]&&t._def&&(t.naked()._def[C]=e[C]),((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]&&Ct(a[i],s)}),((r=t._def)==null?void 0:r.typeName)==="ZodRecord"&&e.type==="object"&&e.additionalProperties&&Ct(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&&Ct(s,i)}else Array.isArray(i)&&i.forEach((s,a)=>{let o=t._def;o.typeName===x.ZodTuple&&Ct(o.items[a],s)})}},"applyZuiPropsRecursively"),ry=l(t=>{let e=ny(t);return Ct(e,t),e},"fromJSONSchemaLegacy"),au=class un{constructor(e=[],n=""){this.type="propertyPath",this._sections=e,this._wrapper=n}withIndexType(e,n){return new un([...this._sections,{type:e,value:n}],this._wrapper)}withWrapper(e){return new un([new un([...this._sections],e)])}toString(){let e=this._wrapper?`${this._wrapper}<`:"",n=this._wrapper?">":"",r=this._sections.length===0||this._sections[0].type!=="propertyPath"?"#":"";return`${e}${r}${this._sections.map(i=>{var s;return i.type==="propertyPath"?i.toString():i.type==="key"?`.${i.value}`:i.type==="any"?"[*]":`[${(s=i.value)!=null?s:i.type}]`}).join("")}${n}`}};l(au,"PropertyPath");var qt=au,iy=l(t=>{var e,n;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(r=>typeof r!="boolean"&&ou(r))&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)==="ZodOptional"},"isOptionalSchema"),sy=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"),ou=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"),ay=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"),oy=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"),ly=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"),uy=l((t,e,n)=>cy(t)?py(t,e,n):dy(t)?fy(t,e,n):gy(t,e,n),"arrayJSONSchemaToZuiArray"),cy=l(t=>Array.isArray(t.items),"_isTuple"),dy=l(t=>t.items!==void 0&&t.uniqueItems,"_isSet"),py=l(({items:t,additionalItems:e},n,r)=>{let i=t.map((a,o)=>n(a,r.withIndexType("number",o))),s=Ft(i);return e!==void 0&&(s=s.rest(n(e,r.withIndexType("number")))),s},"_handleTuple"),fy=l(({items:t,minItems:e,maxItems:n},r,i)=>{let s=Bn(r(t,i.withIndexType("number")));return e&&(s=s.min(e)),n&&(s=s.max(n)),s},"_handleSet"),gy=l(({minItems:t,maxItems:e,items:n},r,i)=>{let s=Ke(r(n,i.withIndexType("number")));return t&&t===e?s.length(t):(t&&(s=s.min(t)),e&&(s=s.max(e)),s)},"_handleArray"),my=l(({type:t,minimum:e,exclusiveMinimum:n,maximum:r,exclusiveMaximum:i,multipleOf:s,format:a})=>{let o=et();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"),Zt={};ge(Zt,{escapeSpecialChars:()=>yy});var yy=l(t=>t.replaceAll(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeSpecialChars");function ei(t,e,n,r){r?.errorMessages&&n&&(t.errorMessage=f(c({},t.errorMessage),{[e]:n}))}l(ei,"addErrorMessage");function B(t,e,n,r,i){t[e]=n,ei(t,e,r,i)}l(B,"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 ti(t,e){let n=c({type:"string"},t.coerce?{[C]:{coerce:t.coerce||void 0}}:{});function r(i){return e.patternStrategy==="escape"?Zt.escapeSpecialChars(i):i}if(l(r,"processPattern"),t.checks)for(let i of t.checks)switch(i.kind){case"min":B(n,"minLength",typeof n.minLength=="number"?Math.max(n.minLength,i.value):i.value,i.message,e);break;case"max":B(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":De(n,"email",i.message,e);break;case"format:idn-email":De(n,"idn-email",i.message,e);break;case"pattern:zod":we(n,j.email,i.message,e);break}break;case"url":De(n,"uri",i.message,e);break;case"uuid":De(n,"uuid",i.message,e);break;case"regex":we(n,i.regex.source,i.message,e);break;case"cuid":we(n,j.cuid,i.message,e);break;case"cuid2":we(n,j.cuid2,i.message,e);break;case"startsWith":we(n,"^"+r(i.value),i.message,e);break;case"endsWith":we(n,r(i.value)+"$",i.message,e);break;case"datetime":De(n,"date-time",i.message,e);break;case"length":B(n,"minLength",typeof n.minLength=="number"?Math.max(n.minLength,i.value):i.value,i.message,e),B(n,"maxLength",typeof n.maxLength=="number"?Math.min(n.maxLength,i.value):i.value,i.message,e);break;case"includes":{we(n,r(i.value),i.message,e);break}case"ip":{i.version!=="v6"&&De(n,"ipv4",i.message,e),i.version!=="v4"&&De(n,"ipv6",i.message,e);break}case"emoji":we(n,j.emoji,i.message,e);break;case"ulid":{we(n,j.ulid,i.message,e);break}case"toLowerCase":case"toUpperCase":case"trim":break;default:}return n}l(ti,"parseStringDef");var De=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}}))):B(t,"format",e,n,r)},"addFormat"),we=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}}))):B(t,"pattern",e,n,r)},"addPattern"),hy=l(({format:t,pattern:e,minLength:n,maxLength:r})=>{let i=ke();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?Bo(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"),vt=l((t,e,n)=>{let r=[];e.enum!==void 0&&r.push(...e.enum),e.const!==void 0&&r.push(e.const);let i,s=r.filter(o=>typeof o===t),[a]=s;if(a)if(s.length===1)i=jt(a);else{let o=s.map(u=>jt(u));i=We(o)}else if(t==="string"&&e.type==="string"&&(i=hy(e)),t==="number"&&(e.type==="number"||e.type==="integer")&&(i=my(e)),t==="boolean"&&(i=tt()),t==="null"&&(i=Lt()),!i)throw new Cn(`Unknown primitive type: "${t}"`,n?.toString());return e.description&&(i=i.describe(e.description)),i},"toZuiPrimitive"),He=Fe();function lu(t){return H(t,new qt)}l(lu,"fromJSONSchema");function H(t,e){var n,r,i,s,a,o;if(t===void 0)return He;if(t===!0)return Fe();if(t===!1)return Mt();if(t.default!==void 0)return H(f(c({},t),{default:void 0}),e).default(t.default);if(t.readOnly)return H(f(c({},t),{readOnly:void 0}),e).readonly();if(t.description!==void 0)return H(f(c({},t),{description:void 0}),e).describe(t.description);if(t.patternProperties!==void 0)throw new $e({patternProperties:t.patternProperties},e.toString());if(t.propertyNames!==void 0)throw new $e({propertyNames:t.propertyNames},e.toString());if(t.if!==void 0)throw new $e({if:t.if},e.toString());if(t.then!==void 0)throw new $e({then:t.then},e.toString());if(t.else!==void 0)throw new $e({else:t.else},e.toString());if(t.$ref!==void 0)return On(t.$ref);if(t.not!==void 0){if(ou(t))return Sn();if(t.not===!0)return Mt();throw new $e({not:t.not},e.toString())}if(Array.isArray(t.type)){if(t.type.length===0)return He;if(t.type.length===1)return H(f(c({},t),{type:t.type[0]}),e);let u=t,{type:d}=u,p=rs(u,["type"]),g=t.type.map((m,_)=>H(f(c({},p),{type:m}),e.withIndexType("number",_)));return We(g)}if(t.type==="string")return t.enum&&t.enum.length>0?En(t.enum):vt("string",t,e);if(t.type==="integer"){let u=vt("number",t,e);return u.typeName==="ZodNumber"?u.int():u}if(t.type==="number")return vt("number",t,e);if(t.type==="boolean")return vt("boolean",t,e);if(t.type==="null")return vt("null",t,e);if(t.type==="array")return uy(t,H,e);if(t.type==="object"){if(t.additionalProperties!==void 0&&t.properties!==void 0){let u=H(t.additionalProperties,e.withIndexType("string"));return H(f(c({},t),{additionalProperties:void 0}),e).catchall(u)}if(t.properties!==void 0){let u={};for(let[d,p]of Object.entries(t.properties)){let g=H(p,e.withIndexType("key",d)),m=(n=t.required)!=null?n:[];u[d]=m.includes(d)||g.isOptional()?g:g.optional()}return dt(u)}if(t.additionalProperties!==void 0){let u=H(t.additionalProperties,e.withIndexType("string"));return zt(u)}return zt(He)}if(t.anyOf!==void 0){if(t.anyOf.length===0)return He;if(t.anyOf.length===1)return H(t.anyOf[0],e);if(iy(t))return H(t.anyOf[0],e).optional();if(sy(t))return H(t.anyOf[0],e).nullable();if(oy(t)&&((i=(r=t["x-zui"])==null?void 0:r.def)!=null&&i.discriminator)){let{discriminator:d}=t["x-zui"].def,p=t.anyOf.map((g,m)=>H(g,e.withIndexType("number",m)));return $t(d,p)}let u=t.anyOf.map((d,p)=>H(d,e.withIndexType("number",p)));return We(u)}if(t.oneOf!==void 0){if(t.oneOf.length===0)return He;if(t.oneOf.length===1)return H(t.oneOf[0],e);if(ly(t)){let d=((s=t.discriminator)==null?void 0:s.propertyName)||((o=(a=t["x-zui"])==null?void 0:a.def)==null?void 0:o.discriminator);if(d){let p=t.oneOf.map((g,m)=>H(g,e.withIndexType("number",m)));return $t(d,p)}}let u=t.oneOf.map((d,p)=>H(d,e.withIndexType("number",p)));return We(u)}if(t.allOf!==void 0){if(t.allOf.length===0)return He;if(t.allOf.length===1)return H(t.allOf[0],e);let d=t.allOf.map((p,g)=>H(p,e.withIndexType("number",g)));return d.slice(2).reduce((p,g)=>Ut(p,g),Ut(d[0],d[1]))}return t.type,ay(t)?Ze():He}l(H,"_fromJSONSchema");var vy=/^\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))?$/,_y=l((t,e,n=!0)=>vr(t,new qt,e,n),"fromObject"),vr=l((t,e,n,r=!0)=>{if(typeof t!="object")throw new yr("Input must be an object",e.toString());let i=l(o=>{let u=o;return n?.nullable&&(u=u.nullable()),n?.optional&&(u=u.optional()),n?.passtrough&&E.zuiObject(u)&&(u=u.passthrough()),u},"applyOptions"),s=Object.entries(t).reduce((o,[u,d])=>{let p=e.withIndexType("key",u);if(d===null)o[u]=i(Lt());else switch(typeof d){case"string":o[u]=vy.test(d)?i(ke().datetime()):i(ke());break;case"number":o[u]=i(et());break;case"boolean":o[u]=i(tt());break;case"object":if(Array.isArray(d)){let[g]=d;if(g==null)o[u]=i(Ke(Ze()));else if(typeof g=="object")o[u]=i(Ke(vr(g,p.withIndexType("number"),n,!1)));else if(typeof g=="string"||typeof g=="number"||typeof g=="boolean"){let m=Ty(g);o[u]=i(Ke(m))}}else o[u]=i(vr(d,p,n,!1));break;default:throw new yr(`Unsupported type for key ${u}`,p.toString())}return o},{}),a=Object.keys(s).length>0;return n?.passtrough||!r&&!a?dt(s).passthrough():dt(s)},"_fromObject"),Ty=l(t=>typeof t=="string"?ke():typeof t=="number"?et():typeof t=="boolean"?tt():Ze(),"_getInnerType");function uu(){return{}}l(uu,"parseAnyDef");function cu(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=I(t.type._def,f(c({},e),{currentPath:[...e.currentPath,"items"]}))),t.minLength&&B(i,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&B(i,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(B(i,"minItems",t.exactLength.value,t.exactLength.message,e),B(i,"maxItems",t.exactLength.value,t.exactLength.message,e)),i}l(cu,"parseArrayDef");function du(t,e){let n=c({type:"integer",format:"int64"},t.coerce?{[C]:{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?B(n,"minimum",r.value,r.message,e):B(n,"exclusiveMinimum",r.value,r.message,e):(r.inclusive||(n.exclusiveMinimum=!0),B(n,"minimum",r.value,r.message,e));break;case"max":e.target==="jsonSchema7"?r.inclusive?B(n,"maximum",r.value,r.message,e):B(n,"exclusiveMaximum",r.value,r.message,e):(r.inclusive||(n.exclusiveMaximum=!0),B(n,"maximum",r.value,r.message,e));break;case"multipleOf":B(n,"multipleOf",r.value,r.message,e);break}return n}l(du,"parseBigintDef");function pu(t){return c({type:"boolean"},t.coerce?{[C]:{coerce:t.coerce||void 0}}:{})}l(pu,"parseBooleanDef");function fu(t,e){return I(t.type._def,e)}l(fu,"parseBrandedDef");var by=l((t,e)=>I(t.innerType._def,e),"parseCatchDef");function gu(t,e){return e.dateStrategy==="integer"?wy(t,e):c({type:"string",format:"date-time"},t.coerce?{[C]:{coerce:t.coerce||void 0}}:{})}l(gu,"parseDateDef");var wy=l((t,e)=>{let n=c({type:"integer",format:"unix-time"},t.coerce?{[C]:{coerce:t.coerce||void 0}}:{});for(let r of t.checks)switch(r.kind){case"min":e.target==="jsonSchema7"&&B(n,"minimum",r.value,r.message,e);break;case"max":e.target==="jsonSchema7"&&B(n,"maximum",r.value,r.message,e);break}return n},"integerDateParser");function mu(t,e){return f(c({},I(t.innerType._def,e)),{default:t.defaultValue()})}l(mu,"parseDefaultDef");function yu(t,e){return e.effectStrategy==="input"?I(t.schema._def,e):{}}l(yu,"parseEffectsDef");function hu(t){return{type:"string",enum:t.values}}l(hu,"parseEnumDef");var xy=l(t=>"type"in t&&t.type==="string"?!1:"allOf"in t,"isJsonSchema7AllOfType");function vu(t,e){let n=[I(t.left._def,f(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),I(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(xy(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=rs(o,["additionalProperties"])}else r=void 0;i.push(a)}}),i.length?c({allOf:i},r):void 0}l(vu,"parseIntersectionDef");function _u(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(_u,"parseLiteralDef");function ni(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=I(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"properties",d]})))!=null?p:{}})},{}),additionalProperties:!1};let o={type:"object",additionalProperties:(r=I(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(ti(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(ni,"parseRecordDef");function Tu(t,e){if(e.mapStrategy==="record")return ni(t,e);let n=I(t.keyType._def,f(c({},e),{currentPath:[...e.currentPath,"items","items","0"]}))||{},r=I(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(Tu,"parseMapDef");function bu(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(bu,"parseNativeEnumDef");function wu(){return{not:{}}}l(wu,"parseNeverDef");function xu(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}l(xu,"parseNullDef");var yn={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function Pu(t,e){if(e.target==="openApi3")return Vi(t,e);let n=t.options instanceof Map?Array.from(t.options.values()):t.options;if(n.every(r=>r._def.typeName in yn&&(!r._def.checks||!r._def.checks.length))){let r=n.reduce((i,s)=>{let a=yn[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 Vi(t,e)}l(Pu,"parseUnionDef");var Vi=l((t,e)=>{let n=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((i,s)=>I(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 Su(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:yn[n._def.typeName],nullable:!0};return _r(n._def,e,s)}let i={type:[yn[n._def.typeName],"null"]};return _r(n._def,e,i)}if(e.target==="openApi3"){let i=I(n._def,f(c({},e),{currentPath:[...e.currentPath]}));return i&&f(c({},i),{nullable:!0})}let r=I(n._def,f(c({},e),{currentPath:[...e.currentPath,"anyOf","0"]}));return r&&{anyOf:[r,{type:"null"}]}}l(Su,"parseNullableDef");function ku(t,e){let n=c({type:"number"},t.coerce?{[C]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return n;for(let r of t.checks)switch(r.kind){case"int":n.type="integer",ei(n,"type",r.message,e);break;case"min":e.target==="jsonSchema7"?r.inclusive?B(n,"minimum",r.value,r.message,e):B(n,"exclusiveMinimum",r.value,r.message,e):(r.inclusive||(n.exclusiveMinimum=!0),B(n,"minimum",r.value,r.message,e));break;case"max":e.target==="jsonSchema7"?r.inclusive?B(n,"maximum",r.value,r.message,e):B(n,"exclusiveMaximum",r.value,r.message,e):(r.inclusive||(n.exclusiveMaximum=!0),B(n,"maximum",r.value,r.message,e));break;case"multipleOf":B(n,"multipleOf",r.value,r.message,e);break}return n}l(ku,"parseNumberDef");var{zuiKey:Av}=Ie,Py=l((t,e)=>{var n;return E.zuiType(t.unknownKeys)?t.unknownKeys.typeName==="ZodNever"?!1:(n=I(t.unknownKeys._def,f(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?n:!0:t.unknownKeys==="passthrough"},"getAdditionalProperties");function Iu(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=I(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:Py(t,e)});return n.required.length||delete n.required,n}l(Iu,"parseObjectDef");var Sy=l((t,e)=>{var n;if(e.currentPath.toString()===((n=e.propertyPath)==null?void 0:n.toString()))return I(t.innerType._def,e);let r=I(t.innerType._def,f(c({},e),{currentPath:[...e.currentPath,"anyOf","1"]}));return r?{anyOf:[{not:{}},r]}:{}},"parseOptionalDef"),ky=l((t,e)=>{if(e.pipeStrategy==="input")return I(t.in._def,e);if(e.pipeStrategy==="output")return I(t.out._def,e);let n=I(t.in._def,f(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),r=I(t.out._def,f(c({},e),{currentPath:[...e.currentPath,"allOf",n?"1":"0"]}));return{allOf:[n,r].filter(i=>i!==void 0)}},"parsePipelineDef");function Ou(t,e){return I(t.type._def,e)}l(Ou,"parsePromiseDef");var Iy=l((t,e)=>I(t.innerType._def,e),"parseReadonlyDef");function Eu(t){return{$ref:t.uri}}l(Eu,"parseRefDef");function Bu(t,e){let r={type:"array",uniqueItems:!0,items:I(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"items"]}))};return t.minSize&&B(r,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&B(r,"maxItems",t.maxSize.value,t.maxSize.message,e),r}l(Bu,"parseSetDef");function Cu(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((n,r)=>I(n._def,f(c({},e),{currentPath:[...e.currentPath,"items",`${r}`]}))).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:I(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)=>I(n._def,f(c({},e),{currentPath:[...e.currentPath,"items",`${r}`]}))).reduce((n,r)=>r===void 0?n:[...n,r],[])}}l(Cu,"parseTupleDef");function Au(){return{not:{}}}l(Au,"parseUndefinedDef");function Zu(){return{}}l(Zu,"parseUnknownDef");function I(t,e,n=!1){let r=e.seen.get(t);if(r&&!n){let a=Oy(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=By(t,t.typeName,e);return s&&_r(t,e,s),i.jsonSchema=s,s}l(I,"parseDef");var Oy=l((t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Ey(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"),Ey=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"),By=l((t,e,n)=>{switch(e){case x.ZodString:return ti(t,n);case x.ZodNumber:return ku(t,n);case x.ZodObject:return Iu(t,n);case x.ZodBigInt:return du(t,n);case x.ZodBoolean:return pu(t);case x.ZodDate:return gu(t,n);case x.ZodUndefined:return Au();case x.ZodNull:return xu(n);case x.ZodArray:return cu(t,n);case x.ZodUnion:case x.ZodDiscriminatedUnion:return Pu(t,n);case x.ZodIntersection:return vu(t,n);case x.ZodTuple:return Cu(t,n);case x.ZodRecord:return ni(t,n);case x.ZodRef:return Eu(t);case x.ZodLiteral:return _u(t,n);case x.ZodEnum:return hu(t);case x.ZodNativeEnum:return bu(t);case x.ZodNullable:return Su(t,n);case x.ZodOptional:return Sy(t,n);case x.ZodMap:return Tu(t,n);case x.ZodSet:return Bu(t,n);case x.ZodLazy:return I(t.getter()._def,n);case x.ZodPromise:return Ou(t,n);case x.ZodNaN:case x.ZodNever:return wu();case x.ZodEffects:return yu(t,n);case x.ZodAny:return uu();case x.ZodUnknown:return Zu();case x.ZodDefault:return mu(t,n);case x.ZodBranded:return fu(t,n);case x.ZodReadonly:return Iy(t,n);case x.ZodCatch:return by(t,n);case x.ZodPipeline:return ky(t,n);case x.ZodFunction:case x.ZodVoid:case x.ZodSymbol:return;default:return(r=>{})(e)}},"selectParser"),_r=l((t,e,n)=>(t.description&&(n.description=t.description,e.markdownDescription&&(n.markdownDescription=t.description)),Object.assign(n,{[C]:c(c({},t[C]),n[C])}),n),"addMeta"),Gi={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"string",mapStrategy:"entries",definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",emailStrategy:"format:email",discriminator:!1,unionStrategy:"anyOf"},Cy=l(t=>typeof t=="string"?f(c({},Gi),{name:t}):c(c({},Gi),t),"getDefaultOptions"),Ay=l(t=>{let e=Cy(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"),Zy=l((t,e)=>{var n;let r=Ay(e),i=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((u,[d,p])=>{var g;return f(c({},u),{[d]:(g=I(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=I(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"),Ry=l((t,e={target:"openApi3"})=>{let n=Zy(t,e);return e.$schemaUrl===!1?delete n.$schema:typeof e.$schemaUrl=="string"&&(n.$schema=e.$schemaUrl),n},"toJSONSchemaLegacy"),{zuiKey:tr}=Ie,Ny=l((t,e)=>{let n={type:"array",description:t.description,items:e(t._def.type),"x-zui":t._def["x-zui"]};return t._def[tr]&&(n[tr]=t._def[tr]),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:nr}=Ie,Dy=l(t=>{let e={type:"number",description:t.description,"x-zui":t._def["x-zui"]};t._def[nr]&&(e[nr]=t._def[nr]);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:rr}=Ie,Hy=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[rr]&&(n[rr]=t._def[rr]),t._def.minSize&&(n.minItems=t._def.minSize.value),t._def.maxSize&&(n.maxItems=t._def.maxSize.value),n},"zodSetToJsonSet"),{zuiKey:_t}=Ie,My=l((t,e)=>{let n={type:"string",description:t.description,"x-zui":t._def["x-zui"]};t._def[_t]&&(n[_t]=t._def[_t]);for(let r of t._def.checks)switch(r.kind){case"cuid":n.format="cuid",n.pattern=j.cuid;break;case"cuid2":n.format="cuid2",n.pattern=j.cuid2;break;case"ulid":n.format="ulid",n.pattern=j.ulid;break;case"uuid":n.format="uuid",n.pattern=j.uuid;break;case"emoji":n.format="emoji",n.pattern=j.emoji;break;case"email":n.format="email",n.pattern=j.email;break;case"ip":n.format=r.version==="v6"?"ipv6":"ipv4",n.pattern=r.version==="v6"?j.ipv6:j.ipv4;break;case"datetime":n.format="date-time",(r.precision!==null||r.offset)&&(n.pattern=Eo(r).source,n[_t]=f(c({},n[_t]),{precision:r.precision,offset:r.offset}));break;case"url":n.format="uri";break;case"endsWith":n.pattern=`${Zt.escapeSpecialChars(r.value)}$`;break;case"startsWith":n.pattern=`^${Zt.escapeSpecialChars(r.value)}`;break;case"includes":let i=r.position&&r.position>=1?`^(?:.{${r.position}}).*`:"";n.pattern=`${i}${Zt.escapeSpecialChars(r.value)}`;break;case"regex":n.pattern=r.regex.source;break;case"length":n.minLength=n.maxLength=Math.max(0,r.value);break;case"min":n.minLength=Math.max(0,r.value);break;case"max":n.maxLength=Math.max(0,r.value);break;default:throw new Vl("ZodString",r.kind,e.toString())}return n},"zodStringToJsonString"),{zuiKey:ir}=Ie,jy=l((t,e,n)=>{let r={type:"array",description:t.description,items:t._def.items.map((i,s)=>e(i,n.withIndexType("number",s)))};return t._def[ir]&&(r[ir]=t._def[ir]),t._def.rest&&(r.additionalItems=e(t._def.rest,n.withIndexType("number"))),r},"zodTupleToJsonTuple"),$y={unionStrategy:"anyOf",discriminatedUnionStrategy:"oneOf",discriminator:!0};function ri(t,e={}){return L(t,e,new qt)}l(ri,"toJSONSchema");function L(t,e={},n){let r=c(c({},$y),e),i=t;switch(i.typeName){case"ZodString":return My(i,n);case"ZodNumber":return Dy(i);case"ZodNaN":throw new Y("ZodNaN",n.toString());case"ZodBigInt":throw new Y("ZodBigInt",n.toString(),{suggestedAlternative:"serialize bigint to string"});case"ZodBoolean":return{type:"boolean",description:i.description,"x-zui":i._def["x-zui"]};case"ZodDate":throw new Y("ZodDate",n.toString(),{suggestedAlternative:"use z.string().datetime() instead"});case"ZodUndefined":return sr(i);case"ZodNull":return ar(i);case"ZodAny":return{description:i.description,"x-zui":i._def["x-zui"]};case"ZodUnknown":return{description:i.description,"x-zui":f(c({},i._def["x-zui"]),{def:{typeName:"ZodUnknown"}})};case"ZodNever":return{not:!0,description:i.description,"x-zui":i._def["x-zui"]};case"ZodVoid":throw new Y("ZodVoid",n.toString());case"ZodArray":return Ny(i,g=>L(g,r,n.withIndexType("number")));case"ZodObject":let s=Object.entries(i.shape),a=s.filter(([g,m])=>!m.isOptional()),o=a.length?a.map(([g])=>g):void 0,u=s.map(([g,m])=>[g,m.mandatory()]).map(([g,m])=>[g,L(m,r,n.withIndexType("key",g))]);return{type:"object",description:i.description,properties:Object.fromEntries(u),required:o,additionalProperties:Uy(i._def,r,n),"x-zui":i._def["x-zui"]};case"ZodUnion":return r.unionStrategy==="oneOf"?{description:i.description,oneOf:i.options.map((g,m)=>L(g,r,n.withIndexType("number",m))),"x-zui":i._def["x-zui"]}:{description:i.description,anyOf:i.options.map((g,m)=>L(g,r,n.withIndexType("number",m))),"x-zui":i._def["x-zui"]};case"ZodDiscriminatedUnion":if(r.discriminatedUnionStrategy==="oneOf"){let g=r.discriminator?{propertyName:i.discriminator}:void 0;return{description:i.description,oneOf:i.options.map((m,_)=>L(m,r,n.withIndexType("number",_))),discriminator:g,"x-zui":f(c({},i._def["x-zui"]),{def:{typeName:"ZodDiscriminatedUnion",discriminator:i.discriminator}})}}return{description:i.description,anyOf:i.options.map((g,m)=>L(g,r,n.withIndexType("number",m))),"x-zui":f(c({},i._def["x-zui"]),{def:{typeName:"ZodDiscriminatedUnion",discriminator:i.discriminator}})};case"ZodIntersection":let d=L(i._def.left,r,n.withIndexType("number",0)),p=L(i._def.right,r,n.withIndexType("number",1));return"additionalProperties"in d&&delete d.additionalProperties,"additionalProperties"in p&&delete p.additionalProperties,{description:i.description,allOf:[d,p],"x-zui":i._def["x-zui"]};case"ZodTuple":return jy(i,(g,m)=>L(g,r,m),n);case"ZodRecord":{let g=i._def.keyType,m=E.zuiString(g)?n.withIndexType("string"):E.zuiNumber(g)?n.withIndexType("number"):n.withIndexType("any");return{type:"object",description:i.description,additionalProperties:L(i._def.valueType,r,m),"x-zui":i._def["x-zui"]}}case"ZodMap":throw new Y("ZodMap",n.toString());case"ZodSet":return Hy(i,g=>L(g,r,n.withIndexType("number")));case"ZodFunction":throw new Y("ZodFunction",n.toString());case"ZodLazy":throw new Y("ZodLazy",n.toString());case"ZodLiteral":if(typeof i.value=="string")return{type:"string",description:i.description,const:i.value,"x-zui":i._def["x-zui"]};if(typeof i.value=="number")return{type:"number",description:i.description,const:i.value,"x-zui":i._def["x-zui"]};if(typeof i.value=="boolean")return{type:"boolean",description:i.description,const:i.value,"x-zui":i._def["x-zui"]};if(i.value===null)return ar(i._def);if(i.value===void 0)return sr(i._def);{i.value;let g=typeof i.value;throw new An(`Unsupported literal type: "${g}"`,n.toString())}case"ZodEnum":return{type:"string",description:i.description,enum:i._def.values,"x-zui":i._def["x-zui"]};case"ZodEffects":throw new Y("ZodEffects",n.toString());case"ZodNativeEnum":throw new Y("ZodNativeEnum",n.toString());case"ZodOptional":return{description:i.description,anyOf:[L(i._def.innerType,r,n),sr()],"x-zui":f(c({},i._def["x-zui"]),{def:{typeName:"ZodOptional"}})};case"ZodNullable":return{anyOf:[L(i._def.innerType,r,n),ar()],"x-zui":f(c({},i._def["x-zui"]),{def:{typeName:"ZodNullable"}})};case"ZodDefault":return f(c({},L(i._def.innerType,r,n)),{default:i._def.defaultValue()});case"ZodCatch":throw new Y("ZodCatch",n.toString());case"ZodPromise":throw new Y("ZodPromise",n.toString());case"ZodBranded":throw new Y("ZodBranded",n.toString());case"ZodPipeline":throw new Y("ZodPipeline",n.toString());case"ZodSymbol":throw new Y("ZodSymbol",n.toString());case"ZodReadonly":return f(c({},L(i._def.innerType,r,n)),{readOnly:!0});case"ZodRef":return{$ref:i._def.uri,description:i.description,"x-zui":i._def["x-zui"]};default:fe.assertNever(i)}}l(L,"_toJSONSchema");var sr=l(t=>({not:!0,description:t?.description,"x-zui":f(c({},t?.["x-zui"]),{def:{typeName:"ZodUndefined"}})}),"undefinedSchema"),ar=l(t=>({type:"null",description:t?.description,"x-zui":t?.["x-zui"]}),"nullSchema"),Uy=l((t,e,n)=>t.unknownKeys==="passthrough"?!0:t.unknownKeys==="strict"||!E.zuiType(t.unknownKeys)||t.unknownKeys.typeName==="ZodNever"?!1:L(t.unknownKeys,e,n.withIndexType("string")),"additionalPropertiesSchema");function Ru(t){return typeof t=="symbol"?"symbol":typeof t=="bigint"?`${t.toString()}n`:T(t)}l(Ru,"primitiveToTypscriptLiteralType");function T(t){return typeof t>"u"?"undefined":typeof t=="symbol"?t.description?`Symbol(${T(t.description)})`:"Symbol()":typeof t=="bigint"?`BigInt(${t.toString()})`:typeof t=="string"?Hu(t):JSON.stringify(t)}l(T,"primitiveToTypescriptValue");function ut(t){return typeof t>"u"?"undefined":JSON.stringify(t)}l(ut,"unknownToTypescriptValue");var Nu=l((t,e)=>{let n=Object.entries(t),r=e?" as const":"";return`{ ${n.map(([i,s])=>`${Tr(i)}: ${ut(s)}`).join(", ")} }${r}`},"recordOfUnknownToTypescriptRecord"),Tr=l(t=>/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t)?t:T(t),"toPropertyKey"),zy=l(t=>t.charAt(0).toUpperCase()+t.slice(1),"capitalize"),Du=l(t=>{let e=/[^a-zA-Z0-9_]/g;return t.split(e).map(zy).filter(r=>!!r).join("")},"toTypeArgumentName"),Ji=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"),W=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(${au(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(${ti(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(${Kt(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(ou,"parseObject");var Xm=l(t=>`z.ref('${t.$ref}')`,"parseRef"),Qm=l(t=>{var e;let n="z.string()";if((e=t[C])!=null&&e.coerce){if(t.format==="date-time")return"z.coerce.date()";n="z.coerce.string()"}return n+=V(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+=V(t,"pattern",({json:r})=>[`.regex(new RegExp(${r})`,", ",")"]),n+=V(t,"minLength",({json:r})=>[`.min(${r}`,", ",")"]),n+=V(t,"maxLength",({json:r})=>[`.max(${r}`,", ",")"]),n},"parseString"),F=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=ny(t,e);return n||(i=ey(t,i),e.withoutDefaults||(i=ty(t,i))),r.r=i,i},"parseSchema"),ey=l((t,e)=>(t.description&&(e+=`.describe(${JSON.stringify(t.description)})`),e),"addMeta"),ty=l((t,e)=>(t.default!==void 0&&(e+=`.default(${JSON.stringify(t.default)})`),e),"addDefaults"),ny=l((t,e)=>M.a.nullable(t)?Jm(t,e):M.an.object(t)?ou(t,e):M.an.array(t)?$m(t,e):M.an.anyOf(t)?au(t,e):M.an.allOf(t)?Kt(t,e):M.a.discriminator(t)?Wm(t,e):M.a.oneOf(t)?ti(t,e):M.a.not(t)?Vm(t,e):M.an.enum(t)?Lm(t):M.a.const(t)?Um(t):M.a.multipleType(t)?qm(t,e):M.a.primitive(t,"string")?Qm(t):M.a.primitive(t,"number")||M.a.primitive(t,"integer")?Ym(t):M.a.primitive(t,"boolean")?zm(t):M.a.primitive(t,"null")?Gm(t):M.a.conditional(t)?Fm(t,e):M.a.ref(t)?Xm(t):Km(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}},ry=l(t=>F(t,{seen:new Map,path:[]}),"jsonSchemaToZodStr"),iy=l(t=>{let e=ry(t);e=e.replaceAll("errors: z.ZodError[]","errors");let n=Nm(e);if(!n.sucess)throw new Cn(n.error);return n.value},"jsonSchemaToZod"),Ct=l((t,e)=>{var n,r;if(e[C]&&t._def&&(t.naked()._def[C]=e[C]),((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]&&Ct(a[i],s)}),((r=t._def)==null?void 0:r.typeName)==="ZodRecord"&&e.type==="object"&&e.additionalProperties&&Ct(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&&Ct(s,i)}else Array.isArray(i)&&i.forEach((s,a)=>{let o=t._def;o.typeName===x.ZodTuple&&Ct(o.items[a],s)})}},"applyZuiPropsRecursively"),sy=l(t=>{let e=iy(t);return Ct(e,t),e},"fromJSONSchemaLegacy"),lu=class un{constructor(e=[],n=""){this.type="propertyPath",this._sections=e,this._wrapper=n}withIndexType(e,n){return new un([...this._sections,{type:e,value:n}],this._wrapper)}withWrapper(e){return new un([new un([...this._sections],e)])}toString(){let e=this._wrapper?`${this._wrapper}<`:"",n=this._wrapper?">":"",r=this._sections.length===0||this._sections[0].type!=="propertyPath"?"#":"";return`${e}${r}${this._sections.map(i=>{var s;return i.type==="propertyPath"?i.toString():i.type==="key"?`.${i.value}`:i.type==="any"?"[*]":`[${(s=i.value)!=null?s:i.type}]`}).join("")}${n}`}};l(lu,"PropertyPath");var qt=lu,ay=l(t=>{var e,n;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(r=>typeof r!="boolean"&&uu(r))&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)==="ZodOptional"},"isOptionalSchema"),oy=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"),uu=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"),ly=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"),uy=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"),cy=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"),dy=l((t,e,n)=>py(t)?gy(t,e,n):fy(t)?my(t,e,n):yy(t,e,n),"arrayJSONSchemaToZuiArray"),py=l(t=>Array.isArray(t.items),"_isTuple"),fy=l(t=>t.items!==void 0&&t.uniqueItems,"_isSet"),gy=l(({items:t,additionalItems:e},n,r)=>{let i=t.map((a,o)=>n(a,r.withIndexType("number",o))),s=Ft(i);return e!==void 0&&(s=s.rest(n(e,r.withIndexType("number")))),s},"_handleTuple"),my=l(({items:t,minItems:e,maxItems:n},r,i)=>{let s=Bn(r(t,i.withIndexType("number")));return e&&(s=s.min(e)),n&&(s=s.max(n)),s},"_handleSet"),yy=l(({minItems:t,maxItems:e,items:n},r,i)=>{let s=Ke(r(n,i.withIndexType("number")));return t&&t===e?s.length(t):(t&&(s=s.min(t)),e&&(s=s.max(e)),s)},"_handleArray"),hy=l(({type:t,minimum:e,exclusiveMinimum:n,maximum:r,exclusiveMaximum:i,multipleOf:s,format:a})=>{let o=et();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"),Rt={};ge(Rt,{escapeSpecialChars:()=>vy});var vy=l(t=>t.replaceAll(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeSpecialChars");function ni(t,e,n,r){r?.errorMessages&&n&&(t.errorMessage=f(c({},t.errorMessage),{[e]:n}))}l(ni,"addErrorMessage");function B(t,e,n,r,i){t[e]=n,ni(t,e,r,i)}l(B,"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 ri(t,e){let n=c({type:"string"},t.coerce?{[C]:{coerce:t.coerce||void 0}}:{});function r(i){return e.patternStrategy==="escape"?Rt.escapeSpecialChars(i):i}if(l(r,"processPattern"),t.checks)for(let i of t.checks)switch(i.kind){case"min":B(n,"minLength",typeof n.minLength=="number"?Math.max(n.minLength,i.value):i.value,i.message,e);break;case"max":B(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":Ne(n,"email",i.message,e);break;case"format:idn-email":Ne(n,"idn-email",i.message,e);break;case"pattern:zod":we(n,j.email,i.message,e);break}break;case"url":Ne(n,"uri",i.message,e);break;case"uuid":Ne(n,"uuid",i.message,e);break;case"regex":we(n,i.regex.source,i.message,e);break;case"cuid":we(n,j.cuid,i.message,e);break;case"cuid2":we(n,j.cuid2,i.message,e);break;case"startsWith":we(n,"^"+r(i.value),i.message,e);break;case"endsWith":we(n,r(i.value)+"$",i.message,e);break;case"datetime":Ne(n,"date-time",i.message,e);break;case"length":B(n,"minLength",typeof n.minLength=="number"?Math.max(n.minLength,i.value):i.value,i.message,e),B(n,"maxLength",typeof n.maxLength=="number"?Math.min(n.maxLength,i.value):i.value,i.message,e);break;case"includes":{we(n,r(i.value),i.message,e);break}case"ip":{i.version!=="v6"&&Ne(n,"ipv4",i.message,e),i.version!=="v4"&&Ne(n,"ipv6",i.message,e);break}case"emoji":we(n,j.emoji,i.message,e);break;case"ulid":{we(n,j.ulid,i.message,e);break}case"toLowerCase":case"toUpperCase":case"trim":break;default:}return n}l(ri,"parseStringDef");var Ne=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}}))):B(t,"format",e,n,r)},"addFormat"),we=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}}))):B(t,"pattern",e,n,r)},"addPattern"),_y=l(({format:t,pattern:e,minLength:n,maxLength:r})=>{let i=ke();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?Ao(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"),vt=l((t,e,n)=>{let r=[];e.enum!==void 0&&r.push(...e.enum),e.const!==void 0&&r.push(e.const);let i,s=r.filter(o=>typeof o===t),[a]=s;if(a)if(s.length===1)i=jt(a);else{let o=s.map(u=>jt(u));i=We(o)}else if(t==="string"&&e.type==="string"&&(i=_y(e)),t==="number"&&(e.type==="number"||e.type==="integer")&&(i=hy(e)),t==="boolean"&&(i=tt()),t==="null"&&(i=Lt()),!i)throw new Cn(`Unknown primitive type: "${t}"`,n?.toString());return e.description&&(i=i.describe(e.description)),i},"toZuiPrimitive"),He=Fe();function cu(t){return H(t,new qt)}l(cu,"fromJSONSchema");function H(t,e){var n,r,i,s,a,o;if(t===void 0)return He;if(t===!0)return Fe();if(t===!1)return Mt();if(t.default!==void 0)return H(f(c({},t),{default:void 0}),e).default(t.default);if(t.readOnly)return H(f(c({},t),{readOnly:void 0}),e).readonly();if(t.description!==void 0)return H(f(c({},t),{description:void 0}),e).describe(t.description);if(t.patternProperties!==void 0)throw new $e({patternProperties:t.patternProperties},e.toString());if(t.propertyNames!==void 0)throw new $e({propertyNames:t.propertyNames},e.toString());if(t.if!==void 0)throw new $e({if:t.if},e.toString());if(t.then!==void 0)throw new $e({then:t.then},e.toString());if(t.else!==void 0)throw new $e({else:t.else},e.toString());if(t.$ref!==void 0)return On(t.$ref);if(t.not!==void 0){if(uu(t))return Sn();if(t.not===!0)return Mt();throw new $e({not:t.not},e.toString())}if(Array.isArray(t.type)){if(t.type.length===0)return He;if(t.type.length===1)return H(f(c({},t),{type:t.type[0]}),e);let u=t,{type:d}=u,p=ss(u,["type"]),g=t.type.map((m,_)=>H(f(c({},p),{type:m}),e.withIndexType("number",_)));return We(g)}if(t.type==="string")return t.enum&&t.enum.length>0?En(t.enum):vt("string",t,e);if(t.type==="integer"){let u=vt("number",t,e);return u.typeName==="ZodNumber"?u.int():u}if(t.type==="number")return vt("number",t,e);if(t.type==="boolean")return vt("boolean",t,e);if(t.type==="null")return vt("null",t,e);if(t.type==="array")return dy(t,H,e);if(t.type==="object"){if(t.additionalProperties!==void 0&&t.properties!==void 0){let u=H(t.additionalProperties,e.withIndexType("string"));return H(f(c({},t),{additionalProperties:void 0}),e).catchall(u)}if(t.properties!==void 0){let u={};for(let[d,p]of Object.entries(t.properties)){let g=H(p,e.withIndexType("key",d)),m=(n=t.required)!=null?n:[];u[d]=m.includes(d)||g.isOptional()?g:g.optional()}return dt(u)}if(t.additionalProperties!==void 0){let u=H(t.additionalProperties,e.withIndexType("string"));return Ut(u)}return Ut(He)}if(t.anyOf!==void 0){if(t.anyOf.length===0)return He;if(t.anyOf.length===1)return H(t.anyOf[0],e);if(ay(t))return H(t.anyOf[0],e).optional();if(oy(t))return H(t.anyOf[0],e).nullable();if(uy(t)&&((i=(r=t["x-zui"])==null?void 0:r.def)!=null&&i.discriminator)){let{discriminator:d}=t["x-zui"].def,p=t.anyOf.map((g,m)=>H(g,e.withIndexType("number",m)));return $t(d,p)}let u=t.anyOf.map((d,p)=>H(d,e.withIndexType("number",p)));return We(u)}if(t.oneOf!==void 0){if(t.oneOf.length===0)return He;if(t.oneOf.length===1)return H(t.oneOf[0],e);if(cy(t)){let d=((s=t.discriminator)==null?void 0:s.propertyName)||((o=(a=t["x-zui"])==null?void 0:a.def)==null?void 0:o.discriminator);if(d){let p=t.oneOf.map((g,m)=>H(g,e.withIndexType("number",m)));return $t(d,p)}}let u=t.oneOf.map((d,p)=>H(d,e.withIndexType("number",p)));return We(u)}if(t.allOf!==void 0){if(t.allOf.length===0)return He;if(t.allOf.length===1)return H(t.allOf[0],e);let d=t.allOf.map((p,g)=>H(p,e.withIndexType("number",g)));return d.slice(2).reduce((p,g)=>zt(p,g),zt(d[0],d[1]))}return t.type,ly(t)?Re():He}l(H,"_fromJSONSchema");var Ty=/^\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))?$/,by=l((t,e,n=!0)=>Tr(t,new qt,e,n),"fromObject"),Tr=l((t,e,n,r=!0)=>{if(typeof t!="object")throw new vr("Input must be an object",e.toString());let i=l(o=>{let u=o;return n?.nullable&&(u=u.nullable()),n?.optional&&(u=u.optional()),n?.passtrough&&E.zuiObject(u)&&(u=u.passthrough()),u},"applyOptions"),s=Object.entries(t).reduce((o,[u,d])=>{let p=e.withIndexType("key",u);if(d===null)o[u]=i(Lt());else switch(typeof d){case"string":o[u]=Ty.test(d)?i(ke().datetime()):i(ke());break;case"number":o[u]=i(et());break;case"boolean":o[u]=i(tt());break;case"object":if(Array.isArray(d)){let[g]=d;if(g==null)o[u]=i(Ke(Re()));else if(typeof g=="object")o[u]=i(Ke(Tr(g,p.withIndexType("number"),n,!1)));else if(typeof g=="string"||typeof g=="number"||typeof g=="boolean"){let m=wy(g);o[u]=i(Ke(m))}}else o[u]=i(Tr(d,p,n,!1));break;default:throw new vr(`Unsupported type for key ${u}`,p.toString())}return o},{}),a=Object.keys(s).length>0;return n?.passtrough||!r&&!a?dt(s).passthrough():dt(s)},"_fromObject"),wy=l(t=>typeof t=="string"?ke():typeof t=="number"?et():typeof t=="boolean"?tt():Re(),"_getInnerType");function du(){return{}}l(du,"parseAnyDef");function pu(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=I(t.type._def,f(c({},e),{currentPath:[...e.currentPath,"items"]}))),t.minLength&&B(i,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&B(i,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(B(i,"minItems",t.exactLength.value,t.exactLength.message,e),B(i,"maxItems",t.exactLength.value,t.exactLength.message,e)),i}l(pu,"parseArrayDef");function fu(t,e){let n=c({type:"integer",format:"int64"},t.coerce?{[C]:{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?B(n,"minimum",r.value,r.message,e):B(n,"exclusiveMinimum",r.value,r.message,e):(r.inclusive||(n.exclusiveMinimum=!0),B(n,"minimum",r.value,r.message,e));break;case"max":e.target==="jsonSchema7"?r.inclusive?B(n,"maximum",r.value,r.message,e):B(n,"exclusiveMaximum",r.value,r.message,e):(r.inclusive||(n.exclusiveMaximum=!0),B(n,"maximum",r.value,r.message,e));break;case"multipleOf":B(n,"multipleOf",r.value,r.message,e);break}return n}l(fu,"parseBigintDef");function gu(t){return c({type:"boolean"},t.coerce?{[C]:{coerce:t.coerce||void 0}}:{})}l(gu,"parseBooleanDef");function mu(t,e){return I(t.type._def,e)}l(mu,"parseBrandedDef");var xy=l((t,e)=>I(t.innerType._def,e),"parseCatchDef");function yu(t,e){return e.dateStrategy==="integer"?Py(t,e):c({type:"string",format:"date-time"},t.coerce?{[C]:{coerce:t.coerce||void 0}}:{})}l(yu,"parseDateDef");var Py=l((t,e)=>{let n=c({type:"integer",format:"unix-time"},t.coerce?{[C]:{coerce:t.coerce||void 0}}:{});for(let r of t.checks)switch(r.kind){case"min":e.target==="jsonSchema7"&&B(n,"minimum",r.value,r.message,e);break;case"max":e.target==="jsonSchema7"&&B(n,"maximum",r.value,r.message,e);break}return n},"integerDateParser");function hu(t,e){return f(c({},I(t.innerType._def,e)),{default:t.defaultValue()})}l(hu,"parseDefaultDef");function vu(t,e){return e.effectStrategy==="input"?I(t.schema._def,e):{}}l(vu,"parseEffectsDef");function _u(t){return{type:"string",enum:t.values}}l(_u,"parseEnumDef");var Sy=l(t=>"type"in t&&t.type==="string"?!1:"allOf"in t,"isJsonSchema7AllOfType");function Tu(t,e){let n=[I(t.left._def,f(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),I(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(Sy(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=ss(o,["additionalProperties"])}else r=void 0;i.push(a)}}),i.length?c({allOf:i},r):void 0}l(Tu,"parseIntersectionDef");function bu(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(bu,"parseLiteralDef");function ii(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=I(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"properties",d]})))!=null?p:{}})},{}),additionalProperties:!1};let o={type:"object",additionalProperties:(r=I(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(ri(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(ii,"parseRecordDef");function wu(t,e){if(e.mapStrategy==="record")return ii(t,e);let n=I(t.keyType._def,f(c({},e),{currentPath:[...e.currentPath,"items","items","0"]}))||{},r=I(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(wu,"parseMapDef");function xu(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(xu,"parseNativeEnumDef");function Pu(){return{not:{}}}l(Pu,"parseNeverDef");function Su(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}l(Su,"parseNullDef");var yn={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function ku(t,e){if(e.target==="openApi3")return Ji(t,e);let n=t.options instanceof Map?Array.from(t.options.values()):t.options;if(n.every(r=>r._def.typeName in yn&&(!r._def.checks||!r._def.checks.length))){let r=n.reduce((i,s)=>{let a=yn[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 Ji(t,e)}l(ku,"parseUnionDef");var Ji=l((t,e)=>{let n=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((i,s)=>I(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 Iu(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:yn[n._def.typeName],nullable:!0};return br(n._def,e,s)}let i={type:[yn[n._def.typeName],"null"]};return br(n._def,e,i)}if(e.target==="openApi3"){let i=I(n._def,f(c({},e),{currentPath:[...e.currentPath]}));return i&&f(c({},i),{nullable:!0})}let r=I(n._def,f(c({},e),{currentPath:[...e.currentPath,"anyOf","0"]}));return r&&{anyOf:[r,{type:"null"}]}}l(Iu,"parseNullableDef");function Ou(t,e){let n=c({type:"number"},t.coerce?{[C]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return n;for(let r of t.checks)switch(r.kind){case"int":n.type="integer",ni(n,"type",r.message,e);break;case"min":e.target==="jsonSchema7"?r.inclusive?B(n,"minimum",r.value,r.message,e):B(n,"exclusiveMinimum",r.value,r.message,e):(r.inclusive||(n.exclusiveMinimum=!0),B(n,"minimum",r.value,r.message,e));break;case"max":e.target==="jsonSchema7"?r.inclusive?B(n,"maximum",r.value,r.message,e):B(n,"exclusiveMaximum",r.value,r.message,e):(r.inclusive||(n.exclusiveMaximum=!0),B(n,"maximum",r.value,r.message,e));break;case"multipleOf":B(n,"multipleOf",r.value,r.message,e);break}return n}l(Ou,"parseNumberDef");var{zuiKey:Zv}=Ie,ky=l((t,e)=>{var n;return E.zuiType(t.unknownKeys)?t.unknownKeys.typeName==="ZodNever"?!1:(n=I(t.unknownKeys._def,f(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?n:!0:t.unknownKeys==="passthrough"},"getAdditionalProperties");function Eu(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=I(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:ky(t,e)});return n.required.length||delete n.required,n}l(Eu,"parseObjectDef");var Iy=l((t,e)=>{var n;if(e.currentPath.toString()===((n=e.propertyPath)==null?void 0:n.toString()))return I(t.innerType._def,e);let r=I(t.innerType._def,f(c({},e),{currentPath:[...e.currentPath,"anyOf","1"]}));return r?{anyOf:[{not:{}},r]}:{}},"parseOptionalDef"),Oy=l((t,e)=>{if(e.pipeStrategy==="input")return I(t.in._def,e);if(e.pipeStrategy==="output")return I(t.out._def,e);let n=I(t.in._def,f(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),r=I(t.out._def,f(c({},e),{currentPath:[...e.currentPath,"allOf",n?"1":"0"]}));return{allOf:[n,r].filter(i=>i!==void 0)}},"parsePipelineDef");function Bu(t,e){return I(t.type._def,e)}l(Bu,"parsePromiseDef");var Ey=l((t,e)=>I(t.innerType._def,e),"parseReadonlyDef");function Cu(t){return{$ref:t.uri}}l(Cu,"parseRefDef");function Au(t,e){let r={type:"array",uniqueItems:!0,items:I(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"items"]}))};return t.minSize&&B(r,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&B(r,"maxItems",t.maxSize.value,t.maxSize.message,e),r}l(Au,"parseSetDef");function Ru(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((n,r)=>I(n._def,f(c({},e),{currentPath:[...e.currentPath,"items",`${r}`]}))).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:I(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)=>I(n._def,f(c({},e),{currentPath:[...e.currentPath,"items",`${r}`]}))).reduce((n,r)=>r===void 0?n:[...n,r],[])}}l(Ru,"parseTupleDef");function Zu(){return{not:{}}}l(Zu,"parseUndefinedDef");function Du(){return{}}l(Du,"parseUnknownDef");function I(t,e,n=!1){let r=e.seen.get(t);if(r&&!n){let a=By(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=Ay(t,t.typeName,e);return s&&br(t,e,s),i.jsonSchema=s,s}l(I,"parseDef");var By=l((t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Cy(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"),Cy=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"),Ay=l((t,e,n)=>{switch(e){case x.ZodString:return ri(t,n);case x.ZodNumber:return Ou(t,n);case x.ZodObject:return Eu(t,n);case x.ZodBigInt:return fu(t,n);case x.ZodBoolean:return gu(t);case x.ZodDate:return yu(t,n);case x.ZodUndefined:return Zu();case x.ZodNull:return Su(n);case x.ZodArray:return pu(t,n);case x.ZodUnion:case x.ZodDiscriminatedUnion:return ku(t,n);case x.ZodIntersection:return Tu(t,n);case x.ZodTuple:return Ru(t,n);case x.ZodRecord:return ii(t,n);case x.ZodRef:return Cu(t);case x.ZodLiteral:return bu(t,n);case x.ZodEnum:return _u(t);case x.ZodNativeEnum:return xu(t);case x.ZodNullable:return Iu(t,n);case x.ZodOptional:return Iy(t,n);case x.ZodMap:return wu(t,n);case x.ZodSet:return Au(t,n);case x.ZodLazy:return I(t.getter()._def,n);case x.ZodPromise:return Bu(t,n);case x.ZodNaN:case x.ZodNever:return Pu();case x.ZodEffects:return vu(t,n);case x.ZodAny:return du();case x.ZodUnknown:return Du();case x.ZodDefault:return hu(t,n);case x.ZodBranded:return mu(t,n);case x.ZodReadonly:return Ey(t,n);case x.ZodCatch:return xy(t,n);case x.ZodPipeline:return Oy(t,n);case x.ZodFunction:case x.ZodVoid:case x.ZodSymbol:return;default:return(r=>{})(e)}},"selectParser"),br=l((t,e,n)=>(t.description&&(n.description=t.description,e.markdownDescription&&(n.markdownDescription=t.description)),Object.assign(n,{[C]:c(c({},t[C]),n[C])}),n),"addMeta"),Yi={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"},Ry=l(t=>typeof t=="string"?f(c({},Yi),{name:t}):c(c({},Yi),t),"getDefaultOptions"),Zy=l(t=>{let e=Ry(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"),Dy=l((t,e)=>{var n;let r=Zy(e),i=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((u,[d,p])=>{var g;return f(c({},u),{[d]:(g=I(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=I(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"),Ny=l((t,e={target:"openApi3"})=>{let n=Dy(t,e);return e.$schemaUrl===!1?delete n.$schema:typeof e.$schemaUrl=="string"&&(n.$schema=e.$schemaUrl),n},"toJSONSchemaLegacy"),{zuiKey:rr}=Ie,Hy=l((t,e)=>{let n={type:"array",description:t.description,items:e(t._def.type),"x-zui":t._def["x-zui"]};return t._def[rr]&&(n[rr]=t._def[rr]),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:ir}=Ie,My=l(t=>{let e={type:"number",description:t.description,"x-zui":t._def["x-zui"]};t._def[ir]&&(e[ir]=t._def[ir]);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:sr}=Ie,jy=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[sr]&&(n[sr]=t._def[sr]),t._def.minSize&&(n.minItems=t._def.minSize.value),t._def.maxSize&&(n.maxItems=t._def.maxSize.value),n},"zodSetToJsonSet"),{zuiKey:_t}=Ie,$y=l((t,e)=>{let n={type:"string",description:t.description,"x-zui":t._def["x-zui"]};t._def[_t]&&(n[_t]=t._def[_t]);for(let r of t._def.checks)switch(r.kind){case"cuid":n.format="cuid",n.pattern=j.cuid;break;case"cuid2":n.format="cuid2",n.pattern=j.cuid2;break;case"ulid":n.format="ulid",n.pattern=j.ulid;break;case"uuid":n.format="uuid",n.pattern=j.uuid;break;case"emoji":n.format="emoji",n.pattern=j.emoji;break;case"email":n.format="email",n.pattern=j.email;break;case"ip":n.format=r.version==="v6"?"ipv6":"ipv4",n.pattern=r.version==="v6"?j.ipv6:j.ipv4;break;case"datetime":n.format="date-time",(r.precision!==null||r.offset)&&(n.pattern=Co(r).source,n[_t]=f(c({},n[_t]),{precision:r.precision,offset:r.offset}));break;case"url":n.format="uri";break;case"endsWith":n.pattern=`${Rt.escapeSpecialChars(r.value)}$`;break;case"startsWith":n.pattern=`^${Rt.escapeSpecialChars(r.value)}`;break;case"includes":let i=r.position&&r.position>=1?`^(?:.{${r.position}}).*`:"";n.pattern=`${i}${Rt.escapeSpecialChars(r.value)}`;break;case"regex":n.pattern=r.regex.source;break;case"length":n.minLength=n.maxLength=Math.max(0,r.value);break;case"min":n.minLength=Math.max(0,r.value);break;case"max":n.maxLength=Math.max(0,r.value);break;default:throw new Jl("ZodString",r.kind,e.toString())}return n},"zodStringToJsonString"),{zuiKey:ar}=Ie,zy=l((t,e,n)=>{let r={type:"array",description:t.description,items:t._def.items.map((i,s)=>e(i,n.withIndexType("number",s)))};return t._def[ar]&&(r[ar]=t._def[ar]),t._def.rest&&(r.additionalItems=e(t._def.rest,n.withIndexType("number"))),r},"zodTupleToJsonTuple"),Uy={unionStrategy:"anyOf",discriminatedUnionStrategy:"oneOf",discriminator:!0};function si(t,e={}){return L(t,e,new qt)}l(si,"toJSONSchema");function L(t,e={},n){let r=c(c({},Uy),e),i=t;switch(i.typeName){case"ZodString":return $y(i,n);case"ZodNumber":return My(i);case"ZodNaN":throw new Y("ZodNaN",n.toString());case"ZodBigInt":throw new Y("ZodBigInt",n.toString(),{suggestedAlternative:"serialize bigint to string"});case"ZodBoolean":return{type:"boolean",description:i.description,"x-zui":i._def["x-zui"]};case"ZodDate":throw new Y("ZodDate",n.toString(),{suggestedAlternative:"use z.string().datetime() instead"});case"ZodUndefined":return or(i);case"ZodNull":return lr(i);case"ZodAny":return{description:i.description,"x-zui":i._def["x-zui"]};case"ZodUnknown":return{description:i.description,"x-zui":f(c({},i._def["x-zui"]),{def:{typeName:"ZodUnknown"}})};case"ZodNever":return{not:!0,description:i.description,"x-zui":i._def["x-zui"]};case"ZodVoid":throw new Y("ZodVoid",n.toString());case"ZodArray":return Hy(i,g=>L(g,r,n.withIndexType("number")));case"ZodObject":let s=Object.entries(i.shape),a=s.filter(([g,m])=>!m.isOptional()),o=a.length?a.map(([g])=>g):void 0,u=s.map(([g,m])=>[g,m.mandatory()]).map(([g,m])=>[g,L(m,r,n.withIndexType("key",g))]);return{type:"object",description:i.description,properties:Object.fromEntries(u),required:o,additionalProperties:Ky(i._def,r,n),"x-zui":i._def["x-zui"]};case"ZodUnion":return r.unionStrategy==="oneOf"?{description:i.description,oneOf:i.options.map((g,m)=>L(g,r,n.withIndexType("number",m))),"x-zui":i._def["x-zui"]}:{description:i.description,anyOf:i.options.map((g,m)=>L(g,r,n.withIndexType("number",m))),"x-zui":i._def["x-zui"]};case"ZodDiscriminatedUnion":if(r.discriminatedUnionStrategy==="oneOf"){let g=r.discriminator?{propertyName:i.discriminator}:void 0;return{description:i.description,oneOf:i.options.map((m,_)=>L(m,r,n.withIndexType("number",_))),discriminator:g,"x-zui":f(c({},i._def["x-zui"]),{def:{typeName:"ZodDiscriminatedUnion",discriminator:i.discriminator}})}}return{description:i.description,anyOf:i.options.map((g,m)=>L(g,r,n.withIndexType("number",m))),"x-zui":f(c({},i._def["x-zui"]),{def:{typeName:"ZodDiscriminatedUnion",discriminator:i.discriminator}})};case"ZodIntersection":let d=L(i._def.left,r,n.withIndexType("number",0)),p=L(i._def.right,r,n.withIndexType("number",1));return"additionalProperties"in d&&delete d.additionalProperties,"additionalProperties"in p&&delete p.additionalProperties,{description:i.description,allOf:[d,p],"x-zui":i._def["x-zui"]};case"ZodTuple":return zy(i,(g,m)=>L(g,r,m),n);case"ZodRecord":{let g=i._def.keyType,m=E.zuiString(g)?n.withIndexType("string"):E.zuiNumber(g)?n.withIndexType("number"):n.withIndexType("any");return{type:"object",description:i.description,additionalProperties:L(i._def.valueType,r,m),"x-zui":i._def["x-zui"]}}case"ZodMap":throw new Y("ZodMap",n.toString());case"ZodSet":return jy(i,g=>L(g,r,n.withIndexType("number")));case"ZodFunction":throw new Y("ZodFunction",n.toString());case"ZodLazy":throw new Y("ZodLazy",n.toString());case"ZodLiteral":if(typeof i.value=="string")return{type:"string",description:i.description,const:i.value,"x-zui":i._def["x-zui"]};if(typeof i.value=="number")return{type:"number",description:i.description,const:i.value,"x-zui":i._def["x-zui"]};if(typeof i.value=="boolean")return{type:"boolean",description:i.description,const:i.value,"x-zui":i._def["x-zui"]};if(i.value===null)return lr(i._def);if(i.value===void 0)return or(i._def);{i.value;let g=typeof i.value;throw new An(`Unsupported literal type: "${g}"`,n.toString())}case"ZodEnum":return{type:"string",description:i.description,enum:i._def.values,"x-zui":i._def["x-zui"]};case"ZodEffects":throw new Y("ZodEffects",n.toString());case"ZodNativeEnum":throw new Y("ZodNativeEnum",n.toString());case"ZodOptional":return{description:i.description,anyOf:[L(i._def.innerType,r,n),or()],"x-zui":f(c({},i._def["x-zui"]),{def:{typeName:"ZodOptional"}})};case"ZodNullable":return{anyOf:[L(i._def.innerType,r,n),lr()],"x-zui":f(c({},i._def["x-zui"]),{def:{typeName:"ZodNullable"}})};case"ZodDefault":return f(c({},L(i._def.innerType,r,n)),{default:i._def.defaultValue()});case"ZodCatch":throw new Y("ZodCatch",n.toString());case"ZodPromise":throw new Y("ZodPromise",n.toString());case"ZodBranded":throw new Y("ZodBranded",n.toString());case"ZodPipeline":throw new Y("ZodPipeline",n.toString());case"ZodSymbol":throw new Y("ZodSymbol",n.toString());case"ZodReadonly":return f(c({},L(i._def.innerType,r,n)),{readOnly:!0});case"ZodRef":return{$ref:i._def.uri,description:i.description,"x-zui":i._def["x-zui"]};default:fe.assertNever(i)}}l(L,"_toJSONSchema");var or=l(t=>({not:!0,description:t?.description,"x-zui":f(c({},t?.["x-zui"]),{def:{typeName:"ZodUndefined"}})}),"undefinedSchema"),lr=l(t=>({type:"null",description:t?.description,"x-zui":t?.["x-zui"]}),"nullSchema"),Ky=l((t,e,n)=>t.unknownKeys==="passthrough"?!0:t.unknownKeys==="strict"||!E.zuiType(t.unknownKeys)||t.unknownKeys.typeName==="ZodNever"?!1:L(t.unknownKeys,e,n.withIndexType("string")),"additionalPropertiesSchema");function Nu(t){return typeof t=="symbol"?"symbol":typeof t=="bigint"?`${t.toString()}n`:T(t)}l(Nu,"primitiveToTypscriptLiteralType");function T(t){return typeof t>"u"?"undefined":typeof t=="symbol"?t.description?`Symbol(${T(t.description)})`:"Symbol()":typeof t=="bigint"?`BigInt(${t.toString()})`:typeof t=="string"?ju(t):JSON.stringify(t)}l(T,"primitiveToTypescriptValue");function ut(t){return typeof t>"u"?"undefined":JSON.stringify(t)}l(ut,"unknownToTypescriptValue");var Hu=l((t,e)=>{let n=Object.entries(t),r=e?" as const":"";return`{ ${n.map(([i,s])=>`${wr(i)}: ${ut(s)}`).join(", ")} }${r}`},"recordOfUnknownToTypescriptRecord"),wr=l(t=>/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t)?t:T(t),"toPropertyKey"),Wy=l(t=>t.charAt(0).toUpperCase()+t.slice(1),"capitalize"),Mu=l(t=>{let e=/[^a-zA-Z0-9_]/g;return t.split(e).map(Wy).filter(r=>!!r).join("")},"toTypeArgumentName"),Xi=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"),W=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
|
|
60
|
+
`).map(i=>i.trim());return Xi(r),r.length&&(r[0]=r[0].replace(/^\/\*\*?/,""),r[r.length-1]=r[r.length-1].replace(/\*\/$/,"")),Xi(r),r.length===0?"":r.length===1?`/** ${n(r[0])} */`:`/**
|
|
61
61
|
${r.map(e).map(n).join(`
|
|
62
62
|
`)}
|
|
63
|
-
*/`},"getMultilineComment");function
|
|
64
|
-
`:"",g=t.value.describe(""),_=E.zuiAny(t.value)?
|
|
65
|
-
${p.join(" | ")}`;case"ZodDiscriminatedUnion":let g=o._def.options.map((
|
|
66
|
-
${g.join(" | ")}`;case"ZodIntersection":return`${k(o._def.left,e.withIndexType("number",0),a)} & ${k(o._def.right,e.withIndexType("number",1),a)}`;case"ZodTuple":return o._def.items.length===0?"[]":`[${o._def.items.map((
|
|
63
|
+
*/`},"getMultilineComment");function ju(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(ju,"escapeString");var $u=["string","number","boolean","unknown","void","any","null","undefined","never","bigint","symbol","object"],Ly=5,Fy=l(t=>$u.includes(t),"isPrimitive"),qy=l(t=>$u.map(e=>`${e}[]`).includes(t),"isArrayOfPrimitives"),ur=l(t=>t.replace(/ +/g," ").trim(),"stripSpaces"),zu=class{constructor(e,n){this.key=e,this.value=n}};l(zu,"KeyValue");var Xt=zu,Uu=class{constructor(e){this.schema=e}};l(Uu,"FnParameters");var Qi=Uu,Ku=class{constructor(e){this.schema=e}};l(Ku,"FnReturn");var es=Ku,Wu=class{constructor(e){this.props=e}};l(Wu,"Declaration");var Zt=Wu;function ai(t,e={}){return Lu(t,new qt,e)}l(ai,"toTypescriptType");function Lu(t,e,n={}){let r=Jy(t,n),i=k(r,e,n);return n.formatter&&(i=n.formatter(i)),i}l(Lu,"_toTypescriptType");var ts=l(t=>t.endsWith("?")?t:`${t}?`,"_optionalKey");function k(t,e,n){var r,i,s;let a=f(c({},n),{declaration:!1,parent:t});if(t===null)return"";if(t instanceof Zt)return Vy(t,e,a);if(t instanceof Xt){let u;if(E.zuiOptional(t.value)?u=t.value:E.zuiDefault(t.value)&&n.treatDefaultAsOptional&&(u=t.value._def.innerType.optional()),u){let h=u._def.innerType;return E.zuiType(h)&&!h.description&&u.description&&(h=h?.describe(u.description)),k(new Xt(ts(t.key),h),e,a)}let d=W(t.value._def.description||t.value.description),p=d?.trim().length>0?`
|
|
64
|
+
`:"",g=t.value.describe(""),_=E.zuiAny(t.value)?ts(t.key):t.key;return`${p}${d}${p}${_}: ${k(g,e,a)}${p}`}if(t instanceof Qi){if(E.zuiTuple(t.schema)){let g="";for(let m=0;m<t.schema.items.length;m++){let _=(s=(i=(r=t.schema.items[m])==null?void 0:r.ui)==null?void 0:i.title)!=null?s:`arg${m}`,h=t.schema.items[m];g+=`${k(new Xt(wr(_),h),e.withIndexType("number",m),a)}${m<t.schema.items.length-1?", ":""} `}return g}let u=E.zuiLiteral(t.schema.naked()),d=k(t.schema,e,a).trim();return d.startsWith("{")&&d.endsWith("}")||d.startsWith("[")&&d.endsWith("]")||d.startsWith("(")&&d.endsWith(")")||d.startsWith("Array<")&&d.endsWith(">")||d.startsWith("Record<")&&d.endsWith(">")||qy(d)||u?`args: ${d}`:d}if(t instanceof es)return E.zuiOptional(t.schema)?`${k(t.schema.unwrap(),e,a)} | undefined`:k(t.schema,e,a);let o=t;switch(o.typeName){case"ZodString":return`${W(o.description)} string`.trim();case"ZodNumber":case"ZodNaN":case"ZodBigInt":return`${W(o.description)} number`.trim();case"ZodBoolean":return`${W(o.description)} boolean`.trim();case"ZodDate":return`${W(o.description)} Date`.trim();case"ZodUndefined":return`${W(o.description)} undefined`.trim();case"ZodNull":return`${W(o.description)} null`.trim();case"ZodAny":return`${W(o.description)} any`.trim();case"ZodUnknown":return`${W(o.description)} unknown`.trim();case"ZodNever":return`${W(o.description)} never`.trim();case"ZodVoid":return`${W(o.description)} void`.trim();case"ZodArray":let u=k(o._def.type,e.withIndexType("number"),a);return Fy(u)?`${u}[]`:`Array<${u}>`;case"ZodObject":return`{ ${Object.entries(o._def.shape()).map(([U,K])=>E.zuiType(K)?k(new Xt(wr(U),K),e.withIndexType("key",U),a):`${U}: unknown`).join("; ")} }`;case"ZodUnion":let p=o._def.options.map((U,K)=>k(U,e.withIndexType("number",K),a));return`${W(o.description)}
|
|
65
|
+
${p.join(" | ")}`;case"ZodDiscriminatedUnion":let g=o._def.options.map((U,K)=>k(U,e.withIndexType("number",K),a));return`${W(o.description)}
|
|
66
|
+
${g.join(" | ")}`;case"ZodIntersection":return`${k(o._def.left,e.withIndexType("number",0),a)} & ${k(o._def.right,e.withIndexType("number",1),a)}`;case"ZodTuple":return o._def.items.length===0?"[]":`[${o._def.items.map((U,K)=>k(U,e.withIndexType("number",K),a)).join(", ")}]`;case"ZodRecord":{let U=k(o._def.keyType,e.withWrapper("KeyOf"),a),K=E.zuiString(o._def.keyType)?e.withIndexType("string"):E.zuiNumber(o._def.keyType)?e.withIndexType("number"):e.withIndexType("any"),ie=k(o._def.valueType,K,a);return`${W(o.description)} { [key: ${U}]: ${ie} }`}case"ZodMap":{let U=E.zuiString(o._def.keyType)?e.withIndexType("string"):E.zuiNumber(o._def.keyType)?e.withIndexType("number"):e.withIndexType("any");return`Map<${k(o._def.keyType,e.withWrapper("KeyOf"),a)}, ${k(o._def.valueType,U,a)}>`}case"ZodSet":return`Set<${k(o._def.valueType,e.withIndexType("number"),a)}>`;case"ZodFunction":let _=k(new Qi(o._def.args),e.withWrapper("Parameters"),a),h=k(new es(o._def.returns),e.withWrapper("ReturnType"),a),A=n?.parent instanceof Zt&&n?.parent.props.type==="type";return n?.declaration&&!A?`${W(o.description)}
|
|
67
67
|
(${_}): ${h}`:`${W(o.description)}
|
|
68
|
-
(${_}) => ${h}`;case"ZodLazy":return k(o._def.getter(),e,a);case"ZodLiteral":let
|
|
69
|
-
${
|
|
70
|
-
`).length>=
|
|
71
|
-
declare function ${i}${o};${d}`);if(t.props.type==="variable")return
|
|
72
|
-
`).trim();case"ZodUnion":return`z.union([${n._def.options.map((ae,de)=>D(ae,e.withIndexType("number",de))).join(", ")}])${O(n._def)}`.trim();case"ZodDiscriminatedUnion":let o=n._def.options.map((ae,de)=>D(ae,e.withIndexType("number",de)));return`z.discriminatedUnion(${T(n._def.discriminator)}, [${o.join(", ")}])${O(n._def)}`.trim();case"ZodIntersection":let d=D(n._def.left,e.withIndexType("number",0)),p=D(n._def.right,e.withIndexType("number",1));return`z.intersection(${d}, ${p})${O(n._def)}`.trim();case"ZodTuple":return`z.tuple([${n._def.items.map((ae,de)=>D(ae,e.withIndexType("number",de))).join(", ")}])${O(n._def)}`.trim();case"ZodRecord":let m=D(n._def.keyType,e.withWrapper("KeyOf")),_=E.zuiString(n._def.keyType)?e.withIndexType("string"):E.zuiNumber(n._def.keyType)?e.withIndexType("number"):e.withIndexType("any"),h=D(n._def.valueType,_);return`z.record(${m}, ${h})${O(n._def)}`.trim();case"ZodMap":let A=D(n._def.keyType,e.withWrapper("KeyOf")),U=E.zuiString(n._def.keyType)?e.withIndexType("string"):E.zuiNumber(n._def.keyType)?e.withIndexType("number"):e.withIndexType("any"),Q=D(n._def.valueType,U);return`z.map(${A}, ${Q})${O(n._def)}`.trim();case"ZodSet":return`z.set(${D(n._def.valueType,e.withIndexType("number"))})${nh(n._def)}${O(n._def)}`.trim();case"ZodFunction":let ee=n._def.args.items.map((ae,de)=>D(ae,e.withWrapper("Parameters").withIndexType("number",de))),z=ee.length?`.args(${ee.join(", ")})`:"",K=D(n._def.returns,e.withWrapper("ReturnType"));return`z.function()${z}.returns(${K})${O(n._def)}`.trim();case"ZodLazy":return`z.lazy(() => ${D(n._def.getter(),e)})${O(n._def)}`.trim();case"ZodLiteral":return`z.literal(${T(n._def.value)})${O(n._def)}`.trim();case"ZodEnum":return`z.enum([${n._def.values.map(T).join(", ")}])${O(n._def)}`.trim();case"ZodEffects":throw new Ue("ZodEffects",e.toString());case"ZodNativeEnum":throw new Ue("ZodNativeEnum",e.toString());case"ZodOptional":return`z.optional(${D(n._def.innerType,e)})${O(n._def,n._def.innerType)}`.trim();case"ZodNullable":return`z.nullable(${D(n._def.innerType,e)})${O(n._def,n._def.innerType)}`.trim();case"ZodDefault":let xc=ut(n._def.defaultValue());return`z.default(${D(n._def.innerType,e)}, ${xc})${O(n._def,n._def.innerType)}`.trim();case"ZodCatch":throw new Ue("ZodCatch",e.toString());case"ZodPromise":return`z.promise(${D(n._def.type,e)})${O(n._def,n._def.type)}`.trim();case"ZodBranded":throw new Ue("ZodBranded",e.toString());case"ZodPipeline":throw new Ue("ZodPipeline",e.toString());case"ZodSymbol":throw new Ue("ZodSymbol",e.toString());case"ZodReadonly":return`z.readonly(${D(n._def.innerType,e)})${O(n._def,n._def.innerType)}`.trim();case"ZodRef":return`z.ref(${T(n._def.uri)})${O(n._def)}`.trim();default:fe.assertNever(n)}}l(D,"sUnwrapZod");var O=l((t,e)=>{let n=e?._def;return`${ah(t,n)}${sh(t,n)}`},"_addMetadata"),sh=l((t,e)=>!t.description||e&&e.description===t.description?"":`.describe(${T(t.description)})`,"_maybeDescribe"),ah=l((t,e)=>`${oh(t,e)}${lh(t,e)}${uh(t,e)}${ch(t,e)}${dh(t,e)}${ph(t,e)}${fh(t,e)}`,"_addZuiExtensions"),oh=l((t,e)=>{var n,r;let i=(n=t[ne])==null?void 0:n.title;return!i||e&&((r=e[ne])==null?void 0:r.title)===i?"":`.title(${T(i)})`},"_maybeTitle"),lh=l((t,e)=>{var n,r;let i=(n=t[ne])==null?void 0:n.displayAs;return!i||e&&Ce((r=e[ne])==null?void 0:r.displayAs,i)?"":`.displayAs(${Nu({id:i[0],params:i[1]})})`},"_maybeDisplayAs"),uh=l((t,e)=>{var n,r;let i=(n=t[ne])==null?void 0:n.disabled;return!i||e&&((r=e[ne])==null?void 0:r.disabled)===i?"":`.disabled(${i})`},"_maybeDisabled"),ch=l((t,e)=>{var n,r;let i=(n=t[ne])==null?void 0:n.hidden;return!i||e&&((r=e[ne])==null?void 0:r.hidden)===i?"":`.hidden(${i})`},"_maybeHidden"),dh=l((t,e)=>{var n,r;let i=(n=t[ne])==null?void 0:n.placeholder;return!i||e&&((r=e[ne])==null?void 0:r.placeholder)===i?"":`.placeholder(${T(i)})`},"_maybePlaceholder"),ph=l((t,e)=>{var n,r;let i=(n=t[ne])==null?void 0:n.secret;return!i||e&&((r=e[ne])==null?void 0:r.secret)===i?"":".secret()"},"_maybeSecret"),fh=l((t,e)=>{var n,r;let i=["title","tooltip","displayAs","disabled","hidden","placeholder","secret","coerce"],s=Object.entries((n=t[ne])!=null?n:{}).filter(([a])=>!i.includes(a));if(s.length===0)return"";if(e){let a=Object.entries((r=e[ne])!=null?r:{}).filter(([o])=>!i.includes(o));if(Ce(Object.fromEntries(s),Object.fromEntries(a)))return""}return`.metadata(${Nu(Object.fromEntries(s))})`},"_maybeSetMetadata"),gh={};P.prototype.toJSONSchema=function(t={}){return ri(this,t)};P.prototype.toTypescriptType=function(t={}){return ii(this,t)};P.prototype.toTypescriptSchema=function(){return si(this)};var q=v.string().min(1),Fu=v.object({text:q}),qu=v.object({markdown:q}),Vu=v.object({imageUrl:q,title:q.optional()}),Gu=v.object({audioUrl:q,title:q.optional()}),Ju=v.object({videoUrl:q,title:q.optional()}),Yu=v.object({fileUrl:q,title:q.optional()}),Xu=v.object({latitude:v.number(),longitude:v.number(),address:v.string().optional(),title:v.string().optional()}),Qu=v.object({title:q,subtitle:q.optional(),imageUrl:q.optional(),actions:v.array(v.object({action:v.enum(["postback","url","say"]),label:q,value:q}))}),Lu=v.object({text:q,options:v.array(v.object({label:q,value:q}))}),mh=v.object({items:v.array(Qu)}),ec=v.union([v.object({type:v.literal("text"),payload:Fu}),v.object({type:v.literal("image"),payload:Vu}),v.object({type:v.literal("audio"),payload:Gu}),v.object({type:v.literal("video"),payload:Ju}),v.object({type:v.literal("file"),payload:Yu}),v.object({type:v.literal("location"),payload:Xu})]),yh=v.object({items:v.array(ec)}),hh={schema:qu},vh={schema:v.object({items:v.array(v.union([...ec.options,v.object({type:v.literal("markdown"),payload:qu})]))})},_h={text:{schema:Fu},image:{schema:Vu},audio:{schema:Gu},video:{schema:Ju},file:{schema:Yu},location:{schema:Xu},carousel:{schema:mh},card:{schema:Qu},dropdown:{schema:Lu},choice:{schema:Lu},bloc:{schema:yh}};var Th={HIDDEN_IN_STUDIO:{bpActionHiddenInStudio:"true"},AWAIT_RETURN:{bpActionAwaitReturn:"true"}},bh="x-bp-integration-identifier";var tc=require("browser-or-node");var oi=console;function oe(t){if(!t.body)throw new Error("Missing body");return JSON.parse(t.body)}async function Vt(t,e=8072,n=Sh){if(!tc.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 wh(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);oi.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 wh(t){let e=await Ph(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:xh(r.search,"?"),headers:n,method:t.method?.toUpperCase()??"GET"}}function xh(t,e){return t.indexOf(e)===0?t.slice(e.length):t}async function Ph(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 Sh(t){oi.info(`Listening on port ${t}`)}var Vn=require("@botpress/client");var li={};Ne(li,{DefinitionError:()=>re,isDefinitionError:()=>kh});var re=class extends Error{__IS_SDK_ERROR__=!0;type="definition_error"},kh=t=>t instanceof re||typeof t=="object"&&t!==null&&"__IS_SDK_ERROR__"in t&&t.__IS_SDK_ERROR__===!0&&"type"in t&&t.type==="definition_error";var N={};Ne(N,{mapKeys:()=>Eh,mapValues:()=>Oh,mergeRecords:()=>Ch,pairs:()=>Rn,stripUndefinedProps:()=>Bh,values:()=>Ih});var Rn=t=>Object.entries(t),Ih=t=>Object.values(t),Oh=(t,e)=>Object.fromEntries(Rn(t).map(([n,r])=>[n,e(r,n)])),Eh=(t,e)=>Object.fromEntries(Rn(t).map(([n,r])=>[e(n),r])),Bh=t=>Object.fromEntries(Rn(t).filter(([,e])=>e!==void 0)),Ch=(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 w={};Ne(w,{safePush:()=>Ah,unique:()=>Zh});var Ah=(t,...e)=>t?[...t,...e]:[...e],Zh=t=>Array.from(new Set(t));var G={};Ne(G,{setName:()=>Rh});var Rh=(t,e)=>(Object.defineProperty(t,"name",{value:e}),t);var nc=t=>{let{name:e,version:n}=t,r={actions:{},events:{},channels:{}},i={name:e,version:n,entities:N.mapValues(t.entities,a=>({name:a.name})),actions:{},events:{},channels:{}},s=N.mapValues(t.entities,a=>a.schema);for(let[a,o]of Object.entries(t.definition.actions??{})){let 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 m=g.schema.dereference(s);u[p]={...g,schema:m}}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 rc="6.11.2";var Re=rc;var Nn=Symbol("schemaName"),ic=t=>t?N.mapValues(t,(n,r)=>({...n,[Nn]:r})):{},sc=t=>Nn in t&&t[Nn]!==void 0,ac=t=>t[Nn];var Dn=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:Re}}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(m=>m.name),d=u.length===0?e.name:`${e.name}<${u.join(",")}>`,{resolved:p,statement:g}=nc({...e,entities:r,actions:N.stripUndefinedProps(i),events:N.stripUndefinedProps(s),channels:N.stripUndefinedProps(a)});return o.actions=N.mergeRecords(o.actions??{},p.actions,this._mergeActions),o.channels=N.mergeRecords(o.channels??{},p.channels,this._mergeChannels),o.events=N.mergeRecords(o.events??{},p.events,this._mergeEvents),o.interfaces[d]={id:e.id,...g},this}_callBuilder(e,n){let i={entities:ic(this.entities)},s=n(i),a=N.pairs(s.entities).find(([u,d])=>!sc(d));if(a)throw new re(`Cannot extend interface "${e.name}" with entity "${a[0]}"; the provided schema is not part of the integration's entities.`);return{entities:N.mapValues(s.entities,u=>({name:ac(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=N.mergeRecords(e.messages,n.messages,this._mergeMessage),i;(e.conversation||n.conversation)&&(i={tags:{...e.conversation?.tags,...n.conversation?.tags}});let s;return(e.message||n.message)&&(s={tags:{...e.message?.tags,...n.message?.tags}}),{...e,...n,messages:r,conversation:i,message:s}};_mergeMessage=(e,n)=>({schema: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 v.object({...s,...a})}if(r.typeName==="ZodRecord"&&i.typeName==="ZodRecord")return v.record(v.intersection(r.valueType,i.valueType));throw new Error("Cannot merge object schemas with record schemas")}};var Ee=require("@botpress/client");var oc=Gn(require("@botpress/client")),Hn={retries:3,retryCondition:t=>oc.axiosRetry.isNetworkOrIdempotentRequestError(t)||[429,502].includes(t.response?.status??0),retryDelay:(t,e)=>(Dh(e.response?.headers??{})??t)*1e3},Dh=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 Hh(String(r))}},Hh=t=>{let e=Mh(t)?jh(t):t.length>0?parseInt(t,10):void 0;return e===void 0||isNaN(e)?void 0:e},Mh=t=>t.includes(" "),jh=t=>{let e=$h(t);if(!e)return;let n=new Date;return Math.max(0,Math.floor((e.getTime()-n.getTime())/1e3))},$h=t=>{let e=new Date(t);return isNaN(e.getTime())?void 0:e};var ft=class{constructor(e){this._client=e}get _inner(){return this._client}createConversation=(e=>this._client.createConversation(e));getConversation=(e=>this._client.getConversation(e));listConversations=(e=>this._client.listConversations(e));getOrCreateConversation=(e=>this._client.getOrCreateConversation(e));updateConversation=(e=>this._client.updateConversation(e));deleteConversation=(e=>this._client.deleteConversation(e));listParticipants=(e=>this._client.listParticipants(e));addParticipant=(e=>this._client.addParticipant(e));getParticipant=(e=>this._client.getParticipant(e));removeParticipant=(e=>this._client.removeParticipant(e));createEvent=(e=>this._client.createEvent(e));getEvent=(e=>this._client.getEvent(e));listEvents=(e=>this._client.listEvents(e));createMessage=(e=>this._client.createMessage(e));getOrCreateMessage=(e=>this._client.getOrCreateMessage(e));getMessage=(e=>this._client.getMessage(e).then(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 Mn=class{_cost=0;get cost(){return this._cost}setCost(e){this._cost=e}toJSON(){return{cost:this.cost}}};var me="#",jn="x-bot-id",lc="x-bot-user-id",uc="x-integration-id",cc="x-integration-alias",dc="x-webhook-id",pc="x-bp-configuration-type",$n="x-bp-configuration",Un="x-bp-operation",fc="x-bp-type";var le=t=>{throw t instanceof Error?t:new Error(t)};var y_=v.enum(["webhook_received","message_created","action_triggered","register","unregister","ping","create_user","create_conversation"]),gc=t=>({botId:t[jn]||le("Missing bot header"),botUserId:t[lc]||le("Missing bot user header"),integrationId:t[uc]||le("Missing integration header"),integrationAlias:t[cc]||le("Missing integration alias header"),webhookId:t[dc]||le("Missing webhook header"),operation:t[Un]||le("Missing operation header"),configurationType:t[pc]??null,configuration:JSON.parse(Buffer.from(t[$n]||le("Missing configuration header"),"base64").toString("utf-8"))});var mc=Gn(require("util")),gt=class{defaultOptions;constructor(e){this.defaultOptions=e}info(...e){this._log("info",e)}debug(...e){this._log("debug",e)}warn(...e){this._log("warn",e)}error(...e){this._log("error",e)}issue(e){console.info(JSON.stringify({...e,...this.getIssueContext()}))}getIssueContext(){return{}}_log(e,n){this._getConsoleMethod(e)(this._serializeMessage(e,n))}_serializeMessage(e,n){let r=mc.default.format(...n);return process.env.BP_LOG_FORMAT==="json"?this.getJsonMessage(e,r):r}getJsonMessage(e,n){return JSON.stringify({msg:n,level: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 mt=class t extends gt{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,n){return JSON.stringify({msg:n,level:e,botId:this.defaultOptions.botId,integrationId:this.defaultOptions.integrationId,integrationAlias:this.defaultOptions.integrationAlias,visible_to_bot_owner:this.defaultOptions.visibleToBotOwners,hidden_to_integration_owner:this.defaultOptions.hiddenToIntegrationOwners,options:this.defaultOptions})}getIssueContext(){let{botId:e,integrationId:n,integrationAlias:r}=this.defaultOptions;return{...e&&{botId:e},...n&&{integrationId:n},...r&&{integrationAlias:r}}}};var Uh=t=>["traceparent","tracestate","sentry-trace"].reduce((e,n)=>(t[n]&&(e[n]=t[n]),e),{}),zh=(t,e,n)=>{let[,r]=(e.headers.traceparent||"").split("-"),i=new Ee.Client({botId:t.botId,integrationId:t.integrationId,integrationAlias:t.integrationAlias,retry:Hn,headers:n.managesOwnTracePropagation?{}:Uh(e.headers)}),s=new ft(i),a=new mt({traceId:r,botId:t.botId,integrationId:t.integrationId,integrationAlias:t.integrationAlias});return{ctx:t,req:e,client:s,logger:a,instance:n}},Kh=async t=>{let{ctx:e}=t;switch(e.operation){case"webhook_received":return await Lh(t);case"register":return await Fh(t);case"unregister":return await qh(t);case"message_created":return await Jh(t);case"action_triggered":return await Yh(t);case"ping":return await Wh(t);case"create_user":return await Vh(t);case"create_conversation":return await Gh(t);default:throw new Ee.InvalidPayloadError(`Unknown operation ${e.operation}`)}},yc=t=>async e=>{let n=gc(e.headers),r=zh(n,e,t),{logger:i}=r;try{let s;return s=await Xh(r),s?{...s,status:s.status??200}:(s=await Kh(r),s?{...s,status:s.status??200}:{status:200})}catch(s){if((0,Ee.isApiError)(s)){let o=s.type==="Runtime"?s:new Ee.RuntimeError(s.message,s);return i.forBot().error(o.message),{status:o.code,body:JSON.stringify(o.toJSON())}}console.error(s);let a=new Ee.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())}}},Wh=async t=>{},Lh=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{let{req:s}=oe(n);return i.webhook({client:t,ctx:e,req:s,logger:r})},Fh=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{if(!i.register)return;let{webhookUrl:s}=oe(n);await i.register({client:t,ctx:e,webhookUrl:s,logger:r})},qh=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{if(!i.unregister)return;let{webhookUrl:s}=oe(n);await i.unregister({ctx:e,webhookUrl:s,client:t,logger:r})},Vh=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{if(!i.createUser)return;let{tags:s}=oe(n);return await i.createUser({ctx:e,client:t,tags:s,logger:r})},Gh=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{if(!i.createConversation)return;let{channel:s,tags:a}=oe(n);return await i.createConversation({ctx:e,client:t,channel:s,tags:a,logger:r})},Jh=async({ctx:t,req:e,client:n,logger:r,instance:i})=>{let{conversation:s,user:a,type:o,payload:u,message:d}=oe(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:_})=>{await n.updateMessage({id:d.id,tags:_})},logger:r})},Yh=async({req:t,ctx:e,client:n,logger:r,instance:i})=>{let{input:s,type:a}=oe(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 Mn,p={output:await o({ctx:e,input:s,client:n,type:a,logger:r,metadata:u}),meta:u.toJSON()};return{body:JSON.stringify(p)}},Xh=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 zn=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,this.managesOwnTracePropagation=e.__advanced?.managesOwnTracePropagation}actions;channels;register;unregister;createUser;createConversation;webhook;unknownOperationHandler;managesOwnTracePropagation;handler=yc(this);start=e=>Vt(this.handler,e)};var Kn=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:Re}}addIntegration(e,n){let r=this;r.integrations||(r.integrations={});let i=n?.alias??e.name;if(r.integrations[i])throw new re(`Another integration with alias "${i}" is already installed in the bot`);let s=n&&"configurationType"in n?n.configurationType:void 0,a=n&&"configuration"in n?n.configuration??{}:{},o=s?e.definition.configurations?.[s]?.schema:e.definition.configuration?.schema,u=o?o.safeParse(a):null,d=u?.success?{...a,...u.data}:a;return r.integrations[i]={...e,alias:i,enabled:n?.enabled,configurationType:s,configuration:d,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 re(`Another plugin with alias "${i}" is already installed in the bot`);let s=Object.fromEntries(Object.entries(n.dependencies??{}).filter(([g,m])=>"integrationInterfaceAlias"in m).map(([g,m])=>{let _=this.integrations?.[m.integrationAlias];if(!_){let A=Object.keys(this.integrations??{}).join(", ")||"(none)";throw new re(`Interface with alias "${g}" of plugin with alias "${i}" references integration with alias "${m.integrationAlias}" which is not installed. Please make sure to add the integration via addIntegration() before calling addPlugin().
|
|
68
|
+
(${_}) => ${h}`;case"ZodLazy":return k(o._def.getter(),e,a);case"ZodLiteral":let z=Nu(o._def.value);return`${W(o.description)}
|
|
69
|
+
${z}`.trim();case"ZodEnum":return o._def.values.map(T).join(" | ");case"ZodEffects":return k(o._def.schema,e,a);case"ZodNativeEnum":throw new nu("ZodNativeEnum",e.toString());case"ZodOptional":return`${k(o._def.innerType,e,a)} | undefined`;case"ZodNullable":return`${k(o._def.innerType,e,a)} | null`;case"ZodDefault":let ee=n.treatDefaultAsOptional?o._def.innerType.optional():o._def.innerType;return k(ee,e,a);case"ZodCatch":return k(o._def.innerType,e,a);case"ZodPromise":return`Promise<${k(o._def.type,e,a)}>`;case"ZodBranded":return k(o._def.type,e,a);case"ZodPipeline":return k(o._def.in,e,a);case"ZodSymbol":return`${W(o.description)} symbol`.trim();case"ZodReadonly":return`Readonly<${k(o._def.innerType,e,a)}>`;case"ZodRef":return Mu(o._def.uri);default:fe.assertNever(o)}}l(k,"sUnwrapZod");var Vy=l((t,e,n)=>{if(t.props.type==="none")return k(t.props.schema,e,n);let{schema:r,identifier:i}=t.props,s=W(r.description),a=r.describe(""),o=k(a,e,f(c({},n),{declaration:!0})),d=o.split(`
|
|
70
|
+
`).length>=Ly&&n.includeClosingTags?`// end of ${i}`:"";if(t.props.type!=="type"&&r.typeName==="ZodFunction")return ur(`${s}
|
|
71
|
+
declare function ${i}${o};${d}`);if(t.props.type==="variable")return ur(`${s}declare const ${i}: ${o};${d}`);let p=t.props.args.length>0?`<${t.props.args.map(Mu).join(", ")}>`:"";return ur(`${s}type ${t.props.identifier}${p} = ${o};${d}`)},"unwrapDeclaration"),Gy=l(t=>t.declaration?t.declaration===!0?"variable":t.declaration:"none","getDeclarationType"),Jy=l((t,e)=>{let n=Gy(e),r=t.getReferences();if(n==="none"){if(r.length>0)throw new _r;return new Zt({type:"none",schema:t})}let i="title"in t.ui?t.ui.title:null;if(!i)throw new iu;if(n==="variable"){if(r.length>0)throw new _r;return new Zt({type:"variable",identifier:i,schema:t})}return new Zt({type:"type",identifier:i,schema:t,args:r})},"getDeclarationProps"),Yy=l(t=>{let e=[];if(t.exactLength){let{value:n,message:r}=t.exactLength;e.push(`.length(${T(n)}, ${T(r)})`)}if(t.minLength){let{value:n,message:r}=t.minLength;e.push(`.min(${T(n)}, ${T(r)})`)}if(t.maxLength){let{value:n,message:r}=t.maxLength;e.push(`.max(${T(n)}, ${T(r)})`)}return e.join("")},"generateArrayChecks"),Xy=l(t=>{let e=t.checks;return e.length===0?"":e.map(Qy).join("")},"generateBigIntChecks"),Qy=l(t=>{switch(t.kind){case"min":return`.min(${T(t.value)}, ${T(t.message)})`;case"max":return`.max(${T(t.value)}, ${T(t.message)})`;case"multipleOf":return`.multipleOf(${T(t.value)}, ${T(t.message)})`;default:return""}},"_generateBigIntCheck"),eh=l(t=>{let e=t.checks;return e.length===0?"":e.map(th).join("")},"generateDateChecks"),th=l(t=>{switch(t.kind){case"min":return`.min(${ns(t.value)}, ${T(t.message)})`;case"max":return`.max(${ns(t.value)}, ${T(t.message)})`;default:return""}},"_generateDateCheck"),ns=l(t=>`new Date(${t})`,"dateTs"),nh=l(t=>{let e=t.checks;return e.length===0?"":e.map(rh).join("")},"generateNumberChecks"),rh=l(t=>{switch(t.kind){case"min":return`.min(${T(t.value)}, ${T(t.message)})`;case"max":return`.max(${T(t.value)}, ${T(t.message)})`;case"int":return`.int(${T(t.message)})`;case"multipleOf":return`.multipleOf(${T(t.value)}, ${T(t.message)})`;case"finite":return`.finite(${T(t.message)})`;default:return""}},"_generateNumberCheck"),ih=l(t=>{let e=[];if(t.minSize){let{value:n,message:r}=t.minSize;e.push(`.min(${T(n)}, ${T(r)})`)}if(t.maxSize){let{value:n,message:r}=t.maxSize;e.push(`.max(${T(n)}, ${T(r)})`)}return e.join("")},"generateSetChecks"),sh=l(t=>{let e=t.checks;return e.length===0?"":e.map(ah).join("")},"generateStringChecks"),ah=l(t=>{switch(t.kind){case"min":return`.min(${T(t.value)}, ${T(t.message)})`;case"max":return`.max(${T(t.value)}, ${T(t.message)})`;case"length":return`.length(${T(t.value)}, ${T(t.message)})`;case"email":return`.email(${T(t.message)})`;case"url":return`.url(${T(t.message)})`;case"emoji":return`.emoji(${T(t.message)})`;case"uuid":return`.uuid(${T(t.message)})`;case"cuid":return`.cuid(${T(t.message)})`;case"cuid2":return`.cuid2(${T(t.message)})`;case"ulid":return`.ulid(${T(t.message)})`;case"includes":let e=ut({message:t.message,position:t.position});return`.includes(${T(t.value)}, ${e})`;case"startsWith":return`.startsWith(${T(t.value)}, ${T(t.message)})`;case"endsWith":return`.endsWith(${T(t.value)}, ${T(t.message)})`;case"regex":return`.regex(${String(t.regex)}, ${T(t.message)})`;case"trim":return".trim()";case"toLowerCase":return".toLowerCase()";case"toUpperCase":return".toUpperCase()";case"datetime":let r=t.precision===null?void 0:t.precision;return`.datetime(${ut({message:t.message,precision:r,offset:t.offset})})`;case"ip":return`.ip(${ut({message:t.message,version:t.version})})`;default:return""}},"_generateStringCheck"),{zuiKey:ne}=Ie;function oi(t){return Fu(t,new qt)}l(oi,"toTypescriptSchema");function Fu(t,e){return N(t,e)}l(Fu,"_toTypescriptSchema");function N(t,e){let n=t;switch(n.typeName){case"ZodString":return`z.string()${sh(n._def)}${O(n._def)}`.trim();case"ZodNumber":return`z.number()${nh(n._def)}${O(n._def)}`.trim();case"ZodNaN":return`z.nan()${O(n._def)}`.trim();case"ZodBigInt":return`z.bigint()${Xy(n._def)}${O(n._def)}`.trim();case"ZodBoolean":return`z.boolean()${O(n._def)}`.trim();case"ZodDate":return`z.date()${eh(n._def)}${O(n._def)}`.trim();case"ZodUndefined":return`z.undefined()${O(n._def)}`.trim();case"ZodNull":return`z.null()${O(n._def)}`.trim();case"ZodAny":return`z.any()${O(n._def)}`.trim();case"ZodUnknown":return`z.unknown()${O(n._def)}`.trim();case"ZodNever":return`z.never()${O(n._def)}`.trim();case"ZodVoid":return`z.void()${O(n._def)}`.trim();case"ZodArray":return`z.array(${N(n._def.type,e.withIndexType("number"))})${Yy(n._def)}${O(n._def,n._def.type)}`;case"ZodObject":let r={};for(let[ae,de]of Object.entries(n.shape))r[ae]=N(de,e.withIndexType("key",ae));let i=n.additionalProperties(),s=i?`.catchall(${N(i,e.withIndexType("string"))})`:"";return["z.object({",...Object.entries(r).map(([ae,de])=>` ${ae}: ${de},`),`})${s}${O(n._def)}`].join(`
|
|
72
|
+
`).trim();case"ZodUnion":return`z.union([${n._def.options.map((ae,de)=>N(ae,e.withIndexType("number",de))).join(", ")}])${O(n._def)}`.trim();case"ZodDiscriminatedUnion":let o=n._def.options.map((ae,de)=>N(ae,e.withIndexType("number",de)));return`z.discriminatedUnion(${T(n._def.discriminator)}, [${o.join(", ")}])${O(n._def)}`.trim();case"ZodIntersection":let d=N(n._def.left,e.withIndexType("number",0)),p=N(n._def.right,e.withIndexType("number",1));return`z.intersection(${d}, ${p})${O(n._def)}`.trim();case"ZodTuple":return`z.tuple([${n._def.items.map((ae,de)=>N(ae,e.withIndexType("number",de))).join(", ")}])${O(n._def)}`.trim();case"ZodRecord":let m=N(n._def.keyType,e.withWrapper("KeyOf")),_=E.zuiString(n._def.keyType)?e.withIndexType("string"):E.zuiNumber(n._def.keyType)?e.withIndexType("number"):e.withIndexType("any"),h=N(n._def.valueType,_);return`z.record(${m}, ${h})${O(n._def)}`.trim();case"ZodMap":let A=N(n._def.keyType,e.withWrapper("KeyOf")),z=E.zuiString(n._def.keyType)?e.withIndexType("string"):E.zuiNumber(n._def.keyType)?e.withIndexType("number"):e.withIndexType("any"),Q=N(n._def.valueType,z);return`z.map(${A}, ${Q})${O(n._def)}`.trim();case"ZodSet":return`z.set(${N(n._def.valueType,e.withIndexType("number"))})${ih(n._def)}${O(n._def)}`.trim();case"ZodFunction":let ee=n._def.args.items.map((ae,de)=>N(ae,e.withWrapper("Parameters").withIndexType("number",de))),U=ee.length?`.args(${ee.join(", ")})`:"",K=N(n._def.returns,e.withWrapper("ReturnType"));return`z.function()${U}.returns(${K})${O(n._def)}`.trim();case"ZodLazy":return`z.lazy(() => ${N(n._def.getter(),e)})${O(n._def)}`.trim();case"ZodLiteral":return`z.literal(${T(n._def.value)})${O(n._def)}`.trim();case"ZodEnum":return`z.enum([${n._def.values.map(T).join(", ")}])${O(n._def)}`.trim();case"ZodEffects":throw new ze("ZodEffects",e.toString());case"ZodNativeEnum":throw new ze("ZodNativeEnum",e.toString());case"ZodOptional":return`z.optional(${N(n._def.innerType,e)})${O(n._def,n._def.innerType)}`.trim();case"ZodNullable":return`z.nullable(${N(n._def.innerType,e)})${O(n._def,n._def.innerType)}`.trim();case"ZodDefault":let Sc=ut(n._def.defaultValue());return`z.default(${N(n._def.innerType,e)}, ${Sc})${O(n._def,n._def.innerType)}`.trim();case"ZodCatch":throw new ze("ZodCatch",e.toString());case"ZodPromise":return`z.promise(${N(n._def.type,e)})${O(n._def,n._def.type)}`.trim();case"ZodBranded":throw new ze("ZodBranded",e.toString());case"ZodPipeline":throw new ze("ZodPipeline",e.toString());case"ZodSymbol":throw new ze("ZodSymbol",e.toString());case"ZodReadonly":return`z.readonly(${N(n._def.innerType,e)})${O(n._def,n._def.innerType)}`.trim();case"ZodRef":return`z.ref(${T(n._def.uri)})${O(n._def)}`.trim();default:fe.assertNever(n)}}l(N,"sUnwrapZod");var O=l((t,e)=>{let n=e?._def;return`${lh(t,n)}${oh(t,n)}`},"_addMetadata"),oh=l((t,e)=>!t.description||e&&e.description===t.description?"":`.describe(${T(t.description)})`,"_maybeDescribe"),lh=l((t,e)=>`${uh(t,e)}${ch(t,e)}${dh(t,e)}${ph(t,e)}${fh(t,e)}${gh(t,e)}${mh(t,e)}`,"_addZuiExtensions"),uh=l((t,e)=>{var n,r;let i=(n=t[ne])==null?void 0:n.title;return!i||e&&((r=e[ne])==null?void 0:r.title)===i?"":`.title(${T(i)})`},"_maybeTitle"),ch=l((t,e)=>{var n,r;let i=(n=t[ne])==null?void 0:n.displayAs;return!i||e&&Ce((r=e[ne])==null?void 0:r.displayAs,i)?"":`.displayAs(${Hu({id:i[0],params:i[1]})})`},"_maybeDisplayAs"),dh=l((t,e)=>{var n,r;let i=(n=t[ne])==null?void 0:n.disabled;return!i||e&&((r=e[ne])==null?void 0:r.disabled)===i?"":`.disabled(${i})`},"_maybeDisabled"),ph=l((t,e)=>{var n,r;let i=(n=t[ne])==null?void 0:n.hidden;return!i||e&&((r=e[ne])==null?void 0:r.hidden)===i?"":`.hidden(${i})`},"_maybeHidden"),fh=l((t,e)=>{var n,r;let i=(n=t[ne])==null?void 0:n.placeholder;return!i||e&&((r=e[ne])==null?void 0:r.placeholder)===i?"":`.placeholder(${T(i)})`},"_maybePlaceholder"),gh=l((t,e)=>{var n,r;let i=(n=t[ne])==null?void 0:n.secret;return!i||e&&((r=e[ne])==null?void 0:r.secret)===i?"":".secret()"},"_maybeSecret"),mh=l((t,e)=>{var n,r;let i=["title","tooltip","displayAs","disabled","hidden","placeholder","secret","coerce"],s=Object.entries((n=t[ne])!=null?n:{}).filter(([a])=>!i.includes(a));if(s.length===0)return"";if(e){let a=Object.entries((r=e[ne])!=null?r:{}).filter(([o])=>!i.includes(o));if(Ce(Object.fromEntries(s),Object.fromEntries(a)))return""}return`.metadata(${Hu(Object.fromEntries(s))})`},"_maybeSetMetadata"),yh={};P.prototype.toJSONSchema=function(t={}){return si(this,t)};P.prototype.toTypescriptType=function(t={}){return ai(this,t)};P.prototype.toTypescriptSchema=function(){return oi(this)};var q=v.string().min(1),Vu=v.object({text:q}),Gu=v.object({markdown:q}),Ju=v.object({imageUrl:q,title:q.optional()}),Yu=v.object({audioUrl:q,title:q.optional()}),Xu=v.object({videoUrl:q,title:q.optional()}),Qu=v.object({fileUrl:q,title:q.optional()}),ec=v.object({latitude:v.number(),longitude:v.number(),address:v.string().optional(),title:v.string().optional()}),tc=v.object({title:q,subtitle:q.optional(),imageUrl:q.optional(),actions:v.array(v.object({action:v.enum(["postback","url","say"]),label:q,value:q}))}),qu=v.object({text:q,options:v.array(v.object({label:q,value:q}))}),hh=v.object({items:v.array(tc)}),nc=v.union([v.object({type:v.literal("text"),payload:Vu}),v.object({type:v.literal("image"),payload:Ju}),v.object({type:v.literal("audio"),payload:Yu}),v.object({type:v.literal("video"),payload:Xu}),v.object({type:v.literal("file"),payload:Qu}),v.object({type:v.literal("location"),payload:ec})]),vh=v.object({items:v.array(nc)}),_h={schema:Gu},Th={schema:v.object({items:v.array(v.union([...nc.options,v.object({type:v.literal("markdown"),payload:Gu})]))})},bh={text:{schema:Vu},image:{schema:Ju},audio:{schema:Yu},video:{schema:Xu},file:{schema:Qu},location:{schema:ec},carousel:{schema:hh},card:{schema:tc},dropdown:{schema:qu},choice:{schema:qu},bloc:{schema:vh}};var wh={HIDDEN_IN_STUDIO:{bpActionHiddenInStudio:"true"},AWAIT_RETURN:{bpActionAwaitReturn:"true"}},xh="x-bp-integration-identifier";var rc=require("browser-or-node");var ui=console;function oe(t){if(!t.body)throw new Error("Missing body");return JSON.parse(t.body)}async function Vt(t,e=8072,n=Ih){if(!rc.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 Ph(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);ui.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 Ph(t){let e=await kh(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:Sh(r.search,"?"),headers:n,method:t.method?.toUpperCase()??"GET"}}function Sh(t,e){return t.indexOf(e)===0?t.slice(e.length):t}async function kh(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 Ih(t){ui.info(`Listening on port ${t}`)}var Jn=require("@botpress/client");var ci={};De(ci,{DefinitionError:()=>re,isDefinitionError:()=>Oh});var re=class extends Error{__IS_SDK_ERROR__=!0;type="definition_error"},Oh=t=>t instanceof re||typeof t=="object"&&t!==null&&"__IS_SDK_ERROR__"in t&&t.__IS_SDK_ERROR__===!0&&"type"in t&&t.type==="definition_error";var D={};De(D,{mapKeys:()=>Ch,mapValues:()=>Bh,mergeRecords:()=>Rh,pairs:()=>Zn,stripUndefinedProps:()=>Ah,values:()=>Eh});var Zn=t=>Object.entries(t),Eh=t=>Object.values(t),Bh=(t,e)=>Object.fromEntries(Zn(t).map(([n,r])=>[n,e(r,n)])),Ch=(t,e)=>Object.fromEntries(Zn(t).map(([n,r])=>[e(n),r])),Ah=t=>Object.fromEntries(Zn(t).filter(([,e])=>e!==void 0)),Rh=(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 w={};De(w,{safePush:()=>Zh,unique:()=>Dh});var Zh=(t,...e)=>t?[...t,...e]:[...e],Dh=t=>Array.from(new Set(t));var G={};De(G,{setName:()=>Nh});var Nh=(t,e)=>(Object.defineProperty(t,"name",{value:e}),t);var ic=t=>{let{name:e,version:n}=t,r={actions:{},events:{},channels:{}},i={name:e,version:n,entities:D.mapValues(t.entities,a=>({name:a.name})),actions:{},events:{},channels:{}},s=D.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 m=g.schema.dereference(s);u[p]={...g,schema:m}}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 sc="6.12.0";var Ze=sc;var Dn=Symbol("schemaName"),ac=t=>t?D.mapValues(t,(n,r)=>({...n,[Dn]:r})):{},oc=t=>Dn in t&&t[Dn]!==void 0,lc=t=>t[Dn];var Nn=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:Ze}}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(m=>m.name),d=u.length===0?e.name:`${e.name}<${u.join(",")}>`,{resolved:p,statement:g}=ic({...e,entities:r,actions:D.stripUndefinedProps(i),events:D.stripUndefinedProps(s),channels:D.stripUndefinedProps(a)});return o.actions=D.mergeRecords(o.actions??{},p.actions,this._mergeActions),o.channels=D.mergeRecords(o.channels??{},p.channels,this._mergeChannels),o.events=D.mergeRecords(o.events??{},p.events,this._mergeEvents),o.interfaces[d]={id:e.id,...g},this}_callBuilder(e,n){let i={entities:ac(this.entities)},s=n(i),a=D.pairs(s.entities).find(([u,d])=>!oc(d));if(a)throw new re(`Cannot extend interface "${e.name}" with entity "${a[0]}"; the provided schema is not part of the integration's entities.`);return{entities:D.mapValues(s.entities,u=>({name:lc(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=D.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 v.object({...s,...a})}if(r.typeName==="ZodRecord"&&i.typeName==="ZodRecord")return v.record(v.intersection(r.valueType,i.valueType));throw new Error("Cannot merge object schemas with record schemas")}};var Ee=require("@botpress/client");var uc=Yn(require("@botpress/client")),Hn={retries:3,retryCondition:t=>uc.axiosRetry.isNetworkOrIdempotentRequestError(t)||[429,502].includes(t.response?.status??0),retryDelay:(t,e)=>(Mh(e.response?.headers??{})??t)*1e3},Mh=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 jh(String(r))}},jh=t=>{let e=$h(t)?zh(t):t.length>0?parseInt(t,10):void 0;return e===void 0||isNaN(e)?void 0:e},$h=t=>t.includes(" "),zh=t=>{let e=Uh(t);if(!e)return;let n=new Date;return Math.max(0,Math.floor((e.getTime()-n.getTime())/1e3))},Uh=t=>{let e=new Date(t);return isNaN(e.getTime())?void 0:e};var ft=class{constructor(e){this._client=e}get _inner(){return this._client}createConversation=(e=>this._client.createConversation(e));getConversation=(e=>this._client.getConversation(e));listConversations=(e=>this._client.listConversations(e));getOrCreateConversation=(e=>this._client.getOrCreateConversation(e));updateConversation=(e=>this._client.updateConversation(e));deleteConversation=(e=>this._client.deleteConversation(e));listParticipants=(e=>this._client.listParticipants(e));addParticipant=(e=>this._client.addParticipant(e));getParticipant=(e=>this._client.getParticipant(e));removeParticipant=(e=>this._client.removeParticipant(e));createEvent=(e=>this._client.createEvent(e));getEvent=(e=>this._client.getEvent(e));listEvents=(e=>this._client.listEvents(e));createMessage=(e=>this._client.createMessage(e));getOrCreateMessage=(e=>this._client.getOrCreateMessage(e));getMessage=(e=>this._client.getMessage(e).then(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 Mn=class{_cost=0;get cost(){return this._cost}setCost(e){this._cost=e}toJSON(){return{cost:this.cost}}};var me="#",jn="x-bot-id",cc="x-bot-user-id",dc="x-integration-id",pc="x-integration-alias",fc="x-webhook-id",gc="x-bp-configuration-type",$n="x-bp-configuration",zn="x-bp-operation",mc="x-bp-type";var le=t=>{throw t instanceof Error?t:new Error(t)};var v_=v.enum(["webhook_received","message_created","action_triggered","register","unregister","ping","create_user","create_conversation"]),yc=t=>({botId:t[jn]||le("Missing bot header"),botUserId:t[cc]||le("Missing bot user header"),integrationId:t[dc]||le("Missing integration header"),integrationAlias:t[pc]||le("Missing integration alias header"),webhookId:t[fc]||le("Missing webhook header"),operation:t[zn]||le("Missing operation header"),configurationType:t[gc]??null,configuration:JSON.parse(Buffer.from(t[$n]||le("Missing configuration header"),"base64").toString("utf-8"))});var hc=Yn(require("util")),gt=class{defaultOptions;constructor(e){this.defaultOptions=e}info(...e){this._log("info",e)}debug(...e){this._log("debug",e)}warn(...e){this._log("warn",e)}error(...e){this._log("error",e)}issue(e){console.info(JSON.stringify({...e,...this.getIssueContext()}))}getIssueContext(){return{}}_log(e,n){this._getConsoleMethod(e)(this._serializeMessage(e,n))}_serializeMessage(e,n){let r=hc.default.format(...n);return process.env.BP_LOG_FORMAT==="json"?this.getJsonMessage(e,r):r}getJsonMessage(e,n){return JSON.stringify({msg:n,level: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 mt=class t extends gt{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,n){return JSON.stringify({msg:n,level:e,botId:this.defaultOptions.botId,integrationId:this.defaultOptions.integrationId,integrationAlias:this.defaultOptions.integrationAlias,visible_to_bot_owner:this.defaultOptions.visibleToBotOwners,hidden_to_integration_owner:this.defaultOptions.hiddenToIntegrationOwners,options:this.defaultOptions})}getIssueContext(){let{botId:e,integrationId:n,integrationAlias:r}=this.defaultOptions;return{...e&&{botId:e},...n&&{integrationId:n},...r&&{integrationAlias:r}}}};var Kh=t=>["traceparent","tracestate","sentry-trace"].reduce((e,n)=>(t[n]&&(e[n]=t[n]),e),{}),Wh=(t,e,n)=>{let[,r]=(e.headers.traceparent||"").split("-"),i=new Ee.Client({botId:t.botId,integrationId:t.integrationId,integrationAlias:t.integrationAlias,retry:Hn,headers:n.managesOwnTracePropagation?{}:Kh(e.headers)}),s=new ft(i),a=new mt({traceId:r,botId:t.botId,integrationId:t.integrationId,integrationAlias:t.integrationAlias});return{ctx:t,req:e,client:s,logger:a,instance:n}},Lh=async t=>{let{ctx:e}=t;switch(e.operation){case"webhook_received":return await qh(t);case"register":return await Vh(t);case"unregister":return await Gh(t);case"message_created":return await Xh(t);case"action_triggered":return await Qh(t);case"ping":return await Fh(t);case"create_user":return await Jh(t);case"create_conversation":return await Yh(t);default:throw new Ee.InvalidPayloadError(`Unknown operation ${e.operation}`)}},vc=t=>async e=>{let n=yc(e.headers),r=Wh(n,e,t),{logger:i}=r;try{let s;return s=await ev(r),s?{...s,status:s.status??200}:(s=await Lh(r),s?{...s,status:s.status??200}:{status:200})}catch(s){if((0,Ee.isApiError)(s)){let o=s.type==="Runtime"?s:new Ee.RuntimeError(s.message,s);return i.forBot().error(o.message),{status:o.code,body:JSON.stringify(o.toJSON())}}console.error(s);let a=new Ee.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())}}},Fh=async t=>{},qh=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{let{req:s}=oe(n);return i.webhook({client:t,ctx:e,req:s,logger:r})},Vh=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{if(!i.register)return;let{webhookUrl:s}=oe(n);await i.register({client:t,ctx:e,webhookUrl:s,logger:r})},Gh=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{if(!i.unregister)return;let{webhookUrl:s}=oe(n);await i.unregister({ctx:e,webhookUrl:s,client:t,logger:r})},Jh=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{if(!i.createUser)return;let{tags:s}=oe(n);return await i.createUser({ctx:e,client:t,tags:s,logger:r})},Yh=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{if(!i.createConversation)return;let{channel:s,tags:a}=oe(n);return await i.createConversation({ctx:e,client:t,channel:s,tags:a,logger:r})},Xh=async({ctx:t,req:e,client:n,logger:r,instance:i})=>{let{conversation:s,user:a,type:o,payload:u,message:d}=oe(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:_})=>{await n.updateMessage({id:d.id,tags:_})},logger:r})},Qh=async({req:t,ctx:e,client:n,logger:r,instance:i})=>{let{input:s,type:a}=oe(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 Mn,p={output:await o({ctx:e,input:s,client:n,type:a,logger:r,metadata:u}),meta:u.toJSON()};return{body:JSON.stringify(p)}},ev=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 Un=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,this.managesOwnTracePropagation=e.__advanced?.managesOwnTracePropagation}actions;channels;register;unregister;createUser;createConversation;webhook;unknownOperationHandler;managesOwnTracePropagation;handler=vc(this);start=e=>Vt(this.handler,e)};function Kn(t){if(t)return Object.fromEntries(Object.entries(t).map(([e,{recurrence:n,...r}])=>[e,r]))}function Wn(t,e){let r={...Object.fromEntries(Object.entries(t??{}).map(([i,s])=>s.recurrence?[i,{type:i,payload:s.recurrence.payload,schedule:{cron:s.recurrence.cron}}]:null).filter(i=>i!==null)),...e};return Object.keys(r).length?r:void 0}var Ln=class{constructor(e){this.props=e;let n=Kn(e.events),r=Wn(e.events,e.recurringEvents);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=n,this.recurringEvents=r,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:n,recurringEvents:r,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:Ze}}addIntegration(e,n){let r=this;r.integrations||(r.integrations={});let i=n?.alias??e.name;if(r.integrations[i])throw new re(`Another integration with alias "${i}" is already installed in the bot`);let s=n&&"configurationType"in n?n.configurationType:void 0,a=n&&"configuration"in n?n.configuration??{}:{},o=s?e.definition.configurations?.[s]?.schema:e.definition.configuration?.schema,u=o?o.safeParse(a):null,d=u?.success?{...a,...u.data}:a;return r.integrations[i]={...e,alias:i,enabled:n?.enabled,configurationType:s,configuration:d,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 re(`Another plugin with alias "${i}" is already installed in the bot`);let s=Object.fromEntries(Object.entries(n.dependencies??{}).filter(([g,m])=>"integrationInterfaceAlias"in m).map(([g,m])=>{let _=this.integrations?.[m.integrationAlias];if(!_){let A=Object.keys(this.integrations??{}).join(", ")||"(none)";throw new re(`Interface with alias "${g}" of plugin with alias "${i}" references integration with alias "${m.integrationAlias}" which is not installed. Please make sure to add the integration via addIntegration() before calling addPlugin().
|
|
73
73
|
Available integration aliases: ${A}`)}let h=_.definition.interfaces?.[m.integrationInterfaceAlias];if(!h){let A=Object.keys(_.definition.interfaces??{}).join(", ")||"(none)";throw new re(`Interface with alias "${m.integrationInterfaceAlias}" does not exist in integration "${_.name}" referenced by interface with alias "${g}" of plugin with alias "${i}".
|
|
74
74
|
Available interface aliases: ${A}`)}return[g,{...h,id:_.id,name:_.name,version:_.version,...m}]})),a=Object.fromEntries(Object.entries(n.dependencies??{}).filter(([g,m])=>!("integrationInterfaceAlias"in m)).map(([g,m])=>{let _=this.integrations?.[m.integrationAlias];if(!_){let h=Object.keys(this.integrations??{}).join(", ")||"(none)";throw new Error(`Integration with alias "${g}" of plugin with alias "${i}" references integration with alias "${m.integrationAlias}" which is not installed. Please make sure to add the integration via addIntegration() before calling addPlugin().
|
|
75
|
-
Available integration aliases: ${h}`)}return[g,{..._,...m}]})),o=n.configuration??{},u=e.definition.configuration?.schema,d=u?u.safeParse(o):null,p=d?.success?{...o,...d.data}:o;return r.plugins[i]={...e,alias:i,configuration:p,interfaces:s,integrations:a},r.withPlugins.user=this._mergeUser(r.withPlugins.user,e.definition.user),r.withPlugins.conversation=this._mergeConversation(r.withPlugins.conversation,e.definition.conversation),r.withPlugins.message=this._mergeMessage(r.withPlugins.message,e.definition.message),r.withPlugins.recurringEvents=this._mergeRecurringEvents(r.withPlugins.recurringEvents,e.definition.recurringEvents),r.withPlugins.tables=this._mergeTables(r.withPlugins.tables,e.definition.tables),r.withPlugins.workflows=this._mergeWorkflows(r.withPlugins.workflows,e.definition.workflows),r.withPlugins.states=this._mergeStates(r.withPlugins.states,this._prefixKeysWithPluginAlias(e.definition.states,i)),r.withPlugins.events=this._mergeEvents(r.withPlugins.events,this._prefixKeysWithPluginAlias(e.definition.events,i)),r.withPlugins.actions=this._mergeActions(r.withPlugins.actions,this._prefixKeysWithPluginAlias(e.definition.actions,i)),this}_mergeUser=(e,n)=>({tags:{...e?.tags,...n?.tags}});_mergeConversation=(e,n)=>({tags:{...e?.tags,...n?.tags}});_mergeMessage=(e,n)=>({tags:{...e?.tags,...n?.tags}});_mergeStates=(e,n)=>({...e,...n});_mergeEvents=(e,n)=>({...e,...n});_mergeRecurringEvents=(e,n)=>({...e,...n});_mergeActions=(e,n)=>({...e,...n});_mergeTables=(e,n)=>({...e,...n});_mergeWorkflows=(e,n)=>({...e,...n});_prefixKeysWithPluginAlias=(e,n)=>N.mapKeys(e??{},r=>`${n}${me}${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 re(`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 m=u.definition.entities?.[g]?.schema;if(!m)throw new Error(`Interface entity "${g}" does not exist in integration "${u.name}"`);e[`interface:${a}/entities/${p}`]=m}}}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 rt=require("@botpress/client");var yt=class t extends gt{constructor(e){super({...e})}with(e){return new t({...this.defaultOptions,...e})}withUserId(e){return this.with({userId:e})}withConversationId(e){return this.with({conversationId:e})}withWorkflowId(e){return this.with({workflowId:e})}withEventId(e){return this.with({eventId:e})}withMessageId(e){return this.with({messageId:e})}};var Te=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 Qh=v.enum(["event_received","register","unregister","ping","action_triggered"]),hc=t=>({botId:t[jn]||le("Missing bot id header"),operation:Qh.parse(t[Un]),type:t[fc]||le("Missing type header"),configuration:JSON.parse(Buffer.from(t[$n]||le("Missing configuration header"),"base64").toString("utf-8"))});var J={status:200};var ci=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 ev=["child_workflow_deleted","child_workflow_finished","workflow_timedout","workflow_started","workflow_continued"],vc=async(t,e)=>{if(t.ctx.type!=="workflow_update"||!ev.includes(e.payload.type))throw new Error("Unexpected event type");let n={...t,logger:tv(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),J;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 nv(n,e);default:e.payload.type}return J},tv=(t,e)=>t.logger.with({eventId:e.id,workflowId:e.payload.workflow.id,conversationId:e.payload.conversation?.id,userId:e.payload.user?.id}),nv=async(t,e)=>{let n=ci(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}"`),J;let{updatedWorkflow:i}=await rv(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. `),J},rv=async(t,e)=>{let n=ci(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 _c=t=>async e=>{let n=hc(e.headers),r=new yt,i=new rt.Client({botId:n.botId,retry:Hn}),s=new Te(i,{before:{createMessage:async o=>{let u=t.hookHandlers.before_outgoing_message[o.type]??[];for(let d of u){let p=new Te(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 Te(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 Te(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 m=new Te(i);o=(await g({client:m,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 lv(a);case"event_received":return await ov(a);case"register":return await sv(a);case"unregister":return await av(a);case"ping":return await iv(a);default:throw new Error(`Unknown operation ${n.operation}`)}}catch(o){let u=o instanceof Error?o:new Error(String(o));if((0,rt.isApiError)(u)){let p=u.type==="Runtime"?u:new rt.RuntimeError(u.message,u);return r.error(p.message),{status:p.code,body:JSON.stringify(p.toJSON())}}let d=new rt.RuntimeError("An unexpected error occurred in the bot.",u);return r.error(d.message,u),{status:d.code,body:JSON.stringify(d.toJSON())}}},iv=async t=>J,sv=async t=>(await t.self.registerHandler?.({client:t.client,ctx:t.ctx,logger:t.logger}),J),av=async t=>J,ov=async t=>{let{ctx:e,logger:n,req:r,client:i,self:s}=t,a={client:i,ctx:e,logger:n},o=oe(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 vc(t,o.event);if(e.type==="message_created"){let _=o.event,h=_.payload.message,A=_.payload.user,U=_.payload.conversation;a.logger=a.logger.with({messageId:h.id,conversationId:h.conversationId,userId:h.userId});let Q=s.hookHandlers.before_incoming_message[h.type]??[];for(let ie of Q){let st=await ie({...a,user:A,conversation:U,data:h});if(h=st?.data??h,st?.stop)return J}let ee={...a,user:A,conversation:U,message:h,event:_},z=s.messageHandlers[h.type]??[];for(let ie of z)await ie(ee);let K=s.hookHandlers.after_incoming_message[h.type]??[];for(let ie of K){let st=await ie({...a,user:A,conversation:U,data:h});if(h=st?.data??h,st?.stop)return J}return J}if(e.type==="state_expired"){let h=o.event.payload.state,A={...a,state:h},U=s.stateExpiredHandlers[h.name]??[];for(let Q of U)await Q(A);return J}let u=o.event,d=s.hookHandlers.before_incoming_event[u.type]??[];for(let _ of d){let h=await _({...a,data:u});if(u=h?.data??u,h?.stop)return J}let p={...a,event:u},g=s.eventHandlers[u.type]??[];for(let _ of g)await _(p);let m=s.hookHandlers.after_incoming_event[u.type]??[];for(let _ of m){let h=await _({...a,data:u});if(u=h?.data??u,h?.stop)return J}return J},lv=async({ctx:t,logger:e,req:n,client:r,self:i})=>{let{input:s,type:a}=oe(n);if(!a)throw new Error("Missing action type");let o=i.hookHandlers.before_incoming_call_action[a]??[];for(let m of o){let _=await m({ctx:t,logger:e,client:r,data:{type:a,input:s}});s=_?.data?.input??s,a=_?.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 m of p){let _=await m({ctx:t,logger:e,client:r,data:{type:a,output:d}});a=_?.data?.type??a,d=_?.data?.output??d}return{status:200,body:JSON.stringify({output:d})}};var be=(t,{alias:e})=>{if(!("tags"in t)||!e)return t;let n=`${e}${me}`,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}${me}`,r=Object.fromEntries(Object.entries(t.tags??{}).map(([i,s])=>[i.startsWith(n)?i:`${n}${i}`,s]));return{...t,tags:r}};var di=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}},ue=t=>new di(t);var Be=t=>new Proxy({},{get:(e,n)=>({listInstances:r=>ue(({nextToken:i})=>t.client.listWorkflows({...r,name:n,nextToken:i}).then(({meta:s,workflows:a})=>({meta:s,items:a.map(o=>ce({...t,workflow:o}))}))),startNewInstance:async r=>{let{workflow:i}=await t.client.createWorkflow({name:n,status:"pending",...X(r,{alias:void 0})});return{workflow:ce({...t,workflow:i})}}})}),ce=t=>{let e=!1;return{...be(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:ce({...t,workflow:r})}},async acknowledgeStartOfProcessing(){if(!t.event||t.workflow.status!=="pending"||e)return{workflow:ce(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:ce({...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:ce({...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:ce({...t,workflow:r})}},async cancel(){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,status:"cancelled"});return await t.onWorkflowUpdate?.(n),{workflow:ce({...t,workflow:n})}}}};var Wn=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 G.setName(i=>r({...i,workflows:Be(i)}),r.name);for(let[i,s]of Object.entries(this._plugins)){let[a,o]=n.split(me);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})=>G.setName(u=>o({...u,workflows:Be(u)}),o.name));return w.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})=>G.setName(u=>o({...u,workflows:Be(u)}),o.name));return w.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})=>G.setName(u=>o({...u,workflows:Be(u)}),o.name));return w.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,m)=>g.order-m.order).map(({handler:g})=>G.setName(m=>g({...m,workflows:Be(m)}),g.name));return w.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})=>G.setName(async d=>{let p=d.workflow;return await u({...d,workflow:ce({...d,onWorkflowUpdate(g){p=g}}),workflows:Be(d)}),p},u.name))??[],o=Object.values(this._plugins).flatMap(u=>u.workflowHandlers[n]?.[s]??[]);return w.unique([...a,...o])}})}})}on={message:(e,n)=>{this._messageHandlers[e]=w.safePush(this._messageHandlers[e],{handler:n,order:this._registerOrder++})},event:(e,n)=>{this._eventHandlers[e]=w.safePush(this._eventHandlers[e],{handler:n,order:this._registerOrder++})},stateExpired:(e,n)=>{this._stateExpiredHandlers[e]=w.safePush(this._stateExpiredHandlers[e],{handler:n,order:this._registerOrder++})},beforeIncomingEvent:(e,n)=>{this._hookHandlers.before_incoming_event[e]=w.safePush(this._hookHandlers.before_incoming_event[e],{handler:n,order:this._registerOrder++})},beforeIncomingMessage:(e,n)=>{this._hookHandlers.before_incoming_message[e]=w.safePush(this._hookHandlers.before_incoming_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingMessage:(e,n)=>{this._hookHandlers.before_outgoing_message[e]=w.safePush(this._hookHandlers.before_outgoing_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingCallAction:(e,n)=>{this._hookHandlers.before_outgoing_call_action[e]=w.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},beforeIncomingCallAction:(e,n)=>{this._hookHandlers.before_incoming_call_action[e]=w.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingEvent:(e,n)=>{this._hookHandlers.after_incoming_event[e]=w.safePush(this._hookHandlers.after_incoming_event[e],{handler:n,order:this._registerOrder++})},afterIncomingMessage:(e,n)=>{this._hookHandlers.after_incoming_message[e]=w.safePush(this._hookHandlers.after_incoming_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingMessage:(e,n)=>{this._hookHandlers.after_outgoing_message[e]=w.safePush(this._hookHandlers.after_outgoing_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingCallAction:(e,n)=>{this._hookHandlers.after_outgoing_call_action[e]=w.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingCallAction:(e,n)=>{this._hookHandlers.after_incoming_call_action[e]=w.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:n,order:this._registerOrder++})},workflowStart:(e,n)=>{this._workflowHandlers.started[e]=w.safePush(this._workflowHandlers.started[e],{handler:n,order:this._registerOrder++})},workflowContinue:(e,n)=>{this._workflowHandlers.continued[e]=w.safePush(this._workflowHandlers.continued[e],{handler:n,order:this._registerOrder++})},workflowTimeout:(e,n)=>{this._workflowHandlers.timed_out[e]=w.safePush(this._workflowHandlers.timed_out[e],{handler:n,order:this._registerOrder++})}};handler=_c(this);start=e=>Vt(this.handler,e)};var Ln=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.title=e.title,this.description=e.description,this.readme=e.readme,this.entities=e.entities??{},this.attributes=e.attributes,this.__advanced=e.__advanced;let n=this._getEntityReference(this.entities),r=e.events===void 0?{}:N.mapValues(e.events,a=>({...a,schema:a.schema(n)})),i=e.actions===void 0?{}:N.mapValues(e.actions,a=>({...a,input:{...a.input,schema:a.input.schema(n)},output:{...a.output,schema:a.output.schema(n)}})),s=e.channels===void 0?{}:N.mapValues(e.channels,a=>({...a,messages:N.mapValues(a.messages,o=>({...o,schema:o.schema(n)}))}));this.events=r,this.actions=i,this.channels=s}name;version;title;description;icon;readme;attributes;entities;events;actions;channels;__advanced;get metadata(){return{sdkVersion:Re}}_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=v.ref(r);s&&o.title(s),a&&o.describe(a),n[r]=o}return n}};var Fn=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,v.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 re(`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:Re}}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(v.record(v.string(),v.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 Tc=(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 pi=t=>({async getById({id:e}){let n=await t.client.getMessage({id:e});return ye({...t,message:n.message})},list(e){return ue(({nextToken:n})=>t.client.listMessages({...X(e??{},{alias:t.plugin?.alias}),nextToken:n}).then(({meta:r,messages:i})=>({meta:r,items:i.map(s=>ye({...t,message:s}))})))}}),ye=t=>({...be(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 ye({...t,message:n})}});var fi=t=>({list(e){return ue(({nextToken:n})=>t.client.listUsers({...X(e??{},{alias:t.pluginAlias}),nextToken:n}).then(({meta:r,users:i})=>({meta:r,items:i.map(s=>he({...t,conversationId:e?.conversationId,user:s}))})))},async getById({id:e}){let n=await t.client.getUser({id:e});return he({...t,user:n.user,conversationId:void 0})}}),he=t=>{let e={...be(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 he({...t,user:r})}};return t.conversationId?{...e,async removeFromConversation(){return await t.client.removeParticipant({id:t.conversationId,userId:t.user.id}),he({...t,conversationId:void 0})}}:{...e,async addToConversation({conversationId:n}){let{participant:r}=await t.client.addParticipant({id:n,userId:t.user.id});return he({...t,user:r,conversationId:n})}}};var gi=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 ue(({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=>it({...t,conversation:g}))})))},async getById({id:s}){let a=await t.client.getConversation({id:s});return it({...t,conversation:a.conversation})}})})}),it=t=>{let e=t.client;return{...be(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 it({...t,conversation:r})},async getMessage({id:n}){let r=await e.getMessage({id:n});return ye({...t,message:r.message})},async getOrCreateMessage(n){let{message:r}=await e.getOrCreateMessage({...X(n,{alias:t.plugin?.alias}),conversationId:t.conversation.id});return ye({...t,message:r})},async createMessage(n){let{message:r}=await e.createMessage({...X(n,{alias:t.plugin?.alias}),conversationId:t.conversation.id});return ye({...t,message:r})},listMessages(n){return ue(({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=>ye({...t,message:a}))})))},listParticipants(){return ue(({nextToken:n})=>e.listParticipants({id:t.conversation.id,nextToken:n}).then(({meta:r,participants:i})=>({meta:r,items:i.map(s=>he({...t,user:s,conversationId:t.conversation.id}))})))}}};var mi=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 ue(({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})))}},bc=(t,e)=>new Proxy({},{get:(n,r)=>{let i=e.alias!==void 0?`${e.alias}${me}${r}`:r;return new mi({client:t,eventName:i})}});var yi=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})}},wc=(t,e)=>new Proxy({},{get:(n,r)=>new Proxy({},{get:(i,s)=>{let a=e.alias!==void 0?`${e.alias}${me}${s}`:s;return new yi(t,r,a)}})});var uv=t=>"user"in t&&"conversation"in t,qn=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=Tc(e,this._runtime),o=wc(e,this._runtime),u=Be({client:e,pluginAlias:this._runtime.alias}),d=bc(e,this._runtime),p=fi({client:e,pluginAlias:this._runtime.alias}),g=gi({client:e,plugin:this._runtime}),m=pi({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:m}}get actionHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=this._actionHandlers[n];if(r)return G.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 w.unique([...r,...i]).sort((a,o)=>a.order-o.order).map(({handler:a})=>G.setName(o=>a({...o,user:he({...o,conversationId:o.conversation.id,pluginAlias:this._runtime.alias}),message:ye({...o,plugin:this._runtime,message:o.message}),conversation:it({...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 w.unique([...r,...i,...s]).sort((o,u)=>o.order-u.order).map(({handler:o})=>G.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 w.unique([...r,...i]).sort((a,o)=>a.order-o.order).map(({handler:a})=>G.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 w.unique([...a,...o,...u]).sort((p,g)=>p.order-g.order).map(({handler:p})=>G.setName(g=>{let m=be(g.data,{alias:this._runtime.alias}),_=this._getTools(g.client),h={};if(uv(g)){let A=he({client:g.client,user:g.user,conversationId:g.conversation.id,pluginAlias:this._runtime.alias}),U=it({client:g.client,plugin:this._runtime,conversation:g.conversation});h={user:A,conversation:U}}return p({...g,data:m,...h,..._})},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})=>G.setName(async u=>{let d=u.workflow;return await o({...u,workflow:ce({...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]=w.safePush(this._messageHandlers[e],{handler:n,order:this._registerOrder++})},event:(e,n)=>{this._eventHandlers[e]=w.safePush(this._eventHandlers[e],{handler:n,order:this._registerOrder++})},stateExpired:(e,n)=>{this._stateExpiredHandlers[e]=w.safePush(this._stateExpiredHandlers[e],{handler:n,order:this._registerOrder++})},beforeIncomingEvent:(e,n)=>{this._hookHandlers.before_incoming_event[e]=w.safePush(this._hookHandlers.before_incoming_event[e],{handler:n,order:this._registerOrder++})},beforeIncomingMessage:(e,n)=>{this._hookHandlers.before_incoming_message[e]=w.safePush(this._hookHandlers.before_incoming_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingMessage:(e,n)=>{this._hookHandlers.before_outgoing_message[e]=w.safePush(this._hookHandlers.before_outgoing_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingCallAction:(e,n)=>{this._hookHandlers.before_outgoing_call_action[e]=w.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},beforeIncomingCallAction:(e,n)=>{this._hookHandlers.before_incoming_call_action[e]=w.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingEvent:(e,n)=>{this._hookHandlers.after_incoming_event[e]=w.safePush(this._hookHandlers.after_incoming_event[e],{handler:n,order:this._registerOrder++})},afterIncomingMessage:(e,n)=>{this._hookHandlers.after_incoming_message[e]=w.safePush(this._hookHandlers.after_incoming_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingMessage:(e,n)=>{this._hookHandlers.after_outgoing_message[e]=w.safePush(this._hookHandlers.after_outgoing_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingCallAction:(e,n)=>{this._hookHandlers.after_outgoing_call_action[e]=w.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingCallAction:(e,n)=>{this._hookHandlers.after_incoming_call_action[e]=w.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:n,order:this._registerOrder++})},workflowStart:(e,n)=>{this._workflowHandlers.started[e]=w.safePush(this._workflowHandlers.started[e],{handler:n,order:this._registerOrder++})},workflowContinue:(e,n)=>{this._workflowHandlers.continued[e]=w.safePush(this._workflowHandlers.continued[e],{handler:n,order:this._registerOrder++})},workflowTimeout:(e,n)=>{this._workflowHandlers.timed_out[e]=w.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 hi={};Ne(hi,{allWithinMajorOf:()=>cv,allWithinMinorOf:()=>dv});var Gt=Gn(require("semver"));function cv(t){let e=Gt.major(t.version);return{...t,version:`>=${e}.0.0 <${e+1}.0.0`}}function dv(t){let e=Gt.major(t.version),n=Gt.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,OAUTH_IDENTIFIER_HEADER,Plugin,PluginDefinition,RuntimeError,WELL_KNOWN_ATTRIBUTES,errors,isApiError,messages,parseBody,serve,version,z});
|
|
75
|
+
Available integration aliases: ${h}`)}return[g,{..._,...m}]})),o=n.configuration??{},u=e.definition.configuration?.schema,d=u?u.safeParse(o):null,p=d?.success?{...o,...d.data}:o;return r.plugins[i]={...e,alias:i,configuration:p,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)=>D.mapKeys(e??{},r=>`${n}${me}${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 re(`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 m=u.definition.entities?.[g]?.schema;if(!m)throw new Error(`Interface entity "${g}" does not exist in integration "${u.name}"`);e[`interface:${a}/entities/${p}`]=m}}}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 rt=require("@botpress/client");var yt=class t extends gt{constructor(e){super({...e})}with(e){return new t({...this.defaultOptions,...e})}withUserId(e){return this.with({userId:e})}withConversationId(e){return this.with({conversationId:e})}withWorkflowId(e){return this.with({workflowId:e})}withEventId(e){return this.with({eventId:e})}withMessageId(e){return this.with({messageId:e})}};var Te=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 tv=v.enum(["event_received","register","unregister","ping","action_triggered"]),_c=t=>({botId:t[jn]||le("Missing bot id header"),operation:tv.parse(t[zn]),type:t[mc]||le("Missing type header"),configuration:JSON.parse(Buffer.from(t[$n]||le("Missing configuration header"),"base64").toString("utf-8"))});var J={status:200};var pi=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 nv=["child_workflow_deleted","child_workflow_finished","workflow_timedout","workflow_started","workflow_continued"],Tc=async(t,e)=>{if(t.ctx.type!=="workflow_update"||!nv.includes(e.payload.type))throw new Error("Unexpected event type");let n={...t,logger:rv(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),J;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 iv(n,e);default:e.payload.type}return J},rv=(t,e)=>t.logger.with({eventId:e.id,workflowId:e.payload.workflow.id,conversationId:e.payload.conversation?.id,userId:e.payload.user?.id}),iv=async(t,e)=>{let n=pi(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}"`),J;let{updatedWorkflow:i}=await sv(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. `),J},sv=async(t,e)=>{let n=pi(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 bc=t=>async e=>{let n=_c(e.headers),r=new yt,i=new rt.Client({botId:n.botId,retry:Hn}),s=new Te(i,{before:{createMessage:async o=>{let u=t.hookHandlers.before_outgoing_message[o.type]??[];for(let d of u){let p=new Te(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 Te(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 Te(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 m=new Te(i);o=(await g({client:m,ctx:n,logger:r,data:{type:d,...o}}))?.data??o}return o}}}),a={req:e,ctx:n,logger:r,client:s,self:t};try{switch(n.operation){case"action_triggered":return await cv(a);case"event_received":return await uv(a);case"register":return await ov(a);case"unregister":return await lv(a);case"ping":return await av(a);default:throw new Error(`Unknown operation ${n.operation}`)}}catch(o){let u=o instanceof Error?o:new Error(String(o));if((0,rt.isApiError)(u)){let p=u.type==="Runtime"?u:new rt.RuntimeError(u.message,u);return r.error(p.message),{status:p.code,body:JSON.stringify(p.toJSON())}}let d=new rt.RuntimeError("An unexpected error occurred in the bot.",u);return r.error(d.message,u),{status:d.code,body:JSON.stringify(d.toJSON())}}},av=async t=>J,ov=async t=>(await t.self.registerHandler?.({client:t.client,ctx:t.ctx,logger:t.logger}),J),lv=async t=>J,uv=async t=>{let{ctx:e,logger:n,req:r,client:i,self:s}=t,a={client:i,ctx:e,logger:n},o=oe(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 Tc(t,o.event);if(e.type==="message_created"){let _=o.event,h=_.payload.message,A=_.payload.user,z=_.payload.conversation;a.logger=a.logger.with({messageId:h.id,conversationId:h.conversationId,userId:h.userId});let Q=s.hookHandlers.before_incoming_message[h.type]??[];for(let ie of Q){let st=await ie({...a,user:A,conversation:z,data:h});if(h=st?.data??h,st?.stop)return J}let ee={...a,user:A,conversation:z,message:h,event:_},U=s.messageHandlers[h.type]??[];for(let ie of U)await ie(ee);let K=s.hookHandlers.after_incoming_message[h.type]??[];for(let ie of K){let st=await ie({...a,user:A,conversation:z,data:h});if(h=st?.data??h,st?.stop)return J}return J}if(e.type==="state_expired"){let h=o.event.payload.state,A={...a,state:h},z=s.stateExpiredHandlers[h.name]??[];for(let Q of z)await Q(A);return J}let u=o.event,d=s.hookHandlers.before_incoming_event[u.type]??[];for(let _ of d){let h=await _({...a,data:u});if(u=h?.data??u,h?.stop)return J}let p={...a,event:u},g=s.eventHandlers[u.type]??[];for(let _ of g)await _(p);let m=s.hookHandlers.after_incoming_event[u.type]??[];for(let _ of m){let h=await _({...a,data:u});if(u=h?.data??u,h?.stop)return J}return J},cv=async({ctx:t,logger:e,req:n,client:r,self:i})=>{let{input:s,type:a}=oe(n);if(!a)throw new Error("Missing action type");let o=i.hookHandlers.before_incoming_call_action[a]??[];for(let m of o){let _=await m({ctx:t,logger:e,client:r,data:{type:a,input:s}});s=_?.data?.input??s,a=_?.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 m of p){let _=await m({ctx:t,logger:e,client:r,data:{type:a,output:d}});a=_?.data?.type??a,d=_?.data?.output??d}return{status:200,body:JSON.stringify({output:d})}};var be=(t,{alias:e})=>{if(!("tags"in t)||!e)return t;let n=`${e}${me}`,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}${me}`,r=Object.fromEntries(Object.entries(t.tags??{}).map(([i,s])=>[i.startsWith(n)?i:`${n}${i}`,s]));return{...t,tags:r}};var fi=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}},ue=t=>new fi(t);var Be=t=>new Proxy({},{get:(e,n)=>({listInstances:r=>ue(({nextToken:i})=>t.client.listWorkflows({...r,name:n,nextToken:i}).then(({meta:s,workflows:a})=>({meta:s,items:a.map(o=>ce({...t,workflow:o}))}))),startNewInstance:async r=>{let{workflow:i}=await t.client.createWorkflow({name:n,status:"pending",...X(r,{alias:void 0})});return{workflow:ce({...t,workflow:i})}}})}),ce=t=>{let e=!1;return{...be(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:ce({...t,workflow:r})}},async acknowledgeStartOfProcessing(){if(!t.event||t.workflow.status!=="pending"||e)return{workflow:ce(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:ce({...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:ce({...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:ce({...t,workflow:r})}},async cancel(){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,status:"cancelled"});return await t.onWorkflowUpdate?.(n),{workflow:ce({...t,workflow:n})}}}};var Fn=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 G.setName(i=>r({...i,workflows:Be(i)}),r.name);for(let[i,s]of Object.entries(this._plugins)){let[a,o]=n.split(me);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})=>G.setName(u=>o({...u,workflows:Be(u)}),o.name));return w.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})=>G.setName(u=>o({...u,workflows:Be(u)}),o.name));return w.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})=>G.setName(u=>o({...u,workflows:Be(u)}),o.name));return w.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,m)=>g.order-m.order).map(({handler:g})=>G.setName(m=>g({...m,workflows:Be(m)}),g.name));return w.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})=>G.setName(async d=>{let p=d.workflow;return await u({...d,workflow:ce({...d,onWorkflowUpdate(g){p=g}}),workflows:Be(d)}),p},u.name))??[],o=Object.values(this._plugins).flatMap(u=>u.workflowHandlers[n]?.[s]??[]);return w.unique([...a,...o])}})}})}on={message:(e,n)=>{this._messageHandlers[e]=w.safePush(this._messageHandlers[e],{handler:n,order:this._registerOrder++})},event:(e,n)=>{this._eventHandlers[e]=w.safePush(this._eventHandlers[e],{handler:n,order:this._registerOrder++})},stateExpired:(e,n)=>{this._stateExpiredHandlers[e]=w.safePush(this._stateExpiredHandlers[e],{handler:n,order:this._registerOrder++})},beforeIncomingEvent:(e,n)=>{this._hookHandlers.before_incoming_event[e]=w.safePush(this._hookHandlers.before_incoming_event[e],{handler:n,order:this._registerOrder++})},beforeIncomingMessage:(e,n)=>{this._hookHandlers.before_incoming_message[e]=w.safePush(this._hookHandlers.before_incoming_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingMessage:(e,n)=>{this._hookHandlers.before_outgoing_message[e]=w.safePush(this._hookHandlers.before_outgoing_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingCallAction:(e,n)=>{this._hookHandlers.before_outgoing_call_action[e]=w.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},beforeIncomingCallAction:(e,n)=>{this._hookHandlers.before_incoming_call_action[e]=w.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingEvent:(e,n)=>{this._hookHandlers.after_incoming_event[e]=w.safePush(this._hookHandlers.after_incoming_event[e],{handler:n,order:this._registerOrder++})},afterIncomingMessage:(e,n)=>{this._hookHandlers.after_incoming_message[e]=w.safePush(this._hookHandlers.after_incoming_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingMessage:(e,n)=>{this._hookHandlers.after_outgoing_message[e]=w.safePush(this._hookHandlers.after_outgoing_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingCallAction:(e,n)=>{this._hookHandlers.after_outgoing_call_action[e]=w.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingCallAction:(e,n)=>{this._hookHandlers.after_incoming_call_action[e]=w.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:n,order:this._registerOrder++})},workflowStart:(e,n)=>{this._workflowHandlers.started[e]=w.safePush(this._workflowHandlers.started[e],{handler:n,order:this._registerOrder++})},workflowContinue:(e,n)=>{this._workflowHandlers.continued[e]=w.safePush(this._workflowHandlers.continued[e],{handler:n,order:this._registerOrder++})},workflowTimeout:(e,n)=>{this._workflowHandlers.timed_out[e]=w.safePush(this._workflowHandlers.timed_out[e],{handler:n,order:this._registerOrder++})}};handler=bc(this);start=e=>Vt(this.handler,e)};var qn=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?{}:D.mapValues(e.events,a=>({...a,schema:a.schema(n)})),i=e.actions===void 0?{}:D.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?{}:D.mapValues(e.channels,a=>({...a,messages:D.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:Ze}}_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=v.ref(r);s&&o.title(s),a&&o.describe(a),n[r]=o}return n}};var Vn=class{constructor(e){this.props=e;let n=Object.fromEntries(Object.entries(e.interfaces??{}).map(([s,a])=>[s,Object.fromEntries(Object.entries(a.definition.entities??{}).map(([o])=>[o,v.ref(`interface:${s}/entities/${o}`)]))]));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.workflows=e.workflows,this.attributes=e.attributes,this.__advanced=e.__advanced;let r=new Set;for(let s of[...Object.keys(e.integrations??{}),...Object.keys(e.interfaces??{})]){if(r.has(s))throw new re(`Duplicate interface or integration alias detected in plugin definition: '${s}'. Please use unique aliases for each interface and integration.`);r.add(s)}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(([s,a])=>[s,{...a,schema:typeof a.schema=="object"?a.schema:a.schema({entities:n})}]));let i=Object.fromEntries(Object.entries(e.events??{}).map(([s,a])=>[s,{...a,schema:typeof a.schema=="object"?a.schema:a.schema({entities:n})}]));this.events=Kn(i),this.recurringEvents=Wn(i,e.recurringEvents),this.actions=Object.fromEntries(Object.entries(e.actions??{}).map(([s,a])=>[s,{...a,input:{...a.input,schema:typeof a.input.schema=="object"?a.input.schema:a.input.schema({entities:n})},output:{...a.output,schema:typeof a.output.schema=="object"?a.output.schema:a.output.schema({entities:n})}}])),this.tables=Object.fromEntries(Object.entries(e.tables??{}).map(([s,a])=>[s,{...a,schema:typeof a.schema=="object"?a.schema:a.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:Ze}}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(v.record(v.string(),v.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 wc=(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 gi=t=>({async getById({id:e}){let n=await t.client.getMessage({id:e});return ye({...t,message:n.message})},list(e){return ue(({nextToken:n})=>t.client.listMessages({...X(e??{},{alias:t.plugin?.alias}),nextToken:n}).then(({meta:r,messages:i})=>({meta:r,items:i.map(s=>ye({...t,message:s}))})))}}),ye=t=>({...be(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 ye({...t,message:n})}});var mi=t=>({list(e){return ue(({nextToken:n})=>t.client.listUsers({...X(e??{},{alias:t.pluginAlias}),nextToken:n}).then(({meta:r,users:i})=>({meta:r,items:i.map(s=>he({...t,conversationId:e?.conversationId,user:s}))})))},async getById({id:e}){let n=await t.client.getUser({id:e});return he({...t,user:n.user,conversationId:void 0})}}),he=t=>{let e={...be(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 he({...t,user:r})}};return t.conversationId?{...e,async removeFromConversation(){return await t.client.removeParticipant({id:t.conversationId,userId:t.user.id}),he({...t,conversationId:void 0})}}:{...e,async addToConversation({conversationId:n}){let{participant:r}=await t.client.addParticipant({id:n,userId:t.user.id});return he({...t,user:r,conversationId:n})}}};var yi=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 ue(({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=>it({...t,conversation:g}))})))},async getById({id:s}){let a=await t.client.getConversation({id:s});return it({...t,conversation:a.conversation})}})})}),it=t=>{let e=t.client;return{...be(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 it({...t,conversation:r})},async getMessage({id:n}){let r=await e.getMessage({id:n});return ye({...t,message:r.message})},async getOrCreateMessage(n){let{message:r}=await e.getOrCreateMessage({...X(n,{alias:t.plugin?.alias}),conversationId:t.conversation.id});return ye({...t,message:r})},async createMessage(n){let{message:r}=await e.createMessage({...X(n,{alias:t.plugin?.alias}),conversationId:t.conversation.id});return ye({...t,message:r})},listMessages(n){return ue(({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=>ye({...t,message:a}))})))},listParticipants(){return ue(({nextToken:n})=>e.listParticipants({id:t.conversation.id,nextToken:n}).then(({meta:r,participants:i})=>({meta:r,items:i.map(s=>he({...t,user:s,conversationId:t.conversation.id}))})))}}};var hi=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 ue(({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})))}},xc=(t,e)=>new Proxy({},{get:(n,r)=>{let i=e.alias!==void 0?`${e.alias}${me}${r}`:r;return new hi({client:t,eventName:i})}});var vi=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})}},Pc=(t,e)=>new Proxy({},{get:(n,r)=>new Proxy({},{get:(i,s)=>{let a=e.alias!==void 0?`${e.alias}${me}${s}`:s;return new vi(t,r,a)}})});var dv=t=>"user"in t&&"conversation"in t,Gn=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=wc(e,this._runtime),o=Pc(e,this._runtime),u=Be({client:e,pluginAlias:this._runtime.alias}),d=xc(e,this._runtime),p=mi({client:e,pluginAlias:this._runtime.alias}),g=yi({client:e,plugin:this._runtime}),m=gi({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:m}}get actionHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=this._actionHandlers[n];if(r)return G.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 w.unique([...r,...i]).sort((a,o)=>a.order-o.order).map(({handler:a})=>G.setName(o=>a({...o,user:he({...o,conversationId:o.conversation.id,pluginAlias:this._runtime.alias}),message:ye({...o,plugin:this._runtime,message:o.message}),conversation:it({...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 w.unique([...r,...i,...s]).sort((o,u)=>o.order-u.order).map(({handler:o})=>G.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 w.unique([...r,...i]).sort((a,o)=>a.order-o.order).map(({handler:a})=>G.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 w.unique([...a,...o,...u]).sort((p,g)=>p.order-g.order).map(({handler:p})=>G.setName(g=>{let m=be(g.data,{alias:this._runtime.alias}),_=this._getTools(g.client),h={};if(dv(g)){let A=he({client:g.client,user:g.user,conversationId:g.conversation.id,pluginAlias:this._runtime.alias}),z=it({client:g.client,plugin:this._runtime,conversation:g.conversation});h={user:A,conversation:z}}return p({...g,data:m,...h,..._})},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})=>G.setName(async u=>{let d=u.workflow;return await o({...u,workflow:ce({...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]=w.safePush(this._messageHandlers[e],{handler:n,order:this._registerOrder++})},event:(e,n)=>{this._eventHandlers[e]=w.safePush(this._eventHandlers[e],{handler:n,order:this._registerOrder++})},stateExpired:(e,n)=>{this._stateExpiredHandlers[e]=w.safePush(this._stateExpiredHandlers[e],{handler:n,order:this._registerOrder++})},beforeIncomingEvent:(e,n)=>{this._hookHandlers.before_incoming_event[e]=w.safePush(this._hookHandlers.before_incoming_event[e],{handler:n,order:this._registerOrder++})},beforeIncomingMessage:(e,n)=>{this._hookHandlers.before_incoming_message[e]=w.safePush(this._hookHandlers.before_incoming_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingMessage:(e,n)=>{this._hookHandlers.before_outgoing_message[e]=w.safePush(this._hookHandlers.before_outgoing_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingCallAction:(e,n)=>{this._hookHandlers.before_outgoing_call_action[e]=w.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},beforeIncomingCallAction:(e,n)=>{this._hookHandlers.before_incoming_call_action[e]=w.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingEvent:(e,n)=>{this._hookHandlers.after_incoming_event[e]=w.safePush(this._hookHandlers.after_incoming_event[e],{handler:n,order:this._registerOrder++})},afterIncomingMessage:(e,n)=>{this._hookHandlers.after_incoming_message[e]=w.safePush(this._hookHandlers.after_incoming_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingMessage:(e,n)=>{this._hookHandlers.after_outgoing_message[e]=w.safePush(this._hookHandlers.after_outgoing_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingCallAction:(e,n)=>{this._hookHandlers.after_outgoing_call_action[e]=w.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingCallAction:(e,n)=>{this._hookHandlers.after_incoming_call_action[e]=w.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:n,order:this._registerOrder++})},workflowStart:(e,n)=>{this._workflowHandlers.started[e]=w.safePush(this._workflowHandlers.started[e],{handler:n,order:this._registerOrder++})},workflowContinue:(e,n)=>{this._workflowHandlers.continued[e]=w.safePush(this._workflowHandlers.continued[e],{handler:n,order:this._registerOrder++})},workflowTimeout:(e,n)=>{this._workflowHandlers.timed_out[e]=w.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 _i={};De(_i,{allWithinMajorOf:()=>pv,allWithinMinorOf:()=>fv});var Gt=Yn(require("semver"));function pv(t){let e=Gt.major(t.version);return{...t,version:`>=${e}.0.0 <${e+1}.0.0`}}function fv(t){let e=Gt.major(t.version),n=Gt.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,OAUTH_IDENTIFIER_HEADER,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:
|