react-components-form
Version:
A simple ui library for React
3 lines (2 loc) • 41.6 kB
JavaScript
(function(p,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("react/jsx-runtime"),require("react"),require("prop-types")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","prop-types"],f):(p=typeof globalThis<"u"?globalThis:p||self,f(p["react-components-form"]={},p.jsxRuntime,p.React,p.PropTypes))})(this,function(p,f,S,l){"use strict";var Gu=Object.defineProperty;var Uu=(p,f,S)=>f in p?Gu(p,f,{enumerable:!0,configurable:!0,writable:!0,value:S}):p[f]=S;var ht=(p,f,S)=>Uu(p,typeof f!="symbol"?f+"":f,S);var q=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function B(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Xe(){this.__data__=[],this.size=0}var Je=Xe;function Ze(t,e){return t===e||t!==t&&e!==e}var ct=Ze,Qe=ct;function ke(t,e){for(var r=t.length;r--;)if(Qe(t[r][0],e))return r;return-1}var W=ke,tr=W,er=Array.prototype,rr=er.splice;function ar(t){var e=this.__data__,r=tr(e,t);if(r<0)return!1;var a=e.length-1;return r==a?e.pop():rr.call(e,r,1),--this.size,!0}var ir=ar,sr=W;function nr(t){var e=this.__data__,r=sr(e,t);return r<0?void 0:e[r][1]}var or=nr,lr=W;function hr(t){return lr(this.__data__,t)>-1}var cr=hr,dr=W;function ur(t,e){var r=this.__data__,a=dr(r,t);return a<0?(++this.size,r.push([t,e])):r[a][1]=e,this}var fr=ur,gr=Je,vr=ir,mr=or,pr=cr,br=fr;function V(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var a=t[e];this.set(a[0],a[1])}}V.prototype.clear=gr,V.prototype.delete=vr,V.prototype.get=mr,V.prototype.has=pr,V.prototype.set=br;var z=V,$r=z;function yr(){this.__data__=new $r,this.size=0}var _r=yr;function Ar(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var Sr=Ar;function Er(t){return this.__data__.get(t)}var Cr=Er;function Or(t){return this.__data__.has(t)}var Mr=Or,Tr=typeof q=="object"&&q&&q.Object===Object&&q,It=Tr,Fr=It,jr=typeof self=="object"&&self&&self.Object===Object&&self,wr=Fr||jr||Function("return this")(),E=wr,Vr=E,xr=Vr.Symbol,G=xr,Pt=G,Lt=Object.prototype,Ir=Lt.hasOwnProperty,Pr=Lt.toString,U=Pt?Pt.toStringTag:void 0;function Lr(t){var e=Ir.call(t,U),r=t[U];try{t[U]=void 0;var a=!0}catch{}var i=Pr.call(t);return a&&(e?t[U]=r:delete t[U]),i}var Dr=Lr,Nr=Object.prototype,Br=Nr.toString;function Gr(t){return Br.call(t)}var Ur=Gr,Dt=G,Kr=Dr,Rr=Ur,Hr="[object Null]",qr="[object Undefined]",Nt=Dt?Dt.toStringTag:void 0;function Wr(t){return t==null?t===void 0?qr:Hr:Nt&&Nt in Object(t)?Kr(t):Rr(t)}var K=Wr;function zr(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var x=zr;const Yr=B(x);var Xr=K,Jr=x,Zr="[object AsyncFunction]",Qr="[object Function]",kr="[object GeneratorFunction]",ta="[object Proxy]";function ea(t){if(!Jr(t))return!1;var e=Xr(t);return e==Qr||e==kr||e==Zr||e==ta}var Bt=ea,ra=E,aa=ra["__core-js_shared__"],ia=aa,dt=ia,Gt=function(){var t=/[^.]+$/.exec(dt&&dt.keys&&dt.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function sa(t){return!!Gt&&Gt in t}var na=sa,oa=Function.prototype,la=oa.toString;function ha(t){if(t!=null){try{return la.call(t)}catch{}try{return t+""}catch{}}return""}var Ut=ha,ca=Bt,da=na,ua=x,fa=Ut,ga=/[\\^$.*+?()[\]{}|]/g,va=/^\[object .+?Constructor\]$/,ma=Function.prototype,pa=Object.prototype,ba=ma.toString,$a=pa.hasOwnProperty,ya=RegExp("^"+ba.call($a).replace(ga,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function _a(t){if(!ua(t)||da(t))return!1;var e=ca(t)?ya:va;return e.test(fa(t))}var Aa=_a;function Sa(t,e){return t==null?void 0:t[e]}var Ea=Sa,Ca=Aa,Oa=Ea;function Ma(t,e){var r=Oa(t,e);return Ca(r)?r:void 0}var T=Ma,Ta=T,Fa=E,ja=Ta(Fa,"Map"),ut=ja,wa=T,Va=wa(Object,"create"),Y=Va,Kt=Y;function xa(){this.__data__=Kt?Kt(null):{},this.size=0}var Ia=xa;function Pa(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var La=Pa,Da=Y,Na="__lodash_hash_undefined__",Ba=Object.prototype,Ga=Ba.hasOwnProperty;function Ua(t){var e=this.__data__;if(Da){var r=e[t];return r===Na?void 0:r}return Ga.call(e,t)?e[t]:void 0}var Ka=Ua,Ra=Y,Ha=Object.prototype,qa=Ha.hasOwnProperty;function Wa(t){var e=this.__data__;return Ra?e[t]!==void 0:qa.call(e,t)}var za=Wa,Ya=Y,Xa="__lodash_hash_undefined__";function Ja(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Ya&&e===void 0?Xa:e,this}var Za=Ja,Qa=Ia,ka=La,ti=Ka,ei=za,ri=Za;function I(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var a=t[e];this.set(a[0],a[1])}}I.prototype.clear=Qa,I.prototype.delete=ka,I.prototype.get=ti,I.prototype.has=ei,I.prototype.set=ri;var ai=I,Rt=ai,ii=z,si=ut;function ni(){this.size=0,this.__data__={hash:new Rt,map:new(si||ii),string:new Rt}}var oi=ni;function li(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var hi=li,ci=hi;function di(t,e){var r=t.__data__;return ci(e)?r[typeof e=="string"?"string":"hash"]:r.map}var X=di,ui=X;function fi(t){var e=ui(this,t).delete(t);return this.size-=e?1:0,e}var gi=fi,vi=X;function mi(t){return vi(this,t).get(t)}var pi=mi,bi=X;function $i(t){return bi(this,t).has(t)}var yi=$i,_i=X;function Ai(t,e){var r=_i(this,t),a=r.size;return r.set(t,e),this.size+=r.size==a?0:1,this}var Si=Ai,Ei=oi,Ci=gi,Oi=pi,Mi=yi,Ti=Si;function P(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var a=t[e];this.set(a[0],a[1])}}P.prototype.clear=Ei,P.prototype.delete=Ci,P.prototype.get=Oi,P.prototype.has=Mi,P.prototype.set=Ti;var ft=P,Fi=z,ji=ut,wi=ft,Vi=200;function xi(t,e){var r=this.__data__;if(r instanceof Fi){var a=r.__data__;if(!ji||a.length<Vi-1)return a.push([t,e]),this.size=++r.size,this;r=this.__data__=new wi(a)}return r.set(t,e),this.size=r.size,this}var Ii=xi,Pi=z,Li=_r,Di=Sr,Ni=Cr,Bi=Mr,Gi=Ii;function L(t){var e=this.__data__=new Pi(t);this.size=e.size}L.prototype.clear=Li,L.prototype.delete=Di,L.prototype.get=Ni,L.prototype.has=Bi,L.prototype.set=Gi;var Ht=L;function Ui(t,e){for(var r=-1,a=t==null?0:t.length;++r<a&&e(t[r],r,t)!==!1;);return t}var Ki=Ui,Ri=T,Hi=function(){try{var t=Ri(Object,"defineProperty");return t({},"",{}),t}catch{}}(),qi=Hi,qt=qi;function Wi(t,e,r){e=="__proto__"&&qt?qt(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var Wt=Wi,zi=Wt,Yi=ct,Xi=Object.prototype,Ji=Xi.hasOwnProperty;function Zi(t,e,r){var a=t[e];(!(Ji.call(t,e)&&Yi(a,r))||r===void 0&&!(e in t))&&zi(t,e,r)}var zt=Zi,Qi=zt,ki=Wt;function ts(t,e,r,a){var i=!r;r||(r={});for(var s=-1,n=e.length;++s<n;){var o=e[s],c=a?a(r[o],t[o],o,r,t):void 0;c===void 0&&(c=t[o]),i?ki(r,o,c):Qi(r,o,c)}return r}var J=ts;function es(t,e){for(var r=-1,a=Array(t);++r<t;)a[r]=e(r);return a}var rs=es;function as(t){return t!=null&&typeof t=="object"}var F=as,is=K,ss=F,ns="[object Arguments]";function os(t){return ss(t)&&is(t)==ns}var ls=os,Yt=ls,hs=F,Xt=Object.prototype,cs=Xt.hasOwnProperty,ds=Xt.propertyIsEnumerable,us=Yt(function(){return arguments}())?Yt:function(t){return hs(t)&&cs.call(t,"callee")&&!ds.call(t,"callee")},Jt=us,fs=Array.isArray,C=fs,Z={exports:{}};function gs(){return!1}var vs=gs;Z.exports,function(t,e){var r=E,a=vs,i=e&&!e.nodeType&&e,s=i&&!0&&t&&!t.nodeType&&t,n=s&&s.exports===i,o=n?r.Buffer:void 0,c=o?o.isBuffer:void 0,h=c||a;t.exports=h}(Z,Z.exports);var Q=Z.exports,ms=9007199254740991,ps=/^(?:0|[1-9]\d*)$/;function bs(t,e){var r=typeof t;return e=e??ms,!!e&&(r=="number"||r!="symbol"&&ps.test(t))&&t>-1&&t%1==0&&t<e}var $s=bs,ys=9007199254740991;function _s(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=ys}var Zt=_s,As=K,Ss=Zt,Es=F,Cs="[object Arguments]",Os="[object Array]",Ms="[object Boolean]",Ts="[object Date]",Fs="[object Error]",js="[object Function]",ws="[object Map]",Vs="[object Number]",xs="[object Object]",Is="[object RegExp]",Ps="[object Set]",Ls="[object String]",Ds="[object WeakMap]",Ns="[object ArrayBuffer]",Bs="[object DataView]",Gs="[object Float32Array]",Us="[object Float64Array]",Ks="[object Int8Array]",Rs="[object Int16Array]",Hs="[object Int32Array]",qs="[object Uint8Array]",Ws="[object Uint8ClampedArray]",zs="[object Uint16Array]",Ys="[object Uint32Array]",m={};m[Gs]=m[Us]=m[Ks]=m[Rs]=m[Hs]=m[qs]=m[Ws]=m[zs]=m[Ys]=!0,m[Cs]=m[Os]=m[Ns]=m[Ms]=m[Bs]=m[Ts]=m[Fs]=m[js]=m[ws]=m[Vs]=m[xs]=m[Is]=m[Ps]=m[Ls]=m[Ds]=!1;function Xs(t){return Es(t)&&Ss(t.length)&&!!m[As(t)]}var Js=Xs;function Zs(t){return function(e){return t(e)}}var gt=Zs,k={exports:{}};k.exports,function(t,e){var r=It,a=e&&!e.nodeType&&e,i=a&&!0&&t&&!t.nodeType&&t,s=i&&i.exports===a,n=s&&r.process,o=function(){try{var c=i&&i.require&&i.require("util").types;return c||n&&n.binding&&n.binding("util")}catch{}}();t.exports=o}(k,k.exports);var vt=k.exports,Qs=Js,ks=gt,Qt=vt,kt=Qt&&Qt.isTypedArray,tn=kt?ks(kt):Qs,mt=tn,en=rs,rn=Jt,an=C,sn=Q,nn=$s,on=mt,ln=Object.prototype,hn=ln.hasOwnProperty;function cn(t,e){var r=an(t),a=!r&&rn(t),i=!r&&!a&&sn(t),s=!r&&!a&&!i&&on(t),n=r||a||i||s,o=n?en(t.length,String):[],c=o.length;for(var h in t)(e||hn.call(t,h))&&!(n&&(h=="length"||i&&(h=="offset"||h=="parent")||s&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||nn(h,c)))&&o.push(h);return o}var te=cn,dn=Object.prototype;function un(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||dn;return t===r}var tt=un;function fn(t,e){return function(r){return t(e(r))}}var ee=fn,gn=ee,vn=gn(Object.keys,Object),mn=vn,pn=tt,bn=mn,$n=Object.prototype,yn=$n.hasOwnProperty;function _n(t){if(!pn(t))return bn(t);var e=[];for(var r in Object(t))yn.call(t,r)&&r!="constructor"&&e.push(r);return e}var re=_n,An=Bt,Sn=Zt;function En(t){return t!=null&&Sn(t.length)&&!An(t)}var pt=En,Cn=te,On=re,Mn=pt;function Tn(t){return Mn(t)?Cn(t):On(t)}var bt=Tn,Fn=J,jn=bt;function wn(t,e){return t&&Fn(e,jn(e),t)}var Vn=wn;function xn(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var In=xn,Pn=x,Ln=tt,Dn=In,Nn=Object.prototype,Bn=Nn.hasOwnProperty;function Gn(t){if(!Pn(t))return Dn(t);var e=Ln(t),r=[];for(var a in t)a=="constructor"&&(e||!Bn.call(t,a))||r.push(a);return r}var Un=Gn,Kn=te,Rn=Un,Hn=pt;function qn(t){return Hn(t)?Kn(t,!0):Rn(t)}var $t=qn,Wn=J,zn=$t;function Yn(t,e){return t&&Wn(e,zn(e),t)}var Xn=Yn,et={exports:{}};et.exports,function(t,e){var r=E,a=e&&!e.nodeType&&e,i=a&&!0&&t&&!t.nodeType&&t,s=i&&i.exports===a,n=s?r.Buffer:void 0,o=n?n.allocUnsafe:void 0;function c(h,u){if(u)return h.slice();var d=h.length,g=o?o(d):new h.constructor(d);return h.copy(g),g}t.exports=c}(et,et.exports);var Jn=et.exports;function Zn(t,e){var r=-1,a=t.length;for(e||(e=Array(a));++r<a;)e[r]=t[r];return e}var Qn=Zn;function kn(t,e){for(var r=-1,a=t==null?0:t.length,i=0,s=[];++r<a;){var n=t[r];e(n,r,t)&&(s[i++]=n)}return s}var to=kn;function eo(){return[]}var ae=eo,ro=to,ao=ae,io=Object.prototype,so=io.propertyIsEnumerable,ie=Object.getOwnPropertySymbols,no=ie?function(t){return t==null?[]:(t=Object(t),ro(ie(t),function(e){return so.call(t,e)}))}:ao,yt=no,oo=J,lo=yt;function ho(t,e){return oo(t,lo(t),e)}var co=ho;function uo(t,e){for(var r=-1,a=e.length,i=t.length;++r<a;)t[i+r]=e[r];return t}var se=uo,fo=ee,go=fo(Object.getPrototypeOf,Object),ne=go,vo=se,mo=ne,po=yt,bo=ae,$o=Object.getOwnPropertySymbols,yo=$o?function(t){for(var e=[];t;)vo(e,po(t)),t=mo(t);return e}:bo,oe=yo,_o=J,Ao=oe;function So(t,e){return _o(t,Ao(t),e)}var Eo=So,Co=se,Oo=C;function Mo(t,e,r){var a=e(t);return Oo(t)?a:Co(a,r(t))}var le=Mo,To=le,Fo=yt,jo=bt;function wo(t){return To(t,jo,Fo)}var he=wo,Vo=le,xo=oe,Io=$t;function Po(t){return Vo(t,Io,xo)}var Lo=Po,Do=T,No=E,Bo=Do(No,"DataView"),Go=Bo,Uo=T,Ko=E,Ro=Uo(Ko,"Promise"),Ho=Ro,qo=T,Wo=E,zo=qo(Wo,"Set"),Yo=zo,Xo=T,Jo=E,Zo=Xo(Jo,"WeakMap"),Qo=Zo,_t=Go,At=ut,St=Ho,Et=Yo,Ct=Qo,ce=K,D=Ut,de="[object Map]",ko="[object Object]",ue="[object Promise]",fe="[object Set]",ge="[object WeakMap]",ve="[object DataView]",tl=D(_t),el=D(At),rl=D(St),al=D(Et),il=D(Ct),j=ce;(_t&&j(new _t(new ArrayBuffer(1)))!=ve||At&&j(new At)!=de||St&&j(St.resolve())!=ue||Et&&j(new Et)!=fe||Ct&&j(new Ct)!=ge)&&(j=function(t){var e=ce(t),r=e==ko?t.constructor:void 0,a=r?D(r):"";if(a)switch(a){case tl:return ve;case el:return de;case rl:return ue;case al:return fe;case il:return ge}return e});var R=j,sl=Object.prototype,nl=sl.hasOwnProperty;function ol(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&nl.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var ll=ol,hl=E,cl=hl.Uint8Array,me=cl,pe=me;function dl(t){var e=new t.constructor(t.byteLength);return new pe(e).set(new pe(t)),e}var Ot=dl,ul=Ot;function fl(t,e){var r=e?ul(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var gl=fl,vl=/\w*$/;function ml(t){var e=new t.constructor(t.source,vl.exec(t));return e.lastIndex=t.lastIndex,e}var pl=ml,be=G,$e=be?be.prototype:void 0,ye=$e?$e.valueOf:void 0;function bl(t){return ye?Object(ye.call(t)):{}}var $l=bl,yl=Ot;function _l(t,e){var r=e?yl(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Al=_l,Sl=Ot,El=gl,Cl=pl,Ol=$l,Ml=Al,Tl="[object Boolean]",Fl="[object Date]",jl="[object Map]",wl="[object Number]",Vl="[object RegExp]",xl="[object Set]",Il="[object String]",Pl="[object Symbol]",Ll="[object ArrayBuffer]",Dl="[object DataView]",Nl="[object Float32Array]",Bl="[object Float64Array]",Gl="[object Int8Array]",Ul="[object Int16Array]",Kl="[object Int32Array]",Rl="[object Uint8Array]",Hl="[object Uint8ClampedArray]",ql="[object Uint16Array]",Wl="[object Uint32Array]";function zl(t,e,r){var a=t.constructor;switch(e){case Ll:return Sl(t);case Tl:case Fl:return new a(+t);case Dl:return El(t,r);case Nl:case Bl:case Gl:case Ul:case Kl:case Rl:case Hl:case ql:case Wl:return Ml(t,r);case jl:return new a;case wl:case Il:return new a(t);case Vl:return Cl(t);case xl:return new a;case Pl:return Ol(t)}}var Yl=zl,Xl=x,_e=Object.create,Jl=function(){function t(){}return function(e){if(!Xl(e))return{};if(_e)return _e(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),Zl=Jl,Ql=Zl,kl=ne,th=tt;function eh(t){return typeof t.constructor=="function"&&!th(t)?Ql(kl(t)):{}}var rh=eh,ah=R,ih=F,sh="[object Map]";function nh(t){return ih(t)&&ah(t)==sh}var oh=nh,lh=oh,hh=gt,Ae=vt,Se=Ae&&Ae.isMap,ch=Se?hh(Se):lh,dh=ch,uh=R,fh=F,gh="[object Set]";function vh(t){return fh(t)&&uh(t)==gh}var mh=vh,ph=mh,bh=gt,Ee=vt,Ce=Ee&&Ee.isSet,$h=Ce?bh(Ce):ph,yh=$h,_h=Ht,Ah=Ki,Sh=zt,Eh=Vn,Ch=Xn,Oh=Jn,Mh=Qn,Th=co,Fh=Eo,jh=he,wh=Lo,Vh=R,xh=ll,Ih=Yl,Ph=rh,Lh=C,Dh=Q,Nh=dh,Bh=x,Gh=yh,Uh=bt,Kh=$t,Rh=1,Hh=2,qh=4,Oe="[object Arguments]",Wh="[object Array]",zh="[object Boolean]",Yh="[object Date]",Xh="[object Error]",Me="[object Function]",Jh="[object GeneratorFunction]",Zh="[object Map]",Qh="[object Number]",Te="[object Object]",kh="[object RegExp]",tc="[object Set]",ec="[object String]",rc="[object Symbol]",ac="[object WeakMap]",ic="[object ArrayBuffer]",sc="[object DataView]",nc="[object Float32Array]",oc="[object Float64Array]",lc="[object Int8Array]",hc="[object Int16Array]",cc="[object Int32Array]",dc="[object Uint8Array]",uc="[object Uint8ClampedArray]",fc="[object Uint16Array]",gc="[object Uint32Array]",v={};v[Oe]=v[Wh]=v[ic]=v[sc]=v[zh]=v[Yh]=v[nc]=v[oc]=v[lc]=v[hc]=v[cc]=v[Zh]=v[Qh]=v[Te]=v[kh]=v[tc]=v[ec]=v[rc]=v[dc]=v[uc]=v[fc]=v[gc]=!0,v[Xh]=v[Me]=v[ac]=!1;function rt(t,e,r,a,i,s){var n,o=e&Rh,c=e&Hh,h=e&qh;if(r&&(n=i?r(t,a,i,s):r(t)),n!==void 0)return n;if(!Bh(t))return t;var u=Lh(t);if(u){if(n=xh(t),!o)return Mh(t,n)}else{var d=Vh(t),g=d==Me||d==Jh;if(Dh(t))return Oh(t,o);if(d==Te||d==Oe||g&&!i){if(n=c||g?{}:Ph(t),!o)return c?Fh(t,Ch(n,t)):Th(t,Eh(n,t))}else{if(!v[d])return i?t:{};n=Ih(t,d,o)}}s||(s=new _h);var A=s.get(t);if(A)return A;s.set(t,n),Gh(t)?t.forEach(function(b){n.add(rt(b,e,r,b,t,s))}):Nh(t)&&t.forEach(function(b,$){n.set($,rt(b,e,r,$,t,s))});var y=h?c?wh:jh:c?Kh:Uh,_=u?void 0:y(t);return Ah(_||t,function(b,$){_&&($=b,b=t[$]),Sh(n,$,rt(b,e,r,$,t,s))}),n}var vc=rt,mc=vc,pc=1,bc=4;function $c(t){return mc(t,pc|bc)}var yc=$c;const at=B(yc);var _c=K,Ac=F,Sc="[object Symbol]";function Ec(t){return typeof t=="symbol"||Ac(t)&&_c(t)==Sc}var Mt=Ec,Cc=C,Oc=Mt,Mc=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Tc=/^\w*$/;function Fc(t,e){if(Cc(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||Oc(t)?!0:Tc.test(t)||!Mc.test(t)||e!=null&&t in Object(e)}var jc=Fc,Fe=ft,wc="Expected a function";function Tt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(wc);var r=function(){var a=arguments,i=e?e.apply(this,a):a[0],s=r.cache;if(s.has(i))return s.get(i);var n=t.apply(this,a);return r.cache=s.set(i,n)||s,n};return r.cache=new(Tt.Cache||Fe),r}Tt.Cache=Fe;var Vc=Tt,xc=Vc,Ic=500;function Pc(t){var e=xc(t,function(a){return r.size===Ic&&r.clear(),a}),r=e.cache;return e}var Lc=Pc,Dc=Lc,Nc=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Bc=/\\(\\)?/g,Gc=Dc(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(Nc,function(r,a,i,s){e.push(i?s.replace(Bc,"$1"):a||r)}),e}),Uc=Gc;function Kc(t,e){for(var r=-1,a=t==null?0:t.length,i=Array(a);++r<a;)i[r]=e(t[r],r,t);return i}var Rc=Kc,je=G,Hc=Rc,qc=C,Wc=Mt,zc=1/0,we=je?je.prototype:void 0,Ve=we?we.toString:void 0;function xe(t){if(typeof t=="string")return t;if(qc(t))return Hc(t,xe)+"";if(Wc(t))return Ve?Ve.call(t):"";var e=t+"";return e=="0"&&1/t==-zc?"-0":e}var Yc=xe,Xc=Yc;function Jc(t){return t==null?"":Xc(t)}var Zc=Jc,Qc=C,kc=jc,td=Uc,ed=Zc;function rd(t,e){return Qc(t)?t:kc(t,e)?[t]:td(ed(t))}var ad=rd,id=Mt,sd=1/0;function nd(t){if(typeof t=="string"||id(t))return t;var e=t+"";return e=="0"&&1/t==-sd?"-0":e}var od=nd,ld=ad,hd=od;function cd(t,e){e=ld(e,t);for(var r=0,a=e.length;t!=null&&r<a;)t=t[hd(e[r++])];return r&&r==a?t:void 0}var dd=cd,ud=dd;function fd(t,e,r){var a=t==null?void 0:ud(t,e);return a===void 0?r:a}var gd=fd;const Ie=B(gd);class Ft{constructor(e){this.model=e||{},this.listeners=[]}set(e,r,a,i){this.model[e]=r,!i&&this.listeners.forEach(s=>s(this.model,a))}setModel(e,r,a){this.model=e,!a&&this.listeners.forEach(i=>i(this.model,r))}getModel(){return this.model}listen(e){this.listeners.push(e)}unlisten(e){const r=this.listeners.indexOf(e);r>-1&&this.listeners.splice(r,1)}}const O=S.createContext({setModel:()=>{},getModel:()=>{},getSchema:()=>{},submitForm:()=>{},getValidationErrors:()=>{},getAllValidationErrors:()=>{},getPath:()=>{},eventsEmitter:{emit:()=>{},registerEvent:()=>{},listen:()=>{},unregisterEvent:()=>{},unlisten:()=>{}},markFieldAsTouched:()=>{},hasBeenTouched:()=>{},validateOnChange:!1,isFormSubmitted:!1,setValidator:()=>{},removeValidator:()=>{}}),jt=(t,e,r)=>{if(Yr(r)||Array.isArray(r)){Object.keys(r).forEach(a=>{if(r[a]){if(typeof r[a]=="string"){t.setModelError(e,r[a]);return}jt(t,`${e}.${a}`,r[a])}});return}t.setModelError(e,r)};class N extends S.Component{constructor(r){super(r);ht(this,"setValidator",(r,a)=>{if(this.findValidatorIndex(a)<0){const s=(n,o)=>{const c=Ie(n,r),h=a(n,c);return h&&typeof h=="boolean"?h:h instanceof Promise?h.then(u=>u&&typeof u=="boolean"?u:jt(o,r,u)):jt(o,r,h)};this.fieldsValidators.push({path:r,validator:a,schemaValidator:s}),typeof this.state.schema.validate=="function"&&this.state.schema.addValidator(s)}});ht(this,"removeValidator",r=>{const a=this.findValidatorIndex(r);if(a>-1){const i=this.fieldsValidators[a];typeof this.state.schema.validate=="function"&&this.state.schema.removeValidator(i.schemaValidator),this.fieldsValidators.splice(a,1)}});ht(this,"findValidatorIndex",r=>this.fieldsValidators.findIndex(a=>a.validator===r));this.state={schema:r.schema,model:r.model||N.getDefaultModelValue(r.schema),validationErrors:{},validateOnChange:r.validateOnChange,touchedFields:{},isFormSubmitted:!1},r.controller&&r.controller.setForm(this),this.fieldsValidators=[],this.storage=new Ft(this.state.model),this.eventsEmitter=r.eventsEmitter,this.setModel=this.setModel.bind(this),this.setStateModel=this.setStateModel.bind(this),this.getModel=this.getModel.bind(this),this.getSchema=this.getSchema.bind(this),this.submitForm=this.submitForm.bind(this),this.runSubmit=this.runSubmit.bind(this),this.getValidationErrors=this.getValidationErrors.bind(this),this.getAllValidationErrors=this.getAllValidationErrors.bind(this),this.getPath=this.getPath.bind(this),this.validateModel=this.validateModel.bind(this),this.submitListener=this.submitListener.bind(this),this.validateListener=this.validateListener.bind(this),this.resetListener=this.resetListener.bind(this),this.handleSchemaValidation=this.handleSchemaValidation.bind(this),this.handleCustomValidation=this.handleCustomValidation.bind(this),this.handlePromiseValidation=this.handlePromiseValidation.bind(this),this.markFieldAsTouched=this.markFieldAsTouched.bind(this),this.hasBeenTouched=this.hasBeenTouched.bind(this)}getProviderContext(){return{setModel:this.setModel,getModel:this.getModel,getSchema:this.getSchema,submitForm:this.submitForm,getValidationErrors:this.getValidationErrors,getAllValidationErrors:this.getAllValidationErrors,getPath:this.getPath,eventsEmitter:this.eventsEmitter,markFieldAsTouched:this.markFieldAsTouched,hasBeenTouched:this.hasBeenTouched,validateOnChange:this.state.validateOnChange,isFormSubmitted:this.state.isFormSubmitted,setValidator:this.setValidator,removeValidator:this.removeValidator}}UNSAFE_componentWillMount(){this.storage.listen(this.setStateModel),this.eventsEmitter&&(this.eventsEmitter.listen("submit",this.submitListener),this.eventsEmitter.listen("validate",this.validateListener),this.eventsEmitter.listen("reset",this.resetListener))}componentWillUnmount(){this.storage.unlisten(this.setStateModel),this.storage.setModel({}),this.eventsEmitter&&(this.eventsEmitter.unlisten("submit",this.submitListener),this.eventsEmitter.unlisten("validate",this.validateListener),this.eventsEmitter.unlisten("reset",this.resetListener))}static getDefaultModelValue(r){return r&&typeof r.getDefaultValues=="function"?r.getDefaultValues():{}}setStateModel(r,a){this.setState({model:r},a)}setModel(r,a,i){const s=Object.assign({},this.state.model);s[r]=a,this.storage.set(r,a,i),this.state.validateOnChange&&this.validateModel(s,this.state.schema)}getModel(r){return this.state.model[r]}getSchema(r){return typeof this.state.schema.getField!="function"?{}:this.state.schema.getField(r)}getValidationErrors(r){return this.state.validationErrors[r]||{}}getAllValidationErrors(){return this.state.validationErrors}getPath(){return this.props.id}submitListener(){return this.submitForm()}validateListener(r){return this.validateModel(this.storage.getModel(),r||this.state.schema)}resetListener(r){const a=r||N.getDefaultModelValue(this.state.schema);this.storage.setModel(a)}handleSchemaValidation(r,a){const i=r.validate(a);return i instanceof Promise?this.handlePromiseValidation(i):(this.setState({validationErrors:i,validateOnChange:!0}),i)}handleCustomValidation(r,a){const i=r(a);return i instanceof Promise?this.handlePromiseValidation(i):(this.setState({validationErrors:i,validateOnChange:!0}),i)}handlePromiseValidation(r){return r.then(a=>(this.setState({validationErrors:a,validateOnChange:!0}),a))}validateModel(r,a){const{customValidation:i}=this.props;return typeof a.validate=="function"?this.handleSchemaValidation(a,r):typeof i=="function"?this.handleCustomValidation(i,r):{}}submitForm(r){this.setState({isFormSubmitted:!0});const a=Object.assign({},this.state.model),i=this.validateModel(a,this.state.schema);return r&&r.preventDefault(),i instanceof Promise?i.then(s=>(this.runSubmit(s,a),s)):this.runSubmit(i,a)}runSubmit(r,a){const i=at(a);if(Object.keys(r).length>0){this.props.onError&&this.props.onError(r,i);return}return this.setState({validateOnChange:!1}),this.props.onSubmit(i),i}markFieldAsTouched(r){if(!this.state.touchedFields[r]){const a=Object.assign({},this.state.touchedFields,{[r]:!0});this.setState({touchedFields:a})}}hasBeenTouched(r){if(!this.state.touchedFields[r]){const i=Object.keys(this.state.touchedFields).find(s=>s.indexOf(r)>-1);return this.state.touchedFields[i]}return!0}render(){const{children:r,className:a,subform:i,id:s}=this.props,n=this.getProviderContext();return i?f.jsx("div",{className:a,children:r}):f.jsx(O.Provider,{value:n,children:f.jsx("form",{onSubmit:this.submitForm,id:s,className:a,children:r})})}}N.propTypes={id:l.string,className:l.string,model:l.shape({}),schema:l.shape({}),onError:l.func,onSubmit:l.func.isRequired,validateOnChange:l.bool,customValidation:l.func,subform:l.bool,children:l.node,eventsEmitter:l.shape({emit:l.func,registerEvent:l.func,listen:l.func,unregisterEvent:l.func,unlisten:l.func}),controller:l.shape({setForm:l.func,getFrom:l.func,getErrors:l.func,setSchema:l.func,getSchema:l.func,setFieldValue:l.func,getFieldValue:l.func})},N.defaultProps={id:"form",className:"",model:void 0,schema:{},onError:void 0,validateOnChange:!1,customValidation:void 0,subform:!1,children:"",eventsEmitter:void 0,controller:void 0};var vd="__lodash_hash_undefined__";function md(t){return this.__data__.set(t,vd),this}var pd=md;function bd(t){return this.__data__.has(t)}var $d=bd,yd=ft,_d=pd,Ad=$d;function it(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new yd;++e<r;)this.add(t[e])}it.prototype.add=it.prototype.push=_d,it.prototype.has=Ad;var Sd=it;function Ed(t,e){for(var r=-1,a=t==null?0:t.length;++r<a;)if(e(t[r],r,t))return!0;return!1}var Cd=Ed;function Od(t,e){return t.has(e)}var Md=Od,Td=Sd,Fd=Cd,jd=Md,wd=1,Vd=2;function xd(t,e,r,a,i,s){var n=r&wd,o=t.length,c=e.length;if(o!=c&&!(n&&c>o))return!1;var h=s.get(t),u=s.get(e);if(h&&u)return h==e&&u==t;var d=-1,g=!0,A=r&Vd?new Td:void 0;for(s.set(t,e),s.set(e,t);++d<o;){var y=t[d],_=e[d];if(a)var b=n?a(_,y,d,e,t,s):a(y,_,d,t,e,s);if(b!==void 0){if(b)continue;g=!1;break}if(A){if(!Fd(e,function($,w){if(!jd(A,w)&&(y===$||i(y,$,r,a,s)))return A.push(w)})){g=!1;break}}else if(!(y===_||i(y,_,r,a,s))){g=!1;break}}return s.delete(t),s.delete(e),g}var Pe=xd;function Id(t){var e=-1,r=Array(t.size);return t.forEach(function(a,i){r[++e]=[i,a]}),r}var Pd=Id;function Ld(t){var e=-1,r=Array(t.size);return t.forEach(function(a){r[++e]=a}),r}var Dd=Ld,Le=G,De=me,Nd=ct,Bd=Pe,Gd=Pd,Ud=Dd,Kd=1,Rd=2,Hd="[object Boolean]",qd="[object Date]",Wd="[object Error]",zd="[object Map]",Yd="[object Number]",Xd="[object RegExp]",Jd="[object Set]",Zd="[object String]",Qd="[object Symbol]",kd="[object ArrayBuffer]",tu="[object DataView]",Ne=Le?Le.prototype:void 0,wt=Ne?Ne.valueOf:void 0;function eu(t,e,r,a,i,s,n){switch(r){case tu:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case kd:return!(t.byteLength!=e.byteLength||!s(new De(t),new De(e)));case Hd:case qd:case Yd:return Nd(+t,+e);case Wd:return t.name==e.name&&t.message==e.message;case Xd:case Zd:return t==e+"";case zd:var o=Gd;case Jd:var c=a&Kd;if(o||(o=Ud),t.size!=e.size&&!c)return!1;var h=n.get(t);if(h)return h==e;a|=Rd,n.set(t,e);var u=Bd(o(t),o(e),a,i,s,n);return n.delete(t),u;case Qd:if(wt)return wt.call(t)==wt.call(e)}return!1}var ru=eu,Be=he,au=1,iu=Object.prototype,su=iu.hasOwnProperty;function nu(t,e,r,a,i,s){var n=r&au,o=Be(t),c=o.length,h=Be(e),u=h.length;if(c!=u&&!n)return!1;for(var d=c;d--;){var g=o[d];if(!(n?g in e:su.call(e,g)))return!1}var A=s.get(t),y=s.get(e);if(A&&y)return A==e&&y==t;var _=!0;s.set(t,e),s.set(e,t);for(var b=n;++d<c;){g=o[d];var $=t[g],w=e[g];if(a)var Ye=n?a(w,$,g,e,t,s):a($,w,g,t,e,s);if(!(Ye===void 0?$===w||i($,w,r,a,s):Ye)){_=!1;break}b||(b=g=="constructor")}if(_&&!b){var ot=t.constructor,lt=e.constructor;ot!=lt&&"constructor"in t&&"constructor"in e&&!(typeof ot=="function"&&ot instanceof ot&&typeof lt=="function"&< instanceof lt)&&(_=!1)}return s.delete(t),s.delete(e),_}var ou=nu,Vt=Ht,lu=Pe,hu=ru,cu=ou,Ge=R,Ue=C,Ke=Q,du=mt,uu=1,Re="[object Arguments]",He="[object Array]",st="[object Object]",fu=Object.prototype,qe=fu.hasOwnProperty;function gu(t,e,r,a,i,s){var n=Ue(t),o=Ue(e),c=n?He:Ge(t),h=o?He:Ge(e);c=c==Re?st:c,h=h==Re?st:h;var u=c==st,d=h==st,g=c==h;if(g&&Ke(t)){if(!Ke(e))return!1;n=!0,u=!1}if(g&&!u)return s||(s=new Vt),n||du(t)?lu(t,e,r,a,i,s):hu(t,e,c,r,a,i,s);if(!(r&uu)){var A=u&&qe.call(t,"__wrapped__"),y=d&&qe.call(e,"__wrapped__");if(A||y){var _=A?t.value():t,b=y?e.value():e;return s||(s=new Vt),i(_,b,r,a,s)}}return g?(s||(s=new Vt),cu(t,e,r,a,i,s)):!1}var vu=gu,mu=vu,We=F;function ze(t,e,r,a,i){return t===e?!0:t==null||e==null||!We(t)&&!We(e)?t!==t&&e!==e:mu(t,e,r,a,ze,i)}var pu=ze,bu=pu;function $u(t,e){return bu(t,e)}var yu=$u;const H=B(yu);var _u=re,Au=R,Su=Jt,Eu=C,Cu=pt,Ou=Q,Mu=tt,Tu=mt,Fu="[object Map]",ju="[object Set]",wu=Object.prototype,Vu=wu.hasOwnProperty;function xu(t){if(t==null)return!0;if(Cu(t)&&(Eu(t)||typeof t=="string"||typeof t.splice=="function"||Ou(t)||Tu(t)||Su(t)))return!t.length;var e=Au(t);if(e==Fu||e==ju)return!t.size;if(Mu(t))return!_u(t).length;for(var r in t)if(Vu.call(t,r))return!1;return!0}var Iu=xu;const Pu=B(Iu),xt=t=>{class e extends S.Component{constructor(a){super(a),this.listeners=[],this.fieldValue=null,this.shouldShowValidationErrors=!1,this.fieldValidationErrors=null,this.fieldValidators=[],this.setFieldValidator=this.setFieldValidator.bind(this),this.removeFieldValidator=this.removeFieldValidator.bind(this),this.registerFieldValidators=this.registerFieldValidators.bind(this),this.unregisterFieldValidators=this.unregisterFieldValidators.bind(this),this.onChangeData=this.onChangeData.bind(this),this.getPath=this.getPath.bind(this),this.getPropsFromSchema=this.getPropsFromSchema.bind(this),this.getEventsEmitter=this.getEventsEmitter.bind(this),this.getValidationErrors=this.getValidationErrors.bind(this),this.getFieldAttributes=this.getFieldAttributes.bind(this),this.hasValidationError=this.hasValidationError.bind(this),this.submit=this.submit.bind(this)}getProviderContext(){return{...this.context,getSchema:this.context.getSchema,getPath:this.getPath,setFieldValidator:this.setFieldValidator,removeFieldValidator:this.removeFieldValidator}}UNSAFE_componentWillMount(){this.updateModelWithValueOrOptions(),this.registerListeners(),this.registerFieldValidators()}shouldComponentUpdate(a){const i=Object.assign({},a),s=Object.assign({},this.props),{name:n}=this.props,{getModel:o,getValidationErrors:c}=this.context;return!H(o(n),this.fieldValue)||!H(c(n),this.fieldValidationErrors)||!H(i,s)||!H(this.shouldShowErrors(),this.shouldShowValidationErrors)}componentWillUnmount(){this.unregisterListeners(),this.unregisterFieldValidators()}onChangeData(a){const{name:i,callbacks:{onChange:s}={}}=this.props,{setModel:n,eventsEmitter:o,markFieldAsTouched:c,validateOnChange:h,isFormSubmitted:u}=this.context;typeof n=="function"&&n(i,a,()=>{const d=this.getPath();o&&o.emit("modelChange",{name:d,value:a}),h&&!u&&c(d),typeof s=="function"&&s(a)})}getModelPath(){const a=this.getPath().split(".");return a.splice(1,a.length).map(i=>{const s=i.split("-");return s.length>1?s[1]:i}).join(".")}setFieldValidator(a){const i=this.getModelPath();this.context.setValidator(i,a),this.fieldValidators.push(a)}setCurrentFieldValue(a){this.fieldValue=at(a)}getValue(){const{name:a,value:i}=this.props,{getModel:s}=this.context;if(typeof s!="function")return i;const n=s(a),o=n!==void 0?n:i;return this.setCurrentFieldValue(o),o}getPropsFromSchema(){const{name:a}=this.props,{getSchema:i}=this.context;if(typeof i=="function")return i(a)}getEventsEmitter(){return this.context.eventsEmitter}getValidationErrors(){const{name:a,callbacks:{onError:i}={}}=this.props,{getValidationErrors:s}=this.context;this.shouldShowValidationErrors=this.shouldShowErrors();let n=[];return this.shouldShowValidationErrors&&(typeof s=="function"&&(n=s(a)),this.fieldValidationErrors=n,typeof i=="function"&&Object.keys(n).length>0&&i(n)),n}getPath(){const{name:a}=this.props,{getPath:i}=this.context;return typeof i!="function"?a:`${i()}.${a}`}getFieldAttributes(){const{validateOnChange:a,isFormSubmitted:i}=this.context,{fieldAttributes:s={},callbacks:{onFocus:n,onBlur:o}={}}=this.props;return Object.assign({},{onFocus:n,onBlur:c=>{typeof o=="function"&&o(c),a&&!i&&this.onChangeData(this.getValue())}},s)}setValueFromOptions(){const{name:a,options:i,defaultOption:s}=this.props,{setModel:n}=this.context;if(Array.isArray(i)&&i.length&&s!==void 0){const o=i[s].label?i[s].value:i[s];n(a,o)}}removeFieldValidator(a){const i=this.fieldValidators.indexOf(a);i>-1&&(this.context.removeValidator(a),this.fieldValidators.splice(i,1))}registerFieldValidators(){if(this.props.validator){const{getModel:a}=this.context,i=(...s)=>{const n=typeof a=="function"?a(this.props.name):"";return this.props.validator(n,...s)};this.setFieldValidator(i)}}unregisterFieldValidators(){this.fieldValidators.forEach(a=>{this.context.removeValidator(a)})}shouldShowErrors(){const{hasBeenTouched:a,validateOnChange:i,isFormSubmitted:s}=this.context;return!i||s?(this.shouldShowValidationErrors=!0,!0):(this.shouldShowValidationErrors=!1,a(this.getPath()))}submit(a){const{submitForm:i}=this.context;typeof i=="function"&&i(a)}updateModelWithValueOrOptions(){const{name:a,value:i}=this.props,{setModel:s}=this.context;!a||typeof s!="function"||(i?s(a,i):this.setValueFromOptions())}registerListeners(){const{onModelChange:a,onEmitEvents:i}=this.props,{eventsEmitter:s}=this.context;if(s&&(typeof a=="function"&&(this.onModelChangeMethod=n=>a(n,this),s.listen("modelChange",this.onModelChangeMethod)),i)){if(Array.isArray(i)){i.forEach(({name:h,method:u})=>{const d={name:h,method:g=>u(g,this)};this.listeners.push(d),s.listen(h,d.method)});return}const{name:n,method:o}=i,c={name:n,method:h=>o(h,this)};this.listeners.push(c),s.listen(n,c.method)}}unregisterListeners(){const{onEmitEvents:a}=this.props,{eventsEmitter:i}=this.context;i&&(typeof this.onModelChangeMethod=="function"&&i.unlisten("modelChange",this.onModelChangeMethod),a&&this.listeners.length>0&&this.listeners.forEach(({name:s,method:n})=>{i.unlisten(s,n)}))}hasValidationError(){return!Pu(this.getValidationErrors())}render(){return f.jsx(O.Provider,{value:this.getProviderContext(),children:f.jsx(t,{...this.getPropsFromSchema(),...this.props,onChange:this.onChangeData,submit:this.submit,validationErrors:this.getValidationErrors(),hasValidationError:this.hasValidationError(),value:this.getValue(),eventsEmitter:this.getEventsEmitter(),path:this.getPath(),fieldAttributes:this.getFieldAttributes()})})}}return e.contextType=O,e.propTypes={name:l.string,value:l.oneOfType([l.string,l.number,l.array,l.object]),fieldAttributes:l.shape({}),options:l.arrayOf(l.oneOfType([l.string,l.number,l.shape({})])),defaultOption:l.number,onModelChange:l.func,onEmitEvents:l.oneOfType([l.shape({name:l.string,method:l.func}),l.arrayOf(l.shape({name:l.string,method:l.func}))]),callbacks:l.shape({onChange:l.func,onError:l.func,onFocus:l.func,onBlur:l.func}),validator:l.func},e};class nt extends S.Component{constructor(e){super(e),this.state={schema:{},model:e.value?e.value:{},validationErrors:{}},this.storage=new Ft(this.state.model),this.setModel=this.setModel.bind(this),this.getModel=this.getModel.bind(this),this.getSchema=this.getSchema.bind(this),this.getValidationErrors=this.getValidationErrors.bind(this),this.setStateModel=this.setStateModel.bind(this)}getProviderContext(){return{...this.context,setModel:this.setModel,getModel:this.getModel,getSchema:this.getSchema,getValidationErrors:this.getValidationErrors}}UNSAFE_componentWillMount(){const{getSchema:e}=this.context,r=e(this.props.name).type;this.setState({schema:r}),this.storage.listen(this.setStateModel)}UNSAFE_componentWillReceiveProps({value:e={}}){this.setState({model:e}),this.storage.setModel(e,null,!0)}componentWillUnmount(){this.storage.unlisten(this.setStateModel)}setStateModel(e,r){this.props.onChange(at(e)),typeof r=="function"&&r()}setModel(e,r,a){this.storage.set(e,r,a)}getModel(e){return this.state.model[e]}getSchema(e){return this.state.schema?Array.isArray(this.state.schema)?this.state.schema[0].getField(e):this.state.schema.getField(e):{}}getValidationErrors(e){const{getValidationErrors:r}=this.context,a=r(this.props.name);if(Array.isArray(a)&&a.length>0){let i=[];return a.forEach(s=>{typeof s=="object"&&s[e]&&(i=[...i,...s[e]])}),i}return a[e]||[]}render(){const{children:e,wrapperClassName:r,fieldAttributes:a}=this.props;return f.jsx(O.Provider,{value:this.getProviderContext(),children:f.jsx("div",{className:r,...a,children:e})})}}nt.contextType=O,nt.propTypes={value:l.shape({}),name:l.string,onChange:l.func.isRequired,children:l.node,wrapperClassName:l.string,fieldAttributes:l.shape({})},nt.defaultProps={value:void 0,name:void 0,children:"",wrapperClassName:"",fieldAttributes:{}};const Lu=xt(nt);class M extends S.Component{static generateItemId(){return Math.random().toString(36).substring(7)}constructor(e,{getSchema:r}){super(e),this.state={schema:r(e.name),model:M.getModelFromProps(e),validationErrors:{}},this.storage=new Ft(this.state.model),this.setModel=this.setModel.bind(this),this.getModel=this.getModel.bind(this),this.getList=this.getList.bind(this),this.addListElement=this.addListElement.bind(this),this.removeListElement=this.removeListElement.bind(this),this.getSchema=this.getSchema.bind(this),this.getValidationErrors=this.getValidationErrors.bind(this),this.setStateModel=this.setStateModel.bind(this)}getProviderContext(){return{...this.context,setModel:this.setModel,getModel:this.getModel,getSchema:this.getSchema,getValidationErrors:this.getValidationErrors}}UNSAFE_componentWillMount(){this.storage.listen(this.setStateModel)}UNSAFE_componentWillReceiveProps({value:e}){let r=!1;e.forEach((a,i)=>{H(a,Ie(this.state,`model.${i}.value`))||(r=!0)}),(r||e.length!==this.state.model.length)&&this.storage.setModel(M.getModelFromProps({value:e}))}componentWillUnmount(){this.storage.unlisten(this.setStateModel)}static getModelFromProps(e){return e.value.length>0?e.value.map(r=>({id:M.generateItemId(),value:r})):[]}setStateModel(e,r){this.setState({model:e},r),this.props.onChange(e.map(a=>a.value))}setModel(e,r,a){const i=e.split("-")[1],s=Array.from(this.state.model);s[parseInt(i,10)].value=r,this.storage.setModel(s,a)}getModel(e){const r=e.split("-")[1];return this.state.model[r].value}getSchema(){return this.state.schema}getValidationErrors(e){const[r,a]=e.split("-"),{getValidationErrors:i}=this.context;return i(r)[parseInt(a,10)]||[]}getDefaultValueForListItem(){if(this.state.schema&&this.state.schema.type&&this.state.schema.type[0]&&typeof this.state.schema.type[0]=="object"&&typeof this.state.schema.type[0].getDefaultValues=="function")return this.state.schema.type[0].getDefaultValues()}getList(e){const{name:r,removeButton:{wrapperClassName:a,className:i,value:s},hideRemoveButton:n,itemWrapperClassName:o}=this.props,c=this.isRemoveAllowed();return this.state.model.map((h,u)=>{const d=()=>this.removeListElement(u),g=S.cloneElement(e,{name:`${r}-${u}`,index:u,value:h.value,key:h.id,removeListElement:d});return f.jsxs("div",{className:o,children:[g,!n&&c&&f.jsx("div",{className:a,children:f.jsx("button",{onClick:d,className:i,type:"button",children:s||"Remove"})})]},h.id)})}isAddAllowed(){const{maxLength:e}=this.props,{model:r}=this.state;return typeof e=="number"?r.length<e:!0}isRemoveAllowed(){const{minLength:e}=this.props,{model:r}=this.state;return typeof e=="number"?r.length>e:!0}addListElement(){const e=Array.from(this.state.model);e.push({id:M.generateItemId(),value:this.getDefaultValueForListItem()}),this.setState({model:e})}removeListElement(e){const r=at(this.state.model);r.splice(e,1),this.props.onChange(r.map(a=>a.value))}render(){const{children:e,className:r,wrapperClassName:a,label:i,addButton:s,hideAddButton:n,fieldAttributes:o,name:c}=this.props,h=this.isAddAllowed();return f.jsx(O.Provider,{value:this.getProviderContext(),children:f.jsxs("div",{className:a,children:[i&&f.jsx("label",{htmlFor:c,children:i}),f.jsx("div",{className:r,...o,children:this.getList(e)}),!n&&h&&f.jsx("button",{onClick:this.addListElement,className:s.className,type:"button",children:s.value||"Add"})]})})}}M.contextType=O,M.defaultProps={children:"",className:"",wrapperClassName:"",itemWrapperClassName:"",label:"",addButton:{},removeButton:{},hideAddButton:!1,hideRemoveButton:!1,name:"",value:[],fieldAttributes:{},minLength:void 0,maxLength:void 0};const Du=xt(M);class Nu{constructor(){this.listeners={}}listen(e,r){if(this.listeners[e]||(this.listeners[e]=[]),typeof r!="function"){console.warn(`FormEventsEmitter->listen - "${e}" listener is not a function`);return}if(this.listeners[e].indexOf(r)>-1){console.warn(`FormEventsEmitter->listen - "${e}" events listener is allready registered`);return}this.listeners[e].push(r)}unlisten(e,r){if(!this.listeners[e]){console.warn(`FormEventsEmitter->unlisten - "${e}" event not registered`);return}if(this.listeners[e].length===0){console.warn(`FormEventsEmitter->unlisten - "${e}" event dont have registered listener`);return}const a=this.listeners[e].indexOf(r);if(a<0){console.warn(`FormEventsEmitter->unlisten - "${e}" listener not exists`);return}this.listeners[e].splice(a,1)}emit(e,r){const a=[];if(this.listeners[e]&&Array.isArray(this.listeners[e]))return this.listeners[e].forEach(i=>{const s=i(r);s&&a.push(s)}),a}}class Bu{constructor(){this.form={}}setForm(e){this.form=e}getForm(){return this.form}setSchema(e){this.getForm().setState({schema:e})}getSchema(){return this.getForm().state.schema}getErrors(){return this.getForm().getAllValidationErrors()}setFieldValue(e,r){this.getForm().setModel(e,r)}getFieldValue(e){return this.getForm().getModel(e)}}p.FieldConnect=xt,p.Form=N,p.FormContext=O,p.FormController=Bu,p.FormEventsEmitter=Nu,p.ListField=Du,p.ObjectField=Lu,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
//# sourceMappingURL=index.umd.js.map