From 17b5cd256a8fb34fd58593674da436012b72ed7f Mon Sep 17 00:00:00 2001 From: KaniRobinson Date: Fri, 12 Oct 2018 10:36:18 +0100 Subject: [PATCH] Build for 0.2.0 --- dist/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/index.js b/dist/index.js index d8b86b1..7d481e9 100644 --- a/dist/index.js +++ b/dist/index.js @@ -13,4 +13,4 @@ * @author Feross Aboukhadijeh * @license MIT */ -t.exports=function(t){return null!=t&&(n(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&n(t.slice(0,0))}(t)||!!t._isBuffer)}},function(t,e,n){"use strict";var r=n(2),o=n(0),i=n(40),u=n(41);function a(t){this.defaults=t,this.interceptors={request:new i,response:new i}}a.prototype.request=function(t){"string"==typeof t&&(t=o.merge({url:arguments[0]},arguments[1])),(t=o.merge(r,{method:"get"},this.defaults,t)).method=t.method.toLowerCase();var e=[u,void 0],n=Promise.resolve(t);for(this.interceptors.request.forEach(function(t){e.unshift(t.fulfilled,t.rejected)}),this.interceptors.response.forEach(function(t){e.push(t.fulfilled,t.rejected)});e.length;)n=n.then(e.shift(),e.shift());return n},o.forEach(["delete","get","head","options"],function(t){a.prototype[t]=function(e,n){return this.request(o.merge(n||{},{method:t,url:e}))}}),o.forEach(["post","put","patch"],function(t){a.prototype[t]=function(e,n,r){return this.request(o.merge(r||{},{method:t,url:e,data:n}))}}),t.exports=a},function(t,e,n){"use strict";var r=n(0);t.exports=function(t,e){r.forEach(t,function(n,r){r!==e&&r.toUpperCase()===e.toUpperCase()&&(t[e]=n,delete t[r])})}},function(t,e,n){"use strict";var r=n(0),o=n(5),i=n(7),u=n(22),a=n(23),c=n(3),s="undefined"!=typeof window&&window.btoa&&window.btoa.bind(window)||n(24);t.exports=function(t){return new Promise(function(e,f){var l=t.data,p=t.headers;r.isFormData(l)&&delete p["Content-Type"];var h=new XMLHttpRequest,d="onreadystatechange",y=!1;if("undefined"==typeof window||!window.XDomainRequest||"withCredentials"in h||a(t.url)||(h=new window.XDomainRequest,d="onload",y=!0,h.onprogress=function(){},h.ontimeout=function(){}),t.auth){var v=t.auth.username||"",m=t.auth.password||"";p.Authorization="Basic "+s(v+":"+m)}if(h.open(t.method.toUpperCase(),i(t.url,t.params,t.paramsSerializer),!0),h.timeout=t.timeout,h[d]=function(){if(h&&(4===h.readyState||y)&&(0!==h.status||h.responseURL&&0===h.responseURL.indexOf("file:"))){var n="getAllResponseHeaders"in h?u(h.getAllResponseHeaders()):null,r={data:t.responseType&&"text"!==t.responseType?h.response:h.responseText,status:1223===h.status?204:h.status,statusText:1223===h.status?"No Content":h.statusText,headers:n,config:t,request:h};o(e,f,r),h=null}},h.onerror=function(){f(c("Network Error",t,null,h)),h=null},h.ontimeout=function(){f(c("timeout of "+t.timeout+"ms exceeded",t,"ECONNABORTED",h)),h=null},r.isStandardBrowserEnv()){var g=n(25),_=(t.withCredentials||a(t.url))&&t.xsrfCookieName?g.read(t.xsrfCookieName):void 0;_&&(p[t.xsrfHeaderName]=_)}if("setRequestHeader"in h&&r.forEach(p,function(t,e){void 0===l&&"content-type"===e.toLowerCase()?delete p[e]:h.setRequestHeader(e,t)}),t.withCredentials&&(h.withCredentials=!0),t.responseType)try{h.responseType=t.responseType}catch(e){if("json"!==t.responseType)throw e}"function"==typeof t.onDownloadProgress&&h.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&h.upload&&h.upload.addEventListener("progress",t.onUploadProgress),t.cancelToken&&t.cancelToken.promise.then(function(t){h&&(h.abort(),f(t),h=null)}),void 0===l&&(l=null),h.send(l)})}},function(t,e,n){"use strict";var r=n(0),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];t.exports=function(t){var e,n,i,u={};return t?(r.forEach(t.split("\n"),function(t){if(i=t.indexOf(":"),e=r.trim(t.substr(0,i)).toLowerCase(),n=r.trim(t.substr(i+1)),e){if(u[e]&&o.indexOf(e)>=0)return;u[e]="set-cookie"===e?(u[e]?u[e]:[]).concat([n]):u[e]?u[e]+", "+n:n}}),u):u}},function(t,e,n){"use strict";var r=n(0);t.exports=r.isStandardBrowserEnv()?function(){var t,e=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function o(t){var r=t;return e&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return t=o(window.location.href),function(e){var n=r.isString(e)?o(e):e;return n.protocol===t.protocol&&n.host===t.host}}():function(){return!0}},function(t,e,n){"use strict";var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function o(){this.message="String contains an invalid character"}o.prototype=new Error,o.prototype.code=5,o.prototype.name="InvalidCharacterError",t.exports=function(t){for(var e,n,i=String(t),u="",a=0,c=r;i.charAt(0|a)||(c="=",a%1);u+=c.charAt(63&e>>8-a%1*8)){if((n=i.charCodeAt(a+=.75))>255)throw new o;e=e<<8|n}return u}},function(t,e,n){"use strict";var r=n(0);t.exports=r.isStandardBrowserEnv()?{write:function(t,e,n,o,i,u){var a=[];a.push(t+"="+encodeURIComponent(e)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(o)&&a.push("path="+o),r.isString(i)&&a.push("domain="+i),!0===u&&a.push("secure"),document.cookie=a.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(t,e,n){"use strict";var r=n(0),o=n(5),i=n(7),u=n(8),a=n(9),c=n(10).http,s=n(10).https,f=n(11),l=n(38),p=n(39),h=n(3),d=n(6);t.exports=function(t){return new Promise(function(e,n){var y,v=t.data,m=t.headers;if(m["User-Agent"]||m["user-agent"]||(m["User-Agent"]="axios/"+p.version),v&&!r.isStream(v)){if(Buffer.isBuffer(v));else if(r.isArrayBuffer(v))v=new Buffer(new Uint8Array(v));else{if(!r.isString(v))return n(h("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",t));v=new Buffer(v,"utf-8")}m["Content-Length"]=v.length}var g=void 0;t.auth&&(g=(t.auth.username||"")+":"+(t.auth.password||""));var _=f.parse(t.url),b=_.protocol||"http:";if(!g&&_.auth){var w=_.auth.split(":");g=(w[0]||"")+":"+(w[1]||"")}g&&delete m.Authorization;var O="https:"===b,x=O?t.httpsAgent:t.httpAgent,C={path:i(_.path,t.params,t.paramsSerializer).replace(/^\?/,""),method:t.method,headers:m,agent:x,auth:g};t.socketPath?C.socketPath=t.socketPath:(C.hostname=_.hostname,C.port=_.port);var j,k=t.proxy;if(!k&&!1!==k){var A=b.slice(0,-1)+"_proxy",E=process.env[A]||process.env[A.toUpperCase()];if(E){var R=f.parse(E);if(k={host:R.hostname,port:R.port},R.auth){var P=R.auth.split(":");k.auth={username:P[0],password:P[1]}}}}if(k&&(C.hostname=k.host,C.host=k.host,C.headers.host=_.hostname+(_.port?":"+_.port:""),C.port=k.port,C.path=b+"//"+_.hostname+(_.port?":"+_.port:"")+C.path,k.auth)){var S=new Buffer(k.auth.username+":"+k.auth.password,"utf8").toString("base64");C.headers["Proxy-Authorization"]="Basic "+S}t.transport?j=t.transport:0===t.maxRedirects?j=O?a:u:(t.maxRedirects&&(C.maxRedirects=t.maxRedirects),j=O?s:c),t.maxContentLength&&t.maxContentLength>-1&&(C.maxBodyLength=t.maxContentLength);var F=j.request(C,function(r){if(!F.aborted){clearTimeout(y),y=null;var i=r;switch(r.headers["content-encoding"]){case"gzip":case"compress":case"deflate":i=i.pipe(l.createUnzip()),delete r.headers["content-encoding"]}var u=r.req||F,a={status:r.statusCode,statusText:r.statusMessage,headers:r.headers,config:t,request:u};if("stream"===t.responseType)a.data=i,o(e,n,a);else{var c=[];i.on("data",function(e){c.push(e),t.maxContentLength>-1&&Buffer.concat(c).length>t.maxContentLength&&n(h("maxContentLength size of "+t.maxContentLength+" exceeded",t,null,u))}),i.on("error",function(e){F.aborted||n(d(e,t,null,u))}),i.on("end",function(){var r=Buffer.concat(c);"arraybuffer"!==t.responseType&&(r=r.toString("utf8")),a.data=r,o(e,n,a)})}}});F.on("error",function(e){F.aborted||n(d(e,t,null,F))}),t.timeout&&!y&&(y=setTimeout(function(){F.abort(),n(h("timeout of "+t.timeout+"ms exceeded",t,"ECONNABORTED",F))},t.timeout)),t.cancelToken&&t.cancelToken.promise.then(function(t){F.aborted||(F.abort(),n(t))}),r.isStream(v)?v.pipe(F):F.end(v)})}},function(t,e){t.exports=require("assert")},function(t,e){t.exports=require("stream")},function(t,e,n){"undefined"==typeof process||"renderer"===process.type?t.exports=n(30):t.exports=n(32)},function(t,e,n){function r(){var t;try{t=e.storage.debug}catch(t){}return!t&&"undefined"!=typeof process&&"env"in process&&(t=process.env.DEBUG),t}(e=t.exports=n(12)).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},e.formatArgs=function(t){var n=this.useColors;if(t[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+t[0]+(n?"%c ":" ")+"+"+e.humanize(this.diff),!n)return;var r="color: "+this.color;t.splice(1,0,r,"color: inherit");var o=0,i=0;t[0].replace(/%[a-zA-Z%]/g,function(t){"%%"!==t&&"%c"===t&&(i=++o)}),t.splice(i,0,r)},e.save=function(t){try{null==t?e.storage.removeItem("debug"):e.storage.debug=t}catch(t){}},e.load=r,e.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},e.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(t){}}(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.formatters.j=function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}},e.enable(r())},function(t,e){var n=1e3,r=60*n,o=60*r,i=24*o,u=365.25*i;function a(t,e,n){if(!(t0)return function(t){if((t=String(t)).length>100)return;var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(t);if(!e)return;var a=parseFloat(e[1]);switch((e[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return a*u;case"days":case"day":case"d":return a*i;case"hours":case"hour":case"hrs":case"hr":case"h":return a*o;case"minutes":case"minute":case"mins":case"min":case"m":return a*r;case"seconds":case"second":case"secs":case"sec":case"s":return a*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}(t);if("number"===c&&!1===isNaN(t))return e.long?function(t){return a(t,i,"day")||a(t,o,"hour")||a(t,r,"minute")||a(t,n,"second")||t+" ms"}(t):function(t){if(t>=i)return Math.round(t/i)+"d";if(t>=o)return Math.round(t/o)+"h";if(t>=r)return Math.round(t/r)+"m";if(t>=n)return Math.round(t/n)+"s";return t+"ms"}(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}},function(t,e,n){var r=n(33),o=n(34);(e=t.exports=n(12)).init=function(t){t.inspectOpts={};for(var n=Object.keys(e.inspectOpts),r=0;r=2&&(e.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(t){}function u(){return process.env.DEBUG}e.inspectOpts=Object.keys(process.env).filter(function(t){return/^debug_/i.test(t)}).reduce(function(t,e){var n=e.substring(6).toLowerCase().replace(/_([a-z])/g,function(t,e){return e.toUpperCase()}),r=process.env[e];return r=!!/^(yes|on|true|enabled)$/i.test(r)||!/^(no|off|false|disabled)$/i.test(r)&&("null"===r?null:Number(r)),t[n]=r,t},{}),e.formatters.o=function(t){return this.inspectOpts.colors=this.useColors,o.inspect(t,this.inspectOpts).split("\n").map(function(t){return t.trim()}).join(" ")},e.formatters.O=function(t){return this.inspectOpts.colors=this.useColors,o.inspect(t,this.inspectOpts)},e.enable(u())},function(t,e){t.exports=require("tty")},function(t,e){t.exports=require("util")},function(t,e,n){"use strict";const r=n(36),o=n(37),i=process.env;let u;function a(t){return function(t){return 0!==t&&{level:t,hasBasic:!0,has256:t>=2,has16m:t>=3}}(function(t){if(!1===u)return 0;if(o("color=16m")||o("color=full")||o("color=truecolor"))return 3;if(o("color=256"))return 2;if(t&&!t.isTTY&&!0!==u)return 0;const e=u?1:0;if("win32"===process.platform){const t=r.release().split(".");return Number(process.versions.node.split(".")[0])>=8&&Number(t[0])>=10&&Number(t[2])>=10586?Number(t[2])>=14931?3:2:1}if("CI"in i)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(t=>t in i)||"codeship"===i.CI_NAME?1:e;if("TEAMCITY_VERSION"in i)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(i.TEAMCITY_VERSION)?1:0;if("truecolor"===i.COLORTERM)return 3;if("TERM_PROGRAM"in i){const t=parseInt((i.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(i.TERM_PROGRAM){case"iTerm.app":return t>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(i.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(i.TERM)?1:"COLORTERM"in i?1:(i.TERM,e)}(t))}o("no-color")||o("no-colors")||o("color=false")?u=!1:(o("color")||o("colors")||o("color=true")||o("color=always"))&&(u=!0),"FORCE_COLOR"in i&&(u=0===i.FORCE_COLOR.length||0!==parseInt(i.FORCE_COLOR,10)),t.exports={supportsColor:a,stdout:a(process.stdout),stderr:a(process.stderr)}},function(t,e){t.exports=require("os")},function(t,e,n){"use strict";t.exports=((t,e)=>{e=e||process.argv;const n=t.startsWith("-")?"":1===t.length?"-":"--",r=e.indexOf(n+t),o=e.indexOf("--");return-1!==r&&(-1===o||r=0?i=a:(i=o+a)<0&&(i=0);ie)return 1;if(t=a)return s;var f=n[c];return s*("desc"===f?-1:1)}}return t.index-e.index}(t,e,n)})},pickBy:function(t,e){return Object.keys(t).reduce(function(n,r){var o=t[r];return e(o,r)&&(n[r]=o),n},{})}},c=function(){return function(t){this.model=t}}(),s=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),f=function(t){function e(e,n){var r=t.call(this,e)||this;return r.mutator=n,r}return s(e,t),e.prototype.mutate=function(t,e){var n=this.mutator||this.model.mutators()[e];return n?n(t):t},e}(c),l=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),p=function(t){function e(e,n,r){var o=t.call(this,e,r)||this;return o.value=n,o}return l(e,t),e.prototype.fill=function(t){return void 0!==t?t:this.value},e.prototype.make=function(t,e,n,r){return this.mutate(this.fill(t),n)},e}(f),h=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),d=function(t){function e(e){var n=t.call(this,e)||this;return n.value=1,n}return h(e,t),e.prototype.fill=function(t){return t},e.prototype.make=function(t,e,n,r){return"number"==typeof t?t:null},e}(f),y=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),v=function(t){function e(e,n,r){var o=t.call(this,e,r)||this;return o.value=n,o}return y(e,t),e.prototype.fill=function(t){return void 0===t?this.value:"string"==typeof t?t:t+""},e.prototype.make=function(t,e,n,r){return this.mutate(this.fill(t),n)},e}(f),m=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),g=function(t){function e(e,n,r){var o=t.call(this,e,r)||this;return o.value=n,o}return m(e,t),e.prototype.fill=function(t){return void 0===t?this.value:"number"==typeof t?t:"string"==typeof t?parseFloat(t):"boolean"==typeof t&&t?1:0},e.prototype.make=function(t,e,n,r){return this.mutate(this.fill(t),n)},e}(f),b=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),w=function(t){function e(e,n,r){var o=t.call(this,e,r)||this;return o.value=n,o}return b(e,t),e.prototype.fill=function(t){if(void 0===t)return this.value;if("boolean"==typeof t)return t;if("string"==typeof t){if(0===t.length)return!1;var e=parseInt(t,0);return!!isNaN(e)||!!e}return"number"==typeof t&&!!t},e.prototype.make=function(t,e,n,r){return this.mutate(this.fill(t),n)},e}(f),O=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),x=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return O(e,t),e.prototype.fillOne=function(t){return void 0===t?null:"object"==typeof t?null:t},e.prototype.fillMany=function(t){return Array.isArray(t)?t:[]},e.prototype.getRelation=function(t,e){var n=t.newPlainQuery(e);return this.addEagerConstraint(t,n),n},e.prototype.getKeys=function(t,e){return t.map(function(t){return t[e]})},e.prototype.addEagerConstraint=function(t,e){for(var n in t.load)t.load[n].forEach(function(t){t(e)})},e.prototype.mapSingleRelations=function(t,e){return t.reduce(function(t,n){return t[n[e]]=n,t},{})},e.prototype.mapManyRelations=function(t,e){return t.reduce(function(t,n){var r=n[e];return t[r]||(t[r]=[]),t[r].push(n),t},{})},e.prototype.isOneRelation=function(t){return!Array.isArray(t)&&null!==t&&"object"==typeof t},e}(c),C=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),j=function(t){function e(e,n,r,o){var i=t.call(this,e)||this;return i.related=i.model.relation(n),i.foreignKey=r,i.localKey=o,i}return C(e,t),e.prototype.define=function(t){return t.one(this.related)},e.prototype.attach=function(t,e,n){var r=n[this.related.entity];r&&r[t]&&void 0===r[t][this.foreignKey]&&(e[this.localKey]||(e[this.localKey]=e.$id),r[t][this.foreignKey]=e[this.localKey])},e.prototype.fill=function(t){return this.fillOne(t)},e.prototype.make=function(t,e,n,r){return void 0===r&&(r=!1),this.isOneRelation(t)?this.related.make(t,r):null},e.prototype.load=function(t,e,n){var r=this,o=this.getRelation(t,this.related.entity);o.where(this.foreignKey,this.getKeys(e,this.localKey));var i=this.mapSingleRelations(o.get(),this.foreignKey);e.forEach(function(t){var e=i[t[r.localKey]];t[n]=e||null})},e}(x),k=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),A=function(t){function e(e,n,r,o){var i=t.call(this,e)||this;return i.parent=i.model.relation(n),i.foreignKey=r,i.ownerKey=o,i}return k(e,t),e.prototype.define=function(t){return t.one(this.parent)},e.prototype.attach=function(t,e,n){void 0===e[this.foreignKey]&&(e[this.foreignKey]=t)},e.prototype.fill=function(t){return this.fillOne(t)},e.prototype.make=function(t,e,n,r){return void 0===r&&(r=!1),this.isOneRelation(t)?this.parent.make(t,r):null},e.prototype.load=function(t,e,n){var r=this,o=this.getRelation(t,this.parent.entity);t.where(this.ownerKey,this.getKeys(e,this.foreignKey));var i=this.mapSingleRelations(o.get(),this.ownerKey);e.forEach(function(t){var e=i[t[r.foreignKey]];t[n]=e||null})},e}(x),E=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),R=function(t){function e(e,n,r,o){var i=t.call(this,e)||this;return i.related=i.model.relation(n),i.foreignKey=r,i.localKey=o,i}return E(e,t),e.prototype.define=function(t){return t.many(this.related)},e.prototype.attach=function(t,e,n){var r=this;Array.isArray(t)&&t.forEach(function(t){var o=n[r.related.entity];o&&o[t]&&void 0===o[t][r.foreignKey]&&(o[t][r.foreignKey]=e.$id)})},e.prototype.fill=function(t){return this.fillMany(t)},e.prototype.make=function(t,e,n,r){var o=this;return void 0===r&&(r=!1),null===t?[]:void 0===t?[]:Array.isArray(t)?0===t.length?[]:t.filter(function(t){return t&&"object"==typeof t}).map(function(t){return o.related.make(t,r)}):[]},e.prototype.load=function(t,e,n){var r=this,o=this.getRelation(t,this.related.entity);o.where(this.foreignKey,this.getKeys(e,this.localKey));var i=this.mapManyRelations(o.get(),this.foreignKey);e.forEach(function(t){var e=i[t[r.localKey]];t[n]=e||[]})},e}(x),P=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),S=function(t){function e(e,n,r,o){var i=t.call(this,e)||this;return i.parent=i.model.relation(n),i.foreignKey=r,i.ownerKey=o,i}return P(e,t),e.prototype.define=function(t){return t.many(this.parent)},e.prototype.attach=function(t,e,n){0!==t.length&&void 0===e[this.foreignKey]&&(e[this.foreignKey]=t)},e.prototype.fill=function(t){return this.fillMany(t)},e.prototype.make=function(t,e,n,r){var o=this;return void 0===r&&(r=!1),null===t?[]:void 0===t?[]:Array.isArray(t)?0===t.length?[]:t.filter(function(t){return t&&"object"==typeof t}).map(function(t){return o.parent.make(t,r)}):[]},e.prototype.load=function(t,e,n){var r=this,o=this.getRelation(t,this.parent.entity);this.addConstraintForHasManyBy(o,e);var i=this.mapSingleRelations(o.get(),this.ownerKey);e.forEach(function(t){var e=r.getRelatedRecords(i,t[r.foreignKey]);t[n]=e})},e.prototype.addConstraintForHasManyBy=function(t,e){var n=this,r=e.reduce(function(t,e){return t.concat(e[n.foreignKey])},[]);t.where(this.ownerKey,r)},e.prototype.getRelatedRecords=function(t,e){return e.reduce(function(e,n){var r=t[n];return r&&e.push(r),e},[])},e}(x),F=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),$=function(t){function e(e,n,r,o,i,u,a){var c=t.call(this,e)||this;return c.related=c.model.relation(n),c.through=c.model.relation(r),c.firstKey=o,c.secondKey=i,c.localKey=u,c.secondLocalKey=a,c}return F(e,t),e.prototype.define=function(t){return t.many(this.related)},e.prototype.attach=function(t,e,n){},e.prototype.fill=function(t){return this.fillMany(t)},e.prototype.make=function(t,e,n,r){var o=this;return void 0===r&&(r=!1),null===t?[]:void 0===t?[]:Array.isArray(t)?0===t.length?[]:t.filter(function(t){return t&&"object"==typeof t}).map(function(t){return o.related.make(t,r)}):[]},e.prototype.load=function(t,e,n){var r=this,o=this.getRelation(t,this.related.entity),i=t.newPlainQuery(this.through.entity);this.addEagerConstraintForThrough(i,e);var u=i.get();this.addEagerConstraintForRelated(o,u);var a=this.mapThroughRelations(u,o);e.forEach(function(t){var e=a[t[r.localKey]];t[n]=e})},e.prototype.addEagerConstraintForThrough=function(t,e){t.where(this.firstKey,this.getKeys(e,this.localKey))},e.prototype.addEagerConstraintForRelated=function(t,e){t.where(this.secondKey,this.getKeys(e,this.secondLocalKey))},e.prototype.mapThroughRelations=function(t,e){var n=this,r=this.mapManyRelations(e.get(),this.secondKey);return t.reduce(function(t,e){var o=e[n.firstKey];t[o]||(t[o]=[]);var i=r[e[n.secondLocalKey]];return i&&(t[o]=t[o].concat(i)),t},{})},e}(x),M=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),I=function(){return(I=Object.assign||function(t){for(var e,n=1,r=arguments.length;n0&&o[o.length-1])&&(6===i[0]||2===i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]0},t.pivotFields=function(){var t=[];return a.forOwn(this.fields(),function(e,n){var r;(e instanceof z||e instanceof W||e instanceof G)&&t.push(((r={})[n]=e,r))}),t},t.hasPivotFields=function(){return this.pivotFields().length>0},t.make=function(t,e){return void 0===e&&(e=!1),e?this.fill({},t,!0):new this(t)},t.makePlain=function(t){return this.make(t,!0)},t.fix=function(t,e){void 0===e&&(e=["$id"]);var n=this.getFields();return Object.keys(t).reduce(function(r,o){var i=t[o],u=n[o];return e.includes(o)?(r[o]=i,r):u?(r[o]=u.fill(i),r):r},{})},t.fixMany=function(t,e){var n=this;return Object.keys(t).reduce(function(r,o){return r[o]=n.fix(t[o],e),r},{})},t.hydrate=function(t,e){void 0===e&&(e=["$id"]);var n=this.getFields(),r=Object.keys(n).reduce(function(e,r){var o=n[r],i=t[r];return e[r]=o.fill(i),e},{});return Object.keys(t).reduce(function(n,r){return e.includes(r)&&void 0!==t[r]&&(n[r]=t[r]),n},r)},t.hydrateMany=function(t,e){var n=this;return Object.keys(t).reduce(function(r,o){return r[o]=n.hydrate(t[o],e),r},{})},t.fill=function(t,e,n){void 0===t&&(t={}),void 0===e&&(e={}),void 0===n&&(n=!1);var r=this.getFields();return Object.keys(r).reduce(function(t,o){var i=r[o],u=e[o];return t[o]=i.make(u,e,o,n),t},t)},t.prototype.$self=function(){return this.constructor},t.prototype.$fields=function(){return this.$self().fields()},t.prototype.$store=function(){return this.$self().store()},t.prototype.$namespace=function(t){return this.$self().namespace(t)},t.prototype.$dispatch=function(t,e){return this.$self().dispatch(t,e)},t.prototype.$getters=function(t){return this.$self().getters(t)},t.prototype.$create=function(t){return Z(this,void 0,void 0,function(){return Q(this,function(e){return[2,this.$dispatch("create",t)]})})},t.prototype.$insert=function(t){return Z(this,void 0,void 0,function(){return Q(this,function(e){return[2,this.$dispatch("insert",t)]})})},t.prototype.$update=function(t){return Z(this,void 0,void 0,function(){return Q(this,function(e){return Array.isArray(t)?[2,this.$dispatch("update",t)]:void 0!==t.where?[2,this.$dispatch("update",t)]:void 0===this.$self().id(t)?[2,this.$dispatch("update",{where:this.$id,data:t})]:[2,this.$dispatch("update",t)]})})},t.prototype.$insertOrUpdate=function(t){return Z(this,void 0,void 0,function(){return Q(this,function(e){return[2,this.$dispatch("insertOrUpdate",t)]})})},t.prototype.$all=function(){return this.$getters("all")()},t.prototype.$find=function(t){return this.$getters("find")(t)},t.prototype.$query=function(){return this.$getters("query")()},t.prototype.$delete=function(t){return Z(this,void 0,void 0,function(){return Q(this,function(e){return t=void 0===t?this.$id:t,[2,this.$dispatch("delete",t)]})})},t.prototype.$fill=function(t){this.$self().fill(this,t)},t.prototype.$toJson=function(){return this.$self().makePlain(this)},t.primaryKey="id"}();function Y(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function X(t,e){return t(e={exports:{}},e.exports),e.exports}var tt=X(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.isImmutable=function(t){return!(!t||"function"!=typeof t.hasOwnProperty||!(t.hasOwnProperty("__ownerID")||t._map&&t._map.hasOwnProperty("__ownerID")))},e.denormalizeImmutable=function(t,e,n){return Object.keys(t).reduce(function(e,r){var o=""+r;return e.has(o)?e.set(o,n(e.get(o),t[o])):e},e)}});Y(tt);tt.isImmutable,tt.denormalizeImmutable;var et=X(function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r=Object.assign||function(t){for(var e=1;e1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!e||"string"!=typeof e)throw new Error("Expected a string key for Entity, but found "+e+".");var i=o.idAttribute,a=void 0===i?"id":i,c=o.mergeStrategy,s=void 0===c?function(t,e){return r({},t,e)}:c,f=o.processStrategy,l=void 0===f?function(t){return r({},t)}:f;this._key=e,this._getId="function"==typeof a?a:u(a),this._idAttribute=a,this._mergeStrategy=s,this._processStrategy=l,this.define(n)}return o(t,[{key:"define",value:function(t){this.schema=Object.keys(t).reduce(function(e,n){var o=t[n];return r({},e,function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}({},n,o))},this.schema||{})}},{key:"getId",value:function(t,e,n){return this._getId(t,e,n)}},{key:"merge",value:function(t,e){return this._mergeStrategy(t,e)}},{key:"normalize",value:function(t,e,r,o,i){var u=this,a=this._processStrategy(t,e,r);return Object.keys(this.schema).forEach(function(t){if(a.hasOwnProperty(t)&&"object"===n(a[t])){var e=u.schema[t];a[t]=o(a[t],a,t,e,i)}}),i(this,a,t,e,r),this.getId(t,e,r)}},{key:"denormalize",value:function(t,e){var n=this;return i.isImmutable(t)?i.denormalizeImmutable(this.schema,t,e):(Object.keys(this.schema).forEach(function(r){if(t.hasOwnProperty(r)){var o=n.schema[r];t[r]=e(t[r],o)}}),t)}},{key:"key",get:function(){return this._key}},{key:"idAttribute",get:function(){return this._idAttribute}}]),t}();e.default=a});Y(et);var nt=X(function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e){for(var n=0;n1)throw new Error("Expected schema definition to be a single schema, but found "+t.length+".");return t[0]},i=function(t){return Array.isArray(t)?t:Object.keys(t).map(function(e){return t[e]})},u=(e.normalize=function(t,e,n,r,u,a){return t=o(t),i(e).map(function(e,o){return u(e,n,r,t,a)})},e.denormalize=function(t,e,n){return t=o(t),e&&e.map?e.map(function(e){return n(e,t)}):e},function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,r.default),n(e,[{key:"normalize",value:function(t,e,n,r,o){var u=this;return i(t).map(function(t,i){return u.normalizeValue(t,e,n,r,o)}).filter(function(t){return void 0!==t&&null!==t})}},{key:"denormalize",value:function(t,e){var n=this;return t&&t.map?t.map(function(t){return n.denormalizeValue(t,e)}):t}}]),e}());e.default=u});Y(it);it.denormalize,it.normalize;var ut=X(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.denormalize=e.normalize=void 0;var n=function(){function t(t,e){for(var n=0;n0&&t.withAllRecursive(e-1)})},t.parseWithRelations=function(t,e,n){var r=this,o=e[0];o.split("|").forEach(function(e){r.setEagerLoad(t,e)}),1!==e.length?(e.shift(),this.addNestedWiths(t,e,n)):this.setEagerLoad(t,o,n)},t.addNestedWiths=function(t,e,n){var r=e.join(".");this.setEagerLoad(t,r,function(t){t.with(r,n)})},t.eagerLoadRelations=function(t,e){var n=t.model.getFields();for(var r in t.load){var o=n[r];o instanceof x&&o.load(t,e,r)}},t}(),Ot=function(){function t(t){this.query=t}return t.on=function(t,e,n){void 0===n&&(n=!1);var r=this.lastHookId+1;return this.lastHookId=r,this.hooks[t]||(this.hooks[t]=[]),this.hooks[t].push({callback:e,once:n,uid:r}),r},t.off=function(t){var e=this,n=!1;return Object.keys(this.hooks).some(function(r){var o=e.hooks[r],i=o.findIndex(function(e){return e.uid===t});return-1!==i&&(o.splice(i,1),n=!0),n}),n},t.prototype.self=function(){return this.constructor},t.prototype.getActionHook=function(t){return this.query.actionContext&&this.query.module.actions&&this.query.module.actions[t]||null},t.prototype.getGlobalHook=function(t){return this.self().hooks[t]?this.self().hooks[t]:null},t.prototype.has=function(t){return!!this.getActionHook(t)||!!this.getGlobalHook(t)},t.prototype.execute=function(t,e){return this.has(t)?(e=this.executeActionHook(t,e),e=this.executeGlobalHook(t,e)):e},t.prototype.executeActionHook=function(t,e){if(!this.query.actionContext)return e;var n=this.getActionHook(t);if(!n)return e;var r=n(this.query.actionContext,e);return!1!==r&&(r||e)},t.prototype.executeGlobalHook=function(t,e){var n=this;if(!1===e)return!1;var r=this.getGlobalHook(t);if(!r)return e;var o=[];return r.forEach(function(t,r){var i=t.callback,u=t.once;e=i.call(n.query,e,n.query.entity),u&&o.push(r)}),o.reverse().forEach(function(t){r.splice(t,1)}),e},t.prototype.executeOnRecords=function(t,e){var n=this;return this.has(t)?Object.keys(e).reduce(function(r,o){var i=e[o],u=n.execute(t,i);return!1===u?r:(r[o]=u,r)},{}):e},t.prototype.executeOnCollection=function(t,e){var n=this;return this.has(t)?(e.map(function(e){n.execute(t,e)}),e):e},t.hooks={},t.lastHookId=0,t}(),xt=function(){return(xt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n0&&(o[i]=u),o},{})},t.prototype.getPersistMethod=function(t,e,n){return n.create&&n.create.includes(t)?"create":n.insert&&n.insert.includes(t)?"insert":n.update&&n.update.includes(t)?"update":n.insertOrUpdate&&n.insertOrUpdate.includes(t)?"insertOrUpdate":e},t.prototype.normalize=function(t){return vt.normalize(this,t)},t.prototype.merge=function(t,e,n){var r=this,o=n||this.model.getFields();a.forOwn(t,function(t,n){var i=o[n];i instanceof c?e[n]=t:r.merge(t,e[n],i)})},t.prototype.all=function(){return this.get()},t.prototype.find=function(t){var e=this.state.data[t];return e?this.item(xt({},e)):null},t.prototype.get=function(){var t=this.process();return this.collect(t)},t.prototype.first=function(){var t=this.process();return this.item(t[0])},t.prototype.last=function(){var t=this.process(),e=t.length-1;return this.item(t[e])},t.prototype.records=function(t){var e=t||this.state.data;return Object.keys(e).map(function(t){return xt({},e[t])})},t.prototype.where=function(t,e){return this.wheres.push({field:t,value:e,boolean:"and"}),this},t.prototype.orWhere=function(t,e){return this.wheres.push({field:t,value:e,boolean:"or"}),this},t.prototype.orderBy=function(t,e){return void 0===e&&(e="asc"),this.orders.push({field:t,direction:e}),this},t.prototype.offset=function(t){return this._offset=t,this},t.prototype.limit=function(t){return this._limit=t,this},t.prototype.with=function(t,e){return void 0===e&&(e=null),wt.with(this,t,e),this},t.prototype.withAll=function(t){return void 0===t&&(t=function(){return null}),wt.withAll(this,t),this},t.prototype.withAllRecursive=function(t){return void 0===t&&(t=3),wt.withAllRecursive(this,t),this},t.prototype.has=function(t,e,n){return this.addHasConstraint(t,e,n,!0)},t.prototype.hasNot=function(t,e,n){return this.addHasConstraint(t,e,n,!1)},t.prototype.addHasConstraint=function(t,e,n,r){var o=this.matchesHasRelation(t,e,n,r);return this.where("$id",function(t){return o.includes(t)}),this},t.prototype.whereHas=function(t,e){return this.addWhereHasConstraint(t,e,!0)},t.prototype.whereHasNot=function(t,e){return this.addWhereHasConstraint(t,e,!1)},t.prototype.addWhereHasConstraint=function(t,e,n){var r=this.matchesWhereHasRelation(t,e,n);return this.where("$id",function(t){return r.includes(t)}),this},t.prototype.process=function(){var t=this.records();return t=this.hook.execute("beforeProcess",t),t=this.filterWhere(t),t=this.hook.execute("afterWhere",t),t=this.filterOrderBy(t),t=this.hook.execute("afterOrderBy",t),t=this.filterLimit(t),t=this.hook.execute("afterLimit",t)},t.prototype.filterWhere=function(t){return bt.where(this,t)},t.prototype.filterOrderBy=function(t){return bt.orderBy(this,t)},t.prototype.filterLimit=function(t){return bt.limit(this,t)},t.prototype.count=function(){return this.plain().get().length},t.prototype.max=function(t){var e=this.plain().get().reduce(function(e,n){return"number"==typeof n[t]&&e.push(n[t]),e},[]);return 0===e.length?0:Math.max.apply(Math,e)},t.prototype.min=function(t){var e=this.plain().get().reduce(function(e,n){return"number"==typeof n[t]&&e.push(n[t]),e},[]);return 0===e.length?0:Math.min.apply(Math,e)},t.prototype.sum=function(t){return this.plain().get().reduce(function(e,n){return"number"==typeof n[t]&&(e+=n[t]),e},0)},t.prototype.item=function(t){return t?(wt.eagerLoadRelations(this,[t]),this.model.make(t,!this.wrap)):null},t.prototype.collect=function(t){var e=this;return a.isEmpty(t)?[]:(wt.eagerLoadRelations(this,t),t.map(function(t){return e.model.make(t,!e.wrap)}))},t.prototype.matchesHasRelation=function(e,n,r,o){var i;void 0===o&&(o=!0),void 0===n?i=function(t){return t.length>=1}:"number"==typeof n?i=function(t){return t.length>=n}:"="===n&&"number"==typeof r?i=function(t){return t.length===r}:">"===n&&"number"==typeof r?i=function(t){return t.length>r}:">="===n&&"number"==typeof r?i=function(t){return t.length>=r}:"<"===n&&"number"==typeof r?i=function(t){return t.length0&&o[o.length-1])&&(6===i[0]||2===i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]0&&o[o.length-1])&&(6===i[0]||2===i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]t>=200&&t<300,maxRedirects:5,socketPath:null,proxy:{},onResponse:t=>t.data,onUnauthorised(t){},onNotFound(t){},onServerError(t){},onGenericError(t){},onValidationError(t){},onError(t){switch(t.response.status){case 401:this.onUnauthorised(t);break;case 404:this.onNotFound(t);break;case 422:this.onValidationError(t);break;case 500:this.onServerError(t);break;default:this.onGenericError(t)}return Promise.reject(t)}},Wt={database:new Nt,http:Dt},Ht={getters:{loading:t=>t.loading,errors:t=>t.errors},mutations:{onRequest(t){t.loading=!0,t.errors=[]},onError(t,e){t.loading=!1,t.errors=e.data},onSuccess(t){t.loading=!1,t.errors=[]}},state:{loading:!1,errors:[]}},Vt={http:Dt,methods:{$fetch:{name:"fetch",http:{url:"",method:"get"}},$get:{name:"get",http:{url:"/:id",method:"get"}},$create:{name:"create",alias:["insert"],http:{url:"",method:"post"}},$update:{name:"update",http:{url:"/:id",method:"put"}},$delete:{name:"delete",http:{url:"/:id",method:"delete"}}}};class Gt{constructor(t,e){if(this.components=t,this.options=o.a.merge({},Wt,e),this.database=e.database,!e.database)throw new Error("database option is required to initialise!")}static setup(t,e){return this.instance=new Gt(t,e),this.instance}static getInstance(){return this.instance}getModelFromState(t){return o.a.find(this.database.entities,{name:t.$name}).model}}class Jt{static transformModule(t){return o.a.merge({},Ht,t)}static transformModel(t){const e=Gt.getInstance();return Vt.http=o.a.merge({},Vt.http,e.options.http),t.methodConf=o.a.merge({},Vt,t.methodConf),t.methodConf.http.url="/"===t.methodConf.http.url?`/${t.entity}`:t.methodConf.http.url,t.getFields=(()=>(t.cachedFields||(t.cachedFields=o.a.merge({},{$id:t.attr(void 0),$isUpdating:t.boolean(!1),$updateErrors:t.attr([]),$isDeleting:t.boolean(!1),$deleteErrors:t.attr([])},t.fields())),t.cachedFields)),t}static transformParams(t,e,n={}){let r=`${e.methodConf.http.url}${e.methodConf.methods[t].http.url}`;return n.params&&o.a.forOwn(n.params,(t,e)=>{r=r.replace(`:${e}`,t)}),n.query&&(r+=`?${Object.keys(n.query).map(t=>`${encodeURIComponent(t)}=${encodeURIComponent(n.query[t])}`).join("&")}`),r}}var Zt=n(15),Qt=n.n(Zt);class Yt{constructor(t){return this.instance=Qt.a.create(t),t.access_token&&(this.instance.defaults.headers.common.Authorization=`Bearer ${t.access_token}`),this.instance.interceptors.response.use(e=>t.onResponse(e),e=>t.onError(e)),this.instance}async head(t,e={}){return this.instance.head(t,e)}async get(t,e={}){return this.instance.get(t,e)}async post(t,e={},n={}){return this.instance.post(t,e,n)}async patch(t,e={},n={}){return this.instance.patch(t,e,n)}async put(t,e={},n={}){return this.instance.put(t,e,n)}async delete(t,e={}){return this.instance.delete(t,e)}}class Xt extends Jt{static async call({state:t,commit:e},n={}){const r=Gt.getInstance().getModelFromState(t),o=Jt.transformParams("$fetch",r,n),i=new Yt(r.methodConf.http).get(o);return this.onRequest(e),i.then(t=>this.onSuccess(e,r,t)).catch(t=>this.onError(e,t)),i}static onRequest(t){t("onRequest")}static onSuccess(t,e,n){t("onSuccess"),e.insertOrUpdate({data:n})}static onError(t,e){t("onError",e)}}class te extends Jt{static async call({state:t,commit:e},n={}){const r=Gt.getInstance().getModelFromState(t),o=Jt.transformParams("$get",r,n),i=new Yt(r.methodConf.http).get(o);return this.onRequest(e),i.then(t=>this.onSuccess(e,r,t)).catch(t=>this.onError(e,t)),i}static onRequest(t){t("onRequest")}static onSuccess(t,e,n){t("onSuccess"),e.insertOrUpdate({data:n})}static onError(t,e){t("onError",e)}}class ee extends Jt{static async call({state:t,commit:e},n={}){if(!n.data||"object"!=typeof n)throw new TypeError("You must include a data object in the params to send a POST request",n);const r=Gt.getInstance().getModelFromState(t),o=Jt.transformParams("$create",r,n),i=new Yt(r.methodConf.http).post(o,n.data);return this.onRequest(e),i.then(t=>this.onSuccess(e,r,t)).catch(t=>this.onError(e,t)),i}static onRequest(t){t("onRequest")}static onSuccess(t,e,n){t("onSuccess"),e.insertOrUpdate({data:n})}static onError(t,e){t("onError",e)}}class ne extends Jt{static async call({state:t,commit:e},n={}){if(!n.data||"object"!=typeof n)throw new TypeError("You must include a data object in the params to send a POST request",n);const r=Gt.getInstance().getModelFromState(t),o=Jt.transformParams("$update",r,n),i=new Yt(r.methodConf.http).put(o,n.data);return this.onRequest(r,n),i.then(t=>this.onSuccess(r,n,t)).catch(t=>this.onError(r,n,t)),i}static onRequest(t,e){t.update({where:e.params.id,data:{$isUpdating:!0,$updateErrors:[]}})}static onSuccess(t,e,n){t.update({where:e.params.id||n.id,data:o.a.merge({},n,{$isUpdating:!1,$updateErrors:[]})})}static onError(t,e,n){t.update({where:e.params.id,data:{$isUpdating:!1,$updateErrors:n}})}}class re extends Jt{static async call({state:t,commit:e},n={}){const r=Gt.getInstance().getModelFromState(t),o=Jt.transformParams("$delete",r,n),i=new Yt(r.methodConf.http).delete(o);return this.onRequest(r,n),i.then(t=>this.onSuccess(r,n,t)).catch(t=>this.onError(r,n,t)),i}static onRequest(t,e){t.update({where:e.params.id,data:{$isDeleting:!0,$deleteErrors:[]}})}static onSuccess(t,e,n){t.delete({where:e.params.id||n.id})}static onError(t,e,n){t.update({where:e.params.id,data:{$isDeleting:!1,$deleteErrors:n}})}}class oe{constructor(t,e){Gt.setup(t,e),this.setupActions(),this.setupModels()}setupActions(){const t=Gt.getInstance();t.components.Actions.$fetch=Xt.call.bind(Xt),t.components.Actions.$get=te.call.bind(te),t.components.Actions.$create=ee.call.bind(ee),t.components.Actions.$update=ne.call.bind(ne),t.components.Actions.$delete=re.call.bind(re)}setupModels(){const t=Gt.getInstance();_.map(t.database.entities,t=>(t.module=Jt.transformModule(t.module),t.model=Jt.transformModel(t.model),t)),t.components.Model.$fetch=function(t={}){return this.dispatch("$fetch",t)},t.components.Model.$get=function(t={}){return this.dispatch("$get",t)},t.components.Model.$create=function(t={}){return this.dispatch("$create",t)},t.components.Model.$update=function(t={}){return this.dispatch("$update",t)},t.components.Model.$delete=function(t={}){return this.dispatch("$delete",t)}}}n.d(e,"default",function(){return ie});class ie{static install(t,e){return new oe(t,e)}}}])}); \ No newline at end of file +t.exports=function(t){return null!=t&&(n(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&n(t.slice(0,0))}(t)||!!t._isBuffer)}},function(t,e,n){"use strict";var r=n(2),o=n(0),i=n(40),u=n(41);function a(t){this.defaults=t,this.interceptors={request:new i,response:new i}}a.prototype.request=function(t){"string"==typeof t&&(t=o.merge({url:arguments[0]},arguments[1])),(t=o.merge(r,{method:"get"},this.defaults,t)).method=t.method.toLowerCase();var e=[u,void 0],n=Promise.resolve(t);for(this.interceptors.request.forEach(function(t){e.unshift(t.fulfilled,t.rejected)}),this.interceptors.response.forEach(function(t){e.push(t.fulfilled,t.rejected)});e.length;)n=n.then(e.shift(),e.shift());return n},o.forEach(["delete","get","head","options"],function(t){a.prototype[t]=function(e,n){return this.request(o.merge(n||{},{method:t,url:e}))}}),o.forEach(["post","put","patch"],function(t){a.prototype[t]=function(e,n,r){return this.request(o.merge(r||{},{method:t,url:e,data:n}))}}),t.exports=a},function(t,e,n){"use strict";var r=n(0);t.exports=function(t,e){r.forEach(t,function(n,r){r!==e&&r.toUpperCase()===e.toUpperCase()&&(t[e]=n,delete t[r])})}},function(t,e,n){"use strict";var r=n(0),o=n(5),i=n(7),u=n(22),a=n(23),c=n(3),s="undefined"!=typeof window&&window.btoa&&window.btoa.bind(window)||n(24);t.exports=function(t){return new Promise(function(e,f){var l=t.data,p=t.headers;r.isFormData(l)&&delete p["Content-Type"];var h=new XMLHttpRequest,d="onreadystatechange",y=!1;if("undefined"==typeof window||!window.XDomainRequest||"withCredentials"in h||a(t.url)||(h=new window.XDomainRequest,d="onload",y=!0,h.onprogress=function(){},h.ontimeout=function(){}),t.auth){var v=t.auth.username||"",m=t.auth.password||"";p.Authorization="Basic "+s(v+":"+m)}if(h.open(t.method.toUpperCase(),i(t.url,t.params,t.paramsSerializer),!0),h.timeout=t.timeout,h[d]=function(){if(h&&(4===h.readyState||y)&&(0!==h.status||h.responseURL&&0===h.responseURL.indexOf("file:"))){var n="getAllResponseHeaders"in h?u(h.getAllResponseHeaders()):null,r={data:t.responseType&&"text"!==t.responseType?h.response:h.responseText,status:1223===h.status?204:h.status,statusText:1223===h.status?"No Content":h.statusText,headers:n,config:t,request:h};o(e,f,r),h=null}},h.onerror=function(){f(c("Network Error",t,null,h)),h=null},h.ontimeout=function(){f(c("timeout of "+t.timeout+"ms exceeded",t,"ECONNABORTED",h)),h=null},r.isStandardBrowserEnv()){var g=n(25),_=(t.withCredentials||a(t.url))&&t.xsrfCookieName?g.read(t.xsrfCookieName):void 0;_&&(p[t.xsrfHeaderName]=_)}if("setRequestHeader"in h&&r.forEach(p,function(t,e){void 0===l&&"content-type"===e.toLowerCase()?delete p[e]:h.setRequestHeader(e,t)}),t.withCredentials&&(h.withCredentials=!0),t.responseType)try{h.responseType=t.responseType}catch(e){if("json"!==t.responseType)throw e}"function"==typeof t.onDownloadProgress&&h.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&h.upload&&h.upload.addEventListener("progress",t.onUploadProgress),t.cancelToken&&t.cancelToken.promise.then(function(t){h&&(h.abort(),f(t),h=null)}),void 0===l&&(l=null),h.send(l)})}},function(t,e,n){"use strict";var r=n(0),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];t.exports=function(t){var e,n,i,u={};return t?(r.forEach(t.split("\n"),function(t){if(i=t.indexOf(":"),e=r.trim(t.substr(0,i)).toLowerCase(),n=r.trim(t.substr(i+1)),e){if(u[e]&&o.indexOf(e)>=0)return;u[e]="set-cookie"===e?(u[e]?u[e]:[]).concat([n]):u[e]?u[e]+", "+n:n}}),u):u}},function(t,e,n){"use strict";var r=n(0);t.exports=r.isStandardBrowserEnv()?function(){var t,e=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function o(t){var r=t;return e&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return t=o(window.location.href),function(e){var n=r.isString(e)?o(e):e;return n.protocol===t.protocol&&n.host===t.host}}():function(){return!0}},function(t,e,n){"use strict";var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function o(){this.message="String contains an invalid character"}o.prototype=new Error,o.prototype.code=5,o.prototype.name="InvalidCharacterError",t.exports=function(t){for(var e,n,i=String(t),u="",a=0,c=r;i.charAt(0|a)||(c="=",a%1);u+=c.charAt(63&e>>8-a%1*8)){if((n=i.charCodeAt(a+=.75))>255)throw new o;e=e<<8|n}return u}},function(t,e,n){"use strict";var r=n(0);t.exports=r.isStandardBrowserEnv()?{write:function(t,e,n,o,i,u){var a=[];a.push(t+"="+encodeURIComponent(e)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(o)&&a.push("path="+o),r.isString(i)&&a.push("domain="+i),!0===u&&a.push("secure"),document.cookie=a.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(t,e,n){"use strict";var r=n(0),o=n(5),i=n(7),u=n(8),a=n(9),c=n(10).http,s=n(10).https,f=n(11),l=n(38),p=n(39),h=n(3),d=n(6);t.exports=function(t){return new Promise(function(e,n){var y,v=t.data,m=t.headers;if(m["User-Agent"]||m["user-agent"]||(m["User-Agent"]="axios/"+p.version),v&&!r.isStream(v)){if(Buffer.isBuffer(v));else if(r.isArrayBuffer(v))v=new Buffer(new Uint8Array(v));else{if(!r.isString(v))return n(h("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",t));v=new Buffer(v,"utf-8")}m["Content-Length"]=v.length}var g=void 0;t.auth&&(g=(t.auth.username||"")+":"+(t.auth.password||""));var _=f.parse(t.url),b=_.protocol||"http:";if(!g&&_.auth){var w=_.auth.split(":");g=(w[0]||"")+":"+(w[1]||"")}g&&delete m.Authorization;var O="https:"===b,x=O?t.httpsAgent:t.httpAgent,C={path:i(_.path,t.params,t.paramsSerializer).replace(/^\?/,""),method:t.method,headers:m,agent:x,auth:g};t.socketPath?C.socketPath=t.socketPath:(C.hostname=_.hostname,C.port=_.port);var j,k=t.proxy;if(!k&&!1!==k){var A=b.slice(0,-1)+"_proxy",E=process.env[A]||process.env[A.toUpperCase()];if(E){var R=f.parse(E);if(k={host:R.hostname,port:R.port},R.auth){var P=R.auth.split(":");k.auth={username:P[0],password:P[1]}}}}if(k&&(C.hostname=k.host,C.host=k.host,C.headers.host=_.hostname+(_.port?":"+_.port:""),C.port=k.port,C.path=b+"//"+_.hostname+(_.port?":"+_.port:"")+C.path,k.auth)){var S=new Buffer(k.auth.username+":"+k.auth.password,"utf8").toString("base64");C.headers["Proxy-Authorization"]="Basic "+S}t.transport?j=t.transport:0===t.maxRedirects?j=O?a:u:(t.maxRedirects&&(C.maxRedirects=t.maxRedirects),j=O?s:c),t.maxContentLength&&t.maxContentLength>-1&&(C.maxBodyLength=t.maxContentLength);var F=j.request(C,function(r){if(!F.aborted){clearTimeout(y),y=null;var i=r;switch(r.headers["content-encoding"]){case"gzip":case"compress":case"deflate":i=i.pipe(l.createUnzip()),delete r.headers["content-encoding"]}var u=r.req||F,a={status:r.statusCode,statusText:r.statusMessage,headers:r.headers,config:t,request:u};if("stream"===t.responseType)a.data=i,o(e,n,a);else{var c=[];i.on("data",function(e){c.push(e),t.maxContentLength>-1&&Buffer.concat(c).length>t.maxContentLength&&n(h("maxContentLength size of "+t.maxContentLength+" exceeded",t,null,u))}),i.on("error",function(e){F.aborted||n(d(e,t,null,u))}),i.on("end",function(){var r=Buffer.concat(c);"arraybuffer"!==t.responseType&&(r=r.toString("utf8")),a.data=r,o(e,n,a)})}}});F.on("error",function(e){F.aborted||n(d(e,t,null,F))}),t.timeout&&!y&&(y=setTimeout(function(){F.abort(),n(h("timeout of "+t.timeout+"ms exceeded",t,"ECONNABORTED",F))},t.timeout)),t.cancelToken&&t.cancelToken.promise.then(function(t){F.aborted||(F.abort(),n(t))}),r.isStream(v)?v.pipe(F):F.end(v)})}},function(t,e){t.exports=require("assert")},function(t,e){t.exports=require("stream")},function(t,e,n){"undefined"==typeof process||"renderer"===process.type?t.exports=n(30):t.exports=n(32)},function(t,e,n){function r(){var t;try{t=e.storage.debug}catch(t){}return!t&&"undefined"!=typeof process&&"env"in process&&(t=process.env.DEBUG),t}(e=t.exports=n(12)).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},e.formatArgs=function(t){var n=this.useColors;if(t[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+t[0]+(n?"%c ":" ")+"+"+e.humanize(this.diff),!n)return;var r="color: "+this.color;t.splice(1,0,r,"color: inherit");var o=0,i=0;t[0].replace(/%[a-zA-Z%]/g,function(t){"%%"!==t&&"%c"===t&&(i=++o)}),t.splice(i,0,r)},e.save=function(t){try{null==t?e.storage.removeItem("debug"):e.storage.debug=t}catch(t){}},e.load=r,e.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},e.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(t){}}(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.formatters.j=function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}},e.enable(r())},function(t,e){var n=1e3,r=60*n,o=60*r,i=24*o,u=365.25*i;function a(t,e,n){if(!(t0)return function(t){if((t=String(t)).length>100)return;var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(t);if(!e)return;var a=parseFloat(e[1]);switch((e[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return a*u;case"days":case"day":case"d":return a*i;case"hours":case"hour":case"hrs":case"hr":case"h":return a*o;case"minutes":case"minute":case"mins":case"min":case"m":return a*r;case"seconds":case"second":case"secs":case"sec":case"s":return a*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}(t);if("number"===c&&!1===isNaN(t))return e.long?function(t){return a(t,i,"day")||a(t,o,"hour")||a(t,r,"minute")||a(t,n,"second")||t+" ms"}(t):function(t){if(t>=i)return Math.round(t/i)+"d";if(t>=o)return Math.round(t/o)+"h";if(t>=r)return Math.round(t/r)+"m";if(t>=n)return Math.round(t/n)+"s";return t+"ms"}(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}},function(t,e,n){var r=n(33),o=n(34);(e=t.exports=n(12)).init=function(t){t.inspectOpts={};for(var n=Object.keys(e.inspectOpts),r=0;r=2&&(e.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(t){}function u(){return process.env.DEBUG}e.inspectOpts=Object.keys(process.env).filter(function(t){return/^debug_/i.test(t)}).reduce(function(t,e){var n=e.substring(6).toLowerCase().replace(/_([a-z])/g,function(t,e){return e.toUpperCase()}),r=process.env[e];return r=!!/^(yes|on|true|enabled)$/i.test(r)||!/^(no|off|false|disabled)$/i.test(r)&&("null"===r?null:Number(r)),t[n]=r,t},{}),e.formatters.o=function(t){return this.inspectOpts.colors=this.useColors,o.inspect(t,this.inspectOpts).split("\n").map(function(t){return t.trim()}).join(" ")},e.formatters.O=function(t){return this.inspectOpts.colors=this.useColors,o.inspect(t,this.inspectOpts)},e.enable(u())},function(t,e){t.exports=require("tty")},function(t,e){t.exports=require("util")},function(t,e,n){"use strict";const r=n(36),o=n(37),i=process.env;let u;function a(t){return function(t){return 0!==t&&{level:t,hasBasic:!0,has256:t>=2,has16m:t>=3}}(function(t){if(!1===u)return 0;if(o("color=16m")||o("color=full")||o("color=truecolor"))return 3;if(o("color=256"))return 2;if(t&&!t.isTTY&&!0!==u)return 0;const e=u?1:0;if("win32"===process.platform){const t=r.release().split(".");return Number(process.versions.node.split(".")[0])>=8&&Number(t[0])>=10&&Number(t[2])>=10586?Number(t[2])>=14931?3:2:1}if("CI"in i)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(t=>t in i)||"codeship"===i.CI_NAME?1:e;if("TEAMCITY_VERSION"in i)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(i.TEAMCITY_VERSION)?1:0;if("truecolor"===i.COLORTERM)return 3;if("TERM_PROGRAM"in i){const t=parseInt((i.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(i.TERM_PROGRAM){case"iTerm.app":return t>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(i.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(i.TERM)?1:"COLORTERM"in i?1:(i.TERM,e)}(t))}o("no-color")||o("no-colors")||o("color=false")?u=!1:(o("color")||o("colors")||o("color=true")||o("color=always"))&&(u=!0),"FORCE_COLOR"in i&&(u=0===i.FORCE_COLOR.length||0!==parseInt(i.FORCE_COLOR,10)),t.exports={supportsColor:a,stdout:a(process.stdout),stderr:a(process.stderr)}},function(t,e){t.exports=require("os")},function(t,e,n){"use strict";t.exports=((t,e)=>{e=e||process.argv;const n=t.startsWith("-")?"":1===t.length?"-":"--",r=e.indexOf(n+t),o=e.indexOf("--");return-1!==r&&(-1===o||r=0?i=a:(i=o+a)<0&&(i=0);ie)return 1;if(t=a)return s;var f=n[c];return s*("desc"===f?-1:1)}}return t.index-e.index}(t,e,n)})},pickBy:function(t,e){return Object.keys(t).reduce(function(n,r){var o=t[r];return e(o,r)&&(n[r]=o),n},{})}},c=function(){return function(t){this.model=t}}(),s=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),f=function(t){function e(e,n){var r=t.call(this,e)||this;return r.mutator=n,r}return s(e,t),e.prototype.mutate=function(t,e){var n=this.mutator||this.model.mutators()[e];return n?n(t):t},e}(c),l=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),p=function(t){function e(e,n,r){var o=t.call(this,e,r)||this;return o.value=n,o}return l(e,t),e.prototype.fill=function(t){return void 0!==t?t:this.value},e.prototype.make=function(t,e,n,r){return this.mutate(this.fill(t),n)},e}(f),h=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),d=function(t){function e(e){var n=t.call(this,e)||this;return n.value=1,n}return h(e,t),e.prototype.fill=function(t){return t},e.prototype.make=function(t,e,n,r){return"number"==typeof t?t:null},e}(f),y=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),v=function(t){function e(e,n,r){var o=t.call(this,e,r)||this;return o.value=n,o}return y(e,t),e.prototype.fill=function(t){return void 0===t?this.value:"string"==typeof t?t:t+""},e.prototype.make=function(t,e,n,r){return this.mutate(this.fill(t),n)},e}(f),m=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),g=function(t){function e(e,n,r){var o=t.call(this,e,r)||this;return o.value=n,o}return m(e,t),e.prototype.fill=function(t){return void 0===t?this.value:"number"==typeof t?t:"string"==typeof t?parseFloat(t):"boolean"==typeof t&&t?1:0},e.prototype.make=function(t,e,n,r){return this.mutate(this.fill(t),n)},e}(f),b=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),w=function(t){function e(e,n,r){var o=t.call(this,e,r)||this;return o.value=n,o}return b(e,t),e.prototype.fill=function(t){if(void 0===t)return this.value;if("boolean"==typeof t)return t;if("string"==typeof t){if(0===t.length)return!1;var e=parseInt(t,0);return!!isNaN(e)||!!e}return"number"==typeof t&&!!t},e.prototype.make=function(t,e,n,r){return this.mutate(this.fill(t),n)},e}(f),O=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),x=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return O(e,t),e.prototype.fillOne=function(t){return void 0===t?null:"object"==typeof t?null:t},e.prototype.fillMany=function(t){return Array.isArray(t)?t:[]},e.prototype.getRelation=function(t,e){var n=t.newPlainQuery(e);return this.addEagerConstraint(t,n),n},e.prototype.getKeys=function(t,e){return t.map(function(t){return t[e]})},e.prototype.addEagerConstraint=function(t,e){for(var n in t.load)t.load[n].forEach(function(t){t(e)})},e.prototype.mapSingleRelations=function(t,e){return t.reduce(function(t,n){return t[n[e]]=n,t},{})},e.prototype.mapManyRelations=function(t,e){return t.reduce(function(t,n){var r=n[e];return t[r]||(t[r]=[]),t[r].push(n),t},{})},e.prototype.isOneRelation=function(t){return!Array.isArray(t)&&null!==t&&"object"==typeof t},e}(c),C=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),j=function(t){function e(e,n,r,o){var i=t.call(this,e)||this;return i.related=i.model.relation(n),i.foreignKey=r,i.localKey=o,i}return C(e,t),e.prototype.define=function(t){return t.one(this.related)},e.prototype.attach=function(t,e,n){var r=n[this.related.entity];r&&r[t]&&void 0===r[t][this.foreignKey]&&(e[this.localKey]||(e[this.localKey]=e.$id),r[t][this.foreignKey]=e[this.localKey])},e.prototype.fill=function(t){return this.fillOne(t)},e.prototype.make=function(t,e,n,r){return void 0===r&&(r=!1),this.isOneRelation(t)?this.related.make(t,r):null},e.prototype.load=function(t,e,n){var r=this,o=this.getRelation(t,this.related.entity);o.where(this.foreignKey,this.getKeys(e,this.localKey));var i=this.mapSingleRelations(o.get(),this.foreignKey);e.forEach(function(t){var e=i[t[r.localKey]];t[n]=e||null})},e}(x),k=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),A=function(t){function e(e,n,r,o){var i=t.call(this,e)||this;return i.parent=i.model.relation(n),i.foreignKey=r,i.ownerKey=o,i}return k(e,t),e.prototype.define=function(t){return t.one(this.parent)},e.prototype.attach=function(t,e,n){void 0===e[this.foreignKey]&&(e[this.foreignKey]=t)},e.prototype.fill=function(t){return this.fillOne(t)},e.prototype.make=function(t,e,n,r){return void 0===r&&(r=!1),this.isOneRelation(t)?this.parent.make(t,r):null},e.prototype.load=function(t,e,n){var r=this,o=this.getRelation(t,this.parent.entity);t.where(this.ownerKey,this.getKeys(e,this.foreignKey));var i=this.mapSingleRelations(o.get(),this.ownerKey);e.forEach(function(t){var e=i[t[r.foreignKey]];t[n]=e||null})},e}(x),E=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),R=function(t){function e(e,n,r,o){var i=t.call(this,e)||this;return i.related=i.model.relation(n),i.foreignKey=r,i.localKey=o,i}return E(e,t),e.prototype.define=function(t){return t.many(this.related)},e.prototype.attach=function(t,e,n){var r=this;Array.isArray(t)&&t.forEach(function(t){var o=n[r.related.entity];o&&o[t]&&void 0===o[t][r.foreignKey]&&(o[t][r.foreignKey]=e.$id)})},e.prototype.fill=function(t){return this.fillMany(t)},e.prototype.make=function(t,e,n,r){var o=this;return void 0===r&&(r=!1),null===t?[]:void 0===t?[]:Array.isArray(t)?0===t.length?[]:t.filter(function(t){return t&&"object"==typeof t}).map(function(t){return o.related.make(t,r)}):[]},e.prototype.load=function(t,e,n){var r=this,o=this.getRelation(t,this.related.entity);o.where(this.foreignKey,this.getKeys(e,this.localKey));var i=this.mapManyRelations(o.get(),this.foreignKey);e.forEach(function(t){var e=i[t[r.localKey]];t[n]=e||[]})},e}(x),P=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),S=function(t){function e(e,n,r,o){var i=t.call(this,e)||this;return i.parent=i.model.relation(n),i.foreignKey=r,i.ownerKey=o,i}return P(e,t),e.prototype.define=function(t){return t.many(this.parent)},e.prototype.attach=function(t,e,n){0!==t.length&&void 0===e[this.foreignKey]&&(e[this.foreignKey]=t)},e.prototype.fill=function(t){return this.fillMany(t)},e.prototype.make=function(t,e,n,r){var o=this;return void 0===r&&(r=!1),null===t?[]:void 0===t?[]:Array.isArray(t)?0===t.length?[]:t.filter(function(t){return t&&"object"==typeof t}).map(function(t){return o.parent.make(t,r)}):[]},e.prototype.load=function(t,e,n){var r=this,o=this.getRelation(t,this.parent.entity);this.addConstraintForHasManyBy(o,e);var i=this.mapSingleRelations(o.get(),this.ownerKey);e.forEach(function(t){var e=r.getRelatedRecords(i,t[r.foreignKey]);t[n]=e})},e.prototype.addConstraintForHasManyBy=function(t,e){var n=this,r=e.reduce(function(t,e){return t.concat(e[n.foreignKey])},[]);t.where(this.ownerKey,r)},e.prototype.getRelatedRecords=function(t,e){return e.reduce(function(e,n){var r=t[n];return r&&e.push(r),e},[])},e}(x),F=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),$=function(t){function e(e,n,r,o,i,u,a){var c=t.call(this,e)||this;return c.related=c.model.relation(n),c.through=c.model.relation(r),c.firstKey=o,c.secondKey=i,c.localKey=u,c.secondLocalKey=a,c}return F(e,t),e.prototype.define=function(t){return t.many(this.related)},e.prototype.attach=function(t,e,n){},e.prototype.fill=function(t){return this.fillMany(t)},e.prototype.make=function(t,e,n,r){var o=this;return void 0===r&&(r=!1),null===t?[]:void 0===t?[]:Array.isArray(t)?0===t.length?[]:t.filter(function(t){return t&&"object"==typeof t}).map(function(t){return o.related.make(t,r)}):[]},e.prototype.load=function(t,e,n){var r=this,o=this.getRelation(t,this.related.entity),i=t.newPlainQuery(this.through.entity);this.addEagerConstraintForThrough(i,e);var u=i.get();this.addEagerConstraintForRelated(o,u);var a=this.mapThroughRelations(u,o);e.forEach(function(t){var e=a[t[r.localKey]];t[n]=e})},e.prototype.addEagerConstraintForThrough=function(t,e){t.where(this.firstKey,this.getKeys(e,this.localKey))},e.prototype.addEagerConstraintForRelated=function(t,e){t.where(this.secondKey,this.getKeys(e,this.secondLocalKey))},e.prototype.mapThroughRelations=function(t,e){var n=this,r=this.mapManyRelations(e.get(),this.secondKey);return t.reduce(function(t,e){var o=e[n.firstKey];t[o]||(t[o]=[]);var i=r[e[n.secondLocalKey]];return i&&(t[o]=t[o].concat(i)),t},{})},e}(x),M=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),I=function(){return(I=Object.assign||function(t){for(var e,n=1,r=arguments.length;n0&&o[o.length-1])&&(6===i[0]||2===i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]0},t.pivotFields=function(){var t=[];return a.forOwn(this.fields(),function(e,n){var r;(e instanceof z||e instanceof W||e instanceof G)&&t.push(((r={})[n]=e,r))}),t},t.hasPivotFields=function(){return this.pivotFields().length>0},t.make=function(t,e){return void 0===e&&(e=!1),e?this.fill({},t,!0):new this(t)},t.makePlain=function(t){return this.make(t,!0)},t.fix=function(t,e){void 0===e&&(e=["$id"]);var n=this.getFields();return Object.keys(t).reduce(function(r,o){var i=t[o],u=n[o];return e.includes(o)?(r[o]=i,r):u?(r[o]=u.fill(i),r):r},{})},t.fixMany=function(t,e){var n=this;return Object.keys(t).reduce(function(r,o){return r[o]=n.fix(t[o],e),r},{})},t.hydrate=function(t,e){void 0===e&&(e=["$id"]);var n=this.getFields(),r=Object.keys(n).reduce(function(e,r){var o=n[r],i=t[r];return e[r]=o.fill(i),e},{});return Object.keys(t).reduce(function(n,r){return e.includes(r)&&void 0!==t[r]&&(n[r]=t[r]),n},r)},t.hydrateMany=function(t,e){var n=this;return Object.keys(t).reduce(function(r,o){return r[o]=n.hydrate(t[o],e),r},{})},t.fill=function(t,e,n){void 0===t&&(t={}),void 0===e&&(e={}),void 0===n&&(n=!1);var r=this.getFields();return Object.keys(r).reduce(function(t,o){var i=r[o],u=e[o];return t[o]=i.make(u,e,o,n),t},t)},t.prototype.$self=function(){return this.constructor},t.prototype.$fields=function(){return this.$self().fields()},t.prototype.$store=function(){return this.$self().store()},t.prototype.$namespace=function(t){return this.$self().namespace(t)},t.prototype.$dispatch=function(t,e){return this.$self().dispatch(t,e)},t.prototype.$getters=function(t){return this.$self().getters(t)},t.prototype.$create=function(t){return Z(this,void 0,void 0,function(){return Q(this,function(e){return[2,this.$dispatch("create",t)]})})},t.prototype.$insert=function(t){return Z(this,void 0,void 0,function(){return Q(this,function(e){return[2,this.$dispatch("insert",t)]})})},t.prototype.$update=function(t){return Z(this,void 0,void 0,function(){return Q(this,function(e){return Array.isArray(t)?[2,this.$dispatch("update",t)]:void 0!==t.where?[2,this.$dispatch("update",t)]:void 0===this.$self().id(t)?[2,this.$dispatch("update",{where:this.$id,data:t})]:[2,this.$dispatch("update",t)]})})},t.prototype.$insertOrUpdate=function(t){return Z(this,void 0,void 0,function(){return Q(this,function(e){return[2,this.$dispatch("insertOrUpdate",t)]})})},t.prototype.$all=function(){return this.$getters("all")()},t.prototype.$find=function(t){return this.$getters("find")(t)},t.prototype.$query=function(){return this.$getters("query")()},t.prototype.$delete=function(t){return Z(this,void 0,void 0,function(){return Q(this,function(e){return t=void 0===t?this.$id:t,[2,this.$dispatch("delete",t)]})})},t.prototype.$fill=function(t){this.$self().fill(this,t)},t.prototype.$toJson=function(){return this.$self().makePlain(this)},t.primaryKey="id"}();function Y(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function X(t,e){return t(e={exports:{}},e.exports),e.exports}var tt=X(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.isImmutable=function(t){return!(!t||"function"!=typeof t.hasOwnProperty||!(t.hasOwnProperty("__ownerID")||t._map&&t._map.hasOwnProperty("__ownerID")))},e.denormalizeImmutable=function(t,e,n){return Object.keys(t).reduce(function(e,r){var o=""+r;return e.has(o)?e.set(o,n(e.get(o),t[o])):e},e)}});Y(tt);tt.isImmutable,tt.denormalizeImmutable;var et=X(function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r=Object.assign||function(t){for(var e=1;e1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!e||"string"!=typeof e)throw new Error("Expected a string key for Entity, but found "+e+".");var i=o.idAttribute,a=void 0===i?"id":i,c=o.mergeStrategy,s=void 0===c?function(t,e){return r({},t,e)}:c,f=o.processStrategy,l=void 0===f?function(t){return r({},t)}:f;this._key=e,this._getId="function"==typeof a?a:u(a),this._idAttribute=a,this._mergeStrategy=s,this._processStrategy=l,this.define(n)}return o(t,[{key:"define",value:function(t){this.schema=Object.keys(t).reduce(function(e,n){var o=t[n];return r({},e,function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}({},n,o))},this.schema||{})}},{key:"getId",value:function(t,e,n){return this._getId(t,e,n)}},{key:"merge",value:function(t,e){return this._mergeStrategy(t,e)}},{key:"normalize",value:function(t,e,r,o,i){var u=this,a=this._processStrategy(t,e,r);return Object.keys(this.schema).forEach(function(t){if(a.hasOwnProperty(t)&&"object"===n(a[t])){var e=u.schema[t];a[t]=o(a[t],a,t,e,i)}}),i(this,a,t,e,r),this.getId(t,e,r)}},{key:"denormalize",value:function(t,e){var n=this;return i.isImmutable(t)?i.denormalizeImmutable(this.schema,t,e):(Object.keys(this.schema).forEach(function(r){if(t.hasOwnProperty(r)){var o=n.schema[r];t[r]=e(t[r],o)}}),t)}},{key:"key",get:function(){return this._key}},{key:"idAttribute",get:function(){return this._idAttribute}}]),t}();e.default=a});Y(et);var nt=X(function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e){for(var n=0;n1)throw new Error("Expected schema definition to be a single schema, but found "+t.length+".");return t[0]},i=function(t){return Array.isArray(t)?t:Object.keys(t).map(function(e){return t[e]})},u=(e.normalize=function(t,e,n,r,u,a){return t=o(t),i(e).map(function(e,o){return u(e,n,r,t,a)})},e.denormalize=function(t,e,n){return t=o(t),e&&e.map?e.map(function(e){return n(e,t)}):e},function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,r.default),n(e,[{key:"normalize",value:function(t,e,n,r,o){var u=this;return i(t).map(function(t,i){return u.normalizeValue(t,e,n,r,o)}).filter(function(t){return void 0!==t&&null!==t})}},{key:"denormalize",value:function(t,e){var n=this;return t&&t.map?t.map(function(t){return n.denormalizeValue(t,e)}):t}}]),e}());e.default=u});Y(it);it.denormalize,it.normalize;var ut=X(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.denormalize=e.normalize=void 0;var n=function(){function t(t,e){for(var n=0;n0&&t.withAllRecursive(e-1)})},t.parseWithRelations=function(t,e,n){var r=this,o=e[0];o.split("|").forEach(function(e){r.setEagerLoad(t,e)}),1!==e.length?(e.shift(),this.addNestedWiths(t,e,n)):this.setEagerLoad(t,o,n)},t.addNestedWiths=function(t,e,n){var r=e.join(".");this.setEagerLoad(t,r,function(t){t.with(r,n)})},t.eagerLoadRelations=function(t,e){var n=t.model.getFields();for(var r in t.load){var o=n[r];o instanceof x&&o.load(t,e,r)}},t}(),Ot=function(){function t(t){this.query=t}return t.on=function(t,e,n){void 0===n&&(n=!1);var r=this.lastHookId+1;return this.lastHookId=r,this.hooks[t]||(this.hooks[t]=[]),this.hooks[t].push({callback:e,once:n,uid:r}),r},t.off=function(t){var e=this,n=!1;return Object.keys(this.hooks).some(function(r){var o=e.hooks[r],i=o.findIndex(function(e){return e.uid===t});return-1!==i&&(o.splice(i,1),n=!0),n}),n},t.prototype.self=function(){return this.constructor},t.prototype.getActionHook=function(t){return this.query.actionContext&&this.query.module.actions&&this.query.module.actions[t]||null},t.prototype.getGlobalHook=function(t){return this.self().hooks[t]?this.self().hooks[t]:null},t.prototype.has=function(t){return!!this.getActionHook(t)||!!this.getGlobalHook(t)},t.prototype.execute=function(t,e){return this.has(t)?(e=this.executeActionHook(t,e),e=this.executeGlobalHook(t,e)):e},t.prototype.executeActionHook=function(t,e){if(!this.query.actionContext)return e;var n=this.getActionHook(t);if(!n)return e;var r=n(this.query.actionContext,e);return!1!==r&&(r||e)},t.prototype.executeGlobalHook=function(t,e){var n=this;if(!1===e)return!1;var r=this.getGlobalHook(t);if(!r)return e;var o=[];return r.forEach(function(t,r){var i=t.callback,u=t.once;e=i.call(n.query,e,n.query.entity),u&&o.push(r)}),o.reverse().forEach(function(t){r.splice(t,1)}),e},t.prototype.executeOnRecords=function(t,e){var n=this;return this.has(t)?Object.keys(e).reduce(function(r,o){var i=e[o],u=n.execute(t,i);return!1===u?r:(r[o]=u,r)},{}):e},t.prototype.executeOnCollection=function(t,e){var n=this;return this.has(t)?(e.map(function(e){n.execute(t,e)}),e):e},t.hooks={},t.lastHookId=0,t}(),xt=function(){return(xt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n0&&(o[i]=u),o},{})},t.prototype.getPersistMethod=function(t,e,n){return n.create&&n.create.includes(t)?"create":n.insert&&n.insert.includes(t)?"insert":n.update&&n.update.includes(t)?"update":n.insertOrUpdate&&n.insertOrUpdate.includes(t)?"insertOrUpdate":e},t.prototype.normalize=function(t){return vt.normalize(this,t)},t.prototype.merge=function(t,e,n){var r=this,o=n||this.model.getFields();a.forOwn(t,function(t,n){var i=o[n];i instanceof c?e[n]=t:r.merge(t,e[n],i)})},t.prototype.all=function(){return this.get()},t.prototype.find=function(t){var e=this.state.data[t];return e?this.item(xt({},e)):null},t.prototype.get=function(){var t=this.process();return this.collect(t)},t.prototype.first=function(){var t=this.process();return this.item(t[0])},t.prototype.last=function(){var t=this.process(),e=t.length-1;return this.item(t[e])},t.prototype.records=function(t){var e=t||this.state.data;return Object.keys(e).map(function(t){return xt({},e[t])})},t.prototype.where=function(t,e){return this.wheres.push({field:t,value:e,boolean:"and"}),this},t.prototype.orWhere=function(t,e){return this.wheres.push({field:t,value:e,boolean:"or"}),this},t.prototype.orderBy=function(t,e){return void 0===e&&(e="asc"),this.orders.push({field:t,direction:e}),this},t.prototype.offset=function(t){return this._offset=t,this},t.prototype.limit=function(t){return this._limit=t,this},t.prototype.with=function(t,e){return void 0===e&&(e=null),wt.with(this,t,e),this},t.prototype.withAll=function(t){return void 0===t&&(t=function(){return null}),wt.withAll(this,t),this},t.prototype.withAllRecursive=function(t){return void 0===t&&(t=3),wt.withAllRecursive(this,t),this},t.prototype.has=function(t,e,n){return this.addHasConstraint(t,e,n,!0)},t.prototype.hasNot=function(t,e,n){return this.addHasConstraint(t,e,n,!1)},t.prototype.addHasConstraint=function(t,e,n,r){var o=this.matchesHasRelation(t,e,n,r);return this.where("$id",function(t){return o.includes(t)}),this},t.prototype.whereHas=function(t,e){return this.addWhereHasConstraint(t,e,!0)},t.prototype.whereHasNot=function(t,e){return this.addWhereHasConstraint(t,e,!1)},t.prototype.addWhereHasConstraint=function(t,e,n){var r=this.matchesWhereHasRelation(t,e,n);return this.where("$id",function(t){return r.includes(t)}),this},t.prototype.process=function(){var t=this.records();return t=this.hook.execute("beforeProcess",t),t=this.filterWhere(t),t=this.hook.execute("afterWhere",t),t=this.filterOrderBy(t),t=this.hook.execute("afterOrderBy",t),t=this.filterLimit(t),t=this.hook.execute("afterLimit",t)},t.prototype.filterWhere=function(t){return bt.where(this,t)},t.prototype.filterOrderBy=function(t){return bt.orderBy(this,t)},t.prototype.filterLimit=function(t){return bt.limit(this,t)},t.prototype.count=function(){return this.plain().get().length},t.prototype.max=function(t){var e=this.plain().get().reduce(function(e,n){return"number"==typeof n[t]&&e.push(n[t]),e},[]);return 0===e.length?0:Math.max.apply(Math,e)},t.prototype.min=function(t){var e=this.plain().get().reduce(function(e,n){return"number"==typeof n[t]&&e.push(n[t]),e},[]);return 0===e.length?0:Math.min.apply(Math,e)},t.prototype.sum=function(t){return this.plain().get().reduce(function(e,n){return"number"==typeof n[t]&&(e+=n[t]),e},0)},t.prototype.item=function(t){return t?(wt.eagerLoadRelations(this,[t]),this.model.make(t,!this.wrap)):null},t.prototype.collect=function(t){var e=this;return a.isEmpty(t)?[]:(wt.eagerLoadRelations(this,t),t.map(function(t){return e.model.make(t,!e.wrap)}))},t.prototype.matchesHasRelation=function(e,n,r,o){var i;void 0===o&&(o=!0),void 0===n?i=function(t){return t.length>=1}:"number"==typeof n?i=function(t){return t.length>=n}:"="===n&&"number"==typeof r?i=function(t){return t.length===r}:">"===n&&"number"==typeof r?i=function(t){return t.length>r}:">="===n&&"number"==typeof r?i=function(t){return t.length>=r}:"<"===n&&"number"==typeof r?i=function(t){return t.length0&&o[o.length-1])&&(6===i[0]||2===i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]0&&o[o.length-1])&&(6===i[0]||2===i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]t>=200&&t<300,maxRedirects:5,socketPath:null,proxy:{},onResponse:t=>t.data,onUnauthorised(t){},onNotFound(t){},onServerError(t){},onGenericError(t){},onValidationError(t){},onError(t){switch(t.response.status){case 401:this.onUnauthorised(t);break;case 404:this.onNotFound(t);break;case 422:this.onValidationError(t);break;case 500:this.onServerError(t);break;default:this.onGenericError(t)}return Promise.reject(t)}},Wt={database:new Nt,http:Dt},Ht={getters:{loading:t=>t.loading,errors:t=>t.errors},mutations:{onRequest(t){t.loading=!0,t.errors=[]},onError(t,e){t.loading=!1,t.errors=e.data},onSuccess(t){t.loading=!1,t.errors=[]}},state:{loading:!1,errors:[]}},Vt={http:Dt,methods:{$fetch:{name:"fetch",http:{url:"",method:"get"}},$get:{name:"get",http:{url:"/:id",method:"get"}},$create:{name:"create",alias:["insert"],http:{url:"",method:"post"}},$update:{name:"update",http:{url:"/:id",method:"put"}},$delete:{name:"delete",http:{url:"/:id",method:"delete"}}}};class Gt{constructor(t,e){if(this.components=t,this.options=o.a.merge({},Wt,e),this.database=e.database,!e.database)throw new Error("database option is required to initialise!")}static setup(t,e){return this.instance=new Gt(t,e),this.instance}static getInstance(){return this.instance}getModelFromState(t){return o.a.find(this.database.entities,{name:t.$name}).model}}class Jt{static transformModule(t){return o.a.merge({},Ht,t)}static transformModel(t){const e=Gt.getInstance();return Vt.http=o.a.merge({},Vt.http,e.options.http),t.methodConf=o.a.merge({},Vt,t.methodConf),t.methodConf.http.url="/"===t.methodConf.http.url?`/${t.entity}`:t.methodConf.http.url,t.getFields=(()=>(t.cachedFields||(t.cachedFields=o.a.merge({},{$id:t.attr(void 0),$isUpdating:t.boolean(!1),$updateErrors:t.attr([]),$isDeleting:t.boolean(!1),$deleteErrors:t.attr([])},t.fields())),t.cachedFields)),t}static transformParams(t,e,n={}){let r=`${e.methodConf.http.url}${e.methodConf.methods[t].http.url}`,i=o.a.map(r.match(/(\/?)(\:)([A-z]*)/gm),t=>t.replace("/",""));return o.a.forEach(i,t=>{r=r.replace(t,n.params[t.replace(":")]?foundParam:"").replace("//","/")}),n.query&&(r+=`?${Object.keys(n.query).map(t=>`${encodeURIComponent(t)}=${encodeURIComponent(n.query[t])}`).join("&")}`),r}}var Zt=n(15),Qt=n.n(Zt);class Yt{constructor(t){return this.instance=Qt.a.create(t),t.access_token&&(this.instance.defaults.headers.common.Authorization=`Bearer ${t.access_token}`),this.instance.interceptors.response.use(e=>t.onResponse(e),e=>t.onError(e)),this.instance}async head(t,e={}){return this.instance.head(t,e)}async get(t,e={}){return this.instance.get(t,e)}async post(t,e={},n={}){return this.instance.post(t,e,n)}async patch(t,e={},n={}){return this.instance.patch(t,e,n)}async put(t,e={},n={}){return this.instance.put(t,e,n)}async delete(t,e={}){return this.instance.delete(t,e)}}class Xt extends Jt{static async call({state:t,commit:e},n={}){const r=Gt.getInstance().getModelFromState(t),o=Jt.transformParams("$fetch",r,n),i=new Yt(r.methodConf.http).get(o);return this.onRequest(e),i.then(t=>this.onSuccess(e,r,t)).catch(t=>this.onError(e,t)),i}static onRequest(t){t("onRequest")}static onSuccess(t,e,n){t("onSuccess"),e.insertOrUpdate({data:n})}static onError(t,e){t("onError",e)}}class te extends Jt{static async call({state:t,commit:e},n={}){const r=Gt.getInstance().getModelFromState(t),o=Jt.transformParams("$get",r,n),i=new Yt(r.methodConf.http).get(o);return this.onRequest(e),i.then(t=>this.onSuccess(e,r,t)).catch(t=>this.onError(e,t)),i}static onRequest(t){t("onRequest")}static onSuccess(t,e,n){t("onSuccess"),e.insertOrUpdate({data:n})}static onError(t,e){t("onError",e)}}class ee extends Jt{static async call({state:t,commit:e},n={}){if(!n.data||"object"!=typeof n)throw new TypeError("You must include a data object in the params to send a POST request",n);const r=Gt.getInstance().getModelFromState(t),o=Jt.transformParams("$create",r,n),i=new Yt(r.methodConf.http).post(o,n.data);return this.onRequest(e),i.then(t=>this.onSuccess(e,r,t)).catch(t=>this.onError(e,t)),i}static onRequest(t){t("onRequest")}static onSuccess(t,e,n){t("onSuccess"),e.insertOrUpdate({data:n})}static onError(t,e){t("onError",e)}}class ne extends Jt{static async call({state:t,commit:e},n={}){if(!n.data||"object"!=typeof n)throw new TypeError("You must include a data object in the params to send a POST request",n);const r=Gt.getInstance().getModelFromState(t),o=Jt.transformParams("$update",r,n),i=new Yt(r.methodConf.http).put(o,n.data);return this.onRequest(r,n),i.then(t=>this.onSuccess(r,n,t)).catch(t=>this.onError(r,n,t)),i}static onRequest(t,e){t.update({where:e.params.id,data:{$isUpdating:!0,$updateErrors:[]}})}static onSuccess(t,e,n){t.update({where:e.params.id||n.id,data:o.a.merge({},n,{$isUpdating:!1,$updateErrors:[]})})}static onError(t,e,n){t.update({where:e.params.id,data:{$isUpdating:!1,$updateErrors:n}})}}class re extends Jt{static async call({state:t,commit:e},n={}){const r=Gt.getInstance().getModelFromState(t),o=Jt.transformParams("$delete",r,n),i=new Yt(r.methodConf.http).delete(o);return this.onRequest(r,n),i.then(t=>this.onSuccess(r,n,t)).catch(t=>this.onError(r,n,t)),i}static onRequest(t,e){t.update({where:e.params.id,data:{$isDeleting:!0,$deleteErrors:[]}})}static onSuccess(t,e,n){t.delete({where:e.params.id||n.id})}static onError(t,e,n){t.update({where:e.params.id,data:{$isDeleting:!1,$deleteErrors:n}})}}class oe{constructor(t,e){Gt.setup(t,e),this.setupActions(),this.setupModels()}setupActions(){const t=Gt.getInstance();t.components.Actions.$fetch=Xt.call.bind(Xt),t.components.Actions.$get=te.call.bind(te),t.components.Actions.$create=ee.call.bind(ee),t.components.Actions.$update=ne.call.bind(ne),t.components.Actions.$delete=re.call.bind(re)}setupModels(){const t=Gt.getInstance();_.map(t.database.entities,t=>(t.module=Jt.transformModule(t.module),t.model=Jt.transformModel(t.model),t)),t.components.Model.$fetch=function(t={}){return this.dispatch("$fetch",t)},t.components.Model.$get=function(t={}){return this.dispatch("$get",t)},t.components.Model.$create=function(t={}){return this.dispatch("$create",t)},t.components.Model.$update=function(t={}){return this.dispatch("$update",t)},t.components.Model.$delete=function(t={}){return this.dispatch("$delete",t)}}}n.d(e,"default",function(){return ie});class ie{static install(t,e){return new oe(t,e)}}}])}); \ No newline at end of file