chain-able
Version:
interfaces that describe their intentions.
3 lines (2 loc) • 26 kB
JavaScript
"use strict";function t(t){return z(t)&&!B(t)&&!F(t)}function n(t){return U(t)?[]:{}}function e(e,r){return L(r.clone)&&t(e)?i(n(e),e,r):e}function r(n,r,o){for(var u=n.slice(),a=0;a<r.length;a++){var s=r[a];d(u[a])?u[a]=e(s,o):t(s)?u[a]=i(n[a],s,o):~n.indexOf(s)||u.push(e(s,o))}return u}function o(n,r,o){var u={};if(t(n))for(var a=M(n),s=0;s<a.length;s++)u[a[s]]=e(n[a[s]],o);for(var c=M(r),f=0;f<c.length;f++){var p=c[f];u[p]=t(r[p])&&n[p]?i(n[p],r[p],o):e(r[p],o)}return u}function i(t,n,r){if(U(n)){var i=r.arrayMerge;return U(t)?i(t,n,r):e(n,r)}return o(t,n,r)}function u(t){this.value=t}function a(t,n,e){var r=[],o=[],i=!0;return function t(u){function a(){if(z(p.node)){p.keys&&p.node_===p.node||(p.keys=M(p.node)),p.isLeaf=0===p.keys.length;for(var t=0;t<o.length;t++)if(o[t].node_===u){p.circular=o[t];break}}else p.isLeaf=!0,p.keys=null;p.notLeaf=!p.isLeaf,p.notRoot=!p.isRoot}var c={},f=!0,p={node:e?s(u):u,node_:u,path:[].concat(r),parent:o[o.length-1],parents:o,key:r.slice(-1)[0],isRoot:0===r.length,level:r.length,circular:null,update:function(t,n){p.isRoot||(p.parent.node[p.key]=t),p.node=t,n&&(f=!1)},delete:function(t){delete p.parent.node[p.key],t&&(f=!1)},remove:function(t){d(p.parent)||(U(p.parent.node)?p.parent.node.splice(p.key,1):delete p.parent.node[p.key],t&&(f=!1))},keys:null,before:function(t){c.before=t},after:function(t){c.after=t},pre:function(t){c.pre=t},post:function(t){c.post=t},stop:function(){i=!1},block:function(){f=!1}};if(!i)return p;a();var l=n.call(p,p.node);return!d(l)&&p.update&&p.update(l),c.before&&c.before.call(p,p.node),f?(z(p.node)&&!p.circular&&(o.push(p),a(),yt(p.keys,function(n,o){r.push(n),c.pre&&c.pre.call(p,p.node[n],n);var i=t(p.node[n]);e&&ht(p.node,n)&&(p.node[n]=i.node),i.isLast=o===p.keys.length-1,i.isFirst=0===o,c.post&&c.post.call(p,i),r.pop()}),o.pop()),c.after&&c.after.call(p,p.node),p):p}(t).node}function s(t){if(z(t)){var n;return S(t)?n=H(t.entries()):w(t)&&(n=Y(t)),n=U(t)?[]:F(t)?new Date(t.getTime?t.getTime():t):B(t)?new RegExp(t):ft(t)?{message:t.message}:$(t)?new Boolean(t):pt(t)?new Number(t):k(t)?new String(t):Object.create(vt(t)),yt(M(t),function(e){n[e]=t[e]}),n}return t}function c(t){if(Bt(t))return Lt(t);for(var n=t.split("|"),e=(t.split("&"),0);e<n.length;e++)p(n[e]);return Ft(t,function(t){for(var e=0;e<n.length;e++)if(Lt(n[e])(t))return!0;return!1}),Lt(t)}function f(t){var n=Vt(t),e=Lt(n),r="?"+n,o=n+"[]",i="!"+n,u=Dt(e,qt),a=Dt(e,Kt(e));return $t(r)&&Ft(r,u),$t(o)&&Ft(o,a),$t(i)&&Ft(i,It(e)),Lt(t)}function p(t){return O(t)?t:k(t)&&Wt(t)?c(t):f(t)}function l(t){var n=vt(t);return[].concat(dn(t),gn(t),M(t),n?l(n):[])}function h(t,n,e){t[Rt("set-"+n)]=e.set,t[Rt("get-"+n)]=e.get}function v(t,n,e){if(!d(e))for(var r=0;r<e.length;r++)x(n,e[r],yn(n,t))}function y(t,n){var e=d(n)?te:n,r=t;r=t&&t instanceof Object?Tn.compose(D.compose(t)):Tn;for(var o=0;o<e.length;o++)r=e[o](r)||r||Tn;return r}var d=function(t){return void 0===t},g=Symbol.iterator,m=Symbol.hasInstance,b=Symbol.toPrimitive,_=function(t,n){return Object.prototype.isPrototypeOf.call(t,n)},j=function(t){return Object.prototype.toString.call(t)},S=function(t){return t instanceof Map||"[object Map]"===j(t)},w=function(t){return t instanceof Set||"[object Set]"===j(t)},O=function(t){return"function"==typeof t},E=function(t){return"string"==typeof t},k=function(t){return E(t)||"[object String]"===j(t)},C=function(t){return!1===t},M=Object.keys,N=Object.assign,x=function(t,n,e){Object.defineProperty(t,n,N({configurable:!0,enumerable:!0},e))},T=function(t){return"parent"===t||"store"===t||"meta"===t||"className"===t},R=function(t,n){return!T(t)&&(S(n)||w(n)||n&&n.store)},I=function(t){var n=function(t){function n(n){t.call(this),n&&(this.parent=n),this.className=this.constructor.name}return t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n,n.prototype[g]=function(){var t=this.values(),n=this.store.size,e=this.entries?this.entries():0,r=0===e?new Array(n):M(e);return{i:0,next:function(){var o=this.i,i=o,u=t[o];return e&&(i=r[o]),d(i)&&d(u)||n<=o?{value:void 0,done:!0}:(this.i++,{value:[i,u],done:!1})}}},n.prototype.end=function(){return this.parent},n.prototype.when=function(t,n,e){return t?O(n)&&(k(t)?this.get(t)&&n(this):n(this)):O(e)&&e(this),this},n.prototype.clear=function(t){var n=this;if(this.store.clear(),C(t))return this;for(var e=M(this),r=0;r<e.length;r++){var o=e[r];R(o,n[o])&&n[o].clear()}return this},n.prototype.delete=function(t){return this.store.delete(t),this},n.prototype.has=function(t){return this.store.has(t)},n.prototype.values=function(){var t=[];return this.store.forEach(function(n){return t.push(n)}),t},n.prototype[b]=function(t){return"number"===t&&this.toNumber?this.toNumber():this.toJSON?this.toJSON():this.toString()},n}(t),e=n.prototype;return x(e,"length",{enumerable:!1,get:function(){return this.store.size}}),x(e,m,{enumerable:!1,value:function(t){return t&&(_(e,t)||t.store)}}),n},A=I(function(){});A.compose=I;var D=A,G=function(t){return"object"==typeof t},P=function(t){return null===t},V=function(t){return d(t)||P(t)},z=function(t){return!V(t)&&G(t)},U=Array.isArray,L=function(t){return!0===t},B=function(t){return t instanceof RegExp||"[object RegExp]"===j(t)},F=function(t){return t instanceof Date||"[object Date]"===j(t)},$=function(t){return L(t)||C(t)||"[object Boolean]"===j(t)},J=function(t){return U(t)?"array":P(t)?"null":typeof t},q=function(t,n){return t.includes(n)},K=function(t,n,e){if(t===n)return t;var o=N({arrayMerge:r,stringToArray:!0,boolToArray:!1,ignoreTypes:["null","undefined"]},e||{}),u=o.ignoreTypes,a=o.stringToArray,s=o.boolToArray,c=o.clone;return L(q(u,J(t)))?n:L(q(u,J(n)))?t:$(t)&&$(n)?s?[t,n]:n:k(t)&&k(n)?a?[t,n]:t+n:U(t)&&k(n)?(c?t.slice(0):t).concat([n]):k(t)&&U(n)?(c?n.slice(0):n).concat([t]):i(t,n,o)},W=Array.from,H=function(t){var n={};return 0!==t.size&&(n=W(t.entries()).reduce(function(t,n){var e=n[0],r=n[1];return t[e]=r,t},{})),n},Q=function(t){return function(n){for(var e=M(n),r=0;r<e.length;r++){var o=e[r];if(!T(o)){var i=n[o];i&&O(i.entries)&&N(t,{[o]:i.entries(!0)||{}})}}return t}},X=function(t){return~j(t).indexOf("Iterator")},Y=function(t){return E(t)?t.includes(",")?t.split(","):[t]:t?U(t)?t:w(t)||S(t)||t.values?W(t.values(t)):X(t)?W(t):[t]:[t]},Z=function(t,n){return Y(t||[]).concat(Y(n))},tt=(process,"transformers"),nt=(process,"observers"),et=(process,"shorthands"),rt=(process,"decorated"),ot=function(t){return t===nt},it=function(t){function n(n,o,a){if("DEBUG"===process.env.NODE_ENV&&console.log("USING META",{key:n,prop:o,value:a}),d(a)){if(d(o))return d(e[n])?[]:0===e[n].size?[]:W(e[n].values());if(!ot(n))return d(e[n])?[]:Y(i(n,o));r(n),u(n,o)}else r(n),u(n,o,a);return t}if(t.meta)return t.meta;var e={},r=function(t){d(e[t])&&(e[t]=ot(t)?new Set:new Map)},o=function(t,n){return d(n)?!!e[t].size:e[t].has(n)},i=function(t,n){return o(t,n)?e[t].get(n):[]},u=function(t,n,r){var o=e[t];if(w(o))o.add(n);else{var i=o.get(n),u=Z(i,r);o.set(n,u)}};return n.store=e,n},ut=function(t){return function(t){function n(n){t.call(this,n),this.store=new Map,this.meta=it(this)}return t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n,n.prototype.tap=function(t,n){return this.set(t,n(this.get(t),K))},n.prototype.from=function(t){for(var n=this,e=M(t),r=0;r<e.length;r++){var o=e[r],i=t[o],u=n[o];u&&u.merge?u.merge(i):O(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(et,t),n[t]=function(e){return n.set(t,e)}}),this},n.prototype.entries=function(t){void 0===t&&(t=!1);var n=H(this.store);if(!1===t)return n;var e=Q(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}(t)},at=ut(D);at.compose=ut;var st=at,ct=function(t){return z(t)||O(t)},ft=function(t){return t instanceof Error||"[object Error]"===j(t)},pt=function(t){return"number"==typeof t||"[object Number]"===j(t)},lt=function(){for(var t=arguments,n=arguments.length,e=new Array(n),r=0;r<n;++r)e[r]=t[r];return e},ht=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},vt=Object.getPrototypeOf,yt=function(t,n){if(t.forEach)t.forEach(n);else for(var e=0;e<t.length;e++)n(t[e],e,t)},dt=function(t){return new u(t)},gt=dt;u.prototype.get=function(t){for(var n=this.value,e=0;e<t.length;e++){var r=t[e];if(!n||!ht(n,r)){n=void 0;break}n=n[r]}return n},u.prototype.has=function(t){for(var n=this.value,e=0;e<t.length;e++){var r=t[e];if(!n||!ht(n,r))return!1;n=n[r]}return!0},u.prototype.set=function(t,n){for(var e=this.value,r=0;r<t.length-1;r++){var o=t[r];ht(e,o)||(e[o]={}),e=e[o]}return e[t[r]]=n,n},u.prototype.map=function(t){return a(this.value,t,!0)},u.prototype.forEach=function(t){return this.value=a(this.value,t,!1)},u.prototype.reduce=function(t,n){var e=1===arguments.length,r=e?this.value:n;return this.forEach(function(n){this.isRoot&&e||(r=t.call(this,r,n))}),r},u.prototype.paths=function(){var t=[];return this.forEach(function(){t.push(this.path)}),t},u.prototype.nodes=function(){var t=[];return this.forEach(function(){t.push(this.node)}),t},u.prototype.clone=function(){var t=[],n=[];return function e(r){for(var o=0;o<t.length;o++)if(t[o]===r)return n[o];if(z(r)){var i=s(r);return t.push(r),n.push(i),yt(M(r),function(t){i[t]=e(r[t])}),t.pop(),n.pop(),i}return r}(this.value)},yt(M(u.prototype),function(t){dt[t]=function(n){var e=new u(n);return e[t].apply(e,lt.apply(null,arguments).slice(1))}});var mt,bt=new Map,_t=function(t,n,e){if(bt.has(n))return bt.get(n);var r=[];return gt(n).forEach(function(){var n=this.path;n&&n.length&&r.push((t?t+".":"")+(n.join?n.join("."):n))}),L(e)&&(r=r.filter(function(t){return!r.some(function(n){return n!==t&&q(n,t)})})),bt.set(n,r),r},jt=function(t,n){return Object.prototype.propertyIsEnumerable.call(t,n)},St=function(t){return t.length},wt=function(t){return St(t)-1},Ot=function(t){if(mt||(mt=new Map),mt.has(t))return mt.get(t);if(U(t))return t;for(var n=t.split("."),e=[],r=0;r<n.length;r++){for(var o=n[r];"\\"===o[wt(o)]&&!d(n[r+1]);)o=o.slice(0,-1)+"."+n[++r];e.push(o)}return mt.set(t,e),e},Et=function(t,n){return ct(t)&&k(n)||U(n)},kt=function(t,n,e){if(!Et(t,n))return d(e)?t:e;for(var r=Ot(n),o=0;o<r.length;o++){if(!jt(t,r[o]))return e;if(t=t[r[o]],V(t)){if(o!==wt(r))return e;break}}return t},Ct=function(t){return k(t)||pt(t)},Mt=function(t){return!V(t)&&!Number.isNaN(t)},Nt=function(t){return ct(t)&&0!==M(t).length},xt=function(t){return O(t)||t instanceof RegExp},Tt={isObjWithKeys:Nt,isObj:ct,isObject:ct,isObjStrict:z,isFunction:O,isReal:Mt,toS:j,isDate:F,isRegExp:B,isError:ft,isBoolean:$,isNumber:pt,isString:k,isMap:S,isSet:w,isSymbol:function(t){return"[object Symbol]"===j(t)},isPrototypeOf:_,isArray:U,isIterator:X,isUndefined:d,isNull:P,isMatcher:xt},Rt=function(t){return t.replace(/\s+/g,"_").replace(/[_.-](\w|$)/g,function(t,n){return n.toUpperCase()})},It=function(t){return function(n){return!t(n)}},At=function(t,n){return function(e){return t(e)&&n(e)}},Dt=function(t,n){return function(e){return t(e)||n(e)}},Gt=function(t){return function(n){for(var e in n)if(!t(n[e]))return!1;return!0}},Pt=new st,Vt=function(t){return t.replace(/[?\[\]!\|]/g,"")},zt=function(t){return Rt("is-"+t)},Ut=function(t){return function(n){return t===n||t.includes(n)}},Lt=function(t){return Pt.get(t)||Pt.get(zt(t))||Ut(t)},Bt=function(t){return Pt.has(t)||Pt.get(zt(t))},Ft=function(t,n){return Pt.set(t,n)},$t=It(Bt),Jt=function(t){return Pt.from(K(Pt.entries(),t))};Jt(Tt);var qt=At(It(Mt),function(t){return""===t}),Kt=function(t){return At(U,Gt(t))},Wt=function(t){return t.includes("|")||t.includes("&")};p.has=Bt,p.get=Lt,p.set=Ft,p.addTypes=Jt,p.map=Pt;var Ht,Qt=p,Xt=function(t){return Ct(t)||$(t)||!Mt(t)||ft(t)||B(t)},Yt=function(t,n,e){return(e||Qt(t))(n)},Zt=function(t,n){return function(e){if(Xt(e))return Yt(t,e,n);for(var r=_t(!1,e,!0),o=0;o<r.length;o++){var i=r[o]||t,u=kt(n,i),a=kt(e,i.split("."));if(!Yt(u,a))return!1}return!0}},tn=d,nn=function(t){return ct(t)&&!tn(t)||U(t)},en=function(t){for(var n=this,e=this.parent,r=this.entries(),o=r.onValid,i=r.onInvalid,u=r.define,a=r.getSet,s=M(t),c=0;c<s.length;c++){var f=s[c],p=t[f],l=n.newThis().name(f);i&&l.onInvalid(i),o&&l.onValid(o),u&&l.define(),a&&l.getSet();var h=p;nn(p)&&(h=Zt(f,p)),e.meta&&e.meta("schema",f,p),l.type(h).build()}return e},rn=function(t){return function(){throw t}},on=function(t,n){return function(e,r,o){var i=j(e),u={[t]:{type:n,arg:{val:e,str:i,json:JSON.stringify(e)}}},a=N(new TypeError(i+" != "+n),u,o);return r&&r.message&&(a.message+=r.message),r&&r.stack&&(a.stack=r.stack),a.reThrow=rn(a),a}},un=function(t){return function(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}}}},an=function(t,n){var e,r,o=n?n(t):un(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},sn={m:1},cn=function(t,n,e){return function(n,r,o){var i=on(t,r),u=an(n,o),a=e.onCall||e.onSet,s=e.onValid||a,c=e.onInvalid||function(t,n){return i(t,n,sn).reThrow()};return function(n){var e=this;return u.onInvalid(function(r){c.call(e,i(n,r),n,t,e)}).onValid(function(){s.call(e,n,t,e)}).call(this,n),this}}},fn=(It(C),function(){}),pn=function(t,n){var e=this,r=t[n];return O(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()}},ln=function(t){return this.target(t),t.meta=it(t),this.plugin(function(n){return t.meta(rt,n),this.returns(function(n){return n||t}).callReturns(!0)})},hn=function(t,n){return this.initial(0).onCall(function(){return n.tap(t,function(t){return t+1})})},vn=function(t,n){var e=function(e){return d(e)?n.get(t):n.set(t,e)};return e.autoGetSet=!0,this.onSet(e).onGet(e).onCall(e)},yn=Object.getOwnPropertyDescriptor,dn=Object.getOwnPropertyNames,gn=Object.getOwnPropertySymbols,mn=l,bn=function(t){var n=mn(t);gt(t).forEach(function(){var t=this.value;U(t)||ct(t)||this.remove()});for(var e=0;e<n.length;e++)delete t[e];n=void 0,t=void 0},_n=["onInvalid","onValid","initial","default","type","callReturns","target","onSet","onCall","onGet"],jn=function(t){function n(e){var r=this;t.call(this,e);var o=this.set.bind(this);this.newThis=function(){return new n(e)},this.toNumber=function(){return r.build(0)},this.extend(_n),this.method=this.methods=function(t){return r.length?r.build().methods(t):r.name(t)},this.encase=function(t){return o("encase",e[t]||t||!0)},this.then=this.onValid.bind(this),this.catch=this.onInvalid.bind(this),this.returns=function(t,n){return o("returns",t||e).callReturns(n)},this.chainable=this.returns,this.alias=function(t){return r.tap("alias",function(n,e){return e(n,Y(t))})},this.plugin=function(t){return r.tap("plugins",function(n,e){return e(n,Y(t))})},this.camelCase=function(){return o("camel",!0)};var i=function(t){return!!d(t)||t};this.define=function(t){return o("define",i(t))},this.getSet=function(t){return o("getSet",i(t))},this.bind=function(t){return o("bind",d(t)?e:t)},this.autoGetSet=function(){return r.plugin(vn)},this.plugin(fn),Nt(Ht)&&M(Ht).forEach(function(t){r[t]=function(n){return Ht[t].call(r,n)}})}return t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n,n.prototype.name=function(t){var n=this,e=t;if(!U(t)&&ct(t)){e=M(t);for(var r=0;r<e.length;r++)n.plugin(pn.call(n,t,e[r]))}return this.set("names",e)},n.prototype.schema=function(t){return en.call(this,t)},n.prototype.build=function(t){for(var n=this,e=this.parent,r=Y(this.get("names")),o=this.get("camel"),i=0;i<r.length;i++)n._build(o?Rt(r[i]):r[i],e);return this.clear(),delete this.parent,bn(this),d(t)?e: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,a=e.onGet;a&&!a.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(ht(n,t)){if(r=yn(n,t),C(r.configurable))return;e=r.value,this.onCall(e).onSet(e)}else n[t]&&(e=n[t],this.onCall(e).onSet(e));var u=i();this._defaults(t,n,u);var a=u.plugins;if(a)for(var s=0;s<a.length;s++)u=i(),a[s].call(o,t,n,u);if((u=i()).encase){var c=cn.call(this,t,n,u)(e);this.onCall(c).onSet(c),e=c,u=i()}var f=u.getSet,p=u.define,l=u.default,y=u.onGet,g=u.onSet,m=u.onCall,b=u.initial,_=u.bind,j=u.returns,S=u.callReturns,w=u.alias;if(e||(e=function(t){return void 0===t&&(t=l),m.call(n,t)}),_&&(e=e.bind(_)),j){var O=e;e=function(){var t=lt.apply(null,arguments),e=O.apply(n,t);return L(S)?j.apply(n,[e].concat(t)):j}}d(b)||n.set(t,b);var E={get:y,set:g},k=p?E:{value:e};r&&(k=N(r,k)),k.value&&k.get&&delete k.value,d(k.writable)||delete k.writable;var M=this.get("target")||n;x(M,t,k),f&&(M.meta&&M.meta(et,t,g),h(M,t,E)),v(t,M,w)},n.prototype.decorate=function(t){return ln.call(this,t||this.parent.parent)},n.prototype.autoIncrement=function(){return this.plugin(hn)},n}(st);jn.add=function(t){N(Ht,t)},Ht=jn.add;var Sn=jn,wn=function(t){return S(t)||t instanceof D},On="onExisting",En="onValue",kn="merger",Cn="obj",Mn=function(t){function n(n){t.call(this,n),this.extend([On,En,Cn]).set(En,function(){return!0}).set(kn,K)}return t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n,n.init=function(t){return new n(t)},n.prototype.merger=function(t){return O(t)?this.set(kn,t):this.set("opts",t)},n.prototype.merge=function(t){for(var n=this,e=this.parent,r=function(t){return n.get(t)},o=r(On),i=r(En),u=r("opts"),a=t||r(Cn),s=r(kn),c=e.meta?e.meta(et):{},f=M(a),p=0,l=f.length;p<l;p++){var h=f[p],v=a[h];d(c[h])||c[h]===h||(h=c[h]);var y=e[h];i(v,h,n)&&(wn(y)?e[h].merge(v):y?function(t,n){var r=function(n,r){return O(e[t])?e[n](r):e.set(n,r)};if(L(e.has(t))){var i=e.get(t);d(o)?r(t,s(i,n,u)):r(t,o(i,n,u))}else r(t,n)}(h,v):e.set(h,v))}return e},n}(st),Nn=function(t){return function(t){function n(){t.apply(this,arguments)}return t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n,n.prototype.methods=function(t){return this.method(t)},n.prototype.method=function(t){return new Sn(this).name(t)},n.prototype.merge=function(t,n){var e=Mn.init(this);return d(n)?e.merge(t):n(e.obj(t)),this},n}(t===st?t:st.compose(t))},xn=Nn(st);xn.compose=Nn;var Tn=xn,Rn=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.prototype.add=function(t){return this.store.add(t),this},n.prototype.prepend=function(n){return this.store=new Set([n].concat(t.prototype.values.call(this))),this},n.prototype.merge=function(t){for(var n=this,e=Y(t),r=0;r<e.length;r++)n.store.add(e[r]);return this},n}(D),In="onChainUpDown",An="onDone",Dn=function(t){function n(n){t.call(this,n),this.data={},this._calls=new Set,this.factory().extend(["optional","required",In,An]).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}),!d(this[t])&&L(this.has(In))?(this.end(),this.get(In)()[t](n)):(this[t]=function(r){return d(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 d(t)?this.data:this.data[t]},n.prototype.factory=function(t){var n=this;return this.end=function(e){var r;return t&&!d(t.end)?r=t.end:n.has(An)&&(r=n.get(An)),r&&(r=r.call(n,n.data,n.parent,n,e)),r&&r!==n?r:n.parent},this},n}(Tn),Gn=function(t,n){return t==n},Pn=function(t,n,e){var r=!0,o=n;return gt(t).forEach(function(t){var i=function(){r=!1};if(!this.isRoot){if(!G(o))return i();o=o[this.key]}var u=o;if(this.post(function(){o=u}),this.circular)gt(n).get(this.circular.path)!==u&&i();else if(V(u)||V(t))u!==t&&i();else if(typeof u!=typeof t)L(e)&&Gn(u,t)||i();else if(u.__proto__!==t.__proto__)i();else if(u===t);else if(z(u))if(B(u)||B(t))u&&t&&u.toString()===t.toString()||i();else if(F(u)||F(t))F(u)&&F(t)&&u.getTime()===t.getTime()||i();else{var a=M(u),s=M(t).length;if(a.length!==s)return i();for(var c=0;c<a.length;c++)ht(t,a[c])||i()}else j(u)===j(t)&&u!==t?i():j(u)!==j(t)&&i()}),r},Vn=function(t){return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")},zn=function(t){return Vn(t).replace(/\\\*/g,".*")},Un={};Un.make=function(t,n,e){if(bt.has(t))return bt.get(t);var r=t;if(xt(r)&&!r.test&&(r.test=r),xt(r))return r;var o="!"===r[0];return o&&(r=r.slice(1)),r=zn(r),o&&n&&(r="(?!"+r+")"),e&&(r="^"+r+"$"),r=new RegExp(""+r,"i"),r.negated=o,bt.set(t,r),r},Un.matcher=function(t,n,e,r){n=Y(n).map(function(t){return Un.make(t,e,r)}),t=Y(t);for(var o=n[0].negated,i=[],u=0;u<t.length;u++){for(var a=t[u],s=o,c=0;c<n.length;c++)n[c].test(a)&&(s=!n[c].negated);s&&i.push(a)}return i};var Ln=N(Un.matcher,Un),Bn={has:function(t,n){if(!Et(t,n))return!1;for(var e=Ot(n),r=0;r<e.length;r++){if(!ct(t))return!1;if(!(e[r]in t))return!1;t=t[e[r]]}return!0},get:kt,set:function(t,n,e){if(Et(t,n))for(var r=Ot(n),o=0;o<r.length;o++){var i=r[o];ct(t[i])||(t[i]={}),o===wt(r)&&(t[i]=e),t=t[i]}},delete:function(t,n){if(Et(t,n))for(var e=Ot(n),r=0;r<e.length;r++){var o=e[r];if(r===wt(e))return void delete t[o];if(t=t[o],!ct(t))return}}},Fn=new Map,$n=function(t){return function(t){function n(){t.apply(this,arguments)}return t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n,n.prototype.observe=function(t,n){var e=this,r=Y(t),o=r.join("_"),i={};return this.meta(nt,function(t){for(var u=Ln(t.key,r),a=0;a<u.length;a++){var s=Ot(u[a]);Bn.set(i,s,e.get(s))}Fn.has(o)&&Pn(Fn.get(o),i)||(Fn.set(o,gt(i).clone()),n.call(e,i,e))})},n}(t)},Jn=function(t){return function(t){function n(n){t.call(this,n),n&&n.meta?this.meta.debug=n.meta.debug:this.debug(!1)}return t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n,n.prototype.debug=function(t){return this.meta.debug=!!d(t)||t,this},n.prototype.setIfEmpty=function(t,n){return C(this.has(t))?this.set(t,n):this},n.prototype.return=function(t){return t},n.prototype.wrap=function(t){return O(t)&&t.call(this,this),this},n}(t)},qn=function(t,n,e){return k(t)?!!new RegExp(Vn(t)).test(n):O(t)&&!t.test?!!t(n):!!t.test(n,e)},Kn=function(t,n){return function(e,r){for(var o=0;o<t.length;o++)if(qn(t[o],e,r))return!0;for(var i=0;i<n.length;i++)if(qn(n[i],r,e))return!0;return!1}},Wn=["obj","keys","vals","onNonMatch","onMatch","clone"],Hn=function(t){function n(n){t.call(this,n),this.call=this.traverse.bind(this),this.extend(Wn).keys([]).vals([]).onMatch(function(t,n){return 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,a=n.clone?gt(e).clone():e,s=Kn(r,o);return gt(e).forEach(function(t){s(this.key,t)?i(t,this):u&&u(t,this)}),this.set(1,a),L(t)?a:this},n.prototype.traversed=function(){return this.get(1)},n}(st),Qn=function(t){return function(t){function n(){t.apply(this,arguments)}return t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n,n.prototype.traverse=function(t){return void 0===t&&(t=!1),new Hn(this).obj(C(t)?this.entries(!0):L(t)?this:t)},n.prototype.transform=function(t,n){return this.meta(tt,t,n)},n.prototype.set=function(n,e,r){for(var o=this,i=e,u=this.meta(tt,n),a=0;a<u.length;a++)i=u[a].call(o,i,o);t.prototype.set.call(this,n,i);var s={key:r,value:i};d(r)&&(s.key=ct(i)?_t(n,i):n);for(var c=this.meta(nt),f=0;f<c.length;f++)c[f](s);return this},n.prototype.remap=function(t,n){var e=this,r=t;return ct(t)||(r={[t]:n}),M(r).forEach(function(t){return e.transform(t,function(n){return e.set(r[t],n),n})}),this},n}(t)},Xn=function(t){return U(t)||k(t)&&t.includes(".")},Yn=function(t,n){return!1!==n.meta.dot&&Xn(t)},Zn=function(t){return function(t){function n(){t.apply(this,arguments)}return t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n,n.prototype.dot=function(t){return this.meta.dot=t,this},n.prototype.set=function(n,e){if(Yn(n,this)){var r=n.split(".").shift(),o=t.prototype.entries.call(this);return Bn.set(o,n,e),t.prototype.set.call(this,r,o[r],n)}return t.prototype.set.call(this,n,e)},n.prototype.get=function(n,e){return Yn(n,this)?Bn.get(t.prototype.entries.call(this),n,e):t.prototype.get.call(this,n)},n.prototype.has=function(n){return Yn(n,this)?Bn.has(t.prototype.entries.call(this),n):t.prototype.has.call(this,n)},n.prototype.delete=function(n){return Yn(n,this)?Bn.delete(t.prototype.entries.call(this),n):t.prototype.delete.call(this,n)},n}(t)},te=[$n,Jn,Qn,Zn];y.Observe=$n,y.Shorthands=Jn,y.Transform=Qn,y.DotProp=Zn;var ne=y,ee=function(t){return U(t)&&0!==t.length},re=function(t){return M(t).reduce(function(n,e){var r=t[e];return Mt(r)&&(ee(r)||Nt(r))&&(n[e]=r),n},{})},oe=Qt,ie=function(t){return t&&t.__esModule?t.default:t}(function(t,n){return n={exports:{}},t(n),n.exports}(function(t){var n=ne();n.chainable=function(t){return new n(t)},n.builder=function(t){return new Sn(t)},n.Chain=n,n.compose=ne,n.traverse=gt,n.addMethodFactories=Sn.add,n.toArr=Y,n.camelCase=Rt,n.dot=Bn,n.matcher=Ln,n.is=Tt,n.reduce=H,n.clean=re,n.meta=it,n.eq=Pn,n.types=oe,n.addTypes=n.types.addTypes,n.Chainable=D,n.ChainedSet=Rn,n.ChainedMap=Tn,n.FactoryChain=Dn,n.MethodChain=Sn,n.MergeChain=Mn,n.merge=K,t.exports=n}));module.exports=ie;
//# sourceMappingURL=index.js.map