foop
Version:
interfaces that describe their intentions.
3 lines (2 loc) • 33.9 kB
JavaScript
define(function(){"use strict";function t(n,e,r){return function(){for(var o=arguments,i=[],u=0,s=n,a=0;a<e.length||u<arguments.length;){var c=void 0;c=a<e.length&&(!N(e[a])||u>=o.length)?e[a]:o[u++],i[a++]=c,N(c)||(s-=1)}return s<=0?r.apply(this,i):M(s,t(n,i,r))}}function n(t){return function(){return this[t]}}function e(t){return wt(t)&&!Et(t)&&!xt(t)}function r(t,n){return Ot(n.clone)&&e(t)?u(Mt(t),t,n):t}function o(t,n,o){for(var i=t.slice(),s=0;s<n.length;s++){var a=n[s];S(i[s])?i[s]=r(a,o):e(a)?i[s]=u(t[s],a,o):~t.indexOf(a)||i.push(r(a,o))}return i}function i(t,n,o){var i={};if(e(t))for(var s=U(t),a=0;a<s.length;a++)i[s[a]]=r(t[s[a]],o);for(var c=U(n),l=0;l<c.length;l++){var f=c[l];i[f]=e(n[f])&&t[f]?u(t[f],n[f],o):r(n[f],o)}return i}function u(t,n,e){if(Z(n)){var o=e.arrayMerge;return Z(t)?o(t,n,e):r(n,e)}return i(t,n,e)}function s(t,n){var e=this;return Q(t)?0===t?function(...t){return 0!==t.length?s(t.length,n).apply(e,t):new n}:A(t,function(t,e,r,o,i){var u=arguments.length;return 1===u||u>5?new n(t,e,r):2===u?new n(t,e):3===u?new n(t,e,r):4===u?new n(t,e,r,o):5===u?new n(t,e,r,o,i):void 0}):s(t.length,t)}function a(t,n){return S(this.parents)&&(this.parents=new Set),this.node=t,this.parent=t,this.root=t,this.reset(),this}function c(t){var n=S(t)?this.node:t;if(un(n))return n;var e=Mt(n),r=e;return l(n).forEach(function(t,n,e){if(!x(t)){var o=yn(n);e.isCircular&&Z(n)&&(o=n.slice(0)),pn(r,e.path,o)}}),e}function l(t){return a.getPooled(t)}function f(t){if(Xn(t))return Wn(t);for(var n=t.split("|"),e=(t.split("&"),0);e<n.length;e++)p(n[e]);return Yn(t,function(t){for(var e=0;e<n.length;e++)if(Wn(n[e])(t))return!0;return!1}),Wn(t)}function h(t){var n=Jn(t),e=Wn(n),r="?"+n,o=n+"[]",i="!"+n,u=rn(e,Bn),s=rn(e,Ln(e));return Hn(r)&&Yn(r,u),Hn(o)&&Yn(o,s),Hn(i)&&Yn(i,zn(e)),Wn(t)}function p(t){return V(t)?(k&&console.log("functionType",{fullKey:t}),t):B(t)&&Zn(t)?(k&&console.log("andOrType",{fullKey:t}),f(t)):(k&&console.log("arithmeticType",{fullKey:t},h(t)),h(t))}function g(t,n,e){t[Vn("set-"+n)]=e.set,t[Vn("get-"+n)]=e.get}function y(t,n,e){if(!S(e))for(var r=0;r<e.length;r++)W(n,e[r],be(n,t))}function d(t){return we.getPooled(t)}function v(t){return L(t)?Je(t):nr(t)?{test:er(!1)}:q(t,"test")?t:V(t)?{test:t}:{test:er(!1)}}function m(t,n){var e=S(n)?pr:n,r=t;gr(t)?(r=jt.composer(r),r=Qt.composer(r),r=Ae.composer(r)):r=Ae;for(var o=0;o<e.length;o++)r=e[o](r);return Be(r),r}var b=Object.assign,S=function(t){return void 0===t},_=(process,"shorthands"),j="production"!==process.env.NODE_ENV,k="debug"===process.env.NODE_ENV,w=Symbol.iterator,O=Symbol.hasInstance,E=Symbol.toPrimitive,x=function(t){return null===t},P=function(t){return S(t)||x(t)},C=Object.prototype.isPrototypeOf,T=function(t,n){return!P(t)&&C.call(t,n)},N=function(t){return"_"===t},M=function(t,n){return 1===t?function(t){return n.apply(this,arguments)}:2===t?function(t,e){return n.apply(this,arguments)}:3===t?function(t,e,r){return n.apply(this,arguments)}:4===t?function(t,e,r,o){return n.apply(this,arguments)}:5===t?function(t,e,r,o,i){return n.apply(this,arguments)}:function(){return n.apply(this,arguments)}},A=function(n,e){return M(n,t(n,[],e))},I=function(t){return Object(t)},R=function(t,n){return n in I(t)},q=function(t,n){return!x(t)&&R(t,n)},V=function(t){return"function"==typeof t},z=A(3,function(t,n,e){if(q(t,n)&&V(t[n]))return t[n](e)})(Object.prototype.toString,"call"),D=function(t){return"[object Map]"===z(t)},G=function(t){return"[object Set]"===z(t)},L=function(t){return"string"==typeof t},B=function(t){return L(t)||"[object String]"===z(t)},F=function(t){return!1===t},K=Object.prototype.hasOwnProperty,J=A(2,function(t,n){return!P(t)&&K.call(t,n)}),$=(A(3,function(t,n,e){return!!J(e,t)&&n(e[t])}),function(){}),U=Object.keys,W=function(t,n,e){Object.defineProperty(t,n,b({configurable:!0,enumerable:!0},e))},X=function(t){return"parent"===t||"store"===t||"meta"===t||"className"===t},Y=Array.from,H=function(t,n,e){return{i:0,next:function(){var r=this.i,o=r,i=n[r];return o=t[r],S(o)&&S(i)||e<=r?{value:void 0,done:!0}:(this.i++,{value:[o,i],done:!1})}}},Q=function(t){return"number"==typeof t},Z=Array.isArray,tt=function(t){return Q(t)||"[object Number]"===z(t)},nt=function(t){return tt(t)&&Number.isNaN(t)},et=function(t){return+t},rt=function(t){var n=et(t);return nt(n)?0:0===n||n===-1/0||n===1/0?n:Math.sign(n)*Math.floor(Math.abs(n))},ot=function(t){return(t=rt(t))<0?0:t>4294967295?4294967295:t},it=function(t){if(P(t))return 0;if(Q(t))return ot(t);if(q(t,"length"))return t.length;if(q(t,"size"))return t.size;var n=0;for(var e in t)J(t,e)&&++n;return n},ut=function(t){return t>1?t-1:1===t?1:0},st=function(t){return new Array(ut(t)>200?0:ut(t))},at=function(t){return st(Q(t)?t:Z(t)?t.length:it(t))},ct=function(){for(var t=arguments,n=arguments.length,e=at(n),r=0;r<n;++r)e[r]=t[r];return e},lt=function(t){return A(2,function(n,e){var r=ct.apply(null,arguments);return r[0]=e,r[1]=n,t.apply(this,r)})},ft=lt(J),ht=A(3,function(t,n,e){return!!q(e,t)&&n(e[t])}),pt=ht("get",V),gt=function(t,n,e){return t?V(n)&&(L(t)&&pt(this)?this.get(t)&&n(this):n(this)):V(e)&&e(this),this},yt=function(t){var n=at(t),e=0;return t.forEach(function(t){n[e++]=t}),n},dt=function(t,n,e,r){var o=-1,i=it(t);for(r&&i&&(e=t[++o]);++o<i;)e=n(e,t[o],o,t);return e},vt=function(t,n){return n(t)},mt=function(t,n){var e=t(n);return S(e.composer)&&(e.composer=function(t,n){e[127913]=t;var r=yt(e[127932]);return dt(r,vt,e[127913])},e[127932]=new Set),V(t)&&e[127932].add(t),e},bt=ft("store"),St=(ht("construct",V),ht("destructor",V)),_t=function(t,n){return!X(t)&&(D(n)||G(n)||bt(n))},jt=mt(function(t,e){j&&(t&&t.prototype||console.log({Target:t}));var r=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 r.prototype.destructor=function(){St(t.prototype)&&t.prototype.destructor.call(this),this.clear(),this.parent=void 0},r.prototype.className=r.constructor.name,r.hashCode=function(){},r.prototype.end=n("parent"),r.prototype.when=gt,r.prototype.clear=function(t){var n=this;if(void 0===t&&(t=!0),this.store.clear(),F(t))return this;for(var e=U(this),r=0;r<e.length;r++){var o=e[r];_t(o,n[o])&&n[o].clear()}return this},r.prototype.delete=function(t){return this.store.delete(t),this},r.prototype.has=function(t){return this.store.has(t)},r.prototype.values=function(){return Y(this.store.values())},r.prototype[w]=function(){return H(this.keys(),this.values(),this.store.size)},r.prototype[E]=function(t){return"number"===t&&this.toNumber?this.toNumber():this.toJSON?this.toJSON():this.toString()},W(r.prototype,"length",{enumerable:!1,get:function(){return this.store.size}}),W(r.prototype,O,{enumerable:!1,value:function(t){return t&&(T(r.prototype,t)||bt(t))}}),r},$),kt=function(t){return"object"==typeof t},wt=function(t){return!P(t)&&kt(t)},Ot=function(t){return!0===t},Et=function(t){return"[object RegExp]"===z(t)},xt=function(t){return"[object Date]"===z(t)},Pt=function(t){return Ot(t)||F(t)},Ct=function(t){return Pt(t)||"[object Boolean]"===z(t)},Tt=function(t){return Z(t)?"array":x(t)?"null":typeof t},Nt=A(2,function(t,n){return t.includes(n)}),Mt=function(t){return Z(t)?[]:{}},At=function(t,n,e){if(t===n)return t;var r=b({arrayMerge:o,stringToArray:!0,boolToArray:!1,ignoreTypes:["null","undefined"]},e),i=r.ignoreTypes,s=r.stringToArray,a=r.boolToArray,c=r.clone;return Ot(Nt(i,Tt(t)))?n:Ot(Nt(i,Tt(n)))?t:Ct(t)&&Ct(n)?a?[t,n]:n:B(t)&&B(n)?s?[t,n]:t+n:Z(t)&&B(n)?(c?t.slice(0):t).concat([n]):B(t)&&Z(n)?(c?n.slice(0):n).concat([t]):u(t,n,r)},It=function(t){var n={};return 0!==t.size&&(n=Y(t.entries()).reduce(function(t,n){var e=n[0],r=n[1];return t[e]=r,t},n)),n},Rt=function(t){return!x(t)&&(kt(t)||V(t))},qt=function(t){return function(n){for(var e=U(n),r=0;r<e.length;r++){var o=e[r];if(!X(o)){var i=n[o];R(i,"entries")&&b(t,{[o]:i.entries(!0)||{}})}}return t}},Vt=function(t){return t},zt=Object.freeze||Vt,Dt=[];zt(Dt);var Gt,Lt=Dt,Bt=function(t){return~z(t).indexOf("Iterator")},Ft=function(t){return L(t)?t.includes(",")?t.split(","):[t]:t?Z(t)?t:G(t)||D(t)||t.values?Y(t.values(t)):Bt(t)?Y(t):[t]:[t]},Kt=function(t,n){return Ft(t||[]).concat(Ft(n))},Jt=(process,"transformers"),$t=(process,"observers"),Ut=(process,"decorated"),Wt=function(t){return t===$t},Xt=function(t){function n(n,o,s){if(S(s)){if(S(o))return k&&console.log("META_CALL_GETTER",{[n]:e[n]}),S(e[n])?Lt:0===it(e[n])?Lt:Y(e[n]);if(!Wt(n))return S(e[n])?Lt:Ft(i(n,o));r(n),u(n,o),k&&console.log("META_CALL_SET_SETTER",{key:n,value:o,store:e})}else r(n),u(n,o,s),k&&console.log("META_CALL_MAP_SETTER",{key:n,prop:o,value:s,store:e});return t}if(J(t,"meta"))return t.meta;var e={},r=function(t,n){S(e[t])&&(e[t]=Wt(t)?new Set:new Map)},o=function(t,n){return S(n)?!!it(e[t]):e[t].has(n)},i=function(t,n){return o(t,n)?e[t].get(n):Lt},u=function(t,n,r){var o=e[t];if(G(o))o.add(n);else{var i=o.get(n),u=Kt(i,r);o.set(n,u)}};return n.store=e,n},Yt=s,Ht=(Yt(0,Map),ft("merge")),Qt=mt(function(t){var n=function(t){function n(n){t.call(this,n),this.store=new Map,this.meta=Xt(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),At))},n.prototype.keys=function(){return Y(this.store.keys())},n.prototype.from=function(t){for(var n=this,e=U(t),r=0;r<e.length;r++){var o=e[r],i=t[o],u=n[o];Ht(u)?u.merge(i):V(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(_,t),n[t]=function(e){return n.set(t,e)}}),this},n.prototype.entries=function(t){var n=It(this.store);if(S(t))return n;var e=qt(n);return e(this),e(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},jt),Zt=lt(Nt),tn=function(t){return""===t||!P(t)&&!!kt(t)&&0===it(t)},nn=function(t){return"[object Error]"===z(t)},en=function(t){return"[object Symbol]"===z(t)},rn=A(3,function(t,n,e){return t(e)||n(e)}),on=rn(function(t){return"[object AsyncFunction]"===z(t)},function(t){return"[object Promise]"===z(t)}),un=function(t){return P(t)||L(t)||Q(t)||Pt(t)},sn=function(t){return!(!wt(t)&&!Z(t)&&(un(t)||Et(t)||xt(t)||en(t)||on(t)||nn(t)))},an=function(t){return t-1},cn=A(2,function(t,n){return P(n)?void 0:n[t]})("length"),ln=function(t){return an(cn(t))},fn=function(t){if(Gt||(Gt=new Map),Gt.has(t))return Gt.get(t);if(Z(t))return t;for(var n=t.split("."),e=[],r=0;r<n.length;r++){for(var o=n[r];"\\"===o[ln(o)]&&!S(n[r+1]);)o=o.slice(0,-1)+"."+n[++r];e.push(o)}return Gt.set(t,e),e},hn=function(t,n){return Rt(t)&&B(n)||Z(n)},pn=function(t,n,e){if(hn(t,n))for(var r=fn(n),o=0;o<r.length;o++){var i=r[o];Rt(t[i])||(t[i]={}),o===ln(r)&&(t[i]=e),t=t[i]}},gn=Yt(0,RegExp),yn=function(t){if(wt(t)){var n;Z(t)?n=[]:xt(t)?n=new t.constructor(t.valueOf()):Et(t)?(n=gn(t.src,t.toString().match(/[^/]*$/)[0])).lastIndex=t.lastIndex:n=Object.create(Object.getPrototypeOf(t));for(var e in t)n[e]=t;return n}return k&&console.log("is not obj",t),t},dn=1===process.env.PERF,vn={};zt(vn);var mn=vn,bn=function(t){return Z(t)?t:Rt(t)?U(t):dn?mn:[]},Sn=function(t,n){return!t||!n||t.toString()!==n.toString()},_n=function(t,n,e){if(k&&console.log("eqValue",{x:t,y:n,loose:e}),P(t)||P(n)){if(k&&console.log("null or undef !=",{x:t,y:n}),t!==n)return!1}else if(typeof t!=typeof n){if(!Ot(e)||t!=n)return k&&console.log("typeof !=",{x:t,y:n}),!1}else{if(z(t)!==z(n))return k&&console.log("diff str types",{x:z(t),y:z(n)}),!1;if(wt(t)){if(J(t,"equals"))return t.equals(n);if(k&&console.log("isObjNotNull",{x:t}),Et(t)||Et(n)){if(k&&console.log("regexp",{x:t,y:n}),Sn(t,n))return k&&console.log("regexp !=",{x:t,y:n}),!1}else if(xt(t)||xt(n)){if(k&&console.log("dates",{x:t,y:n}),!xt(t)||!xt(n)||t.getTime()!==n.getTime())return k&&console.log("!= dates",{x:t,y:n}),!1}else if(nn(t)||nn(n)){if(k&&console.log("isError",{x:t,y:n}),!nn(t)||!nn(n)||t.stack!==n.stack)return k&&console.log("!= errors",{x:t,y:n}),!1}else{var r=U(t),o=U(n).length;if(r.length!==o)return k&&console.log("!= obj key length",{xKeys:r,yKeys:o}),!1;for(var i=0;i<r.length;i++)if(!J(n,r[i]))return k&&console.log("!= obj property",{y:n,val:r[i]}),!1}}else{if(z(t)===z(n)&&t!==n)return k&&console.log("same str types - diff values",{s:z(t),x:t,y:n}),!1;if(V(t)||V(n))return k&&(console.log("isFunction(x) && isFunction(y):"),console.log(t.toString()),console.log(n.toString())),!Sn(t,n)||(k&&console.log("x.toString() !== y.toString()",t.toString()!==n.toString()),!1);if(Rt(t)&&Rt(n))return k&&console.log("isObj(x) && isObj(y):"),!1}}return k&&console.log("eqeqeq:",{[z(t)+"X"]:t,[z(n)+"Y"]:n}),!0},jn=function(t){var n=this;if(k&&t instanceof n)throw new Error("Trying to release an instance\n into a pool of a different type.");t.destructor(),n.instancePool.length<n.poolSize&&n.instancePool.push(t)},kn=function(t){var n=this;if(n.instancePool.length){var e=n.instancePool.pop();return e.construct?e.construct(t):n.call(e,t),e}return new n(t)},wn=function(t,n){var e=t;return e.instancePool=[],e.getPooled=n||kn,e.poolSize||(e.poolSize=10),e.release=jn,e};a.prototype.reset=function(){this.path=[],this.key=void 0,this.isAlive=!0,this.isCircular=!1,this.isLeaf=!1,this.isRoot=!0,this.depth=-1},a.prototype.hasParent=function(t,n){return!!Rt(n)&&this.parents.has(n)},a.prototype.addParent=function(t,n){Rt(n)&&this.parents.add(n)},a.prototype.clear=function(){this.parents.clear()},a.prototype.removeParent=function(t,n){this.parents.delete(n)},a.prototype.forEach=function(t){var n=this.iterate(t);return a.release(this),n},a.prototype.stop=function(){this.isAlive=!1},a.prototype.skip=function(){this.skipBranch=!0},a.prototype.checkIteratable=function(t){if(this.isIteratable=sn(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},a.prototype.remove=function(t){if(!S(this.key)){var n=t||this.node;Rt(n)&&(this.removeParent(n),this.skip(),delete n[this.key],delete this.parent[this.key])}},a.prototype.update=function(t){pn(this.root,this.path,t)},a.prototype.destructor=function(){this.node=void 0,this.parent=void 0,this.reset(),this.clear()},a.prototype.iterate=function(t){var n=this;if(!1===this.isAlive)return a.release(this);var e=this.node;D(e)?e=It(e):G(e)&&(e=Ft(e)),this.addParent(this.depth,e);var r=Z(e),o=r||Rt(e);S(this.onBefore)||this.onBefore(this),Ot(this.isRoot)&&(t.call(this,null,e,this),this.isRoot=!1);var i=r||o;if(i&&tn(e))t.call(this,this.key,e,this),this.node=e;else if(i){this.depth=this.path.length;for(var u=r?e:U(e),s=0;s<u.length;s++){if(!1===n.isAlive)return a.release(n);e!==n.node&&(n.parent=e),n.key=r?s:u[s],S(n.onPre)||n.onPre(n);var c=e[n.key];n.checkIteratable(c);var l=n.path.slice(0);n.path.push(n.key),n.depth=n.path.length,t.call(n,n.key,c,n),Ot(n.skipBranch)?n.skipBranch=!1:Ot(n.isCircular)?n.path=l:(Ot(n.isIteratable)&&(n.node=c,n.iterate(t),n.path=l),S(n.onPost)||n.onPost(n),n.path.pop(),n.removeParent(e))}this.depth=this.path.length}else t.call(this,this.depth,e,this);return this.node=e,S(this.onAfter)||this.onAfter(this),this.path.pop(),this.node},a.prototype.pre=function(t){this.onPre=t},a.prototype.post=function(t){this.onPost=t},a.prototype.before=function(t){this.onBefore=t},a.prototype.after=function(t){this.onAfter=t},a.prototype.clone=c,a.prototype.copy=yn,wn(a),l.eq=function(t){return function(n,e,r){k&&console.log("\n");var o=!0,i=e,u=[i],s=t(n),a=function(){o=!1,s.stop()};return k&&console.log("eq?"),s.forEach(function(t,o,s){if(x(t))return!1===_n(i,o,r)?a():void 0;k&&console.log("eq: iterating:");var c=i;wt(i)&&!tn(i)&&(k&&console.log("is leaf, is not empty node, going deeper"),c=i[t],u.push(c)),s.isLeaf||tn(u)||(k&&console.log("is not leaf, has nodes stack, pop"),i=u.pop()),k&&console.log({key:t,y:o,x:c,a:n,b:e});var l=_n(c,o,r);k&&console.log({eqv:l}),!1===l&&a()}),u=void 0,i=void 0,o}}(l),l.clone=c,l.copy=yn;var On=l,En=new Map,xn=function(t,n,e){if(En.has(n))return En.get(n);var r=[];return k&&console.log({value:n}),On(n).forEach(function(n){var e=this.path;k&&console.log("paths",this.path),e.length&&r.push((t?t+".":"")+e.join("."))}),Ot(e)&&(r=r.filter(function(t){return!r.some(function(n){return n!==t&&Zt(n,t)})})),En.set(n,r),r},Pn=Object.prototype.propertyIsEnumerable,Cn=A(2,function(t,n){return Pn.call(t,n)}),Tn=function(t,n,e){if(!hn(t,n))return S(e)?t:e;for(var r=fn(n),o=0;o<r.length;o++){if(!Cn(t,r[o]))return e;if(t=t[r[o]],P(t)){if(o!==ln(r))return e;break}}return t},Nn=rn(B,tt),Mn=function(t){return!P(t)&&!nt(t)},An=function(t){return Nn(t)||Ct(t)||!Mn(t)||nn(t)||Et(t)},In=function(t){return Rt(t)&&0!==U(t).length},Rn=rn(V,Et),qn={isObjWithKeys:In,isObj:Rt,isObjPure:function(t){return wt(t)&&!Z(t)&&!V(t)},isObjNotNull:wt,isFunction:V,isReal:Mn,toS:z,isDate:xt,isRegExp:Et,isError:nn,isBoolean:Ct,isNumber:tt,isString:B,isMap:D,isSet:G,isSymbol:en,isPrototypeOf:T,isArray:Z,isIterator:Bt,isUndefined:S,isNull:x,isNill:P,isTrue:Ot,isMatcher:Rn},Vn=function(t){return t.replace(/\s+/g,"_").replace(/[_.-](\w|$)/g,function(t,n){return n.toUpperCase()})},zn=A(2,function(t,n){return!t(n)}),Dn=A(2,function(t,n){return function(e){return t(e)&&n(e)}}),Gn=A(2,function(t,n){for(var e in n)if(!t(n[e]))return!1;return!0}),Ln=function(t){return Dn(Z,Gn(t))},Bn=Dn(zn(Mn),tn),Fn=A(3,function(t,n,e){return e.replace(t,n)}),Kn=new Qt,Jn=Fn(/[?\[\]!\|]/g,""),$n=function(t){return Vn("is-"+t)},Un=function(t){return function(n){return t===n||t.includes(n)}},Wn=function(t){return Kn.get(t)||Kn.get($n(t))||Un(t)},Xn=function(t){return Kn.has(t)||Kn.get($n(t))},Yn=function(t,n){return Kn.set(t,n)},Hn=zn(Xn),Qn=function(t){return Kn.from(At(Kn.entries(),t))};Qn(qn);var Zn=function(t){return t.includes("|")||t.includes("&")};p.has=Xn,p.get=Wn,p.set=Yn,p.addTypes=Qn,p.map=Kn;var te=p,ne=function(t,n,e){return(e||te(t))(n)},ee=function(t,n){function e(e){if(An(e))return ne(t,e,n);for(var r=xn(!1,e,!0),o=0;o<r.length;o++){var i=r[o]||t,u=Tn(n,i),s=Tn(e,i.split("."));if(!ne(u,s))return!1}return!0}return j&&(e.inspect=function(){return{property:t,nestedSchema:n}},e.toString=function(){return JSON.stringify(e.inspect(),null,2)}),e},re=S,oe=function(t){return Rt(t)&&!re(t)||Z(t)},ie=function(t){for(var n=this,e=this.parent,r=this.entries(),o=r.onValid,i=r.onInvalid,u=r.define,s=r.getSet,a=U(t),c=0;c<a.length;c++){var l=a[c],f=t[l],h=n.newThis().name(l);i&&h.onInvalid(i),o&&h.onValid(o),u&&h.define(),s&&h.getSet();var p=f;if(oe(f)){var g=ee(l,f);j&&(g.schema=f),p=g}e.meta&&e.meta("schema",l,f),h.type(p).build()}return e},ue=A(4,function(t,n,e,r){return function(o,i,u){var s=n(o,i,u);return t(s)?e(s):r(s)}}),se=function(t){return function(){throw j&&console.log(t),t}},ae=function(t,n){return function(e,r,o){var i=z(e),u={[t]:{type:n,arg:{val:e,str:i,json:JSON.stringify(e)}}},s=b(new TypeError(i+" != "+n),u,o);return r&&r.message&&(s.message+=r.message),r&&r.stack&&(s.stack=r.stack),j&&(s.inspect=function(){var t="thrown: "+r,i="compare: "+s.message,u="name: "+s.name,a="arg: "+e+";\nstr: "+z(e)+" "+typeof e+";\njson: "+JSON.stringify(e),c="type: "+n,l="stack: "+s.stack,f="\n----- inspecting on development -----\n";return o&&(f+="meta: "+JSON.stringify(o)+"\n"),f+=t+"\n"+i+"\n"+u+"\n\n",f+=c+"\n"+a,f+="\n\n"+l+"\n-----\n"}),s.reThrow=se(s),s}},ce=A(3,function(t,n,e){return function(r,o,i){var u;try{return u=t(r,o,i),n?n(u):u}catch(t){return e?e(t):t}}}),le=function(t,n){var e,r,o=n?n(t):ce(t),i=function(t,n,i){return o(r,e)(t,n,i)};return i.then=i.onInvalid=function(t){return e=t,i},i.catch=i.onValid=function(t){return r=t,i},i},fe={m:1},he=function(t,n,e){return function(n,r,o){var i=ae(t,r),u=le(n,o),s=e.onCall||e.onSet,a=e.onValid||s,c=e.onInvalid||function(t,n){return i(t,n,fe).reThrow()};return function(n){var e=this;return u.onInvalid(function(r){c.call(e,i(n,r),n,t,e)}).onValid(function(r){a.call(e,n,t,e)}).call(this,n),this}}},pe=ue(zn(F)),ge=function(t,n,e){var r=e.type;if(r){var o=te(r),i=he(t,0,e)(o,r,pe);j&&(i.type=r),this.onCall(i).onSet(i)}},ye=function(t,n){var e=this,r=t[n];return V(r)?function(){e.define(!1),e.onCall(r)}:function(){e.from(r),r.set&&e.onSet(r.set),r.get&&e.onGet(r.get),r.call&&e.onCall(r.call),r.set&&r.get&&e.define().getSet()}},de=function(t){return this.target(t),t.meta=Xt(t),this.plugin(function(n,e){return t.meta(Ut,n),this.returns(function(n){return n||t}).callReturns(!0)})},ve=function(t,n){return this.initial(0).onCall(function(){return n.tap(t,function(t){return t+1})})},me=function(t,n){var e=function(e){return S(e)?n.get(t):n.set(t,e)};return e.autoGetSet=!0,this.onSet(e).onGet(e).onCall(e)},be=Object.getOwnPropertyDescriptor,Se=A(2,function(t,n){return P(n)?t:n}),_e=["onInvalid","onValid","initial","default","type","callReturns","target","onSet","onCall","onGet"],je=Se(!0),ke={},we=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 e=this;console.log("construct"),this.parent=t;var r=this.set.bind(this);this.newThis=function(){return n.getPooled(e.parent)},this.encase=function(t){return r("encase",e.parent[t]||t||!0)},this.returns=function(t,n){return r("returns",t||e.parent).callReturns(n)},this.bind=function(t){return r("bind",S(t)?e.parent:t)},S(this.alias)&&this.setupOnce(),this.plugin(ge)},n.prototype.setupOnce=function(){var t=this;console.log("setup once");var n=this.set.bind(this);this.toNumber=function(){return t.build(0)},this.extend(_e),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,e){return e(t,Ft(n))})},this.plugin=function(n){return t.tap("plugins",function(t,e){return e(t,Ft(n))})},this.camelCase=function(){return n("camel",!0)},this.define=function(t){return n("define",je(t))},this.getSet=function(t){return n("getSet",je(t))},this.autoGetSet=function(){return t.plugin(me)},In(ke)&&U(ke).forEach(function(n){t[n]=function(e){return ke[n].call(t,e)},j&&(t[n].methodFactory=!0)})},n.prototype.destructor=function(){console.log("destructoor"),this.clear(),this.parent=void 0},n.prototype.name=function(t){var n=this,e=t;if(!Z(t)&&Rt(t)){e=U(t);for(var r=0;r<e.length;r++)n.plugin(ye.call(n,t,e[r]))}return this.set("names",e)},n.prototype.schema=function(t){return ie.call(this,t)},n.prototype.build=function(t){for(var e=this,r=this.parent,o=Ft(this.get("names")),i=this.get("camel"),u=0;u<o.length;u++)e._build(i?Vn(o[u]):o[u],r);return this.clear(),delete this.parent,n.release(this),S(t)?r:t},n.prototype._defaults=function(t,n,e){var r=function(e){return n.set(t,e)},o=function(){return n.get(t)};r.defaulted=!0,o.defaulted=!0;var i=e.onCall,u=e.onSet,s=e.onGet;s&&!s.defaulted||this.onGet(o),i&&!i.defaulted||this.onCall(r),u&&!u.defaulted||this.onSet(r)},n.prototype._build=function(t,n){var e,r,o=this,i=function(){return o.entries()};if(J(n,t)){if(r=be(n,t),F(r.configurable))return;e=r.value,j&&(e.decorated=!0),this.onCall(e).onSet(e)}else n[t]&&(e=n[t],j&&(e.decorated=!0),this.onCall(e).onSet(e));var u=i();this._defaults(t,n,u);var s=u.plugins;if(s)for(var a=0;a<s.length;a++)u=i(),s[a].call(o,t,n,u);if((u=i()).encase){var c=he.call(this,t,n,u)(e);j&&(c.encased=e),this.onCall(c).onSet(c),e=c,u=i()}var l=u.getSet,f=u.define,h=u.default,p=u.onGet,d=u.onSet,v=u.onCall,m=u.initial,w=u.bind,O=u.returns,E=u.callReturns,x=u.alias;if(e||(e=function(t){return void 0===t&&(t=h),v.call(n,t)},j&&(e.created=!0)),w&&(e=e.bind(w)),O){var P=e;e=function(){var t=ct.apply(null,arguments),e=P.apply(n,t);return Ot(E)?O.apply(n,[e].concat(t)):O}}S(m)||n.set(t,m),j&&(W(p,"name",{value:Vn(p.name+"+get-"+t)}),W(d,"name",{value:Vn(d.name+"+set-"+t)}),W(v,"name",{value:Vn(v.name+"+call-"+t)}),W(e,"name",{value:Vn(""+t)}),u.type&&(e.type=u.type),m&&(e.initial=m),w&&(e.bound=w),O&&(e.returns=O),x&&(e.alias=x),E&&(e.callReturns=E),p&&(e._get=p),d&&(e._set=d),v!=v&&(e._call=v)),k&&console.log({name:t,defaultValue:h,initial:m,returns:O,onGet:p,onSet:d,method:e.toString()});var C={get:p,set:d},T=f?C:{value:e};r&&(T=b(r,T)),T.value&&T.get&&delete T.value,S(T.writable)||delete T.writable;var N=this.get("target")||n;W(N,t,T),l&&(N.meta&&N.meta(_,t,d),g(N,t,C)),y(t,N,x)},n.prototype.decorate=function(t){if(j&&!t&&!this.parent.parent)throw new Error("must provide parent argument");return de.call(this,t||this.parent.parent)},n.prototype.autoIncrement=function(){return this.plugin(ve)},n}(Qt);wn(we),ke=d.add=function(t){b(ke,t)};var Oe=d,Ee=function(t){return D(t)||t instanceof jt},xe="onExisting",Pe="onValue",Ce="merger",Te="obj",Ne=function(t){function n(n){t.call(this,n),this.extend([xe,Pe,Te]).set(Pe,function(){return!0}).set(Ce,At)}return t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n,n.prototype.merger=function(t){return V(t)?this.set(Ce,t):this.set("opts",t)},n.prototype.merge=function(t){var n=this,e=this.parent,r=function(t){return n.get(t)},o=r(xe),i=r(Pe),u=r("opts"),s=t||r(Te),a=r(Ce),c=e.meta?e.meta(_):mn,l=U(s);if(j&&!s)throw console.log({onExisting:o,opts:u,obj:s,merger:a,shorthands:c,keys:l,parent:e}),new Error("must provide an object to merge");for(var f=0,h=l.length;f<h;f++){var p=l[f],g=s[p];S(c[p])||c[p]===p||(k&&console.log("had a shorthand with a diff key than the object (likely @alias)",{shorthandMethod:c[p],key:p,value:g}),p=c[p]);var y=e[p];i(g,p,n)?Ee(y)?(k&&console.log("has method or shorthand"),e[p].merge(g)):y?(k&&console.log("has method or shorthand",{method:y,key:p,value:g}),function(t,n){var r=function(n,r){return V(e[t])?e[n](r):e.set(n,r)};if(Ot(e.has(t))){var i=e.get(t);S(o)?(k&&console.log("parent has: no onExisting",{existing:i,[t]:n}),r(t,a(i,n,u))):(k&&console.log("parent has: has onExisting",{existing:i,onExisting:o,[t]:n}),r(t,o(i,n,u)))}else k&&console.log("parent does not have",{[t]:n}),r(t,n)}(p,g)):(k&&console.log("went to default",{method:y,key:p,value:g}),e.set(p,g)):k&&console.log("had onValue, was false, ignored",{onValue:i,key:p,value:g})}return e},n}(Qt);!function(t,n){void 0===n&&(n=1),t.init=Yt(n,t)}(Ne);var Me=Ne,Ae=mt(function(t){var n=t;return n.prototype.methods=function(t){return this.method(t)},n.prototype.method=function(t){return new Oe(this).name(t)},n.prototype.merge=function(t,n){var e=Me.init(this);return S(n)?e.merge(t):n(e.obj(t)),this},n},Qt),Ie=function(t){for(var n=at(t),e=0;e<=t;)n[e]=e++;return n},Re=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}(jt);Re.prototype.keys=function(){return Ie(this.store.size)},Re.prototype.add=function(t){return this.store.add(t),this},Re.prototype.prepend=function(t){return this.store=new Set([t].concat(this.values())),this},Re.prototype.merge=function(t){for(var n=this,e=Ft(t),r=0;r<e.length;r++)n.store.add(e[r]);return this};var qe=Re,Ve=(Yt(0,Set),"onChainUpDown"),ze="onDone",De=function(t){function n(n){t.call(this,n),this.data={},this._calls=new Set,this.factory().extend(["optional","required",Ve,ze]).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,e=this;return t.forEach(function(t){e[t]=function(){return e.end(),e.parent[t].apply(e.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 e=this;return this.tap("len",function(t){return t+1}),!S(this[t])&&Ot(this.has(Ve))?(this.end(),this.get(Ve)()[t](n)):(this[t]=function(r){return k&&console.log("called "+t+" with:",r,"calls length is now:",e._calls.size),S(n)?e.data[t]=r:n(r),e._calls.add(t),e._calls.size===e.get("len")?e.end():e},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(e){var r;return t&&!S(t.end)?r=t.end:n.has(ze)&&(r=n.get(ze)),r&&(r=r.call(n,n.data,n.parent,n,e)),r&&r!==n?r:n.parent},this},n}(Ae),Ge=A(2,function(t,n){return!P(t)&&!P(n)&&n instanceof t}),Le=function(t,n){for(var e in t)n(t[e],e,t);return t},Be=function(t){return Le(t,function(n,e){t[e]=n})},Fe=Fn(/[|\\{}()[\]^$+*?.]/g,"\\$&"),Ke=Fn(/\\\*/g,".*"),Je=function(t){return L(t)?gn(Fe(Ke(t))):Et(t)?t:gn("(?:)")},$e=function(t,n){return function(){return n.call(this,t.apply(this,arguments))}}(Fe,Ke),Ue={};Ue.make=function(t,n,e){if(En.has(t))return En.get(t);var r=t;if(Rn(r)&&!r.test&&(r.test=r),Rn(r))return r;var o="!"===r[0];return o&&(r=r.slice(1)),r=$e(r),o&&n&&(r="(?!"+r+")"),e&&(r="^"+r+"$"),r=gn(""+r,"i"),r.negated=o,En.set(t,r),r},Ue.matcher=function(t,n,e,r){n=Ft(n).map(function(t){return Ue.make(t,e,r)}),t=Ft(t);for(var o=n[0].negated,i=[],u=0;u<t.length;u++){for(var s=t[u],a=o,c=0;c<n.length;c++)n[c].test(s)&&(a=!n[c].negated);a&&i.push(s)}return i};var We=b(Ue.matcher,Ue),Xe=On.eq,Ye=On.clone,He=new Map,Qe=function(t){return t.prototype.observe=function(t,n){var e=this;k&&console.log("observe",{properties:t,fn:n});var r=Ft(t),o=r.join("_");k&&console.log("observe",{[o]:r});var i={};return this.meta($t,function(t){var u=We(t.key,r);if(k&&console.log({m:u,key:t.key,objs:He,data:i,hashKey:o}),0!==u.length){for(var s=0;s<u.length;s++){var a=fn(u[s]);pn(i,a,e.get(a))}He.has(o)&&Xe(He.get(o),i)||(He.set(o,Ye(i)),n.call(e,i,e))}})},t},Ze=(Se($),ft("meta")),tr=function(t){var n=function(t){function n(n){t.call(this,n),this.debug(!!Ze(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=Vt,n.prototype.wrap=function(t){return V(t)&&t.call(this,this),this},n},nr=function(t){return!Mn(t)||F(t)||0===t||""===t},er=function(t){return function(){return t}},rr=function(t){return function(n){return t.test(n)}},or=function(t,n,e){var r=v(t);return P(e)?P(n)?rr(r):r.test(n):r.test(n,e)},ir=function(t,n){return function(e,r){for(var o=0;o<t.length;o++)if(or(t[o],e,r))return!0;for(var i=0;i<n.length;i++)if(or(n[i],r,e))return!0;return!1}},ur=["obj","keys","vals","onNonMatch","onMatch","clone"],sr=function(t){function n(n){t.call(this,n),this.call=this.traverse.bind(this),this.extend(ur).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(),e=n.obj,r=n.keys,o=n.vals,i=n.onMatch,u=n.onNonMatch,s=n.clone?On(e).clone():e,a=ir(r,o);return k&&console.log("matcher for traverse...",r,o),On(s).forEach(function(t,n,e){e.isRoot||(a(t,n)?(k&&console.log("------- match ------- ",t,n),i(n,e)):u&&(k&&console.log("------- NONmatch ------- ",t,n),u(n,e)))}),this.set(1,s),Ot(t)?s:this},n}(Qt),ar=function(t){var n=t.prototype.set;return t.prototype.traverse=function(t){return new sr(this).obj(nr(t)?this.entries(!0):Ot(t)?this:t)},t.prototype.transform=function(t,n){return this.meta(Jt,t,n)},t.prototype.set=function(t,e,r){for(var o=this,i=e,u=this.meta(Jt,t),s=0;s<u.length;s++)i=u[s].call(o,i,o);n.call(this,t,i);var a=this.meta($t);if(!a.length)return this;var c={key:r,value:i};S(r)&&(c.key=Rt(i)?xn(t,i):t);for(var l=0;l<a.length;l++)a[l](c);return this},t.prototype.remap=function(t,n){var e=this,r=Rt(t)?t:{[t]:n};return U(r).forEach(function(t){return e.transform(t,function(n){return e.set(r[t],n),n})}),this},t},cr={has:function(t,n){if(!hn(t,n))return!1;for(var e=fn(n),r=0;r<e.length;r++){if(!Rt(t))return!1;if(!(e[r]in t))return!1;t=t[e[r]]}return!0},get:Tn,set:pn,delete:function(t,n){if(hn(t,n))for(var e=fn(n),r=0;r<e.length;r++){var o=e[r];if(r===ln(e))return void delete t[o];if(t=t[o],!Rt(t))return}}},lr=function(t){return Z(t)||B(t)&&t.includes(".")},fr=function(t,n){return!1!==n.meta.dot&&lr(t)},hr=function(t){var n=t.prototype.entries,e=t.prototype.set,r=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,r){if(fr(t,this)){var o=t.split(".")[0],i=n.call(this);return cr.set(i,t,r),e.call(this,o,i[o],t)}return e.call(this,t,r)},t.prototype.get=function(t,e){return fr(t,this)?cr.get(n.call(this),t,e):o.call(this,t)},t.prototype.has=function(t){return fr(t,this)?cr.has(n.call(this),t):r.call(this,t)},t.prototype.delete=function(t){return fr(t,this)?cr.delete(n.call(this),t):i.call(this,t)},t},pr=[Qe,tr,ar,hr],gr=Ge(Object);m.Observe=Qe,m.Shorthands=tr,m.Transform=ar,m.DotProp=hr;var yr=m,dr=function(t,n){return t.reduce(function(t,e){return n(t,e),t},{})},vr=A(2,function(t,n,e){for(var r=Se(Mt(t),e),o=Z(t),i=bn(t),u=0;u<i.length;u++){var s=o?u:i[u],a=t[s];n(a,s,t)&&(r[s]=a)}return r})("_",function(t){return Mn(t)&&!tn(t)}),mr=function(t){var n=vr(t),e=U(n);return dr(e,function(t,e){return t[e]=n[e]})},br=On.eq,Sr=te;return function(t){return t&&t.__esModule?t.default:t}(function(t,n){return n={exports:{}},t(n),n.exports}(function(t){var n=yr();n.chainable=Yt(0,n),n.builder=Yt(0,Oe),n.Chain=n,n.compose=yr,n.traverse=On,n.addMethodFactories=Oe.add,n.toArr=Ft,n.camelCase=Vn,n.dot=cr,n.matcher=We,n.reduce=It,n.clean=mr,n.meta=Xt,n.eq=br,n.types=Sr,n.encase=le,n.curry=A,n.replace=Fn,n.addTypes=n.types.addTypes,n.Chainable=jt,n.ChainedSet=qe,n.ChainedMap=Ae,n.FactoryChain=De,n.MethodChain=Oe,n.MergeChain=Me,n.merge=At,n.is=qn,b(n,n.is),t.exports=n}))});
//# sourceMappingURL=index.js.map