UNPKG

foop

Version:

interfaces that describe their intentions.

3 lines (2 loc) 28.9 kB
function t(n,r,e){return function(){for(var o=arguments,i=[],u=0,s=n,c=0;c<r.length||u<arguments.length;){var a=void 0;a=c<r.length&&(!E(r[c])||u>=o.length)?r[c]:o[u++],i[c++]=a,E(a)||(s-=1)}return s<=0?e.apply(this,i):N(s,t(n,i,e))}}function n(t){return function(){return this[t]}}function r(t){return _t(t)&&!wt(t)&&!Ct(t)}function e(t,n){return Ot(n.clone)&&r(t)?u(Nt(t),t,n):t}function o(t,n,o){for(var i=t.slice(),s=0;s<n.length;s++){var c=n[s];S(i[s])?i[s]=e(c,o):r(c)?i[s]=u(t[s],c,o):~t.indexOf(c)||i.push(e(c,o))}return i}function i(t,n,o){var i={};if(r(t))for(var s=U(t),c=0;c<s.length;c++)i[s[c]]=e(t[s[c]],o);for(var a=U(n),f=0;f<a.length;f++){var h=a[f];i[h]=r(n[h])&&t[h]?u(t[h],n[h],o):e(n[h],o)}return i}function u(t,n,r){if(X(n)){var o=r.arrayMerge;return X(t)?o(t,n,r):e(n,r)}return i(t,n,r)}function s(t,n){var r=this;return Q(t)?0===t?function(...t){return 0!==t.length?s(t.length,n).apply(r,t):new n}:x(t,function(t,r,e,o,i){var u=arguments.length;return 1===u||u>5?new n(t,r,e):2===u?new n(t,r):3===u?new n(t,r,e):4===u?new n(t,r,e,o):5===u?new n(t,r,e,o,i):void 0}):s(t.length,t)}function c(t,n){return S(this.parents)&&(this.parents=new Set),this.node=t,this.parent=t,this.root=t,this.reset(),this}function a(t){var n=S(t)?this.node:t;if(en(n))return n;var r=Nt(n),e=r;return f(n).forEach(function(t,n,r){if(!C(t)){var o=ln(n);r.isCircular&&X(n)&&(o=n.slice(0)),hn(e,r.path,o)}}),r}function f(t){return c.getPooled(t)}function h(t){if(Kn(t))return Jn(t);for(var n=t.split("|"),r=(t.split("&"),0);r<n.length;r++)l(n[r]);return Wn(t,function(t){for(var r=0;r<n.length;r++)if(Jn(n[r])(t))return!0;return!1}),Jn(t)}function p(t){var n=$n(t),r=Jn(n),e="?"+n,o=n+"[]",i="!"+n,u=nn(r,qn),s=nn(r,Vn(r));return Hn(e)&&Wn(e,u),Hn(o)&&Wn(o,s),Hn(i)&&Wn(i,zn(r)),Jn(t)}function l(t){return R(t)?t:q(t)&&Xn(t)?h(t):p(t)}function v(t,n,r){t[Rn("set-"+n)]=r.set,t[Rn("get-"+n)]=r.get}function d(t,n,r){if(!S(r))for(var e=0;e<r.length;e++)J(n,r[e],yr(n,t))}function y(t){return jr.getPooled(t)}function g(t){return V(t)?Fr(t):Yr(t)?{test:Zr(!1)}:A(t,"test")?t:R(t)?{test:t}:{test:Zr(!1)}}function m(t,n){var r=S(n)?fe:n,e=t;he(t)?(e=St.composer(e),e=Qt.composer(e),e=Nr.composer(e)):e=Nr;for(var o=0;o<r.length;o++)e=r[o](e);return Vr(e),e}var b=Object.assign,S=function(t){return void 0===t},j=(process,"shorthands"),_=Symbol.iterator,O=Symbol.hasInstance,w=Symbol.toPrimitive,C=function(t){return null===t},P=function(t){return S(t)||C(t)},k=Object.prototype.isPrototypeOf,M=function(t,n){return!P(t)&&k.call(t,n)},E=function(t){return"_"===t},N=function(t,n){return 1===t?function(t){return n.apply(this,arguments)}:2===t?function(t,r){return n.apply(this,arguments)}:3===t?function(t,r,e){return n.apply(this,arguments)}:4===t?function(t,r,e,o){return n.apply(this,arguments)}:5===t?function(t,r,e,o,i){return n.apply(this,arguments)}:function(){return n.apply(this,arguments)}},x=function(n,r){return N(n,t(n,[],r))},I=function(t){return Object(t)},T=function(t,n){return n in I(t)},A=function(t,n){return!C(t)&&T(t,n)},R=function(t){return"function"==typeof t},z=x(3,function(t,n,r){if(A(t,n)&&R(t[n]))return t[n](r)})(Object.prototype.toString,"call"),D=function(t){return"[object Map]"===z(t)},G=function(t){return"[object Set]"===z(t)},V=function(t){return"string"==typeof t},q=function(t){return V(t)||"[object String]"===z(t)},B=function(t){return!1===t},F=Object.prototype.hasOwnProperty,$=x(2,function(t,n){return!P(t)&&F.call(t,n)}),L=(x(3,function(t,n,r){return!!$(r,t)&&n(r[t])}),function(){}),U=Object.keys,J=function(t,n,r){Object.defineProperty(t,n,b({configurable:!0,enumerable:!0},r))},K=function(t){return"parent"===t||"store"===t||"meta"===t||"className"===t},W=Array.from,H=function(t,n,r){return{i:0,next:function(){var e=this.i,o=e,i=n[e];return o=t[e],S(o)&&S(i)||r<=e?{value:void 0,done:!0}:(this.i++,{value:[o,i],done:!1})}}},Q=function(t){return"number"==typeof t},X=Array.isArray,Y=function(t){return Q(t)||"[object Number]"===z(t)},Z=function(t){return Y(t)&&Number.isNaN(t)},tt=function(t){return+t},nt=function(t){var n=tt(t);return Z(n)?0:0===n||n===-1/0||n===1/0?n:Math.sign(n)*Math.floor(Math.abs(n))},rt=function(t){return(t=nt(t))<0?0:t>4294967295?4294967295:t},et=function(t){if(P(t))return 0;if(Q(t))return rt(t);if(A(t,"length"))return t.length;if(A(t,"size"))return t.size;var n=0;for(var r in t)$(t,r)&&++n;return n},ot=function(t){return t>1?t-1:1===t?1:0},it=function(t){return new Array(ot(t)>200?0:ot(t))},ut=function(t){return it(Q(t)?t:X(t)?t.length:et(t))},st=function(){for(var t=arguments,n=arguments.length,r=ut(n),e=0;e<n;++e)r[e]=t[e];return r},ct=function(t){return x(2,function(n,r){var e=st.apply(null,arguments);return e[0]=r,e[1]=n,t.apply(this,e)})},at=ct($),ft=x(3,function(t,n,r){return!!A(r,t)&&n(r[t])}),ht=ft("get",R),pt=function(t,n,r){return t?R(n)&&(V(t)&&ht(this)?this.get(t)&&n(this):n(this)):R(r)&&r(this),this},lt=function(t){var n=ut(t),r=0;return t.forEach(function(t){n[r++]=t}),n},vt=function(t,n,r,e){var o=-1,i=et(t);for(e&&i&&(r=t[++o]);++o<i;)r=n(r,t[o],o,t);return r},dt=function(t,n){return n(t)},yt=function(t,n){var r=t(n);return S(r.composer)&&(r.composer=function(t,n){r[127913]=t;var e=lt(r[127932]);return vt(e,dt,r[127913])},r[127932]=new Set),R(t)&&r[127932].add(t),r},gt=at("store"),mt=(ft("construct",R),ft("destructor",R)),bt=function(t,n){return!K(t)&&(D(n)||G(n)||gt(n))},St=yt(function(t,r){var e=function(t){function n(n){t.call(this),this.className=this.constructor.name,this.parent=n}return t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n,n}(t);return e.prototype.destructor=function(){mt(t.prototype)&&t.prototype.destructor.call(this),this.clear(),this.parent=void 0},e.prototype.className=e.constructor.name,e.hashCode=function(){},e.prototype.end=n("parent"),e.prototype.when=pt,e.prototype.clear=function(t){var n=this;if(void 0===t&&(t=!0),this.store.clear(),B(t))return this;for(var r=U(this),e=0;e<r.length;e++){var o=r[e];bt(o,n[o])&&n[o].clear()}return this},e.prototype.delete=function(t){return this.store.delete(t),this},e.prototype.has=function(t){return this.store.has(t)},e.prototype.values=function(){return W(this.store.values())},e.prototype[_]=function(){return H(this.keys(),this.values(),this.store.size)},e.prototype[w]=function(t){return"number"===t&&this.toNumber?this.toNumber():this.toJSON?this.toJSON():this.toString()},J(e.prototype,"length",{enumerable:!1,get:function(){return this.store.size}}),J(e.prototype,O,{enumerable:!1,value:function(t){return t&&(M(e.prototype,t)||gt(t))}}),e},L),jt=function(t){return"object"==typeof t},_t=function(t){return!P(t)&&jt(t)},Ot=function(t){return!0===t},wt=function(t){return"[object RegExp]"===z(t)},Ct=function(t){return"[object Date]"===z(t)},Pt=function(t){return Ot(t)||B(t)},kt=function(t){return Pt(t)||"[object Boolean]"===z(t)},Mt=function(t){return X(t)?"array":C(t)?"null":typeof t},Et=x(2,function(t,n){return t.includes(n)}),Nt=function(t){return X(t)?[]:{}},xt=function(t,n,r){if(t===n)return t;var e=b({arrayMerge:o,stringToArray:!0,boolToArray:!1,ignoreTypes:["null","undefined"]},r),i=e.ignoreTypes,s=e.stringToArray,c=e.boolToArray,a=e.clone;return Ot(Et(i,Mt(t)))?n:Ot(Et(i,Mt(n)))?t:kt(t)&&kt(n)?c?[t,n]:n:q(t)&&q(n)?s?[t,n]:t+n:X(t)&&q(n)?(a?t.slice(0):t).concat([n]):q(t)&&X(n)?(a?n.slice(0):n).concat([t]):u(t,n,e)},It=function(t){var n={};return 0!==t.size&&(n=W(t.entries()).reduce(function(t,n){var r=n[0],e=n[1];return t[r]=e,t},n)),n},Tt=function(t){return!C(t)&&(jt(t)||R(t))},At=function(t){return function(n){for(var r=U(n),e=0;e<r.length;e++){var o=r[e];if(!K(o)){var i=n[o];T(i,"entries")&&b(t,{[o]:i.entries(!0)||{}})}}return t}},Rt=function(t){return t},zt=Object.freeze||Rt,Dt=[];zt(Dt);var Gt,Vt=Dt,qt=function(t){return~z(t).indexOf("Iterator")},Bt=function(t){return V(t)?t.includes(",")?t.split(","):[t]:t?X(t)?t:G(t)||D(t)||t.values?W(t.values(t)):qt(t)?W(t):[t]:[t]},Ft=function(t,n){return Bt(t||[]).concat(Bt(n))},$t=(process,"transformers"),Lt=(process,"observers"),Ut=(process,"decorated"),Jt=function(t){return t===Lt},Kt=function(t){function n(n,o,s){if(S(s)){if(S(o))return S(r[n])?Vt:0===et(r[n])?Vt:W(r[n]);if(!Jt(n))return S(r[n])?Vt:Bt(i(n,o));e(n),u(n,o)}else e(n),u(n,o,s);return t}if($(t,"meta"))return t.meta;var r={},e=function(t,n){S(r[t])&&(r[t]=Jt(t)?new Set:new Map)},o=function(t,n){return S(n)?!!et(r[t]):r[t].has(n)},i=function(t,n){return o(t,n)?r[t].get(n):Vt},u=function(t,n,e){var o=r[t];if(G(o))o.add(n);else{var i=o.get(n),u=Ft(i,e);o.set(n,u)}};return n.store=r,n},Wt=s,Ht=(Wt(0,Map),at("merge")),Qt=yt(function(t){var n=function(t){function n(n){t.call(this,n),this.store=new Map,this.meta=Kt(this)}return t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n,n}(t);return n.prototype.tap=function(t,n){return this.set(t,n(this.get(t),xt))},n.prototype.keys=function(){return W(this.store.keys())},n.prototype.from=function(t){for(var n=this,r=U(t),e=0;e<r.length;e++){var o=r[e],i=t[o],u=n[o];Ht(u)?u.merge(i):R(u)?u.call(n,i):n.set(o,i)}return this},n.prototype.extend=function(t){var n=this;return t.forEach(function(t){n.meta(j,t),n[t]=function(r){return n.set(t,r)}}),this},n.prototype.entries=function(t){var n=It(this.store);if(S(t))return n;var r=At(n);return r(this),r(n),n},n.prototype.get=function(t){return"debug"===t?this.meta.debug:this.store.get(t)},n.prototype.set=function(t,n){return this.store.set(t,n),this},n},St),Xt=ct(Et),Yt=function(t){return""===t||!P(t)&&!!jt(t)&&0===et(t)},Zt=function(t){return"[object Error]"===z(t)},tn=function(t){return"[object Symbol]"===z(t)},nn=x(3,function(t,n,r){return t(r)||n(r)}),rn=nn(function(t){return"[object AsyncFunction]"===z(t)},function(t){return"[object Promise]"===z(t)}),en=function(t){return P(t)||V(t)||Q(t)||Pt(t)},on=function(t){return!(!_t(t)&&!X(t)&&(en(t)||wt(t)||Ct(t)||tn(t)||rn(t)||Zt(t)))},un=function(t){return t-1},sn=x(2,function(t,n){return P(n)?void 0:n[t]})("length"),cn=function(t){return un(sn(t))},an=function(t){if(Gt||(Gt=new Map),Gt.has(t))return Gt.get(t);if(X(t))return t;for(var n=t.split("."),r=[],e=0;e<n.length;e++){for(var o=n[e];"\\"===o[cn(o)]&&!S(n[e+1]);)o=o.slice(0,-1)+"."+n[++e];r.push(o)}return Gt.set(t,r),r},fn=function(t,n){return Tt(t)&&q(n)||X(n)},hn=function(t,n,r){if(fn(t,n))for(var e=an(n),o=0;o<e.length;o++){var i=e[o];Tt(t[i])||(t[i]={}),o===cn(e)&&(t[i]=r),t=t[i]}},pn=Wt(0,RegExp),ln=function(t){if(_t(t)){var n;X(t)?n=[]:Ct(t)?n=new t.constructor(t.valueOf()):wt(t)?(n=pn(t.src,t.toString().match(/[^/]*$/)[0])).lastIndex=t.lastIndex:n=Object.create(Object.getPrototypeOf(t));for(var r in t)n[r]=t;return n}return t},vn=1===process.env.PERF,dn={};zt(dn);var yn=dn,gn=function(t){return X(t)?t:Tt(t)?U(t):vn?yn:[]},mn=function(t,n){return!t||!n||t.toString()!==n.toString()},bn=function(t,n,r){if(P(t)||P(n)){if(t!==n)return!1}else if(typeof t!=typeof n){if(!Ot(r)||t!=n)return!1}else{if(z(t)!==z(n))return!1;if(_t(t)){if($(t,"equals"))return t.equals(n);if(wt(t)||wt(n)){if(mn(t,n))return!1}else if((Ct(t)||Ct(n))&&(!Ct(t)||!Ct(n)||t.getTime()!==n.getTime()))return!1}}return!0},Sn=function(t){var n=this;t.destructor(),n.instancePool.length<n.poolSize&&n.instancePool.push(t)},jn=function(t){var n=this;if(n.instancePool.length){var r=n.instancePool.pop();return r.construct?r.construct(t):n.call(r,t),r}return new n(t)},_n=function(t,n){var r=t;return r.instancePool=[],r.getPooled=n||jn,r.poolSize||(r.poolSize=10),r.release=Sn,r};c.prototype.reset=function(){this.path=[],this.key=void 0,this.isAlive=!0,this.isCircular=!1,this.isLeaf=!1,this.isRoot=!0,this.depth=-1},c.prototype.hasParent=function(t,n){return!!Tt(n)&&this.parents.has(n)},c.prototype.addParent=function(t,n){Tt(n)&&this.parents.add(n)},c.prototype.clear=function(){this.parents.clear()},c.prototype.removeParent=function(t,n){this.parents.delete(n)},c.prototype.forEach=function(t){var n=this.iterate(t);return c.release(this),n},c.prototype.stop=function(){this.isAlive=!1},c.prototype.skip=function(){this.skipBranch=!0},c.prototype.checkIteratable=function(t){if(this.isIteratable=on(t),Ot(this.isIteratable)){this.isLeaf=!1;var n=this.path.join(".");this.hasParent(n,t)?this.isCircular=!0:(this.addParent(n,t),this.isCircular=!1)}else this.isLeaf=!0,this.isCircular=!1},c.prototype.remove=function(t){if(!S(this.key)){var n=t||this.node;Tt(n)&&(this.removeParent(n),this.skip(),delete n[this.key],delete this.parent[this.key])}},c.prototype.update=function(t){hn(this.root,this.path,t)},c.prototype.destructor=function(){this.node=void 0,this.parent=void 0,this.reset(),this.clear()},c.prototype.iterate=function(t){if(!1===this.isAlive)return c.release(this);var n=this.node;D(n)?n=It(n):G(n)&&(n=Bt(n)),this.addParent(this.depth,n);var r=X(n),e=r||Tt(n);return S(this.onBefore)||this.onBefore(this),Ot(this.isRoot)&&(t.call(this,null,n,this),this.isRoot=!1),(r||e)&&Yt(n)&&(t.call(this,this.key,n,this),this.node=n),this.node=n,S(this.onAfter)||this.onAfter(this),this.path.pop(),this.node},c.prototype.pre=function(t){this.onPre=t},c.prototype.post=function(t){this.onPost=t},c.prototype.before=function(t){this.onBefore=t},c.prototype.after=function(t){this.onAfter=t},c.prototype.clone=a,c.prototype.copy=ln,_n(c),f.eq=function(t){return function(n,r,e){var o=!0,i=r,u=[i],s=t(n),c=function(){o=!1,s.stop()};return s.forEach(function(t,n,r){if(C(t))return!1===bn(i,n,e)?c():void 0;var o=i;_t(i)&&!Yt(i)&&(o=i[t],u.push(o)),r.isLeaf||Yt(u)||(i=u.pop()),!1===bn(o,n,e)&&c()}),u=void 0,i=void 0,o}}(f),f.clone=a,f.copy=ln;var On=f,wn=new Map,Cn=function(t,n,r){if(wn.has(n))return wn.get(n);var e=[];return On(n).forEach(function(n){var r=this.path;r.length&&e.push((t?t+".":"")+r.join("."))}),Ot(r)&&(e=e.filter(function(t){return!e.some(function(n){return n!==t&&Xt(n,t)})})),wn.set(n,e),e},Pn=Object.prototype.propertyIsEnumerable,kn=x(2,function(t,n){return Pn.call(t,n)}),Mn=function(t,n,r){if(!fn(t,n))return S(r)?t:r;for(var e=an(n),o=0;o<e.length;o++){if(!kn(t,e[o]))return r;if(t=t[e[o]],P(t)){if(o!==cn(e))return r;break}}return t},En=nn(q,Y),Nn=function(t){return!P(t)&&!Z(t)},xn=function(t){return En(t)||kt(t)||!Nn(t)||Zt(t)||wt(t)},In=function(t){return Tt(t)&&0!==U(t).length},Tn=nn(R,wt),An={isObjWithKeys:In,isObj:Tt,isObjPure:function(t){return _t(t)&&!X(t)&&!R(t)},isObjNotNull:_t,isFunction:R,isReal:Nn,toS:z,isDate:Ct,isRegExp:wt,isError:Zt,isBoolean:kt,isNumber:Y,isString:q,isMap:D,isSet:G,isSymbol:tn,isPrototypeOf:M,isArray:X,isIterator:qt,isUndefined:S,isNull:C,isNill:P,isTrue:Ot,isMatcher:Tn},Rn=function(t){return t.replace(/\s+/g,"_").replace(/[_.-](\w|$)/g,function(t,n){return n.toUpperCase()})},zn=x(2,function(t,n){return!t(n)}),Dn=x(2,function(t,n){return function(r){return t(r)&&n(r)}}),Gn=x(2,function(t,n){for(var r in n)if(!t(n[r]))return!1;return!0}),Vn=function(t){return Dn(X,Gn(t))},qn=Dn(zn(Nn),Yt),Bn=x(3,function(t,n,r){return r.replace(t,n)}),Fn=new Qt,$n=Bn(/[?\[\]!\|]/g,""),Ln=function(t){return Rn("is-"+t)},Un=function(t){return function(n){return t===n||t.includes(n)}},Jn=function(t){return Fn.get(t)||Fn.get(Ln(t))||Un(t)},Kn=function(t){return Fn.has(t)||Fn.get(Ln(t))},Wn=function(t,n){return Fn.set(t,n)},Hn=zn(Kn),Qn=function(t){return Fn.from(xt(Fn.entries(),t))};Qn(An);var Xn=function(t){return t.includes("|")||t.includes("&")};l.has=Kn,l.get=Jn,l.set=Wn,l.addTypes=Qn,l.map=Fn;var Yn=l,Zn=function(t,n,r){return(r||Yn(t))(n)},tr=function(t,n){return function(r){if(xn(r))return Zn(t,r,n);for(var e=Cn(!1,r,!0),o=0;o<e.length;o++){var i=e[o]||t,u=Mn(n,i),s=Mn(r,i.split("."));if(!Zn(u,s))return!1}return!0}},nr=S,rr=function(t){return Tt(t)&&!nr(t)||X(t)},er=function(t){for(var n=this,r=this.parent,e=this.entries(),o=e.onValid,i=e.onInvalid,u=e.define,s=e.getSet,c=U(t),a=0;a<c.length;a++){var f=c[a],h=t[f],p=n.newThis().name(f);i&&p.onInvalid(i),o&&p.onValid(o),u&&p.define(),s&&p.getSet();var l=h;rr(h)&&(l=tr(f,h)),r.meta&&r.meta("schema",f,h),p.type(l).build()}return r},or=x(4,function(t,n,r,e){return function(o,i,u){var s=n(o,i,u);return t(s)?r(s):e(s)}}),ir=function(t){return function(){throw t}},ur=function(t,n){return function(r,e,o){var i=z(r),u={[t]:{type:n,arg:{val:r,str:i,json:JSON.stringify(r)}}},s=b(new TypeError(i+" != "+n),u,o);return e&&e.message&&(s.message+=e.message),e&&e.stack&&(s.stack=e.stack),s.reThrow=ir(s),s}},sr=x(3,function(t,n,r){return function(e,o,i){var u;try{return u=t(e,o,i),n?n(u):u}catch(t){return r?r(t):t}}}),cr=function(t,n){var r,e,o=n?n(t):sr(t),i=function(t,n,i){return o(e,r)(t,n,i)};return i.then=i.onInvalid=function(t){return r=t,i},i.catch=i.onValid=function(t){return e=t,i},i},ar={m:1},fr=function(t,n,r){return function(n,e,o){var i=ur(t,e),u=cr(n,o),s=r.onCall||r.onSet,c=r.onValid||s,a=r.onInvalid||function(t,n){return i(t,n,ar).reThrow()};return function(n){var r=this;return u.onInvalid(function(e){a.call(r,i(n,e),n,t,r)}).onValid(function(e){c.call(r,n,t,r)}).call(this,n),this}}},hr=(or(zn(B)),function(t,n,r){}),pr=function(t,n){var r=this,e=t[n];return R(e)?function(){r.define(!1),r.onCall(e)}:function(){r.from(e),e.set&&r.onSet(e.set),e.get&&r.onGet(e.get),e.call&&r.onCall(e.call),e.set&&e.get&&r.define().getSet()}},lr=function(t){return this.target(t),t.meta=Kt(t),this.plugin(function(n,r){return t.meta(Ut,n),this.returns(function(n){return n||t}).callReturns(!0)})},vr=function(t,n){return this.initial(0).onCall(function(){return n.tap(t,function(t){return t+1})})},dr=function(t,n){var r=function(r){return S(r)?n.get(t):n.set(t,r)};return r.autoGetSet=!0,this.onSet(r).onGet(r).onCall(r)},yr=Object.getOwnPropertyDescriptor,gr=x(2,function(t,n){return P(n)?t:n}),mr=["onInvalid","onValid","initial","default","type","callReturns","target","onSet","onCall","onGet"],br=gr(!0),Sr={},jr=function(t){function n(n){t.call(this,n),this.construct(n)}return t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n,n.prototype.construct=function(t){var r=this;this.parent=t;var e=this.set.bind(this);this.newThis=function(){return n.getPooled(r.parent)},this.encase=function(t){return e("encase",r.parent[t]||t||!0)},this.returns=function(t,n){return e("returns",t||r.parent).callReturns(n)},this.bind=function(t){return e("bind",S(t)?r.parent:t)},S(this.alias)&&this.setupOnce(),this.plugin(hr)},n.prototype.setupOnce=function(){var t=this,n=this.set.bind(this);this.toNumber=function(){return t.build(0)},this.extend(mr),this.method=this.methods=function(n){return t.length?t.build().methods(n):t.name(n)},this.then=this.onValid.bind(this),this.catch=this.onInvalid.bind(this),this.chainable=this.returns,this.alias=function(n){return t.tap("alias",function(t,r){return r(t,Bt(n))})},this.plugin=function(n){return t.tap("plugins",function(t,r){return r(t,Bt(n))})},this.camelCase=function(){return n("camel",!0)},this.define=function(t){return n("define",br(t))},this.getSet=function(t){return n("getSet",br(t))},this.autoGetSet=function(){return t.plugin(dr)},In(Sr)&&U(Sr).forEach(function(n){t[n]=function(r){return Sr[n].call(t,r)}})},n.prototype.destructor=function(){this.clear(),this.parent=void 0},n.prototype.name=function(t){var n=this,r=t;if(!X(t)&&Tt(t)){r=U(t);for(var e=0;e<r.length;e++)n.plugin(pr.call(n,t,r[e]))}return this.set("names",r)},n.prototype.schema=function(t){return er.call(this,t)},n.prototype.build=function(t){for(var r=this,e=this.parent,o=Bt(this.get("names")),i=this.get("camel"),u=0;u<o.length;u++)r._build(i?Rn(o[u]):o[u],e);return this.clear(),delete this.parent,n.release(this),S(t)?e:t},n.prototype._defaults=function(t,n,r){var e=function(r){return n.set(t,r)},o=function(){return n.get(t)};e.defaulted=!0,o.defaulted=!0;var i=r.onCall,u=r.onSet,s=r.onGet;s&&!s.defaulted||this.onGet(o),i&&!i.defaulted||this.onCall(e),u&&!u.defaulted||this.onSet(e)},n.prototype._build=function(t,n){var r,e,o=this,i=function(){return o.entries()};if($(n,t)){if(e=yr(n,t),B(e.configurable))return;r=e.value,this.onCall(r).onSet(r)}else n[t]&&(r=n[t],this.onCall(r).onSet(r));var u=i();this._defaults(t,n,u);var s=u.plugins;if(s)for(var c=0;c<s.length;c++)u=i(),s[c].call(o,t,n,u);if((u=i()).encase){var a=fr.call(this,t,n,u)(r);this.onCall(a).onSet(a),r=a,u=i()}var f=u.getSet,h=u.define,p=u.default,l=u.onGet,y=u.onSet,g=u.onCall,m=u.initial,_=u.bind,O=u.returns,w=u.callReturns,C=u.alias;if(r||(r=function(t){return void 0===t&&(t=p),g.call(n,t)}),_&&(r=r.bind(_)),O){var P=r;r=function(){var t=st.apply(null,arguments),r=P.apply(n,t);return Ot(w)?O.apply(n,[r].concat(t)):O}}S(m)||n.set(t,m);var k={get:l,set:y},M=h?k:{value:r};e&&(M=b(e,M)),M.value&&M.get&&delete M.value,S(M.writable)||delete M.writable;var E=this.get("target")||n;J(E,t,M),f&&(E.meta&&E.meta(j,t,y),v(E,t,k)),d(t,E,C)},n.prototype.decorate=function(t){return lr.call(this,t||this.parent.parent)},n.prototype.autoIncrement=function(){return this.plugin(vr)},n}(Qt);_n(jr),Sr=y.add=function(t){b(Sr,t)};var _r=y,Or=function(t){return D(t)||t instanceof St},wr="onExisting",Cr="onValue",Pr="merger",kr="obj",Mr=function(t){function n(n){t.call(this,n),this.extend([wr,Cr,kr]).set(Cr,function(){return!0}).set(Pr,xt)}return t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n,n.prototype.merger=function(t){return R(t)?this.set(Pr,t):this.set("opts",t)},n.prototype.merge=function(t){for(var n=this,r=this.parent,e=function(t){return n.get(t)},o=e(wr),i=e(Cr),u=e("opts"),s=t||e(kr),c=e(Pr),a=r.meta?r.meta(j):yn,f=U(s),h=0,p=f.length;h<p;h++){var l=f[h],v=s[l];S(a[l])||a[l]===l||(l=a[l]);var d=r[l];i(v,l,n)&&(Or(d)?r[l].merge(v):d?function(t,n){var e=function(n,e){return R(r[t])?r[n](e):r.set(n,e)};if(Ot(r.has(t))){var i=r.get(t);S(o)?e(t,c(i,n,u)):e(t,o(i,n,u))}else e(t,n)}(l,v):r.set(l,v))}return r},n}(Qt);!function(t,n){void 0===n&&(n=1),t.init=Wt(n,t)}(Mr);var Er=Mr,Nr=yt(function(t){var n=t;return n.prototype.methods=function(t){return this.method(t)},n.prototype.method=function(t){return new _r(this).name(t)},n.prototype.merge=function(t,n){var r=Er.init(this);return S(n)?r.merge(t):n(r.obj(t)),this},n},Qt),xr=function(t){for(var n=ut(t),r=0;r<=t;)n[r]=r++;return n},Ir=function(t){function n(n){t.call(this,n),this.store=new Set}return t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n,n}(St);Ir.prototype.keys=function(){return xr(this.store.size)},Ir.prototype.add=function(t){return this.store.add(t),this},Ir.prototype.prepend=function(t){return this.store=new Set([t].concat(this.values())),this},Ir.prototype.merge=function(t){for(var n=this,r=Bt(t),e=0;e<r.length;e++)n.store.add(r[e]);return this};var Tr=Ir,Ar=(Wt(0,Set),"onChainUpDown"),Rr="onDone",zr=function(t){function n(n){t.call(this,n),this.data={},this._calls=new Set,this.factory().extend(["optional","required",Ar,Rr]).set("len",0)}return t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n,n.prototype.chainUpDowns=function(t){var n=arguments,r=this;return t.forEach(function(t){r[t]=function(){return r.end(),r.parent[t].apply(r.parent,n)}}),this},n.prototype.props=function(t){var n=this;return t.forEach(function(t){return n.prop(t)}),this},n.prototype.prop=function(t,n){var r=this;return this.tap("len",function(t){return t+1}),!S(this[t])&&Ot(this.has(Ar))?(this.end(),this.get(Ar)()[t](n)):(this[t]=function(e){return S(n)?r.data[t]=e:n(e),r._calls.add(t),r._calls.size===r.get("len")?r.end():r},this)},n.prototype.getData=function(t){return S(t)?this.data:this.data[t]},n.prototype.factory=function(t){var n=this;return this.end=function(r){var e;return t&&!S(t.end)?e=t.end:n.has(Rr)&&(e=n.get(Rr)),e&&(e=e.call(n,n.data,n.parent,n,r)),e&&e!==n?e:n.parent},this},n}(Nr),Dr=x(2,function(t,n){return!P(t)&&!P(n)&&n instanceof t}),Gr=function(t,n){for(var r in t)n(t[r],r,t);return t},Vr=function(t){return Gr(t,function(n,r){t[r]=n})},qr=Bn(/[|\\{}()[\]^$+*?.]/g,"\\$&"),Br=Bn(/\\\*/g,".*"),Fr=function(t){return V(t)?pn(qr(Br(t))):wt(t)?t:pn("(?:)")},$r=function(t,n){return function(){return n.call(this,t.apply(this,arguments))}}(qr,Br),Lr={};Lr.make=function(t,n,r){if(wn.has(t))return wn.get(t);var e=t;if(Tn(e)&&!e.test&&(e.test=e),Tn(e))return e;var o="!"===e[0];return o&&(e=e.slice(1)),e=$r(e),o&&n&&(e="(?!"+e+")"),r&&(e="^"+e+"$"),e=pn(""+e,"i"),e.negated=o,wn.set(t,e),e},Lr.matcher=function(t,n,r,e){n=Bt(n).map(function(t){return Lr.make(t,r,e)}),t=Bt(t);for(var o=n[0].negated,i=[],u=0;u<t.length;u++){for(var s=t[u],c=o,a=0;a<n.length;a++)n[a].test(s)&&(c=!n[a].negated);c&&i.push(s)}return i};var Ur=b(Lr.matcher,Lr),Jr=On.eq,Kr=On.clone,Wr=new Map,Hr=function(t){return t.prototype.observe=function(t,n){var r=this,e=Bt(t),o=e.join("_"),i={};return this.meta(Lt,function(t){var u=Ur(t.key,e);if(0!==u.length){for(var s=0;s<u.length;s++){var c=an(u[s]);hn(i,c,r.get(c))}Wr.has(o)&&Jr(Wr.get(o),i)||(Wr.set(o,Kr(i)),n.call(r,i,r))}})},t},Qr=(gr(L),at("meta")),Xr=function(t){var n=function(t){function n(n){t.call(this,n),this.debug(!!Qr(n)&&n.meta.debug)}return t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n,n}(t);return n.prototype.debug=function(t){return this.meta?(this.meta.debug=!!S(t)||t,this):this},n.prototype.setIfEmpty=function(t,n){return this.has(t)?this:this.set(t,n)},n.prototype.return=Rt,n.prototype.wrap=function(t){return R(t)&&t.call(this,this),this},n},Yr=function(t){return!Nn(t)||B(t)||0===t||""===t},Zr=function(t){return function(){return t}},te=function(t){return function(n){return t.test(n)}},ne=function(t,n,r){var e=g(t);return P(r)?P(n)?te(e):e.test(n):e.test(n,r)},re=function(t,n){return function(r,e){for(var o=0;o<t.length;o++)if(ne(t[o],r,e))return!0;for(var i=0;i<n.length;i++)if(ne(n[i],e,r))return!0;return!1}},ee=["obj","keys","vals","onNonMatch","onMatch","clone"],oe=function(t){function n(n){t.call(this,n),this.call=this.traverse.bind(this),this.extend(ee).keys([]).vals([]).onMatch(function(t,n){n.remove()})}return t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n,n.prototype.traverse=function(t){var n=this.entries(),r=n.obj,e=n.keys,o=n.vals,i=n.onMatch,u=n.onNonMatch,s=n.clone?On(r).clone():r,c=re(e,o);return On(s).forEach(function(t,n,r){r.isRoot||(c(t,n)?i(n,r):u&&u(n,r))}),this.set(1,s),Ot(t)?s:this},n}(Qt),ie=function(t){var n=t.prototype.set;return t.prototype.traverse=function(t){return new oe(this).obj(Yr(t)?this.entries(!0):Ot(t)?this:t)},t.prototype.transform=function(t,n){return this.meta($t,t,n)},t.prototype.set=function(t,r,e){for(var o=this,i=r,u=this.meta($t,t),s=0;s<u.length;s++)i=u[s].call(o,i,o);n.call(this,t,i);var c=this.meta(Lt);if(!c.length)return this;var a={key:e,value:i};S(e)&&(a.key=Tt(i)?Cn(t,i):t);for(var f=0;f<c.length;f++)c[f](a);return this},t.prototype.remap=function(t,n){var r=this,e=Tt(t)?t:{[t]:n};return U(e).forEach(function(t){return r.transform(t,function(n){return r.set(e[t],n),n})}),this},t},ue={has:function(t,n){if(!fn(t,n))return!1;for(var r=an(n),e=0;e<r.length;e++){if(!Tt(t))return!1;if(!(r[e]in t))return!1;t=t[r[e]]}return!0},get:Mn,set:hn,delete:function(t,n){if(fn(t,n))for(var r=an(n),e=0;e<r.length;e++){var o=r[e];if(e===cn(r))return void delete t[o];if(t=t[o],!Tt(t))return}}},se=function(t){return X(t)||q(t)&&t.includes(".")},ce=function(t,n){return!1!==n.meta.dot&&se(t)},ae=function(t){var n=t.prototype.entries,r=t.prototype.set,e=t.prototype.has,o=t.prototype.get,i=t.prototype.delete;return t.prototype.dot=function(t){return this.meta.dot=t,this},t.prototype.set=function(t,e){if(ce(t,this)){var o=t.split(".")[0],i=n.call(this);return ue.set(i,t,e),r.call(this,o,i[o],t)}return r.call(this,t,e)},t.prototype.get=function(t,r){return ce(t,this)?ue.get(n.call(this),t,r):o.call(this,t)},t.prototype.has=function(t){return ce(t,this)?ue.has(n.call(this),t):e.call(this,t)},t.prototype.delete=function(t){return ce(t,this)?ue.delete(n.call(this),t):i.call(this,t)},t},fe=[Hr,Xr,ie,ae],he=Dr(Object);m.Observe=Hr,m.Shorthands=Xr,m.Transform=ie,m.DotProp=ae;var pe=m,le=function(t,n){return t.reduce(function(t,r){return n(t,r),t},{})},ve=x(2,function(t,n,r){for(var e=gr(Nt(t),r),o=X(t),i=gn(t),u=0;u<i.length;u++){var s=o?u:i[u],c=t[s];n(c,s,t)&&(e[s]=c)}return e})("_",function(t){return Nn(t)&&!Yt(t)}),de=function(t){var n=ve(t),r=U(n);return le(r,function(t,r){return t[r]=n[r]})},ye=On.eq,ge=Yn;export default function(t){return t&&t.__esModule?t.default:t}(function(t,n){return n={exports:{}},t(n),n.exports}(function(t){var n=pe();n.chainable=Wt(0,n),n.builder=Wt(0,_r),n.Chain=n,n.compose=pe,n.traverse=On,n.addMethodFactories=_r.add,n.toArr=Bt,n.camelCase=Rn,n.dot=ue,n.matcher=Ur,n.reduce=It,n.clean=de,n.meta=Kt,n.eq=ye,n.types=ge,n.encase=cr,n.curry=x,n.replace=Bn,n.addTypes=n.types.addTypes,n.Chainable=St,n.ChainedSet=Tr,n.ChainedMap=Nr,n.FactoryChain=zr,n.MethodChain=_r,n.MergeChain=Er,n.merge=xt,n.is=An,b(n,n.is),t.exports=n})); //# sourceMappingURL=index.js.map