diff --git a/packages/@jsonql/client/package.json b/packages/@jsonql/client/package.json index def154cc63f3a9e1b1df5ce1ef661d4d4b0b6119..fff95ad130aa4022f5f8beac1cc74964ed6741fa 100644 --- a/packages/@jsonql/client/package.json +++ b/packages/@jsonql/client/package.json @@ -49,7 +49,7 @@ "@jsonql/ws": "^0.8.4" }, "devDependencies": { - "@jsonql/koa": "^0.7.1", + "@jsonql/koa": "^0.7.2", "ava": "^2.4.0", "browser-env": "^3.3.0", "debug": "^4.1.1", diff --git a/packages/@jsonql/koa/package.json b/packages/@jsonql/koa/package.json index 2ae9f4fc98fc905bc0d710c3319662b8d332ba80..04f22d5283e21aca68c00d0f4c7113eec5f48c59 100644 --- a/packages/@jsonql/koa/package.json +++ b/packages/@jsonql/koa/package.json @@ -1,6 +1,6 @@ { "name": "@jsonql/koa", - "version": "0.7.1", + "version": "0.7.2", "description": "This is the all in one package to start your jsonql project with Koa, jsonql-koa, jsonql-ws-server and more", "main": "index.js", "files": [ @@ -60,16 +60,16 @@ "debug": "^4.1.1", "fs-extra": "^8.1.0", "jsonql-constants": "^1.8.12", - "jsonql-koa": "^1.4.20", + "jsonql-koa": "^1.4.21", "jsonql-params-validator": "^1.4.13", - "jsonql-utils": "^0.8.10", + "jsonql-utils": "^0.8.11", "koa": "^2.11.0", "koa-bodyparser": "^4.2.1", "koa-cors": "0.0.16", "yargs": "^15.0.2" }, "optionalDependencies": { - "jsonql-ws-server": "^1.4.5" + "jsonql-ws-server": "^1.4.9" }, "bin": { "jsonql-koa-cli": "./cli.js" diff --git a/packages/http-client/core.js b/packages/http-client/core.js index 25ddccec519dbf2db5a341e35ae84eb9391a1a1c..d09b651822e7b75fed57ce29c446c54941863aae 100644 --- a/packages/http-client/core.js +++ b/packages/http-client/core.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClient=e()}(this,(function(){"use strict";var t="application/vnd.api+json",e={Accept:t,"Content-Type":[t,"charset=utf-8"].join(";")},r=["POST","PUT"],n="type",o="optional",i="enumv",a="args",u="checker",c="alias",s="__checked__",f={desc:"y"},l="No message";var p="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},h="object"==typeof p&&p&&p.Object===Object&&p,d="object"==typeof self&&self&&self.Object===Object&&self,v=h||d||Function("return this")(),g=v.Symbol;function y(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&I(e,t[r],0)>-1;);return r}(n,o)+1).join("")}function Z(t){return void 0===t}var tt="[object Boolean]";var et="[object Number]";function rt(t){return function(t){return"number"==typeof t||T(t)&&E(t)==et}(t)&&t!=+t}var nt="[object String]";function ot(t){return"string"==typeof t||!b(t)&&T(t)&&E(t)==nt}function it(t,e){return function(r){return t(e(r))}}var at=it(Object.getPrototypeOf,Object),ut="[object Object]",ct=Function.prototype,st=Object.prototype,ft=ct.toString,lt=st.hasOwnProperty,pt=ft.call(Object);function ht(t){if(!T(t)||E(t)!=ut)return!1;var e=at(t);if(null===e)return!0;var r=lt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&ft.call(r)==pt}var dt,vt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[dt?a:++n];if(!1===e(o[u],u,o))break}return t};var gt="[object Arguments]";function yt(t){return T(t)&&E(t)==gt}var bt=Object.prototype,mt=bt.hasOwnProperty,_t=bt.propertyIsEnumerable,wt=yt(function(){return arguments}())?yt:function(t){return T(t)&&mt.call(t,"callee")&&!_t.call(t,"callee")};var jt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ot=jt&&"object"==typeof module&&module&&!module.nodeType&&module,St=Ot&&Ot.exports===jt?v.Buffer:void 0,At=(St?St.isBuffer:void 0)||function(){return!1},kt=9007199254740991,Et=/^(?:0|[1-9]\d*)$/;function Tt(t,e){var r=typeof t;return!!(e=null==e?kt:e)&&("number"==r||"symbol"!=r&&Et.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=xt}var qt={};qt["[object Float32Array]"]=qt["[object Float64Array]"]=qt["[object Int8Array]"]=qt["[object Int16Array]"]=qt["[object Int32Array]"]=qt["[object Uint8Array]"]=qt["[object Uint8ClampedArray]"]=qt["[object Uint16Array]"]=qt["[object Uint32Array]"]=!0,qt["[object Arguments]"]=qt["[object Array]"]=qt["[object ArrayBuffer]"]=qt["[object Boolean]"]=qt["[object DataView]"]=qt["[object Date]"]=qt["[object Error]"]=qt["[object Function]"]=qt["[object Map]"]=qt["[object Number]"]=qt["[object Object]"]=qt["[object RegExp]"]=qt["[object Set]"]=qt["[object String]"]=qt["[object WeakMap]"]=!1;var Ct,$t="object"==typeof exports&&exports&&!exports.nodeType&&exports,zt=$t&&"object"==typeof module&&module&&!module.nodeType&&module,Nt=zt&&zt.exports===$t&&h.process,Ft=function(){try{var t=zt&&zt.require&&zt.require("util").types;return t||Nt&&Nt.binding&&Nt.binding("util")}catch(t){}}(),It=Ft&&Ft.isTypedArray,Rt=It?(Ct=It,function(t){return Ct(t)}):function(t){return T(t)&&Pt(t.length)&&!!qt[E(t)]},Jt=Object.prototype.hasOwnProperty;function Mt(t,e){var r=b(t),n=!r&&wt(t),o=!r&&!n&&At(t),i=!r&&!n&&!o&&Rt(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},ne.prototype.set=function(t,e){var r=this.__data__,n=ee(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var oe,ie=v["__core-js_shared__"],ae=(oe=/[^.]+$/.exec(ie&&ie.keys&&ie.keys.IE_PROTO||""))?"Symbol(src)_1."+oe:"";var ue=Function.prototype.toString;function ce(t){if(null!=t){try{return ue.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var se=/^\[object .+?Constructor\]$/,fe=Function.prototype,le=Object.prototype,pe=fe.toString,he=le.hasOwnProperty,de=RegExp("^"+pe.call(he).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ve(t){return!(!Bt(t)||function(t){return!!ae&&ae in t}(t))&&(Yt(t)?de:se).test(ce(t))}function ge(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return ve(r)?r:void 0}var ye=ge(v,"Map"),be=ge(Object,"create");var me="__lodash_hash_undefined__",_e=Object.prototype.hasOwnProperty;var we=Object.prototype.hasOwnProperty;var je="__lodash_hash_undefined__";function Oe(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&Ce?new xe:void 0;for(i.set(t,e),i.set(e,t);++f0){if(++e>=_n)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(mn);function Sn(t,e){return On(function(t,e,r){return e=bn(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=bn(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=An.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!Bt(r))return!1;var n=typeof e;return!!("number"==n?Qt(r)&&Tt(e,r.length):"string"==n&&e in r)&&te(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0))},Vn=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},Gn=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!Bn(e)(t)})).length)})).length:e.length>e.filter((function(t){return!Kn(r,t)})).length},Wn=function(t,e){if(void 0===e&&(e=null),ht(t)){if(!e)return!0;if(Kn(e))return!e.filter((function(e){var r=t[e.name];return!(e.type.length>e.type.filter((function(t){var e;return!!Z(r)||(!1!==(e=Vn(t))?!Gn({arg:r},e):!Bn(t)(r))})).length)})).length}return!1},Yn=function(t){var e=t.arg,r=t.param,n=[e];return Array.isArray(r.keys)&&r.keys.length&&n.push(r.keys),Wn.apply(null,n)},Qn=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),Xn=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),Zn=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),to=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),eo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),ro=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),no=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),oo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),io=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),ao=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),uo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),co=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),so=Object.freeze({__proto__:null,Jsonql406Error:Qn,Jsonql500Error:Xn,JsonqlAuthorisationError:Zn,JsonqlContractAuthError:to,JsonqlResolverAppError:eo,JsonqlResolverNotFoundError:ro,JsonqlEnumError:no,JsonqlTypeError:oo,JsonqlCheckerError:io,JsonqlValidationError:ao,JsonqlError:uo,JsonqlServerError:co}),fo=uo,lo=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function po(t){if(lo(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||l,a=e.detail||e;if(o&&so[o])throw new so[r](i,a);throw new fo(i,a)}return t}function ho(t){if(Array.isArray(t))throw new ao("",t);var e=t.message||l,r=t.detail||t;switch(!0){case t instanceof Qn:throw new Qn(e,r);case t instanceof Xn:throw new Xn(e,r);case t instanceof Zn:throw new Zn(e,r);case t instanceof to:throw new to(e,r);case t instanceof eo:throw new eo(e,r);case t instanceof ro:throw new ro(e,r);case t instanceof no:throw new no(e,r);case t instanceof oo:throw new oo(e,r);case t instanceof io:throw new io(e,r);case t instanceof ao:throw new ao(e,r);case t instanceof co:throw new co(e,r);default:throw new uo(e,r)}}function vo(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,console,t)}catch(t){}}var go=function(t,e){var r;switch(!0){case"object"===t:return!Yn(e);case"array"===t:return!Kn(e.arg);case!1!==(r=Vn(t)):return!Gn(e,r);default:return!Bn(t)(e.arg)}},yo=function(t,e){return Z(t)?!0!==e.optional||Z(e.defaultvalue)?null:e.defaultvalue:t},bo=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!Kn(e))throw new uo("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!Kn(t))throw new uo("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return vo(1),t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:vo(2);var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:vo(4);var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?yo(t,a):t,index:r,param:a,optional:i}}));default:throw vo(5),new uo("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!$n(e)&&!(r.type.length>r.type.filter((function(e){return go(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return go(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},mo=function(t,e){var r,n=Object.keys(t);return r=e,!!n.filter((function(t){return t===r})).length},_o=function(t){return!$n(t)};function wo(t,e){var r=Cn(e,(function(t,e){return!t[Hn]}));return Sr(r,{})?t:function(t,e){var r={};return e=Yr(e),Zt(t,(function(t,n,o){Xr(r,e(t,n,o),t)})),r}(t,(function(t,e){return function(t,e,r){var n;return r(t,(function(t,r,o){if(e(t,r,o))return n=r,!1})),n}(r,Yr((function(t){return t.alias===e})),Zt)||e}))}function jo(t,e){return En(e,(function(e,r){var n,o;return Z(t[r])||!0===e[Jn]&&_o(t[r])?kn({},e,((n={})[Ln]=!0,n)):((o={})[Un]=t[r],o[Rn]=e[Rn],o[Jn]=e[Jn]||!1,o[Mn]=e[Mn]||!1,o[Dn]=e[Dn]||!1,o)}))}function Oo(t,e){var r=function(t,e){var r=wo(t,e);return{pristineValues:En(Cn(e,(function(t,e){return mo(r,e)})),(function(t){return t.args})),checkAgainstAppProps:Cn(e,(function(t,e){return!mo(r,e)})),config:r}}(t,e),n=r.config,o=r.pristineValues;return[jo(n,r.checkAgainstAppProps),o]}var So=function(t){return Kn(t)?t:[t]};var Ao=function(t,e){return!Kn(e)||function(t,e){return!!t.filter((function(t){return t===e})).length}(e,t)},ko=function(t,e){try{return!!Yt(e)&&e.apply(null,[t])}catch(t){return!1}};function Eo(t){return function(e,r){if(e[Ln])return e[Un];var n=function(t,e){var r,n=[[t[Un]],[(r={},r[Rn]=So(t[Rn]),r[Jn]=t[Jn],r)]];return Reflect.apply(e,null,n)}(e,t);if(n.length)throw vo("runValidationAction",r,e),new oo(r,n);if(!1!==e[Mn]&&!Ao(e[Un],e[Mn]))throw vo(Mn,e[Mn]),new no(r);if(!1!==e[Dn]&&!ko(e[Un],e[Dn]))throw vo(Dn,e[Dn]),new io(r);return e[Un]}}var To=function(t,e){return Promise.resolve(Oo(t,e))};function xo(t,e,r,n){return void 0===t&&(t={}),To(t,e).then((function(t){return function(t,e){var r=t[0],n=t[1],o=En(r,Eo(e));return kn(o,n)}(t,n)})).then((function(t){return kn({},t,r)}))}function Po(t,e,r,s,f,l){void 0===r&&(r=!1),void 0===s&&(s=!1),void 0===f&&(f=!1),void 0===l&&(l=!1);var p={};return p[a]=t,p[n]=e,!0===r&&(p[o]=!0),Kn(s)&&(p[i]=s),Yt(f)&&(p[u]=f),ot(l)&&(p[c]=l),p}var qo=Nn,Co=Kn,$o=function(t,e,r){return void 0===r&&(r=!1),new Promise((function(n,o){var i=bo(t,e,r);return r?i.error.length?o(i.error):n(i.data):i.length?o(i):n([])}))},zo=function(t,e,r){void 0===r&&(r={});var n=r[o],a=r[i],s=r[u],f=r[c];return Po.apply(null,[t,e,n,a,s,f])},No=function(t){return function(e,r,n){return void 0===n&&(n={}),xo(e,r,n,t)}}(bo),Fo="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var Io=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=ii().key(e);t(ai(r),r)}},remove:function(t){return ii().removeItem(t)},clearAll:function(){return ii().clear()}};function ii(){return ni.localStorage}function ai(t){return ii().getItem(t)}var ui=Uo.trim,ci={name:"cookieStorage",read:function(t){if(!t||!pi(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(si.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;si.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:fi,remove:li,clearAll:function(){fi((function(t,e){li(e)}))}},si=Uo.Global.document;function fi(t){for(var e=si.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(ui(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function li(t){t&&pi(t)&&(si.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function pi(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(si.cookie)}var hi=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var di="expire_mixin",vi=function(){var t=this.createStore(this.storage,null,this._namespacePrefix+di);return{set:function(e,r,n,o){this.hasNamespace(di)||t.set(r,o);return e()},get:function(t,r){this.hasNamespace(di)||e.call(this,r);return t()},remove:function(e,r){this.hasNamespace(di)||t.remove(r);return e()},getExpiration:function(e,r){return t.get(r)},removeExpiredKeys:function(t){var r=[];this.each((function(t,e){r.push(e)}));for(var n=0;n>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)}));var Oi=[oi,ci],Si=[hi,vi,_i,function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=ji.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=ji.compress(this._serialize(r));t(e,n)}}}],Ai=ti.createStore(Oi,Si),ki=Uo.Global;function Ei(){return ki.sessionStorage}function Ti(t){return Ei().getItem(t)}var xi=[{name:"sessionStorage",read:Ti,write:function(t,e){return Ei().setItem(t,e)},each:function(t){for(var e=Ei().length-1;e>=0;e--){var r=Ei().key(e);t(Ti(r),r)}},remove:function(t){return Ei().removeItem(t)},clearAll:function(){return Ei().clear()}},ci],Pi=[hi,vi],qi=ti.createStore(xi,Pi),Ci=Ai,$i=qi,zi=Array.isArray,Ni=void 0!==p?p:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Fi="object"==typeof Ni&&Ni&&Ni.Object===Object&&Ni,Ii="object"==typeof self&&self&&self.Object===Object&&self,Ri=(Fi||Ii||Function("return this")()).Symbol,Ji=Object.prototype,Mi=Ji.hasOwnProperty,Ui=Ji.toString,Di=Ri?Ri.toStringTag:void 0;var Hi=Object.prototype.toString;var Li="[object Null]",Bi="[object Undefined]",Ki=Ri?Ri.toStringTag:void 0;function Vi(t){return null==t?void 0===t?Bi:Li:Ki&&Ki in Object(t)?function(t){var e=Mi.call(t,Di),r=t[Di];try{t[Di]=void 0;var n=!0}catch(t){}var o=Ui.call(t);return n&&(e?t[Di]=r:delete t[Di]),o}(t):function(t){return Hi.call(t)}(t)}var Gi=function(t,e){return function(r){return t(e(r))}}(Object.getPrototypeOf,Object);function Wi(t){return null!=t&&"object"==typeof t}var Yi="[object Object]",Qi=Function.prototype,Xi=Object.prototype,Zi=Qi.toString,ta=Xi.hasOwnProperty,ea=Zi.call(Object);var ra=Ri?Ri.prototype:void 0,na=(ra&&ra.toString,"[object String]");function oa(t){return"string"==typeof t||!zi(t)&&Wi(t)&&Vi(t)==na}var ia=function(t,e){return!!t.filter((function(t){return t===e})).length},aa=function(t,e){var r=Object.keys(t);return ia(r,e)},ua=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},ca="query",sa="mutation",fa="socket",la="payload",pa="condition",ha=function(){try{if(window||document)return!0}catch(t){}return!1},da=function(){try{if(!ha()&&Ni)return!0}catch(t){}return!1};var va=function(t){function e(){for(var r=arguments,n=[],o=arguments.length;o--;)n[o]=r[o];t.apply(this,n),this.message=n[0],this.detail=n[1],this.className=e.name,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(function(t){function e(){for(var e=arguments,r=[],n=arguments.length;n--;)r[n]=e[n];t.apply(this,r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.where=function(){return ha()?"browser":da()?"node":"unknown"},e}(Error));var ga=function(t){var e;return(e={}).args=t,e};var ya=function(t){return aa(t,"data")&&!aa(t,"error")?t.data:t},ba=function(t){return function(t){if(!Wi(t)||Vi(t)!=Yi)return!1;var e=Gi(t);if(null===e)return!0;var r=ta.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Zi.call(r)==ea}(t)&&(aa(t,ca)||aa(t,sa)||aa(t,fa))},ma=function(t,e){return void 0===e&&(e={}),ba(e)?Promise.resolve(e):t.getContract()},_a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function wa(t){this.message=t}wa.prototype=new Error,wa.prototype.name="InvalidCharacterError";var ja="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new wa("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=_a.indexOf(n);return a};var Oa=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(ja(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return ja(e)}};function Sa(t){this.message=t}Sa.prototype=new Error,Sa.prototype.name="InvalidTokenError";var Aa=function(t,e){if("string"!=typeof t)throw new Sa("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Oa(t.split(".")[r]))}catch(t){throw new Sa("Invalid token specified: "+t.message)}},ka=Sa;Aa.InvalidTokenError=ka;var Ea,Ta,xa,Pa,qa,Ca,$a,za,Na,Fa=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Ia(t){if(qo(t))return function(t){var e=t.iat||Fa(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new uo("Token has expired on "+r,t)}return t}(Aa(t));throw new uo("Token must be a string!")}zo("HS256",["string"]),zo(!1,["boolean","number","string"],((Ea={})[c]="exp",Ea[o]=!0,Ea)),zo(!1,["boolean","number","string"],((Ta={})[c]="nbf",Ta[o]=!0,Ta)),zo(!1,["boolean","string"],((xa={})[c]="iss",xa[o]=!0,xa)),zo(!1,["boolean","string"],((Pa={})[c]="sub",Pa[o]=!0,Pa)),zo(!1,["boolean","string"],((qa={})[c]="iss",qa[o]=!0,qa)),zo(!1,["boolean"],((Ca={})[o]=!0,Ca)),zo(!1,["boolean","string"],(($a={})[o]=!0,$a)),zo(!1,["boolean","string"],((za={})[o]=!0,za)),zo(!1,["boolean"],((Na={})[o]=!0,Na));var Ra=r[0],Ja=r[1],Ma=function(t){!function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,null,t)}catch(t){}}(t),this.fly=t.Fly?new t.Fly:new Fly,this.opts=t,this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()},Ua={headers:{configurable:!0}};Ua.headers.set=function(t){this.extraHeader=t},Ma.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=kn({},{_cb:ua()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=kn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}return this.fly.request(this.jsonqlEndpoint,t,kn({},{method:Ra,params:o},e))},Ma.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},Ma.prototype.processJsonp=function(t){return ya(t)},Ma.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call"),e.cleanUp();var o=qo(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):ya(o)}),(function(t){throw e.cleanUp(),console.error(t),new co("Server side error",t)}))},Ma.prototype.getHeaders=function(){return this.opts.enableAuth?kn({},e,this.getAuthHeader(),this.extraHeader):kn({},e,this.extraHeader)},Ma.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},Ma.prototype.get=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=kn({},this.extraParams,f)),this.request({},{method:"GET"},this.contractHeader).then(po).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e}))},Ma.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){var n;if(void 0===e&&(e=[]),void 0===r&&(r=!1),oa(t)&&zi(e)){var o=ga(e);return!0===r?o:((n={})[t]=o,n)}throw new va("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(po)},Ma.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){var o;void 0===r&&(r={}),void 0===n&&(n=!1);var i={};if(i[la]=e,i[pa]=r,!0===n)return i;if(oa(t))return(o={})[t]=i,o;throw new va("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Ja}).then(po)},Object.defineProperties(Ma.prototype,Ua);var Da=function(t){function e(e,r){void 0===r&&(r=null),r&&(e.Fly=r),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={storeIt:{configurable:!0},jsonqlEndpoint:{configurable:!0},jsonqlContract:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return r.storeIt.set=function(t){throw console.info("storeIt",t),Co(t)&&t.length>=2&&Reflect.apply(Ci.set,Ci,t),new ao("Expect argument to be array and least 2 items!")},r.jsonqlEndpoint.set=function(t){var e=Ci.get("endpoint")||[];ia(e,t)||(e.push(t),this.storeId=["endpoint",e],this.endpointIndex=e.length-1)},r.jsonqlContract.set=function(t){var e=this.opts.storageKey,r=[e],n=t[0],o=t[1],i=Ci.get(e)||[];i[this.endpointIndex||0]=n,r.push(i),o&&r.push(o),this.opts.keepContract&&(this.storeIt=r)},r.jsonqlToken.set=function(t){var e="credential",r=localStorage.get(e)||[];if(!ia(r,t)){var n=r.length-1;r[n]=t,this[e+"Index"]=n;var o=[e,r];if(this.opts.tokenExpired){var i=parseFloat(this.opts.tokenExpired);if(!isNaN(i)&&i>0){var a=ua();o.push(a+parseFloat(i))}}return this.storeIt=o,this.jsonqlUserdata=this.decoder(t),t}return!1},r.jsonqlUserdata.set=function(t){var e=["userdata",t];return t.exp&&e.push(t.exp),Reflect.apply(Ci.set,Ci,e)},r.jsonqlEndpoint.get=function(){var t=Ci.get("endpoint");if(!t){var e=this.opts,r=[e.hostname,e.jsonqlPath].join("/");return this.jsonqlEndpoint=r,r}return t[this.endpointIndex]},r.jsonqlContract.get=function(){var t=this.opts.storageKey;return(Ci.get(t)||[])[this.endpointIndex]||!1},r.jsonqlToken.get=function(){var t="credential",e=localStorage.get(t);return!!e&&e[this[t+"Index"]]},r.jsonqlUserdata.get=function(){return $i.get("userdata")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&e.useJwt&&(this.setDecoder=Ia)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={userdata:{configurable:!0},rawAuthToken:{configurable:!0},setDecoder:{configurable:!0}};return r.userdata.get=function(){return this.jsonqlUserdata},r.rawAuthToken.get=function(){return this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},e.prototype.storeToken=function(t){return this.jsonqlToken=t},e.prototype.decoder=function(t){return t},e.prototype.getAuthHeader=function(){var t,e=this.rawAuthToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();if(this.log("getContract first call",t),t&&Array.isArray(t)){var e=t[this.endpointIndex||0];if(e)return Promise.resolve(e)}return this.get().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){if(!ba(t))throw new ao("Contract is malformed!");var e=[t];if(this.opts.contractExpired){var r=parseFloat(this.opts.contractExpired);!isNaN(r)&&r>0&&e.push(r)}return this.jsonqlContract=e,this.log("storeContract return result",t),t},e.prototype.readContract=function(){return ba(this.opts.contract)?this.opts.contract:Ci.get(this.opts.storageKey)},Object.defineProperties(e.prototype,r),e}(Ma))),Ha=function(t){return b(t)?t:[t]},La=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,Ha(t))}),Reflect.apply(t,null,r))}};function Ba(t,e,r,n){void 0===n&&(n=!1);var o=function(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Ka=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return $o(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(ho)}},Va=function(t,e,r,n,o){var i={},a=function(t){i=Ba(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return $o(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(ho)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Ga=function(t,e,r,n,o){var i={},a=function(t){i=Ba(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return $o(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(ho)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Wa=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Ka(e,a,0,o);return i.apply(null,t).then(e.postLoginAction).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Ka(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var Ya=function(t,e,r,n){var o=function(t,e,r,n){return La(Va,Ga,Wa)({},t,e,r,n)}(t,n,e,r);return e.enableAuth&&(o.userdata=function(){return t.userdata}),o.getToken=function(){return t.rawAuthToken},e.exposeContract&&(o.getContract=function(){return t.getContract()}),o.eventEmitter=n,o.version="1.4.6",o},Qa={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:t,BEARER:"Bearer",AUTH_HEADER:"Authorization"},Xa={hostname:zo(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:zo("jsonql",["string"]),loginHandlerName:zo("login",["string"]),logoutHandlerName:zo("logout",["string"]),enableJsonp:zo(!1,["boolean"]),enableAuth:zo(!1,["boolean"]),useJwt:zo(!0,["boolean"]),useLocalstorage:zo(!0,["boolean"]),storageKey:zo("storageKey",["string"]),authKey:zo("authKey",["string"]),contractExpired:zo(0,["number"]),keepContract:zo(!0,["boolean"]),exposeContract:zo(!1,["boolean"]),showContractDesc:zo(!1,["boolean"]),contractKey:zo(!1,["boolean"]),contractKeyName:zo("X-JSONQL-CV-KEY",["string"]),enableTimeout:zo(!1,["boolean"]),timeout:zo(5e3,["number"]),returnInstance:zo(!1,["boolean"]),allowReturnRawToken:zo(!1,["boolean"]),debugOn:zo(!1,["boolean"])};function Za(t){return t[s]?t:function(t){var e=t.contract;return No(t,Xa,Qa).then((function(t){return t.contract=e,t}))}(t)}var tu=new WeakMap,eu=new WeakMap;var ru=function(){this.__suspend__=null,this.queueStore=new Set},nu={$suspend:{configurable:!0},$queues:{configurable:!0}};nu.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},ru.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},nu.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},ru.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(ru.prototype,nu);var ou=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){tu.set(this,t)},r.normalStore.get=function(){return tu.get(this)},r.lazyStore.set=function(t){eu.set(this,t)},r.lazyStore.get=function(){return eu.get(this)},e.prototype.hashFnToKey=function(t){return t.toString().split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)+""},Object.defineProperties(e.prototype,r),e}(ru));return function(t,e){var r;return function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r=null),Za(e).then((function(t){return{baseClient:new Da(t,r),opts:t}})).then((function(e){var r=e.baseClient,n=e.opts;return ma(r,n.contract).then((function(e){return Ya(r,n,e,t)}))}))}((r=e.debugOn,new ou({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),e,t)}})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClient=e()}(this,(function(){"use strict";var t="application/vnd.api+json",e={Accept:t,"Content-Type":[t,"charset=utf-8"].join(";")},r=["POST","PUT"],n="type",o="optional",i="enumv",a="args",u="checker",c="alias",s="__checked__",f={desc:"y"},l="No message";var p="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},h="object"==typeof p&&p&&p.Object===Object&&p,d="object"==typeof self&&self&&self.Object===Object&&self,v=h||d||Function("return this")(),g=v.Symbol;function y(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&I(e,t[r],0)>-1;);return r}(n,o)+1).join("")}function Z(t){return void 0===t}var tt="[object Boolean]";var et="[object Number]";function rt(t){return function(t){return"number"==typeof t||T(t)&&E(t)==et}(t)&&t!=+t}var nt="[object String]";function ot(t){return"string"==typeof t||!b(t)&&T(t)&&E(t)==nt}function it(t,e){return function(r){return t(e(r))}}var at=it(Object.getPrototypeOf,Object),ut="[object Object]",ct=Function.prototype,st=Object.prototype,ft=ct.toString,lt=st.hasOwnProperty,pt=ft.call(Object);function ht(t){if(!T(t)||E(t)!=ut)return!1;var e=at(t);if(null===e)return!0;var r=lt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&ft.call(r)==pt}var dt,vt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[dt?a:++n];if(!1===e(o[u],u,o))break}return t};var gt="[object Arguments]";function yt(t){return T(t)&&E(t)==gt}var bt=Object.prototype,mt=bt.hasOwnProperty,_t=bt.propertyIsEnumerable,wt=yt(function(){return arguments}())?yt:function(t){return T(t)&&mt.call(t,"callee")&&!_t.call(t,"callee")};var jt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ot=jt&&"object"==typeof module&&module&&!module.nodeType&&module,St=Ot&&Ot.exports===jt?v.Buffer:void 0,At=(St?St.isBuffer:void 0)||function(){return!1},kt=9007199254740991,Et=/^(?:0|[1-9]\d*)$/;function Tt(t,e){var r=typeof t;return!!(e=null==e?kt:e)&&("number"==r||"symbol"!=r&&Et.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=xt}var qt={};qt["[object Float32Array]"]=qt["[object Float64Array]"]=qt["[object Int8Array]"]=qt["[object Int16Array]"]=qt["[object Int32Array]"]=qt["[object Uint8Array]"]=qt["[object Uint8ClampedArray]"]=qt["[object Uint16Array]"]=qt["[object Uint32Array]"]=!0,qt["[object Arguments]"]=qt["[object Array]"]=qt["[object ArrayBuffer]"]=qt["[object Boolean]"]=qt["[object DataView]"]=qt["[object Date]"]=qt["[object Error]"]=qt["[object Function]"]=qt["[object Map]"]=qt["[object Number]"]=qt["[object Object]"]=qt["[object RegExp]"]=qt["[object Set]"]=qt["[object String]"]=qt["[object WeakMap]"]=!1;var Ct,$t="object"==typeof exports&&exports&&!exports.nodeType&&exports,zt=$t&&"object"==typeof module&&module&&!module.nodeType&&module,Nt=zt&&zt.exports===$t&&h.process,Ft=function(){try{var t=zt&&zt.require&&zt.require("util").types;return t||Nt&&Nt.binding&&Nt.binding("util")}catch(t){}}(),It=Ft&&Ft.isTypedArray,Rt=It?(Ct=It,function(t){return Ct(t)}):function(t){return T(t)&&Pt(t.length)&&!!qt[E(t)]},Jt=Object.prototype.hasOwnProperty;function Mt(t,e){var r=b(t),n=!r&&wt(t),o=!r&&!n&&At(t),i=!r&&!n&&!o&&Rt(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},ne.prototype.set=function(t,e){var r=this.__data__,n=ee(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var oe,ie=v["__core-js_shared__"],ae=(oe=/[^.]+$/.exec(ie&&ie.keys&&ie.keys.IE_PROTO||""))?"Symbol(src)_1."+oe:"";var ue=Function.prototype.toString;function ce(t){if(null!=t){try{return ue.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var se=/^\[object .+?Constructor\]$/,fe=Function.prototype,le=Object.prototype,pe=fe.toString,he=le.hasOwnProperty,de=RegExp("^"+pe.call(he).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ve(t){return!(!Bt(t)||function(t){return!!ae&&ae in t}(t))&&(Yt(t)?de:se).test(ce(t))}function ge(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return ve(r)?r:void 0}var ye=ge(v,"Map"),be=ge(Object,"create");var me="__lodash_hash_undefined__",_e=Object.prototype.hasOwnProperty;var we=Object.prototype.hasOwnProperty;var je="__lodash_hash_undefined__";function Oe(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&Ce?new xe:void 0;for(i.set(t,e),i.set(e,t);++f0){if(++e>=_n)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(mn);function Sn(t,e){return On(function(t,e,r){return e=bn(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=bn(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=An.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!Bt(r))return!1;var n=typeof e;return!!("number"==n?Qt(r)&&Tt(e,r.length):"string"==n&&e in r)&&te(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0))},Vn=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},Gn=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!Bn(e)(t)})).length)})).length:e.length>e.filter((function(t){return!Kn(r,t)})).length},Wn=function(t,e){if(void 0===e&&(e=null),ht(t)){if(!e)return!0;if(Kn(e))return!e.filter((function(e){var r=t[e.name];return!(e.type.length>e.type.filter((function(t){var e;return!!Z(r)||(!1!==(e=Vn(t))?!Gn({arg:r},e):!Bn(t)(r))})).length)})).length}return!1},Yn=function(t){var e=t.arg,r=t.param,n=[e];return Array.isArray(r.keys)&&r.keys.length&&n.push(r.keys),Wn.apply(null,n)},Qn=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),Xn=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),Zn=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),to=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),eo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),ro=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),no=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),oo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),io=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),ao=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),uo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),co=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),so=Object.freeze({__proto__:null,Jsonql406Error:Qn,Jsonql500Error:Xn,JsonqlAuthorisationError:Zn,JsonqlContractAuthError:to,JsonqlResolverAppError:eo,JsonqlResolverNotFoundError:ro,JsonqlEnumError:no,JsonqlTypeError:oo,JsonqlCheckerError:io,JsonqlValidationError:ao,JsonqlError:uo,JsonqlServerError:co}),fo=uo,lo=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function po(t){if(lo(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||l,a=e.detail||e;if(o&&so[o])throw new so[r](i,a);throw new fo(i,a)}return t}function ho(t){if(Array.isArray(t))throw new ao("",t);var e=t.message||l,r=t.detail||t;switch(!0){case t instanceof Qn:throw new Qn(e,r);case t instanceof Xn:throw new Xn(e,r);case t instanceof Zn:throw new Zn(e,r);case t instanceof to:throw new to(e,r);case t instanceof eo:throw new eo(e,r);case t instanceof ro:throw new ro(e,r);case t instanceof no:throw new no(e,r);case t instanceof oo:throw new oo(e,r);case t instanceof io:throw new io(e,r);case t instanceof ao:throw new ao(e,r);case t instanceof co:throw new co(e,r);default:throw new uo(e,r)}}function vo(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,console,t)}catch(t){}}var go=function(t,e){var r;switch(!0){case"object"===t:return!Yn(e);case"array"===t:return!Kn(e.arg);case!1!==(r=Vn(t)):return!Gn(e,r);default:return!Bn(t)(e.arg)}},yo=function(t,e){return Z(t)?!0!==e.optional||Z(e.defaultvalue)?null:e.defaultvalue:t},bo=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!Kn(e))throw new uo("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!Kn(t))throw new uo("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return vo(1),t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:vo(2);var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:vo(4);var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?yo(t,a):t,index:r,param:a,optional:i}}));default:throw vo(5),new uo("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!$n(e)&&!(r.type.length>r.type.filter((function(e){return go(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return go(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},mo=function(t,e){var r,n=Object.keys(t);return r=e,!!n.filter((function(t){return t===r})).length},_o=function(t){return!$n(t)};function wo(t,e){var r=Cn(e,(function(t,e){return!t[Hn]}));return Sr(r,{})?t:function(t,e){var r={};return e=Yr(e),Zt(t,(function(t,n,o){Xr(r,e(t,n,o),t)})),r}(t,(function(t,e){return function(t,e,r){var n;return r(t,(function(t,r,o){if(e(t,r,o))return n=r,!1})),n}(r,Yr((function(t){return t.alias===e})),Zt)||e}))}function jo(t,e){return En(e,(function(e,r){var n,o;return Z(t[r])||!0===e[Jn]&&_o(t[r])?kn({},e,((n={})[Ln]=!0,n)):((o={})[Un]=t[r],o[Rn]=e[Rn],o[Jn]=e[Jn]||!1,o[Mn]=e[Mn]||!1,o[Dn]=e[Dn]||!1,o)}))}function Oo(t,e){var r=function(t,e){var r=wo(t,e);return{pristineValues:En(Cn(e,(function(t,e){return mo(r,e)})),(function(t){return t.args})),checkAgainstAppProps:Cn(e,(function(t,e){return!mo(r,e)})),config:r}}(t,e),n=r.config,o=r.pristineValues;return[jo(n,r.checkAgainstAppProps),o]}var So=function(t){return Kn(t)?t:[t]};var Ao=function(t,e){return!Kn(e)||function(t,e){return!!t.filter((function(t){return t===e})).length}(e,t)},ko=function(t,e){try{return!!Yt(e)&&e.apply(null,[t])}catch(t){return!1}};function Eo(t){return function(e,r){if(e[Ln])return e[Un];var n=function(t,e){var r,n=[[t[Un]],[(r={},r[Rn]=So(t[Rn]),r[Jn]=t[Jn],r)]];return Reflect.apply(e,null,n)}(e,t);if(n.length)throw vo("runValidationAction",r,e),new oo(r,n);if(!1!==e[Mn]&&!Ao(e[Un],e[Mn]))throw vo(Mn,e[Mn]),new no(r);if(!1!==e[Dn]&&!ko(e[Un],e[Dn]))throw vo(Dn,e[Dn]),new io(r);return e[Un]}}var To=function(t,e){return Promise.resolve(Oo(t,e))};function xo(t,e,r,n){return void 0===t&&(t={}),To(t,e).then((function(t){return function(t,e){var r=t[0],n=t[1],o=En(r,Eo(e));return kn(o,n)}(t,n)})).then((function(t){return kn({},t,r)}))}function Po(t,e,r,s,f,l){void 0===r&&(r=!1),void 0===s&&(s=!1),void 0===f&&(f=!1),void 0===l&&(l=!1);var p={};return p[a]=t,p[n]=e,!0===r&&(p[o]=!0),Kn(s)&&(p[i]=s),Yt(f)&&(p[u]=f),ot(l)&&(p[c]=l),p}var qo=Nn,Co=Kn,$o=function(t,e,r){return void 0===r&&(r=!1),new Promise((function(n,o){var i=bo(t,e,r);return r?i.error.length?o(i.error):n(i.data):i.length?o(i):n([])}))},zo=function(t,e,r){void 0===r&&(r={});var n=r[o],a=r[i],s=r[u],f=r[c];return Po.apply(null,[t,e,n,a,s,f])},No=function(t){return function(e,r,n){return void 0===n&&(n={}),xo(e,r,n,t)}}(bo),Fo="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var Io=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=ii().key(e);t(ai(r),r)}},remove:function(t){return ii().removeItem(t)},clearAll:function(){return ii().clear()}};function ii(){return ni.localStorage}function ai(t){return ii().getItem(t)}var ui=Uo.trim,ci={name:"cookieStorage",read:function(t){if(!t||!pi(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(si.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;si.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:fi,remove:li,clearAll:function(){fi((function(t,e){li(e)}))}},si=Uo.Global.document;function fi(t){for(var e=si.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(ui(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function li(t){t&&pi(t)&&(si.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function pi(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(si.cookie)}var hi=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var di="expire_mixin",vi=function(){var t=this.createStore(this.storage,null,this._namespacePrefix+di);return{set:function(e,r,n,o){this.hasNamespace(di)||t.set(r,o);return e()},get:function(t,r){this.hasNamespace(di)||e.call(this,r);return t()},remove:function(e,r){this.hasNamespace(di)||t.remove(r);return e()},getExpiration:function(e,r){return t.get(r)},removeExpiredKeys:function(t){var r=[];this.each((function(t,e){r.push(e)}));for(var n=0;n>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)}));var Oi=[oi,ci],Si=[hi,vi,_i,function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=ji.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=ji.compress(this._serialize(r));t(e,n)}}}],Ai=ti.createStore(Oi,Si),ki=Uo.Global;function Ei(){return ki.sessionStorage}function Ti(t){return Ei().getItem(t)}var xi=[{name:"sessionStorage",read:Ti,write:function(t,e){return Ei().setItem(t,e)},each:function(t){for(var e=Ei().length-1;e>=0;e--){var r=Ei().key(e);t(Ti(r),r)}},remove:function(t){return Ei().removeItem(t)},clearAll:function(){return Ei().clear()}},ci],Pi=[hi,vi],qi=ti.createStore(xi,Pi),Ci=Ai,$i=qi,zi=Array.isArray,Ni=void 0!==p?p:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Fi="object"==typeof Ni&&Ni&&Ni.Object===Object&&Ni,Ii="object"==typeof self&&self&&self.Object===Object&&self,Ri=(Fi||Ii||Function("return this")()).Symbol,Ji=Object.prototype,Mi=Ji.hasOwnProperty,Ui=Ji.toString,Di=Ri?Ri.toStringTag:void 0;var Hi=Object.prototype.toString;var Li="[object Null]",Bi="[object Undefined]",Ki=Ri?Ri.toStringTag:void 0;function Vi(t){return null==t?void 0===t?Bi:Li:Ki&&Ki in Object(t)?function(t){var e=Mi.call(t,Di),r=t[Di];try{t[Di]=void 0;var n=!0}catch(t){}var o=Ui.call(t);return n&&(e?t[Di]=r:delete t[Di]),o}(t):function(t){return Hi.call(t)}(t)}var Gi=function(t,e){return function(r){return t(e(r))}}(Object.getPrototypeOf,Object);function Wi(t){return null!=t&&"object"==typeof t}var Yi="[object Object]",Qi=Function.prototype,Xi=Object.prototype,Zi=Qi.toString,ta=Xi.hasOwnProperty,ea=Zi.call(Object);var ra=Ri?Ri.prototype:void 0,na=(ra&&ra.toString,"[object String]");function oa(t){return"string"==typeof t||!zi(t)&&Wi(t)&&Vi(t)==na}var ia=function(t,e){return!!t.filter((function(t){return t===e})).length},aa=function(t,e){var r=Object.keys(t);return ia(r,e)},ua=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},ca="query",sa="mutation",fa="socket",la="payload",pa="condition",ha=function(){try{if(window||document)return!0}catch(t){}return!1},da=function(){try{if(!ha()&&Ni)return!0}catch(t){}return!1};var va=function(t){function e(){for(var r=arguments,n=[],o=arguments.length;o--;)n[o]=r[o];t.apply(this,n),this.message=n[0],this.detail=n[1],this.className=e.name,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(function(t){function e(){for(var e=arguments,r=[],n=arguments.length;n--;)r[n]=e[n];t.apply(this,r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.where=function(){return ha()?"browser":da()?"node":"unknown"},e}(Error));var ga=function(t){var e;return(e={}).args=t,e};var ya=function(t){return aa(t,"data")&&!aa(t,"error")?t.data:t},ba=function(t){return function(t){if(!Wi(t)||Vi(t)!=Yi)return!1;var e=Gi(t);if(null===e)return!0;var r=ta.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Zi.call(r)==ea}(t)&&(aa(t,ca)||aa(t,sa)||aa(t,fa))},ma=function(t,e){return void 0===e&&(e={}),ba(e)?Promise.resolve(e):t.getContract()},_a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function wa(t){this.message=t}wa.prototype=new Error,wa.prototype.name="InvalidCharacterError";var ja="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new wa("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=_a.indexOf(n);return a};var Oa=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(ja(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return ja(e)}};function Sa(t){this.message=t}Sa.prototype=new Error,Sa.prototype.name="InvalidTokenError";var Aa=function(t,e){if("string"!=typeof t)throw new Sa("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Oa(t.split(".")[r]))}catch(t){throw new Sa("Invalid token specified: "+t.message)}},ka=Sa;Aa.InvalidTokenError=ka;var Ea,Ta,xa,Pa,qa,Ca,$a,za,Na,Fa=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Ia(t){if(qo(t))return function(t){var e=t.iat||Fa(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new uo("Token has expired on "+r,t)}return t}(Aa(t));throw new uo("Token must be a string!")}zo("HS256",["string"]),zo(!1,["boolean","number","string"],((Ea={})[c]="exp",Ea[o]=!0,Ea)),zo(!1,["boolean","number","string"],((Ta={})[c]="nbf",Ta[o]=!0,Ta)),zo(!1,["boolean","string"],((xa={})[c]="iss",xa[o]=!0,xa)),zo(!1,["boolean","string"],((Pa={})[c]="sub",Pa[o]=!0,Pa)),zo(!1,["boolean","string"],((qa={})[c]="iss",qa[o]=!0,qa)),zo(!1,["boolean"],((Ca={})[o]=!0,Ca)),zo(!1,["boolean","string"],(($a={})[o]=!0,$a)),zo(!1,["boolean","string"],((za={})[o]=!0,za)),zo(!1,["boolean"],((Na={})[o]=!0,Na));var Ra=r[0],Ja=r[1],Ma=function(t){!function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,null,t)}catch(t){}}(t),this.fly=t.Fly?new t.Fly:new Fly,this.opts=t,this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()},Ua={headers:{configurable:!0}};Ua.headers.set=function(t){this.extraHeader=t},Ma.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=kn({},{_cb:ua()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=kn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}return this.fly.request(this.jsonqlEndpoint,t,kn({},{method:Ra,params:o},e))},Ma.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},Ma.prototype.processJsonp=function(t){return ya(t)},Ma.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call"),e.cleanUp();var o=qo(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):ya(o)}),(function(t){throw e.cleanUp(),console.error(t),new co("Server side error",t)}))},Ma.prototype.getHeaders=function(){return this.opts.enableAuth?kn({},e,this.getAuthHeader(),this.extraHeader):kn({},e,this.extraHeader)},Ma.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},Ma.prototype.get=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=kn({},this.extraParams,f)),this.request({},{method:"GET"},this.contractHeader).then(po).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e}))},Ma.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){var n;if(void 0===e&&(e=[]),void 0===r&&(r=!1),oa(t)&&zi(e)){var o=ga(e);return!0===r?o:((n={})[t]=o,n)}throw new va("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(po)},Ma.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){var o;void 0===r&&(r={}),void 0===n&&(n=!1);var i={};if(i[la]=e,i[pa]=r,!0===n)return i;if(oa(t))return(o={})[t]=i,o;throw new va("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Ja}).then(po)},Object.defineProperties(Ma.prototype,Ua);var Da=function(t){function e(e,r){void 0===r&&(r=null),r&&(e.Fly=r),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={storeIt:{configurable:!0},jsonqlEndpoint:{configurable:!0},jsonqlContract:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return r.storeIt.set=function(t){throw console.info("storeIt",t),Co(t)&&t.length>=2&&Reflect.apply(Ci.set,Ci,t),new ao("Expect argument to be array and least 2 items!")},r.jsonqlEndpoint.set=function(t){var e=Ci.get("endpoint")||[];ia(e,t)||(e.push(t),this.storeId=["endpoint",e],this.endpointIndex=e.length-1)},r.jsonqlContract.set=function(t){var e=this.opts.storageKey,r=[e],n=t[0],o=t[1],i=Ci.get(e)||[];i[this.endpointIndex||0]=n,r.push(i),o&&r.push(o),this.opts.keepContract&&(this.storeIt=r)},r.jsonqlToken.set=function(t){var e="credential",r=localStorage.get(e)||[];if(!ia(r,t)){var n=r.length-1;r[n]=t,this[e+"Index"]=n;var o=[e,r];if(this.opts.tokenExpired){var i=parseFloat(this.opts.tokenExpired);if(!isNaN(i)&&i>0){var a=ua();o.push(a+parseFloat(i))}}return this.storeIt=o,this.jsonqlUserdata=this.decoder(t),t}return!1},r.jsonqlUserdata.set=function(t){var e=["userdata",t];return t.exp&&e.push(t.exp),Reflect.apply(Ci.set,Ci,e)},r.jsonqlEndpoint.get=function(){var t=Ci.get("endpoint");if(!t){var e=this.opts,r=[e.hostname,e.jsonqlPath].join("/");return this.jsonqlEndpoint=r,r}return t[this.endpointIndex]},r.jsonqlContract.get=function(){var t=this.opts.storageKey;return(Ci.get(t)||[])[this.endpointIndex]||!1},r.jsonqlToken.get=function(){var t="credential",e=localStorage.get(t);return!!e&&e[this[t+"Index"]]},r.jsonqlUserdata.get=function(){return $i.get("userdata")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&e.useJwt&&(this.setDecoder=Ia)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={userdata:{configurable:!0},rawAuthToken:{configurable:!0},setDecoder:{configurable:!0}};return r.userdata.get=function(){return this.jsonqlUserdata},r.rawAuthToken.get=function(){return this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},e.prototype.storeToken=function(t){return this.jsonqlToken=t},e.prototype.decoder=function(t){return t},e.prototype.getAuthHeader=function(){var t,e=this.rawAuthToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();if(this.log("getContract first call",t),t&&Array.isArray(t)){var e=t[this.endpointIndex||0];if(e)return Promise.resolve(e)}return this.get().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){if(!ba(t))throw new ao("Contract is malformed!");var e=[t];if(this.opts.contractExpired){var r=parseFloat(this.opts.contractExpired);!isNaN(r)&&r>0&&e.push(r)}return this.jsonqlContract=e,this.log("storeContract return result",t),t},e.prototype.readContract=function(){return ba(this.opts.contract)?this.opts.contract:Ci.get(this.opts.storageKey)},Object.defineProperties(e.prototype,r),e}(Ma))),Ha=function(t){return b(t)?t:[t]},La=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,Ha(t))}),Reflect.apply(t,null,r))}};function Ba(t,e,r,n){void 0===n&&(n=!1);var o=function(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Ka=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return $o(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(ho)}},Va=function(t,e,r,n,o){var i={},a=function(t){i=Ba(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return $o(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(ho)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Ga=function(t,e,r,n,o){var i={},a=function(t){i=Ba(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return $o(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(ho)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Wa=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Ka(e,a,0,o);return i.apply(null,t).then(e.postLoginAction).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Ka(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var Ya=function(t,e,r,n){var o=function(t,e,r,n){return La(Va,Ga,Wa)({},t,e,r,n)}(t,n,e,r);return e.enableAuth&&(o.userdata=function(){return t.userdata}),o.getToken=function(){return t.rawAuthToken},e.exposeContract&&(o.getContract=function(){return t.getContract()}),o.eventEmitter=n,o.version="1.4.7",o},Qa={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:t,BEARER:"Bearer",AUTH_HEADER:"Authorization"},Xa={hostname:zo(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:zo("jsonql",["string"]),loginHandlerName:zo("login",["string"]),logoutHandlerName:zo("logout",["string"]),enableJsonp:zo(!1,["boolean"]),enableAuth:zo(!1,["boolean"]),useJwt:zo(!0,["boolean"]),useLocalstorage:zo(!0,["boolean"]),storageKey:zo("storageKey",["string"]),authKey:zo("authKey",["string"]),contractExpired:zo(0,["number"]),keepContract:zo(!0,["boolean"]),exposeContract:zo(!1,["boolean"]),showContractDesc:zo(!1,["boolean"]),contractKey:zo(!1,["boolean"]),contractKeyName:zo("X-JSONQL-CV-KEY",["string"]),enableTimeout:zo(!1,["boolean"]),timeout:zo(5e3,["number"]),returnInstance:zo(!1,["boolean"]),allowReturnRawToken:zo(!1,["boolean"]),debugOn:zo(!1,["boolean"])};function Za(t){return t[s]?t:function(t){var e=t.contract;return No(t,Xa,Qa).then((function(t){return t.contract=e,t}))}(t)}var tu=new WeakMap,eu=new WeakMap;var ru=function(){this.__suspend__=null,this.queueStore=new Set},nu={$suspend:{configurable:!0},$queues:{configurable:!0}};nu.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},ru.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},nu.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},ru.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(ru.prototype,nu);var ou=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){tu.set(this,t)},r.normalStore.get=function(){return tu.get(this)},r.lazyStore.set=function(t){eu.set(this,t)},r.lazyStore.get=function(){return eu.get(this)},e.prototype.hashFnToKey=function(t){return t.toString().split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)+""},Object.defineProperties(e.prototype,r),e}(ru));return function(t,e){var r;return function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r=null),Za(e).then((function(t){return{baseClient:new Da(t,r),opts:t}})).then((function(e){var r=e.baseClient,n=e.opts;return ma(r,n.contract).then((function(e){return Ya(r,n,e,t)}))}))}((r=e.debugOn,new ou({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),e,t)}})); //# sourceMappingURL=core.js.map diff --git a/packages/http-client/dist/jsonql-client.static.js b/packages/http-client/dist/jsonql-client.static.js index 0a40f29048f8caa0ab4e9548ccc4dd9a1dc24087..eff9e05b40692635b1cf6a2c6d6a7b58913acac0 100644 --- a/packages/http-client/dist/jsonql-client.static.js +++ b/packages/http-client/dist/jsonql-client.static.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClientStatic=e()}(this,(function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t,e){return t(e={exports:{}},e.exports),e.exports}var r,n=e((function(t,e){var r;r=function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(t,e,r){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};t.exports={type:function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},isObject:function(t,e){return e?"object"===this.type(t):t&&"object"===(void 0===t?"undefined":n(t))},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},trim:function(t){return t.replace(/(^\s*)|(\s*$)/g,"")},encode:function(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")},formatParams:function(t){var e="",r=!0,n=this;return this.isObject(t)?(function t(o,i){var a=n.encode,u=n.type(o);if("array"==u)o.forEach((function(e,r){n.isObject(e)||(r=""),t(e,i+"%5B"+r+"%5D")}));else if("object"==u)for(var c in o)t(o[c],i?i+"%5B"+a(c)+"%5D":a(c));else r||(e+="&"),r=!1,e+=i+"="+a(o)}(t,""),e):t},merge:function(t,e){for(var r in e)t.hasOwnProperty(r)?this.isObject(e[r],1)&&this.isObject(t[r],1)&&this.merge(t[r],e[r]):t[r]=e[r];return t}}},,function(t,e,r){var n=function(){function t(t,e){for(var r=0;r0&&(t+=(-1===t.indexOf("?")?"?":"&")+w.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==y&&(a.responseType=y)}catch(t){}var j=r.headers[u]||r.headers[c],O="application/x-www-form-urlencoded";for(var S in o.trim((j||"").toLowerCase())===O?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(O="application/json;charset=utf-8",e=JSON.stringify(e)),j||b||(r.headers[u]=O),r.headers)if(S===u&&o.isFormData(e))delete r.headers[S];else try{a.setRequestHeader(S,r.headers[S])}catch(t){}function E(t,e,n){v(l.p,(function(){if(t){n&&(e.request=r);var o=t.call(l,e,Promise);e=void 0===o?e:o}d(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){s(t)})).catch((function(t){h(t)}))}))}function k(t){t.engine=a,E(l.onerror,t,-1)}function A(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader(u)||"").indexOf("json")&&!o.isObject(t)&&(t=JSON.parse(t));var e=a.responseHeaders;if(!e){e={};var n=(a.getAllResponseHeaders()||"").split("\r\n");n.pop(),n.forEach((function(t){if(t){var r=t.split(":")[0];e[r]=a.getResponseHeader(r)}}))}var i=a.status,c=a.statusText,s={data:t,headers:e,status:i,statusText:c};if(o.merge(s,a._response),i>=200&&i<300||304===i)s.engine=a,s.request=r,E(l.handler,s,0);else{var f=new A(c,i);f.response=s,k(f)}}catch(f){k(new A(f.msg,a.status))}},a.onerror=function(t){k(new A(t.msg||"Network Error",0))},a.ontimeout=function(){k(new A("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(b?null:e)}),0)}(n):s(n)}),(function(t){h(t)}))}))}));return h.engine=a,h}},{key:"all",value:function(t){return Promise.all(t)}},{key:"spread",value:function(t){return function(e){return t.apply(null,e)}}}]),t}();a.default=a,["get","post","put","patch","head","delete"].forEach((function(t){a.prototype[t]=function(e,r,n){return this.request(e,r,o.merge({method:t},n))}})),["lock","unlock","clear"].forEach((function(t){a.prototype[t]=function(){this.interceptors.request[t]()}})),t.exports=a}])},t.exports=r()})),o=(r=n)&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,i="application/vnd.api+json",a={Accept:i,"Content-Type":[i,"charset=utf-8"].join(";")},u=["POST","PUT"],c="type",s="optional",f="enumv",l="args",p="checker",h="alias",d="__checked__",v={desc:"y"},g="No message",y="onResult",b="onError",m=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),_=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),w=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),j=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),O=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),S=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),E=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),k=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),A=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),x=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),T=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),P=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),q=Object.freeze({__proto__:null,Jsonql406Error:m,Jsonql500Error:_,JsonqlAuthorisationError:w,JsonqlContractAuthError:j,JsonqlResolverAppError:O,JsonqlResolverNotFoundError:S,JsonqlEnumError:E,JsonqlTypeError:k,JsonqlCheckerError:A,JsonqlValidationError:x,JsonqlError:T,JsonqlServerError:P}),C=T,$=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function N(t){if($(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||g,a=e.detail||e;if(o&&q[o])throw new q[r](i,a);throw new C(i,a)}return t}function z(t){if(Array.isArray(t))throw new x("",t);var e=t.message||g,r=t.detail||t;switch(!0){case t instanceof m:throw new m(e,r);case t instanceof _:throw new _(e,r);case t instanceof w:throw new w(e,r);case t instanceof j:throw new j(e,r);case t instanceof O:throw new O(e,r);case t instanceof S:throw new S(e,r);case t instanceof E:throw new E(e,r);case t instanceof k:throw new k(e,r);case t instanceof A:throw new A(e,r);case t instanceof x:throw new x(e,r);case t instanceof P:throw new P(e,r);default:throw new T(e,r)}}var F="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},R="object"==typeof F&&F&&F.Object===Object&&F,I="object"==typeof self&&self&&self.Object===Object&&self,J=R||I||Function("return this")(),M=J.Symbol;function U(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&ut(e,t[r],0)>-1;);return r}(n,o)+1).join("")}function Ot(t){return void 0===t}var St="[object Boolean]";var Et="[object Number]";function kt(t){return function(t){return"number"==typeof t||Q(t)&&X(t)==Et}(t)&&t!=+t}var At="[object String]";function xt(t){return"string"==typeof t||!D(t)&&Q(t)&&X(t)==At}function Tt(t,e){return function(r){return t(e(r))}}var Pt=Tt(Object.getPrototypeOf,Object),qt="[object Object]",Ct=Function.prototype,$t=Object.prototype,Nt=Ct.toString,zt=$t.hasOwnProperty,Ft=Nt.call(Object);function Rt(t){if(!Q(t)||X(t)!=qt)return!1;var e=Pt(t);if(null===e)return!0;var r=zt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Nt.call(r)==Ft}var It,Jt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[It?a:++n];if(!1===e(o[u],u,o))break}return t};var Mt="[object Arguments]";function Ut(t){return Q(t)&&X(t)==Mt}var Dt=Object.prototype,Ht=Dt.hasOwnProperty,Lt=Dt.propertyIsEnumerable,Bt=Ut(function(){return arguments}())?Ut:function(t){return Q(t)&&Ht.call(t,"callee")&&!Lt.call(t,"callee")};var Kt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Vt=Kt&&"object"==typeof module&&module&&!module.nodeType&&module,Gt=Vt&&Vt.exports===Kt?J.Buffer:void 0,Wt=(Gt?Gt.isBuffer:void 0)||function(){return!1},Yt=9007199254740991,Xt=/^(?:0|[1-9]\d*)$/;function Qt(t,e){var r=typeof t;return!!(e=null==e?Yt:e)&&("number"==r||"symbol"!=r&&Xt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=Zt}var ee={};ee["[object Float32Array]"]=ee["[object Float64Array]"]=ee["[object Int8Array]"]=ee["[object Int16Array]"]=ee["[object Int32Array]"]=ee["[object Uint8Array]"]=ee["[object Uint8ClampedArray]"]=ee["[object Uint16Array]"]=ee["[object Uint32Array]"]=!0,ee["[object Arguments]"]=ee["[object Array]"]=ee["[object ArrayBuffer]"]=ee["[object Boolean]"]=ee["[object DataView]"]=ee["[object Date]"]=ee["[object Error]"]=ee["[object Function]"]=ee["[object Map]"]=ee["[object Number]"]=ee["[object Object]"]=ee["[object RegExp]"]=ee["[object Set]"]=ee["[object String]"]=ee["[object WeakMap]"]=!1;var re,ne="object"==typeof exports&&exports&&!exports.nodeType&&exports,oe=ne&&"object"==typeof module&&module&&!module.nodeType&&module,ie=oe&&oe.exports===ne&&R.process,ae=function(){try{var t=oe&&oe.require&&oe.require("util").types;return t||ie&&ie.binding&&ie.binding("util")}catch(t){}}(),ue=ae&&ae.isTypedArray,ce=ue?(re=ue,function(t){return re(t)}):function(t){return Q(t)&&te(t.length)&&!!ee[X(t)]},se=Object.prototype.hasOwnProperty;function fe(t,e){var r=D(t),n=!r&&Bt(t),o=!r&&!n&&Wt(t),i=!r&&!n&&!o&&ce(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},Ae.prototype.set=function(t,e){var r=this.__data__,n=Ee(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var xe,Te=J["__core-js_shared__"],Pe=(xe=/[^.]+$/.exec(Te&&Te.keys&&Te.keys.IE_PROTO||""))?"Symbol(src)_1."+xe:"";var qe=Function.prototype.toString;function Ce(t){if(null!=t){try{return qe.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var $e=/^\[object .+?Constructor\]$/,Ne=Function.prototype,ze=Object.prototype,Fe=Ne.toString,Re=ze.hasOwnProperty,Ie=RegExp("^"+Fe.call(Re).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Je(t){return!(!ve(t)||function(t){return!!Pe&&Pe in t}(t))&&(_e(t)?Ie:$e).test(Ce(t))}function Me(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return Je(r)?r:void 0}var Ue=Me(J,"Map"),De=Me(Object,"create");var He="__lodash_hash_undefined__",Le=Object.prototype.hasOwnProperty;var Be=Object.prototype.hasOwnProperty;var Ke="__lodash_hash_undefined__";function Ve(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&rr?new Ze:void 0;for(i.set(t,e),i.set(e,t);++f0){if(++e>=Ln)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Hn);function Gn(t,e){return Vn(function(t,e,r){return e=Dn(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Dn(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Wn.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!ve(r))return!1;var n=typeof e;return!!("number"==n?we(r)&&Qt(e,r.length):"string"==n&&e in r)&&Se(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0))},bo=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},mo=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!go(e)(t)})).length)})).length:e.length>e.filter((function(t){return!yo(r,t)})).length},_o=function(t,e){if(void 0===e&&(e=null),Rt(t)){if(!e)return!0;if(yo(e))return!e.filter((function(e){var r=t[e.name];return!(e.type.length>e.type.filter((function(t){var e;return!!Ot(r)||(!1!==(e=bo(t))?!mo({arg:r},e):!go(t)(r))})).length)})).length}return!1},wo=function(t){var e=t.arg,r=t.param,n=[e];return Array.isArray(r.keys)&&r.keys.length&&n.push(r.keys),_o.apply(null,n)};function jo(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,console,t)}catch(t){}}var Oo=function(t,e){var r;switch(!0){case"object"===t:return!wo(e);case"array"===t:return!yo(e.arg);case!1!==(r=bo(t)):return!mo(e,r);default:return!go(t)(e.arg)}},So=function(t,e){return Ot(t)?!0!==e.optional||Ot(e.defaultvalue)?null:e.defaultvalue:t},Eo=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!yo(e))throw new T("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!yo(t))throw new T("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return jo(1),t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:jo(2);var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:jo(4);var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?So(t,a):t,index:r,param:a,optional:i}}));default:throw jo(5),new T("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!no(e)&&!(r.type.length>r.type.filter((function(e){return Oo(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Oo(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},ko=function(t,e){var r,n=Object.keys(t);return r=e,!!n.filter((function(t){return t===r})).length},Ao=function(t){return!no(t)};function xo(t,e){var r=ro(e,(function(t,e){return!t[ho]}));return Gr(r,{})?t:function(t,e){var r={};return e=wn(e),Oe(t,(function(t,n,o){On(r,e(t,n,o),t)})),r}(t,(function(t,e){return function(t,e,r){var n;return r(t,(function(t,r,o){if(e(t,r,o))return n=r,!1})),n}(r,wn((function(t){return t.alias===e})),Oe)||e}))}function To(t,e){return Xn(e,(function(e,r){var n,o;return Ot(t[r])||!0===e[so]&&Ao(t[r])?Yn({},e,((n={})[vo]=!0,n)):((o={})[lo]=t[r],o[co]=e[co],o[so]=e[so]||!1,o[fo]=e[fo]||!1,o[po]=e[po]||!1,o)}))}function Po(t,e){var r=function(t,e){var r=xo(t,e);return{pristineValues:Xn(ro(e,(function(t,e){return ko(r,e)})),(function(t){return t.args})),checkAgainstAppProps:ro(e,(function(t,e){return!ko(r,e)})),config:r}}(t,e),n=r.config,o=r.pristineValues;return[To(n,r.checkAgainstAppProps),o]}var qo=function(t){return yo(t)?t:[t]};var Co=function(t,e){return!yo(e)||function(t,e){return!!t.filter((function(t){return t===e})).length}(e,t)},$o=function(t,e){try{return!!_e(e)&&e.apply(null,[t])}catch(t){return!1}};function No(t){return function(e,r){if(e[vo])return e[lo];var n=function(t,e){var r,n=[[t[lo]],[(r={},r[co]=qo(t[co]),r[so]=t[so],r)]];return Reflect.apply(e,null,n)}(e,t);if(n.length)throw jo("runValidationAction",r,e),new k(r,n);if(!1!==e[fo]&&!Co(e[lo],e[fo]))throw jo(fo,e[fo]),new E(r);if(!1!==e[po]&&!$o(e[lo],e[po]))throw jo(po,e[po]),new A(r);return e[lo]}}function zo(t,e,r,n){return void 0===t&&(t={}),Yn(function(t,e){var r=t[0],n=t[1],o=Xn(r,No(e));return Yn(o,n)}(Po(t,e),n),r)}function Fo(t,e,r,n,o,i){void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===o&&(o=!1),void 0===i&&(i=!1);var a={};return a[l]=t,a[c]=e,!0===r&&(a[s]=!0),yo(n)&&(a[f]=n),_e(o)&&(a[p]=o),xt(i)&&(a[h]=i),a}var Ro=io,Io=yo,Jo=function(t,e,r){return void 0===r&&(r=!1),new Promise((function(n,o){var i=Eo(t,e,r);return r?i.error.length?o(i.error):n(i.data):i.length?o(i):n([])}))},Mo=function(t,e,r){void 0===r&&(r={});var n=r[s],o=r[f],i=r[p],a=r[h];return Fo.apply(null,[t,e,n,o,i,a])},Uo=function(t){return function(e,r,n){return void 0===n&&(n={}),zo(e,r,n,t)}}(Eo),Do=function(t){return D(t)?t:[t]},Ho=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,Do(t))}),Reflect.apply(t,null,r))}};function Lo(t,e,r,n){void 0===n&&(n=!1);var o=function(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Bo=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Jo(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(z)}},Ko=function(t,e,r,n,o){var i={},a=function(t){i=Lo(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Jo(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(z)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Vo=function(t,e,r,n,o){var i={},a=function(t){i=Lo(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return Jo(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(z)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Go=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Bo(e,a,0,o);return i.apply(null,t).then(e.postLoginAction).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Bo(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var Wo=Array.isArray,Yo=void 0!==F?F:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Xo="object"==typeof Yo&&Yo&&Yo.Object===Object&&Yo,Qo="object"==typeof self&&self&&self.Object===Object&&self,Zo=(Xo||Qo||Function("return this")()).Symbol,ti=Object.prototype,ei=ti.hasOwnProperty,ri=ti.toString,ni=Zo?Zo.toStringTag:void 0;var oi=Object.prototype.toString;var ii="[object Null]",ai="[object Undefined]",ui=Zo?Zo.toStringTag:void 0;function ci(t){return null==t?void 0===t?ai:ii:ui&&ui in Object(t)?function(t){var e=ei.call(t,ni),r=t[ni];try{t[ni]=void 0;var n=!0}catch(t){}var o=ri.call(t);return n&&(e?t[ni]=r:delete t[ni]),o}(t):function(t){return oi.call(t)}(t)}var si=function(t,e){return function(r){return t(e(r))}}(Object.getPrototypeOf,Object);function fi(t){return null!=t&&"object"==typeof t}var li="[object Object]",pi=Function.prototype,hi=Object.prototype,di=pi.toString,vi=hi.hasOwnProperty,gi=di.call(Object);var yi=Zo?Zo.prototype:void 0,bi=(yi&&yi.toString,"[object String]");function mi(t){return"string"==typeof t||!Wo(t)&&fi(t)&&ci(t)==bi}var _i=function(t,e){return!!t.filter((function(t){return t===e})).length},wi=function(t,e){var r=Object.keys(t);return _i(r,e)},ji=function(){for(var t=arguments,e=[],r=arguments.length;r--;)e[r]=t[r];return e.join("_")},Oi=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},Si="query",Ei="mutation",ki="socket",Ai="payload",xi="condition",Ti=function(){try{if(window||document)return!0}catch(t){}return!1},Pi=function(){try{if(!Ti()&&Yo)return!0}catch(t){}return!1};var qi=function(t){function e(){for(var r=arguments,n=[],o=arguments.length;o--;)n[o]=r[o];t.apply(this,n),this.message=n[0],this.detail=n[1],this.className=e.name,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(function(t){function e(){for(var e=arguments,r=[],n=arguments.length;n--;)r[n]=e[n];t.apply(this,r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.where=function(){return Ti()?"browser":Pi()?"node":"unknown"},e}(Error));var Ci=function(t){var e;return(e={}).args=t,e};var $i=function(t){return wi(t,"data")&&!wi(t,"error")?t.data:t},Ni=function(t){return function(t){if(!fi(t)||ci(t)!=li)return!1;var e=si(t);if(null===e)return!0;var r=vi.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&di.call(r)==gi}(t)&&(wi(t,Si)||wi(t,Ei)||wi(t,ki))},zi=function(t,e){return void 0===e&&(e={}),Ni(e)?Promise.resolve(e):t.getContract()},Fi=function(t,e){return function(r){for(var n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return new Promise((function(o,i){t.$only(ji(e,r,y),o),t.$only(ji(e,r,b),i),t.$trigger(e,{resolverName:r,args:n})}))}},Ri=function(t,e,r){var n=t.$queues,o=r.debugOn;o&&console.info("(validateRegisteredEvents)","storedEvt",n),n.forEach((function(t){var r=t[0],n=t[1].resolverName;if(o&&console.info("(validateRegisteredEvents)",r,n),!e[r][n])throw new Error(r+"."+n+" not existed in contract!")}))};function Ii(t,e,r,n){var o=function(t,e,r,n){return Ho(Ko,Vo,Go)({},t,e,r,n)}(t,e,r,n);Ri(e,n,r);var i=function(t){e.$only(t,(function(r){var n=r.resolverName,i=r.args;o[t][n]?Reflect.apply(o[t][n],null,i).then((function(r){e.$trigger(ji(t,n,y),r)})).catch((function(r){e.$trigger(ji(t,n,b),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}var Ji=function(t,e,r,n){n.$suspend=!0,r.then((function(r){Ii(t,n,e,r)}));var o={query:Fi(n,"query"),mutation:Fi(n,"mutation"),auth:Fi(n,"auth"),getToken:function(){return t.rawAuthToken}};return e.exposeContract&&(o.getContract=function(){return t.get()}),e.enableAuth&&(o.userdata=function(){return t.userdata}),o.version="1.4.6",o},Mi=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=ca().key(e);t(sa(r),r)}},remove:function(t){return ca().removeItem(t)},clearAll:function(){return ca().clear()}};function ca(){return aa.localStorage}function sa(t){return ca().getItem(t)}var fa=Li.trim,la={name:"cookieStorage",read:function(t){if(!t||!va(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(pa.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;pa.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:ha,remove:da,clearAll:function(){ha((function(t,e){da(e)}))}},pa=Li.Global.document;function ha(t){for(var e=pa.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(fa(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function da(t){t&&va(t)&&(pa.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function va(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(pa.cookie)}var ga=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var ya="expire_mixin",ba=function(){var t=this.createStore(this.storage,null,this._namespacePrefix+ya);return{set:function(e,r,n,o){this.hasNamespace(ya)||t.set(r,o);return e()},get:function(t,r){this.hasNamespace(ya)||e.call(this,r);return t()},remove:function(e,r){this.hasNamespace(ya)||t.remove(r);return e()},getExpiration:function(e,r){return t.get(r)},removeExpiredKeys:function(t){var r=[];this.each((function(t,e){r.push(e)}));for(var n=0;n>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)}));var ka=[ua,la],Aa=[ga,ba,Oa,function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Ea.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Ea.compress(this._serialize(r));t(e,n)}}}],xa=na.createStore(ka,Aa),Ta=Li.Global;function Pa(){return Ta.sessionStorage}function qa(t){return Pa().getItem(t)}var Ca=[{name:"sessionStorage",read:qa,write:function(t,e){return Pa().setItem(t,e)},each:function(t){for(var e=Pa().length-1;e>=0;e--){var r=Pa().key(e);t(qa(r),r)}},remove:function(t){return Pa().removeItem(t)},clearAll:function(){return Pa().clear()}},la],$a=[ga,ba],Na=na.createStore(Ca,$a),za=xa,Fa=Na,Ra="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Ia(t){this.message=t}Ia.prototype=new Error,Ia.prototype.name="InvalidCharacterError";var Ja="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Ia("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=Ra.indexOf(n);return a};var Ma=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(Ja(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return Ja(e)}};function Ua(t){this.message=t}Ua.prototype=new Error,Ua.prototype.name="InvalidTokenError";var Da=function(t,e){if("string"!=typeof t)throw new Ua("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Ma(t.split(".")[r]))}catch(t){throw new Ua("Invalid token specified: "+t.message)}},Ha=Ua;Da.InvalidTokenError=Ha;var La,Ba,Ka,Va,Ga,Wa,Ya,Xa,Qa,Za=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function tu(t){if(Ro(t))return function(t){var e=t.iat||Za(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new T("Token has expired on "+r,t)}return t}(Da(t));throw new T("Token must be a string!")}Mo("HS256",["string"]),Mo(!1,["boolean","number","string"],((La={})[h]="exp",La[s]=!0,La)),Mo(!1,["boolean","number","string"],((Ba={})[h]="nbf",Ba[s]=!0,Ba)),Mo(!1,["boolean","string"],((Ka={})[h]="iss",Ka[s]=!0,Ka)),Mo(!1,["boolean","string"],((Va={})[h]="sub",Va[s]=!0,Va)),Mo(!1,["boolean","string"],((Ga={})[h]="iss",Ga[s]=!0,Ga)),Mo(!1,["boolean"],((Wa={})[s]=!0,Wa)),Mo(!1,["boolean","string"],((Ya={})[s]=!0,Ya)),Mo(!1,["boolean","string"],((Xa={})[s]=!0,Xa)),Mo(!1,["boolean"],((Qa={})[s]=!0,Qa));var eu=u[0],ru=u[1],nu=function(t){!function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,null,t)}catch(t){}}(t),this.fly=t.Fly?new t.Fly:new Fly,this.opts=t,this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()},ou={headers:{configurable:!0}};ou.headers.set=function(t){this.extraHeader=t},nu.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=Yn({},{_cb:Oi()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=Yn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}return this.fly.request(this.jsonqlEndpoint,t,Yn({},{method:eu,params:o},e))},nu.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},nu.prototype.processJsonp=function(t){return $i(t)},nu.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call"),e.cleanUp();var o=Ro(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):$i(o)}),(function(t){throw e.cleanUp(),console.error(t),new P("Server side error",t)}))},nu.prototype.getHeaders=function(){return this.opts.enableAuth?Yn({},a,this.getAuthHeader(),this.extraHeader):Yn({},a,this.extraHeader)},nu.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},nu.prototype.get=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=Yn({},this.extraParams,v)),this.request({},{method:"GET"},this.contractHeader).then(N).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e}))},nu.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){var n;if(void 0===e&&(e=[]),void 0===r&&(r=!1),mi(t)&&Wo(e)){var o=Ci(e);return!0===r?o:((n={})[t]=o,n)}throw new qi("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(N)},nu.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){var o;void 0===r&&(r={}),void 0===n&&(n=!1);var i={};if(i[Ai]=e,i[xi]=r,!0===n)return i;if(mi(t))return(o={})[t]=i,o;throw new qi("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:ru}).then(N)},Object.defineProperties(nu.prototype,ou);var iu=function(t){function e(e,r){void 0===r&&(r=null),r&&(e.Fly=r),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={storeIt:{configurable:!0},jsonqlEndpoint:{configurable:!0},jsonqlContract:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return r.storeIt.set=function(t){throw console.info("storeIt",t),Io(t)&&t.length>=2&&Reflect.apply(za.set,za,t),new x("Expect argument to be array and least 2 items!")},r.jsonqlEndpoint.set=function(t){var e=za.get("endpoint")||[];_i(e,t)||(e.push(t),this.storeId=["endpoint",e],this.endpointIndex=e.length-1)},r.jsonqlContract.set=function(t){var e=this.opts.storageKey,r=[e],n=t[0],o=t[1],i=za.get(e)||[];i[this.endpointIndex||0]=n,r.push(i),o&&r.push(o),this.opts.keepContract&&(this.storeIt=r)},r.jsonqlToken.set=function(t){var e="credential",r=localStorage.get(e)||[];if(!_i(r,t)){var n=r.length-1;r[n]=t,this[e+"Index"]=n;var o=[e,r];if(this.opts.tokenExpired){var i=parseFloat(this.opts.tokenExpired);if(!isNaN(i)&&i>0){var a=Oi();o.push(a+parseFloat(i))}}return this.storeIt=o,this.jsonqlUserdata=this.decoder(t),t}return!1},r.jsonqlUserdata.set=function(t){var e=["userdata",t];return t.exp&&e.push(t.exp),Reflect.apply(za.set,za,e)},r.jsonqlEndpoint.get=function(){var t=za.get("endpoint");if(!t){var e=this.opts,r=[e.hostname,e.jsonqlPath].join("/");return this.jsonqlEndpoint=r,r}return t[this.endpointIndex]},r.jsonqlContract.get=function(){var t=this.opts.storageKey;return(za.get(t)||[])[this.endpointIndex]||!1},r.jsonqlToken.get=function(){var t="credential",e=localStorage.get(t);return!!e&&e[this[t+"Index"]]},r.jsonqlUserdata.get=function(){return Fa.get("userdata")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&e.useJwt&&(this.setDecoder=tu)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={userdata:{configurable:!0},rawAuthToken:{configurable:!0},setDecoder:{configurable:!0}};return r.userdata.get=function(){return this.jsonqlUserdata},r.rawAuthToken.get=function(){return this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},e.prototype.storeToken=function(t){return this.jsonqlToken=t},e.prototype.decoder=function(t){return t},e.prototype.getAuthHeader=function(){var t,e=this.rawAuthToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();if(this.log("getContract first call",t),t&&Array.isArray(t)){var e=t[this.endpointIndex||0];if(e)return Promise.resolve(e)}return this.get().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){if(!Ni(t))throw new x("Contract is malformed!");var e=[t];if(this.opts.contractExpired){var r=parseFloat(this.opts.contractExpired);!isNaN(r)&&r>0&&e.push(r)}return this.jsonqlContract=e,this.log("storeContract return result",t),t},e.prototype.readContract=function(){return Ni(this.opts.contract)?this.opts.contract:za.get(this.opts.storageKey)},Object.defineProperties(e.prototype,r),e}(nu))),au={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:i,BEARER:"Bearer",AUTH_HEADER:"Authorization"},uu={hostname:Mo(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:Mo("jsonql",["string"]),loginHandlerName:Mo("login",["string"]),logoutHandlerName:Mo("logout",["string"]),enableJsonp:Mo(!1,["boolean"]),enableAuth:Mo(!1,["boolean"]),useJwt:Mo(!0,["boolean"]),useLocalstorage:Mo(!0,["boolean"]),storageKey:Mo("storageKey",["string"]),authKey:Mo("authKey",["string"]),contractExpired:Mo(0,["number"]),keepContract:Mo(!0,["boolean"]),exposeContract:Mo(!1,["boolean"]),showContractDesc:Mo(!1,["boolean"]),contractKey:Mo(!1,["boolean"]),contractKeyName:Mo("X-JSONQL-CV-KEY",["string"]),enableTimeout:Mo(!1,["boolean"]),timeout:Mo(5e3,["number"]),returnInstance:Mo(!1,["boolean"]),allowReturnRawToken:Mo(!1,["boolean"]),debugOn:Mo(!1,["boolean"])};function cu(t){return t[d]?t:function(t){return Uo(t,uu,au)}(t)}var su=new WeakMap,fu=new WeakMap;var lu=function(){this.__suspend__=null,this.queueStore=new Set},pu={$suspend:{configurable:!0},$queues:{configurable:!0}};pu.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},lu.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},pu.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},lu.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(lu.prototype,pu);var hu=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){su.set(this,t)},r.normalStore.get=function(){return su.get(this)},r.lazyStore.set=function(t){fu.set(this,t)},r.lazyStore.get=function(){return fu.get(this)},e.prototype.hashFnToKey=function(t){return t.toString().split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)+""},Object.defineProperties(e.prototype,r),e}(lu));function du(t,e){void 0===e&&(e={});var r,n=e.contract,o=cu(e),i=new iu(o,t),a=zi(i,n),u=(r=o.debugOn,new hu({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),c=Ji(i,o,a,u);return c.eventEmitter=u,c}return function(t){return void 0===t&&(t={}),du(o,t)}})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClientStatic=e()}(this,(function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t,e){return t(e={exports:{}},e.exports),e.exports}var r,n=e((function(t,e){var r;r=function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(t,e,r){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};t.exports={type:function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},isObject:function(t,e){return e?"object"===this.type(t):t&&"object"===(void 0===t?"undefined":n(t))},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},trim:function(t){return t.replace(/(^\s*)|(\s*$)/g,"")},encode:function(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")},formatParams:function(t){var e="",r=!0,n=this;return this.isObject(t)?(function t(o,i){var a=n.encode,u=n.type(o);if("array"==u)o.forEach((function(e,r){n.isObject(e)||(r=""),t(e,i+"%5B"+r+"%5D")}));else if("object"==u)for(var c in o)t(o[c],i?i+"%5B"+a(c)+"%5D":a(c));else r||(e+="&"),r=!1,e+=i+"="+a(o)}(t,""),e):t},merge:function(t,e){for(var r in e)t.hasOwnProperty(r)?this.isObject(e[r],1)&&this.isObject(t[r],1)&&this.merge(t[r],e[r]):t[r]=e[r];return t}}},,function(t,e,r){var n=function(){function t(t,e){for(var r=0;r0&&(t+=(-1===t.indexOf("?")?"?":"&")+w.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==y&&(a.responseType=y)}catch(t){}var j=r.headers[u]||r.headers[c],O="application/x-www-form-urlencoded";for(var S in o.trim((j||"").toLowerCase())===O?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(O="application/json;charset=utf-8",e=JSON.stringify(e)),j||b||(r.headers[u]=O),r.headers)if(S===u&&o.isFormData(e))delete r.headers[S];else try{a.setRequestHeader(S,r.headers[S])}catch(t){}function E(t,e,n){v(l.p,(function(){if(t){n&&(e.request=r);var o=t.call(l,e,Promise);e=void 0===o?e:o}d(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){s(t)})).catch((function(t){h(t)}))}))}function k(t){t.engine=a,E(l.onerror,t,-1)}function A(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader(u)||"").indexOf("json")&&!o.isObject(t)&&(t=JSON.parse(t));var e=a.responseHeaders;if(!e){e={};var n=(a.getAllResponseHeaders()||"").split("\r\n");n.pop(),n.forEach((function(t){if(t){var r=t.split(":")[0];e[r]=a.getResponseHeader(r)}}))}var i=a.status,c=a.statusText,s={data:t,headers:e,status:i,statusText:c};if(o.merge(s,a._response),i>=200&&i<300||304===i)s.engine=a,s.request=r,E(l.handler,s,0);else{var f=new A(c,i);f.response=s,k(f)}}catch(f){k(new A(f.msg,a.status))}},a.onerror=function(t){k(new A(t.msg||"Network Error",0))},a.ontimeout=function(){k(new A("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(b?null:e)}),0)}(n):s(n)}),(function(t){h(t)}))}))}));return h.engine=a,h}},{key:"all",value:function(t){return Promise.all(t)}},{key:"spread",value:function(t){return function(e){return t.apply(null,e)}}}]),t}();a.default=a,["get","post","put","patch","head","delete"].forEach((function(t){a.prototype[t]=function(e,r,n){return this.request(e,r,o.merge({method:t},n))}})),["lock","unlock","clear"].forEach((function(t){a.prototype[t]=function(){this.interceptors.request[t]()}})),t.exports=a}])},t.exports=r()})),o=(r=n)&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,i="application/vnd.api+json",a={Accept:i,"Content-Type":[i,"charset=utf-8"].join(";")},u=["POST","PUT"],c="type",s="optional",f="enumv",l="args",p="checker",h="alias",d="__checked__",v={desc:"y"},g="No message",y="onResult",b="onError",m=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),_=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),w=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),j=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),O=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),S=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),E=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),k=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),A=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),x=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),T=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),P=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),q=Object.freeze({__proto__:null,Jsonql406Error:m,Jsonql500Error:_,JsonqlAuthorisationError:w,JsonqlContractAuthError:j,JsonqlResolverAppError:O,JsonqlResolverNotFoundError:S,JsonqlEnumError:E,JsonqlTypeError:k,JsonqlCheckerError:A,JsonqlValidationError:x,JsonqlError:T,JsonqlServerError:P}),C=T,$=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function N(t){if($(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||g,a=e.detail||e;if(o&&q[o])throw new q[r](i,a);throw new C(i,a)}return t}function z(t){if(Array.isArray(t))throw new x("",t);var e=t.message||g,r=t.detail||t;switch(!0){case t instanceof m:throw new m(e,r);case t instanceof _:throw new _(e,r);case t instanceof w:throw new w(e,r);case t instanceof j:throw new j(e,r);case t instanceof O:throw new O(e,r);case t instanceof S:throw new S(e,r);case t instanceof E:throw new E(e,r);case t instanceof k:throw new k(e,r);case t instanceof A:throw new A(e,r);case t instanceof x:throw new x(e,r);case t instanceof P:throw new P(e,r);default:throw new T(e,r)}}var F="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},R="object"==typeof F&&F&&F.Object===Object&&F,I="object"==typeof self&&self&&self.Object===Object&&self,J=R||I||Function("return this")(),M=J.Symbol;function U(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&ut(e,t[r],0)>-1;);return r}(n,o)+1).join("")}function Ot(t){return void 0===t}var St="[object Boolean]";var Et="[object Number]";function kt(t){return function(t){return"number"==typeof t||Q(t)&&X(t)==Et}(t)&&t!=+t}var At="[object String]";function xt(t){return"string"==typeof t||!D(t)&&Q(t)&&X(t)==At}function Tt(t,e){return function(r){return t(e(r))}}var Pt=Tt(Object.getPrototypeOf,Object),qt="[object Object]",Ct=Function.prototype,$t=Object.prototype,Nt=Ct.toString,zt=$t.hasOwnProperty,Ft=Nt.call(Object);function Rt(t){if(!Q(t)||X(t)!=qt)return!1;var e=Pt(t);if(null===e)return!0;var r=zt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Nt.call(r)==Ft}var It,Jt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[It?a:++n];if(!1===e(o[u],u,o))break}return t};var Mt="[object Arguments]";function Ut(t){return Q(t)&&X(t)==Mt}var Dt=Object.prototype,Ht=Dt.hasOwnProperty,Lt=Dt.propertyIsEnumerable,Bt=Ut(function(){return arguments}())?Ut:function(t){return Q(t)&&Ht.call(t,"callee")&&!Lt.call(t,"callee")};var Kt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Vt=Kt&&"object"==typeof module&&module&&!module.nodeType&&module,Gt=Vt&&Vt.exports===Kt?J.Buffer:void 0,Wt=(Gt?Gt.isBuffer:void 0)||function(){return!1},Yt=9007199254740991,Xt=/^(?:0|[1-9]\d*)$/;function Qt(t,e){var r=typeof t;return!!(e=null==e?Yt:e)&&("number"==r||"symbol"!=r&&Xt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=Zt}var ee={};ee["[object Float32Array]"]=ee["[object Float64Array]"]=ee["[object Int8Array]"]=ee["[object Int16Array]"]=ee["[object Int32Array]"]=ee["[object Uint8Array]"]=ee["[object Uint8ClampedArray]"]=ee["[object Uint16Array]"]=ee["[object Uint32Array]"]=!0,ee["[object Arguments]"]=ee["[object Array]"]=ee["[object ArrayBuffer]"]=ee["[object Boolean]"]=ee["[object DataView]"]=ee["[object Date]"]=ee["[object Error]"]=ee["[object Function]"]=ee["[object Map]"]=ee["[object Number]"]=ee["[object Object]"]=ee["[object RegExp]"]=ee["[object Set]"]=ee["[object String]"]=ee["[object WeakMap]"]=!1;var re,ne="object"==typeof exports&&exports&&!exports.nodeType&&exports,oe=ne&&"object"==typeof module&&module&&!module.nodeType&&module,ie=oe&&oe.exports===ne&&R.process,ae=function(){try{var t=oe&&oe.require&&oe.require("util").types;return t||ie&&ie.binding&&ie.binding("util")}catch(t){}}(),ue=ae&&ae.isTypedArray,ce=ue?(re=ue,function(t){return re(t)}):function(t){return Q(t)&&te(t.length)&&!!ee[X(t)]},se=Object.prototype.hasOwnProperty;function fe(t,e){var r=D(t),n=!r&&Bt(t),o=!r&&!n&&Wt(t),i=!r&&!n&&!o&&ce(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},Ae.prototype.set=function(t,e){var r=this.__data__,n=Ee(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var xe,Te=J["__core-js_shared__"],Pe=(xe=/[^.]+$/.exec(Te&&Te.keys&&Te.keys.IE_PROTO||""))?"Symbol(src)_1."+xe:"";var qe=Function.prototype.toString;function Ce(t){if(null!=t){try{return qe.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var $e=/^\[object .+?Constructor\]$/,Ne=Function.prototype,ze=Object.prototype,Fe=Ne.toString,Re=ze.hasOwnProperty,Ie=RegExp("^"+Fe.call(Re).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Je(t){return!(!ve(t)||function(t){return!!Pe&&Pe in t}(t))&&(_e(t)?Ie:$e).test(Ce(t))}function Me(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return Je(r)?r:void 0}var Ue=Me(J,"Map"),De=Me(Object,"create");var He="__lodash_hash_undefined__",Le=Object.prototype.hasOwnProperty;var Be=Object.prototype.hasOwnProperty;var Ke="__lodash_hash_undefined__";function Ve(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&rr?new Ze:void 0;for(i.set(t,e),i.set(e,t);++f0){if(++e>=Ln)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Hn);function Gn(t,e){return Vn(function(t,e,r){return e=Dn(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Dn(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Wn.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!ve(r))return!1;var n=typeof e;return!!("number"==n?we(r)&&Qt(e,r.length):"string"==n&&e in r)&&Se(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0))},bo=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},mo=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!go(e)(t)})).length)})).length:e.length>e.filter((function(t){return!yo(r,t)})).length},_o=function(t,e){if(void 0===e&&(e=null),Rt(t)){if(!e)return!0;if(yo(e))return!e.filter((function(e){var r=t[e.name];return!(e.type.length>e.type.filter((function(t){var e;return!!Ot(r)||(!1!==(e=bo(t))?!mo({arg:r},e):!go(t)(r))})).length)})).length}return!1},wo=function(t){var e=t.arg,r=t.param,n=[e];return Array.isArray(r.keys)&&r.keys.length&&n.push(r.keys),_o.apply(null,n)};function jo(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,console,t)}catch(t){}}var Oo=function(t,e){var r;switch(!0){case"object"===t:return!wo(e);case"array"===t:return!yo(e.arg);case!1!==(r=bo(t)):return!mo(e,r);default:return!go(t)(e.arg)}},So=function(t,e){return Ot(t)?!0!==e.optional||Ot(e.defaultvalue)?null:e.defaultvalue:t},Eo=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!yo(e))throw new T("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!yo(t))throw new T("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return jo(1),t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:jo(2);var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:jo(4);var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?So(t,a):t,index:r,param:a,optional:i}}));default:throw jo(5),new T("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!no(e)&&!(r.type.length>r.type.filter((function(e){return Oo(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Oo(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},ko=function(t,e){var r,n=Object.keys(t);return r=e,!!n.filter((function(t){return t===r})).length},Ao=function(t){return!no(t)};function xo(t,e){var r=ro(e,(function(t,e){return!t[ho]}));return Gr(r,{})?t:function(t,e){var r={};return e=wn(e),Oe(t,(function(t,n,o){On(r,e(t,n,o),t)})),r}(t,(function(t,e){return function(t,e,r){var n;return r(t,(function(t,r,o){if(e(t,r,o))return n=r,!1})),n}(r,wn((function(t){return t.alias===e})),Oe)||e}))}function To(t,e){return Xn(e,(function(e,r){var n,o;return Ot(t[r])||!0===e[so]&&Ao(t[r])?Yn({},e,((n={})[vo]=!0,n)):((o={})[lo]=t[r],o[co]=e[co],o[so]=e[so]||!1,o[fo]=e[fo]||!1,o[po]=e[po]||!1,o)}))}function Po(t,e){var r=function(t,e){var r=xo(t,e);return{pristineValues:Xn(ro(e,(function(t,e){return ko(r,e)})),(function(t){return t.args})),checkAgainstAppProps:ro(e,(function(t,e){return!ko(r,e)})),config:r}}(t,e),n=r.config,o=r.pristineValues;return[To(n,r.checkAgainstAppProps),o]}var qo=function(t){return yo(t)?t:[t]};var Co=function(t,e){return!yo(e)||function(t,e){return!!t.filter((function(t){return t===e})).length}(e,t)},$o=function(t,e){try{return!!_e(e)&&e.apply(null,[t])}catch(t){return!1}};function No(t){return function(e,r){if(e[vo])return e[lo];var n=function(t,e){var r,n=[[t[lo]],[(r={},r[co]=qo(t[co]),r[so]=t[so],r)]];return Reflect.apply(e,null,n)}(e,t);if(n.length)throw jo("runValidationAction",r,e),new k(r,n);if(!1!==e[fo]&&!Co(e[lo],e[fo]))throw jo(fo,e[fo]),new E(r);if(!1!==e[po]&&!$o(e[lo],e[po]))throw jo(po,e[po]),new A(r);return e[lo]}}function zo(t,e,r,n){return void 0===t&&(t={}),Yn(function(t,e){var r=t[0],n=t[1],o=Xn(r,No(e));return Yn(o,n)}(Po(t,e),n),r)}function Fo(t,e,r,n,o,i){void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===o&&(o=!1),void 0===i&&(i=!1);var a={};return a[l]=t,a[c]=e,!0===r&&(a[s]=!0),yo(n)&&(a[f]=n),_e(o)&&(a[p]=o),xt(i)&&(a[h]=i),a}var Ro=io,Io=yo,Jo=function(t,e,r){return void 0===r&&(r=!1),new Promise((function(n,o){var i=Eo(t,e,r);return r?i.error.length?o(i.error):n(i.data):i.length?o(i):n([])}))},Mo=function(t,e,r){void 0===r&&(r={});var n=r[s],o=r[f],i=r[p],a=r[h];return Fo.apply(null,[t,e,n,o,i,a])},Uo=function(t){return function(e,r,n){return void 0===n&&(n={}),zo(e,r,n,t)}}(Eo),Do=function(t){return D(t)?t:[t]},Ho=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,Do(t))}),Reflect.apply(t,null,r))}};function Lo(t,e,r,n){void 0===n&&(n=!1);var o=function(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Bo=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Jo(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(z)}},Ko=function(t,e,r,n,o){var i={},a=function(t){i=Lo(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Jo(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(z)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Vo=function(t,e,r,n,o){var i={},a=function(t){i=Lo(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return Jo(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(z)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Go=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Bo(e,a,0,o);return i.apply(null,t).then(e.postLoginAction).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Bo(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var Wo=Array.isArray,Yo=void 0!==F?F:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Xo="object"==typeof Yo&&Yo&&Yo.Object===Object&&Yo,Qo="object"==typeof self&&self&&self.Object===Object&&self,Zo=(Xo||Qo||Function("return this")()).Symbol,ti=Object.prototype,ei=ti.hasOwnProperty,ri=ti.toString,ni=Zo?Zo.toStringTag:void 0;var oi=Object.prototype.toString;var ii="[object Null]",ai="[object Undefined]",ui=Zo?Zo.toStringTag:void 0;function ci(t){return null==t?void 0===t?ai:ii:ui&&ui in Object(t)?function(t){var e=ei.call(t,ni),r=t[ni];try{t[ni]=void 0;var n=!0}catch(t){}var o=ri.call(t);return n&&(e?t[ni]=r:delete t[ni]),o}(t):function(t){return oi.call(t)}(t)}var si=function(t,e){return function(r){return t(e(r))}}(Object.getPrototypeOf,Object);function fi(t){return null!=t&&"object"==typeof t}var li="[object Object]",pi=Function.prototype,hi=Object.prototype,di=pi.toString,vi=hi.hasOwnProperty,gi=di.call(Object);var yi=Zo?Zo.prototype:void 0,bi=(yi&&yi.toString,"[object String]");function mi(t){return"string"==typeof t||!Wo(t)&&fi(t)&&ci(t)==bi}var _i=function(t,e){return!!t.filter((function(t){return t===e})).length},wi=function(t,e){var r=Object.keys(t);return _i(r,e)},ji=function(){for(var t=arguments,e=[],r=arguments.length;r--;)e[r]=t[r];return e.join("_")},Oi=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},Si="query",Ei="mutation",ki="socket",Ai="payload",xi="condition",Ti=function(){try{if(window||document)return!0}catch(t){}return!1},Pi=function(){try{if(!Ti()&&Yo)return!0}catch(t){}return!1};var qi=function(t){function e(){for(var r=arguments,n=[],o=arguments.length;o--;)n[o]=r[o];t.apply(this,n),this.message=n[0],this.detail=n[1],this.className=e.name,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(function(t){function e(){for(var e=arguments,r=[],n=arguments.length;n--;)r[n]=e[n];t.apply(this,r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.where=function(){return Ti()?"browser":Pi()?"node":"unknown"},e}(Error));var Ci=function(t){var e;return(e={}).args=t,e};var $i=function(t){return wi(t,"data")&&!wi(t,"error")?t.data:t},Ni=function(t){return function(t){if(!fi(t)||ci(t)!=li)return!1;var e=si(t);if(null===e)return!0;var r=vi.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&di.call(r)==gi}(t)&&(wi(t,Si)||wi(t,Ei)||wi(t,ki))},zi=function(t,e){return void 0===e&&(e={}),Ni(e)?Promise.resolve(e):t.getContract()},Fi=function(t,e){return function(r){for(var n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return new Promise((function(o,i){t.$only(ji(e,r,y),o),t.$only(ji(e,r,b),i),t.$trigger(e,{resolverName:r,args:n})}))}},Ri=function(t,e,r){var n=t.$queues,o=r.debugOn;o&&console.info("(validateRegisteredEvents)","storedEvt",n),n.forEach((function(t){var r=t[0],n=t[1].resolverName;if(o&&console.info("(validateRegisteredEvents)",r,n),!e[r][n])throw new Error(r+"."+n+" not existed in contract!")}))};function Ii(t,e,r,n){var o=function(t,e,r,n){return Ho(Ko,Vo,Go)({},t,e,r,n)}(t,e,r,n);Ri(e,n,r);var i=function(t){e.$only(t,(function(r){var n=r.resolverName,i=r.args;o[t][n]?Reflect.apply(o[t][n],null,i).then((function(r){e.$trigger(ji(t,n,y),r)})).catch((function(r){e.$trigger(ji(t,n,b),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}var Ji=function(t,e,r,n){n.$suspend=!0,r.then((function(r){Ii(t,n,e,r)}));var o={query:Fi(n,"query"),mutation:Fi(n,"mutation"),auth:Fi(n,"auth"),getToken:function(){return t.rawAuthToken}};return e.exposeContract&&(o.getContract=function(){return t.get()}),e.enableAuth&&(o.userdata=function(){return t.userdata}),o.version="1.4.7",o},Mi=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=ca().key(e);t(sa(r),r)}},remove:function(t){return ca().removeItem(t)},clearAll:function(){return ca().clear()}};function ca(){return aa.localStorage}function sa(t){return ca().getItem(t)}var fa=Li.trim,la={name:"cookieStorage",read:function(t){if(!t||!va(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(pa.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;pa.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:ha,remove:da,clearAll:function(){ha((function(t,e){da(e)}))}},pa=Li.Global.document;function ha(t){for(var e=pa.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(fa(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function da(t){t&&va(t)&&(pa.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function va(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(pa.cookie)}var ga=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var ya="expire_mixin",ba=function(){var t=this.createStore(this.storage,null,this._namespacePrefix+ya);return{set:function(e,r,n,o){this.hasNamespace(ya)||t.set(r,o);return e()},get:function(t,r){this.hasNamespace(ya)||e.call(this,r);return t()},remove:function(e,r){this.hasNamespace(ya)||t.remove(r);return e()},getExpiration:function(e,r){return t.get(r)},removeExpiredKeys:function(t){var r=[];this.each((function(t,e){r.push(e)}));for(var n=0;n>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)}));var ka=[ua,la],Aa=[ga,ba,Oa,function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Ea.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Ea.compress(this._serialize(r));t(e,n)}}}],xa=na.createStore(ka,Aa),Ta=Li.Global;function Pa(){return Ta.sessionStorage}function qa(t){return Pa().getItem(t)}var Ca=[{name:"sessionStorage",read:qa,write:function(t,e){return Pa().setItem(t,e)},each:function(t){for(var e=Pa().length-1;e>=0;e--){var r=Pa().key(e);t(qa(r),r)}},remove:function(t){return Pa().removeItem(t)},clearAll:function(){return Pa().clear()}},la],$a=[ga,ba],Na=na.createStore(Ca,$a),za=xa,Fa=Na,Ra="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Ia(t){this.message=t}Ia.prototype=new Error,Ia.prototype.name="InvalidCharacterError";var Ja="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Ia("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=Ra.indexOf(n);return a};var Ma=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(Ja(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return Ja(e)}};function Ua(t){this.message=t}Ua.prototype=new Error,Ua.prototype.name="InvalidTokenError";var Da=function(t,e){if("string"!=typeof t)throw new Ua("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Ma(t.split(".")[r]))}catch(t){throw new Ua("Invalid token specified: "+t.message)}},Ha=Ua;Da.InvalidTokenError=Ha;var La,Ba,Ka,Va,Ga,Wa,Ya,Xa,Qa,Za=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function tu(t){if(Ro(t))return function(t){var e=t.iat||Za(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new T("Token has expired on "+r,t)}return t}(Da(t));throw new T("Token must be a string!")}Mo("HS256",["string"]),Mo(!1,["boolean","number","string"],((La={})[h]="exp",La[s]=!0,La)),Mo(!1,["boolean","number","string"],((Ba={})[h]="nbf",Ba[s]=!0,Ba)),Mo(!1,["boolean","string"],((Ka={})[h]="iss",Ka[s]=!0,Ka)),Mo(!1,["boolean","string"],((Va={})[h]="sub",Va[s]=!0,Va)),Mo(!1,["boolean","string"],((Ga={})[h]="iss",Ga[s]=!0,Ga)),Mo(!1,["boolean"],((Wa={})[s]=!0,Wa)),Mo(!1,["boolean","string"],((Ya={})[s]=!0,Ya)),Mo(!1,["boolean","string"],((Xa={})[s]=!0,Xa)),Mo(!1,["boolean"],((Qa={})[s]=!0,Qa));var eu=u[0],ru=u[1],nu=function(t){!function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,null,t)}catch(t){}}(t),this.fly=t.Fly?new t.Fly:new Fly,this.opts=t,this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()},ou={headers:{configurable:!0}};ou.headers.set=function(t){this.extraHeader=t},nu.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=Yn({},{_cb:Oi()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=Yn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}return this.fly.request(this.jsonqlEndpoint,t,Yn({},{method:eu,params:o},e))},nu.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},nu.prototype.processJsonp=function(t){return $i(t)},nu.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call"),e.cleanUp();var o=Ro(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):$i(o)}),(function(t){throw e.cleanUp(),console.error(t),new P("Server side error",t)}))},nu.prototype.getHeaders=function(){return this.opts.enableAuth?Yn({},a,this.getAuthHeader(),this.extraHeader):Yn({},a,this.extraHeader)},nu.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},nu.prototype.get=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=Yn({},this.extraParams,v)),this.request({},{method:"GET"},this.contractHeader).then(N).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e}))},nu.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){var n;if(void 0===e&&(e=[]),void 0===r&&(r=!1),mi(t)&&Wo(e)){var o=Ci(e);return!0===r?o:((n={})[t]=o,n)}throw new qi("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(N)},nu.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){var o;void 0===r&&(r={}),void 0===n&&(n=!1);var i={};if(i[Ai]=e,i[xi]=r,!0===n)return i;if(mi(t))return(o={})[t]=i,o;throw new qi("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:ru}).then(N)},Object.defineProperties(nu.prototype,ou);var iu=function(t){function e(e,r){void 0===r&&(r=null),r&&(e.Fly=r),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={storeIt:{configurable:!0},jsonqlEndpoint:{configurable:!0},jsonqlContract:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return r.storeIt.set=function(t){throw console.info("storeIt",t),Io(t)&&t.length>=2&&Reflect.apply(za.set,za,t),new x("Expect argument to be array and least 2 items!")},r.jsonqlEndpoint.set=function(t){var e=za.get("endpoint")||[];_i(e,t)||(e.push(t),this.storeId=["endpoint",e],this.endpointIndex=e.length-1)},r.jsonqlContract.set=function(t){var e=this.opts.storageKey,r=[e],n=t[0],o=t[1],i=za.get(e)||[];i[this.endpointIndex||0]=n,r.push(i),o&&r.push(o),this.opts.keepContract&&(this.storeIt=r)},r.jsonqlToken.set=function(t){var e="credential",r=localStorage.get(e)||[];if(!_i(r,t)){var n=r.length-1;r[n]=t,this[e+"Index"]=n;var o=[e,r];if(this.opts.tokenExpired){var i=parseFloat(this.opts.tokenExpired);if(!isNaN(i)&&i>0){var a=Oi();o.push(a+parseFloat(i))}}return this.storeIt=o,this.jsonqlUserdata=this.decoder(t),t}return!1},r.jsonqlUserdata.set=function(t){var e=["userdata",t];return t.exp&&e.push(t.exp),Reflect.apply(za.set,za,e)},r.jsonqlEndpoint.get=function(){var t=za.get("endpoint");if(!t){var e=this.opts,r=[e.hostname,e.jsonqlPath].join("/");return this.jsonqlEndpoint=r,r}return t[this.endpointIndex]},r.jsonqlContract.get=function(){var t=this.opts.storageKey;return(za.get(t)||[])[this.endpointIndex]||!1},r.jsonqlToken.get=function(){var t="credential",e=localStorage.get(t);return!!e&&e[this[t+"Index"]]},r.jsonqlUserdata.get=function(){return Fa.get("userdata")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&e.useJwt&&(this.setDecoder=tu)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={userdata:{configurable:!0},rawAuthToken:{configurable:!0},setDecoder:{configurable:!0}};return r.userdata.get=function(){return this.jsonqlUserdata},r.rawAuthToken.get=function(){return this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},e.prototype.storeToken=function(t){return this.jsonqlToken=t},e.prototype.decoder=function(t){return t},e.prototype.getAuthHeader=function(){var t,e=this.rawAuthToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();if(this.log("getContract first call",t),t&&Array.isArray(t)){var e=t[this.endpointIndex||0];if(e)return Promise.resolve(e)}return this.get().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){if(!Ni(t))throw new x("Contract is malformed!");var e=[t];if(this.opts.contractExpired){var r=parseFloat(this.opts.contractExpired);!isNaN(r)&&r>0&&e.push(r)}return this.jsonqlContract=e,this.log("storeContract return result",t),t},e.prototype.readContract=function(){return Ni(this.opts.contract)?this.opts.contract:za.get(this.opts.storageKey)},Object.defineProperties(e.prototype,r),e}(nu))),au={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:i,BEARER:"Bearer",AUTH_HEADER:"Authorization"},uu={hostname:Mo(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:Mo("jsonql",["string"]),loginHandlerName:Mo("login",["string"]),logoutHandlerName:Mo("logout",["string"]),enableJsonp:Mo(!1,["boolean"]),enableAuth:Mo(!1,["boolean"]),useJwt:Mo(!0,["boolean"]),useLocalstorage:Mo(!0,["boolean"]),storageKey:Mo("storageKey",["string"]),authKey:Mo("authKey",["string"]),contractExpired:Mo(0,["number"]),keepContract:Mo(!0,["boolean"]),exposeContract:Mo(!1,["boolean"]),showContractDesc:Mo(!1,["boolean"]),contractKey:Mo(!1,["boolean"]),contractKeyName:Mo("X-JSONQL-CV-KEY",["string"]),enableTimeout:Mo(!1,["boolean"]),timeout:Mo(5e3,["number"]),returnInstance:Mo(!1,["boolean"]),allowReturnRawToken:Mo(!1,["boolean"]),debugOn:Mo(!1,["boolean"])};function cu(t){return t[d]?t:function(t){return Uo(t,uu,au)}(t)}var su=new WeakMap,fu=new WeakMap;var lu=function(){this.__suspend__=null,this.queueStore=new Set},pu={$suspend:{configurable:!0},$queues:{configurable:!0}};pu.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},lu.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},pu.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},lu.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(lu.prototype,pu);var hu=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){su.set(this,t)},r.normalStore.get=function(){return su.get(this)},r.lazyStore.set=function(t){fu.set(this,t)},r.lazyStore.get=function(){return fu.get(this)},e.prototype.hashFnToKey=function(t){return t.toString().split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)+""},Object.defineProperties(e.prototype,r),e}(lu));function du(t,e){void 0===e&&(e={});var r,n=e.contract,o=cu(e),i=new iu(o,t),a=zi(i,n),u=(r=o.debugOn,new hu({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),c=Ji(i,o,a,u);return c.eventEmitter=u,c}return function(t){return void 0===t&&(t={}),du(o,t)}})); //# sourceMappingURL=jsonql-client.static.js.map diff --git a/packages/http-client/dist/jsonql-client.umd.js b/packages/http-client/dist/jsonql-client.umd.js index c0e8f86dacf50a70d557b2d3fdce7df93d5a6c9c..0cecc4a5727772c41d3b32c486bb4ab21d8eb2d9 100644 --- a/packages/http-client/dist/jsonql-client.umd.js +++ b/packages/http-client/dist/jsonql-client.umd.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClient=e()}(this,(function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t,e){return t(e={exports:{}},e.exports),e.exports}var r,n=e((function(t,e){var r;r=function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(t,e,r){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};t.exports={type:function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},isObject:function(t,e){return e?"object"===this.type(t):t&&"object"===(void 0===t?"undefined":n(t))},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},trim:function(t){return t.replace(/(^\s*)|(\s*$)/g,"")},encode:function(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")},formatParams:function(t){var e="",r=!0,n=this;return this.isObject(t)?(function t(o,i){var a=n.encode,u=n.type(o);if("array"==u)o.forEach((function(e,r){n.isObject(e)||(r=""),t(e,i+"%5B"+r+"%5D")}));else if("object"==u)for(var c in o)t(o[c],i?i+"%5B"+a(c)+"%5D":a(c));else r||(e+="&"),r=!1,e+=i+"="+a(o)}(t,""),e):t},merge:function(t,e){for(var r in e)t.hasOwnProperty(r)?this.isObject(e[r],1)&&this.isObject(t[r],1)&&this.merge(t[r],e[r]):t[r]=e[r];return t}}},,function(t,e,r){var n=function(){function t(t,e){for(var r=0;r0&&(t+=(-1===t.indexOf("?")?"?":"&")+w.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==y&&(a.responseType=y)}catch(t){}var j=r.headers[u]||r.headers[c],O="application/x-www-form-urlencoded";for(var S in o.trim((j||"").toLowerCase())===O?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(O="application/json;charset=utf-8",e=JSON.stringify(e)),j||b||(r.headers[u]=O),r.headers)if(S===u&&o.isFormData(e))delete r.headers[S];else try{a.setRequestHeader(S,r.headers[S])}catch(t){}function E(t,e,n){v(l.p,(function(){if(t){n&&(e.request=r);var o=t.call(l,e,Promise);e=void 0===o?e:o}d(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){s(t)})).catch((function(t){h(t)}))}))}function k(t){t.engine=a,E(l.onerror,t,-1)}function A(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader(u)||"").indexOf("json")&&!o.isObject(t)&&(t=JSON.parse(t));var e=a.responseHeaders;if(!e){e={};var n=(a.getAllResponseHeaders()||"").split("\r\n");n.pop(),n.forEach((function(t){if(t){var r=t.split(":")[0];e[r]=a.getResponseHeader(r)}}))}var i=a.status,c=a.statusText,s={data:t,headers:e,status:i,statusText:c};if(o.merge(s,a._response),i>=200&&i<300||304===i)s.engine=a,s.request=r,E(l.handler,s,0);else{var f=new A(c,i);f.response=s,k(f)}}catch(f){k(new A(f.msg,a.status))}},a.onerror=function(t){k(new A(t.msg||"Network Error",0))},a.ontimeout=function(){k(new A("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(b?null:e)}),0)}(n):s(n)}),(function(t){h(t)}))}))}));return h.engine=a,h}},{key:"all",value:function(t){return Promise.all(t)}},{key:"spread",value:function(t){return function(e){return t.apply(null,e)}}}]),t}();a.default=a,["get","post","put","patch","head","delete"].forEach((function(t){a.prototype[t]=function(e,r,n){return this.request(e,r,o.merge({method:t},n))}})),["lock","unlock","clear"].forEach((function(t){a.prototype[t]=function(){this.interceptors.request[t]()}})),t.exports=a}])},t.exports=r()})),o=(r=n)&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,i="application/vnd.api+json",a={Accept:i,"Content-Type":[i,"charset=utf-8"].join(";")},u=["POST","PUT"],c="type",s="optional",f="enumv",l="args",p="checker",h="alias",d="__checked__",v={desc:"y"},g="No message";var y="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},b="object"==typeof y&&y&&y.Object===Object&&y,m="object"==typeof self&&self&&self.Object===Object&&self,_=b||m||Function("return this")(),w=_.Symbol;function j(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&D(e,t[r],0)>-1;);return r}(n,o)+1).join("")}function ot(t){return void 0===t}var it="[object Boolean]";var at="[object Number]";function ut(t){return function(t){return"number"==typeof t||$(t)&&C(t)==at}(t)&&t!=+t}var ct="[object String]";function st(t){return"string"==typeof t||!O(t)&&$(t)&&C(t)==ct}function ft(t,e){return function(r){return t(e(r))}}var lt=ft(Object.getPrototypeOf,Object),pt="[object Object]",ht=Function.prototype,dt=Object.prototype,vt=ht.toString,gt=dt.hasOwnProperty,yt=vt.call(Object);function bt(t){if(!$(t)||C(t)!=pt)return!1;var e=lt(t);if(null===e)return!0;var r=gt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&vt.call(r)==yt}var mt,_t=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[mt?a:++n];if(!1===e(o[u],u,o))break}return t};var wt="[object Arguments]";function jt(t){return $(t)&&C(t)==wt}var Ot=Object.prototype,St=Ot.hasOwnProperty,Et=Ot.propertyIsEnumerable,kt=jt(function(){return arguments}())?jt:function(t){return $(t)&&St.call(t,"callee")&&!Et.call(t,"callee")};var At="object"==typeof exports&&exports&&!exports.nodeType&&exports,xt=At&&"object"==typeof module&&module&&!module.nodeType&&module,Tt=xt&&xt.exports===At?_.Buffer:void 0,Pt=(Tt?Tt.isBuffer:void 0)||function(){return!1},qt=9007199254740991,Ct=/^(?:0|[1-9]\d*)$/;function $t(t,e){var r=typeof t;return!!(e=null==e?qt:e)&&("number"==r||"symbol"!=r&&Ct.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=Nt}var Ft={};Ft["[object Float32Array]"]=Ft["[object Float64Array]"]=Ft["[object Int8Array]"]=Ft["[object Int16Array]"]=Ft["[object Int32Array]"]=Ft["[object Uint8Array]"]=Ft["[object Uint8ClampedArray]"]=Ft["[object Uint16Array]"]=Ft["[object Uint32Array]"]=!0,Ft["[object Arguments]"]=Ft["[object Array]"]=Ft["[object ArrayBuffer]"]=Ft["[object Boolean]"]=Ft["[object DataView]"]=Ft["[object Date]"]=Ft["[object Error]"]=Ft["[object Function]"]=Ft["[object Map]"]=Ft["[object Number]"]=Ft["[object Object]"]=Ft["[object RegExp]"]=Ft["[object Set]"]=Ft["[object String]"]=Ft["[object WeakMap]"]=!1;var Rt,It="object"==typeof exports&&exports&&!exports.nodeType&&exports,Jt=It&&"object"==typeof module&&module&&!module.nodeType&&module,Mt=Jt&&Jt.exports===It&&b.process,Ut=function(){try{var t=Jt&&Jt.require&&Jt.require("util").types;return t||Mt&&Mt.binding&&Mt.binding("util")}catch(t){}}(),Dt=Ut&&Ut.isTypedArray,Ht=Dt?(Rt=Dt,function(t){return Rt(t)}):function(t){return $(t)&&zt(t.length)&&!!Ft[C(t)]},Lt=Object.prototype.hasOwnProperty;function Bt(t,e){var r=O(t),n=!r&&kt(t),o=!r&&!n&&Pt(t),i=!r&&!n&&!o&&Ht(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},ce.prototype.set=function(t,e){var r=this.__data__,n=ae(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var se,fe=_["__core-js_shared__"],le=(se=/[^.]+$/.exec(fe&&fe.keys&&fe.keys.IE_PROTO||""))?"Symbol(src)_1."+se:"";var pe=Function.prototype.toString;function he(t){if(null!=t){try{return pe.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var de=/^\[object .+?Constructor\]$/,ve=Function.prototype,ge=Object.prototype,ye=ve.toString,be=ge.hasOwnProperty,me=RegExp("^"+ye.call(be).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function _e(t){return!(!Yt(t)||function(t){return!!le&&le in t}(t))&&(ee(t)?me:de).test(he(t))}function we(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return _e(r)?r:void 0}var je=we(_,"Map"),Oe=we(Object,"create");var Se="__lodash_hash_undefined__",Ee=Object.prototype.hasOwnProperty;var ke=Object.prototype.hasOwnProperty;var Ae="__lodash_hash_undefined__";function xe(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&Re?new Ne:void 0;for(i.set(t,e),i.set(e,t);++f0){if(++e>=En)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Sn);function Tn(t,e){return xn(function(t,e,r){return e=On(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=On(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Pn.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!Yt(r))return!1;var n=typeof e;return!!("number"==n?re(r)&&$t(e,r.length):"string"==n&&e in r)&&ie(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0))},Qn=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},Zn=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!Yn(e)(t)})).length)})).length:e.length>e.filter((function(t){return!Xn(r,t)})).length},to=function(t,e){if(void 0===e&&(e=null),bt(t)){if(!e)return!0;if(Xn(e))return!e.filter((function(e){var r=t[e.name];return!(e.type.length>e.type.filter((function(t){var e;return!!ot(r)||(!1!==(e=Qn(t))?!Zn({arg:r},e):!Yn(t)(r))})).length)})).length}return!1},eo=function(t){var e=t.arg,r=t.param,n=[e];return Array.isArray(r.keys)&&r.keys.length&&n.push(r.keys),to.apply(null,n)},ro=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),no=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),oo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),io=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),ao=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),uo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),co=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),so=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),fo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),lo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),po=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),ho=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),vo=Object.freeze({__proto__:null,Jsonql406Error:ro,Jsonql500Error:no,JsonqlAuthorisationError:oo,JsonqlContractAuthError:io,JsonqlResolverAppError:ao,JsonqlResolverNotFoundError:uo,JsonqlEnumError:co,JsonqlTypeError:so,JsonqlCheckerError:fo,JsonqlValidationError:lo,JsonqlError:po,JsonqlServerError:ho}),go=po,yo=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function bo(t){if(yo(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||g,a=e.detail||e;if(o&&vo[o])throw new vo[r](i,a);throw new go(i,a)}return t}function mo(t){if(Array.isArray(t))throw new lo("",t);var e=t.message||g,r=t.detail||t;switch(!0){case t instanceof ro:throw new ro(e,r);case t instanceof no:throw new no(e,r);case t instanceof oo:throw new oo(e,r);case t instanceof io:throw new io(e,r);case t instanceof ao:throw new ao(e,r);case t instanceof uo:throw new uo(e,r);case t instanceof co:throw new co(e,r);case t instanceof so:throw new so(e,r);case t instanceof fo:throw new fo(e,r);case t instanceof lo:throw new lo(e,r);case t instanceof ho:throw new ho(e,r);default:throw new po(e,r)}}function _o(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,console,t)}catch(t){}}var wo=function(t,e){var r;switch(!0){case"object"===t:return!eo(e);case"array"===t:return!Xn(e.arg);case!1!==(r=Qn(t)):return!Zn(e,r);default:return!Yn(t)(e.arg)}},jo=function(t,e){return ot(t)?!0!==e.optional||ot(e.defaultvalue)?null:e.defaultvalue:t},Oo=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!Xn(e))throw new po("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!Xn(t))throw new po("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return _o(1),t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:_o(2);var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:_o(4);var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?jo(t,a):t,index:r,param:a,optional:i}}));default:throw _o(5),new po("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!In(e)&&!(r.type.length>r.type.filter((function(e){return wo(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return wo(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},So=function(t,e){var r,n=Object.keys(t);return r=e,!!n.filter((function(t){return t===r})).length},Eo=function(t){return!In(t)};function ko(t,e){var r=Rn(e,(function(t,e){return!t[Gn]}));return Tr(r,{})?t:function(t,e){var r={};return e=en(e),oe(t,(function(t,n,o){nn(r,e(t,n,o),t)})),r}(t,(function(t,e){return function(t,e,r){var n;return r(t,(function(t,r,o){if(e(t,r,o))return n=r,!1})),n}(r,en((function(t){return t.alias===e})),oe)||e}))}function Ao(t,e){return Cn(e,(function(e,r){var n,o;return ot(t[r])||!0===e[Ln]&&Eo(t[r])?qn({},e,((n={})[Wn]=!0,n)):((o={})[Kn]=t[r],o[Hn]=e[Hn],o[Ln]=e[Ln]||!1,o[Bn]=e[Bn]||!1,o[Vn]=e[Vn]||!1,o)}))}function xo(t,e){var r=function(t,e){var r=ko(t,e);return{pristineValues:Cn(Rn(e,(function(t,e){return So(r,e)})),(function(t){return t.args})),checkAgainstAppProps:Rn(e,(function(t,e){return!So(r,e)})),config:r}}(t,e),n=r.config,o=r.pristineValues;return[Ao(n,r.checkAgainstAppProps),o]}var To=function(t){return Xn(t)?t:[t]};var Po=function(t,e){return!Xn(e)||function(t,e){return!!t.filter((function(t){return t===e})).length}(e,t)},qo=function(t,e){try{return!!ee(e)&&e.apply(null,[t])}catch(t){return!1}};function Co(t){return function(e,r){if(e[Wn])return e[Kn];var n=function(t,e){var r,n=[[t[Kn]],[(r={},r[Hn]=To(t[Hn]),r[Ln]=t[Ln],r)]];return Reflect.apply(e,null,n)}(e,t);if(n.length)throw _o("runValidationAction",r,e),new so(r,n);if(!1!==e[Bn]&&!Po(e[Kn],e[Bn]))throw _o(Bn,e[Bn]),new co(r);if(!1!==e[Vn]&&!qo(e[Kn],e[Vn]))throw _o(Vn,e[Vn]),new fo(r);return e[Kn]}}var $o=function(t,e){return Promise.resolve(xo(t,e))};function No(t,e,r,n){return void 0===t&&(t={}),$o(t,e).then((function(t){return function(t,e){var r=t[0],n=t[1],o=Cn(r,Co(e));return qn(o,n)}(t,n)})).then((function(t){return qn({},t,r)}))}function zo(t,e,r,n,o,i){void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===o&&(o=!1),void 0===i&&(i=!1);var a={};return a[l]=t,a[c]=e,!0===r&&(a[s]=!0),Xn(n)&&(a[f]=n),ee(o)&&(a[p]=o),st(i)&&(a[h]=i),a}var Fo=Mn,Ro=Xn,Io=function(t,e,r){return void 0===r&&(r=!1),new Promise((function(n,o){var i=Oo(t,e,r);return r?i.error.length?o(i.error):n(i.data):i.length?o(i):n([])}))},Jo=function(t,e,r){void 0===r&&(r={});var n=r[s],o=r[f],i=r[p],a=r[h];return zo.apply(null,[t,e,n,o,i,a])},Mo=function(t){return function(e,r,n){return void 0===n&&(n={}),No(e,r,n,t)}}(Oo),Uo=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=si().key(e);t(fi(r),r)}},remove:function(t){return si().removeItem(t)},clearAll:function(){return si().clear()}};function si(){return ui.localStorage}function fi(t){return si().getItem(t)}var li=Bo.trim,pi={name:"cookieStorage",read:function(t){if(!t||!gi(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(hi.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;hi.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:di,remove:vi,clearAll:function(){di((function(t,e){vi(e)}))}},hi=Bo.Global.document;function di(t){for(var e=hi.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(li(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function vi(t){t&&gi(t)&&(hi.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function gi(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(hi.cookie)}var yi=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var bi="expire_mixin",mi=function(){var t=this.createStore(this.storage,null,this._namespacePrefix+bi);return{set:function(e,r,n,o){this.hasNamespace(bi)||t.set(r,o);return e()},get:function(t,r){this.hasNamespace(bi)||e.call(this,r);return t()},remove:function(e,r){this.hasNamespace(bi)||t.remove(r);return e()},getExpiration:function(e,r){return t.get(r)},removeExpiredKeys:function(t){var r=[];this.each((function(t,e){r.push(e)}));for(var n=0;n>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)}));var Ai=[ci,pi],xi=[yi,mi,Si,function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=ki.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=ki.compress(this._serialize(r));t(e,n)}}}],Ti=oi.createStore(Ai,xi),Pi=Bo.Global;function qi(){return Pi.sessionStorage}function Ci(t){return qi().getItem(t)}var $i=[{name:"sessionStorage",read:Ci,write:function(t,e){return qi().setItem(t,e)},each:function(t){for(var e=qi().length-1;e>=0;e--){var r=qi().key(e);t(Ci(r),r)}},remove:function(t){return qi().removeItem(t)},clearAll:function(){return qi().clear()}},pi],Ni=[yi,mi],zi=oi.createStore($i,Ni),Fi=Ti,Ri=zi,Ii=Array.isArray,Ji=void 0!==y?y:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Mi="object"==typeof Ji&&Ji&&Ji.Object===Object&&Ji,Ui="object"==typeof self&&self&&self.Object===Object&&self,Di=(Mi||Ui||Function("return this")()).Symbol,Hi=Object.prototype,Li=Hi.hasOwnProperty,Bi=Hi.toString,Ki=Di?Di.toStringTag:void 0;var Vi=Object.prototype.toString;var Gi="[object Null]",Wi="[object Undefined]",Yi=Di?Di.toStringTag:void 0;function Xi(t){return null==t?void 0===t?Wi:Gi:Yi&&Yi in Object(t)?function(t){var e=Li.call(t,Ki),r=t[Ki];try{t[Ki]=void 0;var n=!0}catch(t){}var o=Bi.call(t);return n&&(e?t[Ki]=r:delete t[Ki]),o}(t):function(t){return Vi.call(t)}(t)}var Qi=function(t,e){return function(r){return t(e(r))}}(Object.getPrototypeOf,Object);function Zi(t){return null!=t&&"object"==typeof t}var ta="[object Object]",ea=Function.prototype,ra=Object.prototype,na=ea.toString,oa=ra.hasOwnProperty,ia=na.call(Object);var aa=Di?Di.prototype:void 0,ua=(aa&&aa.toString,"[object String]");function ca(t){return"string"==typeof t||!Ii(t)&&Zi(t)&&Xi(t)==ua}var sa=function(t,e){return!!t.filter((function(t){return t===e})).length},fa=function(t,e){var r=Object.keys(t);return sa(r,e)},la=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},pa="query",ha="mutation",da="socket",va="payload",ga="condition",ya=function(){try{if(window||document)return!0}catch(t){}return!1},ba=function(){try{if(!ya()&&Ji)return!0}catch(t){}return!1};var ma=function(t){function e(){for(var r=arguments,n=[],o=arguments.length;o--;)n[o]=r[o];t.apply(this,n),this.message=n[0],this.detail=n[1],this.className=e.name,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(function(t){function e(){for(var e=arguments,r=[],n=arguments.length;n--;)r[n]=e[n];t.apply(this,r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.where=function(){return ya()?"browser":ba()?"node":"unknown"},e}(Error));var _a=function(t){var e;return(e={}).args=t,e};var wa=function(t){return fa(t,"data")&&!fa(t,"error")?t.data:t},ja=function(t){return function(t){if(!Zi(t)||Xi(t)!=ta)return!1;var e=Qi(t);if(null===e)return!0;var r=oa.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&na.call(r)==ia}(t)&&(fa(t,pa)||fa(t,ha)||fa(t,da))},Oa=function(t,e){return void 0===e&&(e={}),ja(e)?Promise.resolve(e):t.getContract()},Sa="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Ea(t){this.message=t}Ea.prototype=new Error,Ea.prototype.name="InvalidCharacterError";var ka="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Ea("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=Sa.indexOf(n);return a};var Aa=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(ka(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return ka(e)}};function xa(t){this.message=t}xa.prototype=new Error,xa.prototype.name="InvalidTokenError";var Ta=function(t,e){if("string"!=typeof t)throw new xa("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Aa(t.split(".")[r]))}catch(t){throw new xa("Invalid token specified: "+t.message)}},Pa=xa;Ta.InvalidTokenError=Pa;var qa,Ca,$a,Na,za,Fa,Ra,Ia,Ja,Ma=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Ua(t){if(Fo(t))return function(t){var e=t.iat||Ma(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new po("Token has expired on "+r,t)}return t}(Ta(t));throw new po("Token must be a string!")}Jo("HS256",["string"]),Jo(!1,["boolean","number","string"],((qa={})[h]="exp",qa[s]=!0,qa)),Jo(!1,["boolean","number","string"],((Ca={})[h]="nbf",Ca[s]=!0,Ca)),Jo(!1,["boolean","string"],(($a={})[h]="iss",$a[s]=!0,$a)),Jo(!1,["boolean","string"],((Na={})[h]="sub",Na[s]=!0,Na)),Jo(!1,["boolean","string"],((za={})[h]="iss",za[s]=!0,za)),Jo(!1,["boolean"],((Fa={})[s]=!0,Fa)),Jo(!1,["boolean","string"],((Ra={})[s]=!0,Ra)),Jo(!1,["boolean","string"],((Ia={})[s]=!0,Ia)),Jo(!1,["boolean"],((Ja={})[s]=!0,Ja));var Da=u[0],Ha=u[1],La=function(t){!function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,null,t)}catch(t){}}(t),this.fly=t.Fly?new t.Fly:new Fly,this.opts=t,this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()},Ba={headers:{configurable:!0}};Ba.headers.set=function(t){this.extraHeader=t},La.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=qn({},{_cb:la()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=qn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}return this.fly.request(this.jsonqlEndpoint,t,qn({},{method:Da,params:o},e))},La.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},La.prototype.processJsonp=function(t){return wa(t)},La.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call"),e.cleanUp();var o=Fo(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):wa(o)}),(function(t){throw e.cleanUp(),console.error(t),new ho("Server side error",t)}))},La.prototype.getHeaders=function(){return this.opts.enableAuth?qn({},a,this.getAuthHeader(),this.extraHeader):qn({},a,this.extraHeader)},La.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},La.prototype.get=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=qn({},this.extraParams,v)),this.request({},{method:"GET"},this.contractHeader).then(bo).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e}))},La.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){var n;if(void 0===e&&(e=[]),void 0===r&&(r=!1),ca(t)&&Ii(e)){var o=_a(e);return!0===r?o:((n={})[t]=o,n)}throw new ma("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(bo)},La.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){var o;void 0===r&&(r={}),void 0===n&&(n=!1);var i={};if(i[va]=e,i[ga]=r,!0===n)return i;if(ca(t))return(o={})[t]=i,o;throw new ma("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Ha}).then(bo)},Object.defineProperties(La.prototype,Ba);var Ka=function(t){function e(e,r){void 0===r&&(r=null),r&&(e.Fly=r),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={storeIt:{configurable:!0},jsonqlEndpoint:{configurable:!0},jsonqlContract:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return r.storeIt.set=function(t){throw console.info("storeIt",t),Ro(t)&&t.length>=2&&Reflect.apply(Fi.set,Fi,t),new lo("Expect argument to be array and least 2 items!")},r.jsonqlEndpoint.set=function(t){var e=Fi.get("endpoint")||[];sa(e,t)||(e.push(t),this.storeId=["endpoint",e],this.endpointIndex=e.length-1)},r.jsonqlContract.set=function(t){var e=this.opts.storageKey,r=[e],n=t[0],o=t[1],i=Fi.get(e)||[];i[this.endpointIndex||0]=n,r.push(i),o&&r.push(o),this.opts.keepContract&&(this.storeIt=r)},r.jsonqlToken.set=function(t){var e="credential",r=localStorage.get(e)||[];if(!sa(r,t)){var n=r.length-1;r[n]=t,this[e+"Index"]=n;var o=[e,r];if(this.opts.tokenExpired){var i=parseFloat(this.opts.tokenExpired);if(!isNaN(i)&&i>0){var a=la();o.push(a+parseFloat(i))}}return this.storeIt=o,this.jsonqlUserdata=this.decoder(t),t}return!1},r.jsonqlUserdata.set=function(t){var e=["userdata",t];return t.exp&&e.push(t.exp),Reflect.apply(Fi.set,Fi,e)},r.jsonqlEndpoint.get=function(){var t=Fi.get("endpoint");if(!t){var e=this.opts,r=[e.hostname,e.jsonqlPath].join("/");return this.jsonqlEndpoint=r,r}return t[this.endpointIndex]},r.jsonqlContract.get=function(){var t=this.opts.storageKey;return(Fi.get(t)||[])[this.endpointIndex]||!1},r.jsonqlToken.get=function(){var t="credential",e=localStorage.get(t);return!!e&&e[this[t+"Index"]]},r.jsonqlUserdata.get=function(){return Ri.get("userdata")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&e.useJwt&&(this.setDecoder=Ua)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={userdata:{configurable:!0},rawAuthToken:{configurable:!0},setDecoder:{configurable:!0}};return r.userdata.get=function(){return this.jsonqlUserdata},r.rawAuthToken.get=function(){return this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},e.prototype.storeToken=function(t){return this.jsonqlToken=t},e.prototype.decoder=function(t){return t},e.prototype.getAuthHeader=function(){var t,e=this.rawAuthToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();if(this.log("getContract first call",t),t&&Array.isArray(t)){var e=t[this.endpointIndex||0];if(e)return Promise.resolve(e)}return this.get().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){if(!ja(t))throw new lo("Contract is malformed!");var e=[t];if(this.opts.contractExpired){var r=parseFloat(this.opts.contractExpired);!isNaN(r)&&r>0&&e.push(r)}return this.jsonqlContract=e,this.log("storeContract return result",t),t},e.prototype.readContract=function(){return ja(this.opts.contract)?this.opts.contract:Fi.get(this.opts.storageKey)},Object.defineProperties(e.prototype,r),e}(La))),Va=function(t){return O(t)?t:[t]},Ga=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,Va(t))}),Reflect.apply(t,null,r))}};function Wa(t,e,r,n){void 0===n&&(n=!1);var o=function(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Ya=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Io(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(mo)}},Xa=function(t,e,r,n,o){var i={},a=function(t){i=Wa(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Io(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(mo)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Qa=function(t,e,r,n,o){var i={},a=function(t){i=Wa(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return Io(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(mo)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Za=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Ya(e,a,0,o);return i.apply(null,t).then(e.postLoginAction).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Ya(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var tu=function(t,e,r,n){var o=function(t,e,r,n){return Ga(Xa,Qa,Za)({},t,e,r,n)}(t,n,e,r);return e.enableAuth&&(o.userdata=function(){return t.userdata}),o.getToken=function(){return t.rawAuthToken},e.exposeContract&&(o.getContract=function(){return t.getContract()}),o.eventEmitter=n,o.version="1.4.6",o},eu={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:i,BEARER:"Bearer",AUTH_HEADER:"Authorization"},ru={hostname:Jo(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:Jo("jsonql",["string"]),loginHandlerName:Jo("login",["string"]),logoutHandlerName:Jo("logout",["string"]),enableJsonp:Jo(!1,["boolean"]),enableAuth:Jo(!1,["boolean"]),useJwt:Jo(!0,["boolean"]),useLocalstorage:Jo(!0,["boolean"]),storageKey:Jo("storageKey",["string"]),authKey:Jo("authKey",["string"]),contractExpired:Jo(0,["number"]),keepContract:Jo(!0,["boolean"]),exposeContract:Jo(!1,["boolean"]),showContractDesc:Jo(!1,["boolean"]),contractKey:Jo(!1,["boolean"]),contractKeyName:Jo("X-JSONQL-CV-KEY",["string"]),enableTimeout:Jo(!1,["boolean"]),timeout:Jo(5e3,["number"]),returnInstance:Jo(!1,["boolean"]),allowReturnRawToken:Jo(!1,["boolean"]),debugOn:Jo(!1,["boolean"])};function nu(t){return t[d]?t:function(t){var e=t.contract;return Mo(t,ru,eu).then((function(t){return t.contract=e,t}))}(t)}var ou=new WeakMap,iu=new WeakMap;var au=function(){this.__suspend__=null,this.queueStore=new Set},uu={$suspend:{configurable:!0},$queues:{configurable:!0}};uu.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},au.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},uu.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},au.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(au.prototype,uu);var cu=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){ou.set(this,t)},r.normalStore.get=function(){return ou.get(this)},r.lazyStore.set=function(t){iu.set(this,t)},r.lazyStore.get=function(){return iu.get(this)},e.prototype.hashFnToKey=function(t){return t.toString().split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)+""},Object.defineProperties(e.prototype,r),e}(au));function su(t,e){var r;return function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r=null),nu(e).then((function(t){return{baseClient:new Ka(t,r),opts:t}})).then((function(e){var r=e.baseClient,n=e.opts;return Oa(r,n.contract).then((function(e){return tu(r,n,e,t)}))}))}((r=e.debugOn,new cu({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),e,t)}return function(t){return void 0===t&&(t={}),su(o,t)}})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClient=e()}(this,(function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t,e){return t(e={exports:{}},e.exports),e.exports}var r,n=e((function(t,e){var r;r=function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(t,e,r){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};t.exports={type:function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},isObject:function(t,e){return e?"object"===this.type(t):t&&"object"===(void 0===t?"undefined":n(t))},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},trim:function(t){return t.replace(/(^\s*)|(\s*$)/g,"")},encode:function(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")},formatParams:function(t){var e="",r=!0,n=this;return this.isObject(t)?(function t(o,i){var a=n.encode,u=n.type(o);if("array"==u)o.forEach((function(e,r){n.isObject(e)||(r=""),t(e,i+"%5B"+r+"%5D")}));else if("object"==u)for(var c in o)t(o[c],i?i+"%5B"+a(c)+"%5D":a(c));else r||(e+="&"),r=!1,e+=i+"="+a(o)}(t,""),e):t},merge:function(t,e){for(var r in e)t.hasOwnProperty(r)?this.isObject(e[r],1)&&this.isObject(t[r],1)&&this.merge(t[r],e[r]):t[r]=e[r];return t}}},,function(t,e,r){var n=function(){function t(t,e){for(var r=0;r0&&(t+=(-1===t.indexOf("?")?"?":"&")+w.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==y&&(a.responseType=y)}catch(t){}var j=r.headers[u]||r.headers[c],O="application/x-www-form-urlencoded";for(var S in o.trim((j||"").toLowerCase())===O?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(O="application/json;charset=utf-8",e=JSON.stringify(e)),j||b||(r.headers[u]=O),r.headers)if(S===u&&o.isFormData(e))delete r.headers[S];else try{a.setRequestHeader(S,r.headers[S])}catch(t){}function E(t,e,n){v(l.p,(function(){if(t){n&&(e.request=r);var o=t.call(l,e,Promise);e=void 0===o?e:o}d(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){s(t)})).catch((function(t){h(t)}))}))}function k(t){t.engine=a,E(l.onerror,t,-1)}function A(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader(u)||"").indexOf("json")&&!o.isObject(t)&&(t=JSON.parse(t));var e=a.responseHeaders;if(!e){e={};var n=(a.getAllResponseHeaders()||"").split("\r\n");n.pop(),n.forEach((function(t){if(t){var r=t.split(":")[0];e[r]=a.getResponseHeader(r)}}))}var i=a.status,c=a.statusText,s={data:t,headers:e,status:i,statusText:c};if(o.merge(s,a._response),i>=200&&i<300||304===i)s.engine=a,s.request=r,E(l.handler,s,0);else{var f=new A(c,i);f.response=s,k(f)}}catch(f){k(new A(f.msg,a.status))}},a.onerror=function(t){k(new A(t.msg||"Network Error",0))},a.ontimeout=function(){k(new A("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(b?null:e)}),0)}(n):s(n)}),(function(t){h(t)}))}))}));return h.engine=a,h}},{key:"all",value:function(t){return Promise.all(t)}},{key:"spread",value:function(t){return function(e){return t.apply(null,e)}}}]),t}();a.default=a,["get","post","put","patch","head","delete"].forEach((function(t){a.prototype[t]=function(e,r,n){return this.request(e,r,o.merge({method:t},n))}})),["lock","unlock","clear"].forEach((function(t){a.prototype[t]=function(){this.interceptors.request[t]()}})),t.exports=a}])},t.exports=r()})),o=(r=n)&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,i="application/vnd.api+json",a={Accept:i,"Content-Type":[i,"charset=utf-8"].join(";")},u=["POST","PUT"],c="type",s="optional",f="enumv",l="args",p="checker",h="alias",d="__checked__",v={desc:"y"},g="No message";var y="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},b="object"==typeof y&&y&&y.Object===Object&&y,m="object"==typeof self&&self&&self.Object===Object&&self,_=b||m||Function("return this")(),w=_.Symbol;function j(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&D(e,t[r],0)>-1;);return r}(n,o)+1).join("")}function ot(t){return void 0===t}var it="[object Boolean]";var at="[object Number]";function ut(t){return function(t){return"number"==typeof t||$(t)&&C(t)==at}(t)&&t!=+t}var ct="[object String]";function st(t){return"string"==typeof t||!O(t)&&$(t)&&C(t)==ct}function ft(t,e){return function(r){return t(e(r))}}var lt=ft(Object.getPrototypeOf,Object),pt="[object Object]",ht=Function.prototype,dt=Object.prototype,vt=ht.toString,gt=dt.hasOwnProperty,yt=vt.call(Object);function bt(t){if(!$(t)||C(t)!=pt)return!1;var e=lt(t);if(null===e)return!0;var r=gt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&vt.call(r)==yt}var mt,_t=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[mt?a:++n];if(!1===e(o[u],u,o))break}return t};var wt="[object Arguments]";function jt(t){return $(t)&&C(t)==wt}var Ot=Object.prototype,St=Ot.hasOwnProperty,Et=Ot.propertyIsEnumerable,kt=jt(function(){return arguments}())?jt:function(t){return $(t)&&St.call(t,"callee")&&!Et.call(t,"callee")};var At="object"==typeof exports&&exports&&!exports.nodeType&&exports,xt=At&&"object"==typeof module&&module&&!module.nodeType&&module,Tt=xt&&xt.exports===At?_.Buffer:void 0,Pt=(Tt?Tt.isBuffer:void 0)||function(){return!1},qt=9007199254740991,Ct=/^(?:0|[1-9]\d*)$/;function $t(t,e){var r=typeof t;return!!(e=null==e?qt:e)&&("number"==r||"symbol"!=r&&Ct.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=Nt}var Ft={};Ft["[object Float32Array]"]=Ft["[object Float64Array]"]=Ft["[object Int8Array]"]=Ft["[object Int16Array]"]=Ft["[object Int32Array]"]=Ft["[object Uint8Array]"]=Ft["[object Uint8ClampedArray]"]=Ft["[object Uint16Array]"]=Ft["[object Uint32Array]"]=!0,Ft["[object Arguments]"]=Ft["[object Array]"]=Ft["[object ArrayBuffer]"]=Ft["[object Boolean]"]=Ft["[object DataView]"]=Ft["[object Date]"]=Ft["[object Error]"]=Ft["[object Function]"]=Ft["[object Map]"]=Ft["[object Number]"]=Ft["[object Object]"]=Ft["[object RegExp]"]=Ft["[object Set]"]=Ft["[object String]"]=Ft["[object WeakMap]"]=!1;var Rt,It="object"==typeof exports&&exports&&!exports.nodeType&&exports,Jt=It&&"object"==typeof module&&module&&!module.nodeType&&module,Mt=Jt&&Jt.exports===It&&b.process,Ut=function(){try{var t=Jt&&Jt.require&&Jt.require("util").types;return t||Mt&&Mt.binding&&Mt.binding("util")}catch(t){}}(),Dt=Ut&&Ut.isTypedArray,Ht=Dt?(Rt=Dt,function(t){return Rt(t)}):function(t){return $(t)&&zt(t.length)&&!!Ft[C(t)]},Lt=Object.prototype.hasOwnProperty;function Bt(t,e){var r=O(t),n=!r&&kt(t),o=!r&&!n&&Pt(t),i=!r&&!n&&!o&&Ht(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},ce.prototype.set=function(t,e){var r=this.__data__,n=ae(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var se,fe=_["__core-js_shared__"],le=(se=/[^.]+$/.exec(fe&&fe.keys&&fe.keys.IE_PROTO||""))?"Symbol(src)_1."+se:"";var pe=Function.prototype.toString;function he(t){if(null!=t){try{return pe.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var de=/^\[object .+?Constructor\]$/,ve=Function.prototype,ge=Object.prototype,ye=ve.toString,be=ge.hasOwnProperty,me=RegExp("^"+ye.call(be).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function _e(t){return!(!Yt(t)||function(t){return!!le&&le in t}(t))&&(ee(t)?me:de).test(he(t))}function we(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return _e(r)?r:void 0}var je=we(_,"Map"),Oe=we(Object,"create");var Se="__lodash_hash_undefined__",Ee=Object.prototype.hasOwnProperty;var ke=Object.prototype.hasOwnProperty;var Ae="__lodash_hash_undefined__";function xe(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&Re?new Ne:void 0;for(i.set(t,e),i.set(e,t);++f0){if(++e>=En)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Sn);function Tn(t,e){return xn(function(t,e,r){return e=On(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=On(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Pn.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!Yt(r))return!1;var n=typeof e;return!!("number"==n?re(r)&&$t(e,r.length):"string"==n&&e in r)&&ie(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0))},Qn=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},Zn=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!Yn(e)(t)})).length)})).length:e.length>e.filter((function(t){return!Xn(r,t)})).length},to=function(t,e){if(void 0===e&&(e=null),bt(t)){if(!e)return!0;if(Xn(e))return!e.filter((function(e){var r=t[e.name];return!(e.type.length>e.type.filter((function(t){var e;return!!ot(r)||(!1!==(e=Qn(t))?!Zn({arg:r},e):!Yn(t)(r))})).length)})).length}return!1},eo=function(t){var e=t.arg,r=t.param,n=[e];return Array.isArray(r.keys)&&r.keys.length&&n.push(r.keys),to.apply(null,n)},ro=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),no=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),oo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),io=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),ao=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),uo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),co=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),so=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),fo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),lo=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),po=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),ho=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),vo=Object.freeze({__proto__:null,Jsonql406Error:ro,Jsonql500Error:no,JsonqlAuthorisationError:oo,JsonqlContractAuthError:io,JsonqlResolverAppError:ao,JsonqlResolverNotFoundError:uo,JsonqlEnumError:co,JsonqlTypeError:so,JsonqlCheckerError:fo,JsonqlValidationError:lo,JsonqlError:po,JsonqlServerError:ho}),go=po,yo=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function bo(t){if(yo(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||g,a=e.detail||e;if(o&&vo[o])throw new vo[r](i,a);throw new go(i,a)}return t}function mo(t){if(Array.isArray(t))throw new lo("",t);var e=t.message||g,r=t.detail||t;switch(!0){case t instanceof ro:throw new ro(e,r);case t instanceof no:throw new no(e,r);case t instanceof oo:throw new oo(e,r);case t instanceof io:throw new io(e,r);case t instanceof ao:throw new ao(e,r);case t instanceof uo:throw new uo(e,r);case t instanceof co:throw new co(e,r);case t instanceof so:throw new so(e,r);case t instanceof fo:throw new fo(e,r);case t instanceof lo:throw new lo(e,r);case t instanceof ho:throw new ho(e,r);default:throw new po(e,r)}}function _o(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,console,t)}catch(t){}}var wo=function(t,e){var r;switch(!0){case"object"===t:return!eo(e);case"array"===t:return!Xn(e.arg);case!1!==(r=Qn(t)):return!Zn(e,r);default:return!Yn(t)(e.arg)}},jo=function(t,e){return ot(t)?!0!==e.optional||ot(e.defaultvalue)?null:e.defaultvalue:t},Oo=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!Xn(e))throw new po("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!Xn(t))throw new po("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return _o(1),t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:_o(2);var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:_o(4);var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?jo(t,a):t,index:r,param:a,optional:i}}));default:throw _o(5),new po("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!In(e)&&!(r.type.length>r.type.filter((function(e){return wo(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return wo(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},So=function(t,e){var r,n=Object.keys(t);return r=e,!!n.filter((function(t){return t===r})).length},Eo=function(t){return!In(t)};function ko(t,e){var r=Rn(e,(function(t,e){return!t[Gn]}));return Tr(r,{})?t:function(t,e){var r={};return e=en(e),oe(t,(function(t,n,o){nn(r,e(t,n,o),t)})),r}(t,(function(t,e){return function(t,e,r){var n;return r(t,(function(t,r,o){if(e(t,r,o))return n=r,!1})),n}(r,en((function(t){return t.alias===e})),oe)||e}))}function Ao(t,e){return Cn(e,(function(e,r){var n,o;return ot(t[r])||!0===e[Ln]&&Eo(t[r])?qn({},e,((n={})[Wn]=!0,n)):((o={})[Kn]=t[r],o[Hn]=e[Hn],o[Ln]=e[Ln]||!1,o[Bn]=e[Bn]||!1,o[Vn]=e[Vn]||!1,o)}))}function xo(t,e){var r=function(t,e){var r=ko(t,e);return{pristineValues:Cn(Rn(e,(function(t,e){return So(r,e)})),(function(t){return t.args})),checkAgainstAppProps:Rn(e,(function(t,e){return!So(r,e)})),config:r}}(t,e),n=r.config,o=r.pristineValues;return[Ao(n,r.checkAgainstAppProps),o]}var To=function(t){return Xn(t)?t:[t]};var Po=function(t,e){return!Xn(e)||function(t,e){return!!t.filter((function(t){return t===e})).length}(e,t)},qo=function(t,e){try{return!!ee(e)&&e.apply(null,[t])}catch(t){return!1}};function Co(t){return function(e,r){if(e[Wn])return e[Kn];var n=function(t,e){var r,n=[[t[Kn]],[(r={},r[Hn]=To(t[Hn]),r[Ln]=t[Ln],r)]];return Reflect.apply(e,null,n)}(e,t);if(n.length)throw _o("runValidationAction",r,e),new so(r,n);if(!1!==e[Bn]&&!Po(e[Kn],e[Bn]))throw _o(Bn,e[Bn]),new co(r);if(!1!==e[Vn]&&!qo(e[Kn],e[Vn]))throw _o(Vn,e[Vn]),new fo(r);return e[Kn]}}var $o=function(t,e){return Promise.resolve(xo(t,e))};function No(t,e,r,n){return void 0===t&&(t={}),$o(t,e).then((function(t){return function(t,e){var r=t[0],n=t[1],o=Cn(r,Co(e));return qn(o,n)}(t,n)})).then((function(t){return qn({},t,r)}))}function zo(t,e,r,n,o,i){void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===o&&(o=!1),void 0===i&&(i=!1);var a={};return a[l]=t,a[c]=e,!0===r&&(a[s]=!0),Xn(n)&&(a[f]=n),ee(o)&&(a[p]=o),st(i)&&(a[h]=i),a}var Fo=Mn,Ro=Xn,Io=function(t,e,r){return void 0===r&&(r=!1),new Promise((function(n,o){var i=Oo(t,e,r);return r?i.error.length?o(i.error):n(i.data):i.length?o(i):n([])}))},Jo=function(t,e,r){void 0===r&&(r={});var n=r[s],o=r[f],i=r[p],a=r[h];return zo.apply(null,[t,e,n,o,i,a])},Mo=function(t){return function(e,r,n){return void 0===n&&(n={}),No(e,r,n,t)}}(Oo),Uo=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=si().key(e);t(fi(r),r)}},remove:function(t){return si().removeItem(t)},clearAll:function(){return si().clear()}};function si(){return ui.localStorage}function fi(t){return si().getItem(t)}var li=Bo.trim,pi={name:"cookieStorage",read:function(t){if(!t||!gi(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(hi.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;hi.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:di,remove:vi,clearAll:function(){di((function(t,e){vi(e)}))}},hi=Bo.Global.document;function di(t){for(var e=hi.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(li(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function vi(t){t&&gi(t)&&(hi.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function gi(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(hi.cookie)}var yi=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var bi="expire_mixin",mi=function(){var t=this.createStore(this.storage,null,this._namespacePrefix+bi);return{set:function(e,r,n,o){this.hasNamespace(bi)||t.set(r,o);return e()},get:function(t,r){this.hasNamespace(bi)||e.call(this,r);return t()},remove:function(e,r){this.hasNamespace(bi)||t.remove(r);return e()},getExpiration:function(e,r){return t.get(r)},removeExpiredKeys:function(t){var r=[];this.each((function(t,e){r.push(e)}));for(var n=0;n>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)}));var Ai=[ci,pi],xi=[yi,mi,Si,function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=ki.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=ki.compress(this._serialize(r));t(e,n)}}}],Ti=oi.createStore(Ai,xi),Pi=Bo.Global;function qi(){return Pi.sessionStorage}function Ci(t){return qi().getItem(t)}var $i=[{name:"sessionStorage",read:Ci,write:function(t,e){return qi().setItem(t,e)},each:function(t){for(var e=qi().length-1;e>=0;e--){var r=qi().key(e);t(Ci(r),r)}},remove:function(t){return qi().removeItem(t)},clearAll:function(){return qi().clear()}},pi],Ni=[yi,mi],zi=oi.createStore($i,Ni),Fi=Ti,Ri=zi,Ii=Array.isArray,Ji=void 0!==y?y:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Mi="object"==typeof Ji&&Ji&&Ji.Object===Object&&Ji,Ui="object"==typeof self&&self&&self.Object===Object&&self,Di=(Mi||Ui||Function("return this")()).Symbol,Hi=Object.prototype,Li=Hi.hasOwnProperty,Bi=Hi.toString,Ki=Di?Di.toStringTag:void 0;var Vi=Object.prototype.toString;var Gi="[object Null]",Wi="[object Undefined]",Yi=Di?Di.toStringTag:void 0;function Xi(t){return null==t?void 0===t?Wi:Gi:Yi&&Yi in Object(t)?function(t){var e=Li.call(t,Ki),r=t[Ki];try{t[Ki]=void 0;var n=!0}catch(t){}var o=Bi.call(t);return n&&(e?t[Ki]=r:delete t[Ki]),o}(t):function(t){return Vi.call(t)}(t)}var Qi=function(t,e){return function(r){return t(e(r))}}(Object.getPrototypeOf,Object);function Zi(t){return null!=t&&"object"==typeof t}var ta="[object Object]",ea=Function.prototype,ra=Object.prototype,na=ea.toString,oa=ra.hasOwnProperty,ia=na.call(Object);var aa=Di?Di.prototype:void 0,ua=(aa&&aa.toString,"[object String]");function ca(t){return"string"==typeof t||!Ii(t)&&Zi(t)&&Xi(t)==ua}var sa=function(t,e){return!!t.filter((function(t){return t===e})).length},fa=function(t,e){var r=Object.keys(t);return sa(r,e)},la=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},pa="query",ha="mutation",da="socket",va="payload",ga="condition",ya=function(){try{if(window||document)return!0}catch(t){}return!1},ba=function(){try{if(!ya()&&Ji)return!0}catch(t){}return!1};var ma=function(t){function e(){for(var r=arguments,n=[],o=arguments.length;o--;)n[o]=r[o];t.apply(this,n),this.message=n[0],this.detail=n[1],this.className=e.name,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(function(t){function e(){for(var e=arguments,r=[],n=arguments.length;n--;)r[n]=e[n];t.apply(this,r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.where=function(){return ya()?"browser":ba()?"node":"unknown"},e}(Error));var _a=function(t){var e;return(e={}).args=t,e};var wa=function(t){return fa(t,"data")&&!fa(t,"error")?t.data:t},ja=function(t){return function(t){if(!Zi(t)||Xi(t)!=ta)return!1;var e=Qi(t);if(null===e)return!0;var r=oa.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&na.call(r)==ia}(t)&&(fa(t,pa)||fa(t,ha)||fa(t,da))},Oa=function(t,e){return void 0===e&&(e={}),ja(e)?Promise.resolve(e):t.getContract()},Sa="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Ea(t){this.message=t}Ea.prototype=new Error,Ea.prototype.name="InvalidCharacterError";var ka="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Ea("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=Sa.indexOf(n);return a};var Aa=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(ka(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return ka(e)}};function xa(t){this.message=t}xa.prototype=new Error,xa.prototype.name="InvalidTokenError";var Ta=function(t,e){if("string"!=typeof t)throw new xa("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Aa(t.split(".")[r]))}catch(t){throw new xa("Invalid token specified: "+t.message)}},Pa=xa;Ta.InvalidTokenError=Pa;var qa,Ca,$a,Na,za,Fa,Ra,Ia,Ja,Ma=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Ua(t){if(Fo(t))return function(t){var e=t.iat||Ma(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new po("Token has expired on "+r,t)}return t}(Ta(t));throw new po("Token must be a string!")}Jo("HS256",["string"]),Jo(!1,["boolean","number","string"],((qa={})[h]="exp",qa[s]=!0,qa)),Jo(!1,["boolean","number","string"],((Ca={})[h]="nbf",Ca[s]=!0,Ca)),Jo(!1,["boolean","string"],(($a={})[h]="iss",$a[s]=!0,$a)),Jo(!1,["boolean","string"],((Na={})[h]="sub",Na[s]=!0,Na)),Jo(!1,["boolean","string"],((za={})[h]="iss",za[s]=!0,za)),Jo(!1,["boolean"],((Fa={})[s]=!0,Fa)),Jo(!1,["boolean","string"],((Ra={})[s]=!0,Ra)),Jo(!1,["boolean","string"],((Ia={})[s]=!0,Ia)),Jo(!1,["boolean"],((Ja={})[s]=!0,Ja));var Da=u[0],Ha=u[1],La=function(t){!function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,null,t)}catch(t){}}(t),this.fly=t.Fly?new t.Fly:new Fly,this.opts=t,this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()},Ba={headers:{configurable:!0}};Ba.headers.set=function(t){this.extraHeader=t},La.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=qn({},{_cb:la()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=qn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}return this.fly.request(this.jsonqlEndpoint,t,qn({},{method:Da,params:o},e))},La.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},La.prototype.processJsonp=function(t){return wa(t)},La.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call"),e.cleanUp();var o=Fo(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):wa(o)}),(function(t){throw e.cleanUp(),console.error(t),new ho("Server side error",t)}))},La.prototype.getHeaders=function(){return this.opts.enableAuth?qn({},a,this.getAuthHeader(),this.extraHeader):qn({},a,this.extraHeader)},La.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},La.prototype.get=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=qn({},this.extraParams,v)),this.request({},{method:"GET"},this.contractHeader).then(bo).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e}))},La.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){var n;if(void 0===e&&(e=[]),void 0===r&&(r=!1),ca(t)&&Ii(e)){var o=_a(e);return!0===r?o:((n={})[t]=o,n)}throw new ma("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(bo)},La.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){var o;void 0===r&&(r={}),void 0===n&&(n=!1);var i={};if(i[va]=e,i[ga]=r,!0===n)return i;if(ca(t))return(o={})[t]=i,o;throw new ma("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Ha}).then(bo)},Object.defineProperties(La.prototype,Ba);var Ka=function(t){function e(e,r){void 0===r&&(r=null),r&&(e.Fly=r),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={storeIt:{configurable:!0},jsonqlEndpoint:{configurable:!0},jsonqlContract:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return r.storeIt.set=function(t){throw console.info("storeIt",t),Ro(t)&&t.length>=2&&Reflect.apply(Fi.set,Fi,t),new lo("Expect argument to be array and least 2 items!")},r.jsonqlEndpoint.set=function(t){var e=Fi.get("endpoint")||[];sa(e,t)||(e.push(t),this.storeId=["endpoint",e],this.endpointIndex=e.length-1)},r.jsonqlContract.set=function(t){var e=this.opts.storageKey,r=[e],n=t[0],o=t[1],i=Fi.get(e)||[];i[this.endpointIndex||0]=n,r.push(i),o&&r.push(o),this.opts.keepContract&&(this.storeIt=r)},r.jsonqlToken.set=function(t){var e="credential",r=localStorage.get(e)||[];if(!sa(r,t)){var n=r.length-1;r[n]=t,this[e+"Index"]=n;var o=[e,r];if(this.opts.tokenExpired){var i=parseFloat(this.opts.tokenExpired);if(!isNaN(i)&&i>0){var a=la();o.push(a+parseFloat(i))}}return this.storeIt=o,this.jsonqlUserdata=this.decoder(t),t}return!1},r.jsonqlUserdata.set=function(t){var e=["userdata",t];return t.exp&&e.push(t.exp),Reflect.apply(Fi.set,Fi,e)},r.jsonqlEndpoint.get=function(){var t=Fi.get("endpoint");if(!t){var e=this.opts,r=[e.hostname,e.jsonqlPath].join("/");return this.jsonqlEndpoint=r,r}return t[this.endpointIndex]},r.jsonqlContract.get=function(){var t=this.opts.storageKey;return(Fi.get(t)||[])[this.endpointIndex]||!1},r.jsonqlToken.get=function(){var t="credential",e=localStorage.get(t);return!!e&&e[this[t+"Index"]]},r.jsonqlUserdata.get=function(){return Ri.get("userdata")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&e.useJwt&&(this.setDecoder=Ua)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={userdata:{configurable:!0},rawAuthToken:{configurable:!0},setDecoder:{configurable:!0}};return r.userdata.get=function(){return this.jsonqlUserdata},r.rawAuthToken.get=function(){return this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},e.prototype.storeToken=function(t){return this.jsonqlToken=t},e.prototype.decoder=function(t){return t},e.prototype.getAuthHeader=function(){var t,e=this.rawAuthToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();if(this.log("getContract first call",t),t&&Array.isArray(t)){var e=t[this.endpointIndex||0];if(e)return Promise.resolve(e)}return this.get().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){if(!ja(t))throw new lo("Contract is malformed!");var e=[t];if(this.opts.contractExpired){var r=parseFloat(this.opts.contractExpired);!isNaN(r)&&r>0&&e.push(r)}return this.jsonqlContract=e,this.log("storeContract return result",t),t},e.prototype.readContract=function(){return ja(this.opts.contract)?this.opts.contract:Fi.get(this.opts.storageKey)},Object.defineProperties(e.prototype,r),e}(La))),Va=function(t){return O(t)?t:[t]},Ga=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,Va(t))}),Reflect.apply(t,null,r))}};function Wa(t,e,r,n){void 0===n&&(n=!1);var o=function(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Ya=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Io(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(mo)}},Xa=function(t,e,r,n,o){var i={},a=function(t){i=Wa(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Io(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(mo)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Qa=function(t,e,r,n,o){var i={},a=function(t){i=Wa(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return Io(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(mo)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Za=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Ya(e,a,0,o);return i.apply(null,t).then(e.postLoginAction).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Ya(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var tu=function(t,e,r,n){var o=function(t,e,r,n){return Ga(Xa,Qa,Za)({},t,e,r,n)}(t,n,e,r);return e.enableAuth&&(o.userdata=function(){return t.userdata}),o.getToken=function(){return t.rawAuthToken},e.exposeContract&&(o.getContract=function(){return t.getContract()}),o.eventEmitter=n,o.version="1.4.7",o},eu={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:i,BEARER:"Bearer",AUTH_HEADER:"Authorization"},ru={hostname:Jo(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:Jo("jsonql",["string"]),loginHandlerName:Jo("login",["string"]),logoutHandlerName:Jo("logout",["string"]),enableJsonp:Jo(!1,["boolean"]),enableAuth:Jo(!1,["boolean"]),useJwt:Jo(!0,["boolean"]),useLocalstorage:Jo(!0,["boolean"]),storageKey:Jo("storageKey",["string"]),authKey:Jo("authKey",["string"]),contractExpired:Jo(0,["number"]),keepContract:Jo(!0,["boolean"]),exposeContract:Jo(!1,["boolean"]),showContractDesc:Jo(!1,["boolean"]),contractKey:Jo(!1,["boolean"]),contractKeyName:Jo("X-JSONQL-CV-KEY",["string"]),enableTimeout:Jo(!1,["boolean"]),timeout:Jo(5e3,["number"]),returnInstance:Jo(!1,["boolean"]),allowReturnRawToken:Jo(!1,["boolean"]),debugOn:Jo(!1,["boolean"])};function nu(t){return t[d]?t:function(t){var e=t.contract;return Mo(t,ru,eu).then((function(t){return t.contract=e,t}))}(t)}var ou=new WeakMap,iu=new WeakMap;var au=function(){this.__suspend__=null,this.queueStore=new Set},uu={$suspend:{configurable:!0},$queues:{configurable:!0}};uu.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},au.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},uu.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},au.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(au.prototype,uu);var cu=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){ou.set(this,t)},r.normalStore.get=function(){return ou.get(this)},r.lazyStore.set=function(t){iu.set(this,t)},r.lazyStore.get=function(){return iu.get(this)},e.prototype.hashFnToKey=function(t){return t.toString().split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)+""},Object.defineProperties(e.prototype,r),e}(au));function su(t,e){var r;return function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r=null),nu(e).then((function(t){return{baseClient:new Ka(t,r),opts:t}})).then((function(e){var r=e.baseClient,n=e.opts;return Oa(r,n.contract).then((function(e){return tu(r,n,e,t)}))}))}((r=e.debugOn,new cu({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),e,t)}return function(t){return void 0===t&&(t={}),su(o,t)}})); //# sourceMappingURL=jsonql-client.umd.js.map diff --git a/packages/http-client/package.json b/packages/http-client/package.json index 055c25c04a93189a9be2414b630c8beb50039819..b81c1a3ec233ddd4a32f26c79a426db8e23e8b6c 100755 --- a/packages/http-client/package.json +++ b/packages/http-client/package.json @@ -1,6 +1,6 @@ { "name": "jsonql-client", - "version": "1.4.6", + "version": "1.4.7", "description": "jsonql http browser client using Fly.js", "main": "core.js", "module": "index.js", @@ -63,9 +63,9 @@ "flyio": "^0.6.14", "jsonql-constants": "^1.8.12", "jsonql-errors": "^1.1.7", - "jsonql-jwt": "^1.3.4", + "jsonql-jwt": "^1.3.5", "jsonql-params-validator": "^1.4.13", - "jsonql-utils": "^0.8.10", + "jsonql-utils": "^0.8.11", "lodash-es": "^4.17.15", "nb-event-service": "^1.8.5", "store": "^2.0.12" @@ -76,12 +76,12 @@ "debug": "^4.1.1", "esm": "^3.2.25", "glob": "^7.1.6", - "jsonql-koa": "^1.4.20", + "jsonql-koa": "^1.4.21", "koa-favicon": "^2.0.1", "nyc": "^14.1.1", "promise-polyfill": "8.1.3", "qunit": "^2.9.3", - "rollup": "^1.27.6", + "rollup": "^1.27.7", "rollup-plugin-alias": "^2.2.0", "rollup-plugin-analyzer": "^3.2.2", "rollup-plugin-async": "^1.2.0", diff --git a/packages/http-client/static.js b/packages/http-client/static.js index f851e42bdd9b84789d235827d9cdfcb4b6e5d914..0ad5689599a013e1e8c21beca66a9bb9337ca40c 100644 --- a/packages/http-client/static.js +++ b/packages/http-client/static.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClientStatic=e()}(this,(function(){"use strict";var t="application/vnd.api+json",e={Accept:t,"Content-Type":[t,"charset=utf-8"].join(";")},r=["POST","PUT"],n="type",o="optional",i="enumv",a="args",u="checker",c="alias",s="__checked__",f={desc:"y"},l="No message",p="onResult",h="onError",d=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),v=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),g=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),y=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),b=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),m=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),_=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),w=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),j=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),O=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),S=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),E=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),A=Object.freeze({__proto__:null,Jsonql406Error:d,Jsonql500Error:v,JsonqlAuthorisationError:g,JsonqlContractAuthError:y,JsonqlResolverAppError:b,JsonqlResolverNotFoundError:m,JsonqlEnumError:_,JsonqlTypeError:w,JsonqlCheckerError:j,JsonqlValidationError:O,JsonqlError:S,JsonqlServerError:E}),k=S,T=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function x(t){if(T(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||l,a=e.detail||e;if(o&&A[o])throw new A[r](i,a);throw new k(i,a)}return t}function q(t){if(Array.isArray(t))throw new O("",t);var e=t.message||l,r=t.detail||t;switch(!0){case t instanceof d:throw new d(e,r);case t instanceof v:throw new v(e,r);case t instanceof g:throw new g(e,r);case t instanceof y:throw new y(e,r);case t instanceof b:throw new b(e,r);case t instanceof m:throw new m(e,r);case t instanceof _:throw new _(e,r);case t instanceof w:throw new w(e,r);case t instanceof j:throw new j(e,r);case t instanceof O:throw new O(e,r);case t instanceof E:throw new E(e,r);default:throw new S(e,r)}}var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},C="object"==typeof P&&P&&P.Object===Object&&P,$="object"==typeof self&&self&&self.Object===Object&&self,N=C||$||Function("return this")(),z=N.Symbol;function F(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&rt(e,t[r],0)>-1;);return r}(n,o)+1).join("")}function bt(t){return void 0===t}var mt="[object Boolean]";var _t="[object Number]";function wt(t){return function(t){return"number"==typeof t||V(t)&&K(t)==_t}(t)&&t!=+t}var jt="[object String]";function Ot(t){return"string"==typeof t||!I(t)&&V(t)&&K(t)==jt}function St(t,e){return function(r){return t(e(r))}}var Et=St(Object.getPrototypeOf,Object),At="[object Object]",kt=Function.prototype,Tt=Object.prototype,xt=kt.toString,qt=Tt.hasOwnProperty,Pt=xt.call(Object);function Ct(t){if(!V(t)||K(t)!=At)return!1;var e=Et(t);if(null===e)return!0;var r=qt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&xt.call(r)==Pt}var $t,Nt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[$t?a:++n];if(!1===e(o[u],u,o))break}return t};var zt="[object Arguments]";function Ft(t){return V(t)&&K(t)==zt}var It=Object.prototype,Rt=It.hasOwnProperty,Jt=It.propertyIsEnumerable,Mt=Ft(function(){return arguments}())?Ft:function(t){return V(t)&&Rt.call(t,"callee")&&!Jt.call(t,"callee")};var Ut="object"==typeof exports&&exports&&!exports.nodeType&&exports,Dt=Ut&&"object"==typeof module&&module&&!module.nodeType&&module,Ht=Dt&&Dt.exports===Ut?N.Buffer:void 0,Lt=(Ht?Ht.isBuffer:void 0)||function(){return!1},Bt=9007199254740991,Kt=/^(?:0|[1-9]\d*)$/;function Vt(t,e){var r=typeof t;return!!(e=null==e?Bt:e)&&("number"==r||"symbol"!=r&&Kt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=Gt}var Yt={};Yt["[object Float32Array]"]=Yt["[object Float64Array]"]=Yt["[object Int8Array]"]=Yt["[object Int16Array]"]=Yt["[object Int32Array]"]=Yt["[object Uint8Array]"]=Yt["[object Uint8ClampedArray]"]=Yt["[object Uint16Array]"]=Yt["[object Uint32Array]"]=!0,Yt["[object Arguments]"]=Yt["[object Array]"]=Yt["[object ArrayBuffer]"]=Yt["[object Boolean]"]=Yt["[object DataView]"]=Yt["[object Date]"]=Yt["[object Error]"]=Yt["[object Function]"]=Yt["[object Map]"]=Yt["[object Number]"]=Yt["[object Object]"]=Yt["[object RegExp]"]=Yt["[object Set]"]=Yt["[object String]"]=Yt["[object WeakMap]"]=!1;var Qt,Xt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Zt=Xt&&"object"==typeof module&&module&&!module.nodeType&&module,te=Zt&&Zt.exports===Xt&&C.process,ee=function(){try{var t=Zt&&Zt.require&&Zt.require("util").types;return t||te&&te.binding&&te.binding("util")}catch(t){}}(),re=ee&&ee.isTypedArray,ne=re?(Qt=re,function(t){return Qt(t)}):function(t){return V(t)&&Wt(t.length)&&!!Yt[K(t)]},oe=Object.prototype.hasOwnProperty;function ie(t,e){var r=I(t),n=!r&&Mt(t),o=!r&&!n&&Lt(t),i=!r&&!n&&!o&&ne(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},je.prototype.set=function(t,e){var r=this.__data__,n=_e(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var Oe,Se=N["__core-js_shared__"],Ee=(Oe=/[^.]+$/.exec(Se&&Se.keys&&Se.keys.IE_PROTO||""))?"Symbol(src)_1."+Oe:"";var Ae=Function.prototype.toString;function ke(t){if(null!=t){try{return Ae.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var Te=/^\[object .+?Constructor\]$/,xe=Function.prototype,qe=Object.prototype,Pe=xe.toString,Ce=qe.hasOwnProperty,$e=RegExp("^"+Pe.call(Ce).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ne(t){return!(!fe(t)||function(t){return!!Ee&&Ee in t}(t))&&(ve(t)?$e:Te).test(ke(t))}function ze(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return Ne(r)?r:void 0}var Fe=ze(N,"Map"),Ie=ze(Object,"create");var Re="__lodash_hash_undefined__",Je=Object.prototype.hasOwnProperty;var Me=Object.prototype.hasOwnProperty;var Ue="__lodash_hash_undefined__";function De(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&Qe?new Ge:void 0;for(i.set(t,e),i.set(e,t);++f0){if(++e>=Jn)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Rn);function Hn(t,e){return Dn(function(t,e,r){return e=In(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=In(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Ln.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!fe(r))return!1;var n=typeof e;return!!("number"==n?ge(r)&&Vt(e,r.length):"string"==n&&e in r)&&me(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0))},po=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},ho=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!fo(e)(t)})).length)})).length:e.length>e.filter((function(t){return!lo(r,t)})).length},vo=function(t,e){if(void 0===e&&(e=null),Ct(t)){if(!e)return!0;if(lo(e))return!e.filter((function(e){var r=t[e.name];return!(e.type.length>e.type.filter((function(t){var e;return!!bt(r)||(!1!==(e=po(t))?!ho({arg:r},e):!fo(t)(r))})).length)})).length}return!1},go=function(t){var e=t.arg,r=t.param,n=[e];return Array.isArray(r.keys)&&r.keys.length&&n.push(r.keys),vo.apply(null,n)};function yo(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,console,t)}catch(t){}}var bo=function(t,e){var r;switch(!0){case"object"===t:return!go(e);case"array"===t:return!lo(e.arg);case!1!==(r=po(t)):return!ho(e,r);default:return!fo(t)(e.arg)}},mo=function(t,e){return bt(t)?!0!==e.optional||bt(e.defaultvalue)?null:e.defaultvalue:t},_o=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!lo(e))throw new S("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!lo(t))throw new S("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return yo(1),t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:yo(2);var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:yo(4);var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?mo(t,a):t,index:r,param:a,optional:i}}));default:throw yo(5),new S("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!Xn(e)&&!(r.type.length>r.type.filter((function(e){return bo(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return bo(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},wo=function(t,e){var r,n=Object.keys(t);return r=e,!!n.filter((function(t){return t===r})).length},jo=function(t){return!Xn(t)};function Oo(t,e){var r=Qn(e,(function(t,e){return!t[co]}));return Hr(r,{})?t:function(t,e){var r={};return e=gn(e),be(t,(function(t,n,o){bn(r,e(t,n,o),t)})),r}(t,(function(t,e){return function(t,e,r){var n;return r(t,(function(t,r,o){if(e(t,r,o))return n=r,!1})),n}(r,gn((function(t){return t.alias===e})),be)||e}))}function So(t,e){return Kn(e,(function(e,r){var n,o;return bt(t[r])||!0===e[oo]&&jo(t[r])?Bn({},e,((n={})[so]=!0,n)):((o={})[ao]=t[r],o[no]=e[no],o[oo]=e[oo]||!1,o[io]=e[io]||!1,o[uo]=e[uo]||!1,o)}))}function Eo(t,e){var r=function(t,e){var r=Oo(t,e);return{pristineValues:Kn(Qn(e,(function(t,e){return wo(r,e)})),(function(t){return t.args})),checkAgainstAppProps:Qn(e,(function(t,e){return!wo(r,e)})),config:r}}(t,e),n=r.config,o=r.pristineValues;return[So(n,r.checkAgainstAppProps),o]}var Ao=function(t){return lo(t)?t:[t]};var ko=function(t,e){return!lo(e)||function(t,e){return!!t.filter((function(t){return t===e})).length}(e,t)},To=function(t,e){try{return!!ve(e)&&e.apply(null,[t])}catch(t){return!1}};function xo(t){return function(e,r){if(e[so])return e[ao];var n=function(t,e){var r,n=[[t[ao]],[(r={},r[no]=Ao(t[no]),r[oo]=t[oo],r)]];return Reflect.apply(e,null,n)}(e,t);if(n.length)throw yo("runValidationAction",r,e),new w(r,n);if(!1!==e[io]&&!ko(e[ao],e[io]))throw yo(io,e[io]),new _(r);if(!1!==e[uo]&&!To(e[ao],e[uo]))throw yo(uo,e[uo]),new j(r);return e[ao]}}function qo(t,e,r,n){return void 0===t&&(t={}),Bn(function(t,e){var r=t[0],n=t[1],o=Kn(r,xo(e));return Bn(o,n)}(Eo(t,e),n),r)}function Po(t,e,r,s,f,l){void 0===r&&(r=!1),void 0===s&&(s=!1),void 0===f&&(f=!1),void 0===l&&(l=!1);var p={};return p[a]=t,p[n]=e,!0===r&&(p[o]=!0),lo(s)&&(p[i]=s),ve(f)&&(p[u]=f),Ot(l)&&(p[c]=l),p}var Co=to,$o=lo,No=function(t,e,r){return void 0===r&&(r=!1),new Promise((function(n,o){var i=_o(t,e,r);return r?i.error.length?o(i.error):n(i.data):i.length?o(i):n([])}))},zo=function(t,e,r){void 0===r&&(r={});var n=r[o],a=r[i],s=r[u],f=r[c];return Po.apply(null,[t,e,n,a,s,f])},Fo=function(t){return function(e,r,n){return void 0===n&&(n={}),qo(e,r,n,t)}}(_o),Io=function(t){return I(t)?t:[t]},Ro=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,Io(t))}),Reflect.apply(t,null,r))}};function Jo(t,e,r,n){void 0===n&&(n=!1);var o=function(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Mo=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return No(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(q)}},Uo=function(t,e,r,n,o){var i={},a=function(t){i=Jo(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return No(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(q)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Do=function(t,e,r,n,o){var i={},a=function(t){i=Jo(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return No(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(q)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Ho=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Mo(e,a,0,o);return i.apply(null,t).then(e.postLoginAction).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Mo(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var Lo=Array.isArray,Bo=void 0!==P?P:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Ko="object"==typeof Bo&&Bo&&Bo.Object===Object&&Bo,Vo="object"==typeof self&&self&&self.Object===Object&&self,Go=(Ko||Vo||Function("return this")()).Symbol,Wo=Object.prototype,Yo=Wo.hasOwnProperty,Qo=Wo.toString,Xo=Go?Go.toStringTag:void 0;var Zo=Object.prototype.toString;var ti="[object Null]",ei="[object Undefined]",ri=Go?Go.toStringTag:void 0;function ni(t){return null==t?void 0===t?ei:ti:ri&&ri in Object(t)?function(t){var e=Yo.call(t,Xo),r=t[Xo];try{t[Xo]=void 0;var n=!0}catch(t){}var o=Qo.call(t);return n&&(e?t[Xo]=r:delete t[Xo]),o}(t):function(t){return Zo.call(t)}(t)}var oi=function(t,e){return function(r){return t(e(r))}}(Object.getPrototypeOf,Object);function ii(t){return null!=t&&"object"==typeof t}var ai="[object Object]",ui=Function.prototype,ci=Object.prototype,si=ui.toString,fi=ci.hasOwnProperty,li=si.call(Object);var pi=Go?Go.prototype:void 0,hi=(pi&&pi.toString,"[object String]");function di(t){return"string"==typeof t||!Lo(t)&&ii(t)&&ni(t)==hi}var vi=function(t,e){return!!t.filter((function(t){return t===e})).length},gi=function(t,e){var r=Object.keys(t);return vi(r,e)},yi=function(){for(var t=arguments,e=[],r=arguments.length;r--;)e[r]=t[r];return e.join("_")},bi=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},mi="query",_i="mutation",wi="socket",ji="payload",Oi="condition",Si=function(){try{if(window||document)return!0}catch(t){}return!1},Ei=function(){try{if(!Si()&&Bo)return!0}catch(t){}return!1};var Ai=function(t){function e(){for(var r=arguments,n=[],o=arguments.length;o--;)n[o]=r[o];t.apply(this,n),this.message=n[0],this.detail=n[1],this.className=e.name,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(function(t){function e(){for(var e=arguments,r=[],n=arguments.length;n--;)r[n]=e[n];t.apply(this,r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.where=function(){return Si()?"browser":Ei()?"node":"unknown"},e}(Error));var ki=function(t){var e;return(e={}).args=t,e};var Ti=function(t){return gi(t,"data")&&!gi(t,"error")?t.data:t},xi=function(t){return function(t){if(!ii(t)||ni(t)!=ai)return!1;var e=oi(t);if(null===e)return!0;var r=fi.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&si.call(r)==li}(t)&&(gi(t,mi)||gi(t,_i)||gi(t,wi))},qi=function(t,e){return void 0===e&&(e={}),xi(e)?Promise.resolve(e):t.getContract()},Pi=function(t,e){return function(r){for(var n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return new Promise((function(o,i){t.$only(yi(e,r,p),o),t.$only(yi(e,r,h),i),t.$trigger(e,{resolverName:r,args:n})}))}},Ci=function(t,e,r){var n=t.$queues,o=r.debugOn;o&&console.info("(validateRegisteredEvents)","storedEvt",n),n.forEach((function(t){var r=t[0],n=t[1].resolverName;if(o&&console.info("(validateRegisteredEvents)",r,n),!e[r][n])throw new Error(r+"."+n+" not existed in contract!")}))};function $i(t,e,r,n){var o=function(t,e,r,n){return Ro(Uo,Do,Ho)({},t,e,r,n)}(t,e,r,n);Ci(e,n,r);var i=function(t){e.$only(t,(function(r){var n=r.resolverName,i=r.args;o[t][n]?Reflect.apply(o[t][n],null,i).then((function(r){e.$trigger(yi(t,n,p),r)})).catch((function(r){e.$trigger(yi(t,n,h),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}var Ni=function(t,e,r,n){n.$suspend=!0,r.then((function(r){$i(t,n,e,r)}));var o={query:Pi(n,"query"),mutation:Pi(n,"mutation"),auth:Pi(n,"auth"),getToken:function(){return t.rawAuthToken}};return e.exposeContract&&(o.getContract=function(){return t.get()}),e.enableAuth&&(o.userdata=function(){return t.userdata}),o.version="1.4.6",o},zi="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var Fi=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=oa().key(e);t(ia(r),r)}},remove:function(t){return oa().removeItem(t)},clearAll:function(){return oa().clear()}};function oa(){return ra.localStorage}function ia(t){return oa().getItem(t)}var aa=Mi.trim,ua={name:"cookieStorage",read:function(t){if(!t||!la(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(ca.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;ca.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:sa,remove:fa,clearAll:function(){sa((function(t,e){fa(e)}))}},ca=Mi.Global.document;function sa(t){for(var e=ca.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(aa(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function fa(t){t&&la(t)&&(ca.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function la(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(ca.cookie)}var pa=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var ha="expire_mixin",da=function(){var t=this.createStore(this.storage,null,this._namespacePrefix+ha);return{set:function(e,r,n,o){this.hasNamespace(ha)||t.set(r,o);return e()},get:function(t,r){this.hasNamespace(ha)||e.call(this,r);return t()},remove:function(e,r){this.hasNamespace(ha)||t.remove(r);return e()},getExpiration:function(e,r){return t.get(r)},removeExpiredKeys:function(t){var r=[];this.each((function(t,e){r.push(e)}));for(var n=0;n>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)}));var ja=[na,ua],Oa=[pa,da,ma,function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=wa.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=wa.compress(this._serialize(r));t(e,n)}}}],Sa=Zi.createStore(ja,Oa),Ea=Mi.Global;function Aa(){return Ea.sessionStorage}function ka(t){return Aa().getItem(t)}var Ta=[{name:"sessionStorage",read:ka,write:function(t,e){return Aa().setItem(t,e)},each:function(t){for(var e=Aa().length-1;e>=0;e--){var r=Aa().key(e);t(ka(r),r)}},remove:function(t){return Aa().removeItem(t)},clearAll:function(){return Aa().clear()}},ua],xa=[pa,da],qa=Zi.createStore(Ta,xa),Pa=Sa,Ca=qa,$a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Na(t){this.message=t}Na.prototype=new Error,Na.prototype.name="InvalidCharacterError";var za="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Na("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=$a.indexOf(n);return a};var Fa=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(za(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return za(e)}};function Ia(t){this.message=t}Ia.prototype=new Error,Ia.prototype.name="InvalidTokenError";var Ra=function(t,e){if("string"!=typeof t)throw new Ia("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Fa(t.split(".")[r]))}catch(t){throw new Ia("Invalid token specified: "+t.message)}},Ja=Ia;Ra.InvalidTokenError=Ja;var Ma,Ua,Da,Ha,La,Ba,Ka,Va,Ga,Wa=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Ya(t){if(Co(t))return function(t){var e=t.iat||Wa(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new S("Token has expired on "+r,t)}return t}(Ra(t));throw new S("Token must be a string!")}zo("HS256",["string"]),zo(!1,["boolean","number","string"],((Ma={})[c]="exp",Ma[o]=!0,Ma)),zo(!1,["boolean","number","string"],((Ua={})[c]="nbf",Ua[o]=!0,Ua)),zo(!1,["boolean","string"],((Da={})[c]="iss",Da[o]=!0,Da)),zo(!1,["boolean","string"],((Ha={})[c]="sub",Ha[o]=!0,Ha)),zo(!1,["boolean","string"],((La={})[c]="iss",La[o]=!0,La)),zo(!1,["boolean"],((Ba={})[o]=!0,Ba)),zo(!1,["boolean","string"],((Ka={})[o]=!0,Ka)),zo(!1,["boolean","string"],((Va={})[o]=!0,Va)),zo(!1,["boolean"],((Ga={})[o]=!0,Ga));var Qa=r[0],Xa=r[1],Za=function(t){!function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,null,t)}catch(t){}}(t),this.fly=t.Fly?new t.Fly:new Fly,this.opts=t,this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()},tu={headers:{configurable:!0}};tu.headers.set=function(t){this.extraHeader=t},Za.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=Bn({},{_cb:bi()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=Bn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}return this.fly.request(this.jsonqlEndpoint,t,Bn({},{method:Qa,params:o},e))},Za.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},Za.prototype.processJsonp=function(t){return Ti(t)},Za.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call"),e.cleanUp();var o=Co(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):Ti(o)}),(function(t){throw e.cleanUp(),console.error(t),new E("Server side error",t)}))},Za.prototype.getHeaders=function(){return this.opts.enableAuth?Bn({},e,this.getAuthHeader(),this.extraHeader):Bn({},e,this.extraHeader)},Za.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},Za.prototype.get=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=Bn({},this.extraParams,f)),this.request({},{method:"GET"},this.contractHeader).then(x).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e}))},Za.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){var n;if(void 0===e&&(e=[]),void 0===r&&(r=!1),di(t)&&Lo(e)){var o=ki(e);return!0===r?o:((n={})[t]=o,n)}throw new Ai("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(x)},Za.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){var o;void 0===r&&(r={}),void 0===n&&(n=!1);var i={};if(i[ji]=e,i[Oi]=r,!0===n)return i;if(di(t))return(o={})[t]=i,o;throw new Ai("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Xa}).then(x)},Object.defineProperties(Za.prototype,tu);var eu=function(t){function e(e,r){void 0===r&&(r=null),r&&(e.Fly=r),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={storeIt:{configurable:!0},jsonqlEndpoint:{configurable:!0},jsonqlContract:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return r.storeIt.set=function(t){throw console.info("storeIt",t),$o(t)&&t.length>=2&&Reflect.apply(Pa.set,Pa,t),new O("Expect argument to be array and least 2 items!")},r.jsonqlEndpoint.set=function(t){var e=Pa.get("endpoint")||[];vi(e,t)||(e.push(t),this.storeId=["endpoint",e],this.endpointIndex=e.length-1)},r.jsonqlContract.set=function(t){var e=this.opts.storageKey,r=[e],n=t[0],o=t[1],i=Pa.get(e)||[];i[this.endpointIndex||0]=n,r.push(i),o&&r.push(o),this.opts.keepContract&&(this.storeIt=r)},r.jsonqlToken.set=function(t){var e="credential",r=localStorage.get(e)||[];if(!vi(r,t)){var n=r.length-1;r[n]=t,this[e+"Index"]=n;var o=[e,r];if(this.opts.tokenExpired){var i=parseFloat(this.opts.tokenExpired);if(!isNaN(i)&&i>0){var a=bi();o.push(a+parseFloat(i))}}return this.storeIt=o,this.jsonqlUserdata=this.decoder(t),t}return!1},r.jsonqlUserdata.set=function(t){var e=["userdata",t];return t.exp&&e.push(t.exp),Reflect.apply(Pa.set,Pa,e)},r.jsonqlEndpoint.get=function(){var t=Pa.get("endpoint");if(!t){var e=this.opts,r=[e.hostname,e.jsonqlPath].join("/");return this.jsonqlEndpoint=r,r}return t[this.endpointIndex]},r.jsonqlContract.get=function(){var t=this.opts.storageKey;return(Pa.get(t)||[])[this.endpointIndex]||!1},r.jsonqlToken.get=function(){var t="credential",e=localStorage.get(t);return!!e&&e[this[t+"Index"]]},r.jsonqlUserdata.get=function(){return Ca.get("userdata")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&e.useJwt&&(this.setDecoder=Ya)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={userdata:{configurable:!0},rawAuthToken:{configurable:!0},setDecoder:{configurable:!0}};return r.userdata.get=function(){return this.jsonqlUserdata},r.rawAuthToken.get=function(){return this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},e.prototype.storeToken=function(t){return this.jsonqlToken=t},e.prototype.decoder=function(t){return t},e.prototype.getAuthHeader=function(){var t,e=this.rawAuthToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();if(this.log("getContract first call",t),t&&Array.isArray(t)){var e=t[this.endpointIndex||0];if(e)return Promise.resolve(e)}return this.get().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){if(!xi(t))throw new O("Contract is malformed!");var e=[t];if(this.opts.contractExpired){var r=parseFloat(this.opts.contractExpired);!isNaN(r)&&r>0&&e.push(r)}return this.jsonqlContract=e,this.log("storeContract return result",t),t},e.prototype.readContract=function(){return xi(this.opts.contract)?this.opts.contract:Pa.get(this.opts.storageKey)},Object.defineProperties(e.prototype,r),e}(Za))),ru={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:t,BEARER:"Bearer",AUTH_HEADER:"Authorization"},nu={hostname:zo(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:zo("jsonql",["string"]),loginHandlerName:zo("login",["string"]),logoutHandlerName:zo("logout",["string"]),enableJsonp:zo(!1,["boolean"]),enableAuth:zo(!1,["boolean"]),useJwt:zo(!0,["boolean"]),useLocalstorage:zo(!0,["boolean"]),storageKey:zo("storageKey",["string"]),authKey:zo("authKey",["string"]),contractExpired:zo(0,["number"]),keepContract:zo(!0,["boolean"]),exposeContract:zo(!1,["boolean"]),showContractDesc:zo(!1,["boolean"]),contractKey:zo(!1,["boolean"]),contractKeyName:zo("X-JSONQL-CV-KEY",["string"]),enableTimeout:zo(!1,["boolean"]),timeout:zo(5e3,["number"]),returnInstance:zo(!1,["boolean"]),allowReturnRawToken:zo(!1,["boolean"]),debugOn:zo(!1,["boolean"])};function ou(t){return t[s]?t:function(t){return Fo(t,nu,ru)}(t)}var iu=new WeakMap,au=new WeakMap;var uu=function(){this.__suspend__=null,this.queueStore=new Set},cu={$suspend:{configurable:!0},$queues:{configurable:!0}};cu.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},uu.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},cu.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},uu.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(uu.prototype,cu);var su=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){iu.set(this,t)},r.normalStore.get=function(){return iu.get(this)},r.lazyStore.set=function(t){au.set(this,t)},r.lazyStore.get=function(){return au.get(this)},e.prototype.hashFnToKey=function(t){return t.toString().split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)+""},Object.defineProperties(e.prototype,r),e}(uu));return function(t,e){void 0===e&&(e={});var r,n=e.contract,o=ou(e),i=new eu(o,t),a=qi(i,n),u=(r=o.debugOn,new su({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),c=Ni(i,o,a,u);return c.eventEmitter=u,c}})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClientStatic=e()}(this,(function(){"use strict";var t="application/vnd.api+json",e={Accept:t,"Content-Type":[t,"charset=utf-8"].join(";")},r=["POST","PUT"],n="type",o="optional",i="enumv",a="args",u="checker",c="alias",s="__checked__",f={desc:"y"},l="No message",p="onResult",h="onError",d=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),v=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),g=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),y=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),b=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),m=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),_=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),w=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),j=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),O=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),S=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),E=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),A=Object.freeze({__proto__:null,Jsonql406Error:d,Jsonql500Error:v,JsonqlAuthorisationError:g,JsonqlContractAuthError:y,JsonqlResolverAppError:b,JsonqlResolverNotFoundError:m,JsonqlEnumError:_,JsonqlTypeError:w,JsonqlCheckerError:j,JsonqlValidationError:O,JsonqlError:S,JsonqlServerError:E}),k=S,T=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function x(t){if(T(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||l,a=e.detail||e;if(o&&A[o])throw new A[r](i,a);throw new k(i,a)}return t}function q(t){if(Array.isArray(t))throw new O("",t);var e=t.message||l,r=t.detail||t;switch(!0){case t instanceof d:throw new d(e,r);case t instanceof v:throw new v(e,r);case t instanceof g:throw new g(e,r);case t instanceof y:throw new y(e,r);case t instanceof b:throw new b(e,r);case t instanceof m:throw new m(e,r);case t instanceof _:throw new _(e,r);case t instanceof w:throw new w(e,r);case t instanceof j:throw new j(e,r);case t instanceof O:throw new O(e,r);case t instanceof E:throw new E(e,r);default:throw new S(e,r)}}var P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},C="object"==typeof P&&P&&P.Object===Object&&P,$="object"==typeof self&&self&&self.Object===Object&&self,N=C||$||Function("return this")(),z=N.Symbol;function F(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&rt(e,t[r],0)>-1;);return r}(n,o)+1).join("")}function bt(t){return void 0===t}var mt="[object Boolean]";var _t="[object Number]";function wt(t){return function(t){return"number"==typeof t||V(t)&&K(t)==_t}(t)&&t!=+t}var jt="[object String]";function Ot(t){return"string"==typeof t||!I(t)&&V(t)&&K(t)==jt}function St(t,e){return function(r){return t(e(r))}}var Et=St(Object.getPrototypeOf,Object),At="[object Object]",kt=Function.prototype,Tt=Object.prototype,xt=kt.toString,qt=Tt.hasOwnProperty,Pt=xt.call(Object);function Ct(t){if(!V(t)||K(t)!=At)return!1;var e=Et(t);if(null===e)return!0;var r=qt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&xt.call(r)==Pt}var $t,Nt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[$t?a:++n];if(!1===e(o[u],u,o))break}return t};var zt="[object Arguments]";function Ft(t){return V(t)&&K(t)==zt}var It=Object.prototype,Rt=It.hasOwnProperty,Jt=It.propertyIsEnumerable,Mt=Ft(function(){return arguments}())?Ft:function(t){return V(t)&&Rt.call(t,"callee")&&!Jt.call(t,"callee")};var Ut="object"==typeof exports&&exports&&!exports.nodeType&&exports,Dt=Ut&&"object"==typeof module&&module&&!module.nodeType&&module,Ht=Dt&&Dt.exports===Ut?N.Buffer:void 0,Lt=(Ht?Ht.isBuffer:void 0)||function(){return!1},Bt=9007199254740991,Kt=/^(?:0|[1-9]\d*)$/;function Vt(t,e){var r=typeof t;return!!(e=null==e?Bt:e)&&("number"==r||"symbol"!=r&&Kt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=Gt}var Yt={};Yt["[object Float32Array]"]=Yt["[object Float64Array]"]=Yt["[object Int8Array]"]=Yt["[object Int16Array]"]=Yt["[object Int32Array]"]=Yt["[object Uint8Array]"]=Yt["[object Uint8ClampedArray]"]=Yt["[object Uint16Array]"]=Yt["[object Uint32Array]"]=!0,Yt["[object Arguments]"]=Yt["[object Array]"]=Yt["[object ArrayBuffer]"]=Yt["[object Boolean]"]=Yt["[object DataView]"]=Yt["[object Date]"]=Yt["[object Error]"]=Yt["[object Function]"]=Yt["[object Map]"]=Yt["[object Number]"]=Yt["[object Object]"]=Yt["[object RegExp]"]=Yt["[object Set]"]=Yt["[object String]"]=Yt["[object WeakMap]"]=!1;var Qt,Xt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Zt=Xt&&"object"==typeof module&&module&&!module.nodeType&&module,te=Zt&&Zt.exports===Xt&&C.process,ee=function(){try{var t=Zt&&Zt.require&&Zt.require("util").types;return t||te&&te.binding&&te.binding("util")}catch(t){}}(),re=ee&&ee.isTypedArray,ne=re?(Qt=re,function(t){return Qt(t)}):function(t){return V(t)&&Wt(t.length)&&!!Yt[K(t)]},oe=Object.prototype.hasOwnProperty;function ie(t,e){var r=I(t),n=!r&&Mt(t),o=!r&&!n&&Lt(t),i=!r&&!n&&!o&&ne(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},je.prototype.set=function(t,e){var r=this.__data__,n=_e(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var Oe,Se=N["__core-js_shared__"],Ee=(Oe=/[^.]+$/.exec(Se&&Se.keys&&Se.keys.IE_PROTO||""))?"Symbol(src)_1."+Oe:"";var Ae=Function.prototype.toString;function ke(t){if(null!=t){try{return Ae.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var Te=/^\[object .+?Constructor\]$/,xe=Function.prototype,qe=Object.prototype,Pe=xe.toString,Ce=qe.hasOwnProperty,$e=RegExp("^"+Pe.call(Ce).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ne(t){return!(!fe(t)||function(t){return!!Ee&&Ee in t}(t))&&(ve(t)?$e:Te).test(ke(t))}function ze(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return Ne(r)?r:void 0}var Fe=ze(N,"Map"),Ie=ze(Object,"create");var Re="__lodash_hash_undefined__",Je=Object.prototype.hasOwnProperty;var Me=Object.prototype.hasOwnProperty;var Ue="__lodash_hash_undefined__";function De(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&Qe?new Ge:void 0;for(i.set(t,e),i.set(e,t);++f0){if(++e>=Jn)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Rn);function Hn(t,e){return Dn(function(t,e,r){return e=In(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=In(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Ln.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!fe(r))return!1;var n=typeof e;return!!("number"==n?ge(r)&&Vt(e,r.length):"string"==n&&e in r)&&me(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0))},po=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},ho=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!fo(e)(t)})).length)})).length:e.length>e.filter((function(t){return!lo(r,t)})).length},vo=function(t,e){if(void 0===e&&(e=null),Ct(t)){if(!e)return!0;if(lo(e))return!e.filter((function(e){var r=t[e.name];return!(e.type.length>e.type.filter((function(t){var e;return!!bt(r)||(!1!==(e=po(t))?!ho({arg:r},e):!fo(t)(r))})).length)})).length}return!1},go=function(t){var e=t.arg,r=t.param,n=[e];return Array.isArray(r.keys)&&r.keys.length&&n.push(r.keys),vo.apply(null,n)};function yo(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,console,t)}catch(t){}}var bo=function(t,e){var r;switch(!0){case"object"===t:return!go(e);case"array"===t:return!lo(e.arg);case!1!==(r=po(t)):return!ho(e,r);default:return!fo(t)(e.arg)}},mo=function(t,e){return bt(t)?!0!==e.optional||bt(e.defaultvalue)?null:e.defaultvalue:t},_o=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!lo(e))throw new S("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!lo(t))throw new S("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return yo(1),t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:yo(2);var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:yo(4);var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?mo(t,a):t,index:r,param:a,optional:i}}));default:throw yo(5),new S("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!Xn(e)&&!(r.type.length>r.type.filter((function(e){return bo(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return bo(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},wo=function(t,e){var r,n=Object.keys(t);return r=e,!!n.filter((function(t){return t===r})).length},jo=function(t){return!Xn(t)};function Oo(t,e){var r=Qn(e,(function(t,e){return!t[co]}));return Hr(r,{})?t:function(t,e){var r={};return e=gn(e),be(t,(function(t,n,o){bn(r,e(t,n,o),t)})),r}(t,(function(t,e){return function(t,e,r){var n;return r(t,(function(t,r,o){if(e(t,r,o))return n=r,!1})),n}(r,gn((function(t){return t.alias===e})),be)||e}))}function So(t,e){return Kn(e,(function(e,r){var n,o;return bt(t[r])||!0===e[oo]&&jo(t[r])?Bn({},e,((n={})[so]=!0,n)):((o={})[ao]=t[r],o[no]=e[no],o[oo]=e[oo]||!1,o[io]=e[io]||!1,o[uo]=e[uo]||!1,o)}))}function Eo(t,e){var r=function(t,e){var r=Oo(t,e);return{pristineValues:Kn(Qn(e,(function(t,e){return wo(r,e)})),(function(t){return t.args})),checkAgainstAppProps:Qn(e,(function(t,e){return!wo(r,e)})),config:r}}(t,e),n=r.config,o=r.pristineValues;return[So(n,r.checkAgainstAppProps),o]}var Ao=function(t){return lo(t)?t:[t]};var ko=function(t,e){return!lo(e)||function(t,e){return!!t.filter((function(t){return t===e})).length}(e,t)},To=function(t,e){try{return!!ve(e)&&e.apply(null,[t])}catch(t){return!1}};function xo(t){return function(e,r){if(e[so])return e[ao];var n=function(t,e){var r,n=[[t[ao]],[(r={},r[no]=Ao(t[no]),r[oo]=t[oo],r)]];return Reflect.apply(e,null,n)}(e,t);if(n.length)throw yo("runValidationAction",r,e),new w(r,n);if(!1!==e[io]&&!ko(e[ao],e[io]))throw yo(io,e[io]),new _(r);if(!1!==e[uo]&&!To(e[ao],e[uo]))throw yo(uo,e[uo]),new j(r);return e[ao]}}function qo(t,e,r,n){return void 0===t&&(t={}),Bn(function(t,e){var r=t[0],n=t[1],o=Kn(r,xo(e));return Bn(o,n)}(Eo(t,e),n),r)}function Po(t,e,r,s,f,l){void 0===r&&(r=!1),void 0===s&&(s=!1),void 0===f&&(f=!1),void 0===l&&(l=!1);var p={};return p[a]=t,p[n]=e,!0===r&&(p[o]=!0),lo(s)&&(p[i]=s),ve(f)&&(p[u]=f),Ot(l)&&(p[c]=l),p}var Co=to,$o=lo,No=function(t,e,r){return void 0===r&&(r=!1),new Promise((function(n,o){var i=_o(t,e,r);return r?i.error.length?o(i.error):n(i.data):i.length?o(i):n([])}))},zo=function(t,e,r){void 0===r&&(r={});var n=r[o],a=r[i],s=r[u],f=r[c];return Po.apply(null,[t,e,n,a,s,f])},Fo=function(t){return function(e,r,n){return void 0===n&&(n={}),qo(e,r,n,t)}}(_o),Io=function(t){return I(t)?t:[t]},Ro=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,Io(t))}),Reflect.apply(t,null,r))}};function Jo(t,e,r,n){void 0===n&&(n=!1);var o=function(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Mo=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return No(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(q)}},Uo=function(t,e,r,n,o){var i={},a=function(t){i=Jo(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return No(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(q)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Do=function(t,e,r,n,o){var i={},a=function(t){i=Jo(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return No(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(q)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Ho=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Mo(e,a,0,o);return i.apply(null,t).then(e.postLoginAction).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Mo(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var Lo=Array.isArray,Bo=void 0!==P?P:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Ko="object"==typeof Bo&&Bo&&Bo.Object===Object&&Bo,Vo="object"==typeof self&&self&&self.Object===Object&&self,Go=(Ko||Vo||Function("return this")()).Symbol,Wo=Object.prototype,Yo=Wo.hasOwnProperty,Qo=Wo.toString,Xo=Go?Go.toStringTag:void 0;var Zo=Object.prototype.toString;var ti="[object Null]",ei="[object Undefined]",ri=Go?Go.toStringTag:void 0;function ni(t){return null==t?void 0===t?ei:ti:ri&&ri in Object(t)?function(t){var e=Yo.call(t,Xo),r=t[Xo];try{t[Xo]=void 0;var n=!0}catch(t){}var o=Qo.call(t);return n&&(e?t[Xo]=r:delete t[Xo]),o}(t):function(t){return Zo.call(t)}(t)}var oi=function(t,e){return function(r){return t(e(r))}}(Object.getPrototypeOf,Object);function ii(t){return null!=t&&"object"==typeof t}var ai="[object Object]",ui=Function.prototype,ci=Object.prototype,si=ui.toString,fi=ci.hasOwnProperty,li=si.call(Object);var pi=Go?Go.prototype:void 0,hi=(pi&&pi.toString,"[object String]");function di(t){return"string"==typeof t||!Lo(t)&&ii(t)&&ni(t)==hi}var vi=function(t,e){return!!t.filter((function(t){return t===e})).length},gi=function(t,e){var r=Object.keys(t);return vi(r,e)},yi=function(){for(var t=arguments,e=[],r=arguments.length;r--;)e[r]=t[r];return e.join("_")},bi=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},mi="query",_i="mutation",wi="socket",ji="payload",Oi="condition",Si=function(){try{if(window||document)return!0}catch(t){}return!1},Ei=function(){try{if(!Si()&&Bo)return!0}catch(t){}return!1};var Ai=function(t){function e(){for(var r=arguments,n=[],o=arguments.length;o--;)n[o]=r[o];t.apply(this,n),this.message=n[0],this.detail=n[1],this.className=e.name,Error.captureStackTrace&&Error.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(function(t){function e(){for(var e=arguments,r=[],n=arguments.length;n--;)r[n]=e[n];t.apply(this,r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.where=function(){return Si()?"browser":Ei()?"node":"unknown"},e}(Error));var ki=function(t){var e;return(e={}).args=t,e};var Ti=function(t){return gi(t,"data")&&!gi(t,"error")?t.data:t},xi=function(t){return function(t){if(!ii(t)||ni(t)!=ai)return!1;var e=oi(t);if(null===e)return!0;var r=fi.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&si.call(r)==li}(t)&&(gi(t,mi)||gi(t,_i)||gi(t,wi))},qi=function(t,e){return void 0===e&&(e={}),xi(e)?Promise.resolve(e):t.getContract()},Pi=function(t,e){return function(r){for(var n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return new Promise((function(o,i){t.$only(yi(e,r,p),o),t.$only(yi(e,r,h),i),t.$trigger(e,{resolverName:r,args:n})}))}},Ci=function(t,e,r){var n=t.$queues,o=r.debugOn;o&&console.info("(validateRegisteredEvents)","storedEvt",n),n.forEach((function(t){var r=t[0],n=t[1].resolverName;if(o&&console.info("(validateRegisteredEvents)",r,n),!e[r][n])throw new Error(r+"."+n+" not existed in contract!")}))};function $i(t,e,r,n){var o=function(t,e,r,n){return Ro(Uo,Do,Ho)({},t,e,r,n)}(t,e,r,n);Ci(e,n,r);var i=function(t){e.$only(t,(function(r){var n=r.resolverName,i=r.args;o[t][n]?Reflect.apply(o[t][n],null,i).then((function(r){e.$trigger(yi(t,n,p),r)})).catch((function(r){e.$trigger(yi(t,n,h),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}var Ni=function(t,e,r,n){n.$suspend=!0,r.then((function(r){$i(t,n,e,r)}));var o={query:Pi(n,"query"),mutation:Pi(n,"mutation"),auth:Pi(n,"auth"),getToken:function(){return t.rawAuthToken}};return e.exposeContract&&(o.getContract=function(){return t.get()}),e.enableAuth&&(o.userdata=function(){return t.userdata}),o.version="1.4.7",o},zi="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var Fi=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=oa().key(e);t(ia(r),r)}},remove:function(t){return oa().removeItem(t)},clearAll:function(){return oa().clear()}};function oa(){return ra.localStorage}function ia(t){return oa().getItem(t)}var aa=Mi.trim,ua={name:"cookieStorage",read:function(t){if(!t||!la(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(ca.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;ca.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:sa,remove:fa,clearAll:function(){sa((function(t,e){fa(e)}))}},ca=Mi.Global.document;function sa(t){for(var e=ca.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(aa(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function fa(t){t&&la(t)&&(ca.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function la(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(ca.cookie)}var pa=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var ha="expire_mixin",da=function(){var t=this.createStore(this.storage,null,this._namespacePrefix+ha);return{set:function(e,r,n,o){this.hasNamespace(ha)||t.set(r,o);return e()},get:function(t,r){this.hasNamespace(ha)||e.call(this,r);return t()},remove:function(e,r){this.hasNamespace(ha)||t.remove(r);return e()},getExpiration:function(e,r){return t.get(r)},removeExpiredKeys:function(t){var r=[];this.each((function(t,e){r.push(e)}));for(var n=0;n>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)}));var ja=[na,ua],Oa=[pa,da,ma,function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=wa.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=wa.compress(this._serialize(r));t(e,n)}}}],Sa=Zi.createStore(ja,Oa),Ea=Mi.Global;function Aa(){return Ea.sessionStorage}function ka(t){return Aa().getItem(t)}var Ta=[{name:"sessionStorage",read:ka,write:function(t,e){return Aa().setItem(t,e)},each:function(t){for(var e=Aa().length-1;e>=0;e--){var r=Aa().key(e);t(ka(r),r)}},remove:function(t){return Aa().removeItem(t)},clearAll:function(){return Aa().clear()}},ua],xa=[pa,da],qa=Zi.createStore(Ta,xa),Pa=Sa,Ca=qa,$a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Na(t){this.message=t}Na.prototype=new Error,Na.prototype.name="InvalidCharacterError";var za="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Na("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=$a.indexOf(n);return a};var Fa=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(za(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return za(e)}};function Ia(t){this.message=t}Ia.prototype=new Error,Ia.prototype.name="InvalidTokenError";var Ra=function(t,e){if("string"!=typeof t)throw new Ia("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Fa(t.split(".")[r]))}catch(t){throw new Ia("Invalid token specified: "+t.message)}},Ja=Ia;Ra.InvalidTokenError=Ja;var Ma,Ua,Da,Ha,La,Ba,Ka,Va,Ga,Wa=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Ya(t){if(Co(t))return function(t){var e=t.iat||Wa(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new S("Token has expired on "+r,t)}return t}(Ra(t));throw new S("Token must be a string!")}zo("HS256",["string"]),zo(!1,["boolean","number","string"],((Ma={})[c]="exp",Ma[o]=!0,Ma)),zo(!1,["boolean","number","string"],((Ua={})[c]="nbf",Ua[o]=!0,Ua)),zo(!1,["boolean","string"],((Da={})[c]="iss",Da[o]=!0,Da)),zo(!1,["boolean","string"],((Ha={})[c]="sub",Ha[o]=!0,Ha)),zo(!1,["boolean","string"],((La={})[c]="iss",La[o]=!0,La)),zo(!1,["boolean"],((Ba={})[o]=!0,Ba)),zo(!1,["boolean","string"],((Ka={})[o]=!0,Ka)),zo(!1,["boolean","string"],((Va={})[o]=!0,Va)),zo(!1,["boolean"],((Ga={})[o]=!0,Ga));var Qa=r[0],Xa=r[1],Za=function(t){!function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];try{window&&window.console&&Reflect.apply(console.log,null,t)}catch(t){}}(t),this.fly=t.Fly?new t.Fly:new Fly,this.opts=t,this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()},tu={headers:{configurable:!0}};tu.headers.set=function(t){this.extraHeader=t},Za.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=Bn({},{_cb:bi()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=Bn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}return this.fly.request(this.jsonqlEndpoint,t,Bn({},{method:Qa,params:o},e))},Za.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},Za.prototype.processJsonp=function(t){return Ti(t)},Za.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call"),e.cleanUp();var o=Co(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):Ti(o)}),(function(t){throw e.cleanUp(),console.error(t),new E("Server side error",t)}))},Za.prototype.getHeaders=function(){return this.opts.enableAuth?Bn({},e,this.getAuthHeader(),this.extraHeader):Bn({},e,this.extraHeader)},Za.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},Za.prototype.get=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=Bn({},this.extraParams,f)),this.request({},{method:"GET"},this.contractHeader).then(x).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e}))},Za.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){var n;if(void 0===e&&(e=[]),void 0===r&&(r=!1),di(t)&&Lo(e)){var o=ki(e);return!0===r?o:((n={})[t]=o,n)}throw new Ai("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(x)},Za.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){var o;void 0===r&&(r={}),void 0===n&&(n=!1);var i={};if(i[ji]=e,i[Oi]=r,!0===n)return i;if(di(t))return(o={})[t]=i,o;throw new Ai("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Xa}).then(x)},Object.defineProperties(Za.prototype,tu);var eu=function(t){function e(e,r){void 0===r&&(r=null),r&&(e.Fly=r),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={storeIt:{configurable:!0},jsonqlEndpoint:{configurable:!0},jsonqlContract:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return r.storeIt.set=function(t){throw console.info("storeIt",t),$o(t)&&t.length>=2&&Reflect.apply(Pa.set,Pa,t),new O("Expect argument to be array and least 2 items!")},r.jsonqlEndpoint.set=function(t){var e=Pa.get("endpoint")||[];vi(e,t)||(e.push(t),this.storeId=["endpoint",e],this.endpointIndex=e.length-1)},r.jsonqlContract.set=function(t){var e=this.opts.storageKey,r=[e],n=t[0],o=t[1],i=Pa.get(e)||[];i[this.endpointIndex||0]=n,r.push(i),o&&r.push(o),this.opts.keepContract&&(this.storeIt=r)},r.jsonqlToken.set=function(t){var e="credential",r=localStorage.get(e)||[];if(!vi(r,t)){var n=r.length-1;r[n]=t,this[e+"Index"]=n;var o=[e,r];if(this.opts.tokenExpired){var i=parseFloat(this.opts.tokenExpired);if(!isNaN(i)&&i>0){var a=bi();o.push(a+parseFloat(i))}}return this.storeIt=o,this.jsonqlUserdata=this.decoder(t),t}return!1},r.jsonqlUserdata.set=function(t){var e=["userdata",t];return t.exp&&e.push(t.exp),Reflect.apply(Pa.set,Pa,e)},r.jsonqlEndpoint.get=function(){var t=Pa.get("endpoint");if(!t){var e=this.opts,r=[e.hostname,e.jsonqlPath].join("/");return this.jsonqlEndpoint=r,r}return t[this.endpointIndex]},r.jsonqlContract.get=function(){var t=this.opts.storageKey;return(Pa.get(t)||[])[this.endpointIndex]||!1},r.jsonqlToken.get=function(){var t="credential",e=localStorage.get(t);return!!e&&e[this[t+"Index"]]},r.jsonqlUserdata.get=function(){return Ca.get("userdata")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&e.useJwt&&(this.setDecoder=Ya)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={userdata:{configurable:!0},rawAuthToken:{configurable:!0},setDecoder:{configurable:!0}};return r.userdata.get=function(){return this.jsonqlUserdata},r.rawAuthToken.get=function(){return this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},e.prototype.storeToken=function(t){return this.jsonqlToken=t},e.prototype.decoder=function(t){return t},e.prototype.getAuthHeader=function(){var t,e=this.rawAuthToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();if(this.log("getContract first call",t),t&&Array.isArray(t)){var e=t[this.endpointIndex||0];if(e)return Promise.resolve(e)}return this.get().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){if(!xi(t))throw new O("Contract is malformed!");var e=[t];if(this.opts.contractExpired){var r=parseFloat(this.opts.contractExpired);!isNaN(r)&&r>0&&e.push(r)}return this.jsonqlContract=e,this.log("storeContract return result",t),t},e.prototype.readContract=function(){return xi(this.opts.contract)?this.opts.contract:Pa.get(this.opts.storageKey)},Object.defineProperties(e.prototype,r),e}(Za))),ru={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:t,BEARER:"Bearer",AUTH_HEADER:"Authorization"},nu={hostname:zo(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:zo("jsonql",["string"]),loginHandlerName:zo("login",["string"]),logoutHandlerName:zo("logout",["string"]),enableJsonp:zo(!1,["boolean"]),enableAuth:zo(!1,["boolean"]),useJwt:zo(!0,["boolean"]),useLocalstorage:zo(!0,["boolean"]),storageKey:zo("storageKey",["string"]),authKey:zo("authKey",["string"]),contractExpired:zo(0,["number"]),keepContract:zo(!0,["boolean"]),exposeContract:zo(!1,["boolean"]),showContractDesc:zo(!1,["boolean"]),contractKey:zo(!1,["boolean"]),contractKeyName:zo("X-JSONQL-CV-KEY",["string"]),enableTimeout:zo(!1,["boolean"]),timeout:zo(5e3,["number"]),returnInstance:zo(!1,["boolean"]),allowReturnRawToken:zo(!1,["boolean"]),debugOn:zo(!1,["boolean"])};function ou(t){return t[s]?t:function(t){return Fo(t,nu,ru)}(t)}var iu=new WeakMap,au=new WeakMap;var uu=function(){this.__suspend__=null,this.queueStore=new Set},cu={$suspend:{configurable:!0},$queues:{configurable:!0}};cu.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},uu.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},cu.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},uu.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(uu.prototype,cu);var su=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){iu.set(this,t)},r.normalStore.get=function(){return iu.get(this)},r.lazyStore.set=function(t){au.set(this,t)},r.lazyStore.get=function(){return au.get(this)},e.prototype.hashFnToKey=function(t){return t.toString().split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)+""},Object.defineProperties(e.prototype,r),e}(uu));return function(t,e){void 0===e&&(e={});var r,n=e.contract,o=ou(e),i=new eu(o,t),a=qi(i,n),u=(r=o.debugOn,new su({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),c=Ni(i,o,a,u);return c.eventEmitter=u,c}})); //# sourceMappingURL=static.js.map